import { Hex } from 'viem';
import { StaticAbiType, DynamicAbiType } from '@latticexyz/schema-type/internal';
export { DynamicAbiType, StaticAbiType } from '@latticexyz/schema-type/internal';
import { ResourceType } from '@latticexyz/common';
import { satisfy } from '@latticexyz/common/type-utils';

/**
 * Common output types of a MUD config. We use these types as inputs for libraries.
 */
type AbiType = StaticAbiType | DynamicAbiType;

type Schema = {
    readonly [fieldName: string]: {
        /** the Solidity primitive ABI type */
        readonly type: AbiType;
        /** the user defined type or Solidity primitive ABI type */
        readonly internalType: string;
    };
};
type Table = {
    readonly type: satisfy<ResourceType, "table" | "offchainTable">;
    readonly name: string;
    readonly namespace: string;
    readonly tableId: Hex;
    readonly schema: Schema;
    readonly key: readonly string[];
};

export { AbiType, Schema, Table };
