@based/schema 5.0.0-alpha.1 → 5.0.0-alpha.3

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.
@@ -20,7 +20,7 @@ export class SchemaParser {
20
20
  expectObject(types);
21
21
  for (const type in types) {
22
22
  this.lvl++;
23
- if (type[0] === '_') {
23
+ if (type === '_root') {
24
24
  throw new Error(INVALID_KEY);
25
25
  }
26
26
  this.path[this.lvl] = type;
@@ -382,10 +382,15 @@ p.alias = propParser(STUB, {
382
382
  },
383
383
  format: binaryOpts.format,
384
384
  }, 0);
385
- p.hll = propParser(STUB, {
385
+ p.cardinality = propParser(STUB, {
386
386
  default(val) {
387
387
  expectNumber(val);
388
388
  },
389
389
  }, 0);
390
+ p.json = propParser(STUB, {
391
+ default(val) {
392
+ expectObject(val);
393
+ },
394
+ }, 0);
390
395
  export default p;
391
396
  //# sourceMappingURL=props.js.map
package/dist/types.d.ts CHANGED
@@ -49,6 +49,9 @@ export type SchemaNumber = Prop<{
49
49
  max?: number;
50
50
  step?: number | 'any';
51
51
  display?: NumberDisplay;
52
+ history?: {
53
+ interval: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
54
+ };
52
55
  }>;
53
56
  export type SchemaString = Prop<{
54
57
  type: 'string';
@@ -67,13 +70,20 @@ export type SchemaBinary = Prop<{
67
70
  mime?: Mime;
68
71
  format?: StringFormat;
69
72
  }>;
73
+ export type SchemaJson = Prop<{
74
+ type: 'json';
75
+ default?: Record<string, any> | null;
76
+ }>;
70
77
  export type SchemaBoolean = Prop<{
71
78
  type: 'boolean';
72
79
  default?: boolean;
73
80
  }>;
74
- export type SchemaHll = Prop<{
75
- type: 'hll';
76
- default?: number;
81
+ export type SchemaCardinality = Prop<{
82
+ type: 'cardinality';
83
+ default?: string;
84
+ maxBytes?: number;
85
+ mime?: Mime;
86
+ format?: NumberDisplay;
77
87
  }>;
78
88
  export type SchemaVector = Prop<{
79
89
  type: 'vector';
@@ -122,7 +132,7 @@ export type SchemaEnum = Prop<{
122
132
  export type SchemaAlias = Omit<SchemaString, 'type'> & {
123
133
  type: 'alias';
124
134
  };
125
- export type SchemaPropShorthand = 'timestamp' | 'binary' | 'boolean' | 'string' | 'alias' | 'text' | 'hll' | NumberType | EnumItem[];
135
+ export type SchemaPropShorthand = 'timestamp' | 'binary' | 'boolean' | 'string' | 'alias' | 'text' | 'json' | 'cardinality' | NumberType | EnumItem[];
126
136
  type SetItems<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaEnum | (isStrict extends true ? never : 'timestamp' | 'binary' | 'boolean' | 'string' | NumberType | EnumItem[]);
127
137
  export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
128
138
  type?: 'set';
@@ -131,7 +141,7 @@ export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
131
141
  } ? ItemsType['default'][] : undefined;
132
142
  items: ItemsType & NeverInItems;
133
143
  }>;
134
- type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaBinary | SchemaHll | SchemaVector | (isStrict extends true ? SchemaSet<SetItems<true>> : SchemaPropShorthand | SchemaSet);
144
+ type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaJson | SchemaBinary | SchemaCardinality | SchemaVector | (isStrict extends true ? SchemaSet<SetItems<true>> : SchemaPropShorthand | SchemaSet);
135
145
  export type SchemaProp<isStrict = false> = SchemaReferencesWithQuery | SchemaReferenceWithQuery | NonRefSchemaProps<isStrict> | SchemaReferences | SchemaReference | SchemaObject | SchemaBinary;
136
146
  export type SchemaPropOneWay<isStrict = false> = SchemaReferencesOneWay | SchemaReferenceOneWay | SchemaObjectOneWay | NonRefSchemaProps<isStrict>;
137
147
  export type SchemaAnyProp = SchemaPropOneWay | SchemaProp;
@@ -152,8 +162,10 @@ export type StrictSchemaType = GenericSchemaType<true>;
152
162
  export type SchemaType<isStrict = false> = isStrict extends true ? StrictSchemaType : StrictSchemaType | GenericSchemaType<false> | (SchemaProps & {
153
163
  props?: never;
154
164
  });
155
- export type SchemaTypeName = AllowedKey;
156
- export type SchemaTypes<isStrict = false> = Record<SchemaTypeName, SchemaType<isStrict>>;
165
+ export type SchemaTypeName = Exclude<string, '_root'>;
166
+ export type SchemaTypes<isStrict = false> = Record<SchemaTypeName, SchemaType<isStrict>> & {
167
+ _root?: never;
168
+ };
157
169
  export type SchemaPropsOneWay<isStrict = false> = Record<AllowedKey, SchemaPropOneWay<isStrict>> & {
158
170
  id?: never;
159
171
  };
@@ -178,9 +190,10 @@ export type SchemaPropTypeMap = {
178
190
  alias: SchemaAlias;
179
191
  enum: SchemaEnum;
180
192
  text: SchemaText;
193
+ json: SchemaJson;
181
194
  set: SchemaSet;
182
195
  binary: SchemaBinary;
183
- hll: SchemaHll;
196
+ cardinality: SchemaCardinality;
184
197
  vector: SchemaVector;
185
198
  } & Record<NumberType, SchemaNumber>;
186
199
  export type SchemaPropTypes = keyof SchemaPropTypeMap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/schema",
3
- "version": "5.0.0-alpha.1",
3
+ "version": "5.0.0-alpha.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "files": [