@based/schema 5.0.0-alpha.0 → 5.0.0-alpha.10
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/def/addEdges.d.ts +4 -0
- package/dist/def/addEdges.js +76 -0
- package/dist/def/createEmptyDef.d.ts +38 -0
- package/dist/def/createEmptyDef.js +41 -0
- package/dist/def/defaultMap.d.ts +3 -0
- package/dist/def/defaultMap.js +27 -0
- package/dist/def/fillEmptyMain.d.ts +5 -0
- package/dist/def/fillEmptyMain.js +61 -0
- package/dist/def/getPropLen.d.ts +3 -0
- package/dist/def/getPropLen.js +23 -0
- package/dist/def/index.d.ts +9 -0
- package/dist/def/index.js +10 -0
- package/dist/def/makePacked.d.ts +3 -0
- package/dist/def/makePacked.js +50 -0
- package/dist/def/makeSeparateSort.d.ts +3 -0
- package/dist/def/makeSeparateSort.js +27 -0
- package/dist/def/makeSeparateTextSort.d.ts +3 -0
- package/dist/def/makeSeparateTextSort.js +38 -0
- package/dist/def/readFromPacked.d.ts +3 -0
- package/dist/def/readFromPacked.js +140 -0
- package/dist/def/selvaBuffer.d.ts +5 -0
- package/dist/def/selvaBuffer.js +115 -0
- package/dist/def/typeDef.d.ts +7 -0
- package/dist/def/typeDef.js +215 -0
- package/dist/def/types.d.ts +166 -0
- package/dist/def/types.js +116 -0
- package/dist/def/utils.d.ts +8 -0
- package/dist/def/utils.js +59 -0
- package/dist/def/validation.d.ts +7 -0
- package/dist/def/validation.js +258 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lang.d.ts +1 -0
- package/dist/lang.js +4 -0
- package/dist/parse/assert.d.ts +1 -0
- package/dist/parse/assert.js +7 -1
- package/dist/parse/index.d.ts +1 -1
- package/dist/parse/index.js +5 -5
- package/dist/parse/props.d.ts +1 -0
- package/dist/parse/props.js +112 -47
- package/dist/types.d.ts +42 -13
- package/dist/types.js +2 -0
- package/package.json +8 -4
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LangName } from './lang.js';
|
|
2
|
+
import { Validation } from './def/validation.js';
|
|
2
3
|
type Role = 'title' | 'source' | 'media' | string;
|
|
3
4
|
export declare const numberDisplays: readonly ["short", "human", "ratio", "bytes", "euro", "dollar", "pound", "meter"];
|
|
4
5
|
export declare const dateDisplays: readonly ["date", "date-time", "date-time-text", "date-time-human", "time", "time-precise"];
|
|
@@ -14,6 +15,7 @@ type QueryFn = Function;
|
|
|
14
15
|
type PropValues = {
|
|
15
16
|
type?: string;
|
|
16
17
|
default?: any;
|
|
18
|
+
validation?: Validation;
|
|
17
19
|
};
|
|
18
20
|
type Prop<V extends PropValues> = {
|
|
19
21
|
required?: boolean;
|
|
@@ -24,6 +26,7 @@ type Prop<V extends PropValues> = {
|
|
|
24
26
|
role?: Role;
|
|
25
27
|
readOnly?: boolean;
|
|
26
28
|
examples?: string[];
|
|
29
|
+
validation?: Validation;
|
|
27
30
|
} & V;
|
|
28
31
|
type EnumItem = string | number | boolean;
|
|
29
32
|
type NeverInItems = {
|
|
@@ -31,15 +34,18 @@ type NeverInItems = {
|
|
|
31
34
|
};
|
|
32
35
|
export type SchemaReferences = Prop<{
|
|
33
36
|
type?: 'references';
|
|
37
|
+
default?: number[];
|
|
34
38
|
items: SchemaReference & NeverInItems;
|
|
35
39
|
}>;
|
|
36
40
|
export type SchemaReferencesOneWay = Prop<{
|
|
37
41
|
type?: 'references';
|
|
42
|
+
default?: number[];
|
|
38
43
|
items: SchemaReferenceOneWay & NeverInItems;
|
|
39
44
|
}>;
|
|
40
45
|
export type SchemaText = Prop<{
|
|
41
46
|
type: 'text';
|
|
42
47
|
default?: Record<string, string>;
|
|
48
|
+
format?: StringFormat;
|
|
43
49
|
}>;
|
|
44
50
|
type NumberType = 'number' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32';
|
|
45
51
|
export type SchemaNumber = Prop<{
|
|
@@ -49,6 +55,9 @@ export type SchemaNumber = Prop<{
|
|
|
49
55
|
max?: number;
|
|
50
56
|
step?: number | 'any';
|
|
51
57
|
display?: NumberDisplay;
|
|
58
|
+
history?: {
|
|
59
|
+
interval: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
|
60
|
+
};
|
|
52
61
|
}>;
|
|
53
62
|
export type SchemaString = Prop<{
|
|
54
63
|
type: 'string';
|
|
@@ -62,34 +71,48 @@ export type SchemaString = Prop<{
|
|
|
62
71
|
}>;
|
|
63
72
|
export type SchemaBinary = Prop<{
|
|
64
73
|
type: 'binary';
|
|
65
|
-
default?:
|
|
74
|
+
default?: Uint8Array;
|
|
66
75
|
maxBytes?: number;
|
|
67
76
|
mime?: Mime;
|
|
68
77
|
format?: StringFormat;
|
|
69
78
|
}>;
|
|
79
|
+
export type SchemaJson = Prop<{
|
|
80
|
+
type: 'json';
|
|
81
|
+
default?: Record<string, any> | null;
|
|
82
|
+
}>;
|
|
70
83
|
export type SchemaBoolean = Prop<{
|
|
71
84
|
type: 'boolean';
|
|
72
85
|
default?: boolean;
|
|
73
86
|
}>;
|
|
74
|
-
export type
|
|
75
|
-
type: '
|
|
76
|
-
|
|
87
|
+
export type SchemaCardinality = Prop<{
|
|
88
|
+
type: 'cardinality';
|
|
89
|
+
maxBytes?: number;
|
|
90
|
+
mime?: Mime;
|
|
91
|
+
format?: NumberDisplay;
|
|
92
|
+
}>;
|
|
93
|
+
export type SchemaVector = Prop<{
|
|
94
|
+
type: 'vector';
|
|
95
|
+
default?: Float32Array;
|
|
96
|
+
size: number;
|
|
77
97
|
}>;
|
|
78
98
|
export type SchemaTimestamp = Prop<{
|
|
79
99
|
type: 'timestamp';
|
|
80
|
-
default?: number | Date;
|
|
100
|
+
default?: number | Date | string;
|
|
81
101
|
on?: 'create' | 'update';
|
|
82
102
|
display?: DateDisplay;
|
|
103
|
+
min?: number | string;
|
|
104
|
+
max?: number | string;
|
|
105
|
+
step?: number | 'any' | string;
|
|
83
106
|
}>;
|
|
84
107
|
export type SchemaReferenceOneWay = Prop<{
|
|
85
108
|
type?: 'reference';
|
|
86
|
-
default?:
|
|
109
|
+
default?: number;
|
|
87
110
|
ref: string;
|
|
88
111
|
mime?: Mime;
|
|
89
112
|
}>;
|
|
90
113
|
export type SchemaReference = Prop<{
|
|
91
114
|
type?: 'reference';
|
|
92
|
-
default?:
|
|
115
|
+
default?: number;
|
|
93
116
|
ref: string;
|
|
94
117
|
prop: string;
|
|
95
118
|
dependent?: boolean;
|
|
@@ -111,13 +134,13 @@ export type SchemaReferencesWithQuery = SchemaReferencesOneWay & {
|
|
|
111
134
|
};
|
|
112
135
|
export type SchemaEnum = Prop<{
|
|
113
136
|
type?: 'enum';
|
|
114
|
-
default?: EnumItem;
|
|
137
|
+
default?: EnumItem | undefined;
|
|
115
138
|
enum: EnumItem[];
|
|
116
139
|
}>;
|
|
117
140
|
export type SchemaAlias = Omit<SchemaString, 'type'> & {
|
|
118
141
|
type: 'alias';
|
|
119
142
|
};
|
|
120
|
-
export type SchemaPropShorthand = 'timestamp' | 'binary' | 'boolean' | 'string' | 'alias' | 'text' | '
|
|
143
|
+
export type SchemaPropShorthand = 'timestamp' | 'binary' | 'boolean' | 'string' | 'alias' | 'text' | 'json' | 'cardinality' | NumberType | EnumItem[];
|
|
121
144
|
type SetItems<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaEnum | (isStrict extends true ? never : 'timestamp' | 'binary' | 'boolean' | 'string' | NumberType | EnumItem[]);
|
|
122
145
|
export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
|
|
123
146
|
type?: 'set';
|
|
@@ -126,7 +149,7 @@ export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
|
|
|
126
149
|
} ? ItemsType['default'][] : undefined;
|
|
127
150
|
items: ItemsType & NeverInItems;
|
|
128
151
|
}>;
|
|
129
|
-
type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaBinary |
|
|
152
|
+
type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaJson | SchemaBinary | SchemaCardinality | SchemaVector | (isStrict extends true ? SchemaSet<SetItems<true>> : SchemaPropShorthand | SchemaSet);
|
|
130
153
|
export type SchemaProp<isStrict = false> = SchemaReferencesWithQuery | SchemaReferenceWithQuery | NonRefSchemaProps<isStrict> | SchemaReferences | SchemaReference | SchemaObject | SchemaBinary;
|
|
131
154
|
export type SchemaPropOneWay<isStrict = false> = SchemaReferencesOneWay | SchemaReferenceOneWay | SchemaObjectOneWay | NonRefSchemaProps<isStrict>;
|
|
132
155
|
export type SchemaAnyProp = SchemaPropOneWay | SchemaProp;
|
|
@@ -147,8 +170,10 @@ export type StrictSchemaType = GenericSchemaType<true>;
|
|
|
147
170
|
export type SchemaType<isStrict = false> = isStrict extends true ? StrictSchemaType : StrictSchemaType | GenericSchemaType<false> | (SchemaProps & {
|
|
148
171
|
props?: never;
|
|
149
172
|
});
|
|
150
|
-
export type SchemaTypeName =
|
|
151
|
-
export type SchemaTypes<isStrict = false> = Record<SchemaTypeName, SchemaType<isStrict
|
|
173
|
+
export type SchemaTypeName = Exclude<string, '_root'>;
|
|
174
|
+
export type SchemaTypes<isStrict = false> = Record<SchemaTypeName, SchemaType<isStrict>> & {
|
|
175
|
+
_root?: never;
|
|
176
|
+
};
|
|
152
177
|
export type SchemaPropsOneWay<isStrict = false> = Record<AllowedKey, SchemaPropOneWay<isStrict>> & {
|
|
153
178
|
id?: never;
|
|
154
179
|
};
|
|
@@ -173,11 +198,15 @@ export type SchemaPropTypeMap = {
|
|
|
173
198
|
alias: SchemaAlias;
|
|
174
199
|
enum: SchemaEnum;
|
|
175
200
|
text: SchemaText;
|
|
201
|
+
json: SchemaJson;
|
|
176
202
|
set: SchemaSet;
|
|
177
203
|
binary: SchemaBinary;
|
|
178
|
-
|
|
204
|
+
cardinality: SchemaCardinality;
|
|
205
|
+
vector: SchemaVector;
|
|
179
206
|
} & Record<NumberType, SchemaNumber>;
|
|
180
207
|
export type SchemaPropTypes = keyof SchemaPropTypeMap;
|
|
181
208
|
export declare const isPropType: <T extends SchemaPropTypes>(type: T, prop: SchemaProp) => prop is SchemaPropTypeMap[T];
|
|
209
|
+
export declare const MAX_ID = 4294967295;
|
|
210
|
+
export declare const MIN_ID = 1;
|
|
182
211
|
export {};
|
|
183
212
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/schema",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.10",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
5
|
"files": [
|
|
7
6
|
"dist",
|
|
8
7
|
"README.md",
|
|
9
8
|
"package.json",
|
|
10
9
|
"!dist/**/*.map"
|
|
11
10
|
],
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./def": "./dist/def/index.js",
|
|
14
|
+
".": "./dist/index.js"
|
|
15
|
+
},
|
|
12
16
|
"scripts": {
|
|
13
17
|
"build": "tsc",
|
|
14
18
|
"watch": "tsc --watch",
|
|
15
|
-
"test": "tsc && tsc
|
|
16
|
-
"test1": "tsc && tsc $npm_config --noEmit && tsx --test $npm_config"
|
|
19
|
+
"test": "tsc && tsc $npm_config --noEmit && tsx --test $npm_config"
|
|
17
20
|
},
|
|
18
21
|
"prettier": "@saulx/prettier-config",
|
|
19
22
|
"sideEffects": false,
|
|
@@ -26,6 +29,7 @@
|
|
|
26
29
|
"typescript": "^5.6.3"
|
|
27
30
|
},
|
|
28
31
|
"dependencies": {
|
|
32
|
+
"@saulx/utils": "^6.4.0",
|
|
29
33
|
"picocolors": "^1.1.0"
|
|
30
34
|
}
|
|
31
35
|
}
|