@latticexyz/store 2.0.13-main-609de113f → 3.0.0-main-560fd6a0c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4TPTNI2Q.js → chunk-ULFS6I46.js} +2 -2
- package/dist/{chunk-4TPTNI2Q.js.map → chunk-ULFS6I46.js.map} +1 -1
- package/dist/chunk-YSCNU2IH.js +2 -0
- package/dist/chunk-YSCNU2IH.js.map +1 -0
- package/dist/codegen.d.ts +1 -1
- package/dist/codegen.js +52 -52
- package/dist/codegen.js.map +1 -1
- package/dist/config/v2.d.ts +3 -3
- package/dist/config/v2.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +1 -26
- package/dist/internal.js +0 -1
- package/dist/mud.config.d.ts +129 -38
- package/dist/mud.config.js +1 -1
- package/dist/namespacedTables-bf676cf3.d.ts +12 -0
- package/dist/{output-2853398e.d.ts → output-672c1950.d.ts} +26 -7
- package/dist/{store-cb0f85e1.d.ts → storeWithShorthands-a1806a91.d.ts} +83 -33
- package/package.json +7 -16
- package/dist/chunk-M5RJAVGF.js +0 -2
- package/dist/chunk-M5RJAVGF.js.map +0 -1
- package/dist/chunk-RRYXNY5P.js +0 -2
- package/dist/chunk-RRYXNY5P.js.map +0 -1
- package/dist/config.d.ts +0 -6
- package/dist/config.js +0 -2
- package/dist/config.js.map +0 -1
- package/dist/register.d.ts +0 -22
- package/dist/register.js +0 -2
- package/dist/register.js.map +0 -1
- package/dist/storeConfig-55cad8c2.d.ts +0 -939
- package/dist/storeWithShorthands-43aad36b.d.ts +0 -57
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../ts/config/defaults.ts","../ts/config/storeConfig.ts"],"sourcesContent":["export const DEFAULTS = {\n namespace: \"\",\n enums: {},\n userTypes: {},\n} as const;\n\nexport type DEFAULTS = typeof DEFAULTS;\n\nexport const TABLE_DEFAULTS = {\n directory: \"tables\",\n keySchema: { key: \"bytes32\" },\n tableIdArgument: false,\n storeArgument: false,\n offchainOnly: false,\n} as const;\n\nexport type TABLE_DEFAULTS = typeof TABLE_DEFAULTS;\n","import { AbiType, AbiTypes, StaticAbiType, StaticAbiTypes, StaticArray } from \"@latticexyz/schema-type/deprecated\";\nimport { RefinementCtx, z, ZodIssueCode } from \"zod\";\nimport type {\n AsDependent,\n ExtractUserTypes,\n OrDefaults,\n RequireKeys,\n StringForUnion,\n} from \"@latticexyz/common/type-utils\";\nimport {\n // validation utils\n getDuplicates,\n parseStaticArray,\n STORE_NAME_MAX_LENGTH,\n // config\n MUDCoreUserConfig,\n // schemas\n zObjectName,\n zUserEnum,\n zValueName,\n zNamespace,\n zName,\n} from \"@latticexyz/config/library\";\nimport { DEFAULTS, TABLE_DEFAULTS } from \"./defaults\";\nimport { UserType } from \"@latticexyz/common/codegen\";\nimport { SchemaAbiType, isSchemaAbiType, schemaAbiTypes } from \"@latticexyz/schema-type/internal\";\n\nconst zTableName = zObjectName;\nconst zKeyName = zValueName;\nconst zColumnName = zValueName;\nconst zUserEnumName = zObjectName;\nconst zUserTypeName = zObjectName;\n\n// Fields can use AbiType or one of user-defined wrapper types\n// (user types are refined later, based on the appropriate config options)\nconst zFieldData = z.string();\n\nexport type FieldData<UserTypes extends StringForUnion> = AbiType | StaticArray | UserTypes;\n\n// Primary keys allow only static types\n// (user types are refined later, based on the appropriate config options)\nconst zKeyElementSchema = z.string();\nconst zKeySchema = z.record(zKeyName, zKeyElementSchema).default(TABLE_DEFAULTS.keySchema);\n\ntype KeySchema<StaticUserTypes extends StringForUnion> = StaticAbiType | StaticUserTypes;\n\n/************************************************************************\n *\n * TABLE SCHEMA\n *\n ************************************************************************/\n\nexport type FullSchemaConfig<UserTypes extends StringForUnion = StringForUnion> = Record<string, FieldData<UserTypes>>;\nexport type ShorthandSchemaConfig<UserTypes extends StringForUnion = StringForUnion> = FieldData<UserTypes>;\nexport type SchemaConfig<UserTypes extends StringForUnion = StringForUnion> =\n | FullSchemaConfig<UserTypes>\n | ShorthandSchemaConfig<UserTypes>;\n\nexport type ExpandSchemaConfig<TSchemaConfig extends SchemaConfig<string>> =\n TSchemaConfig extends ShorthandSchemaConfig<string> ? { value: TSchemaConfig } : TSchemaConfig;\n\nconst zFullSchemaConfig = z\n .record(zColumnName, zFieldData)\n .refine((arg) => Object.keys(arg).length > 0, \"Table schema may not be empty\");\n\nconst zShorthandSchemaConfig = zFieldData.transform((fieldData) => {\n return zFullSchemaConfig.parse({\n value: fieldData,\n });\n});\n\nexport const zSchemaConfig = zFullSchemaConfig.or(zShorthandSchemaConfig);\n\ntype ResolvedSchema<\n TSchema extends Record<string, string>,\n TUserTypes extends Record<string, Pick<UserType, \"internalType\">>,\n> = {\n [key in keyof TSchema]: TSchema[key] extends keyof TUserTypes\n ? TUserTypes[TSchema[key]][\"internalType\"]\n : TSchema[key];\n};\n\n// TODO: add strong types to UserTypes config and use them here\n// (see https://github.com/latticexyz/mud/pull/1588)\nexport function resolveUserTypes<\n TSchema extends Record<string, string>,\n TUserTypes extends Record<string, Pick<UserType, \"internalType\">>,\n>(schema: TSchema, userTypes: TUserTypes): ResolvedSchema<TSchema, TUserTypes> {\n const resolvedSchema: Record<string, SchemaAbiType> = {};\n for (const [key, value] of Object.entries(schema)) {\n if (isSchemaAbiType(value)) {\n resolvedSchema[key] = value;\n } else if (userTypes[value] !== undefined) {\n resolvedSchema[key] = userTypes[value].internalType as SchemaAbiType;\n } else {\n const staticArray = parseStaticArray(value);\n if (!staticArray) throw new Error(`Unexpected type: ${value}`);\n resolvedSchema[key] = `${staticArray.elementType as StaticAbiType}[]`;\n }\n }\n return resolvedSchema as ResolvedSchema<TSchema, TUserTypes>;\n}\n\n/************************************************************************\n *\n * TABLE\n *\n ************************************************************************/\n\nexport interface TableConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> {\n /** Output directory path for the file. Default is \"tables\" */\n directory?: string;\n /** Make methods accept `tableId` argument instead of it being a hardcoded constant. Default is false */\n tableIdArgument?: boolean;\n /** Include methods that accept a manual `IStore` argument. Default is true. */\n storeArgument?: boolean;\n /** Include a data struct and methods for it. Default is false for 1-column tables; true for multi-column tables. */\n dataStruct?: boolean;\n /** Offchain tables don't write to onchain storage, but only emit events for offchain clients. Default is false. */\n offchainOnly?: boolean;\n /**\n * Table's key names mapped to their types.\n * Default is `{ key: \"bytes32\" }`\n * Key names' first letter should be lowercase.\n */\n keySchema?: Record<string, KeySchema<StaticUserTypes>>;\n /**\n * Table's field names mapped to their types.\n * Field names' first letter should be lowercase.\n */\n valueSchema: SchemaConfig<UserTypes>;\n}\n\nexport type FullTableConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> = Required<TableConfig<UserTypes, StaticUserTypes>> & {\n valueSchema: FullSchemaConfig<UserTypes>;\n};\n\nexport interface ExpandTableConfig<T extends TableConfig<string, string>, TableName extends string>\n extends OrDefaults<\n T,\n {\n directory: string;\n name: TableName;\n tableIdArgument: typeof TABLE_DEFAULTS.tableIdArgument;\n storeArgument: typeof TABLE_DEFAULTS.storeArgument;\n // dataStruct isn't expanded, because its value is conditional on the number of value schema fields\n dataStruct: boolean;\n keySchema: typeof TABLE_DEFAULTS.keySchema;\n offchainOnly: typeof TABLE_DEFAULTS.offchainOnly;\n }\n > {\n valueSchema: ExpandSchemaConfig<T[\"valueSchema\"]>;\n}\n\nconst zFullTableConfig = z\n .object({\n directory: z.string().default(TABLE_DEFAULTS.directory),\n name: zName.optional(),\n tableIdArgument: z.boolean().default(TABLE_DEFAULTS.tableIdArgument),\n storeArgument: z.boolean().default(TABLE_DEFAULTS.storeArgument),\n dataStruct: z.boolean().optional(),\n keySchema: zKeySchema,\n valueSchema: zSchemaConfig,\n offchainOnly: z.boolean().default(TABLE_DEFAULTS.offchainOnly),\n })\n .transform((arg) => {\n // default dataStruct value depends on value schema's length\n if (Object.keys(arg.valueSchema).length === 1) {\n arg.dataStruct ??= false;\n } else {\n arg.dataStruct ??= true;\n }\n return arg as RequireKeys<typeof arg, \"dataStruct\">;\n });\n\nconst zShorthandTableConfig = zFieldData.transform((fieldData) => {\n return zFullTableConfig.parse({\n valueSchema: {\n value: fieldData,\n },\n });\n});\n\nexport const zTableConfig = zFullTableConfig.or(zShorthandTableConfig);\n\n/************************************************************************\n *\n * TABLES\n *\n ************************************************************************/\n\nexport type TablesConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> = Record<string, TableConfig<UserTypes, StaticUserTypes> | FieldData<UserTypes>>;\n\nexport const zTablesConfig = z.record(zTableName, zTableConfig).transform((tables) => {\n // default name depends on tableName\n for (const tableName of Object.keys(tables)) {\n const table = tables[tableName];\n table.name = tableName.slice(0, STORE_NAME_MAX_LENGTH);\n\n tables[tableName] = table;\n }\n return tables as Record<string, RequireKeys<(typeof tables)[string], \"name\">>;\n});\n\nexport type FullTablesConfig<\n UserTypes extends StringForUnion = StringForUnion,\n StaticUserTypes extends StringForUnion = StringForUnion,\n> = Record<string, FullTableConfig<UserTypes, StaticUserTypes>>;\n\nexport type ExpandTablesConfig<T extends TablesConfig<string, string>> = {\n [TableName in keyof T]: T[TableName] extends FieldData<string>\n ? ExpandTableConfig<{ valueSchema: { value: T[TableName] } }, TableName extends string ? TableName : never>\n : T[TableName] extends TableConfig<string, string>\n ? ExpandTableConfig<T[TableName], TableName extends string ? TableName : never>\n : // Weakly typed values get a weakly typed expansion.\n // This shouldn't normally happen within `mudConfig`, but can be manually triggered via `ExpandMUDUserConfig`\n ExpandTableConfig<TableConfig<string, string>, TableName extends string ? TableName : string>;\n};\n\n/************************************************************************\n *\n * ENUMS\n *\n ************************************************************************/\n\nexport type EnumsConfig<EnumNames extends StringForUnion> = never extends EnumNames\n ? {\n /**\n * Enum names mapped to lists of their member names\n *\n * (enums are inferred to be absent)\n */\n enums?: Record<EnumNames, string[]>;\n }\n : StringForUnion extends EnumNames\n ? {\n /**\n * Enum names mapped to lists of their member names\n *\n * (enums aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables)\n */\n enums?: Record<EnumNames, string[]>;\n }\n : {\n /**\n * Enum names mapped to lists of their member names\n *\n * Enums defined here can be used as types in table schemas/keys\n */\n enums: Record<EnumNames, string[]>;\n };\n\nexport type FullEnumsConfig<EnumNames extends StringForUnion> = {\n enums: Record<EnumNames, string[]>;\n};\n\nexport const zEnumsConfig = z.object({\n enums: z.record(zUserEnumName, zUserEnum).default(DEFAULTS.enums),\n});\n\n/************************************************************************\n *\n * USER TYPES\n *\n ************************************************************************/\n\nexport type UserTypesConfig<UserTypeNames extends StringForUnion = StringForUnion> = never extends UserTypeNames\n ? {\n /**\n * User types mapped to file paths from which to import them.\n * Paths are treated as relative to root.\n * Paths that don't start with a \".\" have foundry remappings applied to them first.\n *\n * (user types are inferred to be absent)\n */\n userTypes?: Record<UserTypeNames, UserType>;\n }\n : StringForUnion extends UserTypeNames\n ? {\n /**\n * User types mapped to file paths from which to import them.\n * Paths are treated as relative to root.\n * Paths that don't start with a \".\" have foundry remappings applied to them first.\n *\n * (user types aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables)\n */\n userTypes?: Record<UserTypeNames, UserType>;\n }\n : {\n /**\n * User types mapped to file paths from which to import them.\n * Paths are treated as relative to root.\n * Paths that don't start with a \".\" have foundry remappings applied to them first.\n *\n * User types defined here can be used as types in table schemas/keys\n */\n userTypes: Record<UserTypeNames, UserType>;\n };\n\nconst zUserTypeConfig = z.object({\n filePath: z.string(),\n internalType: z.enum(schemaAbiTypes),\n});\n\nexport const zUserTypesConfig = z.object({\n userTypes: z.record(zUserTypeName, zUserTypeConfig).default(DEFAULTS.userTypes),\n});\n\n/************************************************************************\n *\n * FINAL\n *\n ************************************************************************/\n\n// zod doesn't preserve doc comments\n/** MUDCoreUserConfig wrapper to use generics in some options for better type inference */\nexport type MUDUserConfig<\n T extends MUDCoreUserConfig = MUDCoreUserConfig,\n EnumNames extends StringForUnion = StringForUnion,\n UserTypeNames extends StringForUnion = StringForUnion,\n StaticUserTypes extends ExtractUserTypes<EnumNames | UserTypeNames> = ExtractUserTypes<EnumNames | UserTypeNames>,\n> = T &\n EnumsConfig<EnumNames> &\n UserTypesConfig<UserTypeNames> & {\n /**\n * Configuration for each table.\n *\n * The key is the table name (capitalized).\n *\n * The value:\n * - abi or user type for a single-value table.\n * - FullTableConfig object for multi-value tables (or for customizable options).\n */\n tables: TablesConfig<AsDependent<StaticUserTypes>, AsDependent<StaticUserTypes>>;\n /** The namespace for table ids. Default is \"\" (ROOT) */\n namespace?: string;\n };\n\nconst StoreConfigUnrefined = z\n .object({\n namespace: zNamespace.default(DEFAULTS.namespace),\n tables: zTablesConfig,\n })\n .merge(zEnumsConfig)\n .merge(zUserTypesConfig);\n\n// finally validate global conditions\nexport const zStoreConfig = StoreConfigUnrefined.superRefine(validateStoreConfig);\n\nexport type StoreUserConfig = z.input<typeof zStoreConfig>;\nexport type StoreConfig = z.output<typeof zStoreConfig>;\n\n// Catchall preserves other plugins' options\nexport const zPluginStoreConfig = StoreConfigUnrefined.catchall(z.any()).superRefine(validateStoreConfig);\n\n/************************************************************************\n *\n * HELPERS\n *\n ************************************************************************/\n\n// Validate conditions that check multiple different config options simultaneously\nfunction validateStoreConfig(config: z.output<typeof StoreConfigUnrefined>, ctx: RefinementCtx) {\n // Local table variables must be unique within the table\n for (const table of Object.values(config.tables)) {\n const keySchemaNames = Object.keys(table.keySchema);\n const fieldNames = Object.keys(table.valueSchema);\n const duplicateVariableNames = getDuplicates([...keySchemaNames, ...fieldNames]);\n if (duplicateVariableNames.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Field and key names within one table must be unique: ${duplicateVariableNames.join(\", \")}`,\n });\n }\n }\n // Global names must be unique\n const tableLibraryNames = Object.keys(config.tables);\n const staticUserTypeNames = [...Object.keys(config.enums), ...Object.keys(config.userTypes)];\n const userTypeNames = staticUserTypeNames;\n const globalNames = [...tableLibraryNames, ...userTypeNames];\n const duplicateGlobalNames = getDuplicates(globalNames);\n if (duplicateGlobalNames.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Table library names, enum names, user type names must be globally unique: ${duplicateGlobalNames.join(\n \", \",\n )}`,\n });\n }\n // Table names used for tableId must be unique\n const tableNames = Object.values(config.tables).map(({ name }) => name);\n const duplicateTableNames = getDuplicates(tableNames);\n if (duplicateTableNames.length > 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Table names must be unique: ${duplicateTableNames.join(\", \")}`,\n });\n }\n // User types must exist\n for (const table of Object.values(config.tables)) {\n for (const keySchemaType of Object.values(table.keySchema)) {\n validateStaticAbiOrUserType(staticUserTypeNames, keySchemaType, ctx);\n }\n for (const fieldType of Object.values(table.valueSchema)) {\n validateAbiOrUserType(userTypeNames, staticUserTypeNames, fieldType, ctx);\n }\n }\n}\n\nfunction validateAbiOrUserType(\n userTypeNames: string[],\n staticUserTypeNames: string[],\n type: string,\n ctx: RefinementCtx,\n) {\n if (!(AbiTypes as string[]).includes(type) && !userTypeNames.includes(type)) {\n const staticArray = parseStaticArray(type);\n if (staticArray) {\n validateStaticArray(staticUserTypeNames, staticArray.elementType, staticArray.staticLength, ctx);\n } else {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `${type} is not a valid abi type, and is not defined in userTypes`,\n });\n }\n }\n}\n\nfunction validateStaticAbiOrUserType(staticUserTypeNames: string[], type: string, ctx: RefinementCtx) {\n if (!(StaticAbiTypes as string[]).includes(type) && !staticUserTypeNames.includes(type)) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `${type} is not a static type`,\n });\n }\n}\n\nfunction validateStaticArray(\n staticUserTypeNames: string[],\n elementType: string,\n staticLength: number,\n ctx: RefinementCtx,\n) {\n validateStaticAbiOrUserType(staticUserTypeNames, elementType, ctx);\n\n if (staticLength === 0) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Static array length must not be 0`,\n });\n } else if (staticLength >= 2 ** 16) {\n ctx.addIssue({\n code: ZodIssueCode.custom,\n message: `Static array length must be less than 2**16`,\n });\n }\n}\n"],"mappings":"AAAO,IAAMA,EAAW,CACtB,UAAW,GACX,MAAO,CAAC,EACR,UAAW,CAAC,CACd,EAIaC,EAAiB,CAC5B,UAAW,SACX,UAAW,CAAE,IAAK,SAAU,EAC5B,gBAAiB,GACjB,cAAe,GACf,aAAc,EAChB,ECdA,OAAkB,YAAAC,EAAyB,kBAAAC,MAAmC,qCAC9E,OAAwB,KAAAC,EAAG,gBAAAC,MAAoB,MAQ/C,OAEE,iBAAAC,EACA,oBAAAC,EACA,yBAAAC,EAIA,eAAAC,EACA,aAAAC,EACA,cAAAC,EACA,cAAAC,EACA,SAAAC,MACK,6BAGP,OAAwB,mBAAAC,EAAiB,kBAAAC,MAAsB,mCAE/D,IAAMC,EAAaC,EACbC,EAAWC,EACXC,EAAcD,EACdE,EAAgBJ,EAChBK,EAAgBL,EAIhBM,EAAaC,EAAE,OAAO,EAMtBC,EAAoBD,EAAE,OAAO,EAC7BE,EAAaF,EAAE,OAAON,EAAUO,CAAiB,EAAE,QAAQE,EAAe,SAAS,EAmBnFC,EAAoBJ,EACvB,OAAOJ,EAAaG,CAAU,EAC9B,OAAQM,GAAQ,OAAO,KAAKA,CAAG,EAAE,OAAS,EAAG,+BAA+B,EAEzEC,EAAyBP,EAAW,UAAWQ,GAC5CH,EAAkB,MAAM,CAC7B,MAAOG,CACT,CAAC,CACF,EAEYC,EAAgBJ,EAAkB,GAAGE,CAAsB,EAajE,SAASG,GAGdC,EAAiBC,EAA4D,CAC7E,IAAMC,EAAgD,CAAC,EACvD,OAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQJ,CAAM,EAC9C,GAAIpB,EAAgBwB,CAAK,EACvBF,EAAeC,CAAG,EAAIC,UACbH,EAAUG,CAAK,IAAM,OAC9BF,EAAeC,CAAG,EAAIF,EAAUG,CAAK,EAAE,iBA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,IAAI,GACvE,CAAC,EAGH,QAAW1B,KAAS,OAAO,OAAOY,EAAO,MAAM,EAAG,CAChD,QAAWe,KAAiB,OAAO,OAAO3B,EAAM,SAAS,EACvD4B,EAA4BR,EAAqBO,EAAed,CAAG,EAErE,QAAWgB,KAAa,OAAO,OAAO7B,EAAM,WAAW,EACrD8B,EAAsBT,EAAeD,EAAqBS,EAAWhB,CAAG,EAG9E,CAEA,SAASiB,EACPT,EACAD,EACAW,EACAlB,EACA,CACA,GAAI,CAAEmB,EAAsB,SAASD,CAAI,GAAK,CAACV,EAAc,SAASU,CAAI,EAAG,CAC3E,IAAMxC,EAAcC,EAAiBuC,CAAI,EACrCxC,EACF0C,EAAoBb,EAAqB7B,EAAY,YAAaA,EAAY,aAAcsB,CAAG,EAE/FA,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,GAAGa,4DACd,CAAC,EAGP,CAEA,SAASH,EAA4BR,EAA+BW,EAAclB,EAAoB,CAChG,CAAEqB,EAA4B,SAASH,CAAI,GAAK,CAACX,EAAoB,SAASW,CAAI,GACpFlB,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,GAAGa,wBACd,CAAC,CAEL,CAEA,SAASE,EACPb,EACAe,EACAC,EACAvB,EACA,CACAe,EAA4BR,EAAqBe,EAAatB,CAAG,EAE7DuB,IAAiB,EACnBvB,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,mCACX,CAAC,EACQkB,GAAgB,GAAK,IAC9BvB,EAAI,SAAS,CACX,KAAMK,EAAa,OACnB,QAAS,6CACX,CAAC,CAEL","names":["DEFAULTS","TABLE_DEFAULTS","AbiTypes","StaticAbiTypes","z","ZodIssueCode","getDuplicates","parseStaticArray","STORE_NAME_MAX_LENGTH","zObjectName","zUserEnum","zValueName","zNamespace","zName","isSchemaAbiType","schemaAbiTypes","zTableName","zObjectName","zKeyName","zValueName","zColumnName","zUserEnumName","zUserTypeName","zFieldData","z","zKeyElementSchema","zKeySchema","TABLE_DEFAULTS","zFullSchemaConfig","arg","zShorthandSchemaConfig","fieldData","zSchemaConfig","resolveUserTypes","schema","userTypes","resolvedSchema","key","value","staticArray","parseStaticArray","zFullTableConfig","zName","zShorthandTableConfig","zTableConfig","zTablesConfig","tables","tableName","table","STORE_NAME_MAX_LENGTH","zEnumsConfig","zUserEnum","DEFAULTS","zUserTypeConfig","zUserTypesConfig","StoreConfigUnrefined","zNamespace","zStoreConfig","validateStoreConfig","zPluginStoreConfig","config","ctx","keySchemaNames","fieldNames","duplicateVariableNames","getDuplicates","ZodIssueCode","tableLibraryNames","staticUserTypeNames","userTypeNames","globalNames","duplicateGlobalNames","tableNames","name","duplicateTableNames","keySchemaType","validateStaticAbiOrUserType","fieldType","validateAbiOrUserType","type","AbiTypes","validateStaticArray","StaticAbiTypes","elementType","staticLength"]}
|
package/dist/config.d.ts
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
export { D as DEFAULTS, l as EnumsConfig, E as ExpandSchemaConfig, f as ExpandTableConfig, k as ExpandTablesConfig, F as FieldData, m as FullEnumsConfig, a as FullSchemaConfig, e as FullTableConfig, j as FullTablesConfig, M as MUDUserConfig, c as SchemaConfig, b as ShorthandSchemaConfig, S as StoreConfig, q as StoreUserConfig, T as TABLE_DEFAULTS, d as TableConfig, h as TablesConfig, U as UserTypesConfig, r as resolveUserTypes, n as zEnumsConfig, s as zPluginStoreConfig, z as zSchemaConfig, p as zStoreConfig, g as zTableConfig, i as zTablesConfig, o as zUserTypesConfig } from './storeConfig-55cad8c2.js';
|
2
|
-
import '@latticexyz/schema-type/deprecated';
|
3
|
-
import 'zod';
|
4
|
-
import '@latticexyz/common/type-utils';
|
5
|
-
import '@latticexyz/config/library';
|
6
|
-
import '@latticexyz/common/codegen';
|
package/dist/config.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-RRYXNY5P.js";export{a as DEFAULTS,b as TABLE_DEFAULTS,d as resolveUserTypes,g as zEnumsConfig,j as zPluginStoreConfig,c as zSchemaConfig,i as zStoreConfig,e as zTableConfig,f as zTablesConfig,h as zUserTypesConfig};
|
2
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/register.d.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
export { mudCoreConfig } from '@latticexyz/config/register';
|
2
|
-
import { OrDefaults, StringForUnion, ExtractUserTypes } from '@latticexyz/common/type-utils';
|
3
|
-
import { MUDCoreUserConfig } from '@latticexyz/config/library';
|
4
|
-
import { q as StoreUserConfig, S as StoreConfig, D as DEFAULTS, k as ExpandTablesConfig, M as MUDUserConfig } from './storeConfig-55cad8c2.js';
|
5
|
-
import '@latticexyz/schema-type/deprecated';
|
6
|
-
import 'zod';
|
7
|
-
import '@latticexyz/common/codegen';
|
8
|
-
|
9
|
-
declare module "@latticexyz/config/library" {
|
10
|
-
interface MUDCoreUserConfig extends StoreUserConfig {
|
11
|
-
}
|
12
|
-
interface MUDCoreConfig extends StoreConfig {
|
13
|
-
}
|
14
|
-
}
|
15
|
-
interface ExpandMUDUserConfig<T extends MUDCoreUserConfig> extends OrDefaults<T, DEFAULTS> {
|
16
|
-
tables: ExpandTablesConfig<T["tables"]>;
|
17
|
-
}
|
18
|
-
|
19
|
-
/** mudCoreConfig wrapper to use generics in some options for better type inference */
|
20
|
-
declare function mudConfig<T extends MUDCoreUserConfig, EnumNames extends StringForUnion = never, UserTypeNames extends StringForUnion = never, StaticUserTypes extends ExtractUserTypes<EnumNames | UserTypeNames> = ExtractUserTypes<EnumNames | UserTypeNames>>(config: MUDUserConfig<T, EnumNames, UserTypeNames, StaticUserTypes>): ExpandMUDUserConfig<T>;
|
21
|
-
|
22
|
-
export { ExpandMUDUserConfig, mudConfig };
|
package/dist/register.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import{j as o}from"./chunk-RRYXNY5P.js";import"@latticexyz/config/register";import{mudCoreConfig as y}from"@latticexyz/config/register";import{extendMUDCoreConfig as n,fromZodErrorCustom as t}from"@latticexyz/config/library";import{ZodError as s}from"zod";n(r=>{try{return o.parse(r)}catch(e){throw e instanceof s?t(e,"StoreConfig Validation Error"):e}});import{mudCoreConfig as i}from"@latticexyz/config/library";function m(r){return i(r)}export{m as mudConfig,y as mudCoreConfig};
|
2
|
-
//# sourceMappingURL=register.js.map
|
package/dist/register.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../ts/register/index.ts","../ts/register/configExtensions.ts","../ts/register/mudConfig.ts"],"sourcesContent":["// Importing this file has side-effects for MUD config,\n// and the order of imports is important in relation to other plugins\n// (store should usually be the first plugin)\n\n// For convenience register and reexport config, to reduce the number of needed imports for users\nimport \"@latticexyz/config/register\";\nexport { mudCoreConfig } from \"@latticexyz/config/register\";\n// Extend core config and types\nimport \"./configExtensions\";\nimport \"./typeExtensions\";\n\nexport { mudConfig } from \"./mudConfig\";\nexport type { ExpandMUDUserConfig } from \"./typeExtensions\";\n","import { extendMUDCoreConfig, fromZodErrorCustom } from \"@latticexyz/config/library\";\nimport { ZodError } from \"zod\";\nimport { zPluginStoreConfig } from \"../config\";\n\nextendMUDCoreConfig((config) => {\n // This function gets called within mudConfig.\n // The call order of config extenders depends on the order of their imports.\n // Any config validation and transformation should be placed here.\n try {\n return zPluginStoreConfig.parse(config);\n } catch (error) {\n if (error instanceof ZodError) {\n throw fromZodErrorCustom(error, \"StoreConfig Validation Error\");\n } else {\n throw error;\n }\n }\n});\n","import { mudCoreConfig, MUDCoreUserConfig } from \"@latticexyz/config/library\";\nimport { ExtractUserTypes, StringForUnion } from \"@latticexyz/common/type-utils\";\nimport { ExpandMUDUserConfig } from \"./typeExtensions\";\nimport { MUDUserConfig } from \"../config/storeConfig\";\n\n/** mudCoreConfig wrapper to use generics in some options for better type inference */\nexport function mudConfig<\n T extends MUDCoreUserConfig,\n // (`never` is overridden by inference, so only the defined enums can be used by default)\n EnumNames extends StringForUnion = never,\n UserTypeNames extends StringForUnion = never,\n StaticUserTypes extends ExtractUserTypes<EnumNames | UserTypeNames> = ExtractUserTypes<EnumNames | UserTypeNames>,\n>(config: MUDUserConfig<T, EnumNames, UserTypeNames, StaticUserTypes>): ExpandMUDUserConfig<T> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return mudCoreConfig(config) as any;\n}\n"],"mappings":"wCAKA,MAAO,8BACP,OAAS,iBAAAA,MAAqB,8BCN9B,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,6BACxD,OAAS,YAAAC,MAAgB,MAGzBC,EAAqBC,GAAW,CAI9B,GAAI,CACF,OAAOC,EAAmB,MAAMD,CAAM,CACxC,OAASE,EAAP,CACA,MAAIA,aAAiBC,EACbC,EAAmBF,EAAO,8BAA8B,EAExDA,CAEV,CACF,CAAC,ECjBD,OAAS,iBAAAG,MAAwC,6BAM1C,SAASC,EAMdC,EAA6F,CAE7F,OAAOF,EAAcE,CAAM,CAC7B","names":["mudCoreConfig","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginStoreConfig","error","ZodError","fromZodErrorCustom","mudCoreConfig","mudConfig","config"]}
|