@based/schema 5.0.0-alpha.1 → 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 -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 +105 -49
- package/dist/types.d.ts +36 -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,18 +71,24 @@ 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;
|
|
77
92
|
}>;
|
|
78
93
|
export type SchemaVector = Prop<{
|
|
79
94
|
type: 'vector';
|
|
@@ -82,19 +97,22 @@ export type SchemaVector = Prop<{
|
|
|
82
97
|
}>;
|
|
83
98
|
export type SchemaTimestamp = Prop<{
|
|
84
99
|
type: 'timestamp';
|
|
85
|
-
default?: number | Date;
|
|
100
|
+
default?: number | Date | string;
|
|
86
101
|
on?: 'create' | 'update';
|
|
87
102
|
display?: DateDisplay;
|
|
103
|
+
min?: number | string;
|
|
104
|
+
max?: number | string;
|
|
105
|
+
step?: number | 'any' | string;
|
|
88
106
|
}>;
|
|
89
107
|
export type SchemaReferenceOneWay = Prop<{
|
|
90
108
|
type?: 'reference';
|
|
91
|
-
default?:
|
|
109
|
+
default?: number;
|
|
92
110
|
ref: string;
|
|
93
111
|
mime?: Mime;
|
|
94
112
|
}>;
|
|
95
113
|
export type SchemaReference = Prop<{
|
|
96
114
|
type?: 'reference';
|
|
97
|
-
default?:
|
|
115
|
+
default?: number;
|
|
98
116
|
ref: string;
|
|
99
117
|
prop: string;
|
|
100
118
|
dependent?: boolean;
|
|
@@ -116,13 +134,13 @@ export type SchemaReferencesWithQuery = SchemaReferencesOneWay & {
|
|
|
116
134
|
};
|
|
117
135
|
export type SchemaEnum = Prop<{
|
|
118
136
|
type?: 'enum';
|
|
119
|
-
default?: EnumItem;
|
|
137
|
+
default?: EnumItem | undefined;
|
|
120
138
|
enum: EnumItem[];
|
|
121
139
|
}>;
|
|
122
140
|
export type SchemaAlias = Omit<SchemaString, 'type'> & {
|
|
123
141
|
type: 'alias';
|
|
124
142
|
};
|
|
125
|
-
export type SchemaPropShorthand = 'timestamp' | 'binary' | 'boolean' | 'string' | 'alias' | 'text' | '
|
|
143
|
+
export type SchemaPropShorthand = 'timestamp' | 'binary' | 'boolean' | 'string' | 'alias' | 'text' | 'json' | 'cardinality' | NumberType | EnumItem[];
|
|
126
144
|
type SetItems<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaEnum | (isStrict extends true ? never : 'timestamp' | 'binary' | 'boolean' | 'string' | NumberType | EnumItem[]);
|
|
127
145
|
export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
|
|
128
146
|
type?: 'set';
|
|
@@ -131,7 +149,7 @@ export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
|
|
|
131
149
|
} ? ItemsType['default'][] : undefined;
|
|
132
150
|
items: ItemsType & NeverInItems;
|
|
133
151
|
}>;
|
|
134
|
-
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);
|
|
135
153
|
export type SchemaProp<isStrict = false> = SchemaReferencesWithQuery | SchemaReferenceWithQuery | NonRefSchemaProps<isStrict> | SchemaReferences | SchemaReference | SchemaObject | SchemaBinary;
|
|
136
154
|
export type SchemaPropOneWay<isStrict = false> = SchemaReferencesOneWay | SchemaReferenceOneWay | SchemaObjectOneWay | NonRefSchemaProps<isStrict>;
|
|
137
155
|
export type SchemaAnyProp = SchemaPropOneWay | SchemaProp;
|
|
@@ -152,8 +170,10 @@ export type StrictSchemaType = GenericSchemaType<true>;
|
|
|
152
170
|
export type SchemaType<isStrict = false> = isStrict extends true ? StrictSchemaType : StrictSchemaType | GenericSchemaType<false> | (SchemaProps & {
|
|
153
171
|
props?: never;
|
|
154
172
|
});
|
|
155
|
-
export type SchemaTypeName =
|
|
156
|
-
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
|
+
};
|
|
157
177
|
export type SchemaPropsOneWay<isStrict = false> = Record<AllowedKey, SchemaPropOneWay<isStrict>> & {
|
|
158
178
|
id?: never;
|
|
159
179
|
};
|
|
@@ -178,12 +198,15 @@ export type SchemaPropTypeMap = {
|
|
|
178
198
|
alias: SchemaAlias;
|
|
179
199
|
enum: SchemaEnum;
|
|
180
200
|
text: SchemaText;
|
|
201
|
+
json: SchemaJson;
|
|
181
202
|
set: SchemaSet;
|
|
182
203
|
binary: SchemaBinary;
|
|
183
|
-
|
|
204
|
+
cardinality: SchemaCardinality;
|
|
184
205
|
vector: SchemaVector;
|
|
185
206
|
} & Record<NumberType, SchemaNumber>;
|
|
186
207
|
export type SchemaPropTypes = keyof SchemaPropTypeMap;
|
|
187
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;
|
|
188
211
|
export {};
|
|
189
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
|
}
|