@latticexyz/store 3.0.0-main-2da9e48cd → 3.0.0-main-fb1cfef0c
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-JX6B2S4J.js +2 -0
- package/dist/chunk-JX6B2S4J.js.map +1 -0
- package/dist/codegen.d.ts +2 -2
- 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/index.js.map +1 -1
- package/dist/{output-5b3b98d5.d.ts → input-48d1368b.d.ts} +87 -94
- package/dist/mud.config.d.ts +236 -108
- package/dist/mud.config.js +1 -1
- package/dist/namespacedTables-8a81e0a2.d.ts +147 -0
- package/dist/store-6077eba5.d.ts +72 -0
- package/package.json +7 -7
- package/dist/chunk-6SXWMDLH.js +0 -2
- package/dist/chunk-6SXWMDLH.js.map +0 -1
- package/dist/chunk-ACZGBP2R.js +0 -2
- package/dist/chunk-ACZGBP2R.js.map +0 -1
- package/dist/generics-627f4c31.d.ts +0 -29
- package/dist/storeWithShorthands-b5cb4574.d.ts +0 -219
package/dist/mud.config.d.ts
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
import { r as resolveNamespacedTables, m as mergeIfUndefined } from './
|
1
|
+
import { r as resolveNamespacedTables, m as mergeIfUndefined, a as resolveTables } from './namespacedTables-8a81e0a2.js';
|
2
|
+
import '@arktype/util';
|
3
|
+
import './input-48d1368b.js';
|
4
|
+
import 'viem';
|
5
|
+
import '@latticexyz/config';
|
6
|
+
import '@latticexyz/schema-type/internal';
|
2
7
|
|
3
8
|
declare const _default: {
|
4
9
|
readonly namespace: string;
|
@@ -158,132 +163,255 @@ declare const _default: {
|
|
158
163
|
readonly store: {
|
159
164
|
readonly label: "store";
|
160
165
|
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}`;
|
166
|
+
readonly tables: resolveTables<{
|
167
|
+
readonly StoreHooks: mergeIfUndefined<{
|
168
168
|
readonly schema: {
|
169
|
-
readonly tableId:
|
170
|
-
|
171
|
-
readonly internalType: "ResourceId";
|
172
|
-
};
|
173
|
-
readonly hooks: {
|
174
|
-
readonly type: "bytes21[]";
|
175
|
-
readonly internalType: "bytes21[]";
|
176
|
-
};
|
169
|
+
readonly tableId: "ResourceId";
|
170
|
+
readonly hooks: "bytes21[]";
|
177
171
|
};
|
178
172
|
readonly key: readonly ["tableId"];
|
179
|
-
|
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";
|
173
|
+
}, {
|
192
174
|
readonly namespace: string;
|
193
|
-
|
194
|
-
|
175
|
+
}>;
|
176
|
+
readonly Tables: mergeIfUndefined<{
|
195
177
|
readonly schema: {
|
196
|
-
readonly tableId:
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
readonly
|
201
|
-
|
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
|
-
};
|
178
|
+
readonly tableId: "ResourceId";
|
179
|
+
readonly fieldLayout: "FieldLayout";
|
180
|
+
readonly keySchema: "Schema";
|
181
|
+
readonly valueSchema: "Schema";
|
182
|
+
readonly abiEncodedKeyNames: "bytes";
|
183
|
+
readonly abiEncodedFieldNames: "bytes";
|
220
184
|
};
|
221
185
|
readonly key: readonly ["tableId"];
|
222
|
-
|
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";
|
186
|
+
}, {
|
235
187
|
readonly namespace: string;
|
236
|
-
|
237
|
-
|
188
|
+
}>;
|
189
|
+
readonly ResourceIds: mergeIfUndefined<{
|
238
190
|
readonly schema: {
|
239
|
-
readonly resourceId:
|
240
|
-
|
241
|
-
readonly internalType: "ResourceId";
|
242
|
-
};
|
243
|
-
readonly exists: {
|
244
|
-
readonly type: "bool";
|
245
|
-
readonly internalType: "bool";
|
246
|
-
};
|
191
|
+
readonly resourceId: "ResourceId";
|
192
|
+
readonly exists: "bool";
|
247
193
|
};
|
248
194
|
readonly key: readonly ["resourceId"];
|
249
|
-
|
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";
|
195
|
+
}, {
|
262
196
|
readonly namespace: string;
|
263
|
-
|
264
|
-
|
197
|
+
}>;
|
198
|
+
readonly Hooks: mergeIfUndefined<{
|
265
199
|
readonly schema: {
|
266
|
-
readonly resourceId:
|
267
|
-
|
268
|
-
readonly internalType: "ResourceId";
|
269
|
-
};
|
270
|
-
readonly hooks: {
|
271
|
-
readonly type: "bytes21[]";
|
272
|
-
readonly internalType: "bytes21[]";
|
273
|
-
};
|
200
|
+
readonly resourceId: "ResourceId";
|
201
|
+
readonly hooks: "bytes21[]";
|
274
202
|
};
|
275
203
|
readonly key: readonly ["resourceId"];
|
276
204
|
readonly codegen: {
|
277
|
-
readonly outputDirectory: string;
|
278
205
|
readonly tableIdArgument: true;
|
279
|
-
readonly storeArgument: false;
|
280
|
-
readonly dataStruct: boolean;
|
281
206
|
};
|
282
|
-
|
283
|
-
|
284
|
-
|
207
|
+
}, {
|
208
|
+
readonly namespace: string;
|
209
|
+
}>;
|
210
|
+
}, {
|
211
|
+
types: {
|
212
|
+
string: "string";
|
213
|
+
bytes32: "bytes32";
|
214
|
+
uint8: "uint8";
|
215
|
+
uint16: "uint16";
|
216
|
+
uint24: "uint24";
|
217
|
+
uint32: "uint32";
|
218
|
+
uint40: "uint40";
|
219
|
+
uint48: "uint48";
|
220
|
+
uint56: "uint56";
|
221
|
+
uint64: "uint64";
|
222
|
+
uint72: "uint72";
|
223
|
+
uint80: "uint80";
|
224
|
+
uint88: "uint88";
|
225
|
+
uint96: "uint96";
|
226
|
+
uint104: "uint104";
|
227
|
+
uint112: "uint112";
|
228
|
+
uint120: "uint120";
|
229
|
+
uint128: "uint128";
|
230
|
+
uint136: "uint136";
|
231
|
+
uint144: "uint144";
|
232
|
+
uint152: "uint152";
|
233
|
+
uint160: "uint160";
|
234
|
+
uint168: "uint168";
|
235
|
+
uint176: "uint176";
|
236
|
+
uint184: "uint184";
|
237
|
+
uint192: "uint192";
|
238
|
+
uint200: "uint200";
|
239
|
+
uint208: "uint208";
|
240
|
+
uint216: "uint216";
|
241
|
+
uint224: "uint224";
|
242
|
+
uint232: "uint232";
|
243
|
+
uint240: "uint240";
|
244
|
+
uint248: "uint248";
|
245
|
+
uint256: "uint256";
|
246
|
+
int8: "int8";
|
247
|
+
int16: "int16";
|
248
|
+
int24: "int24";
|
249
|
+
int32: "int32";
|
250
|
+
int40: "int40";
|
251
|
+
int48: "int48";
|
252
|
+
int56: "int56";
|
253
|
+
int64: "int64";
|
254
|
+
int72: "int72";
|
255
|
+
int80: "int80";
|
256
|
+
int88: "int88";
|
257
|
+
int96: "int96";
|
258
|
+
int104: "int104";
|
259
|
+
int112: "int112";
|
260
|
+
int120: "int120";
|
261
|
+
int128: "int128";
|
262
|
+
int136: "int136";
|
263
|
+
int144: "int144";
|
264
|
+
int152: "int152";
|
265
|
+
int160: "int160";
|
266
|
+
int168: "int168";
|
267
|
+
int176: "int176";
|
268
|
+
int184: "int184";
|
269
|
+
int192: "int192";
|
270
|
+
int200: "int200";
|
271
|
+
int208: "int208";
|
272
|
+
int216: "int216";
|
273
|
+
int224: "int224";
|
274
|
+
int232: "int232";
|
275
|
+
int240: "int240";
|
276
|
+
int248: "int248";
|
277
|
+
int256: "int256";
|
278
|
+
bytes1: "bytes1";
|
279
|
+
bytes2: "bytes2";
|
280
|
+
bytes3: "bytes3";
|
281
|
+
bytes4: "bytes4";
|
282
|
+
bytes5: "bytes5";
|
283
|
+
bytes6: "bytes6";
|
284
|
+
bytes7: "bytes7";
|
285
|
+
bytes8: "bytes8";
|
286
|
+
bytes9: "bytes9";
|
287
|
+
bytes10: "bytes10";
|
288
|
+
bytes11: "bytes11";
|
289
|
+
bytes12: "bytes12";
|
290
|
+
bytes13: "bytes13";
|
291
|
+
bytes14: "bytes14";
|
292
|
+
bytes15: "bytes15";
|
293
|
+
bytes16: "bytes16";
|
294
|
+
bytes17: "bytes17";
|
295
|
+
bytes18: "bytes18";
|
296
|
+
bytes19: "bytes19";
|
297
|
+
bytes20: "bytes20";
|
298
|
+
bytes21: "bytes21";
|
299
|
+
bytes22: "bytes22";
|
300
|
+
bytes23: "bytes23";
|
301
|
+
bytes24: "bytes24";
|
302
|
+
bytes25: "bytes25";
|
303
|
+
bytes26: "bytes26";
|
304
|
+
bytes27: "bytes27";
|
305
|
+
bytes28: "bytes28";
|
306
|
+
bytes29: "bytes29";
|
307
|
+
bytes30: "bytes30";
|
308
|
+
bytes31: "bytes31";
|
309
|
+
bool: "bool";
|
310
|
+
address: "address";
|
311
|
+
"uint8[]": "uint8[]";
|
312
|
+
"uint16[]": "uint16[]";
|
313
|
+
"uint24[]": "uint24[]";
|
314
|
+
"uint32[]": "uint32[]";
|
315
|
+
"uint40[]": "uint40[]";
|
316
|
+
"uint48[]": "uint48[]";
|
317
|
+
"uint56[]": "uint56[]";
|
318
|
+
"uint64[]": "uint64[]";
|
319
|
+
"uint72[]": "uint72[]";
|
320
|
+
"uint80[]": "uint80[]";
|
321
|
+
"uint88[]": "uint88[]";
|
322
|
+
"uint96[]": "uint96[]";
|
323
|
+
"uint104[]": "uint104[]";
|
324
|
+
"uint112[]": "uint112[]";
|
325
|
+
"uint120[]": "uint120[]";
|
326
|
+
"uint128[]": "uint128[]";
|
327
|
+
"uint136[]": "uint136[]";
|
328
|
+
"uint144[]": "uint144[]";
|
329
|
+
"uint152[]": "uint152[]";
|
330
|
+
"uint160[]": "uint160[]";
|
331
|
+
"uint168[]": "uint168[]";
|
332
|
+
"uint176[]": "uint176[]";
|
333
|
+
"uint184[]": "uint184[]";
|
334
|
+
"uint192[]": "uint192[]";
|
335
|
+
"uint200[]": "uint200[]";
|
336
|
+
"uint208[]": "uint208[]";
|
337
|
+
"uint216[]": "uint216[]";
|
338
|
+
"uint224[]": "uint224[]";
|
339
|
+
"uint232[]": "uint232[]";
|
340
|
+
"uint240[]": "uint240[]";
|
341
|
+
"uint248[]": "uint248[]";
|
342
|
+
"uint256[]": "uint256[]";
|
343
|
+
"int8[]": "int8[]";
|
344
|
+
"int16[]": "int16[]";
|
345
|
+
"int24[]": "int24[]";
|
346
|
+
"int32[]": "int32[]";
|
347
|
+
"int40[]": "int40[]";
|
348
|
+
"int48[]": "int48[]";
|
349
|
+
"int56[]": "int56[]";
|
350
|
+
"int64[]": "int64[]";
|
351
|
+
"int72[]": "int72[]";
|
352
|
+
"int80[]": "int80[]";
|
353
|
+
"int88[]": "int88[]";
|
354
|
+
"int96[]": "int96[]";
|
355
|
+
"int104[]": "int104[]";
|
356
|
+
"int112[]": "int112[]";
|
357
|
+
"int120[]": "int120[]";
|
358
|
+
"int128[]": "int128[]";
|
359
|
+
"int136[]": "int136[]";
|
360
|
+
"int144[]": "int144[]";
|
361
|
+
"int152[]": "int152[]";
|
362
|
+
"int160[]": "int160[]";
|
363
|
+
"int168[]": "int168[]";
|
364
|
+
"int176[]": "int176[]";
|
365
|
+
"int184[]": "int184[]";
|
366
|
+
"int192[]": "int192[]";
|
367
|
+
"int200[]": "int200[]";
|
368
|
+
"int208[]": "int208[]";
|
369
|
+
"int216[]": "int216[]";
|
370
|
+
"int224[]": "int224[]";
|
371
|
+
"int232[]": "int232[]";
|
372
|
+
"int240[]": "int240[]";
|
373
|
+
"int248[]": "int248[]";
|
374
|
+
"int256[]": "int256[]";
|
375
|
+
"bytes1[]": "bytes1[]";
|
376
|
+
"bytes2[]": "bytes2[]";
|
377
|
+
"bytes3[]": "bytes3[]";
|
378
|
+
"bytes4[]": "bytes4[]";
|
379
|
+
"bytes5[]": "bytes5[]";
|
380
|
+
"bytes6[]": "bytes6[]";
|
381
|
+
"bytes7[]": "bytes7[]";
|
382
|
+
"bytes8[]": "bytes8[]";
|
383
|
+
"bytes9[]": "bytes9[]";
|
384
|
+
"bytes10[]": "bytes10[]";
|
385
|
+
"bytes11[]": "bytes11[]";
|
386
|
+
"bytes12[]": "bytes12[]";
|
387
|
+
"bytes13[]": "bytes13[]";
|
388
|
+
"bytes14[]": "bytes14[]";
|
389
|
+
"bytes15[]": "bytes15[]";
|
390
|
+
"bytes16[]": "bytes16[]";
|
391
|
+
"bytes17[]": "bytes17[]";
|
392
|
+
"bytes18[]": "bytes18[]";
|
393
|
+
"bytes19[]": "bytes19[]";
|
394
|
+
"bytes20[]": "bytes20[]";
|
395
|
+
"bytes21[]": "bytes21[]";
|
396
|
+
"bytes22[]": "bytes22[]";
|
397
|
+
"bytes23[]": "bytes23[]";
|
398
|
+
"bytes24[]": "bytes24[]";
|
399
|
+
"bytes25[]": "bytes25[]";
|
400
|
+
"bytes26[]": "bytes26[]";
|
401
|
+
"bytes27[]": "bytes27[]";
|
402
|
+
"bytes28[]": "bytes28[]";
|
403
|
+
"bytes29[]": "bytes29[]";
|
404
|
+
"bytes30[]": "bytes30[]";
|
405
|
+
"bytes31[]": "bytes31[]";
|
406
|
+
"bytes32[]": "bytes32[]";
|
407
|
+
"bool[]": "bool[]";
|
408
|
+
"address[]": "address[]";
|
409
|
+
bytes: "bytes";
|
410
|
+
readonly ResourceId: "bytes32";
|
411
|
+
readonly FieldLayout: "bytes32";
|
412
|
+
readonly Schema: "bytes32";
|
285
413
|
};
|
286
|
-
}
|
414
|
+
}>;
|
287
415
|
};
|
288
416
|
};
|
289
417
|
};
|
package/dist/mud.config.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{
|
1
|
+
import{Q as e}from"./chunk-JX6B2S4J.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
|
@@ -0,0 +1,147 @@
|
|
1
|
+
import { conform, show, requiredKeyOf, ErrorMessage, narrow } from '@arktype/util';
|
2
|
+
import { a as Scope, A as AbiTypeScope, c as SchemaInput, g as getStaticAbiTypeKeys, h as TableInput, m as TableCodegen, i as TableShorthandInput, d as ScopedSchemaInput, j as TablesInput } from './input-48d1368b.js';
|
3
|
+
import { Hex } from 'viem';
|
4
|
+
import { FixedArrayAbiType, fixedArrayToArray } from '@latticexyz/schema-type/internal';
|
5
|
+
|
6
|
+
type get<input, key> = key extends keyof input ? input[key] : undefined;
|
7
|
+
declare function get<input, key extends PropertyKey>(input: input, key: key): get<input, key>;
|
8
|
+
type getPath<input, path extends readonly PropertyKey[]> = path extends readonly [
|
9
|
+
infer head,
|
10
|
+
...infer tail extends PropertyKey[]
|
11
|
+
] ? head extends keyof input ? getPath<input[head], tail> : undefined : input;
|
12
|
+
declare function getPath<input, path extends readonly PropertyKey[]>(input: input, path: path): getPath<input, path>;
|
13
|
+
declare function hasOwnKey<obj, const key extends PropertyKey>(object: obj, key: key): object is {
|
14
|
+
[k in key]: k extends keyof obj ? obj[k] : unknown;
|
15
|
+
} & obj;
|
16
|
+
declare function isObject<input>(input: input): input is input & object;
|
17
|
+
type mergeIfUndefined<base, defaults> = {
|
18
|
+
readonly [key in keyof base | keyof defaults]: key extends keyof base ? undefined extends base[key] ? key extends keyof defaults ? defaults[key] : base[key] : base[key] : key extends keyof defaults ? defaults[key] : never;
|
19
|
+
};
|
20
|
+
declare function mergeIfUndefined<base extends object, defaults extends object>(base: base, defaults: defaults): mergeIfUndefined<base, defaults>;
|
21
|
+
type parseNumber<T> = T extends `${infer N extends number}` ? N : never;
|
22
|
+
|
23
|
+
type validateSchema<schema, scope extends Scope = AbiTypeScope> = schema extends string ? SchemaInput : {
|
24
|
+
[key in keyof schema]: schema[key] extends FixedArrayAbiType ? schema[key] : conform<schema[key], keyof scope["types"]>;
|
25
|
+
};
|
26
|
+
declare function validateSchema<scope extends Scope = AbiTypeScope>(schema: unknown, scope?: scope): asserts schema is SchemaInput;
|
27
|
+
type resolveSchema<schema, scope extends Scope> = show<{
|
28
|
+
readonly [key in keyof schema]: {
|
29
|
+
/** the Solidity primitive ABI type */
|
30
|
+
readonly type: schema[key] extends FixedArrayAbiType ? fixedArrayToArray<schema[key]> : scope["types"][schema[key] & keyof scope["types"]];
|
31
|
+
/** the user defined type or Solidity primitive ABI type */
|
32
|
+
readonly internalType: schema[key];
|
33
|
+
};
|
34
|
+
}>;
|
35
|
+
declare function resolveSchema<schema extends SchemaInput, scope extends Scope = AbiTypeScope>(schema: schema, scope?: scope): resolveSchema<schema, scope>;
|
36
|
+
declare function defineSchema<schema, scope extends AbiTypeScope = AbiTypeScope>(schema: validateSchema<schema, scope>, scope?: scope): resolveSchema<schema, scope>;
|
37
|
+
declare function isSchemaInput<scope extends Scope = AbiTypeScope>(input: unknown, scope?: scope): input is SchemaInput;
|
38
|
+
|
39
|
+
declare const CODEGEN_DEFAULTS: {
|
40
|
+
readonly storeImportPath: "@latticexyz/store/src/";
|
41
|
+
readonly userTypesFilename: "common.sol";
|
42
|
+
readonly outputDirectory: "codegen";
|
43
|
+
readonly namespaceDirectories: false;
|
44
|
+
readonly indexFilename: "index.sol";
|
45
|
+
};
|
46
|
+
type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;
|
47
|
+
declare const TABLE_CODEGEN_DEFAULTS: {
|
48
|
+
readonly outputDirectory: string;
|
49
|
+
readonly tableIdArgument: false;
|
50
|
+
readonly storeArgument: false;
|
51
|
+
};
|
52
|
+
type TABLE_CODEGEN_DEFAULTS = typeof TABLE_CODEGEN_DEFAULTS;
|
53
|
+
declare const TABLE_DEPLOY_DEFAULTS: {
|
54
|
+
readonly disabled: false;
|
55
|
+
};
|
56
|
+
type TABLE_DEPLOY_DEFAULTS = typeof TABLE_DEPLOY_DEFAULTS;
|
57
|
+
declare const TABLE_DEFAULTS: {
|
58
|
+
readonly namespace: "";
|
59
|
+
readonly type: "table";
|
60
|
+
};
|
61
|
+
type TABLE_DEFAULTS = typeof TABLE_DEFAULTS;
|
62
|
+
declare const CONFIG_DEFAULTS: {
|
63
|
+
readonly sourceDirectory: "src";
|
64
|
+
readonly namespace: "";
|
65
|
+
};
|
66
|
+
type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;
|
67
|
+
|
68
|
+
type ValidKeys<schema extends SchemaInput, scope extends Scope> = readonly [
|
69
|
+
getStaticAbiTypeKeys<schema, scope>,
|
70
|
+
...getStaticAbiTypeKeys<schema, scope>[]
|
71
|
+
];
|
72
|
+
declare function isValidPrimaryKey<schema extends SchemaInput, scope extends Scope>(key: unknown, schema: schema, scope?: scope): key is ValidKeys<schema, scope>;
|
73
|
+
type validateKeys<validKeys extends PropertyKey, keys> = keys extends readonly string[] ? {
|
74
|
+
readonly [i in keyof keys]: keys[i] extends validKeys ? keys[i] : validKeys;
|
75
|
+
} : readonly string[];
|
76
|
+
type ValidateTableOptions = {
|
77
|
+
inStoreContext: boolean;
|
78
|
+
};
|
79
|
+
type requiredTableKey<inStoreContext extends boolean> = Exclude<requiredKeyOf<TableInput>, inStoreContext extends true ? "label" | "namespace" : "">;
|
80
|
+
type validateTable<input, scope extends Scope = AbiTypeScope, options extends ValidateTableOptions = {
|
81
|
+
inStoreContext: false;
|
82
|
+
}> = {
|
83
|
+
[key in keyof input | requiredTableKey<options["inStoreContext"]>]: key extends "key" ? validateKeys<getStaticAbiTypeKeys<conform<get<input, "schema">, SchemaInput>, scope>, get<input, key>> : key extends "schema" ? validateSchema<get<input, key>, scope> : key extends "label" | "namespace" ? options["inStoreContext"] extends true ? ErrorMessage<"Overrides of `label` and `namespace` are not allowed for tables in a store config"> : key extends keyof input ? narrow<input[key]> : never : key extends keyof TableInput ? TableInput[key] : ErrorMessage<`Key \`${key & string}\` does not exist in TableInput`>;
|
84
|
+
};
|
85
|
+
declare function validateTable<input, scope extends Scope = AbiTypeScope>(input: input, scope?: scope, options?: ValidateTableOptions): asserts input is TableInput & input;
|
86
|
+
type resolveTableCodegen<input extends TableInput> = show<{
|
87
|
+
[key in keyof TableCodegen]-?: key extends keyof input["codegen"] ? undefined extends input["codegen"][key] ? key extends "dataStruct" ? boolean : key extends keyof TABLE_CODEGEN_DEFAULTS ? TABLE_CODEGEN_DEFAULTS[key] : never : input["codegen"][key] : key extends "dataStruct" ? boolean : key extends keyof TABLE_CODEGEN_DEFAULTS ? TABLE_CODEGEN_DEFAULTS[key] : never;
|
88
|
+
}>;
|
89
|
+
declare function resolveTableCodegen<input extends TableInput>(input: input): resolveTableCodegen<input>;
|
90
|
+
type resolveTable<input, scope extends Scope = Scope> = input extends TableInput ? {
|
91
|
+
readonly label: input["label"];
|
92
|
+
readonly type: undefined extends input["type"] ? typeof TABLE_DEFAULTS.type : input["type"];
|
93
|
+
readonly namespace: string;
|
94
|
+
readonly name: string;
|
95
|
+
readonly tableId: Hex;
|
96
|
+
readonly schema: resolveSchema<input["schema"], scope>;
|
97
|
+
readonly key: Readonly<input["key"]>;
|
98
|
+
readonly codegen: resolveTableCodegen<input>;
|
99
|
+
readonly deploy: mergeIfUndefined<undefined extends input["deploy"] ? {} : input["deploy"], TABLE_DEPLOY_DEFAULTS>;
|
100
|
+
} : never;
|
101
|
+
declare function resolveTable<input extends TableInput, scope extends Scope = AbiTypeScope>(input: input, scope?: scope): resolveTable<input, scope>;
|
102
|
+
declare function defineTable<input, scope extends Scope = AbiTypeScope>(input: validateTable<input, scope>, scope?: scope): resolveTable<input, scope>;
|
103
|
+
|
104
|
+
declare const NoStaticKeyFieldError = "Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.";
|
105
|
+
type NoStaticKeyFieldError = ErrorMessage<typeof NoStaticKeyFieldError>;
|
106
|
+
declare function isTableShorthandInput(shorthand: unknown): shorthand is TableShorthandInput;
|
107
|
+
type validateTableShorthand<input, scope extends Scope = AbiTypeScope> = input extends SchemaInput ? "id" extends getStaticAbiTypeKeys<input, scope> ? conform<input, ScopedSchemaInput<scope>> : NoStaticKeyFieldError : input extends FixedArrayAbiType | keyof scope["types"] ? input : input extends string ? keyof scope["types"] : ScopedSchemaInput<scope>;
|
108
|
+
declare function validateTableShorthand<scope extends Scope = AbiTypeScope>(shorthand: unknown, scope?: scope): asserts shorthand is TableShorthandInput;
|
109
|
+
type expandTableShorthand<shorthand> = shorthand extends string ? {
|
110
|
+
readonly schema: {
|
111
|
+
readonly id: "bytes32";
|
112
|
+
readonly value: shorthand;
|
113
|
+
};
|
114
|
+
readonly key: ["id"];
|
115
|
+
} : shorthand extends SchemaInput ? {
|
116
|
+
readonly schema: shorthand;
|
117
|
+
readonly key: ["id"];
|
118
|
+
} : shorthand;
|
119
|
+
declare function expandTableShorthand<shorthand, scope extends Scope = AbiTypeScope>(shorthand: shorthand, scope: scope): expandTableShorthand<shorthand>;
|
120
|
+
declare function defineTableShorthand<input, scope extends Scope = AbiTypeScope>(input: validateTableShorthand<input, scope>, scope?: scope): expandTableShorthand<input>;
|
121
|
+
|
122
|
+
type validateTables<tables, scope extends Scope = AbiTypeScope> = {
|
123
|
+
[label in keyof tables]: tables[label] extends TableShorthandInput ? validateTableShorthand<tables[label], scope> : tables[label] extends object ? validateTable<tables[label], scope, {
|
124
|
+
inStoreContext: true;
|
125
|
+
}> : ErrorMessage<`Expected tables config.`>;
|
126
|
+
};
|
127
|
+
declare function validateTables<scope extends Scope = AbiTypeScope>(input: unknown, scope: scope): asserts input is TablesInput;
|
128
|
+
type resolveTables<tables, scope extends Scope = AbiTypeScope> = {
|
129
|
+
readonly [label in keyof tables]: resolveTable<mergeIfUndefined<expandTableShorthand<tables[label]>, {
|
130
|
+
readonly label: label;
|
131
|
+
}>, scope>;
|
132
|
+
};
|
133
|
+
declare function resolveTables<tables extends TablesInput, scope extends Scope = AbiTypeScope>(tables: tables, scope: scope): resolveTables<tables, scope>;
|
134
|
+
declare function defineTables<input, scope extends Scope = AbiTypeScope>(input: validateTables<input, scope>, scope?: scope): show<resolveTables<input, scope>>;
|
135
|
+
|
136
|
+
/**
|
137
|
+
* @internal Only kept for backwards compatibility
|
138
|
+
*/
|
139
|
+
type resolveNamespacedTables<tables, namespace> = {
|
140
|
+
readonly [label in keyof tables as namespace extends "" ? label : `${namespace & string}__${label & string}`]: tables[label];
|
141
|
+
};
|
142
|
+
/**
|
143
|
+
* @internal Only kept for backwards compatibility
|
144
|
+
*/
|
145
|
+
declare function resolveNamespacedTables<tables, namespace>(tables: tables, namespace: namespace): show<resolveNamespacedTables<tables, namespace>>;
|
146
|
+
|
147
|
+
export { TABLE_DEPLOY_DEFAULTS as A, TABLE_DEFAULTS as B, CODEGEN_DEFAULTS as C, CONFIG_DEFAULTS as D, NoStaticKeyFieldError as N, TABLE_CODEGEN_DEFAULTS as T, ValidKeys as V, resolveTables as a, getPath as b, resolveSchema as c, defineSchema as d, isSchemaInput as e, isTableShorthandInput as f, get as g, hasOwnKey as h, isObject as i, validateTableShorthand as j, expandTableShorthand as k, defineTableShorthand as l, mergeIfUndefined as m, isValidPrimaryKey as n, validateKeys as o, parseNumber as p, ValidateTableOptions as q, resolveNamespacedTables as r, requiredTableKey as s, validateTable as t, resolveTableCodegen as u, validateSchema as v, resolveTable as w, defineTable as x, validateTables as y, defineTables as z };
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { narrow, ErrorMessage, show } from '@arktype/util';
|
2
|
+
import { p as parseNumber, m as mergeIfUndefined, C as CODEGEN_DEFAULTS, a as resolveTables, k as expandTableShorthand, g as get, y as validateTables, D as CONFIG_DEFAULTS, r as resolveNamespacedTables, w as resolveTable } from './namespacedTables-8a81e0a2.js';
|
3
|
+
import { U as UserTypes, A as AbiTypeScope, e as extendScope, E as EnumsInput, a as Scope, N as NamespaceInput, k as StoreInput } from './input-48d1368b.js';
|
4
|
+
|
5
|
+
type extractInternalType<userTypes extends UserTypes> = {
|
6
|
+
[key in keyof userTypes]: userTypes[key]["type"];
|
7
|
+
};
|
8
|
+
declare function extractInternalType<userTypes extends UserTypes>(userTypes: userTypes): extractInternalType<userTypes>;
|
9
|
+
declare function isUserTypes(userTypes: unknown): userTypes is UserTypes;
|
10
|
+
type scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope> = UserTypes extends userTypes ? scope : userTypes extends UserTypes ? extendScope<scope, extractInternalType<userTypes>> : scope;
|
11
|
+
declare function scopeWithUserTypes<userTypes, scope extends AbiTypeScope = AbiTypeScope>(userTypes: userTypes, scope?: scope): scopeWithUserTypes<userTypes, scope>;
|
12
|
+
declare function validateUserTypes(userTypes: unknown): asserts userTypes is UserTypes;
|
13
|
+
|
14
|
+
type scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope> = EnumsInput extends enums ? scope : enums extends EnumsInput ? extendScope<scope, {
|
15
|
+
[key in keyof enums]: "uint8";
|
16
|
+
}> : scope;
|
17
|
+
declare function scopeWithEnums<enums, scope extends AbiTypeScope = AbiTypeScope>(enums: enums, scope?: scope): scopeWithEnums<enums, scope>;
|
18
|
+
type resolveEnums<enums> = {
|
19
|
+
readonly [key in keyof enums]: Readonly<enums[key]>;
|
20
|
+
};
|
21
|
+
declare function resolveEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums>;
|
22
|
+
type mapEnums<enums> = {
|
23
|
+
readonly [key in keyof enums]: {
|
24
|
+
readonly [element in keyof enums[key] as enums[key][element] & string]: parseNumber<element>;
|
25
|
+
};
|
26
|
+
};
|
27
|
+
declare function mapEnums<enums extends EnumsInput>(enums: enums): resolveEnums<enums>;
|
28
|
+
|
29
|
+
type resolveCodegen<codegen> = codegen extends {} ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS> : CODEGEN_DEFAULTS;
|
30
|
+
declare function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen>;
|
31
|
+
|
32
|
+
type resolveNamespace<input, scope extends Scope = AbiTypeScope> = input extends NamespaceInput ? {
|
33
|
+
readonly label: input["label"];
|
34
|
+
readonly namespace: string;
|
35
|
+
readonly tables: undefined extends input["tables"] ? {} : resolveTables<{
|
36
|
+
readonly [label in keyof input["tables"]]: mergeIfUndefined<expandTableShorthand<input["tables"][label]>, {
|
37
|
+
readonly namespace: string;
|
38
|
+
}>;
|
39
|
+
}, scope>;
|
40
|
+
} : never;
|
41
|
+
declare function resolveNamespace<const input extends NamespaceInput, scope extends Scope = AbiTypeScope>(input: input, scope: scope): resolveNamespace<input, scope>;
|
42
|
+
|
43
|
+
type extendedScope<input> = scopeWithEnums<get<input, "enums">, scopeWithUserTypes<get<input, "userTypes">>>;
|
44
|
+
declare function extendedScope<input>(input: input): extendedScope<input>;
|
45
|
+
type validateStore<input> = {
|
46
|
+
[key in keyof input]: key extends "tables" ? validateTables<input[key], extendedScope<input>> : key extends "userTypes" ? UserTypes : key extends "enums" ? narrow<input[key]> : key extends keyof StoreInput ? StoreInput[key] : ErrorMessage<`\`${key & string}\` is not a valid Store config option.`>;
|
47
|
+
};
|
48
|
+
declare function validateStore(input: unknown): asserts input is StoreInput;
|
49
|
+
type resolveStore<input, namespace = "namespace" extends keyof input ? input["namespace"] extends string ? input["namespace"] : CONFIG_DEFAULTS["namespace"] : CONFIG_DEFAULTS["namespace"]> = {
|
50
|
+
readonly namespace: string;
|
51
|
+
readonly sourceDirectory: "sourceDirectory" extends keyof input ? input["sourceDirectory"] : CONFIG_DEFAULTS["sourceDirectory"];
|
52
|
+
readonly tables: "tables" extends keyof input ? resolveNamespacedTables<{
|
53
|
+
readonly [label in keyof input["tables"]]: resolveTable<mergeIfUndefined<expandTableShorthand<input["tables"][label]>, {
|
54
|
+
label: label;
|
55
|
+
namespace: namespace;
|
56
|
+
}>, extendedScope<input>>;
|
57
|
+
}, namespace> : {};
|
58
|
+
readonly userTypes: "userTypes" extends keyof input ? input["userTypes"] : {};
|
59
|
+
readonly enums: "enums" extends keyof input ? show<resolveEnums<input["enums"]>> : {};
|
60
|
+
readonly enumValues: "enums" extends keyof input ? show<mapEnums<input["enums"]>> : {};
|
61
|
+
readonly codegen: "codegen" extends keyof input ? resolveCodegen<input["codegen"]> : resolveCodegen<{}>;
|
62
|
+
readonly namespaces: {
|
63
|
+
readonly [label in namespace & string]: resolveNamespace<{
|
64
|
+
readonly label: label;
|
65
|
+
readonly tables: "tables" extends keyof input ? input["tables"] : undefined;
|
66
|
+
}, extendedScope<input>>;
|
67
|
+
};
|
68
|
+
};
|
69
|
+
declare function resolveStore<const input extends StoreInput>(input: input): resolveStore<input>;
|
70
|
+
declare function defineStore<const input>(input: validateStore<input>): show<resolveStore<input>>;
|
71
|
+
|
72
|
+
export { resolveCodegen as a, resolveEnums as b, extractInternalType as c, defineStore as d, extendedScope as e, scopeWithUserTypes as f, validateUserTypes as g, isUserTypes as i, mapEnums as m, resolveStore as r, scopeWithEnums as s, validateStore as v };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@latticexyz/store",
|
3
|
-
"version": "3.0.0-main-
|
3
|
+
"version": "3.0.0-main-fb1cfef0c",
|
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-
|
50
|
-
"@latticexyz/config": "3.0.0-main-
|
51
|
-
"@latticexyz/protocol-parser": "3.0.0-main-
|
52
|
-
"@latticexyz/schema-type": "3.0.0-main-
|
49
|
+
"@latticexyz/common": "3.0.0-main-fb1cfef0c",
|
50
|
+
"@latticexyz/config": "3.0.0-main-fb1cfef0c",
|
51
|
+
"@latticexyz/protocol-parser": "3.0.0-main-fb1cfef0c",
|
52
|
+
"@latticexyz/schema-type": "3.0.0-main-fb1cfef0c"
|
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-
|
66
|
-
"@latticexyz/gas-report": "3.0.0-main-
|
65
|
+
"@latticexyz/abi-ts": "3.0.0-main-fb1cfef0c",
|
66
|
+
"@latticexyz/gas-report": "3.0.0-main-fb1cfef0c"
|
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",
|
package/dist/chunk-6SXWMDLH.js
DELETED
@@ -1,2 +0,0 @@
|
|
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
|