@latticexyz/store 2.2.18-ebe1aea8d4afb690ce1c7c2bcb42dc0f1faf6e77 → 2.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-FULF4J63.js +460 -0
- package/dist/{chunk-5YJ4WITG.js.map → chunk-FULF4J63.js.map} +1 -1
- package/dist/chunk-ZBDA5HOY.js +27 -0
- package/dist/{chunk-4TACS4IT.js.map → chunk-ZBDA5HOY.js.map} +1 -1
- package/dist/codegen.js +1005 -210
- package/dist/codegen.js.map +1 -1
- package/dist/index.js +22 -1
- package/dist/internal.js +302 -1
- package/dist/internal.js.map +1 -1
- package/dist/mud.config.js +60 -1
- package/dist/mud.config.js.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-4TACS4IT.js +0 -2
- package/dist/chunk-5YJ4WITG.js +0 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../ts/config/v2/generics.ts","../ts/config/v2/defaults.ts","../ts/config/v2/scope.ts","../ts/config/v2/schema.ts","../ts/config/v2/table.ts","../ts/config/v2/tableShorthand.ts","../ts/config/v2/tables.ts","../ts/config/v2/userTypes.ts","../ts/config/v2/enums.ts","../ts/config/v2/codegen.ts","../ts/config/v2/namespace.ts","../ts/config/v2/namespaces.ts","../ts/config/v2/flattenNamespacedTables.ts","../ts/config/v2/store.ts"],"sourcesContent":["// TODO: move to common/utils\n\nexport type get<input, key> = key extends keyof input ? input[key] : undefined;\n\nexport function get<input, key extends PropertyKey>(input: input, key: key): get<input, key> {\n return (typeof input === \"object\" && input != null && hasOwnKey(input, key) ? input[key] : undefined) as never;\n}\n\nexport type getPath<input, path extends readonly PropertyKey[]> = path extends readonly [\n infer head,\n ...infer tail extends PropertyKey[],\n]\n ? head extends keyof input\n ? getPath<input[head], tail>\n : undefined\n : input;\n\nexport function getPath<input, path extends readonly PropertyKey[]>(input: input, path: path): getPath<input, path> {\n return path.length ? (getPath(get(input, path[0]), path.slice(1)) as never) : (input as never);\n}\n\nexport function hasOwnKey<obj, const key extends PropertyKey>(\n object: obj,\n key: key,\n): object is { [k in key]: k extends keyof obj ? obj[k] : unknown } & obj {\n // eslint-disable-next-line no-prototype-builtins\n return typeof object === \"object\" && object !== null && object.hasOwnProperty(key);\n}\n\nexport function isObject<input>(input: input): input is input & object {\n return input != null && typeof input === \"object\";\n}\n\nexport type mergeIfUndefined<base, defaults> = {\n readonly [key in keyof base | keyof defaults]: key extends keyof base\n ? undefined extends base[key]\n ? key extends keyof defaults\n ? defaults[key]\n : base[key]\n : base[key]\n : key extends keyof defaults\n ? defaults[key]\n : never;\n};\n\nexport function mergeIfUndefined<base extends object, defaults extends object>(\n base: base,\n defaults: defaults,\n): mergeIfUndefined<base, defaults> {\n const keys = [...new Set([...Object.keys(base), ...Object.keys(defaults)])];\n return Object.fromEntries(\n keys.map((key) => [\n key,\n typeof base[key as keyof base] === \"undefined\" ? defaults[key as keyof defaults] : base[key as keyof base],\n ]),\n ) as never;\n}\n\nexport type parseNumber<T> = T extends `${infer N extends number}` ? N : never;\n","import { CodegenInput, StoreInput, TableCodegenInput, TableDeployInput, TableInput } from \"./input\";\n\nexport const CODEGEN_DEFAULTS = {\n storeImportPath: \"@latticexyz/store/src\",\n userTypesFilename: \"common.sol\",\n outputDirectory: \"codegen\",\n indexFilename: \"index.sol\",\n} as const satisfies CodegenInput;\n\nexport type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;\n\nexport const TABLE_CODEGEN_DEFAULTS = {\n outputDirectory: \"tables\" as string,\n tableIdArgument: false,\n storeArgument: false,\n} as const satisfies TableCodegenInput;\n\nexport type TABLE_CODEGEN_DEFAULTS = typeof TABLE_CODEGEN_DEFAULTS;\n\nexport const TABLE_DEPLOY_DEFAULTS = {\n disabled: false,\n} as const satisfies TableDeployInput;\n\nexport type TABLE_DEPLOY_DEFAULTS = typeof TABLE_DEPLOY_DEFAULTS;\n\nexport const TABLE_DEFAULTS = {\n namespaceLabel: \"\",\n type: \"table\",\n} as const satisfies Pick<TableInput, \"namespaceLabel\" | \"type\">;\n\nexport type TABLE_DEFAULTS = typeof TABLE_DEFAULTS;\n\nexport const CONFIG_DEFAULTS = {\n sourceDirectory: \"src\",\n namespace: \"\",\n} as const satisfies StoreInput;\n\nexport type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;\n","import { Dict, show } from \"@ark/util\";\nimport { SchemaInput } from \"./input\";\nimport { StaticAbiType, schemaAbiTypes } from \"@latticexyz/schema-type/internal\";\nimport { AbiType } from \"./output\";\n\nexport const Scope = { types: {} } as const satisfies ScopeOptions;\nexport type Scope = typeof Scope;\n\nexport type AbiTypeScope = ScopeOptions<{ [t in AbiType]: t }>;\nexport const AbiTypeScope = {\n types: Object.fromEntries(schemaAbiTypes.map((abiType) => [abiType, abiType])),\n} as AbiTypeScope;\n\nexport type ScopeOptions<types extends Dict<string, AbiType> = Dict<string, AbiType>> = {\n types: types;\n};\n\nexport type getStaticAbiTypeKeys<\n schema extends SchemaInput,\n scope extends Scope = AbiTypeScope,\n> = SchemaInput extends schema\n ? string\n : {\n [key in keyof schema]: scope[\"types\"] extends { [_ in schema[key]]: StaticAbiType } ? key : never;\n }[keyof schema];\n\nexport type extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>> = show<\n ScopeOptions<show<scope[\"types\"] & additionalTypes>>\n>;\n\nexport function extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>>(\n scope: scope,\n additionalTypes: additionalTypes,\n): extendScope<scope, additionalTypes> {\n return {\n types: {\n ...scope.types,\n ...additionalTypes,\n },\n };\n}\n","import { conform, show } from \"@ark/util\";\nimport { AbiTypeScope, Scope } from \"./scope\";\nimport { hasOwnKey, isObject } from \"./generics\";\nimport { SchemaInput } from \"./input\";\nimport { FixedArrayAbiType, fixedArrayToArray, isFixedArrayAbiType } from \"@latticexyz/schema-type/internal\";\n\nexport type validateSchema<schema, scope extends Scope = AbiTypeScope> = schema extends string\n ? SchemaInput\n : {\n [key in keyof schema]: schema[key] extends FixedArrayAbiType\n ? schema[key]\n : conform<schema[key], keyof scope[\"types\"]>;\n };\n\nexport function validateSchema<scope extends Scope = AbiTypeScope>(\n schema: unknown,\n scope: scope = AbiTypeScope as never,\n): asserts schema is SchemaInput {\n if (!isObject(schema)) {\n throw new Error(`Expected schema, received ${JSON.stringify(schema)}`);\n }\n\n for (const internalType of Object.values(schema)) {\n if (isFixedArrayAbiType(internalType)) continue;\n if (hasOwnKey(scope.types, internalType)) continue;\n throw new Error(`\"${String(internalType)}\" is not a valid type in this scope.`);\n }\n}\n\nexport type resolveSchema<schema, scope extends Scope> = show<{\n readonly [key in keyof schema]: {\n /** the Solidity primitive ABI type */\n readonly type: schema[key] extends FixedArrayAbiType\n ? fixedArrayToArray<schema[key]>\n : scope[\"types\"][schema[key] & keyof scope[\"types\"]];\n /** the user defined type or Solidity primitive ABI type */\n readonly internalType: schema[key];\n };\n}>;\n\nexport function resolveSchema<schema extends SchemaInput, scope extends Scope = AbiTypeScope>(\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveSchema<schema, scope> {\n return Object.fromEntries(\n Object.entries(schema).map(([key, internalType]) => [\n key,\n {\n type: isFixedArrayAbiType(internalType) ? fixedArrayToArray(internalType) : scope.types[internalType as never],\n internalType,\n },\n ]),\n ) as never;\n}\n\nexport function defineSchema<schema, scope extends AbiTypeScope = AbiTypeScope>(\n schema: validateSchema<schema, scope>,\n scope: scope = AbiTypeScope as scope,\n): resolveSchema<schema, scope> {\n validateSchema(schema, scope);\n return resolveSchema(schema, scope) as never;\n}\n\nexport function isSchemaInput<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope = AbiTypeScope as never,\n): input is SchemaInput {\n return (\n typeof input === \"object\" &&\n input != null &&\n Object.values(input).every((fieldType) => isFixedArrayAbiType(fieldType) || hasOwnKey(scope.types, fieldType))\n );\n}\n","import { ErrorMessage, conform, show, narrow, requiredKeyOf } from \"@ark/util\";\nimport { isStaticAbiType } from \"@latticexyz/schema-type/internal\";\nimport { Hex } from \"viem\";\nimport { get, hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { resolveSchema, validateSchema } from \"./schema\";\nimport { AbiTypeScope, Scope, getStaticAbiTypeKeys } from \"./scope\";\nimport { TableCodegen } from \"./output\";\nimport { TABLE_CODEGEN_DEFAULTS, TABLE_DEFAULTS, TABLE_DEPLOY_DEFAULTS } from \"./defaults\";\nimport { resourceToHex } from \"@latticexyz/common\";\nimport { SchemaInput, TableInput } from \"./input\";\n\nexport type ValidKeys<schema extends SchemaInput, scope extends Scope> = readonly [\n getStaticAbiTypeKeys<schema, scope>,\n ...getStaticAbiTypeKeys<schema, scope>[],\n];\n\nfunction getValidKeys<schema extends SchemaInput, scope extends Scope = AbiTypeScope>(\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): ValidKeys<schema, scope> {\n return Object.entries(schema)\n .filter(([, internalType]) => hasOwnKey(scope.types, internalType) && isStaticAbiType(scope.types[internalType]))\n .map(([key]) => key) as never;\n}\n\nexport function isValidPrimaryKey<schema extends SchemaInput, scope extends Scope>(\n key: unknown,\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): key is ValidKeys<schema, scope> {\n return (\n Array.isArray(key) &&\n key.every(\n (key) =>\n hasOwnKey(schema, key) && hasOwnKey(scope.types, schema[key]) && isStaticAbiType(scope.types[schema[key]]),\n )\n );\n}\n\nexport type validateKeys<validKeys extends PropertyKey, keys> = keys extends readonly string[]\n ? {\n readonly [i in keyof keys]: keys[i] extends validKeys ? keys[i] : validKeys;\n }\n : readonly string[];\n\nexport type ValidateTableOptions = { inStoreContext: boolean };\n\nexport type requiredTableKey<inStoreContext extends boolean> = Exclude<\n requiredKeyOf<TableInput>,\n inStoreContext extends true ? \"label\" | \"namespaceLabel\" | \"namespace\" : never\n>;\n\nexport type validateTable<\n input,\n scope extends Scope = AbiTypeScope,\n options extends ValidateTableOptions = { inStoreContext: false },\n> = {\n [key in keyof input | requiredTableKey<options[\"inStoreContext\"]>]: key extends \"key\"\n ? validateKeys<getStaticAbiTypeKeys<conform<get<input, \"schema\">, SchemaInput>, scope>, get<input, key>>\n : key extends \"schema\"\n ? validateSchema<get<input, key>, scope>\n : key extends \"label\" | \"namespaceLabel\" | \"namespace\"\n ? options[\"inStoreContext\"] extends true\n ? ErrorMessage<\"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for tables in this context\">\n : key extends keyof input\n ? narrow<input[key]>\n : never\n : key extends keyof TableInput\n ? TableInput[key]\n : ErrorMessage<`Key \\`${key & string}\\` does not exist in TableInput`>;\n};\n\nexport function validateTable<input, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as unknown as scope,\n options: ValidateTableOptions = { inStoreContext: false },\n): asserts input is TableInput & input {\n if (typeof input !== \"object\" || input == null) {\n throw new Error(`Expected full table config, got \\`${JSON.stringify(input)}\\``);\n }\n\n if (!hasOwnKey(input, \"schema\")) {\n throw new Error(\"Missing schema input\");\n }\n validateSchema(input.schema, scope);\n\n if (!hasOwnKey(input, \"key\") || !isValidPrimaryKey(input[\"key\"], input[\"schema\"], scope)) {\n throw new Error(\n `Invalid key. Expected \\`(${getValidKeys(input[\"schema\"], scope)\n .map((item) => `\"${String(item)}\"`)\n .join(\" | \")})[]\\`, received \\`${\n hasOwnKey(input, \"key\") && Array.isArray(input.key)\n ? `[${input.key.map((item) => `\"${item}\"`).join(\", \")}]`\n : String(get(input, \"key\"))\n }\\``,\n );\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`Table \\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n\n if (\n hasOwnKey(input, \"namespaceLabel\") &&\n typeof input.namespaceLabel === \"string\" &&\n (!hasOwnKey(input, \"namespace\") || typeof input.namespace !== \"string\") &&\n input.namespaceLabel.length > 14\n ) {\n throw new Error(\n `Table \\`namespace\\` defaults to \\`namespaceLabel\\`, but must fit into a \\`bytes14\\` and \"${input.namespaceLabel}\" is too long. Provide explicit \\`namespace\\` override.`,\n );\n }\n\n if (hasOwnKey(input, \"name\") && typeof input.name === \"string\" && input.name.length > 16) {\n throw new Error(`Table \\`name\\` must fit into a \\`bytes16\\`, but \"${input.name}\" is too long.`);\n }\n\n if (\n options.inStoreContext &&\n (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespaceLabel\") || hasOwnKey(input, \"namespace\"))\n ) {\n throw new Error(\n \"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for tables in this context.\",\n );\n }\n}\n\nexport type resolveTableCodegen<input extends TableInput> = show<{\n [key in keyof TableCodegen]-?: key extends keyof input[\"codegen\"]\n ? undefined extends input[\"codegen\"][key]\n ? key extends \"dataStruct\"\n ? boolean\n : key extends keyof TABLE_CODEGEN_DEFAULTS\n ? TABLE_CODEGEN_DEFAULTS[key]\n : never\n : input[\"codegen\"][key]\n : // dataStruct isn't narrowed, because its value is conditional on the number of value schema fields\n key extends \"dataStruct\"\n ? boolean\n : key extends keyof TABLE_CODEGEN_DEFAULTS\n ? TABLE_CODEGEN_DEFAULTS[key]\n : never;\n}>;\n\nexport function resolveTableCodegen<input extends TableInput>(input: input): resolveTableCodegen<input> {\n const options = input.codegen;\n return {\n outputDirectory: get(options, \"outputDirectory\") ?? TABLE_CODEGEN_DEFAULTS.outputDirectory,\n tableIdArgument: get(options, \"tableIdArgument\") ?? TABLE_CODEGEN_DEFAULTS.tableIdArgument,\n storeArgument: get(options, \"storeArgument\") ?? TABLE_CODEGEN_DEFAULTS.storeArgument,\n // dataStruct is true if there are at least 2 value fields\n dataStruct: get(options, \"dataStruct\") ?? Object.keys(input.schema).length - input.key.length > 1,\n } satisfies TableCodegen as never;\n}\n\nexport type resolveTable<input, scope extends Scope = Scope> = input extends TableInput\n ? {\n readonly label: input[\"label\"];\n readonly namespaceLabel: undefined extends input[\"namespaceLabel\"]\n ? typeof TABLE_DEFAULTS.namespaceLabel\n : input[\"namespaceLabel\"];\n readonly type: undefined extends input[\"type\"] ? typeof TABLE_DEFAULTS.type : input[\"type\"];\n readonly namespace: string;\n readonly name: string;\n readonly tableId: Hex;\n readonly schema: resolveSchema<input[\"schema\"], scope>;\n readonly key: Readonly<input[\"key\"]>;\n readonly codegen: resolveTableCodegen<input>;\n readonly deploy: show<\n mergeIfUndefined<undefined extends input[\"deploy\"] ? {} : input[\"deploy\"], TABLE_DEPLOY_DEFAULTS>\n >;\n }\n : never;\n\nexport function resolveTable<input extends TableInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveTable<input, scope> {\n const namespaceLabel = input.namespaceLabel ?? TABLE_DEFAULTS.namespaceLabel;\n // validate ensures this is length constrained\n const namespace = input.namespace ?? namespaceLabel;\n\n const label = input.label;\n const name = input.name ?? label.slice(0, 16);\n const type = input.type ?? TABLE_DEFAULTS.type;\n const tableId = resourceToHex({ type, namespace, name });\n\n return {\n label,\n type,\n namespace,\n namespaceLabel,\n name,\n tableId,\n schema: resolveSchema(input.schema, scope),\n key: input.key,\n codegen: resolveTableCodegen(input),\n deploy: mergeIfUndefined(input.deploy ?? {}, TABLE_DEPLOY_DEFAULTS),\n } as never;\n}\n\nexport function defineTable<input, scope extends Scope = AbiTypeScope>(\n input: validateTable<input, scope>,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveTable<input, scope> {\n validateTable(input, scope);\n return resolveTable(input, scope) as never;\n}\n","import { FixedArrayAbiType, isFixedArrayAbiType, isStaticAbiType } from \"@latticexyz/schema-type/internal\";\nimport { hasOwnKey, isObject } from \"./generics\";\nimport { SchemaInput, ScopedSchemaInput, TableShorthandInput } from \"./input\";\nimport { isSchemaInput } from \"./schema\";\nimport { AbiTypeScope, Scope, getStaticAbiTypeKeys } from \"./scope\";\nimport { ErrorMessage, conform } from \"@ark/util\";\n\nexport const NoStaticKeyFieldError =\n \"Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.\";\n\nexport type NoStaticKeyFieldError = ErrorMessage<typeof NoStaticKeyFieldError>;\n\nexport function isTableShorthandInput(shorthand: unknown): shorthand is TableShorthandInput {\n return (\n typeof shorthand === \"string\" ||\n (isObject(shorthand) && Object.values(shorthand).every((value) => typeof value === \"string\"))\n );\n}\n\n// We don't use `conform` here because the restrictions we're imposing here are not native to typescript\nexport type validateTableShorthand<input, scope extends Scope = AbiTypeScope> = input extends SchemaInput\n ? // If a shorthand schema is provided, require it to have a static `id` field\n \"id\" extends getStaticAbiTypeKeys<input, scope>\n ? // Require all values to be valid types in this scope\n conform<input, ScopedSchemaInput<scope>>\n : NoStaticKeyFieldError\n : // If a fixed array type or a valid type from the scope is provided, accept it\n input extends FixedArrayAbiType | keyof scope[\"types\"]\n ? input\n : // If the input is not a valid shorthand, return the expected type\n input extends string\n ? keyof scope[\"types\"]\n : ScopedSchemaInput<scope>;\n\nexport function validateTableShorthand<scope extends Scope = AbiTypeScope>(\n shorthand: unknown,\n scope: scope = AbiTypeScope as never,\n): asserts shorthand is TableShorthandInput {\n if (typeof shorthand === \"string\") {\n if (isFixedArrayAbiType(shorthand) || hasOwnKey(scope.types, shorthand)) {\n return;\n }\n throw new Error(`Invalid ABI type. \\`${shorthand}\\` not found in scope.`);\n }\n if (typeof shorthand === \"object\" && shorthand !== null) {\n if (isSchemaInput(shorthand, scope)) {\n if (hasOwnKey(shorthand, \"id\") && isStaticAbiType(scope.types[shorthand.id as keyof typeof scope.types])) {\n return;\n }\n throw new Error(`Invalid schema. Expected an \\`id\\` field with a static ABI type or an explicit \\`key\\` option.`);\n }\n throw new Error(`Invalid schema. Are you using invalid types or missing types in your scope?`);\n }\n throw new Error(`Invalid table shorthand.`);\n}\n\nexport type expandTableShorthand<shorthand> = shorthand extends string\n ? {\n readonly schema: {\n readonly id: \"bytes32\";\n readonly value: shorthand;\n };\n readonly key: [\"id\"];\n }\n : shorthand extends SchemaInput\n ? {\n readonly schema: shorthand;\n readonly key: [\"id\"];\n }\n : shorthand;\n\nexport function expandTableShorthand<shorthand, scope extends Scope = AbiTypeScope>(\n shorthand: shorthand,\n scope: scope,\n): expandTableShorthand<shorthand> {\n if (typeof shorthand === \"string\") {\n return {\n schema: {\n id: \"bytes32\",\n value: shorthand,\n },\n key: [\"id\"],\n } as never;\n }\n\n if (isSchemaInput(shorthand, scope)) {\n return {\n schema: shorthand,\n key: [\"id\"],\n } as never;\n }\n\n return shorthand as never;\n}\n\nexport function defineTableShorthand<input, scope extends Scope = AbiTypeScope>(\n input: validateTableShorthand<input, scope>,\n scope: scope = AbiTypeScope as unknown as scope,\n): expandTableShorthand<input> {\n validateTableShorthand(input, scope);\n return expandTableShorthand(input, scope) as never;\n}\n","import { ErrorMessage, show } from \"@ark/util\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\nimport { TableShorthandInput, TablesInput } from \"./input\";\nimport { Scope, AbiTypeScope } from \"./scope\";\nimport { validateTable, resolveTable } from \"./table\";\nimport { expandTableShorthand, isTableShorthandInput, validateTableShorthand } from \"./tableShorthand\";\n\nexport type validateTables<tables, scope extends Scope = AbiTypeScope> = {\n [label in keyof tables]: tables[label] extends TableShorthandInput\n ? validateTableShorthand<tables[label], scope>\n : tables[label] extends object\n ? validateTable<tables[label], scope, { inStoreContext: true }>\n : ErrorMessage<`Expected tables config.`>;\n};\n\nexport function validateTables<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope,\n): asserts input is TablesInput {\n if (isObject(input)) {\n for (const table of Object.values(input)) {\n if (isTableShorthandInput(table)) {\n validateTableShorthand(table, scope);\n } else {\n validateTable(table, scope, { inStoreContext: true });\n }\n }\n return;\n }\n throw new Error(`Expected tables config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveTables<tables, scope extends Scope = AbiTypeScope> = {\n readonly [label in keyof tables]: resolveTable<\n mergeIfUndefined<expandTableShorthand<tables[label]>, { readonly label: label }>,\n scope\n >;\n};\n\nexport function resolveTables<tables extends TablesInput, scope extends Scope = AbiTypeScope>(\n tables: tables,\n scope: scope,\n): resolveTables<tables, scope> {\n return Object.fromEntries(\n Object.entries(tables).map(([label, table]) => {\n return [label, resolveTable(mergeIfUndefined(expandTableShorthand(table, scope), { label }), scope)];\n }),\n ) as never;\n}\n\nexport function defineTables<input, scope extends Scope = AbiTypeScope>(\n input: validateTables<input, scope>,\n scope: scope = AbiTypeScope as never,\n): show<resolveTables<input, scope>> {\n validateTables(input, scope);\n return resolveTables(input, scope) as never;\n}\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport { UserTypes } from \"./output\";\nimport { isSchemaAbiType } from \"@latticexyz/schema-type/internal\";\nimport { AbiTypeScope, extendScope } from \"./scope\";\nimport { hasOwnKey, isObject } from \"./generics\";\n\nexport type extractInternalType<userTypes extends UserTypes> = { [key in keyof userTypes]: userTypes[key][\"type\"] };\n\nexport function extractInternalType<userTypes extends UserTypes>(userTypes: userTypes): extractInternalType<userTypes> {\n return mapObject(userTypes, (userType) => userType.type);\n}\n\nexport function isUserTypes(userTypes: unknown): userTypes is UserTypes {\n return isObject(userTypes) && Object.values(userTypes).every((userType) => isSchemaAbiType(userType.type));\n}\n\nexport type scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope> = UserTypes extends userTypes\n ? scope\n : userTypes extends UserTypes\n ? extendScope<scope, extractInternalType<userTypes>>\n : scope;\n\nexport function scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope>(\n userTypes: userTypes,\n scope: scope = AbiTypeScope as scope,\n): scopeWithUserTypes<userTypes, scope> {\n return (isUserTypes(userTypes) ? extendScope(scope, extractInternalType(userTypes)) : scope) as never;\n}\n\nexport function validateUserTypes(userTypes: unknown): asserts userTypes is UserTypes {\n if (!isObject(userTypes)) {\n throw new Error(`Expected userTypes, received ${JSON.stringify(userTypes)}`);\n }\n\n for (const { type } of Object.values(userTypes)) {\n if (!hasOwnKey(AbiTypeScope.types, type)) {\n throw new Error(`\"${String(type)}\" is not a valid ABI type.`);\n }\n }\n}\n","import { flatMorph } from \"@ark/util\";\nimport { EnumsInput } from \"./input\";\nimport { AbiTypeScope, extendScope } from \"./scope\";\nimport { parseNumber } from \"./generics\";\n\nfunction isEnums(enums: unknown): enums is EnumsInput {\n return (\n typeof enums === \"object\" &&\n enums != null &&\n Object.values(enums).every((item) => Array.isArray(item) && item.every((element) => typeof element === \"string\"))\n );\n}\n\nexport type scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope> = EnumsInput extends enums\n ? scope\n : enums extends EnumsInput\n ? extendScope<scope, { [key in keyof enums]: \"uint8\" }>\n : scope;\n\nexport function scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope>(\n enums: enums,\n scope: scope = AbiTypeScope as scope,\n): scopeWithEnums<enums, scope> {\n if (isEnums(enums)) {\n const enumScope = Object.fromEntries(Object.keys(enums).map((key) => [key, \"uint8\" as const]));\n return extendScope(scope, enumScope) as never;\n }\n return scope as never;\n}\n\nexport type resolveEnums<enums> = {\n readonly [key in keyof enums]: Readonly<enums[key]>;\n};\n\nexport function resolveEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums> {\n return enums;\n}\n\nexport type mapEnums<enums> = {\n readonly [key in keyof enums]: {\n readonly [element in keyof enums[key] & `${number}` as enums[key][element] & string]: parseNumber<element>;\n };\n};\n\nexport function mapEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums> {\n return flatMorph(enums as EnumsInput, (enumName, enumElements) => [\n enumName,\n flatMorph(enumElements, (enumIndex, enumElement) => [enumElement, enumIndex]),\n ]) as never;\n}\n","import { show } from \"@ark/util\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? show<mergeIfUndefined<codegen, CODEGEN_DEFAULTS>>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { ErrorMessage, flatMorph, show } from \"@ark/util\";\nimport { hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { NamespaceInput } from \"./input\";\nimport { resolveTables, validateTables } from \"./tables\";\nimport { AbiTypeScope, Scope } from \"./scope\";\nimport { expandTableShorthand } from \"./tableShorthand\";\n\nexport type validateNamespace<input, scope extends Scope = AbiTypeScope> = {\n [key in keyof input]: key extends \"tables\"\n ? validateTables<input[key], scope>\n : key extends keyof NamespaceInput\n ? NamespaceInput[key]\n : ErrorMessage<`\\`${key & string}\\` is not a valid namespace config option.`>;\n};\n\nexport function validateNamespace<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope,\n): asserts input is NamespaceInput {\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`\\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n if (hasOwnKey(input, \"tables\")) {\n validateTables(input.tables, scope);\n }\n}\n\nexport type resolveNamespace<input, scope extends Scope = AbiTypeScope> = input extends NamespaceInput\n ? {\n readonly label: input[\"label\"];\n readonly namespace: string;\n readonly tables: undefined extends input[\"tables\"]\n ? {}\n : show<\n resolveTables<\n {\n readonly [label in keyof input[\"tables\"]]: mergeIfUndefined<\n expandTableShorthand<input[\"tables\"][label]>,\n { readonly namespace: string; readonly namespaceLabel: input[\"label\"] }\n >;\n },\n scope\n >\n >;\n }\n : never;\n\nexport function resolveNamespace<const input extends NamespaceInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as never,\n): resolveNamespace<input, scope> {\n const namespaceLabel = input.label;\n const namespace = input.namespace ?? namespaceLabel.slice(0, 14);\n return {\n label: namespaceLabel,\n namespace,\n tables: resolveTables(\n flatMorph(input.tables ?? {}, (label, table) => {\n return [label, mergeIfUndefined(expandTableShorthand(table, scope), { namespace, namespaceLabel })];\n }),\n scope,\n ),\n } as never;\n}\n","import { show, flatMorph } from \"@ark/util\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\nimport { NamespacesInput } from \"./input\";\nimport { AbiTypeScope, Scope } from \"./scope\";\nimport { validateNamespace, resolveNamespace } from \"./namespace\";\nimport { groupBy } from \"@latticexyz/common/utils\";\n\nexport type validateNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n [label in keyof namespaces]: validateNamespace<namespaces[label], scope>;\n};\n\nexport function validateNamespaces<scope extends Scope = AbiTypeScope>(\n namespaces: unknown,\n scope: scope,\n): asserts namespaces is NamespacesInput {\n if (!isObject(namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);\n }\n for (const namespace of Object.values(namespaces)) {\n validateNamespace(namespace, scope);\n }\n}\n\nexport type resolveNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n readonly [label in keyof namespaces]: resolveNamespace<mergeIfUndefined<namespaces[label], { label: label }>, scope>;\n};\n\nexport function resolveNamespaces<input extends NamespacesInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope,\n): resolveNamespaces<input, scope> {\n if (!isObject(input)) {\n throw new Error(`Expected namespaces config, received ${JSON.stringify(input)}`);\n }\n\n const namespaces = flatMorph(input as NamespacesInput, (label, namespace) => [\n label,\n resolveNamespace(mergeIfUndefined(namespace, { label }), scope),\n ]);\n\n // This should probably be in `validate`, but `namespace` gets set during the resolve step above, so it's easier to validate here.\n const duplicates = Array.from(groupBy(Object.values(namespaces), (namespace) => namespace.namespace).entries())\n .filter(([, entries]) => entries.length > 1)\n .map(([namespace]) => namespace);\n if (duplicates.length > 0) {\n throw new Error(`Found namespaces defined more than once in config: ${duplicates.join(\", \")}`);\n }\n\n return namespaces as never;\n}\n\nexport function defineNamespaces<input, scope extends Scope = AbiTypeScope>(\n input: validateNamespaces<input, scope>,\n scope: scope = AbiTypeScope as never,\n): show<resolveNamespaces<input, scope>> {\n validateNamespaces(input, scope);\n return resolveNamespaces(input, scope) as never;\n}\n","import { show } from \"@ark/util\";\nimport { Namespaces } from \"./output\";\n\ntype flattenNamespacedTableKeys<config> = config extends {\n readonly namespaces: infer namespaces;\n}\n ? {\n [namespaceLabel in keyof namespaces]: namespaces[namespaceLabel] extends { readonly tables: infer tables }\n ? namespaceLabel extends \"\"\n ? keyof tables\n : `${namespaceLabel & string}__${keyof tables & string}`\n : never;\n }[keyof namespaces]\n : never;\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport type flattenNamespacedTables<config> = config extends { readonly namespaces: Namespaces }\n ? {\n readonly [key in flattenNamespacedTableKeys<config>]: key extends `${infer namespaceLabel}__${infer tableLabel}`\n ? config[\"namespaces\"][namespaceLabel][\"tables\"][tableLabel]\n : config[\"namespaces\"][\"\"][\"tables\"][key];\n }\n : never;\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport function flattenNamespacedTables<config extends { readonly namespaces: Namespaces }>(\n config: config,\n): show<flattenNamespacedTables<config>> {\n return Object.fromEntries(\n Object.entries(config.namespaces).flatMap(([namespaceLabel, namespace]) =>\n Object.entries(namespace.tables).map(([tableLabel, table]) => [\n namespaceLabel === \"\" ? tableLabel : `${namespaceLabel}__${tableLabel}`,\n table,\n ]),\n ),\n ) as never;\n}\n","import { ErrorMessage, show, narrow } from \"@ark/util\";\nimport { get, hasOwnKey } from \"./generics\";\nimport { UserTypes } from \"./output\";\nimport { CONFIG_DEFAULTS } from \"./defaults\";\nimport { StoreInput } from \"./input\";\nimport { validateTables } from \"./tables\";\nimport { scopeWithUserTypes, validateUserTypes } from \"./userTypes\";\nimport { mapEnums, resolveEnums, scopeWithEnums } from \"./enums\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveNamespaces, validateNamespaces } from \"./namespaces\";\nimport { flattenNamespacedTables } from \"./flattenNamespacedTables\";\n\nexport type extendedScope<input> = scopeWithEnums<get<input, \"enums\">, scopeWithUserTypes<get<input, \"userTypes\">>>;\n\nexport function extendedScope<input>(input: input): extendedScope<input> {\n return scopeWithEnums(get(input, \"enums\"), scopeWithUserTypes(get(input, \"userTypes\")));\n}\n\nexport type validateStore<input> = {\n [key in keyof input]: key extends \"namespaces\"\n ? input extends { namespace?: unknown; tables?: unknown }\n ? ErrorMessage<\"Cannot use `namespaces` with `namespace` or `tables` keys.\">\n : validateNamespaces<input[key], extendedScope<input>>\n : key extends \"tables\"\n ? validateTables<input[key], extendedScope<input>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<input[key]>\n : key extends keyof StoreInput\n ? StoreInput[key]\n : ErrorMessage<`\\`${key & string}\\` is not a valid Store config option.`>;\n};\n\nexport function validateStore(input: unknown): asserts input is StoreInput {\n const scope = extendedScope(input);\n\n if (hasOwnKey(input, \"namespaces\")) {\n if (hasOwnKey(input, \"namespace\") || hasOwnKey(input, \"tables\")) {\n throw new Error(\"Cannot use `namespaces` with `namespace` or `tables` keys.\");\n }\n validateNamespaces(input.namespaces, scope);\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`\\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n\n if (hasOwnKey(input, \"tables\")) {\n validateTables(input.tables, scope);\n }\n\n if (hasOwnKey(input, \"userTypes\")) {\n validateUserTypes(input.userTypes);\n }\n}\n\nexport type resolveNamespaceMode<input> = \"namespaces\" extends keyof input\n ? {\n readonly multipleNamespaces: true;\n readonly namespace: null;\n readonly namespaces: show<resolveNamespaces<input[\"namespaces\"], extendedScope<input>>>;\n }\n : {\n readonly multipleNamespaces: false;\n readonly namespace: string;\n readonly namespaces: show<\n resolveNamespaces<\n {\n readonly [label in \"namespace\" extends keyof input\n ? input[\"namespace\"] extends string\n ? input[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"]]: input;\n },\n extendedScope<input>\n >\n >;\n };\n\nexport type resolveStore<input> = resolveNamespaceMode<input> & {\n readonly tables: flattenNamespacedTables<resolveNamespaceMode<input>>;\n readonly sourceDirectory: \"sourceDirectory\" extends keyof input\n ? input[\"sourceDirectory\"]\n : CONFIG_DEFAULTS[\"sourceDirectory\"];\n readonly userTypes: \"userTypes\" extends keyof input ? input[\"userTypes\"] : {};\n readonly enums: \"enums\" extends keyof input ? show<resolveEnums<input[\"enums\"]>> : {};\n readonly enumValues: \"enums\" extends keyof input ? show<mapEnums<input[\"enums\"]>> : {};\n readonly codegen: \"codegen\" extends keyof input ? resolveCodegen<input[\"codegen\"]> : resolveCodegen<{}>;\n};\n\nexport function resolveStore<const input extends StoreInput>(input: input): resolveStore<input> {\n const scope = extendedScope(input);\n\n const baseNamespace = input.namespace ?? CONFIG_DEFAULTS[\"namespace\"];\n const namespaces = input.namespaces\n ? ({\n multipleNamespaces: true,\n namespace: null,\n namespaces: resolveNamespaces(input.namespaces, scope),\n } as const)\n : ({\n multipleNamespaces: false,\n namespace: baseNamespace,\n namespaces: resolveNamespaces({ [baseNamespace]: input }, scope),\n } as const);\n\n const tables = flattenNamespacedTables(namespaces as never);\n\n return {\n ...namespaces,\n tables,\n sourceDirectory: input.sourceDirectory ?? CONFIG_DEFAULTS[\"sourceDirectory\"],\n userTypes: input.userTypes ?? {},\n enums: resolveEnums(input.enums ?? {}),\n enumValues: mapEnums(input.enums ?? {}),\n codegen: resolveCodegen(input.codegen),\n } as never;\n}\n\nexport function defineStore<const input>(input: validateStore<input>): show<resolveStore<input>> {\n validateStore(input);\n return resolveStore(input) as never;\n}\n"],"mappings":"AAIO,SAASA,EAAoCC,EAAcC,EAA2B,CAC3F,OAAQ,OAAOD,GAAU,UAAYA,GAAS,MAAQE,EAAUF,EAAOC,CAAG,EAAID,EAAMC,CAAG,EAAI,MAC7F,CAWO,SAASE,EAAoDH,EAAcI,EAAkC,CAClH,OAAOA,EAAK,OAAUD,EAAQJ,EAAIC,EAAOI,EAAK,CAAC,CAAC,EAAGA,EAAK,MAAM,CAAC,CAAC,EAAe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QN,EAAcC,CAAK,EAEjC,GAAIM,EAAUN,EAAO,YAAY,EAAG,CAClC,GAAIM,EAAUN,EAAO,WAAW,GAAKM,EAAUN,EAAO,QAAQ,EAC5D,MAAM,IAAI,MAAM,4DAA4D,EAE9EO,EAAmBP,EAAM,WAAYK,CAAK,CAC5C,CAEA,GAAIC,EAAUN,EAAO,WAAW,GAAK,OAAOA,EAAM,WAAc,UAAYA,EAAM,UAAU,OAAS,GACnG,MAAM,IAAI,MAAM,mDAAmDA,EAAM,SAAS,gBAAgB,EAGhGM,EAAUN,EAAO,QAAQ,GAC3BQ,EAAeR,EAAM,OAAQK,CAAK,EAGhCC,EAAUN,EAAO,WAAW,GAC9BS,EAAkBT,EAAM,SAAS,CAErC,CAoCO,SAASU,GAA6CV,EAAmC,CAC9F,IAAMK,EAAQN,EAAcC,CAAK,EAE3BW,EAAgBX,EAAM,WAAaY,EAAgB,UACnDC,EAAab,EAAM,WACpB,CACC,mBAAoB,GACpB,UAAW,KACX,WAAYc,EAAkBd,EAAM,WAAYK,CAAK,CACvD,EACC,CACC,mBAAoB,GACpB,UAAWM,EACX,WAAYG,EAAkB,CAAE,CAACH,CAAa,EAAGX,CAAM,EAAGK,CAAK,CACjE,EAEEU,EAASC,EAAwBH,CAAmB,EAE1D,MAAO,CACL,GAAGA,EACH,OAAAE,EACA,gBAAiBf,EAAM,iBAAmBY,EAAgB,gBAC1D,UAAWZ,EAAM,WAAa,CAAC,EAC/B,MAAoBA,EAAM,OAAS,CAAC,EACpC,WAAYiB,EAASjB,EAAM,OAAS,CAAC,CAAC,EACtC,QAASkB,EAAelB,EAAM,OAAO,CACvC,CACF,CAEO,SAASmB,GAAyBnB,EAAwD,CAC/F,OAAAI,GAAcJ,CAAK,EACZU,GAAaV,CAAK,CAC3B","names":["get","input","key","hasOwnKey","getPath","path","object","isObject","mergeIfUndefined","base","defaults","keys","CODEGEN_DEFAULTS","TABLE_CODEGEN_DEFAULTS","TABLE_DEPLOY_DEFAULTS","TABLE_DEFAULTS","CONFIG_DEFAULTS","schemaAbiTypes","Scope","AbiTypeScope","abiType","extendScope","scope","additionalTypes","fixedArrayToArray","isFixedArrayAbiType","validateSchema","schema","scope","AbiTypeScope","isObject","internalType","hasOwnKey","resolveSchema","key","defineSchema","isSchemaInput","input","fieldType","isStaticAbiType","resourceToHex","getValidKeys","schema","scope","AbiTypeScope","internalType","hasOwnKey","isStaticAbiType","key","isValidPrimaryKey","validateTable","input","options","validateSchema","item","get","resolveTableCodegen","TABLE_CODEGEN_DEFAULTS","resolveTable","namespaceLabel","TABLE_DEFAULTS","namespace","label","name","type","tableId","resolveSchema","mergeIfUndefined","TABLE_DEPLOY_DEFAULTS","defineTable","isFixedArrayAbiType","isStaticAbiType","NoStaticKeyFieldError","isTableShorthandInput","shorthand","isObject","value","validateTableShorthand","scope","AbiTypeScope","isFixedArrayAbiType","hasOwnKey","isSchemaInput","isStaticAbiType","expandTableShorthand","defineTableShorthand","input","validateTables","input","scope","isObject","table","isTableShorthandInput","validateTableShorthand","validateTable","resolveTables","tables","label","resolveTable","mergeIfUndefined","expandTableShorthand","defineTables","AbiTypeScope","mapObject","isSchemaAbiType","extractInternalType","userTypes","mapObject","userType","isUserTypes","isObject","isSchemaAbiType","scopeWithUserTypes","scope","AbiTypeScope","extendScope","validateUserTypes","type","hasOwnKey","flatMorph","isEnums","enums","item","element","scopeWithEnums","scope","AbiTypeScope","enumScope","key","extendScope","resolveEnums","mapEnums","flatMorph","enumName","enumElements","enumIndex","enumElement","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","flatMorph","validateNamespace","input","scope","hasOwnKey","validateTables","resolveNamespace","AbiTypeScope","namespaceLabel","namespace","resolveTables","flatMorph","label","table","mergeIfUndefined","expandTableShorthand","flatMorph","groupBy","validateNamespaces","namespaces","scope","isObject","namespace","validateNamespace","resolveNamespaces","input","flatMorph","label","resolveNamespace","mergeIfUndefined","duplicates","entries","defineNamespaces","AbiTypeScope","flattenNamespacedTables","config","namespaceLabel","namespace","tableLabel","table","extendedScope","input","scopeWithEnums","get","scopeWithUserTypes","validateStore","scope","hasOwnKey","validateNamespaces","validateTables","validateUserTypes","resolveStore","baseNamespace","CONFIG_DEFAULTS","namespaces","resolveNamespaces","tables","flattenNamespacedTables","mapEnums","resolveCodegen","defineStore"]}
|
1
|
+
{"version":3,"sources":["../ts/config/v2/generics.ts","../ts/config/v2/defaults.ts","../ts/config/v2/scope.ts","../ts/config/v2/schema.ts","../ts/config/v2/table.ts","../ts/config/v2/tableShorthand.ts","../ts/config/v2/tables.ts","../ts/config/v2/userTypes.ts","../ts/config/v2/enums.ts","../ts/config/v2/codegen.ts","../ts/config/v2/namespace.ts","../ts/config/v2/namespaces.ts","../ts/config/v2/flattenNamespacedTables.ts","../ts/config/v2/store.ts"],"sourcesContent":["// TODO: move to common/utils\n\nexport type get<input, key> = key extends keyof input ? input[key] : undefined;\n\nexport function get<input, key extends PropertyKey>(input: input, key: key): get<input, key> {\n return (typeof input === \"object\" && input != null && hasOwnKey(input, key) ? input[key] : undefined) as never;\n}\n\nexport type getPath<input, path extends readonly PropertyKey[]> = path extends readonly [\n infer head,\n ...infer tail extends PropertyKey[],\n]\n ? head extends keyof input\n ? getPath<input[head], tail>\n : undefined\n : input;\n\nexport function getPath<input, path extends readonly PropertyKey[]>(input: input, path: path): getPath<input, path> {\n return path.length ? (getPath(get(input, path[0]), path.slice(1)) as never) : (input as never);\n}\n\nexport function hasOwnKey<obj, const key extends PropertyKey>(\n object: obj,\n key: key,\n): object is { [k in key]: k extends keyof obj ? obj[k] : unknown } & obj {\n // eslint-disable-next-line no-prototype-builtins\n return typeof object === \"object\" && object !== null && object.hasOwnProperty(key);\n}\n\nexport function isObject<input>(input: input): input is input & object {\n return input != null && typeof input === \"object\";\n}\n\nexport type mergeIfUndefined<base, defaults> = {\n readonly [key in keyof base | keyof defaults]: key extends keyof base\n ? undefined extends base[key]\n ? key extends keyof defaults\n ? defaults[key]\n : base[key]\n : base[key]\n : key extends keyof defaults\n ? defaults[key]\n : never;\n};\n\nexport function mergeIfUndefined<base extends object, defaults extends object>(\n base: base,\n defaults: defaults,\n): mergeIfUndefined<base, defaults> {\n const keys = [...new Set([...Object.keys(base), ...Object.keys(defaults)])];\n return Object.fromEntries(\n keys.map((key) => [\n key,\n typeof base[key as keyof base] === \"undefined\" ? defaults[key as keyof defaults] : base[key as keyof base],\n ]),\n ) as never;\n}\n\nexport type parseNumber<T> = T extends `${infer N extends number}` ? N : never;\n","import { CodegenInput, StoreInput, TableCodegenInput, TableDeployInput, TableInput } from \"./input\";\n\nexport const CODEGEN_DEFAULTS = {\n storeImportPath: \"@latticexyz/store/src\",\n userTypesFilename: \"common.sol\",\n outputDirectory: \"codegen\",\n indexFilename: \"index.sol\",\n} as const satisfies CodegenInput;\n\nexport type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;\n\nexport const TABLE_CODEGEN_DEFAULTS = {\n outputDirectory: \"tables\" as string,\n tableIdArgument: false,\n storeArgument: false,\n} as const satisfies TableCodegenInput;\n\nexport type TABLE_CODEGEN_DEFAULTS = typeof TABLE_CODEGEN_DEFAULTS;\n\nexport const TABLE_DEPLOY_DEFAULTS = {\n disabled: false,\n} as const satisfies TableDeployInput;\n\nexport type TABLE_DEPLOY_DEFAULTS = typeof TABLE_DEPLOY_DEFAULTS;\n\nexport const TABLE_DEFAULTS = {\n namespaceLabel: \"\",\n type: \"table\",\n} as const satisfies Pick<TableInput, \"namespaceLabel\" | \"type\">;\n\nexport type TABLE_DEFAULTS = typeof TABLE_DEFAULTS;\n\nexport const CONFIG_DEFAULTS = {\n sourceDirectory: \"src\",\n namespace: \"\",\n} as const satisfies StoreInput;\n\nexport type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;\n","import { Dict, show } from \"@ark/util\";\nimport { SchemaInput } from \"./input\";\nimport { StaticAbiType, schemaAbiTypes } from \"@latticexyz/schema-type/internal\";\nimport { AbiType } from \"./output\";\n\nexport const Scope = { types: {} } as const satisfies ScopeOptions;\nexport type Scope = typeof Scope;\n\nexport type AbiTypeScope = ScopeOptions<{ [t in AbiType]: t }>;\nexport const AbiTypeScope = {\n types: Object.fromEntries(schemaAbiTypes.map((abiType) => [abiType, abiType])),\n} as AbiTypeScope;\n\nexport type ScopeOptions<types extends Dict<string, AbiType> = Dict<string, AbiType>> = {\n types: types;\n};\n\nexport type getStaticAbiTypeKeys<\n schema extends SchemaInput,\n scope extends Scope = AbiTypeScope,\n> = SchemaInput extends schema\n ? string\n : {\n [key in keyof schema]: scope[\"types\"] extends { [_ in schema[key]]: StaticAbiType } ? key : never;\n }[keyof schema];\n\nexport type extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>> = show<\n ScopeOptions<show<scope[\"types\"] & additionalTypes>>\n>;\n\nexport function extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>>(\n scope: scope,\n additionalTypes: additionalTypes,\n): extendScope<scope, additionalTypes> {\n return {\n types: {\n ...scope.types,\n ...additionalTypes,\n },\n };\n}\n","import { conform, show } from \"@ark/util\";\nimport { AbiTypeScope, Scope } from \"./scope\";\nimport { hasOwnKey, isObject } from \"./generics\";\nimport { SchemaInput } from \"./input\";\nimport { FixedArrayAbiType, fixedArrayToArray, isFixedArrayAbiType } from \"@latticexyz/schema-type/internal\";\n\nexport type validateSchema<schema, scope extends Scope = AbiTypeScope> = schema extends string\n ? SchemaInput\n : {\n [key in keyof schema]: schema[key] extends FixedArrayAbiType\n ? schema[key]\n : conform<schema[key], keyof scope[\"types\"]>;\n };\n\nexport function validateSchema<scope extends Scope = AbiTypeScope>(\n schema: unknown,\n scope: scope = AbiTypeScope as never,\n): asserts schema is SchemaInput {\n if (!isObject(schema)) {\n throw new Error(`Expected schema, received ${JSON.stringify(schema)}`);\n }\n\n for (const internalType of Object.values(schema)) {\n if (isFixedArrayAbiType(internalType)) continue;\n if (hasOwnKey(scope.types, internalType)) continue;\n throw new Error(`\"${String(internalType)}\" is not a valid type in this scope.`);\n }\n}\n\nexport type resolveSchema<schema, scope extends Scope> = show<{\n readonly [key in keyof schema]: {\n /** the Solidity primitive ABI type */\n readonly type: schema[key] extends FixedArrayAbiType\n ? fixedArrayToArray<schema[key]>\n : scope[\"types\"][schema[key] & keyof scope[\"types\"]];\n /** the user defined type or Solidity primitive ABI type */\n readonly internalType: schema[key];\n };\n}>;\n\nexport function resolveSchema<schema extends SchemaInput, scope extends Scope = AbiTypeScope>(\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveSchema<schema, scope> {\n return Object.fromEntries(\n Object.entries(schema).map(([key, internalType]) => [\n key,\n {\n type: isFixedArrayAbiType(internalType) ? fixedArrayToArray(internalType) : scope.types[internalType as never],\n internalType,\n },\n ]),\n ) as never;\n}\n\nexport function defineSchema<schema, scope extends AbiTypeScope = AbiTypeScope>(\n schema: validateSchema<schema, scope>,\n scope: scope = AbiTypeScope as scope,\n): resolveSchema<schema, scope> {\n validateSchema(schema, scope);\n return resolveSchema(schema, scope) as never;\n}\n\nexport function isSchemaInput<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope = AbiTypeScope as never,\n): input is SchemaInput {\n return (\n typeof input === \"object\" &&\n input != null &&\n Object.values(input).every((fieldType) => isFixedArrayAbiType(fieldType) || hasOwnKey(scope.types, fieldType))\n );\n}\n","import { ErrorMessage, conform, show, narrow, requiredKeyOf } from \"@ark/util\";\nimport { isStaticAbiType } from \"@latticexyz/schema-type/internal\";\nimport { Hex } from \"viem\";\nimport { get, hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { resolveSchema, validateSchema } from \"./schema\";\nimport { AbiTypeScope, Scope, getStaticAbiTypeKeys } from \"./scope\";\nimport { TableCodegen } from \"./output\";\nimport { TABLE_CODEGEN_DEFAULTS, TABLE_DEFAULTS, TABLE_DEPLOY_DEFAULTS } from \"./defaults\";\nimport { resourceToHex } from \"@latticexyz/common\";\nimport { SchemaInput, TableInput } from \"./input\";\n\nexport type ValidKeys<schema extends SchemaInput, scope extends Scope> = readonly [\n getStaticAbiTypeKeys<schema, scope>,\n ...getStaticAbiTypeKeys<schema, scope>[],\n];\n\nfunction getValidKeys<schema extends SchemaInput, scope extends Scope = AbiTypeScope>(\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): ValidKeys<schema, scope> {\n return Object.entries(schema)\n .filter(([, internalType]) => hasOwnKey(scope.types, internalType) && isStaticAbiType(scope.types[internalType]))\n .map(([key]) => key) as never;\n}\n\nexport function isValidPrimaryKey<schema extends SchemaInput, scope extends Scope>(\n key: unknown,\n schema: schema,\n scope: scope = AbiTypeScope as unknown as scope,\n): key is ValidKeys<schema, scope> {\n return (\n Array.isArray(key) &&\n key.every(\n (key) =>\n hasOwnKey(schema, key) && hasOwnKey(scope.types, schema[key]) && isStaticAbiType(scope.types[schema[key]]),\n )\n );\n}\n\nexport type validateKeys<validKeys extends PropertyKey, keys> = keys extends readonly string[]\n ? {\n readonly [i in keyof keys]: keys[i] extends validKeys ? keys[i] : validKeys;\n }\n : readonly string[];\n\nexport type ValidateTableOptions = { inStoreContext: boolean };\n\nexport type requiredTableKey<inStoreContext extends boolean> = Exclude<\n requiredKeyOf<TableInput>,\n inStoreContext extends true ? \"label\" | \"namespaceLabel\" | \"namespace\" : never\n>;\n\nexport type validateTable<\n input,\n scope extends Scope = AbiTypeScope,\n options extends ValidateTableOptions = { inStoreContext: false },\n> = {\n [key in keyof input | requiredTableKey<options[\"inStoreContext\"]>]: key extends \"key\"\n ? validateKeys<getStaticAbiTypeKeys<conform<get<input, \"schema\">, SchemaInput>, scope>, get<input, key>>\n : key extends \"schema\"\n ? validateSchema<get<input, key>, scope>\n : key extends \"label\" | \"namespaceLabel\" | \"namespace\"\n ? options[\"inStoreContext\"] extends true\n ? ErrorMessage<\"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for tables in this context\">\n : key extends keyof input\n ? narrow<input[key]>\n : never\n : key extends keyof TableInput\n ? TableInput[key]\n : ErrorMessage<`Key \\`${key & string}\\` does not exist in TableInput`>;\n};\n\nexport function validateTable<input, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as unknown as scope,\n options: ValidateTableOptions = { inStoreContext: false },\n): asserts input is TableInput & input {\n if (typeof input !== \"object\" || input == null) {\n throw new Error(`Expected full table config, got \\`${JSON.stringify(input)}\\``);\n }\n\n if (!hasOwnKey(input, \"schema\")) {\n throw new Error(\"Missing schema input\");\n }\n validateSchema(input.schema, scope);\n\n if (!hasOwnKey(input, \"key\") || !isValidPrimaryKey(input[\"key\"], input[\"schema\"], scope)) {\n throw new Error(\n `Invalid key. Expected \\`(${getValidKeys(input[\"schema\"], scope)\n .map((item) => `\"${String(item)}\"`)\n .join(\" | \")})[]\\`, received \\`${\n hasOwnKey(input, \"key\") && Array.isArray(input.key)\n ? `[${input.key.map((item) => `\"${item}\"`).join(\", \")}]`\n : String(get(input, \"key\"))\n }\\``,\n );\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`Table \\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n\n if (\n hasOwnKey(input, \"namespaceLabel\") &&\n typeof input.namespaceLabel === \"string\" &&\n (!hasOwnKey(input, \"namespace\") || typeof input.namespace !== \"string\") &&\n input.namespaceLabel.length > 14\n ) {\n throw new Error(\n `Table \\`namespace\\` defaults to \\`namespaceLabel\\`, but must fit into a \\`bytes14\\` and \"${input.namespaceLabel}\" is too long. Provide explicit \\`namespace\\` override.`,\n );\n }\n\n if (hasOwnKey(input, \"name\") && typeof input.name === \"string\" && input.name.length > 16) {\n throw new Error(`Table \\`name\\` must fit into a \\`bytes16\\`, but \"${input.name}\" is too long.`);\n }\n\n if (\n options.inStoreContext &&\n (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespaceLabel\") || hasOwnKey(input, \"namespace\"))\n ) {\n throw new Error(\n \"Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for tables in this context.\",\n );\n }\n}\n\nexport type resolveTableCodegen<input extends TableInput> = show<{\n [key in keyof TableCodegen]-?: key extends keyof input[\"codegen\"]\n ? undefined extends input[\"codegen\"][key]\n ? key extends \"dataStruct\"\n ? boolean\n : key extends keyof TABLE_CODEGEN_DEFAULTS\n ? TABLE_CODEGEN_DEFAULTS[key]\n : never\n : input[\"codegen\"][key]\n : // dataStruct isn't narrowed, because its value is conditional on the number of value schema fields\n key extends \"dataStruct\"\n ? boolean\n : key extends keyof TABLE_CODEGEN_DEFAULTS\n ? TABLE_CODEGEN_DEFAULTS[key]\n : never;\n}>;\n\nexport function resolveTableCodegen<input extends TableInput>(input: input): resolveTableCodegen<input> {\n const options = input.codegen;\n return {\n outputDirectory: get(options, \"outputDirectory\") ?? TABLE_CODEGEN_DEFAULTS.outputDirectory,\n tableIdArgument: get(options, \"tableIdArgument\") ?? TABLE_CODEGEN_DEFAULTS.tableIdArgument,\n storeArgument: get(options, \"storeArgument\") ?? TABLE_CODEGEN_DEFAULTS.storeArgument,\n // dataStruct is true if there are at least 2 value fields\n dataStruct: get(options, \"dataStruct\") ?? Object.keys(input.schema).length - input.key.length > 1,\n } satisfies TableCodegen as never;\n}\n\nexport type resolveTable<input, scope extends Scope = Scope> = input extends TableInput\n ? {\n readonly label: input[\"label\"];\n readonly namespaceLabel: undefined extends input[\"namespaceLabel\"]\n ? typeof TABLE_DEFAULTS.namespaceLabel\n : input[\"namespaceLabel\"];\n readonly type: undefined extends input[\"type\"] ? typeof TABLE_DEFAULTS.type : input[\"type\"];\n readonly namespace: string;\n readonly name: string;\n readonly tableId: Hex;\n readonly schema: resolveSchema<input[\"schema\"], scope>;\n readonly key: Readonly<input[\"key\"]>;\n readonly codegen: resolveTableCodegen<input>;\n readonly deploy: show<\n mergeIfUndefined<undefined extends input[\"deploy\"] ? {} : input[\"deploy\"], TABLE_DEPLOY_DEFAULTS>\n >;\n }\n : never;\n\nexport function resolveTable<input extends TableInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveTable<input, scope> {\n const namespaceLabel = input.namespaceLabel ?? TABLE_DEFAULTS.namespaceLabel;\n // validate ensures this is length constrained\n const namespace = input.namespace ?? namespaceLabel;\n\n const label = input.label;\n const name = input.name ?? label.slice(0, 16);\n const type = input.type ?? TABLE_DEFAULTS.type;\n const tableId = resourceToHex({ type, namespace, name });\n\n return {\n label,\n type,\n namespace,\n namespaceLabel,\n name,\n tableId,\n schema: resolveSchema(input.schema, scope),\n key: input.key,\n codegen: resolveTableCodegen(input),\n deploy: mergeIfUndefined(input.deploy ?? {}, TABLE_DEPLOY_DEFAULTS),\n } as never;\n}\n\nexport function defineTable<input, scope extends Scope = AbiTypeScope>(\n input: validateTable<input, scope>,\n scope: scope = AbiTypeScope as unknown as scope,\n): resolveTable<input, scope> {\n validateTable(input, scope);\n return resolveTable(input, scope) as never;\n}\n","import { FixedArrayAbiType, isFixedArrayAbiType, isStaticAbiType } from \"@latticexyz/schema-type/internal\";\nimport { hasOwnKey, isObject } from \"./generics\";\nimport { SchemaInput, ScopedSchemaInput, TableShorthandInput } from \"./input\";\nimport { isSchemaInput } from \"./schema\";\nimport { AbiTypeScope, Scope, getStaticAbiTypeKeys } from \"./scope\";\nimport { ErrorMessage, conform } from \"@ark/util\";\n\nexport const NoStaticKeyFieldError =\n \"Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.\";\n\nexport type NoStaticKeyFieldError = ErrorMessage<typeof NoStaticKeyFieldError>;\n\nexport function isTableShorthandInput(shorthand: unknown): shorthand is TableShorthandInput {\n return (\n typeof shorthand === \"string\" ||\n (isObject(shorthand) && Object.values(shorthand).every((value) => typeof value === \"string\"))\n );\n}\n\n// We don't use `conform` here because the restrictions we're imposing here are not native to typescript\nexport type validateTableShorthand<input, scope extends Scope = AbiTypeScope> = input extends SchemaInput\n ? // If a shorthand schema is provided, require it to have a static `id` field\n \"id\" extends getStaticAbiTypeKeys<input, scope>\n ? // Require all values to be valid types in this scope\n conform<input, ScopedSchemaInput<scope>>\n : NoStaticKeyFieldError\n : // If a fixed array type or a valid type from the scope is provided, accept it\n input extends FixedArrayAbiType | keyof scope[\"types\"]\n ? input\n : // If the input is not a valid shorthand, return the expected type\n input extends string\n ? keyof scope[\"types\"]\n : ScopedSchemaInput<scope>;\n\nexport function validateTableShorthand<scope extends Scope = AbiTypeScope>(\n shorthand: unknown,\n scope: scope = AbiTypeScope as never,\n): asserts shorthand is TableShorthandInput {\n if (typeof shorthand === \"string\") {\n if (isFixedArrayAbiType(shorthand) || hasOwnKey(scope.types, shorthand)) {\n return;\n }\n throw new Error(`Invalid ABI type. \\`${shorthand}\\` not found in scope.`);\n }\n if (typeof shorthand === \"object\" && shorthand !== null) {\n if (isSchemaInput(shorthand, scope)) {\n if (hasOwnKey(shorthand, \"id\") && isStaticAbiType(scope.types[shorthand.id as keyof typeof scope.types])) {\n return;\n }\n throw new Error(`Invalid schema. Expected an \\`id\\` field with a static ABI type or an explicit \\`key\\` option.`);\n }\n throw new Error(`Invalid schema. Are you using invalid types or missing types in your scope?`);\n }\n throw new Error(`Invalid table shorthand.`);\n}\n\nexport type expandTableShorthand<shorthand> = shorthand extends string\n ? {\n readonly schema: {\n readonly id: \"bytes32\";\n readonly value: shorthand;\n };\n readonly key: [\"id\"];\n }\n : shorthand extends SchemaInput\n ? {\n readonly schema: shorthand;\n readonly key: [\"id\"];\n }\n : shorthand;\n\nexport function expandTableShorthand<shorthand, scope extends Scope = AbiTypeScope>(\n shorthand: shorthand,\n scope: scope,\n): expandTableShorthand<shorthand> {\n if (typeof shorthand === \"string\") {\n return {\n schema: {\n id: \"bytes32\",\n value: shorthand,\n },\n key: [\"id\"],\n } as never;\n }\n\n if (isSchemaInput(shorthand, scope)) {\n return {\n schema: shorthand,\n key: [\"id\"],\n } as never;\n }\n\n return shorthand as never;\n}\n\nexport function defineTableShorthand<input, scope extends Scope = AbiTypeScope>(\n input: validateTableShorthand<input, scope>,\n scope: scope = AbiTypeScope as unknown as scope,\n): expandTableShorthand<input> {\n validateTableShorthand(input, scope);\n return expandTableShorthand(input, scope) as never;\n}\n","import { ErrorMessage, show } from \"@ark/util\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\nimport { TableShorthandInput, TablesInput } from \"./input\";\nimport { Scope, AbiTypeScope } from \"./scope\";\nimport { validateTable, resolveTable } from \"./table\";\nimport { expandTableShorthand, isTableShorthandInput, validateTableShorthand } from \"./tableShorthand\";\n\nexport type validateTables<tables, scope extends Scope = AbiTypeScope> = {\n [label in keyof tables]: tables[label] extends TableShorthandInput\n ? validateTableShorthand<tables[label], scope>\n : tables[label] extends object\n ? validateTable<tables[label], scope, { inStoreContext: true }>\n : ErrorMessage<`Expected tables config.`>;\n};\n\nexport function validateTables<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope,\n): asserts input is TablesInput {\n if (isObject(input)) {\n for (const table of Object.values(input)) {\n if (isTableShorthandInput(table)) {\n validateTableShorthand(table, scope);\n } else {\n validateTable(table, scope, { inStoreContext: true });\n }\n }\n return;\n }\n throw new Error(`Expected tables config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveTables<tables, scope extends Scope = AbiTypeScope> = {\n readonly [label in keyof tables]: resolveTable<\n mergeIfUndefined<expandTableShorthand<tables[label]>, { readonly label: label }>,\n scope\n >;\n};\n\nexport function resolveTables<tables extends TablesInput, scope extends Scope = AbiTypeScope>(\n tables: tables,\n scope: scope,\n): resolveTables<tables, scope> {\n return Object.fromEntries(\n Object.entries(tables).map(([label, table]) => {\n return [label, resolveTable(mergeIfUndefined(expandTableShorthand(table, scope), { label }), scope)];\n }),\n ) as never;\n}\n\nexport function defineTables<input, scope extends Scope = AbiTypeScope>(\n input: validateTables<input, scope>,\n scope: scope = AbiTypeScope as never,\n): show<resolveTables<input, scope>> {\n validateTables(input, scope);\n return resolveTables(input, scope) as never;\n}\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport { UserTypes } from \"./output\";\nimport { isSchemaAbiType } from \"@latticexyz/schema-type/internal\";\nimport { AbiTypeScope, extendScope } from \"./scope\";\nimport { hasOwnKey, isObject } from \"./generics\";\n\nexport type extractInternalType<userTypes extends UserTypes> = { [key in keyof userTypes]: userTypes[key][\"type\"] };\n\nexport function extractInternalType<userTypes extends UserTypes>(userTypes: userTypes): extractInternalType<userTypes> {\n return mapObject(userTypes, (userType) => userType.type);\n}\n\nexport function isUserTypes(userTypes: unknown): userTypes is UserTypes {\n return isObject(userTypes) && Object.values(userTypes).every((userType) => isSchemaAbiType(userType.type));\n}\n\nexport type scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope> = UserTypes extends userTypes\n ? scope\n : userTypes extends UserTypes\n ? extendScope<scope, extractInternalType<userTypes>>\n : scope;\n\nexport function scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope>(\n userTypes: userTypes,\n scope: scope = AbiTypeScope as scope,\n): scopeWithUserTypes<userTypes, scope> {\n return (isUserTypes(userTypes) ? extendScope(scope, extractInternalType(userTypes)) : scope) as never;\n}\n\nexport function validateUserTypes(userTypes: unknown): asserts userTypes is UserTypes {\n if (!isObject(userTypes)) {\n throw new Error(`Expected userTypes, received ${JSON.stringify(userTypes)}`);\n }\n\n for (const { type } of Object.values(userTypes)) {\n if (!hasOwnKey(AbiTypeScope.types, type)) {\n throw new Error(`\"${String(type)}\" is not a valid ABI type.`);\n }\n }\n}\n","import { flatMorph } from \"@ark/util\";\nimport { EnumsInput } from \"./input\";\nimport { AbiTypeScope, extendScope } from \"./scope\";\nimport { parseNumber } from \"./generics\";\n\nfunction isEnums(enums: unknown): enums is EnumsInput {\n return (\n typeof enums === \"object\" &&\n enums != null &&\n Object.values(enums).every((item) => Array.isArray(item) && item.every((element) => typeof element === \"string\"))\n );\n}\n\nexport type scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope> = EnumsInput extends enums\n ? scope\n : enums extends EnumsInput\n ? extendScope<scope, { [key in keyof enums]: \"uint8\" }>\n : scope;\n\nexport function scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope>(\n enums: enums,\n scope: scope = AbiTypeScope as scope,\n): scopeWithEnums<enums, scope> {\n if (isEnums(enums)) {\n const enumScope = Object.fromEntries(Object.keys(enums).map((key) => [key, \"uint8\" as const]));\n return extendScope(scope, enumScope) as never;\n }\n return scope as never;\n}\n\nexport type resolveEnums<enums> = {\n readonly [key in keyof enums]: Readonly<enums[key]>;\n};\n\nexport function resolveEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums> {\n return enums;\n}\n\nexport type mapEnums<enums> = {\n readonly [key in keyof enums]: {\n readonly [element in keyof enums[key] & `${number}` as enums[key][element] & string]: parseNumber<element>;\n };\n};\n\nexport function mapEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums> {\n return flatMorph(enums as EnumsInput, (enumName, enumElements) => [\n enumName,\n flatMorph(enumElements, (enumIndex, enumElement) => [enumElement, enumIndex]),\n ]) as never;\n}\n","import { show } from \"@ark/util\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? show<mergeIfUndefined<codegen, CODEGEN_DEFAULTS>>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { ErrorMessage, flatMorph, show } from \"@ark/util\";\nimport { hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { NamespaceInput } from \"./input\";\nimport { resolveTables, validateTables } from \"./tables\";\nimport { AbiTypeScope, Scope } from \"./scope\";\nimport { expandTableShorthand } from \"./tableShorthand\";\n\nexport type validateNamespace<input, scope extends Scope = AbiTypeScope> = {\n [key in keyof input]: key extends \"tables\"\n ? validateTables<input[key], scope>\n : key extends keyof NamespaceInput\n ? NamespaceInput[key]\n : ErrorMessage<`\\`${key & string}\\` is not a valid namespace config option.`>;\n};\n\nexport function validateNamespace<scope extends Scope = AbiTypeScope>(\n input: unknown,\n scope: scope,\n): asserts input is NamespaceInput {\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`\\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n if (hasOwnKey(input, \"tables\")) {\n validateTables(input.tables, scope);\n }\n}\n\nexport type resolveNamespace<input, scope extends Scope = AbiTypeScope> = input extends NamespaceInput\n ? {\n readonly label: input[\"label\"];\n readonly namespace: string;\n readonly tables: undefined extends input[\"tables\"]\n ? {}\n : show<\n resolveTables<\n {\n readonly [label in keyof input[\"tables\"]]: mergeIfUndefined<\n expandTableShorthand<input[\"tables\"][label]>,\n { readonly namespace: string; readonly namespaceLabel: input[\"label\"] }\n >;\n },\n scope\n >\n >;\n }\n : never;\n\nexport function resolveNamespace<const input extends NamespaceInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope = AbiTypeScope as never,\n): resolveNamespace<input, scope> {\n const namespaceLabel = input.label;\n const namespace = input.namespace ?? namespaceLabel.slice(0, 14);\n return {\n label: namespaceLabel,\n namespace,\n tables: resolveTables(\n flatMorph(input.tables ?? {}, (label, table) => {\n return [label, mergeIfUndefined(expandTableShorthand(table, scope), { namespace, namespaceLabel })];\n }),\n scope,\n ),\n } as never;\n}\n","import { show, flatMorph } from \"@ark/util\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\nimport { NamespacesInput } from \"./input\";\nimport { AbiTypeScope, Scope } from \"./scope\";\nimport { validateNamespace, resolveNamespace } from \"./namespace\";\nimport { groupBy } from \"@latticexyz/common/utils\";\n\nexport type validateNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n [label in keyof namespaces]: validateNamespace<namespaces[label], scope>;\n};\n\nexport function validateNamespaces<scope extends Scope = AbiTypeScope>(\n namespaces: unknown,\n scope: scope,\n): asserts namespaces is NamespacesInput {\n if (!isObject(namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);\n }\n for (const namespace of Object.values(namespaces)) {\n validateNamespace(namespace, scope);\n }\n}\n\nexport type resolveNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n readonly [label in keyof namespaces]: resolveNamespace<mergeIfUndefined<namespaces[label], { label: label }>, scope>;\n};\n\nexport function resolveNamespaces<input extends NamespacesInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope,\n): resolveNamespaces<input, scope> {\n if (!isObject(input)) {\n throw new Error(`Expected namespaces config, received ${JSON.stringify(input)}`);\n }\n\n const namespaces = flatMorph(input as NamespacesInput, (label, namespace) => [\n label,\n resolveNamespace(mergeIfUndefined(namespace, { label }), scope),\n ]);\n\n // This should probably be in `validate`, but `namespace` gets set during the resolve step above, so it's easier to validate here.\n const duplicates = Array.from(groupBy(Object.values(namespaces), (namespace) => namespace.namespace).entries())\n .filter(([, entries]) => entries.length > 1)\n .map(([namespace]) => namespace);\n if (duplicates.length > 0) {\n throw new Error(`Found namespaces defined more than once in config: ${duplicates.join(\", \")}`);\n }\n\n return namespaces as never;\n}\n\nexport function defineNamespaces<input, scope extends Scope = AbiTypeScope>(\n input: validateNamespaces<input, scope>,\n scope: scope = AbiTypeScope as never,\n): show<resolveNamespaces<input, scope>> {\n validateNamespaces(input, scope);\n return resolveNamespaces(input, scope) as never;\n}\n","import { show } from \"@ark/util\";\nimport { Namespaces } from \"./output\";\n\ntype flattenNamespacedTableKeys<config> = config extends {\n readonly namespaces: infer namespaces;\n}\n ? {\n [namespaceLabel in keyof namespaces]: namespaces[namespaceLabel] extends { readonly tables: infer tables }\n ? namespaceLabel extends \"\"\n ? keyof tables\n : `${namespaceLabel & string}__${keyof tables & string}`\n : never;\n }[keyof namespaces]\n : never;\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport type flattenNamespacedTables<config> = config extends { readonly namespaces: Namespaces }\n ? {\n readonly [key in flattenNamespacedTableKeys<config>]: key extends `${infer namespaceLabel}__${infer tableLabel}`\n ? config[\"namespaces\"][namespaceLabel][\"tables\"][tableLabel]\n : config[\"namespaces\"][\"\"][\"tables\"][key];\n }\n : never;\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport function flattenNamespacedTables<config extends { readonly namespaces: Namespaces }>(\n config: config,\n): show<flattenNamespacedTables<config>> {\n return Object.fromEntries(\n Object.entries(config.namespaces).flatMap(([namespaceLabel, namespace]) =>\n Object.entries(namespace.tables).map(([tableLabel, table]) => [\n namespaceLabel === \"\" ? tableLabel : `${namespaceLabel}__${tableLabel}`,\n table,\n ]),\n ),\n ) as never;\n}\n","import { ErrorMessage, show, narrow } from \"@ark/util\";\nimport { get, hasOwnKey } from \"./generics\";\nimport { UserTypes } from \"./output\";\nimport { CONFIG_DEFAULTS } from \"./defaults\";\nimport { StoreInput } from \"./input\";\nimport { validateTables } from \"./tables\";\nimport { scopeWithUserTypes, validateUserTypes } from \"./userTypes\";\nimport { mapEnums, resolveEnums, scopeWithEnums } from \"./enums\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveNamespaces, validateNamespaces } from \"./namespaces\";\nimport { flattenNamespacedTables } from \"./flattenNamespacedTables\";\n\nexport type extendedScope<input> = scopeWithEnums<get<input, \"enums\">, scopeWithUserTypes<get<input, \"userTypes\">>>;\n\nexport function extendedScope<input>(input: input): extendedScope<input> {\n return scopeWithEnums(get(input, \"enums\"), scopeWithUserTypes(get(input, \"userTypes\")));\n}\n\nexport type validateStore<input> = {\n [key in keyof input]: key extends \"namespaces\"\n ? input extends { namespace?: unknown; tables?: unknown }\n ? ErrorMessage<\"Cannot use `namespaces` with `namespace` or `tables` keys.\">\n : validateNamespaces<input[key], extendedScope<input>>\n : key extends \"tables\"\n ? validateTables<input[key], extendedScope<input>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<input[key]>\n : key extends keyof StoreInput\n ? StoreInput[key]\n : ErrorMessage<`\\`${key & string}\\` is not a valid Store config option.`>;\n};\n\nexport function validateStore(input: unknown): asserts input is StoreInput {\n const scope = extendedScope(input);\n\n if (hasOwnKey(input, \"namespaces\")) {\n if (hasOwnKey(input, \"namespace\") || hasOwnKey(input, \"tables\")) {\n throw new Error(\"Cannot use `namespaces` with `namespace` or `tables` keys.\");\n }\n validateNamespaces(input.namespaces, scope);\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`\\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n\n if (hasOwnKey(input, \"tables\")) {\n validateTables(input.tables, scope);\n }\n\n if (hasOwnKey(input, \"userTypes\")) {\n validateUserTypes(input.userTypes);\n }\n}\n\nexport type resolveNamespaceMode<input> = \"namespaces\" extends keyof input\n ? {\n readonly multipleNamespaces: true;\n readonly namespace: null;\n readonly namespaces: show<resolveNamespaces<input[\"namespaces\"], extendedScope<input>>>;\n }\n : {\n readonly multipleNamespaces: false;\n readonly namespace: string;\n readonly namespaces: show<\n resolveNamespaces<\n {\n readonly [label in \"namespace\" extends keyof input\n ? input[\"namespace\"] extends string\n ? input[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"]]: input;\n },\n extendedScope<input>\n >\n >;\n };\n\nexport type resolveStore<input> = resolveNamespaceMode<input> & {\n readonly tables: flattenNamespacedTables<resolveNamespaceMode<input>>;\n readonly sourceDirectory: \"sourceDirectory\" extends keyof input\n ? input[\"sourceDirectory\"]\n : CONFIG_DEFAULTS[\"sourceDirectory\"];\n readonly userTypes: \"userTypes\" extends keyof input ? input[\"userTypes\"] : {};\n readonly enums: \"enums\" extends keyof input ? show<resolveEnums<input[\"enums\"]>> : {};\n readonly enumValues: \"enums\" extends keyof input ? show<mapEnums<input[\"enums\"]>> : {};\n readonly codegen: \"codegen\" extends keyof input ? resolveCodegen<input[\"codegen\"]> : resolveCodegen<{}>;\n};\n\nexport function resolveStore<const input extends StoreInput>(input: input): resolveStore<input> {\n const scope = extendedScope(input);\n\n const baseNamespace = input.namespace ?? CONFIG_DEFAULTS[\"namespace\"];\n const namespaces = input.namespaces\n ? ({\n multipleNamespaces: true,\n namespace: null,\n namespaces: resolveNamespaces(input.namespaces, scope),\n } as const)\n : ({\n multipleNamespaces: false,\n namespace: baseNamespace,\n namespaces: resolveNamespaces({ [baseNamespace]: input }, scope),\n } as const);\n\n const tables = flattenNamespacedTables(namespaces as never);\n\n return {\n ...namespaces,\n tables,\n sourceDirectory: input.sourceDirectory ?? CONFIG_DEFAULTS[\"sourceDirectory\"],\n userTypes: input.userTypes ?? {},\n enums: resolveEnums(input.enums ?? {}),\n enumValues: mapEnums(input.enums ?? {}),\n codegen: resolveCodegen(input.codegen),\n } as never;\n}\n\nexport function defineStore<const input>(input: validateStore<input>): show<resolveStore<input>> {\n validateStore(input);\n return resolveStore(input) as never;\n}\n"],"mappings":";AAIO,SAAS,IAAoC,OAAc,KAA2B;AAC3F,SAAQ,OAAO,UAAU,YAAY,SAAS,QAAQ,UAAU,OAAO,GAAG,IAAI,MAAM,GAAG,IAAI;AAC7F;AAWO,SAAS,QAAoD,OAAc,MAAkC;AAClH,SAAO,KAAK,SAAU,QAAQ,IAAI,OAAO,KAAK,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,IAAe;AACjF;AAEO,SAAS,UACd,QACA,KACwE;AAExE,SAAO,OAAO,WAAW,YAAY,WAAW,QAAQ,OAAO,eAAe,GAAG;AACnF;AAEO,SAAS,SAAgB,OAAuC;AACrE,SAAO,SAAS,QAAQ,OAAO,UAAU;AAC3C;AAcO,SAAS,iBACd,MACA,UACkC;AAClC,QAAM,OAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,IAAI,GAAG,GAAG,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC;AAC1E,SAAO,OAAO;AAAA,IACZ,KAAK,IAAI,CAAC,QAAQ;AA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BAAiB;AAAA,IAC3E,WAAW,MAAM,aAAa,CAAC;AAAA,IAC/B,OAAO,aAAa,MAAM,SAAS,CAAC,CAAC;AAAA,IACrC,YAAY,SAAS,MAAM,SAAS,CAAC,CAAC;AAAA,IACtC,SAAS,eAAe,MAAM,OAAO;AAAA,EACvC;AACF;AAEO,SAAS,YAAyB,OAAwD;AAC/F,gBAAc,KAAK;AACnB,SAAO,aAAa,KAAK;AAC3B;","names":["key","isFixedArrayAbiType","isStaticAbiType","isFixedArrayAbiType","isStaticAbiType","flatMorph","flatMorph","flatMorph","flatMorph"]}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// ts/storeEvents.ts
|
2
|
+
var helloStoreEvent = "event HelloStore(bytes32 indexed storeVersion)";
|
3
|
+
var storeSetRecordEvent = "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)";
|
4
|
+
var storeSpliceStaticDataEvent = "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)";
|
5
|
+
var storeSpliceDynamicDataEvent = "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)";
|
6
|
+
var storeDeleteRecordEvent = "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)";
|
7
|
+
var storeEvents = [
|
8
|
+
storeSetRecordEvent,
|
9
|
+
storeSpliceStaticDataEvent,
|
10
|
+
storeSpliceDynamicDataEvent,
|
11
|
+
storeDeleteRecordEvent
|
12
|
+
];
|
13
|
+
|
14
|
+
// ts/storeEventsAbi.ts
|
15
|
+
import { parseAbi } from "abitype";
|
16
|
+
var storeEventsAbi = parseAbi(storeEvents);
|
17
|
+
|
18
|
+
export {
|
19
|
+
helloStoreEvent,
|
20
|
+
storeSetRecordEvent,
|
21
|
+
storeSpliceStaticDataEvent,
|
22
|
+
storeSpliceDynamicDataEvent,
|
23
|
+
storeDeleteRecordEvent,
|
24
|
+
storeEvents,
|
25
|
+
storeEventsAbi
|
26
|
+
};
|
27
|
+
//# sourceMappingURL=chunk-ZBDA5HOY.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../ts/storeEvents.ts","../ts/storeEventsAbi.ts"],"sourcesContent":["export const helloStoreEvent = \"event HelloStore(bytes32 indexed storeVersion)\";\n\nexport const storeSetRecordEvent =\n \"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)\";\n\nexport const storeSpliceStaticDataEvent =\n \"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)\";\n\nexport const storeSpliceDynamicDataEvent =\n \"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)\";\n\nexport const storeDeleteRecordEvent = \"event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)\";\n\n// Store protocol events\nexport const storeEvents = [\n storeSetRecordEvent,\n storeSpliceStaticDataEvent,\n storeSpliceDynamicDataEvent,\n storeDeleteRecordEvent,\n] as const;\n","import { parseAbi, AbiEvent } from \"abitype\";\nimport { storeEvents } from \"./storeEvents\";\n\nexport const storeEventsAbi = parseAbi(storeEvents) satisfies readonly AbiEvent[];\nexport type storeEventsAbi = typeof storeEventsAbi;\n\nexport type StoreEventsAbi = typeof storeEventsAbi;\nexport type StoreEventsAbiItem = (typeof storeEventsAbi)[number];\n\nexport type StoreSetRecordEventAbiItem = StoreEventsAbiItem & { readonly name: \"Store_SetRecord\" };\n"],"mappings":"AAAO,
|
1
|
+
{"version":3,"sources":["../ts/storeEvents.ts","../ts/storeEventsAbi.ts"],"sourcesContent":["export const helloStoreEvent = \"event HelloStore(bytes32 indexed storeVersion)\";\n\nexport const storeSetRecordEvent =\n \"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)\";\n\nexport const storeSpliceStaticDataEvent =\n \"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)\";\n\nexport const storeSpliceDynamicDataEvent =\n \"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)\";\n\nexport const storeDeleteRecordEvent = \"event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)\";\n\n// Store protocol events\nexport const storeEvents = [\n storeSetRecordEvent,\n storeSpliceStaticDataEvent,\n storeSpliceDynamicDataEvent,\n storeDeleteRecordEvent,\n] as const;\n","import { parseAbi, AbiEvent } from \"abitype\";\nimport { storeEvents } from \"./storeEvents\";\n\nexport const storeEventsAbi = parseAbi(storeEvents) satisfies readonly AbiEvent[];\nexport type storeEventsAbi = typeof storeEventsAbi;\n\nexport type StoreEventsAbi = typeof storeEventsAbi;\nexport type StoreEventsAbiItem = (typeof storeEventsAbi)[number];\n\nexport type StoreSetRecordEventAbiItem = StoreEventsAbiItem & { readonly name: \"Store_SetRecord\" };\n"],"mappings":";AAAO,IAAM,kBAAkB;AAExB,IAAM,sBACX;AAEK,IAAM,6BACX;AAEK,IAAM,8BACX;AAEK,IAAM,yBAAyB;AAG/B,IAAM,cAAc;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACnBA,SAAS,gBAA0B;AAG5B,IAAM,iBAAiB,SAAS,WAAW;","names":[]}
|