@latticexyz/store 3.0.0-main-8f6fa588d → 3.0.0-main-69e23a36b

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.
@@ -1,2 +1,2 @@
1
- import{H as h,I as S,J as y,a as s,c as r,d as n,l as a,q as p,s as c}from"./chunk-ZL5JTF5W.js";import{isFixedArrayAbiType as x,isStaticAbiType as T}from"@latticexyz/schema-type/internal";var F="Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.";function d(e){return typeof e=="string"||n(e)&&Object.values(e).every(t=>typeof t=="string")}function b(e,t=a){if(typeof e=="string"){if(x(e)||r(t.types,e))return;throw new Error(`Invalid ABI type. \`${e}\` not found in scope.`)}if(typeof e=="object"&&e!==null){if(p(e,t)){if(r(e,"id")&&T(t.types[e.id]))return;throw new Error("Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.")}throw new Error("Invalid schema. Are you using invalid types or missing types in your scope?")}throw new Error("Invalid table shorthand.")}function l(e,t=a){return p(e,t)?{schema:e,key:["id"]}:{schema:{id:"bytes32",value:e},key:["id"]}}function j(e,t=a){return b(e,t),l(e,t)}function u(e,t){if(n(e))for(let o of Object.keys(e))d(s(e,o))?b(s(e,o),t):c(s(e,o),t)}import{mapObject as f}from"@latticexyz/common/utils";function v(e){let t=h(e);r(e,"tables")&&n(e.tables)&&u(e.tables,t)}function m(e){let t=h(e),o={...e,tables:f(e.tables,i=>d(i)?l(i,t):i)};return S(o),y(o)}function q(e){return v(e),m(e)}export{F as a,d as b,b as c,l as d,j as e,u as f,v as g,m as h,q as i};
2
- //# sourceMappingURL=chunk-JFFK3JST.js.map
1
+ import{H as h,I as S,J as y,a as s,c as r,d as n,l as a,q as p,s as c}from"./chunk-ACZGBP2R.js";import{isFixedArrayAbiType as x,isStaticAbiType as T}from"@latticexyz/schema-type/internal";var F="Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.";function d(e){return typeof e=="string"||n(e)&&Object.values(e).every(t=>typeof t=="string")}function b(e,t=a){if(typeof e=="string"){if(x(e)||r(t.types,e))return;throw new Error(`Invalid ABI type. \`${e}\` not found in scope.`)}if(typeof e=="object"&&e!==null){if(p(e,t)){if(r(e,"id")&&T(t.types[e.id]))return;throw new Error("Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.")}throw new Error("Invalid schema. Are you using invalid types or missing types in your scope?")}throw new Error("Invalid table shorthand.")}function l(e,t=a){return p(e,t)?{schema:e,key:["id"]}:{schema:{id:"bytes32",value:e},key:["id"]}}function j(e,t=a){return b(e,t),l(e,t)}function u(e,t){if(n(e))for(let o of Object.keys(e))d(s(e,o))?b(s(e,o),t):c(s(e,o),t)}import{mapObject as f}from"@latticexyz/common/utils";function v(e){let t=h(e);r(e,"tables")&&n(e.tables)&&u(e.tables,t)}function m(e){let t=h(e),o={...e,tables:f(e.tables,i=>d(i)?l(i,t):i)};return S(o),y(o)}function q(e){return v(e),m(e)}export{F as a,d as b,b as c,l as d,j as e,u as f,v as g,m as h,q as i};
2
+ //# sourceMappingURL=chunk-6SXWMDLH.js.map
@@ -0,0 +1,2 @@
1
+ function p(e,t){return typeof e=="object"&&e!=null&&n(e,t)?e[t]:void 0}function K(e,t){return t.length?K(p(e,t[0]),t.slice(1)):e}function n(e,t){return typeof e=="object"&&e!==null&&e.hasOwnProperty(t)}function i(e){return e!=null&&typeof e=="object"}function c(e,t){let s=[...new Set([...Object.keys(e),...Object.keys(t)])];return Object.fromEntries(s.map(o=>[o,typeof e[o]>"u"?t[o]:e[o]]))}var b={storeImportPath:"@latticexyz/store/src/",userTypesFilename:"common.sol",outputDirectory:"codegen",namespaceDirectories:!1,indexFilename:"index.sol"},l={outputDirectory:"tables",tableIdArgument:!1,storeArgument:!1},I={disabled:!1},x={namespace:"",type:"table"},T={sourceDirectory:"src",namespace:""};import{schemaAbiTypes as $}from"@latticexyz/schema-type/internal";var re={types:{}},r={types:Object.fromEntries($.map(e=>[e,e]))};function d(e,t){return{types:{...e.types,...t}}}import{fixedArrayToArray as G,isFixedArrayAbiType as S}from"@latticexyz/schema-type/internal";function k(e,t=r){if(!i(e))throw new Error(`Expected schema, received ${JSON.stringify(e)}`);for(let s of Object.values(e))if(!S(s)&&!n(t.types,s))throw new Error(`"${String(s)}" is not a valid type in this scope.`)}function g(e,t=r){return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,{type:S(o)?G(o):t.types[o],internalType:o}]))}function de(e,t=r){return k(e,t),g(e,t)}function me(e,t=r){return typeof e=="object"&&e!=null&&Object.values(e).every(s=>S(s)||n(t.types,s))}import{isStaticAbiType as D}from"@latticexyz/schema-type/internal";import{resourceToHex as B}from"@latticexyz/common";function P(e,t=r){return Object.entries(e).filter(([,s])=>n(t.types,s)&&D(t.types[s])).map(([s])=>s)}function M(e,t,s=r){return Array.isArray(e)&&e.every(o=>n(t,o)&&n(s.types,t[o])&&D(s.types[t[o]]))}function E(e,t=r,s={inStoreContext:!1}){if(typeof e!="object"||e==null)throw new Error(`Expected full table config, got \`${JSON.stringify(e)}\``);if(!n(e,"schema"))throw new Error("Missing schema input");if(k(e.schema,t),!n(e,"key")||!M(e.key,e.schema,t))throw new Error(`Invalid key. Expected \`(${P(e.schema,t).map(o=>`"${String(o)}"`).join(" | ")})[]\`, received \`${n(e,"key")&&Array.isArray(e.key)?`[${e.key.map(o=>`"${o}"`).join(", ")}]`:String(p(e,"key"))}\``);if(n(e,"namespace")&&typeof e.namespace=="string"&&e.namespace.length>14)throw new Error(`Table \`namespace\` must fit into a \`bytes14\`, but "${e.namespace}" is too long.`);if(n(e,"name")&&typeof e.name=="string"&&e.name.length>16)throw new Error(`Table \`name\` must fit into a \`bytes16\`, but "${e.name}" is too long.`);if(s.inStoreContext&&(n(e,"label")||n(e,"namespace")))throw new Error("Overrides of `label` and `namespace` are not allowed for tables in a store config.")}function V(e){let t=e.codegen;return{outputDirectory:p(t,"outputDirectory")??l.outputDirectory,tableIdArgument:p(t,"tableIdArgument")??l.tableIdArgument,storeArgument:p(t,"storeArgument")??l.storeArgument,dataStruct:p(t,"dataStruct")??Object.keys(e.schema).length-e.key.length>1}}function h(e,t=r){let s=e.label,o=e.type??x.type,a=e.namespace??x.namespace,y=e.name??s.slice(0,16),u=B({type:o,namespace:a,name:y});return{label:s,type:o,namespace:a,name:y,tableId:u,schema:g(e.schema,t),key:e.key,codegen:V(e),deploy:c(e.deploy??{},I)}}function he(e,t=r){return E(e,t),h(e,t)}function v(e,t){if(i(e)){for(let s of Object.values(e))E(s,t,{inStoreContext:!0});return}throw new Error(`Expected store config, received ${JSON.stringify(e)}`)}function m(e,t){return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,h(c(o,{label:s}),t)]))}import{mapObject as W}from"@latticexyz/common/utils";import{isSchemaAbiType as Y}from"@latticexyz/schema-type/internal";function q(e){return W(e,t=>t.type)}function J(e){return i(e)&&Object.values(e).every(t=>Y(t.type))}function O(e,t=r){return J(e)?d(t,q(e)):t}function w(e){if(!i(e))throw new Error(`Expected userTypes, received ${JSON.stringify(e)}`);for(let{type:t}of Object.values(e))if(!n(r.types,t))throw new Error(`"${String(t)}" is not a valid ABI type.`)}import{flatMorph as U}from"@arktype/util";function H(e){return typeof e=="object"&&e!=null&&Object.values(e).every(t=>Array.isArray(t)&&t.every(s=>typeof s=="string"))}function L(e,t=r){if(H(e)){let s=Object.fromEntries(Object.keys(e).map(o=>[o,"uint8"]));return d(t,s)}return t}function R(e){return e}function C(e){return U(e,(t,s)=>[t,U(s,(o,a)=>[a,o])])}function _(e){return i(e)?c(e,b):b}import{flatMorph as z}from"@arktype/util";function N(e,t){return z(e,(s,o)=>[t===""?s:`${t}__${s}`,o])}import{flatMorph as X}from"@arktype/util";import{flatMorph as Q}from"@arktype/util";function F(e,t){let s=e.label,o=e.namespace??s.slice(0,14);return{label:s,namespace:o,tables:m(Q(e.tables??{},(a,y)=>[a,c(y,{namespace:o})]),t)}}function j(e){return L(p(e,"enums"),O(p(e,"userTypes")))}function Z(e){let t=j(e);if(n(e,"namespace")&&typeof e.namespace=="string"&&e.namespace.length>14)throw new Error(`\`namespace\` must fit into a \`bytes14\`, but "${e.namespace}" is too long.`);n(e,"tables")&&v(e.tables,t),n(e,"userTypes")&&w(e.userTypes)}function ee(e){let t=j(e),s=e.namespace??T.namespace,o=_(e.codegen),a=X(e.tables??{},(A,f)=>[A,{...f,label:A,namespace:s,codegen:{...f.codegen,outputDirectory:f.codegen?.outputDirectory??(o.namespaceDirectories&&s!==""?`${s}/tables`:"tables")}}]),y={[s]:F({label:s,tables:a},t)},u=m(a,t);return{namespace:s,tables:N(u,s),namespaces:y,sourceDirectory:e.sourceDirectory??T.sourceDirectory,userTypes:e.userTypes??{},enums:e.enums??{},enumValues:C(e.enums??{}),codegen:o}}function rt(e){return Z(e),ee(e)}export{p as a,K as b,n as c,i as d,c as e,b as f,l as g,I as h,x as i,T as j,re as k,r as l,d as m,k as n,g as o,de as p,me as q,M as r,E as s,V as t,h as u,he as v,v as w,m as x,q as y,J as z,O as A,w as B,L as C,R as D,C as E,_ as F,N as G,j as H,Z as I,ee as J,rt as K};
2
+ //# sourceMappingURL=chunk-ACZGBP2R.js.map
@@ -0,0 +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/tables.ts","../ts/config/v2/userTypes.ts","../ts/config/v2/enums.ts","../ts/config/v2/codegen.ts","../ts/config/v2/namespacedTables.ts","../ts/config/v2/store.ts","../ts/config/v2/namespace.ts"],"sourcesContent":["export 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 // TODO: default to true if using top-level `namespaces` key (once its migrated to store)\n namespaceDirectories: false,\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 namespace: \"\",\n type: \"table\",\n} as const satisfies Pick<TableInput, \"namespace\" | \"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 \"@arktype/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 \"@arktype/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 \"@arktype/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\" | \"namespace\" : \"\"\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\" | \"namespace\"\n ? options[\"inStoreContext\"] extends true\n ? ErrorMessage<\"Overrides of `label` and `namespace` are not allowed for tables in a store config\">\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 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 (options.inStoreContext && (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespace\"))) {\n throw new Error(\"Overrides of `label` and `namespace` are not allowed for tables in a store config.\");\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 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: mergeIfUndefined<\n undefined extends input[\"deploy\"] ? {} : input[\"deploy\"],\n 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 label = input.label;\n const type = input.type ?? TABLE_DEFAULTS.type;\n const namespace = input.namespace ?? TABLE_DEFAULTS.namespace;\n const name = input.name ?? label.slice(0, 16);\n const tableId = resourceToHex({ type, namespace, name });\n\n return {\n label,\n type,\n namespace,\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 { ErrorMessage, show } from \"@arktype/util\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\nimport { TablesInput } from \"./input\";\nimport { Scope, AbiTypeScope } from \"./scope\";\nimport { validateTable, resolveTable } from \"./table\";\n\nexport type validateTables<tables, scope extends Scope = AbiTypeScope> = {\n [label in keyof tables]: tables[label] extends object\n ? validateTable<tables[label], scope, { inStoreContext: true }>\n : ErrorMessage<`Expected full table 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 validateTable(table, scope, { inStoreContext: true });\n }\n return;\n }\n throw new Error(`Expected store config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveTables<tables, scope extends Scope = AbiTypeScope> = show<{\n readonly [label in keyof tables]: resolveTable<mergeIfUndefined<tables[label], { label: label }>, scope>;\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(table, { label }), scope)];\n }),\n ) 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 \"@arktype/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] 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 { CODEGEN_DEFAULTS } from \"./defaults\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (\n isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS\n ) as resolveCodegen<codegen>;\n}\n","import { flatMorph } from \"@arktype/util\";\nimport { Tables } from \"./output\";\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport type resolveNamespacedTables<tables, namespace> = {\n readonly [label in keyof tables as namespace extends \"\"\n ? label\n : `${namespace & string}__${label & string}`]: tables[label];\n};\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport function resolveNamespacedTables<tables, namespace>(\n tables: tables,\n namespace: namespace,\n): resolveNamespacedTables<tables, namespace> {\n return flatMorph(tables as Tables, (label, table) => [\n namespace === \"\" ? label : `${namespace}__${label}`,\n table,\n ]) as never;\n}\n","import { ErrorMessage, show, flatMorph, narrow } from \"@arktype/util\";\nimport { get, hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { UserTypes } from \"./output\";\nimport { CONFIG_DEFAULTS } from \"./defaults\";\nimport { StoreInput } from \"./input\";\nimport { resolveTables, validateTables } from \"./tables\";\nimport { scopeWithUserTypes, validateUserTypes } from \"./userTypes\";\nimport { mapEnums, resolveEnums, scopeWithEnums } from \"./enums\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveNamespacedTables } from \"./namespacedTables\";\nimport { resolveTable } from \"./table\";\nimport { resolveNamespace } from \"./namespace\";\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 \"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, \"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 resolveStore<\n input,\n namespace = \"namespace\" extends keyof input\n ? input[\"namespace\"] extends string\n ? input[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"],\n> = {\n readonly namespace: string;\n readonly sourceDirectory: \"sourceDirectory\" extends keyof input\n ? input[\"sourceDirectory\"]\n : CONFIG_DEFAULTS[\"sourceDirectory\"];\n readonly tables: \"tables\" extends keyof input\n ? resolveNamespacedTables<\n {\n readonly [label in keyof input[\"tables\"]]: resolveTable<\n mergeIfUndefined<input[\"tables\"][label], { label: label; namespace: namespace }>,\n extendedScope<input>\n >;\n },\n namespace\n >\n : {};\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 readonly namespaces: {\n readonly [label in namespace & string]: resolveNamespace<\n {\n readonly label: label;\n readonly tables: \"tables\" extends keyof input ? input[\"tables\"] : undefined;\n },\n extendedScope<input>\n >;\n };\n};\n\nexport function resolveStore<const input extends StoreInput>(input: input): resolveStore<input> {\n const scope = extendedScope(input);\n const namespace = input.namespace ?? CONFIG_DEFAULTS[\"namespace\"];\n const codegen = resolveCodegen(input.codegen);\n\n const tablesInput = flatMorph(input.tables ?? {}, (label, table) => {\n return [\n label,\n {\n ...table,\n label,\n namespace,\n codegen: {\n ...table.codegen,\n outputDirectory:\n table.codegen?.outputDirectory ??\n (codegen.namespaceDirectories && namespace !== \"\" ? `${namespace}/tables` : \"tables\"),\n },\n },\n ];\n });\n\n const namespaces = {\n [namespace]: resolveNamespace({ label: namespace, tables: tablesInput }, scope),\n };\n\n const tables = resolveTables(tablesInput, scope);\n\n return {\n namespace,\n tables: resolveNamespacedTables(tables, namespace),\n namespaces,\n sourceDirectory: input.sourceDirectory ?? CONFIG_DEFAULTS[\"sourceDirectory\"],\n userTypes: input.userTypes ?? {},\n enums: resolveEnums(input.enums ?? {}),\n enumValues: mapEnums(input.enums ?? {}),\n 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","import { ErrorMessage, flatMorph } from \"@arktype/util\";\nimport { hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { NamespaceInput } from \"./input\";\nimport { resolveTables, validateTables } from \"./tables\";\nimport { AbiTypeScope, Scope } from \"./scope\";\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 : resolveTables<\n {\n readonly [label in keyof input[\"tables\"]]: mergeIfUndefined<\n input[\"tables\"][label],\n { readonly namespace: string }\n >;\n },\n scope\n >;\n }\n : never;\n\nexport function resolveNamespace<const input extends NamespaceInput, scope extends Scope = AbiTypeScope>(\n input: input,\n scope: scope,\n): resolveNamespace<input, scope> {\n const label = input.label;\n const namespace = input.namespace ?? label.slice(0, 14);\n return {\n label,\n namespace,\n tables: resolveTables(\n flatMorph(input.tables ?? {}, (label, table) => {\n return [label, mergeIfUndefined(table, { namesp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,EAAM,WAAc,UAAYA,EAAM,UAAU,OAAS,GACnG,MAAM,IAAI,MAAM,mDAAmDA,EAAM,yBAAyB,EAGhGM,EAAUN,EAAO,QAAQ,GAC3BO,EAAeP,EAAM,OAAQK,CAAK,EAGhCC,EAAUN,EAAO,WAAW,GAC9BQ,EAAkBR,EAAM,SAAS,CAErC,CAwCO,SAASS,GAA6CT,EAAmC,CAC9F,IAAMK,EAAQN,EAAcC,CAAK,EAC3BU,EAAYV,EAAM,WAAaW,EAAgB,UAC/CC,EAAUC,EAAeb,EAAM,OAAO,EAEtCc,EAAcC,EAAUf,EAAM,QAAU,CAAC,EAAG,CAACgB,EAAOC,IACjD,CACLD,EACA,CACE,GAAGC,EACH,MAAAD,EACA,UAAAN,EACA,QAAS,CACP,GAAGO,EAAM,QACT,gBACEA,EAAM,SAAS,kBACdL,EAAQ,sBAAwBF,IAAc,GAAK,GAAGA,WAAqB,SAChF,CACF,CACF,CACD,EAEKQ,EAAa,CACjB,CAACR,CAAS,EAAGS,EAAiB,CAAE,MAAOT,EAAW,OAAQI,CAAY,EAAGT,CAAK,CAChF,EAEMe,EAASC,EAAcP,EAAaT,CAAK,EAE/C,MAAO,CACL,UAAAK,EACA,OAAQY,EAAwBF,EAAQV,CAAS,EACjD,WAAAQ,EACA,gBAAiBlB,EAAM,iBAAmBW,EAAgB,gBAC1D,UAAWX,EAAM,WAAa,CAAC,EAC/B,MAAoBA,EAAM,OAAS,CAAC,EACpC,WAAYuB,EAASvB,EAAM,OAAS,CAAC,CAAC,EACtC,QAAAY,CACF,CACF,CAEO,SAASY,GAAyBxB,EAAwD,CAC/F,OAAAI,EAAcJ,CAAK,EACZS,GAAaT,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","label","type","TABLE_DEFAULTS","namespace","name","tableId","resolveSchema","mergeIfUndefined","TABLE_DEPLOY_DEFAULTS","defineTable","validateTables","input","scope","isObject","table","validateTable","resolveTables","tables","label","resolveTable","mergeIfUndefined","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","resolveNamespacedTables","tables","namespace","label","table","flatMorph","flatMorph","resolveNamespace","input","scope","label","namespace","resolveTables","flatMorph","table","mergeIfUndefined","extendedScope","input","scopeWithEnums","get","scopeWithUserTypes","validateStore","scope","hasOwnKey","validateTables","validateUserTypes","resolveStore","namespace","CONFIG_DEFAULTS","codegen","resolveCodegen","tablesInput","flatMorph","label","table","namespaces","resolveNamespace","tables","resolveTables","resolveNamespacedTables","mapEnums","defineStore"]}
package/dist/codegen.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ImportDatum, StaticResourceData, RenderKeyTuple, RenderField, RenderStaticField, RenderDynamicField, RenderType, SolidityUserDefinedType } from '@latticexyz/common/codegen';
2
- import { S as Store } from './output-d041ff5d.js';
2
+ import { S as Store } from './output-5b3b98d5.js';
3
3
  import { SchemaType } from '@latticexyz/schema-type/deprecated';
4
4
  import '@arktype/util';
5
5
  import '@latticexyz/config';
@@ -1,6 +1,6 @@
1
1
  export { g as get, a as getPath, h as hasOwnKey, i as isObject, m as mergeIfUndefined, p as parseNumber, r as resolveNamespacedTables } from '../generics-627f4c31.js';
2
- export { A as AbiTypeScope, s as Codegen, C as CodegenInput, n as EnumValues, E as EnumsInput, c as SchemaInput, a as Scope, b as ScopeOptions, d as ScopedSchemaInput, S as Store, j as StoreInput, m as StoreWithShorthandsInput, q as Table, o as TableCodegen, T as TableCodegenInput, p as TableDeploy, f as TableDeployInput, h as TableInput, k as TableShorthandInput, r as Tables, i as TablesInput, l as TablesWithShorthandsInput, U as UserTypes, e as extendScope, g as getStaticAbiTypeKeys } from '../output-d041ff5d.js';
3
- export { D as CODEGEN_DEFAULTS, G as CONFIG_DEFAULTS, N as NoStaticKeyFieldError, T as TABLE_CODEGEN_DEFAULTS, F as TABLE_DEFAULTS, E as TABLE_DEPLOY_DEFAULTS, V as ValidKeys, p as ValidateTableOptions, a as defineSchema, C as defineStore, d as defineStoreWithShorthands, w as defineTable, g as defineTableShorthand, z as extendedScope, L as extractInternalType, i as isSchemaInput, b as isTableShorthandInput, M as isUserTypes, n as isValidPrimaryKey, K as mapEnums, q as requiredTableKey, H as resolveCodegen, J as resolveEnums, r as resolveSchema, B as resolveStore, m as resolveStoreWithShorthands, u as resolveTable, t as resolveTableCodegen, f as resolveTableShorthand, h as resolveTableWithShorthand, y as resolveTables, j as resolveTablesWithShorthands, I as scopeWithEnums, O as scopeWithUserTypes, o as validateKeys, v as validateSchema, A as validateStore, l as validateStoreWithShorthands, s as validateTable, e as validateTableShorthand, c as validateTableWithShorthand, x as validateTables, k as validateTablesWithShorthands, P as validateUserTypes } from '../storeWithShorthands-afb30624.js';
2
+ export { A as AbiTypeScope, s as Codegen, C as CodegenInput, n as EnumValues, E as EnumsInput, t as Namespace, N as NamespaceInput, u as Namespaces, c as SchemaInput, a as Scope, b as ScopeOptions, d as ScopedSchemaInput, S as Store, j as StoreInput, m as StoreWithShorthandsInput, q as Table, o as TableCodegen, T as TableCodegenInput, p as TableDeploy, f as TableDeployInput, h as TableInput, k as TableShorthandInput, r as Tables, i as TablesInput, l as TablesWithShorthandsInput, U as UserTypes, e as extendScope, g as getStaticAbiTypeKeys } from '../output-5b3b98d5.js';
3
+ export { D as CODEGEN_DEFAULTS, G as CONFIG_DEFAULTS, N as NoStaticKeyFieldError, T as TABLE_CODEGEN_DEFAULTS, F as TABLE_DEFAULTS, E as TABLE_DEPLOY_DEFAULTS, V as ValidKeys, p as ValidateTableOptions, a as defineSchema, C as defineStore, d as defineStoreWithShorthands, w as defineTable, g as defineTableShorthand, z as extendedScope, L as extractInternalType, i as isSchemaInput, b as isTableShorthandInput, M as isUserTypes, n as isValidPrimaryKey, K as mapEnums, q as requiredTableKey, H as resolveCodegen, J as resolveEnums, r as resolveSchema, B as resolveStore, m as resolveStoreWithShorthands, u as resolveTable, t as resolveTableCodegen, f as resolveTableShorthand, h as resolveTableWithShorthand, y as resolveTables, j as resolveTablesWithShorthands, I as scopeWithEnums, O as scopeWithUserTypes, o as validateKeys, v as validateSchema, A as validateStore, l as validateStoreWithShorthands, s as validateTable, e as validateTableShorthand, c as validateTableWithShorthand, x as validateTables, k as validateTablesWithShorthands, P as validateUserTypes } from '../storeWithShorthands-b5cb4574.js';
4
4
  export { AbiType, Schema } from '@latticexyz/config';
5
5
  import '@arktype/util';
6
6
  import 'viem';
package/dist/config/v2.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as L,b as M,c as N,d as O,e as P,f as Q,g as R,h as S,i as T}from"../chunk-JFFK3JST.js";import{A,B,C,D,E,F,G,H,I,J,K,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"../chunk-ZL5JTF5W.js";export{d as AbiTypeScope,p as CODEGEN_DEFAULTS,b as CONFIG_DEFAULTS,L as NoStaticKeyFieldError,c as Scope,t as TABLE_CODEGEN_DEFAULTS,a as TABLE_DEFAULTS,x as TABLE_DEPLOY_DEFAULTS,j as defineSchema,K as defineStore,T as defineStoreWithShorthands,u as defineTable,P as defineTableShorthand,g as extendScope,H as extendedScope,y as extractInternalType,o as get,r as getPath,e as hasOwnKey,f as isObject,k as isSchemaInput,M as isTableShorthandInput,z as isUserTypes,l as isValidPrimaryKey,E as mapEnums,m as mergeIfUndefined,F as resolveCodegen,D as resolveEnums,G as resolveNamespacedTables,i as resolveSchema,J as resolveStore,S as resolveStoreWithShorthands,s as resolveTable,q as resolveTableCodegen,O as resolveTableShorthand,w as resolveTables,C as scopeWithEnums,A as scopeWithUserTypes,h as validateSchema,I as validateStore,R as validateStoreWithShorthands,n as validateTable,N as validateTableShorthand,v as validateTables,Q as validateTablesWithShorthands,B as validateUserTypes};
1
+ import{a as L,b as M,c as N,d as O,e as P,f as Q,g as R,h as S,i as T}from"../chunk-6SXWMDLH.js";import{A,B,C,D,E,F,G,H,I,J,K,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"../chunk-ACZGBP2R.js";export{d as AbiTypeScope,p as CODEGEN_DEFAULTS,b as CONFIG_DEFAULTS,L as NoStaticKeyFieldError,c as Scope,t as TABLE_CODEGEN_DEFAULTS,a as TABLE_DEFAULTS,x as TABLE_DEPLOY_DEFAULTS,j as defineSchema,K as defineStore,T as defineStoreWithShorthands,u as defineTable,P as defineTableShorthand,g as extendScope,H as extendedScope,y as extractInternalType,o as get,r as getPath,e as hasOwnKey,f as isObject,k as isSchemaInput,M as isTableShorthandInput,z as isUserTypes,l as isValidPrimaryKey,E as mapEnums,m as mergeIfUndefined,F as resolveCodegen,D as resolveEnums,G as resolveNamespacedTables,i as resolveSchema,J as resolveStore,S as resolveStoreWithShorthands,s as resolveTable,q as resolveTableCodegen,O as resolveTableShorthand,w as resolveTables,C as scopeWithEnums,A as scopeWithUserTypes,h as validateSchema,I as validateStore,R as validateStoreWithShorthands,n as validateTable,N as validateTableShorthand,v as validateTables,Q as validateTablesWithShorthands,B as validateUserTypes};
2
2
  //# sourceMappingURL=v2.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { d as defineStore } from './storeWithShorthands-afb30624.js';
2
- export { S as Store } from './output-d041ff5d.js';
1
+ export { d as defineStore } from './storeWithShorthands-b5cb4574.js';
2
+ export { S as Store } from './output-5b3b98d5.js';
3
3
  import '@arktype/util';
4
4
  import './generics-627f4c31.js';
5
5
  import 'viem';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{i as n}from"./chunk-JFFK3JST.js";import"./chunk-ZL5JTF5W.js";var i="event HelloStore(bytes32 indexed storeVersion)",t="event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)",o="event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)",r="event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)",s="event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)",e=[t,o,r,s];import{parseAbi as a}from"abitype";var d=a(e);export{n as defineStore,i as helloStoreEvent,s as storeDeleteRecordEvent,e as storeEvents,d as storeEventsAbi,t as storeSetRecordEvent,r as storeSpliceDynamicDataEvent,o as storeSpliceStaticDataEvent};
1
+ import{i as n}from"./chunk-6SXWMDLH.js";import"./chunk-ACZGBP2R.js";var i="event HelloStore(bytes32 indexed storeVersion)",t="event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)",o="event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)",r="event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)",s="event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)",e=[t,o,r,s];import{parseAbi as a}from"abitype";var d=a(e);export{n as defineStore,i as helloStoreEvent,s as storeDeleteRecordEvent,e as storeEvents,d as storeEventsAbi,t as storeSetRecordEvent,r as storeSpliceDynamicDataEvent,o as storeSpliceStaticDataEvent};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,13 @@
1
1
  import { r as resolveNamespacedTables, m as mergeIfUndefined } from './generics-627f4c31.js';
2
2
 
3
3
  declare const _default: {
4
- readonly namespace: "store";
4
+ readonly namespace: string;
5
5
  readonly sourceDirectory: "src";
6
6
  readonly tables: resolveNamespacedTables<{
7
7
  readonly StoreHooks: {
8
8
  readonly label: "StoreHooks";
9
9
  readonly type: "table";
10
- readonly namespace: "store";
10
+ readonly namespace: string;
11
11
  readonly name: string;
12
12
  readonly tableId: `0x${string}`;
13
13
  readonly schema: {
@@ -34,7 +34,7 @@ declare const _default: {
34
34
  readonly Tables: {
35
35
  readonly label: "Tables";
36
36
  readonly type: "table";
37
- readonly namespace: "store";
37
+ readonly namespace: string;
38
38
  readonly name: string;
39
39
  readonly tableId: `0x${string}`;
40
40
  readonly schema: {
@@ -77,7 +77,7 @@ declare const _default: {
77
77
  readonly ResourceIds: {
78
78
  readonly label: "ResourceIds";
79
79
  readonly type: "table";
80
- readonly namespace: "store";
80
+ readonly namespace: string;
81
81
  readonly name: string;
82
82
  readonly tableId: `0x${string}`;
83
83
  readonly schema: {
@@ -104,7 +104,7 @@ declare const _default: {
104
104
  readonly Hooks: {
105
105
  readonly label: "Hooks";
106
106
  readonly type: "table";
107
- readonly namespace: "store";
107
+ readonly namespace: string;
108
108
  readonly name: string;
109
109
  readonly tableId: `0x${string}`;
110
110
  readonly schema: {
@@ -154,6 +154,138 @@ declare const _default: {
154
154
  readonly namespaceDirectories: false;
155
155
  readonly indexFilename: "index.sol";
156
156
  }>;
157
+ readonly namespaces: {
158
+ readonly store: {
159
+ readonly label: "store";
160
+ readonly namespace: string;
161
+ readonly tables: {
162
+ readonly StoreHooks: {
163
+ readonly label: "StoreHooks";
164
+ readonly type: "table";
165
+ readonly namespace: string;
166
+ readonly name: string;
167
+ readonly tableId: `0x${string}`;
168
+ readonly schema: {
169
+ readonly tableId: {
170
+ readonly type: "bytes32";
171
+ readonly internalType: "ResourceId";
172
+ };
173
+ readonly hooks: {
174
+ readonly type: "bytes21[]";
175
+ readonly internalType: "bytes21[]";
176
+ };
177
+ };
178
+ readonly key: readonly ["tableId"];
179
+ readonly codegen: {
180
+ readonly outputDirectory: string;
181
+ readonly tableIdArgument: false;
182
+ readonly storeArgument: false;
183
+ readonly dataStruct: boolean;
184
+ };
185
+ readonly deploy: mergeIfUndefined<{}, {
186
+ readonly disabled: false;
187
+ }>;
188
+ };
189
+ readonly Tables: {
190
+ readonly label: "Tables";
191
+ readonly type: "table";
192
+ readonly namespace: string;
193
+ readonly name: string;
194
+ readonly tableId: `0x${string}`;
195
+ readonly schema: {
196
+ readonly tableId: {
197
+ readonly type: "bytes32";
198
+ readonly internalType: "ResourceId";
199
+ };
200
+ readonly fieldLayout: {
201
+ readonly type: "bytes32";
202
+ readonly internalType: "FieldLayout";
203
+ };
204
+ readonly keySchema: {
205
+ readonly type: "bytes32";
206
+ readonly internalType: "Schema";
207
+ };
208
+ readonly valueSchema: {
209
+ readonly type: "bytes32";
210
+ readonly internalType: "Schema";
211
+ };
212
+ readonly abiEncodedKeyNames: {
213
+ readonly type: "bytes";
214
+ readonly internalType: "bytes";
215
+ };
216
+ readonly abiEncodedFieldNames: {
217
+ readonly type: "bytes";
218
+ readonly internalType: "bytes";
219
+ };
220
+ };
221
+ readonly key: readonly ["tableId"];
222
+ readonly codegen: {
223
+ readonly outputDirectory: string;
224
+ readonly tableIdArgument: false;
225
+ readonly storeArgument: false;
226
+ readonly dataStruct: boolean;
227
+ };
228
+ readonly deploy: mergeIfUndefined<{}, {
229
+ readonly disabled: false;
230
+ }>;
231
+ };
232
+ readonly ResourceIds: {
233
+ readonly label: "ResourceIds";
234
+ readonly type: "table";
235
+ readonly namespace: string;
236
+ readonly name: string;
237
+ readonly tableId: `0x${string}`;
238
+ readonly schema: {
239
+ readonly resourceId: {
240
+ readonly type: "bytes32";
241
+ readonly internalType: "ResourceId";
242
+ };
243
+ readonly exists: {
244
+ readonly type: "bool";
245
+ readonly internalType: "bool";
246
+ };
247
+ };
248
+ readonly key: readonly ["resourceId"];
249
+ readonly codegen: {
250
+ readonly outputDirectory: string;
251
+ readonly tableIdArgument: false;
252
+ readonly storeArgument: false;
253
+ readonly dataStruct: boolean;
254
+ };
255
+ readonly deploy: mergeIfUndefined<{}, {
256
+ readonly disabled: false;
257
+ }>;
258
+ };
259
+ readonly Hooks: {
260
+ readonly label: "Hooks";
261
+ readonly type: "table";
262
+ readonly namespace: string;
263
+ readonly name: string;
264
+ readonly tableId: `0x${string}`;
265
+ readonly schema: {
266
+ readonly resourceId: {
267
+ readonly type: "bytes32";
268
+ readonly internalType: "ResourceId";
269
+ };
270
+ readonly hooks: {
271
+ readonly type: "bytes21[]";
272
+ readonly internalType: "bytes21[]";
273
+ };
274
+ };
275
+ readonly key: readonly ["resourceId"];
276
+ readonly codegen: {
277
+ readonly outputDirectory: string;
278
+ readonly tableIdArgument: true;
279
+ readonly storeArgument: false;
280
+ readonly dataStruct: boolean;
281
+ };
282
+ readonly deploy: mergeIfUndefined<{}, {
283
+ readonly disabled: false;
284
+ }>;
285
+ };
286
+ };
287
+ };
288
+ };
157
289
  };
158
290
 
159
291
  export { _default as default };
@@ -1,2 +1,2 @@
1
- import{K as e}from"./chunk-ZL5JTF5W.js";var o=e({codegen:{storeImportPath:"../../"},namespace:"store",userTypes:{ResourceId:{filePath:"./src/ResourceId.sol",type:"bytes32"},FieldLayout:{filePath:"./src/FieldLayout.sol",type:"bytes32"},Schema:{filePath:"./src/Schema.sol",type:"bytes32"}},tables:{StoreHooks:{schema:{tableId:"ResourceId",hooks:"bytes21[]"},key:["tableId"]},Tables:{schema:{tableId:"ResourceId",fieldLayout:"FieldLayout",keySchema:"Schema",valueSchema:"Schema",abiEncodedKeyNames:"bytes",abiEncodedFieldNames:"bytes"},key:["tableId"]},ResourceIds:{schema:{resourceId:"ResourceId",exists:"bool"},key:["resourceId"]},Hooks:{schema:{resourceId:"ResourceId",hooks:"bytes21[]"},key:["resourceId"],codegen:{tableIdArgument:!0}}}});export{o as default};
1
+ import{K as e}from"./chunk-ACZGBP2R.js";var o=e({codegen:{storeImportPath:"../../"},namespace:"store",userTypes:{ResourceId:{filePath:"./src/ResourceId.sol",type:"bytes32"},FieldLayout:{filePath:"./src/FieldLayout.sol",type:"bytes32"},Schema:{filePath:"./src/Schema.sol",type:"bytes32"}},tables:{StoreHooks:{schema:{tableId:"ResourceId",hooks:"bytes21[]"},key:["tableId"]},Tables:{schema:{tableId:"ResourceId",fieldLayout:"FieldLayout",keySchema:"Schema",valueSchema:"Schema",abiEncodedKeyNames:"bytes",abiEncodedFieldNames:"bytes"},key:["tableId"]},ResourceIds:{schema:{resourceId:"ResourceId",exists:"bool"},key:["resourceId"]},Hooks:{schema:{resourceId:"ResourceId",hooks:"bytes21[]"},key:["resourceId"],codegen:{tableIdArgument:!0}}}});export{o as default};
2
2
  //# sourceMappingURL=mud.config.js.map
@@ -63,7 +63,20 @@ type TablesInput = {
63
63
  readonly [label: string]: Omit<TableInput, "label" | "namespace">;
64
64
  };
65
65
  type CodegenInput = Partial<Codegen>;
66
- type StoreInput = {
66
+ type NamespaceInput = {
67
+ /**
68
+ * Human-readable namespace label. Used as config keys and directory names.
69
+ * Labels are not length constrained like namespaces within resource IDs, but special characters should be avoided to be compatible with the filesystem, Solidity compiler, etc.
70
+ */
71
+ readonly label: string;
72
+ /**
73
+ * Namespace used in resource ID.
74
+ * Defaults to the first 16 characters of `label` if not set.
75
+ */
76
+ readonly namespace?: string;
77
+ readonly tables?: TablesInput;
78
+ };
79
+ type StoreInput = Omit<NamespaceInput, "label"> & {
67
80
  /**
68
81
  * Directory of Solidity source relative to the MUD config.
69
82
  * This is used to resolve other paths in the config, like codegen and user types.
@@ -71,8 +84,6 @@ type StoreInput = {
71
84
  * Defaults to `src` to match `foundry.toml`'s default. If you change this from the default, you may also need to configure foundry with the same source directory.
72
85
  */
73
86
  readonly sourceDirectory?: string;
74
- readonly namespace?: string;
75
- readonly tables?: TablesInput;
76
87
  readonly userTypes?: UserTypes;
77
88
  readonly enums?: EnumsInput;
78
89
  readonly codegen?: CodegenInput;
@@ -138,7 +149,22 @@ type Codegen = {
138
149
  readonly namespaceDirectories: boolean;
139
150
  readonly indexFilename: string;
140
151
  };
141
- type Store = {
152
+ type Namespace = {
153
+ /**
154
+ * Human-readable namespace label. Used as config keys and directory names.
155
+ * Labels are not length constrained like namespaces within resource IDs, but special characters should be avoided to be compatible with the filesystem, Solidity compiler, etc.
156
+ */
157
+ readonly label: string;
158
+ /**
159
+ * Namespace used in resource ID.
160
+ */
161
+ readonly namespace: string;
162
+ readonly tables: Tables;
163
+ };
164
+ type Namespaces = {
165
+ readonly [label: string]: Namespace;
166
+ };
167
+ type Store = Omit<Namespace, "label"> & {
142
168
  /**
143
169
  * Directory of Solidity source relative to the MUD config.
144
170
  * This is used to resolve other paths in the config, like codegen and user types.
@@ -146,14 +172,11 @@ type Store = {
146
172
  * Defaults to `src` to match `foundry.toml`'s default. If you change this from the default, you may also need to configure foundry with the same source directory.
147
173
  */
148
174
  readonly sourceDirectory: string;
149
- readonly tables: {
150
- readonly [label: string]: Table;
151
- };
152
175
  readonly userTypes: UserTypes;
153
176
  readonly enums: EnumsInput;
154
177
  readonly enumValues: EnumValues;
155
- readonly namespace: string;
156
178
  readonly codegen: Codegen;
179
+ readonly namespaces: Namespaces;
157
180
  };
158
181
 
159
- export { AbiTypeScope as A, CodegenInput as C, EnumsInput as E, Store as S, TableCodegenInput as T, UserTypes as U, Scope as a, ScopeOptions as b, SchemaInput as c, ScopedSchemaInput as d, extendScope as e, TableDeployInput as f, getStaticAbiTypeKeys as g, TableInput as h, TablesInput as i, StoreInput as j, TableShorthandInput as k, TablesWithShorthandsInput as l, StoreWithShorthandsInput as m, EnumValues as n, TableCodegen as o, TableDeploy as p, Table as q, Tables as r, Codegen as s };
182
+ export { AbiTypeScope as A, CodegenInput as C, EnumsInput as E, NamespaceInput as N, Store as S, TableCodegenInput as T, UserTypes as U, Scope as a, ScopeOptions as b, SchemaInput as c, ScopedSchemaInput as d, extendScope as e, TableDeployInput as f, getStaticAbiTypeKeys as g, TableInput as h, TablesInput as i, StoreInput as j, TableShorthandInput as k, TablesWithShorthandsInput as l, StoreWithShorthandsInput as m, EnumValues as n, TableCodegen as o, TableDeploy as p, Table as q, Tables as r, Codegen as s, Namespace as t, Namespaces as u };
@@ -1,6 +1,6 @@
1
1
  import { conform, show, requiredKeyOf, ErrorMessage, narrow } from '@arktype/util';
2
2
  import { g as get, m as mergeIfUndefined, p as parseNumber, r as resolveNamespacedTables } from './generics-627f4c31.js';
3
- import { a as Scope, A as AbiTypeScope, c as SchemaInput, g as getStaticAbiTypeKeys, h as TableInput, o as TableCodegen, i as TablesInput, U as UserTypes, e as extendScope, E as EnumsInput, j as StoreInput, k as TableShorthandInput, d as ScopedSchemaInput, l as TablesWithShorthandsInput, m as StoreWithShorthandsInput } from './output-d041ff5d.js';
3
+ import { a as Scope, A as AbiTypeScope, c as SchemaInput, g as getStaticAbiTypeKeys, h as TableInput, o as TableCodegen, i as TablesInput, U as UserTypes, e as extendScope, E as EnumsInput, N as NamespaceInput, j as StoreInput, k as TableShorthandInput, d as ScopedSchemaInput, l as TablesWithShorthandsInput, m as StoreWithShorthandsInput } from './output-5b3b98d5.js';
4
4
  import { Hex } from 'viem';
5
5
  import { FixedArrayAbiType, fixedArrayToArray } from '@latticexyz/schema-type/internal';
6
6
 
@@ -74,7 +74,7 @@ declare function resolveTableCodegen<input extends TableInput>(input: input): re
74
74
  type resolveTable<input, scope extends Scope = Scope> = input extends TableInput ? {
75
75
  readonly label: input["label"];
76
76
  readonly type: undefined extends input["type"] ? typeof TABLE_DEFAULTS.type : input["type"];
77
- readonly namespace: undefined extends input["namespace"] ? typeof TABLE_DEFAULTS.namespace : input["namespace"];
77
+ readonly namespace: string;
78
78
  readonly name: string;
79
79
  readonly tableId: Hex;
80
80
  readonly schema: resolveSchema<input["schema"], scope>;
@@ -125,6 +125,17 @@ declare function mapEnums<enums extends EnumsInput>(enums: enums): resolveEnums<
125
125
  type resolveCodegen<codegen> = codegen extends {} ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS> : CODEGEN_DEFAULTS;
126
126
  declare function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen>;
127
127
 
128
+ type resolveNamespace<input, scope extends Scope = AbiTypeScope> = input extends NamespaceInput ? {
129
+ readonly label: input["label"];
130
+ readonly namespace: string;
131
+ readonly tables: undefined extends input["tables"] ? {} : resolveTables<{
132
+ readonly [label in keyof input["tables"]]: mergeIfUndefined<input["tables"][label], {
133
+ readonly namespace: string;
134
+ }>;
135
+ }, scope>;
136
+ } : never;
137
+ declare function resolveNamespace<const input extends NamespaceInput, scope extends Scope = AbiTypeScope>(input: input, scope: scope): resolveNamespace<input, scope>;
138
+
128
139
  type extendedScope<input> = scopeWithEnums<get<input, "enums">, scopeWithUserTypes<get<input, "userTypes">>>;
129
140
  declare function extendedScope<input>(input: input): extendedScope<input>;
130
141
  type validateStore<input> = {
@@ -132,7 +143,7 @@ type validateStore<input> = {
132
143
  };
133
144
  declare function validateStore(input: unknown): asserts input is StoreInput;
134
145
  type resolveStore<input, namespace = "namespace" extends keyof input ? input["namespace"] extends string ? input["namespace"] : CONFIG_DEFAULTS["namespace"] : CONFIG_DEFAULTS["namespace"]> = {
135
- readonly namespace: namespace;
146
+ readonly namespace: string;
136
147
  readonly sourceDirectory: "sourceDirectory" extends keyof input ? input["sourceDirectory"] : CONFIG_DEFAULTS["sourceDirectory"];
137
148
  readonly tables: "tables" extends keyof input ? resolveNamespacedTables<{
138
149
  readonly [label in keyof input["tables"]]: resolveTable<mergeIfUndefined<input["tables"][label], {
@@ -144,6 +155,12 @@ type resolveStore<input, namespace = "namespace" extends keyof input ? input["na
144
155
  readonly enums: "enums" extends keyof input ? show<resolveEnums<input["enums"]>> : {};
145
156
  readonly enumValues: "enums" extends keyof input ? show<mapEnums<input["enums"]>> : {};
146
157
  readonly codegen: "codegen" extends keyof input ? resolveCodegen<input["codegen"]> : resolveCodegen<{}>;
158
+ readonly namespaces: {
159
+ readonly [label in namespace & string]: resolveNamespace<{
160
+ readonly label: label;
161
+ readonly tables: "tables" extends keyof input ? input["tables"] : undefined;
162
+ }, extendedScope<input>>;
163
+ };
147
164
  };
148
165
  declare function resolveStore<const input extends StoreInput>(input: input): resolveStore<input>;
149
166
  declare function defineStore<const input>(input: validateStore<input>): show<resolveStore<input>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/store",
3
- "version": "3.0.0-main-8f6fa588d",
3
+ "version": "3.0.0-main-69e23a36b",
4
4
  "description": "Store",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,10 +46,10 @@
46
46
  "abitype": "1.0.0",
47
47
  "arktype": "1.0.29-alpha",
48
48
  "viem": "2.9.20",
49
- "@latticexyz/common": "3.0.0-main-8f6fa588d",
50
- "@latticexyz/config": "3.0.0-main-8f6fa588d",
51
- "@latticexyz/protocol-parser": "3.0.0-main-8f6fa588d",
52
- "@latticexyz/schema-type": "3.0.0-main-8f6fa588d"
49
+ "@latticexyz/common": "3.0.0-main-69e23a36b",
50
+ "@latticexyz/config": "3.0.0-main-69e23a36b",
51
+ "@latticexyz/protocol-parser": "3.0.0-main-69e23a36b",
52
+ "@latticexyz/schema-type": "3.0.0-main-69e23a36b"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@arktype/attest": "0.7.5",
@@ -62,8 +62,8 @@
62
62
  "tsup": "^6.7.0",
63
63
  "tsx": "^3.12.6",
64
64
  "vitest": "0.34.6",
65
- "@latticexyz/abi-ts": "3.0.0-main-8f6fa588d",
66
- "@latticexyz/gas-report": "3.0.0-main-8f6fa588d"
65
+ "@latticexyz/abi-ts": "3.0.0-main-69e23a36b",
66
+ "@latticexyz/gas-report": "3.0.0-main-69e23a36b"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "pnpm run build:tightcoder && pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts && pnpm run build:js",
@@ -1,2 +0,0 @@
1
- function p(e,t){return typeof e=="object"&&e!=null&&n(e,t)?e[t]:void 0}function F(e,t){return t.length?F(p(e,t[0]),t.slice(1)):e}function n(e,t){return typeof e=="object"&&e!==null&&e.hasOwnProperty(t)}function a(e){return e!=null&&typeof e=="object"}function c(e,t){let s=[...new Set([...Object.keys(e),...Object.keys(t)])];return Object.fromEntries(s.map(o=>[o,typeof e[o]>"u"?t[o]:e[o]]))}var m={storeImportPath:"@latticexyz/store/src/",userTypesFilename:"common.sol",outputDirectory:"codegen",namespaceDirectories:!1,indexFilename:"index.sol"},l={outputDirectory:"tables",tableIdArgument:!1,storeArgument:!1},h={disabled:!1},f={namespace:"",type:"table"},b={sourceDirectory:"src",namespace:""};import{schemaAbiTypes as j}from"@latticexyz/schema-type/internal";var te={types:{}},r={types:Object.fromEntries(j.map(e=>[e,e]))};function u(e,t){return{types:{...e.types,...t}}}import{fixedArrayToArray as N,isFixedArrayAbiType as x}from"@latticexyz/schema-type/internal";function T(e,t=r){if(!a(e))throw new Error(`Expected schema, received ${JSON.stringify(e)}`);for(let s of Object.values(e))if(!x(s)&&!n(t.types,s))throw new Error(`"${String(s)}" is not a valid type in this scope.`)}function S(e,t=r){return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,{type:x(o)?N(o):t.types[o],internalType:o}]))}function ie(e,t=r){return T(e,t),S(e,t)}function ce(e,t=r){return typeof e=="object"&&e!=null&&Object.values(e).every(s=>x(s)||n(t.types,s))}import{isStaticAbiType as g}from"@latticexyz/schema-type/internal";import{resourceToHex as K}from"@latticexyz/common";function G(e,t=r){return Object.entries(e).filter(([,s])=>n(t.types,s)&&g(t.types[s])).map(([s])=>s)}function $(e,t,s=r){return Array.isArray(e)&&e.every(o=>n(t,o)&&n(s.types,t[o])&&g(s.types[t[o]]))}function k(e,t=r,s={inStoreContext:!1}){if(typeof e!="object"||e==null)throw new Error(`Expected full table config, got \`${JSON.stringify(e)}\``);if(!n(e,"schema"))throw new Error("Missing schema input");if(T(e.schema,t),!n(e,"key")||!$(e.key,e.schema,t))throw new Error(`Invalid key. Expected \`(${G(e.schema,t).map(o=>`"${String(o)}"`).join(" | ")})[]\`, received \`${n(e,"key")&&Array.isArray(e.key)?`[${e.key.map(o=>`"${o}"`).join(", ")}]`:String(p(e,"key"))}\``);if(n(e,"namespace")&&typeof e.namespace=="string"&&e.namespace.length>14)throw new Error(`Table \`namespace\` must fit into a \`bytes14\`, but "${e.namespace}" is too long.`);if(n(e,"name")&&typeof e.name=="string"&&e.name.length>16)throw new Error(`Table \`name\` must fit into a \`bytes16\`, but "${e.name}" is too long.`);if(s.inStoreContext&&(n(e,"label")||n(e,"namespace")))throw new Error("Overrides of `label` and `namespace` are not allowed for tables in a store config.")}function B(e){let t=e.codegen;return{outputDirectory:p(t,"outputDirectory")??l.outputDirectory,tableIdArgument:p(t,"tableIdArgument")??l.tableIdArgument,storeArgument:p(t,"storeArgument")??l.storeArgument,dataStruct:p(t,"dataStruct")??Object.keys(e.schema).length-e.key.length>1}}function E(e,t=r){let s=e.label,o=e.type??f.type,i=e.namespace??f.namespace,y=e.name??s.slice(0,16),d=K({type:o,namespace:i,name:y});return{label:s,type:o,namespace:i,name:y,tableId:d,schema:S(e.schema,t),key:e.key,codegen:B(e),deploy:c(e.deploy??{},h)}}function Se(e,t=r){return k(e,t),E(e,t)}function A(e,t){if(a(e)){for(let s of Object.values(e))k(s,t,{inStoreContext:!0});return}throw new Error(`Expected store config, received ${JSON.stringify(e)}`)}function v(e,t){return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,E(c(o,{label:s}),t)]))}import{mapObject as P}from"@latticexyz/common/utils";import{isSchemaAbiType as M}from"@latticexyz/schema-type/internal";function V(e){return P(e,t=>t.type)}function W(e){return a(e)&&Object.values(e).every(t=>M(t.type))}function I(e,t=r){return W(e)?u(t,V(e)):t}function D(e){if(!a(e))throw new Error(`Expected userTypes, received ${JSON.stringify(e)}`);for(let{type:t}of Object.values(e))if(!n(r.types,t))throw new Error(`"${String(t)}" is not a valid ABI type.`)}import{flatMorph as O}from"@arktype/util";function Y(e){return typeof e=="object"&&e!=null&&Object.values(e).every(t=>Array.isArray(t)&&t.every(s=>typeof s=="string"))}function w(e,t=r){if(Y(e)){let s=Object.fromEntries(Object.keys(e).map(o=>[o,"uint8"]));return u(t,s)}return t}function q(e){return e}function U(e){return O(e,(t,s)=>[t,O(s,(o,i)=>[i,o])])}function L(e){return a(e)?c(e,m):m}import{flatMorph as J}from"@arktype/util";function _(e,t){return J(e,(s,o)=>[t===""?s:`${t}__${s}`,o])}import{flatMorph as H}from"@arktype/util";function C(e){return w(p(e,"enums"),I(p(e,"userTypes")))}function R(e){let t=C(e);n(e,"tables")&&A(e.tables,t),n(e,"userTypes")&&D(e.userTypes)}function z(e){let t=C(e),s=e.namespace??b.namespace,o=L(e.codegen),i=v(H(e.tables??{},(y,d)=>[y,{...d,label:y,namespace:s,codegen:{...d.codegen,outputDirectory:d.codegen?.outputDirectory??(o.namespaceDirectories&&s!==""?`${s}/tables`:"tables")}}]),t);return{namespace:s,sourceDirectory:e.sourceDirectory??b.sourceDirectory,tables:_(i,s),userTypes:e.userTypes??{},enums:e.enums??{},enumValues:U(e.enums??{}),codegen:o}}function Re(e){return R(e),z(e)}export{p as a,F as b,n as c,a as d,c as e,m as f,l as g,h,f as i,b as j,te as k,r as l,u as m,T as n,S as o,ie as p,ce as q,$ as r,k as s,B as t,E as u,Se as v,A as w,v as x,V as y,W as z,I as A,D as B,w as C,q as D,U as E,L as F,_ as G,C as H,R as I,z as J,Re as K};
2
- //# sourceMappingURL=chunk-ZL5JTF5W.js.map
@@ -1 +0,0 @@
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/tables.ts","../ts/config/v2/userTypes.ts","../ts/config/v2/enums.ts","../ts/config/v2/codegen.ts","../ts/config/v2/namespacedTables.ts","../ts/config/v2/store.ts"],"sourcesContent":["export 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 // TODO: default to true if using top-level `namespaces` key (once its migrated to store)\n namespaceDirectories: false,\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 namespace: \"\",\n type: \"table\",\n} as const satisfies Pick<TableInput, \"namespace\" | \"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 \"@arktype/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 \"@arktype/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 \"@arktype/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\" | \"namespace\" : \"\"\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\" | \"namespace\"\n ? options[\"inStoreContext\"] extends true\n ? ErrorMessage<\"Overrides of `label` and `namespace` are not allowed for tables in a store config\">\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 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 (options.inStoreContext && (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespace\"))) {\n throw new Error(\"Overrides of `label` and `namespace` are not allowed for tables in a store config.\");\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 type: undefined extends input[\"type\"] ? typeof TABLE_DEFAULTS.type : input[\"type\"];\n readonly namespace: undefined extends input[\"namespace\"] ? typeof TABLE_DEFAULTS.namespace : input[\"namespace\"];\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: mergeIfUndefined<\n undefined extends input[\"deploy\"] ? {} : input[\"deploy\"],\n 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 label = input.label;\n const type = input.type ?? TABLE_DEFAULTS.type;\n const namespace = input.namespace ?? TABLE_DEFAULTS.namespace;\n const name = input.name ?? label.slice(0, 16);\n const tableId = resourceToHex({ type, namespace, name });\n\n return {\n label,\n type,\n namespace,\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 { ErrorMessage, show } from \"@arktype/util\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\nimport { TablesInput } from \"./input\";\nimport { Scope, AbiTypeScope } from \"./scope\";\nimport { validateTable, resolveTable } from \"./table\";\n\nexport type validateTables<tables, scope extends Scope = AbiTypeScope> = {\n [label in keyof tables]: tables[label] extends object\n ? validateTable<tables[label], scope, { inStoreContext: true }>\n : ErrorMessage<`Expected full table 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 validateTable(table, scope, { inStoreContext: true });\n }\n return;\n }\n throw new Error(`Expected store config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveTables<tables, scope extends Scope = AbiTypeScope> = show<{\n readonly [label in keyof tables]: resolveTable<mergeIfUndefined<tables[label], { label: label }>, scope>;\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(table, { label }), scope)];\n }),\n ) 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 \"@arktype/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] 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 { CODEGEN_DEFAULTS } from \"./defaults\";\nimport { isObject, mergeIfUndefined } from \"./generics\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (\n isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS\n ) as resolveCodegen<codegen>;\n}\n","import { flatMorph } from \"@arktype/util\";\nimport { Tables } from \"./output\";\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport type resolveNamespacedTables<tables, namespace> = {\n readonly [label in keyof tables as namespace extends \"\"\n ? label\n : `${namespace & string}__${label & string}`]: tables[label];\n};\n\n/**\n * @internal Only kept for backwards compatibility\n */\nexport function resolveNamespacedTables<tables, namespace>(\n tables: tables,\n namespace: namespace,\n): resolveNamespacedTables<tables, namespace> {\n return flatMorph(tables as Tables, (label, table) => [\n namespace === \"\" ? label : `${namespace}__${label}`,\n table,\n ]) as never;\n}\n","import { ErrorMessage, show, flatMorph, narrow } from \"@arktype/util\";\nimport { get, hasOwnKey, mergeIfUndefined } from \"./generics\";\nimport { UserTypes } from \"./output\";\nimport { CONFIG_DEFAULTS } from \"./defaults\";\nimport { StoreInput } from \"./input\";\nimport { resolveTables, validateTables } from \"./tables\";\nimport { scopeWithUserTypes, validateUserTypes } from \"./userTypes\";\nimport { mapEnums, resolveEnums, scopeWithEnums } from \"./enums\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveNamespacedTables } from \"./namespacedTables\";\nimport { resolveTable } from \"./table\";\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 \"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 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 resolveStore<\n input,\n namespace = \"namespace\" extends keyof input\n ? input[\"namespace\"] extends string\n ? input[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"]\n : CONFIG_DEFAULTS[\"namespace\"],\n> = {\n readonly namespace: namespace;\n readonly sourceDirectory: \"sourceDirectory\" extends keyof input\n ? input[\"sourceDirectory\"]\n : CONFIG_DEFAULTS[\"sourceDirectory\"];\n readonly tables: \"tables\" extends keyof input\n ? resolveNamespacedTables<\n {\n readonly [label in keyof input[\"tables\"]]: resolveTable<\n mergeIfUndefined<input[\"tables\"][label], { label: label; namespace: namespace }>,\n extendedScope<input>\n >;\n },\n namespace\n >\n : {};\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 const namespace = input.namespace ?? CONFIG_DEFAULTS[\"namespace\"];\n const codegen = resolveCodegen(input.codegen);\n\n const tables = resolveTables(\n flatMorph(input.tables ?? {}, (label, table) => {\n return [\n label,\n {\n ...table,\n label,\n namespace,\n codegen: {\n ...table.codegen,\n outputDirectory:\n table.codegen?.outputDirectory ??\n (codegen.namespaceDirectories && namespace !== \"\" ? `${namespace}/tables` : \"tables\"),\n },\n },\n ];\n }),\n scope,\n );\n\n return {\n namespace,\n sourceDirectory: input.sourceDirectory ?? CONFIG_DEFAULTS[\"sourceDirectory\"],\n tables: resolveNamespacedTables(tables, namespace),\n userTypes: input.userTypes ?? {},\n enums: resolveEnums(input.enums ?? {}),\n enumValues: mapEnums(input.enums ?? {}),\n 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":"AAEO,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,EAAeJ,CACjF,CAEO,SAASE,EACdG,EACAJ,EACwE,CAExE,OAAO,OAAOI,GAAW,UAAYA,IAAW,MAAQA,EAAO,eAAeJ,CAAG,CACnF,CAEO,SAASK,EAAgBN,EAAuC,CACrE,OAAOA,GAAS,MAAQ,OAAOA,GAAU,QAC3C,CAcO,SAASO,EACdC,EACAC,EACkC,CAClC,IAAMC,EAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,OAAO,KAAKF,CAAI,EAAG,GAAG,OAAO,KAAKC,CAAQ,CAAC,CAAC,CAAC,EAC1E,OAAO,OAAO,YACZC,EAAK,IAAKT,GAAQ,CAChBA,EACA,OAAOO,EAAKP,CAAiB,EAAM,IAAcQ,EAASR,CAAqB,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O,WAAW,CAAC,CAAC,CACxF,CAcO,SAASI,EAAcJ,EAA6C,CACzE,IAAMK,EAAQN,EAAcC,CAAK,EAC7BM,EAAUN,EAAO,QAAQ,GAC3BO,EAAeP,EAAM,OAAQK,CAAK,EAGhCC,EAAUN,EAAO,WAAW,GAC9BQ,EAAkBR,EAAM,SAAS,CAErC,CA+BO,SAASS,EAA6CT,EAAmC,CAC9F,IAAMK,EAAQN,EAAcC,CAAK,EAC3BU,EAAYV,EAAM,WAAaW,EAAgB,UAC/CC,EAAUC,EAAeb,EAAM,OAAO,EAEtCc,EAASC,EACbC,EAAUhB,EAAM,QAAU,CAAC,EAAG,CAACiB,EAAOC,IAC7B,CACLD,EACA,CACE,GAAGC,EACH,MAAAD,EACA,UAAAP,EACA,QAAS,CACP,GAAGQ,EAAM,QACT,gBACEA,EAAM,SAAS,kBACdN,EAAQ,sBAAwBF,IAAc,GAAK,GAAGA,WAAqB,SAChF,CACF,CACF,CACD,EACDL,CACF,EAEA,MAAO,CACL,UAAAK,EACA,gBAAiBV,EAAM,iBAAmBW,EAAgB,gBAC1D,OAAQQ,EAAwBL,EAAQJ,CAAS,EACjD,UAAWV,EAAM,WAAa,CAAC,EAC/B,MAAoBA,EAAM,OAAS,CAAC,EACpC,WAAYoB,EAASpB,EAAM,OAAS,CAAC,CAAC,EACtC,QAAAY,CACF,CACF,CAEO,SAASS,GAAyBrB,EAAwD,CAC/F,OAAAI,EAAcJ,CAAK,EACZS,EAAaT,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","label","type","TABLE_DEFAULTS","namespace","name","tableId","resolveSchema","mergeIfUndefined","TABLE_DEPLOY_DEFAULTS","defineTable","validateTables","input","scope","isObject","table","validateTable","resolveTables","tables","label","resolveTable","mergeIfUndefined","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","resolveNamespacedTables","tables","namespace","label","table","flatMorph","extendedScope","input","scopeWithEnums","get","scopeWithUserTypes","validateStore","scope","hasOwnKey","validateTables","validateUserTypes","resolveStore","namespace","CONFIG_DEFAULTS","codegen","resolveCodegen","tables","resolveTables","flatMorph","label","table","resolveNamespacedTables","mapEnums","defineStore"]}