@latticexyz/store 2.2.18-90aac1d4acce19ac592d47a090732dd11c1c3e7a → 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2

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.
@@ -0,0 +1,27 @@
1
+ // ts/storeEvents.ts
2
+ var helloStoreEvent = "event HelloStore(bytes32 indexed storeVersion)";
3
+ var storeSetRecordEvent = "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)";
4
+ var storeSpliceStaticDataEvent = "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)";
5
+ var storeSpliceDynamicDataEvent = "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)";
6
+ var storeDeleteRecordEvent = "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)";
7
+ var storeEvents = [
8
+ storeSetRecordEvent,
9
+ storeSpliceStaticDataEvent,
10
+ storeSpliceDynamicDataEvent,
11
+ storeDeleteRecordEvent
12
+ ];
13
+
14
+ // ts/storeEventsAbi.ts
15
+ import { parseAbi } from "abitype";
16
+ var storeEventsAbi = parseAbi(storeEvents);
17
+
18
+ export {
19
+ helloStoreEvent,
20
+ storeSetRecordEvent,
21
+ storeSpliceStaticDataEvent,
22
+ storeSpliceDynamicDataEvent,
23
+ storeDeleteRecordEvent,
24
+ storeEvents,
25
+ storeEventsAbi
26
+ };
27
+ //# sourceMappingURL=chunk-Y2IOLXYI.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/storeEvents.ts","../ts/storeEventsAbi.ts"],"sourcesContent":["export const helloStoreEvent = \"event HelloStore(bytes32 indexed storeVersion)\";\n\nexport const storeSetRecordEvent =\n \"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)\";\n\nexport const storeSpliceStaticDataEvent =\n \"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)\";\n\nexport const storeSpliceDynamicDataEvent =\n \"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)\";\n\nexport const storeDeleteRecordEvent = \"event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)\";\n\n// Store protocol events\nexport const storeEvents = [\n storeSetRecordEvent,\n storeSpliceStaticDataEvent,\n storeSpliceDynamicDataEvent,\n storeDeleteRecordEvent,\n] as const;\n","import { parseAbi, AbiEvent } from \"abitype\";\nimport { storeEvents } from \"./storeEvents\";\n\nexport const storeEventsAbi = parseAbi(storeEvents) satisfies readonly AbiEvent[];\nexport type storeEventsAbi = typeof storeEventsAbi;\n\nexport type StoreEventsAbi = typeof storeEventsAbi;\nexport type StoreEventsAbiItem = (typeof storeEventsAbi)[number];\n\nexport type StoreSetRecordEventAbiItem = StoreEventsAbiItem & { readonly name: \"Store_SetRecord\" };\n"],"mappings":"AAAO,IAAMA,EAAkB,iDAElBC,EACX,kIAEWC,EACX,sGAEWC,EACX,4KAEWC,EAAyB,wEAGzBC,EAAc,CACzBJ,EACAC,EACAC,EACAC,CACF,ECnBA,OAAS,YAAAE,MAA0B,UAG5B,IAAMC,EAAiBC,EAASC,CAAW","names":["helloStoreEvent","storeSetRecordEvent","storeSpliceStaticDataEvent","storeSpliceDynamicDataEvent","storeDeleteRecordEvent","storeEvents","parseAbi","storeEventsAbi","parseAbi","storeEvents"]}
1
+ {"version":3,"sources":["../ts/storeEvents.ts","../ts/storeEventsAbi.ts"],"sourcesContent":["export const helloStoreEvent = \"event HelloStore(bytes32 indexed storeVersion)\";\n\nexport const storeSetRecordEvent =\n \"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)\";\n\nexport const storeSpliceStaticDataEvent =\n \"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)\";\n\nexport const storeSpliceDynamicDataEvent =\n \"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)\";\n\nexport const storeDeleteRecordEvent = \"event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)\";\n\n// Store protocol events\nexport const storeEvents = [\n storeSetRecordEvent,\n storeSpliceStaticDataEvent,\n storeSpliceDynamicDataEvent,\n storeDeleteRecordEvent,\n] as const;\n","import { parseAbi, AbiEvent } from \"abitype\";\nimport { storeEvents } from \"./storeEvents\";\n\nexport const storeEventsAbi = parseAbi(storeEvents) satisfies readonly AbiEvent[];\nexport type storeEventsAbi = typeof storeEventsAbi;\n\nexport type StoreEventsAbi = typeof storeEventsAbi;\nexport type StoreEventsAbiItem = (typeof storeEventsAbi)[number];\n\nexport type StoreSetRecordEventAbiItem = StoreEventsAbiItem & { readonly name: \"Store_SetRecord\" };\n"],"mappings":";AAAO,IAAM,kBAAkB;AAExB,IAAM,sBACX;AAEK,IAAM,6BACX;AAEK,IAAM,8BACX;AAEK,IAAM,yBAAyB;AAG/B,IAAM,cAAc;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACnBA,SAAS,gBAA0B;AAG5B,IAAM,iBAAiB,SAAS,WAAW;","names":[]}
@@ -0,0 +1,460 @@
1
+ // ts/config/v2/generics.ts
2
+ function get(input, key) {
3
+ return typeof input === "object" && input != null && hasOwnKey(input, key) ? input[key] : void 0;
4
+ }
5
+ function getPath(input, path) {
6
+ return path.length ? getPath(get(input, path[0]), path.slice(1)) : input;
7
+ }
8
+ function hasOwnKey(object, key) {
9
+ return typeof object === "object" && object !== null && object.hasOwnProperty(key);
10
+ }
11
+ function isObject(input) {
12
+ return input != null && typeof input === "object";
13
+ }
14
+ function mergeIfUndefined(base, defaults) {
15
+ const keys = [.../* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(defaults)])];
16
+ return Object.fromEntries(
17
+ keys.map((key) => [
18
+ key,
19
+ typeof base[key] === "undefined" ? defaults[key] : base[key]
20
+ ])
21
+ );
22
+ }
23
+
24
+ // ts/config/v2/defaults.ts
25
+ var CODEGEN_DEFAULTS = {
26
+ storeImportPath: "@latticexyz/store/src",
27
+ userTypesFilename: "common.sol",
28
+ outputDirectory: "codegen",
29
+ indexFilename: "index.sol"
30
+ };
31
+ var TABLE_CODEGEN_DEFAULTS = {
32
+ outputDirectory: "tables",
33
+ tableIdArgument: false,
34
+ storeArgument: false
35
+ };
36
+ var TABLE_DEPLOY_DEFAULTS = {
37
+ disabled: false
38
+ };
39
+ var TABLE_DEFAULTS = {
40
+ namespaceLabel: "",
41
+ type: "table"
42
+ };
43
+ var CONFIG_DEFAULTS = {
44
+ sourceDirectory: "src",
45
+ namespace: ""
46
+ };
47
+
48
+ // ts/config/v2/scope.ts
49
+ import { schemaAbiTypes } from "@latticexyz/schema-type/internal";
50
+ var Scope = { types: {} };
51
+ var AbiTypeScope = {
52
+ types: Object.fromEntries(schemaAbiTypes.map((abiType) => [abiType, abiType]))
53
+ };
54
+ function extendScope(scope, additionalTypes) {
55
+ return {
56
+ types: {
57
+ ...scope.types,
58
+ ...additionalTypes
59
+ }
60
+ };
61
+ }
62
+
63
+ // ts/config/v2/schema.ts
64
+ import { fixedArrayToArray, isFixedArrayAbiType } from "@latticexyz/schema-type/internal";
65
+ function validateSchema(schema, scope = AbiTypeScope) {
66
+ if (!isObject(schema)) {
67
+ throw new Error(`Expected schema, received ${JSON.stringify(schema)}`);
68
+ }
69
+ for (const internalType of Object.values(schema)) {
70
+ if (isFixedArrayAbiType(internalType)) continue;
71
+ if (hasOwnKey(scope.types, internalType)) continue;
72
+ throw new Error(`"${String(internalType)}" is not a valid type in this scope.`);
73
+ }
74
+ }
75
+ function resolveSchema(schema, scope = AbiTypeScope) {
76
+ return Object.fromEntries(
77
+ Object.entries(schema).map(([key, internalType]) => [
78
+ key,
79
+ {
80
+ type: isFixedArrayAbiType(internalType) ? fixedArrayToArray(internalType) : scope.types[internalType],
81
+ internalType
82
+ }
83
+ ])
84
+ );
85
+ }
86
+ function defineSchema(schema, scope = AbiTypeScope) {
87
+ validateSchema(schema, scope);
88
+ return resolveSchema(schema, scope);
89
+ }
90
+ function isSchemaInput(input, scope = AbiTypeScope) {
91
+ return typeof input === "object" && input != null && Object.values(input).every((fieldType) => isFixedArrayAbiType(fieldType) || hasOwnKey(scope.types, fieldType));
92
+ }
93
+
94
+ // ts/config/v2/table.ts
95
+ import { isStaticAbiType } from "@latticexyz/schema-type/internal";
96
+ import { resourceToHex } from "@latticexyz/common";
97
+ function getValidKeys(schema, scope = AbiTypeScope) {
98
+ return Object.entries(schema).filter(([, internalType]) => hasOwnKey(scope.types, internalType) && isStaticAbiType(scope.types[internalType])).map(([key]) => key);
99
+ }
100
+ function isValidPrimaryKey(key, schema, scope = AbiTypeScope) {
101
+ return Array.isArray(key) && key.every(
102
+ (key2) => hasOwnKey(schema, key2) && hasOwnKey(scope.types, schema[key2]) && isStaticAbiType(scope.types[schema[key2]])
103
+ );
104
+ }
105
+ function validateTable(input, scope = AbiTypeScope, options = { inStoreContext: false }) {
106
+ if (typeof input !== "object" || input == null) {
107
+ throw new Error(`Expected full table config, got \`${JSON.stringify(input)}\``);
108
+ }
109
+ if (!hasOwnKey(input, "schema")) {
110
+ throw new Error("Missing schema input");
111
+ }
112
+ validateSchema(input.schema, scope);
113
+ if (!hasOwnKey(input, "key") || !isValidPrimaryKey(input["key"], input["schema"], scope)) {
114
+ throw new Error(
115
+ `Invalid key. Expected \`(${getValidKeys(input["schema"], scope).map((item) => `"${String(item)}"`).join(" | ")})[]\`, received \`${hasOwnKey(input, "key") && Array.isArray(input.key) ? `[${input.key.map((item) => `"${item}"`).join(", ")}]` : String(get(input, "key"))}\``
116
+ );
117
+ }
118
+ if (hasOwnKey(input, "namespace") && typeof input.namespace === "string" && input.namespace.length > 14) {
119
+ throw new Error(`Table \`namespace\` must fit into a \`bytes14\`, but "${input.namespace}" is too long.`);
120
+ }
121
+ if (hasOwnKey(input, "namespaceLabel") && typeof input.namespaceLabel === "string" && (!hasOwnKey(input, "namespace") || typeof input.namespace !== "string") && input.namespaceLabel.length > 14) {
122
+ throw new Error(
123
+ `Table \`namespace\` defaults to \`namespaceLabel\`, but must fit into a \`bytes14\` and "${input.namespaceLabel}" is too long. Provide explicit \`namespace\` override.`
124
+ );
125
+ }
126
+ if (hasOwnKey(input, "name") && typeof input.name === "string" && input.name.length > 16) {
127
+ throw new Error(`Table \`name\` must fit into a \`bytes16\`, but "${input.name}" is too long.`);
128
+ }
129
+ if (options.inStoreContext && (hasOwnKey(input, "label") || hasOwnKey(input, "namespaceLabel") || hasOwnKey(input, "namespace"))) {
130
+ throw new Error(
131
+ "Overrides of `label`, `namespaceLabel`, and `namespace` are not allowed for tables in this context."
132
+ );
133
+ }
134
+ }
135
+ function resolveTableCodegen(input) {
136
+ const options = input.codegen;
137
+ return {
138
+ outputDirectory: get(options, "outputDirectory") ?? TABLE_CODEGEN_DEFAULTS.outputDirectory,
139
+ tableIdArgument: get(options, "tableIdArgument") ?? TABLE_CODEGEN_DEFAULTS.tableIdArgument,
140
+ storeArgument: get(options, "storeArgument") ?? TABLE_CODEGEN_DEFAULTS.storeArgument,
141
+ // dataStruct is true if there are at least 2 value fields
142
+ dataStruct: get(options, "dataStruct") ?? Object.keys(input.schema).length - input.key.length > 1
143
+ };
144
+ }
145
+ function resolveTable(input, scope = AbiTypeScope) {
146
+ const namespaceLabel = input.namespaceLabel ?? TABLE_DEFAULTS.namespaceLabel;
147
+ const namespace = input.namespace ?? namespaceLabel;
148
+ const label = input.label;
149
+ const name = input.name ?? label.slice(0, 16);
150
+ const type = input.type ?? TABLE_DEFAULTS.type;
151
+ const tableId = resourceToHex({ type, namespace, name });
152
+ return {
153
+ label,
154
+ type,
155
+ namespace,
156
+ namespaceLabel,
157
+ name,
158
+ tableId,
159
+ schema: resolveSchema(input.schema, scope),
160
+ key: input.key,
161
+ codegen: resolveTableCodegen(input),
162
+ deploy: mergeIfUndefined(input.deploy ?? {}, TABLE_DEPLOY_DEFAULTS)
163
+ };
164
+ }
165
+ function defineTable(input, scope = AbiTypeScope) {
166
+ validateTable(input, scope);
167
+ return resolveTable(input, scope);
168
+ }
169
+
170
+ // ts/config/v2/tableShorthand.ts
171
+ import { isFixedArrayAbiType as isFixedArrayAbiType2, isStaticAbiType as isStaticAbiType2 } from "@latticexyz/schema-type/internal";
172
+ var NoStaticKeyFieldError = "Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.";
173
+ function isTableShorthandInput(shorthand) {
174
+ return typeof shorthand === "string" || isObject(shorthand) && Object.values(shorthand).every((value) => typeof value === "string");
175
+ }
176
+ function validateTableShorthand(shorthand, scope = AbiTypeScope) {
177
+ if (typeof shorthand === "string") {
178
+ if (isFixedArrayAbiType2(shorthand) || hasOwnKey(scope.types, shorthand)) {
179
+ return;
180
+ }
181
+ throw new Error(`Invalid ABI type. \`${shorthand}\` not found in scope.`);
182
+ }
183
+ if (typeof shorthand === "object" && shorthand !== null) {
184
+ if (isSchemaInput(shorthand, scope)) {
185
+ if (hasOwnKey(shorthand, "id") && isStaticAbiType2(scope.types[shorthand.id])) {
186
+ return;
187
+ }
188
+ throw new Error(`Invalid schema. Expected an \`id\` field with a static ABI type or an explicit \`key\` option.`);
189
+ }
190
+ throw new Error(`Invalid schema. Are you using invalid types or missing types in your scope?`);
191
+ }
192
+ throw new Error(`Invalid table shorthand.`);
193
+ }
194
+ function expandTableShorthand(shorthand, scope) {
195
+ if (typeof shorthand === "string") {
196
+ return {
197
+ schema: {
198
+ id: "bytes32",
199
+ value: shorthand
200
+ },
201
+ key: ["id"]
202
+ };
203
+ }
204
+ if (isSchemaInput(shorthand, scope)) {
205
+ return {
206
+ schema: shorthand,
207
+ key: ["id"]
208
+ };
209
+ }
210
+ return shorthand;
211
+ }
212
+ function defineTableShorthand(input, scope = AbiTypeScope) {
213
+ validateTableShorthand(input, scope);
214
+ return expandTableShorthand(input, scope);
215
+ }
216
+
217
+ // ts/config/v2/tables.ts
218
+ function validateTables(input, scope) {
219
+ if (isObject(input)) {
220
+ for (const table of Object.values(input)) {
221
+ if (isTableShorthandInput(table)) {
222
+ validateTableShorthand(table, scope);
223
+ } else {
224
+ validateTable(table, scope, { inStoreContext: true });
225
+ }
226
+ }
227
+ return;
228
+ }
229
+ throw new Error(`Expected tables config, received ${JSON.stringify(input)}`);
230
+ }
231
+ function resolveTables(tables, scope) {
232
+ return Object.fromEntries(
233
+ Object.entries(tables).map(([label, table]) => {
234
+ return [label, resolveTable(mergeIfUndefined(expandTableShorthand(table, scope), { label }), scope)];
235
+ })
236
+ );
237
+ }
238
+ function defineTables(input, scope = AbiTypeScope) {
239
+ validateTables(input, scope);
240
+ return resolveTables(input, scope);
241
+ }
242
+
243
+ // ts/config/v2/userTypes.ts
244
+ import { mapObject } from "@latticexyz/common/utils";
245
+ import { isSchemaAbiType } from "@latticexyz/schema-type/internal";
246
+ function extractInternalType(userTypes) {
247
+ return mapObject(userTypes, (userType) => userType.type);
248
+ }
249
+ function isUserTypes(userTypes) {
250
+ return isObject(userTypes) && Object.values(userTypes).every((userType) => isSchemaAbiType(userType.type));
251
+ }
252
+ function scopeWithUserTypes(userTypes, scope = AbiTypeScope) {
253
+ return isUserTypes(userTypes) ? extendScope(scope, extractInternalType(userTypes)) : scope;
254
+ }
255
+ function validateUserTypes(userTypes) {
256
+ if (!isObject(userTypes)) {
257
+ throw new Error(`Expected userTypes, received ${JSON.stringify(userTypes)}`);
258
+ }
259
+ for (const { type } of Object.values(userTypes)) {
260
+ if (!hasOwnKey(AbiTypeScope.types, type)) {
261
+ throw new Error(`"${String(type)}" is not a valid ABI type.`);
262
+ }
263
+ }
264
+ }
265
+
266
+ // ts/config/v2/enums.ts
267
+ import { flatMorph } from "@ark/util";
268
+ function isEnums(enums) {
269
+ return typeof enums === "object" && enums != null && Object.values(enums).every((item) => Array.isArray(item) && item.every((element) => typeof element === "string"));
270
+ }
271
+ function scopeWithEnums(enums, scope = AbiTypeScope) {
272
+ if (isEnums(enums)) {
273
+ const enumScope = Object.fromEntries(Object.keys(enums).map((key) => [key, "uint8"]));
274
+ return extendScope(scope, enumScope);
275
+ }
276
+ return scope;
277
+ }
278
+ function resolveEnums(enums) {
279
+ return enums;
280
+ }
281
+ function mapEnums(enums) {
282
+ return flatMorph(enums, (enumName, enumElements) => [
283
+ enumName,
284
+ flatMorph(enumElements, (enumIndex, enumElement) => [enumElement, enumIndex])
285
+ ]);
286
+ }
287
+
288
+ // ts/config/v2/codegen.ts
289
+ function resolveCodegen(codegen) {
290
+ return isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS;
291
+ }
292
+
293
+ // ts/config/v2/namespace.ts
294
+ import { flatMorph as flatMorph2 } from "@ark/util";
295
+ function validateNamespace(input, scope) {
296
+ if (hasOwnKey(input, "namespace") && typeof input.namespace === "string" && input.namespace.length > 14) {
297
+ throw new Error(`\`namespace\` must fit into a \`bytes14\`, but "${input.namespace}" is too long.`);
298
+ }
299
+ if (hasOwnKey(input, "tables")) {
300
+ validateTables(input.tables, scope);
301
+ }
302
+ }
303
+ function resolveNamespace(input, scope = AbiTypeScope) {
304
+ const namespaceLabel = input.label;
305
+ const namespace = input.namespace ?? namespaceLabel.slice(0, 14);
306
+ return {
307
+ label: namespaceLabel,
308
+ namespace,
309
+ tables: resolveTables(
310
+ flatMorph2(input.tables ?? {}, (label, table) => {
311
+ return [label, mergeIfUndefined(expandTableShorthand(table, scope), { namespace, namespaceLabel })];
312
+ }),
313
+ scope
314
+ )
315
+ };
316
+ }
317
+
318
+ // ts/config/v2/namespaces.ts
319
+ import { flatMorph as flatMorph3 } from "@ark/util";
320
+ import { groupBy } from "@latticexyz/common/utils";
321
+ function validateNamespaces(namespaces, scope) {
322
+ if (!isObject(namespaces)) {
323
+ throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);
324
+ }
325
+ for (const namespace of Object.values(namespaces)) {
326
+ validateNamespace(namespace, scope);
327
+ }
328
+ }
329
+ function resolveNamespaces(input, scope) {
330
+ if (!isObject(input)) {
331
+ throw new Error(`Expected namespaces config, received ${JSON.stringify(input)}`);
332
+ }
333
+ const namespaces = flatMorph3(input, (label, namespace) => [
334
+ label,
335
+ resolveNamespace(mergeIfUndefined(namespace, { label }), scope)
336
+ ]);
337
+ const duplicates = Array.from(groupBy(Object.values(namespaces), (namespace) => namespace.namespace).entries()).filter(([, entries]) => entries.length > 1).map(([namespace]) => namespace);
338
+ if (duplicates.length > 0) {
339
+ throw new Error(`Found namespaces defined more than once in config: ${duplicates.join(", ")}`);
340
+ }
341
+ return namespaces;
342
+ }
343
+ function defineNamespaces(input, scope = AbiTypeScope) {
344
+ validateNamespaces(input, scope);
345
+ return resolveNamespaces(input, scope);
346
+ }
347
+
348
+ // ts/config/v2/flattenNamespacedTables.ts
349
+ function flattenNamespacedTables(config) {
350
+ return Object.fromEntries(
351
+ Object.entries(config.namespaces).flatMap(
352
+ ([namespaceLabel, namespace]) => Object.entries(namespace.tables).map(([tableLabel, table]) => [
353
+ namespaceLabel === "" ? tableLabel : `${namespaceLabel}__${tableLabel}`,
354
+ table
355
+ ])
356
+ )
357
+ );
358
+ }
359
+
360
+ // ts/config/v2/store.ts
361
+ function extendedScope(input) {
362
+ return scopeWithEnums(get(input, "enums"), scopeWithUserTypes(get(input, "userTypes")));
363
+ }
364
+ function validateStore(input) {
365
+ const scope = extendedScope(input);
366
+ if (hasOwnKey(input, "namespaces")) {
367
+ if (hasOwnKey(input, "namespace") || hasOwnKey(input, "tables")) {
368
+ throw new Error("Cannot use `namespaces` with `namespace` or `tables` keys.");
369
+ }
370
+ validateNamespaces(input.namespaces, scope);
371
+ }
372
+ if (hasOwnKey(input, "namespace") && typeof input.namespace === "string" && input.namespace.length > 14) {
373
+ throw new Error(`\`namespace\` must fit into a \`bytes14\`, but "${input.namespace}" is too long.`);
374
+ }
375
+ if (hasOwnKey(input, "tables")) {
376
+ validateTables(input.tables, scope);
377
+ }
378
+ if (hasOwnKey(input, "userTypes")) {
379
+ validateUserTypes(input.userTypes);
380
+ }
381
+ }
382
+ function resolveStore(input) {
383
+ const scope = extendedScope(input);
384
+ const baseNamespace = input.namespace ?? CONFIG_DEFAULTS["namespace"];
385
+ const namespaces = input.namespaces ? {
386
+ multipleNamespaces: true,
387
+ namespace: null,
388
+ namespaces: resolveNamespaces(input.namespaces, scope)
389
+ } : {
390
+ multipleNamespaces: false,
391
+ namespace: baseNamespace,
392
+ namespaces: resolveNamespaces({ [baseNamespace]: input }, scope)
393
+ };
394
+ const tables = flattenNamespacedTables(namespaces);
395
+ return {
396
+ ...namespaces,
397
+ tables,
398
+ sourceDirectory: input.sourceDirectory ?? CONFIG_DEFAULTS["sourceDirectory"],
399
+ userTypes: input.userTypes ?? {},
400
+ enums: resolveEnums(input.enums ?? {}),
401
+ enumValues: mapEnums(input.enums ?? {}),
402
+ codegen: resolveCodegen(input.codegen)
403
+ };
404
+ }
405
+ function defineStore(input) {
406
+ validateStore(input);
407
+ return resolveStore(input);
408
+ }
409
+
410
+ export {
411
+ get,
412
+ getPath,
413
+ hasOwnKey,
414
+ isObject,
415
+ mergeIfUndefined,
416
+ CODEGEN_DEFAULTS,
417
+ TABLE_CODEGEN_DEFAULTS,
418
+ TABLE_DEPLOY_DEFAULTS,
419
+ TABLE_DEFAULTS,
420
+ CONFIG_DEFAULTS,
421
+ Scope,
422
+ AbiTypeScope,
423
+ extendScope,
424
+ validateSchema,
425
+ resolveSchema,
426
+ defineSchema,
427
+ isSchemaInput,
428
+ isValidPrimaryKey,
429
+ validateTable,
430
+ resolveTableCodegen,
431
+ resolveTable,
432
+ defineTable,
433
+ NoStaticKeyFieldError,
434
+ isTableShorthandInput,
435
+ validateTableShorthand,
436
+ expandTableShorthand,
437
+ defineTableShorthand,
438
+ validateTables,
439
+ resolveTables,
440
+ defineTables,
441
+ extractInternalType,
442
+ isUserTypes,
443
+ scopeWithUserTypes,
444
+ validateUserTypes,
445
+ scopeWithEnums,
446
+ resolveEnums,
447
+ mapEnums,
448
+ resolveCodegen,
449
+ validateNamespace,
450
+ resolveNamespace,
451
+ validateNamespaces,
452
+ resolveNamespaces,
453
+ defineNamespaces,
454
+ flattenNamespacedTables,
455
+ extendedScope,
456
+ validateStore,
457
+ resolveStore,
458
+ defineStore
459
+ };
460
+ //# sourceMappingURL=chunk-YO3UX5MT.js.map