@based/schema 5.0.0-alpha.0 → 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.
- package/dist/lang.d.ts +2 -1
- package/dist/lang.js +4 -0
- package/dist/parse/assert.d.ts +1 -0
- package/dist/parse/assert.js +7 -1
- package/dist/parse/props.js +10 -1
- package/dist/types.d.ts +7 -1
- package/package.json +1 -1
package/dist/lang.d.ts
CHANGED
|
@@ -145,7 +145,8 @@ declare const langCodes: {
|
|
|
145
145
|
readonly yo: 143;
|
|
146
146
|
readonly zu: 144;
|
|
147
147
|
};
|
|
148
|
-
export declare const langCodesMap: Map<string, 0 |
|
|
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>;
|
|
149
150
|
export type LangName = keyof typeof langCodes;
|
|
150
151
|
export type LangCode = (typeof langCodes)[LangName];
|
|
151
152
|
export {};
|
package/dist/lang.js
CHANGED
|
@@ -146,4 +146,8 @@ const langCodes = {
|
|
|
146
146
|
zu: 144,
|
|
147
147
|
};
|
|
148
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
|
+
});
|
|
149
153
|
//# sourceMappingURL=lang.js.map
|
package/dist/parse/assert.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
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;
|
package/dist/parse/assert.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isFloat32Array } from 'util/types';
|
|
2
|
+
import { EXPECTED_ARR, EXPECTED_BOOL, EXPECTED_FN, EXPECTED_NUM, EXPECTED_OBJ, EXPECTED_STR, } from './errors.js';
|
|
2
3
|
export const expectObject = (obj, msg) => {
|
|
3
4
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
5
|
throw Error(msg || EXPECTED_OBJ);
|
|
5
6
|
}
|
|
6
7
|
};
|
|
8
|
+
export const expectFloat32Array = (arr) => {
|
|
9
|
+
if (!isFloat32Array(arr)) {
|
|
10
|
+
throw Error(EXPECTED_ARR);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
7
13
|
export const expectString = (obj) => {
|
|
8
14
|
if (typeof obj !== 'string') {
|
|
9
15
|
throw Error(EXPECTED_STR);
|
package/dist/parse/props.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stringFormats, dateDisplays, numberDisplays, } from '../types.js';
|
|
2
|
-
import { expectBoolean, expectFunction, expectObject, expectString,
|
|
2
|
+
import { expectBoolean, expectFloat32Array, expectFunction, expectNumber, expectObject, expectString, } from './assert.js';
|
|
3
3
|
import { EXPECTED_ARR, EXPECTED_DATE, EXPECTED_OBJ, EXPECTED_PRIMITIVE, EXPECTED_VALUE_IN_ENUM, INVALID_VALUE, MIN_MAX, MISSING_TYPE, OUT_OF_RANGE, TEXT_REQUIRES_LOCALES, TYPE_MISMATCH, UNKNOWN_PROP, NOT_ALLOWED_IN_ITEMS, } from './errors.js';
|
|
4
4
|
import { getPropType } from './utils.js';
|
|
5
5
|
let stringFormatsSet;
|
|
@@ -96,6 +96,15 @@ p.boolean = propParser(STUB, {
|
|
|
96
96
|
expectBoolean(val);
|
|
97
97
|
},
|
|
98
98
|
}, 0);
|
|
99
|
+
p.vector = propParser({
|
|
100
|
+
size(val) {
|
|
101
|
+
expectNumber(val);
|
|
102
|
+
},
|
|
103
|
+
}, {
|
|
104
|
+
default(val) {
|
|
105
|
+
expectFloat32Array(val);
|
|
106
|
+
},
|
|
107
|
+
}, 0);
|
|
99
108
|
p.enum = propParser({
|
|
100
109
|
enum(items) {
|
|
101
110
|
if (!Array.isArray(items)) {
|
package/dist/types.d.ts
CHANGED
|
@@ -75,6 +75,11 @@ export type SchemaHll = Prop<{
|
|
|
75
75
|
type: 'hll';
|
|
76
76
|
default?: number;
|
|
77
77
|
}>;
|
|
78
|
+
export type SchemaVector = Prop<{
|
|
79
|
+
type: 'vector';
|
|
80
|
+
default?: Float32Array;
|
|
81
|
+
size: number;
|
|
82
|
+
}>;
|
|
78
83
|
export type SchemaTimestamp = Prop<{
|
|
79
84
|
type: 'timestamp';
|
|
80
85
|
default?: number | Date;
|
|
@@ -126,7 +131,7 @@ export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
|
|
|
126
131
|
} ? ItemsType['default'][] : undefined;
|
|
127
132
|
items: ItemsType & NeverInItems;
|
|
128
133
|
}>;
|
|
129
|
-
type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaBinary | SchemaHll | (isStrict extends true ? SchemaSet<SetItems<true>> : SchemaPropShorthand | SchemaSet);
|
|
134
|
+
type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaBinary | SchemaHll | SchemaVector | (isStrict extends true ? SchemaSet<SetItems<true>> : SchemaPropShorthand | SchemaSet);
|
|
130
135
|
export type SchemaProp<isStrict = false> = SchemaReferencesWithQuery | SchemaReferenceWithQuery | NonRefSchemaProps<isStrict> | SchemaReferences | SchemaReference | SchemaObject | SchemaBinary;
|
|
131
136
|
export type SchemaPropOneWay<isStrict = false> = SchemaReferencesOneWay | SchemaReferenceOneWay | SchemaObjectOneWay | NonRefSchemaProps<isStrict>;
|
|
132
137
|
export type SchemaAnyProp = SchemaPropOneWay | SchemaProp;
|
|
@@ -176,6 +181,7 @@ export type SchemaPropTypeMap = {
|
|
|
176
181
|
set: SchemaSet;
|
|
177
182
|
binary: SchemaBinary;
|
|
178
183
|
hll: SchemaHll;
|
|
184
|
+
vector: SchemaVector;
|
|
179
185
|
} & Record<NumberType, SchemaNumber>;
|
|
180
186
|
export type SchemaPropTypes = keyof SchemaPropTypeMap;
|
|
181
187
|
export declare const isPropType: <T extends SchemaPropTypes>(type: T, prop: SchemaProp) => prop is SchemaPropTypeMap[T];
|