@based/schema 4.1.1 → 5.0.0-alpha.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.
Files changed (123) hide show
  1. package/README.md +152 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +2 -0
  4. package/dist/lang.d.ts +153 -0
  5. package/dist/lang.js +153 -0
  6. package/dist/mermaid.d.ts +3 -0
  7. package/dist/mermaid.js +24 -0
  8. package/dist/parse/assert.d.ts +2 -1
  9. package/dist/parse/assert.js +9 -3
  10. package/dist/parse/errors.d.ts +2 -0
  11. package/dist/parse/errors.js +2 -0
  12. package/dist/parse/index.d.ts +5 -4
  13. package/dist/parse/index.js +43 -41
  14. package/dist/parse/props.js +168 -75
  15. package/dist/parse/utils.d.ts +2 -2
  16. package/dist/parse/utils.js +11 -2
  17. package/dist/types.d.ts +72 -23
  18. package/dist/types.js +93 -0
  19. package/package.json +4 -3
  20. package/dist/parsePayload/index.d.ts +0 -3
  21. package/dist/parsePayload/index.js +0 -2
  22. package/dist/parseSchema/assert.d.ts +0 -6
  23. package/dist/parseSchema/assert.js +0 -27
  24. package/dist/parseSchema/errors.d.ts +0 -19
  25. package/dist/parseSchema/errors.js +0 -19
  26. package/dist/parseSchema/index.d.ts +0 -20
  27. package/dist/parseSchema/index.js +0 -132
  28. package/dist/parseSchema/props.d.ts +0 -7
  29. package/dist/parseSchema/props.js +0 -256
  30. package/dist/parseSchema/utils.d.ts +0 -3
  31. package/dist/parseSchema/utils.js +0 -29
  32. package/dist/src/compat/index.d.ts +0 -6
  33. package/dist/src/compat/index.js +0 -217
  34. package/dist/src/compat/oldSchemaType.d.ts +0 -93
  35. package/dist/src/compat/oldSchemaType.js +0 -2
  36. package/dist/src/display/index.d.ts +0 -2
  37. package/dist/src/display/index.js +0 -16
  38. package/dist/src/display/number.d.ts +0 -4
  39. package/dist/src/display/number.js +0 -97
  40. package/dist/src/display/string.d.ts +0 -5
  41. package/dist/src/display/string.js +0 -26
  42. package/dist/src/display/timestamp.d.ts +0 -5
  43. package/dist/src/display/timestamp.js +0 -134
  44. package/dist/src/error.d.ts +0 -21
  45. package/dist/src/error.js +0 -23
  46. package/dist/src/index.d.ts +0 -6
  47. package/dist/src/index.js +0 -7
  48. package/dist/src/languages.d.ts +0 -188
  49. package/dist/src/languages.js +0 -188
  50. package/dist/src/set/fields/array.d.ts +0 -2
  51. package/dist/src/set/fields/array.js +0 -119
  52. package/dist/src/set/fields/index.d.ts +0 -3
  53. package/dist/src/set/fields/index.js +0 -85
  54. package/dist/src/set/fields/number.d.ts +0 -4
  55. package/dist/src/set/fields/number.js +0 -123
  56. package/dist/src/set/fields/object.d.ts +0 -3
  57. package/dist/src/set/fields/object.js +0 -28
  58. package/dist/src/set/fields/references.d.ts +0 -3
  59. package/dist/src/set/fields/references.js +0 -136
  60. package/dist/src/set/fields/set.d.ts +0 -2
  61. package/dist/src/set/fields/set.js +0 -59
  62. package/dist/src/set/fields/string.d.ts +0 -3
  63. package/dist/src/set/fields/string.js +0 -289
  64. package/dist/src/set/index.d.ts +0 -3
  65. package/dist/src/set/index.js +0 -205
  66. package/dist/src/set/isValidId.d.ts +0 -2
  67. package/dist/src/set/isValidId.js +0 -17
  68. package/dist/src/types.d.ts +0 -205
  69. package/dist/src/types.js +0 -113
  70. package/dist/src/updateSchema.d.ts +0 -2
  71. package/dist/src/updateSchema.js +0 -12
  72. package/dist/src/validateSchema/basedSchemaTypeValidator.d.ts +0 -3
  73. package/dist/src/validateSchema/basedSchemaTypeValidator.js +0 -45
  74. package/dist/src/validateSchema/fieldValidators.d.ts +0 -27
  75. package/dist/src/validateSchema/fieldValidators.js +0 -360
  76. package/dist/src/validateSchema/index.d.ts +0 -17
  77. package/dist/src/validateSchema/index.js +0 -109
  78. package/dist/src/validateSchema/utils.d.ts +0 -25
  79. package/dist/src/validateSchema/utils.js +0 -61
  80. package/dist/src/walker/args.d.ts +0 -36
  81. package/dist/src/walker/args.js +0 -158
  82. package/dist/src/walker/index.d.ts +0 -6
  83. package/dist/src/walker/index.js +0 -31
  84. package/dist/src/walker/parse.d.ts +0 -3
  85. package/dist/src/walker/parse.js +0 -182
  86. package/dist/src/walker/types.d.ts +0 -45
  87. package/dist/src/walker/types.js +0 -7
  88. package/dist/test/array.d.ts +0 -1
  89. package/dist/test/array.js +0 -342
  90. package/dist/test/compat.d.ts +0 -1
  91. package/dist/test/compat.js +0 -97
  92. package/dist/test/data/newSchemas.d.ts +0 -2
  93. package/dist/test/data/newSchemas.js +0 -489
  94. package/dist/test/data/oldSchemas.d.ts +0 -2
  95. package/dist/test/data/oldSchemas.js +0 -5058
  96. package/dist/test/display.d.ts +0 -1
  97. package/dist/test/display.js +0 -103
  98. package/dist/test/json.d.ts +0 -1
  99. package/dist/test/json.js +0 -40
  100. package/dist/test/number.d.ts +0 -1
  101. package/dist/test/number.js +0 -374
  102. package/dist/test/reference.d.ts +0 -1
  103. package/dist/test/reference.js +0 -188
  104. package/dist/test/rest.d.ts +0 -1
  105. package/dist/test/rest.js +0 -168
  106. package/dist/test/set.d.ts +0 -1
  107. package/dist/test/set.js +0 -95
  108. package/dist/test/string.d.ts +0 -1
  109. package/dist/test/string.js +0 -120
  110. package/dist/test/text.d.ts +0 -1
  111. package/dist/test/text.js +0 -324
  112. package/dist/test/utils/index.d.ts +0 -11
  113. package/dist/test/utils/index.js +0 -17
  114. package/dist/test/validateSchema/basic.d.ts +0 -1
  115. package/dist/test/validateSchema/basic.js +0 -94
  116. package/dist/test/validateSchema/fields.d.ts +0 -1
  117. package/dist/test/validateSchema/fields.js +0 -436
  118. package/dist/test/validateSchema/languages.d.ts +0 -1
  119. package/dist/test/validateSchema/languages.js +0 -124
  120. package/dist/test/validateSchema/realWorld.d.ts +0 -1
  121. package/dist/test/validateSchema/realWorld.js +0 -13
  122. package/dist/test/walker.d.ts +0 -1
  123. package/dist/test/walker.js +0 -289
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @based/schema
2
+
3
+ ## Display & format WIP
4
+
5
+ Using `display` will not validate or transform and will purely change how the value is shown in UI and API.
6
+
7
+ Use `format` to specify in which format the value has to represented and modified. This may impose some validation and will influence how the UI shows the value.
8
+
9
+ ### For example
10
+
11
+ ```ts
12
+ {
13
+ types: {
14
+ article: {
15
+ props: {
16
+ price: {
17
+ type: 'int32',
18
+ display: 'euro',
19
+ },
20
+ authorEmail: {
21
+ type: 'string',
22
+ format: 'email',
23
+ display: 'lowercase',
24
+ },
25
+ lastModified: {
26
+ type: 'timestamp',
27
+ display: 'date-time'
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### Display options
36
+
37
+ #### Timestamp
38
+
39
+ ```
40
+ 'date',
41
+ 'date-time',
42
+ 'date-time-text',
43
+ 'human',
44
+ 'time',
45
+ 'time-precise',
46
+ ```
47
+
48
+ #### Number
49
+
50
+ ```
51
+ 'short',
52
+ 'human',
53
+ 'ratio',
54
+ 'bytes',
55
+ 'euro',
56
+ 'dollar',
57
+ 'pound',
58
+
59
+ 'round-short',
60
+ 'round-human',
61
+ 'round-ratio',
62
+ 'round-bytes',
63
+ 'round-euro',
64
+ 'round-dollar',
65
+ 'round-pound',
66
+ ```
67
+
68
+ #### String
69
+
70
+ ```
71
+ 'lowercase',
72
+ 'uppercase',
73
+ 'capitalize',
74
+ ```
75
+
76
+ ### Format options
77
+
78
+ #### String
79
+
80
+ ```
81
+ 'email',
82
+ 'URL',
83
+ 'MACAddress',
84
+ 'IP',
85
+ 'IPRange',
86
+ 'FQDN',
87
+ 'IBAN',
88
+ 'BIC',
89
+ 'alpha',
90
+ 'alphaLocales',
91
+ 'alphanumeric',
92
+ 'alphanumericLocales',
93
+ 'passportNumber',
94
+ 'port',
95
+ 'lowercase',
96
+ 'uppercase',
97
+ 'ascii',
98
+ 'semVer',
99
+ 'surrogatePair',
100
+ 'IMEI',
101
+ 'hexadecimal',
102
+ 'octal',
103
+ 'hexColor',
104
+ 'rgbColor',
105
+ 'HSL',
106
+ 'ISRC',
107
+ 'MD5',
108
+ 'JWT',
109
+ 'UUID',
110
+ 'luhnNumber',
111
+ 'creditCard',
112
+ 'identityCard',
113
+ 'EAN',
114
+ 'ISIN',
115
+ 'ISBN',
116
+ 'ISSN',
117
+ 'mobilePhone',
118
+ 'mobilePhoneLocales',
119
+ 'postalCode',
120
+ 'postalCodeLocales',
121
+ 'ethereumAddress',
122
+ 'currency',
123
+ 'btcAddress',
124
+ 'ISO6391',
125
+ 'ISO8601',
126
+ 'RFC3339',
127
+ 'ISO31661Alpha2',
128
+ 'ISO31661Alpha3',
129
+ 'ISO4217',
130
+ 'base32',
131
+ 'base58',
132
+ 'base64',
133
+ 'dataURI',
134
+ 'magnetURI',
135
+ 'mimeType',
136
+ 'latLong',
137
+ 'slug',
138
+ 'strongPassword',
139
+ 'taxID',
140
+ 'licensePlate',
141
+ 'VAT',
142
+ 'code',
143
+ 'typescript',
144
+ 'javascript',
145
+ 'python',
146
+ 'rust',
147
+ 'css',
148
+ 'html',
149
+ 'json',
150
+ 'markdown',
151
+ 'clike'
152
+ ```
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './types.js';
2
2
  export * from './parse/index.js';
3
+ export * from './lang.js';
4
+ export * from './mermaid.js';
3
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './types.js';
2
2
  export * from './parse/index.js';
3
+ export * from './lang.js';
4
+ export * from './mermaid.js';
3
5
  //# sourceMappingURL=index.js.map
package/dist/lang.d.ts ADDED
@@ -0,0 +1,153 @@
1
+ declare const langCodes: {
2
+ readonly none: 0;
3
+ readonly aa: 1;
4
+ readonly ab: 2;
5
+ readonly af: 3;
6
+ readonly ak: 4;
7
+ readonly sq: 5;
8
+ readonly am: 6;
9
+ readonly ar: 7;
10
+ readonly an: 8;
11
+ readonly hy: 9;
12
+ readonly as: 10;
13
+ readonly av: 11;
14
+ readonly ae: 12;
15
+ readonly ay: 13;
16
+ readonly az: 14;
17
+ readonly eu: 15;
18
+ readonly be: 16;
19
+ readonly bn: 17;
20
+ readonly bi: 18;
21
+ readonly bs: 19;
22
+ readonly br: 20;
23
+ readonly bg: 21;
24
+ readonly my: 22;
25
+ readonly ca: 23;
26
+ readonly km: 24;
27
+ readonly ce: 25;
28
+ readonly zh: 26;
29
+ readonly cv: 27;
30
+ readonly kw: 28;
31
+ readonly co: 29;
32
+ readonly hr: 30;
33
+ readonly cs: 31;
34
+ readonly da: 32;
35
+ readonly dv: 33;
36
+ readonly nl: 34;
37
+ readonly dz: 35;
38
+ readonly en: 36;
39
+ readonly et: 37;
40
+ readonly fo: 38;
41
+ readonly fi: 39;
42
+ readonly fr: 40;
43
+ readonly ff: 41;
44
+ readonly gd: 42;
45
+ readonly gl: 43;
46
+ readonly de: 44;
47
+ readonly gsw: 45;
48
+ readonly el: 46;
49
+ readonly kl: 47;
50
+ readonly gu: 48;
51
+ readonly ht: 49;
52
+ readonly ha: 50;
53
+ readonly he: 51;
54
+ readonly hi: 52;
55
+ readonly hu: 53;
56
+ readonly is: 54;
57
+ readonly ig: 55;
58
+ readonly id: 56;
59
+ readonly ia: 57;
60
+ readonly iu: 58;
61
+ readonly ik: 59;
62
+ readonly ga: 60;
63
+ readonly it: 61;
64
+ readonly ja: 62;
65
+ readonly kn: 63;
66
+ readonly ks: 64;
67
+ readonly kk: 65;
68
+ readonly rw: 66;
69
+ readonly ko: 67;
70
+ readonly ku: 68;
71
+ readonly ky: 69;
72
+ readonly lo: 70;
73
+ readonly la: 71;
74
+ readonly lv: 72;
75
+ readonly lb: 73;
76
+ readonly li: 74;
77
+ readonly ln: 75;
78
+ readonly lt: 76;
79
+ readonly mk: 77;
80
+ readonly mg: 78;
81
+ readonly ms: 79;
82
+ readonly ml: 80;
83
+ readonly mt: 81;
84
+ readonly gv: 82;
85
+ readonly mi: 83;
86
+ readonly ro: 84;
87
+ readonly mn: 85;
88
+ readonly ne: 86;
89
+ readonly se: 87;
90
+ readonly no: 88;
91
+ readonly nb: 89;
92
+ readonly nn: 90;
93
+ readonly oc: 91;
94
+ readonly or: 92;
95
+ readonly om: 93;
96
+ readonly os: 94;
97
+ readonly pa: 95;
98
+ readonly ps: 96;
99
+ readonly fa: 97;
100
+ readonly pl: 98;
101
+ readonly pt: 99;
102
+ readonly qu: 100;
103
+ readonly rm: 101;
104
+ readonly ru: 102;
105
+ readonly sm: 103;
106
+ readonly sa: 104;
107
+ readonly sc: 105;
108
+ readonly sr: 106;
109
+ readonly sd: 107;
110
+ readonly si: 108;
111
+ readonly sk: 109;
112
+ readonly sl: 110;
113
+ readonly so: 111;
114
+ readonly st: 112;
115
+ readonly nr: 113;
116
+ readonly es: 114;
117
+ readonly sw: 115;
118
+ readonly ss: 116;
119
+ readonly sv: 117;
120
+ readonly tl: 118;
121
+ readonly tg: 119;
122
+ readonly ta: 120;
123
+ readonly tt: 121;
124
+ readonly te: 122;
125
+ readonly th: 123;
126
+ readonly bo: 124;
127
+ readonly ti: 125;
128
+ readonly to: 126;
129
+ readonly ts: 127;
130
+ readonly tn: 128;
131
+ readonly tr: 129;
132
+ readonly tk: 130;
133
+ readonly ug: 131;
134
+ readonly uk: 132;
135
+ readonly ur: 133;
136
+ readonly uz: 134;
137
+ readonly ve: 135;
138
+ readonly vi: 136;
139
+ readonly wa: 137;
140
+ readonly cy: 138;
141
+ readonly fy: 139;
142
+ readonly wo: 140;
143
+ readonly xh: 141;
144
+ readonly yi: 142;
145
+ readonly yo: 143;
146
+ readonly zu: 144;
147
+ };
148
+ export declare const langCodesMap: Map<string, 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144>;
149
+ export declare const inverseLangMap: Map<any, any>;
150
+ export type LangName = keyof typeof langCodes;
151
+ export type LangCode = (typeof langCodes)[LangName];
152
+ export {};
153
+ //# sourceMappingURL=lang.d.ts.map
package/dist/lang.js ADDED
@@ -0,0 +1,153 @@
1
+ const langCodes = {
2
+ none: 0,
3
+ aa: 1,
4
+ ab: 2,
5
+ af: 3,
6
+ ak: 4,
7
+ sq: 5,
8
+ am: 6,
9
+ ar: 7,
10
+ an: 8,
11
+ hy: 9,
12
+ as: 10,
13
+ av: 11,
14
+ ae: 12,
15
+ ay: 13,
16
+ az: 14,
17
+ eu: 15,
18
+ be: 16,
19
+ bn: 17,
20
+ bi: 18,
21
+ bs: 19,
22
+ br: 20,
23
+ bg: 21,
24
+ my: 22,
25
+ ca: 23,
26
+ km: 24,
27
+ ce: 25,
28
+ zh: 26,
29
+ cv: 27,
30
+ kw: 28,
31
+ co: 29,
32
+ hr: 30,
33
+ cs: 31,
34
+ da: 32,
35
+ dv: 33,
36
+ nl: 34,
37
+ dz: 35,
38
+ en: 36,
39
+ et: 37,
40
+ fo: 38,
41
+ fi: 39,
42
+ fr: 40,
43
+ ff: 41,
44
+ gd: 42,
45
+ gl: 43,
46
+ de: 44,
47
+ gsw: 45,
48
+ el: 46,
49
+ kl: 47,
50
+ gu: 48,
51
+ ht: 49,
52
+ ha: 50,
53
+ he: 51,
54
+ hi: 52,
55
+ hu: 53,
56
+ is: 54,
57
+ ig: 55,
58
+ id: 56,
59
+ ia: 57,
60
+ iu: 58,
61
+ ik: 59,
62
+ ga: 60,
63
+ it: 61,
64
+ ja: 62,
65
+ kn: 63,
66
+ ks: 64,
67
+ kk: 65,
68
+ rw: 66,
69
+ ko: 67,
70
+ ku: 68,
71
+ ky: 69,
72
+ lo: 70,
73
+ la: 71,
74
+ lv: 72,
75
+ lb: 73,
76
+ li: 74,
77
+ ln: 75,
78
+ lt: 76,
79
+ mk: 77,
80
+ mg: 78,
81
+ ms: 79,
82
+ ml: 80,
83
+ mt: 81,
84
+ gv: 82,
85
+ mi: 83,
86
+ ro: 84,
87
+ mn: 85,
88
+ ne: 86,
89
+ se: 87,
90
+ no: 88,
91
+ nb: 89,
92
+ nn: 90,
93
+ oc: 91,
94
+ or: 92,
95
+ om: 93,
96
+ os: 94,
97
+ pa: 95,
98
+ ps: 96,
99
+ fa: 97,
100
+ pl: 98,
101
+ pt: 99,
102
+ qu: 100,
103
+ rm: 101,
104
+ ru: 102,
105
+ sm: 103,
106
+ sa: 104,
107
+ sc: 105,
108
+ sr: 106,
109
+ sd: 107,
110
+ si: 108,
111
+ sk: 109,
112
+ sl: 110,
113
+ so: 111,
114
+ st: 112,
115
+ nr: 113,
116
+ es: 114,
117
+ sw: 115,
118
+ ss: 116,
119
+ sv: 117,
120
+ tl: 118,
121
+ tg: 119,
122
+ ta: 120,
123
+ tt: 121,
124
+ te: 122,
125
+ th: 123,
126
+ bo: 124,
127
+ ti: 125,
128
+ to: 126,
129
+ ts: 127,
130
+ tn: 128,
131
+ tr: 129,
132
+ tk: 130,
133
+ ug: 131,
134
+ uk: 132,
135
+ ur: 133,
136
+ uz: 134,
137
+ ve: 135,
138
+ vi: 136,
139
+ wa: 137,
140
+ cy: 138,
141
+ fy: 139,
142
+ wo: 140,
143
+ xh: 141,
144
+ yi: 142,
145
+ yo: 143,
146
+ zu: 144,
147
+ };
148
+ export const langCodesMap = new Map(Object.entries(langCodes));
149
+ export const inverseLangMap = new Map();
150
+ langCodesMap.forEach((v, k) => {
151
+ inverseLangMap.set(v, k);
152
+ });
153
+ //# sourceMappingURL=lang.js.map
@@ -0,0 +1,3 @@
1
+ import { StrictSchema } from './types.js';
2
+ export declare const mermaid: (schema: StrictSchema) => string;
3
+ //# sourceMappingURL=mermaid.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { getPropType } from './parse/utils.js';
2
+ import { isPropType } from './types.js';
3
+ export const mermaid = (schema) => {
4
+ let mermaid = 'classDiagram';
5
+ if (schema.types) {
6
+ for (const type in schema.types) {
7
+ for (const key in schema.types[type].props) {
8
+ const prop = schema.types[type].props[key];
9
+ const propType = getPropType(prop);
10
+ if (isPropType('reference', prop)) {
11
+ mermaid += `\n${type} --> ${prop.ref} : ${key}`;
12
+ }
13
+ else if (isPropType('references', prop)) {
14
+ mermaid += `\n${type} --> ${prop.items.ref} : ${key}[]`;
15
+ }
16
+ else {
17
+ mermaid += `\n${type} : ${propType} ${key}`;
18
+ }
19
+ }
20
+ }
21
+ }
22
+ return mermaid;
23
+ };
24
+ //# sourceMappingURL=mermaid.js.map
@@ -1,4 +1,5 @@
1
- export declare const expectObject: (obj: any) => void;
1
+ export declare const expectObject: (obj: any, msg?: string) => void;
2
+ export declare const expectFloat32Array: (arr: any) => void;
2
3
  export declare const expectString: (obj: any) => void;
3
4
  export declare const expectBoolean: (v: any) => void;
4
5
  export declare const expectFunction: (v: any) => void;
@@ -1,7 +1,13 @@
1
- import { EXPECTED_BOOL, EXPECTED_FN, EXPECTED_NUM, EXPECTED_OBJ, EXPECTED_STR, } from './errors.js';
2
- export const expectObject = (obj) => {
1
+ import { isFloat32Array } from 'util/types';
2
+ import { EXPECTED_ARR, EXPECTED_BOOL, EXPECTED_FN, EXPECTED_NUM, EXPECTED_OBJ, EXPECTED_STR, } from './errors.js';
3
+ export const expectObject = (obj, msg) => {
3
4
  if (typeof obj !== 'object' || obj === null) {
4
- throw Error(EXPECTED_OBJ);
5
+ throw Error(msg || EXPECTED_OBJ);
6
+ }
7
+ };
8
+ export const expectFloat32Array = (arr) => {
9
+ if (!isFloat32Array(arr)) {
10
+ throw Error(EXPECTED_ARR);
5
11
  }
6
12
  };
7
13
  export const expectString = (obj) => {
@@ -9,6 +9,7 @@ export declare const EXPECTED_STR = "Expected string";
9
9
  export declare const EXPECTED_FN = "Expected function";
10
10
  export declare const EXPECTED_PRIMITIVE = "Expected primitive value";
11
11
  export declare const INVALID_VALUE = "Invalid value";
12
+ export declare const INVALID_KEY = "Invalid key";
12
13
  export declare const INVALID_SCHEMA = "Invalid schema";
13
14
  export declare const MIN_MAX = "Max value must be larger than min value";
14
15
  export declare const UNKNOWN_PROP = "Unknown property";
@@ -16,4 +17,5 @@ export declare const MISSING_TYPE = "Missing type";
16
17
  export declare const INVALID_TYPE = "Invalid type";
17
18
  export declare const TEXT_REQUIRES_LOCALES = "Type text requires locales";
18
19
  export declare const TYPE_MISMATCH = "Types do not match";
20
+ export declare const NOT_ALLOWED_IN_ITEMS = "Property not allowed in items definition";
19
21
  //# sourceMappingURL=errors.d.ts.map
@@ -9,6 +9,7 @@ export const EXPECTED_STR = 'Expected string';
9
9
  export const EXPECTED_FN = 'Expected function';
10
10
  export const EXPECTED_PRIMITIVE = 'Expected primitive value';
11
11
  export const INVALID_VALUE = 'Invalid value';
12
+ export const INVALID_KEY = 'Invalid key';
12
13
  export const INVALID_SCHEMA = 'Invalid schema';
13
14
  export const MIN_MAX = 'Max value must be larger than min value';
14
15
  export const UNKNOWN_PROP = 'Unknown property';
@@ -16,4 +17,5 @@ export const MISSING_TYPE = 'Missing type';
16
17
  export const INVALID_TYPE = 'Invalid type';
17
18
  export const TEXT_REQUIRES_LOCALES = 'Type text requires locales';
18
19
  export const TYPE_MISMATCH = 'Types do not match';
20
+ export const NOT_ALLOWED_IN_ITEMS = 'Property not allowed in items definition';
19
21
  //# sourceMappingURL=errors.js.map
@@ -1,20 +1,21 @@
1
- import { Schema, SchemaType } from '../types.js';
1
+ import { Schema, SchemaType, StrictSchema } from '../types.js';
2
2
  import { getPropType } from './utils.js';
3
3
  export { getPropType };
4
4
  export declare class SchemaParser {
5
5
  constructor(schema: Schema);
6
+ isItems: boolean;
6
7
  inQuery: boolean;
7
8
  schema: Schema;
8
9
  type: SchemaType;
9
- parseType(type: SchemaType): void;
10
+ path: string[];
11
+ lvl: number;
10
12
  parseTypes(): void;
11
13
  parseProps(props: any, schemaType?: SchemaType): void;
12
14
  parseLocales(): void;
13
15
  parse(): void;
14
16
  }
15
17
  export declare const print: (schema: Schema, path: string[]) => string;
16
- export declare const debug: (schema: Schema) => void;
17
18
  export declare const parse: (schema: Schema) => {
18
- schema: Schema;
19
+ schema: StrictSchema;
19
20
  };
20
21
  //# sourceMappingURL=index.d.ts.map