@based/schema 5.0.3 → 5.0.4-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/def/typeDef.js +7 -2
- package/dist/def/types.d.ts +2 -0
- package/dist/def/utils.d.ts +2 -1
- package/dist/def/utils.js +7 -1
- package/dist/parse/props.js +12 -0
- package/dist/types.d.ts +3 -2
- package/package.json +1 -1
package/dist/def/typeDef.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isPropType, getPropType, } from '../index.js';
|
|
2
2
|
import { setByPath } from '@based/utils';
|
|
3
|
-
import { TYPE_INDEX_MAP, REFERENCES, REFERENCE, NUMBER, BLOCK_CAPACITY_MAX, BLOCK_CAPACITY_DEFAULT, BLOCK_CAPACITY_MIN, VECTOR, COLVEC, } from './types.js';
|
|
3
|
+
import { TYPE_INDEX_MAP, REFERENCES, REFERENCE, NUMBER, BLOCK_CAPACITY_MAX, BLOCK_CAPACITY_DEFAULT, BLOCK_CAPACITY_MIN, VECTOR, COLVEC, CARDINALITY, } from './types.js';
|
|
4
4
|
import { DEFAULT_MAP } from './defaultMap.js';
|
|
5
5
|
import { makeSeparateTextSort } from './makeSeparateTextSort.js';
|
|
6
6
|
import { makeSeparateSort } from './makeSeparateSort.js';
|
|
7
|
-
import { getPropLen, isSeparate, parseMinMaxStep, reorderProps, schemaVectorBaseTypeToEnum, sortMainProps, } from './utils.js';
|
|
7
|
+
import { getPropLen, isSeparate, parseMinMaxStep, reorderProps, schemaVectorBaseTypeToEnum, sortMainProps, cardinalityModeToEnum, } from './utils.js';
|
|
8
8
|
import { addEdges } from './addEdges.js';
|
|
9
9
|
import { createEmptyDef } from './createEmptyDef.js';
|
|
10
10
|
import { fillEmptyMain, isZeroes } from './fillEmptyMain.js';
|
|
@@ -137,6 +137,11 @@ const createSchemaTypeDef = (typeName, type, parsed, locales, result = createEmp
|
|
|
137
137
|
if (prop.typeIndex === VECTOR || prop.typeIndex === COLVEC) {
|
|
138
138
|
prop.vectorBaseType = schemaVectorBaseTypeToEnum(schemaProp.baseType ?? 'number');
|
|
139
139
|
}
|
|
140
|
+
if (prop.typeIndex === CARDINALITY) {
|
|
141
|
+
prop.cardinalityMode ??= cardinalityModeToEnum((schemaProp.mode ??= 'sparse'));
|
|
142
|
+
const prec = typeName == '_root' ? 14 : 8;
|
|
143
|
+
prop.cardinalityPrecision ??= schemaProp.precision ??= prec;
|
|
144
|
+
}
|
|
140
145
|
if (isPropType('enum', schemaProp)) {
|
|
141
146
|
prop.enum = Array.isArray(schemaProp) ? schemaProp : schemaProp.enum;
|
|
142
147
|
prop.reverseEnum = {};
|
package/dist/def/types.d.ts
CHANGED
package/dist/def/utils.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { PropDef, PropDefEdge, VectorBaseType } from './types.js';
|
|
2
|
-
import { SchemaProp, SchemaVectorBaseType } from '../types.js';
|
|
2
|
+
import { SchemaProp, SchemaVectorBaseType, HLLRegisterRepresentation } from '../types.js';
|
|
3
3
|
export declare function isSeparate(schemaProp: SchemaProp, len: number): boolean;
|
|
4
4
|
export declare const propIsSigned: (prop: PropDef | PropDefEdge) => boolean;
|
|
5
5
|
export declare const propIsNumerical: (prop: PropDef | PropDefEdge) => boolean;
|
|
6
6
|
export declare const schemaVectorBaseTypeToEnum: (vector: SchemaVectorBaseType) => VectorBaseType;
|
|
7
|
+
export declare const cardinalityModeToEnum: (mode: HLLRegisterRepresentation) => number;
|
|
7
8
|
export declare function getPropLen(schemaProp: SchemaProp): number;
|
|
8
9
|
export declare const parseMinMaxStep: (val: any) => string | number;
|
|
9
10
|
export declare const sortMainProps: (a: PropDef | PropDefEdge, b: PropDef | PropDefEdge) => 0 | 1 | -1;
|
package/dist/def/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INT16, INT32, INT8, UINT16, UINT32, UINT8, NUMBER, TIMESTAMP, SIZE_MAP, VECTOR_BASE_TYPE_SIZE_MAP, VectorBaseType, REVERSE_SIZE_MAP, REFERENCES, REFERENCE, ALIAS, ALIASES, COLVEC, } from './types.js';
|
|
2
|
-
import { isPropType } from '../types.js';
|
|
2
|
+
import { isPropType, } from '../types.js';
|
|
3
3
|
import { getPropType } from '../parse/utils.js';
|
|
4
4
|
import { convertToTimestamp } from '@based/utils';
|
|
5
5
|
export function isSeparate(schemaProp, len) {
|
|
@@ -50,6 +50,12 @@ export const schemaVectorBaseTypeToEnum = (vector) => {
|
|
|
50
50
|
return VectorBaseType.Float64;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
export const cardinalityModeToEnum = (mode) => {
|
|
54
|
+
if (mode === 'dense')
|
|
55
|
+
return 1;
|
|
56
|
+
else
|
|
57
|
+
0;
|
|
58
|
+
};
|
|
53
59
|
export function getPropLen(schemaProp) {
|
|
54
60
|
let len = SIZE_MAP[getPropType(schemaProp)];
|
|
55
61
|
if (isPropType('string', schemaProp) ||
|
package/dist/parse/props.js
CHANGED
|
@@ -504,6 +504,18 @@ p.cardinality = propParser(STUB, {
|
|
|
504
504
|
default(val, prop, ctx) {
|
|
505
505
|
return isDefault(val, prop, ctx);
|
|
506
506
|
},
|
|
507
|
+
mode(val, prop, ctx) {
|
|
508
|
+
if (!['dense', 'sparse'].includes(val)) {
|
|
509
|
+
throw Error(INVALID_VALUE);
|
|
510
|
+
}
|
|
511
|
+
p.mode = val;
|
|
512
|
+
},
|
|
513
|
+
precision(val, prop, ctx) {
|
|
514
|
+
if (val < 2 || val > 16) {
|
|
515
|
+
throw Error(INVALID_VALUE);
|
|
516
|
+
}
|
|
517
|
+
p.precision = val;
|
|
518
|
+
},
|
|
507
519
|
}, 0);
|
|
508
520
|
p.json = propParser(STUB, {
|
|
509
521
|
default(val, prop, ctx) {
|
package/dist/types.d.ts
CHANGED
|
@@ -85,11 +85,12 @@ export type SchemaBoolean = Prop<{
|
|
|
85
85
|
type: 'boolean';
|
|
86
86
|
default?: boolean;
|
|
87
87
|
}>;
|
|
88
|
+
export type HLLRegisterRepresentation = 'sparse' | 'dense';
|
|
88
89
|
export type SchemaCardinality = Prop<{
|
|
89
90
|
type: 'cardinality';
|
|
90
91
|
maxBytes?: number;
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
precision?: number;
|
|
93
|
+
mode?: HLLRegisterRepresentation;
|
|
93
94
|
}>;
|
|
94
95
|
type VectorDefaultType = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
95
96
|
export type SchemaVectorBaseType = NumberType | 'float32' | 'float64';
|