schemos 0.2.0 → 0.2.1

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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fixed-tuple.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-tuple.test-d.d.ts","sourceRoot":"","sources":["../../src/patches/fixed-tuple.test-d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,76 @@
1
+ import { expectTypeOf, test } from 'vitest';
2
+ // ---------------------------------------------------------------------------
3
+ // Fixed-length array patch: minItems === maxItems should produce a tuple type
4
+ // Mirrors ThomasAribart/json-schema-to-ts#231
5
+ // ---------------------------------------------------------------------------
6
+ // -- AssetInfo (native or cw20 token) ---------------------------------------
7
+ const assetInfoSchema = {
8
+ oneOf: [
9
+ {
10
+ type: 'object',
11
+ required: ['native'],
12
+ properties: { native: { type: 'string' } },
13
+ additionalProperties: false,
14
+ },
15
+ {
16
+ type: 'object',
17
+ required: ['cw20'],
18
+ properties: { cw20: { type: 'string' } },
19
+ additionalProperties: false,
20
+ },
21
+ ],
22
+ };
23
+ // -- DEX Pair: exactly 2 AssetInfo ------------------------------------------
24
+ const pairSchema = {
25
+ type: 'object',
26
+ required: ['asset_infos', 'contract_addr'],
27
+ properties: {
28
+ asset_infos: {
29
+ type: 'array',
30
+ items: assetInfoSchema,
31
+ minItems: 2,
32
+ maxItems: 2,
33
+ },
34
+ contract_addr: { type: 'string' },
35
+ },
36
+ additionalProperties: false,
37
+ };
38
+ test('Pair.asset_infos is a fixed-length tuple [AssetInfo, AssetInfo]', () => {
39
+ expectTypeOf().toEqualTypeOf();
40
+ });
41
+ // -- Empty fixed-length array (minItems === maxItems === 0) -----------------
42
+ const emptyArraySchema = {
43
+ type: 'object',
44
+ required: ['items'],
45
+ properties: {
46
+ items: {
47
+ type: 'array',
48
+ items: { type: 'string' },
49
+ minItems: 0,
50
+ maxItems: 0,
51
+ },
52
+ },
53
+ additionalProperties: false,
54
+ };
55
+ test('empty fixed-length array is []', () => {
56
+ expectTypeOf().toEqualTypeOf();
57
+ });
58
+ // -- Range array (minItems !== maxItems) should still be T[] ----------------
59
+ const rangeArraySchema = {
60
+ type: 'object',
61
+ required: ['items'],
62
+ properties: {
63
+ items: {
64
+ type: 'array',
65
+ items: { type: 'number' },
66
+ minItems: 1,
67
+ maxItems: 3,
68
+ },
69
+ },
70
+ additionalProperties: false,
71
+ };
72
+ // TODO: Update this once json-schema-to-ts supports range arrays as tuples (minItems !== maxItems)
73
+ test('range array (min !== max) stays as T[]', () => {
74
+ expectTypeOf().toEqualTypeOf();
75
+ });
76
+ //# sourceMappingURL=fixed-tuple.test-d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-tuple.test-d.js","sourceRoot":"","sources":["../../src/patches/fixed-tuple.test-d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE3C,8EAA8E;AAC9E,8EAA8E;AAC9E,8CAA8C;AAC9C,8EAA8E;AAE9E,8EAA8E;AAC9E,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE;QACL;YACE,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC1C,oBAAoB,EAAE,KAAK;SAC5B;QACD;YACE,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,MAAM,CAAC;YAClB,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YACxC,oBAAoB,EAAE,KAAK;SAC5B;KACF;CACO,CAAA;AAIV,8EAA8E;AAC9E,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,aAAa,EAAE,eAAe,CAAC;IAC1C,UAAU,EAAE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": "schemos",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Type-safe CosmWasm contract interactions, zero codegen",
6
6
  "license": "MIT",