@based/schema 5.0.0-alpha.2 → 5.0.0-alpha.4
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/index.d.ts +6 -0
- package/dist/def/index.js +7 -0
- package/dist/def/readFromPacked.d.ts +3 -0
- package/dist/def/readFromPacked.js +126 -0
- package/dist/def/selvaBuffer.d.ts +5 -0
- package/dist/def/selvaBuffer.js +116 -0
- package/dist/def/typeDef.d.ts +7 -0
- package/dist/def/typeDef.js +370 -0
- package/dist/def/types.d.ts +147 -0
- package/dist/def/types.js +121 -0
- package/dist/def/utils.d.ts +4 -0
- package/dist/def/utils.js +24 -0
- package/dist/lang.d.ts +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { REVERSE_SIZE_MAP } from './types.js';
|
|
2
|
+
export const readFromPacked = (packed) => {
|
|
3
|
+
const size = (packed[0] | (packed[1] << 8)) >>> 0;
|
|
4
|
+
const props = [];
|
|
5
|
+
const b = packed.subarray(2, 2 + size);
|
|
6
|
+
let collectMain = false;
|
|
7
|
+
const mainProps = [];
|
|
8
|
+
const typeId = b.subarray(0, 2);
|
|
9
|
+
const typeIdNr = (typeId[0] | (typeId[1] << 8)) >>> 0;
|
|
10
|
+
for (let i = 2; i < b.length; i++) {
|
|
11
|
+
const prop = b[i];
|
|
12
|
+
if (collectMain) {
|
|
13
|
+
if (prop === 0) {
|
|
14
|
+
collectMain = false;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
mainProps.push({
|
|
18
|
+
prop: 0,
|
|
19
|
+
typeIndex: b[i],
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (prop == 0) {
|
|
25
|
+
collectMain = true;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
props.push({ prop, typeIndex: b[i + 1] });
|
|
29
|
+
i++;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const decoder = new TextDecoder();
|
|
34
|
+
const fields = [];
|
|
35
|
+
const f = packed.subarray(2 + size, packed.length);
|
|
36
|
+
for (let i = 0; i < f.length; i++) {
|
|
37
|
+
const size = f[i];
|
|
38
|
+
fields.push(decoder.decode(f.subarray(i + 1, i + 1 + size)));
|
|
39
|
+
i += size;
|
|
40
|
+
}
|
|
41
|
+
for (let i = 0; i < mainProps.length; i++) {
|
|
42
|
+
mainProps[i].path = fields[i + 1];
|
|
43
|
+
}
|
|
44
|
+
for (let i = 0; i < props.length; i++) {
|
|
45
|
+
props[i].path = fields[i + 1 + mainProps.length];
|
|
46
|
+
}
|
|
47
|
+
// Fixed len strings not supported
|
|
48
|
+
// Refs also not supported
|
|
49
|
+
// Text not supported yet
|
|
50
|
+
// Ref not supported yet
|
|
51
|
+
// compression: 1 (0)
|
|
52
|
+
// YET
|
|
53
|
+
const result = {
|
|
54
|
+
cnt: 0,
|
|
55
|
+
checksum: 0,
|
|
56
|
+
total: 0,
|
|
57
|
+
type: fields[0],
|
|
58
|
+
lastId: 0,
|
|
59
|
+
blockCapacity: 0,
|
|
60
|
+
mainLen: mainProps.length,
|
|
61
|
+
buf: b,
|
|
62
|
+
propNames: f,
|
|
63
|
+
packed,
|
|
64
|
+
props: {},
|
|
65
|
+
reverseProps: {}, // in a bit
|
|
66
|
+
id: typeIdNr,
|
|
67
|
+
idUint8: typeId,
|
|
68
|
+
separate: [],
|
|
69
|
+
main: {},
|
|
70
|
+
tree: {},
|
|
71
|
+
// not nessecary...
|
|
72
|
+
hasSeperateSort: false,
|
|
73
|
+
seperateSort: {
|
|
74
|
+
size: 0,
|
|
75
|
+
buffer: new Uint8Array([]),
|
|
76
|
+
bufferTmp: new Uint8Array([]),
|
|
77
|
+
props: [],
|
|
78
|
+
},
|
|
79
|
+
hasSeperateTextSort: false,
|
|
80
|
+
seperateTextSort: {
|
|
81
|
+
size: 0,
|
|
82
|
+
buffer: new Uint8Array([]),
|
|
83
|
+
bufferTmp: new Uint8Array([]),
|
|
84
|
+
props: [],
|
|
85
|
+
},
|
|
86
|
+
// need this...
|
|
87
|
+
locales: {},
|
|
88
|
+
localeSize: 0,
|
|
89
|
+
};
|
|
90
|
+
let s = 0;
|
|
91
|
+
for (const p of mainProps) {
|
|
92
|
+
const len = REVERSE_SIZE_MAP[p.typeIndex];
|
|
93
|
+
result.props[p.path] = {
|
|
94
|
+
prop: p.prop,
|
|
95
|
+
separate: false,
|
|
96
|
+
__isPropDef: true,
|
|
97
|
+
start: s,
|
|
98
|
+
typeIndex: p.typeIndex,
|
|
99
|
+
path: p.path.split('.'),
|
|
100
|
+
len,
|
|
101
|
+
};
|
|
102
|
+
s += len;
|
|
103
|
+
}
|
|
104
|
+
for (const p of props) {
|
|
105
|
+
result.props[p.path] = {
|
|
106
|
+
prop: p.prop,
|
|
107
|
+
separate: true,
|
|
108
|
+
__isPropDef: true,
|
|
109
|
+
start: 0,
|
|
110
|
+
typeIndex: p.typeIndex,
|
|
111
|
+
path: p.path.split('.'),
|
|
112
|
+
len: 0,
|
|
113
|
+
compression: 1,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// make this into a typeDef
|
|
117
|
+
// return {
|
|
118
|
+
// type: fields[0],
|
|
119
|
+
// fields,
|
|
120
|
+
// typeId,
|
|
121
|
+
// props,
|
|
122
|
+
// mainProps,
|
|
123
|
+
// }
|
|
124
|
+
return result;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=readFromPacked.js.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ALIAS, ALIASES, BINARY, BOOLEAN, CREATED, EMPTY_MICRO_BUFFER, ENUM, CARDINALITY, INT16, INT32, INT64, INT8, MICRO_BUFFER, NULL, NUMBER, REFERENCE, REFERENCES, STRING, TEXT, TIMESTAMP, UINT16, UINT32, UINT8, UPDATED, VECTOR, WEAK_REFERENCE, WEAK_REFERENCES, JSON, } from './types.js';
|
|
2
|
+
const selvaTypeMap = [];
|
|
3
|
+
selvaTypeMap[NULL] = 0;
|
|
4
|
+
selvaTypeMap[TIMESTAMP] = 1;
|
|
5
|
+
selvaTypeMap[CREATED] = 1;
|
|
6
|
+
selvaTypeMap[UPDATED] = 1;
|
|
7
|
+
selvaTypeMap[NUMBER] = 4;
|
|
8
|
+
selvaTypeMap[CARDINALITY] = 11;
|
|
9
|
+
selvaTypeMap[INT8] = 20;
|
|
10
|
+
selvaTypeMap[UINT8] = 6;
|
|
11
|
+
selvaTypeMap[INT16] = 21;
|
|
12
|
+
selvaTypeMap[UINT16] = 22;
|
|
13
|
+
selvaTypeMap[INT32] = 23;
|
|
14
|
+
selvaTypeMap[UINT32] = 7;
|
|
15
|
+
selvaTypeMap[INT64] = 24;
|
|
16
|
+
selvaTypeMap[BOOLEAN] = 9;
|
|
17
|
+
selvaTypeMap[ENUM] = 10;
|
|
18
|
+
selvaTypeMap[STRING] = 11;
|
|
19
|
+
selvaTypeMap[TEXT] = 12;
|
|
20
|
+
selvaTypeMap[REFERENCE] = 13;
|
|
21
|
+
selvaTypeMap[REFERENCES] = 14;
|
|
22
|
+
selvaTypeMap[WEAK_REFERENCE] = 15;
|
|
23
|
+
selvaTypeMap[WEAK_REFERENCES] = 16;
|
|
24
|
+
selvaTypeMap[MICRO_BUFFER] = 17;
|
|
25
|
+
selvaTypeMap[ALIAS] = 18;
|
|
26
|
+
selvaTypeMap[ALIASES] = 19;
|
|
27
|
+
selvaTypeMap[BINARY] = 11;
|
|
28
|
+
selvaTypeMap[VECTOR] = 17;
|
|
29
|
+
selvaTypeMap[JSON] = 11;
|
|
30
|
+
const EDGE_FIELD_CONSTRAINT_FLAG_DEPENDENT = 0x01;
|
|
31
|
+
function sepPropCount(props) {
|
|
32
|
+
return props.filter((prop) => prop.separate).length;
|
|
33
|
+
}
|
|
34
|
+
function makeEdgeConstraintFlags(prop) {
|
|
35
|
+
return prop.dependent ? EDGE_FIELD_CONSTRAINT_FLAG_DEPENDENT : 0x00;
|
|
36
|
+
}
|
|
37
|
+
const propDefBuffer = (schema, prop, isEdge) => {
|
|
38
|
+
const type = prop.typeIndex;
|
|
39
|
+
const selvaType = selvaTypeMap[type];
|
|
40
|
+
if (prop.len && (type === MICRO_BUFFER || type === VECTOR)) {
|
|
41
|
+
const buf = Buffer.allocUnsafe(3);
|
|
42
|
+
buf[0] = selvaType;
|
|
43
|
+
buf.writeUint16LE(prop.len, 1);
|
|
44
|
+
return [...buf.values()];
|
|
45
|
+
}
|
|
46
|
+
else if (type === REFERENCE || type === REFERENCES) {
|
|
47
|
+
const buf = Buffer.allocUnsafe(9);
|
|
48
|
+
const dstType = schema[prop.inverseTypeName];
|
|
49
|
+
let eschema = [];
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
buf[0] = selvaType + 2 * !!isEdge; // field type
|
|
52
|
+
buf[1] = makeEdgeConstraintFlags(prop); // flags
|
|
53
|
+
buf.writeUInt16LE(dstType.id, 2); // dst_node_type
|
|
54
|
+
buf.writeUint32LE(0, 5); // schema_len
|
|
55
|
+
if (!isEdge) {
|
|
56
|
+
prop.inverseTypeId = dstType.id;
|
|
57
|
+
prop.inversePropNumber = dstType.props[prop.inversePropName].prop;
|
|
58
|
+
buf[4] = prop.inversePropNumber;
|
|
59
|
+
if (prop.edges) {
|
|
60
|
+
const props = Object.values(prop.edges);
|
|
61
|
+
eschema = props
|
|
62
|
+
.map((prop) => propDefBuffer(schema, prop, true))
|
|
63
|
+
.flat(1);
|
|
64
|
+
eschema.unshift(0, 0, 0, 0, sepPropCount(props), 0);
|
|
65
|
+
buf.writeUint32LE(eschema.length, 5);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return [...buf.values(), ...eschema];
|
|
69
|
+
}
|
|
70
|
+
else if (type === STRING ||
|
|
71
|
+
type === BINARY ||
|
|
72
|
+
type === CARDINALITY ||
|
|
73
|
+
type === JSON) {
|
|
74
|
+
return [selvaType, prop.len < 50 ? prop.len : 0];
|
|
75
|
+
}
|
|
76
|
+
{
|
|
77
|
+
return [selvaType];
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
function makeBlockCapacityBuffer(blockCapacity) {
|
|
81
|
+
const buf = Buffer.allocUnsafe(4);
|
|
82
|
+
buf.writeInt32LE(blockCapacity);
|
|
83
|
+
return buf;
|
|
84
|
+
}
|
|
85
|
+
// todo rewrite
|
|
86
|
+
export function schemaToSelvaBuffer(schema) {
|
|
87
|
+
if (typeof Buffer === 'undefined') {
|
|
88
|
+
// TMP
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
return Object.values(schema).map((t, i) => {
|
|
92
|
+
const props = Object.values(t.props);
|
|
93
|
+
const rest = [];
|
|
94
|
+
let refFields = 0;
|
|
95
|
+
for (const f of props) {
|
|
96
|
+
if (f.separate) {
|
|
97
|
+
if (f.typeIndex === REFERENCE || f.typeIndex === REFERENCES) {
|
|
98
|
+
refFields++;
|
|
99
|
+
}
|
|
100
|
+
rest.push(f);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
rest.sort((a, b) => a.prop - b.prop);
|
|
104
|
+
return Buffer.from([
|
|
105
|
+
...makeBlockCapacityBuffer(t.blockCapacity).values(),
|
|
106
|
+
1 + sepPropCount(props),
|
|
107
|
+
1 + refFields,
|
|
108
|
+
...propDefBuffer(schema, {
|
|
109
|
+
...EMPTY_MICRO_BUFFER,
|
|
110
|
+
len: t.mainLen === 0 ? 1 : t.mainLen,
|
|
111
|
+
}),
|
|
112
|
+
...rest.map((f) => propDefBuffer(schema, f)).flat(1),
|
|
113
|
+
]);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=selvaBuffer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SchemaObject, StrictSchemaType, SchemaLocales } from '../index.js';
|
|
2
|
+
import { SchemaTypeDef, SchemaTypesParsedById, SchemaTypesParsed } from './types.js';
|
|
3
|
+
import { StrictSchema } from '../types.js';
|
|
4
|
+
export declare const DEFAULT_BLOCK_CAPACITY = 100000;
|
|
5
|
+
export declare const updateTypeDefs: (schema: StrictSchema, schemaTypesParsed: SchemaTypesParsed, schemaTypesParsedById: SchemaTypesParsedById) => void;
|
|
6
|
+
export declare const createSchemaTypeDef: (typeName: string, type: StrictSchemaType | SchemaObject, parsed: SchemaTypesParsed, locales: Partial<SchemaLocales>, result?: Partial<SchemaTypeDef>, path?: string[], top?: boolean) => SchemaTypeDef;
|
|
7
|
+
//# sourceMappingURL=typeDef.d.ts.map
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { isPropType, getPropType, } from '../index.js';
|
|
2
|
+
import { setByPath } from '@saulx/utils';
|
|
3
|
+
import { hashObjectIgnoreKeyOrder } from '@saulx/hash';
|
|
4
|
+
import { SIZE_MAP, TYPE_INDEX_MAP, STRING, ALIAS, CARDINALITY, REFERENCES, REFERENCE, TEXT, } from './types.js';
|
|
5
|
+
// TMP
|
|
6
|
+
export const DEFAULT_BLOCK_CAPACITY = 100_000;
|
|
7
|
+
const addEdges = (prop, refProp) => {
|
|
8
|
+
let edgesCnt = 0;
|
|
9
|
+
for (const key in refProp) {
|
|
10
|
+
if (key[0] === '$') {
|
|
11
|
+
if (!prop.edges) {
|
|
12
|
+
prop.edges = {};
|
|
13
|
+
prop.reverseEdges = {};
|
|
14
|
+
prop.edgesTotalLen = 0;
|
|
15
|
+
}
|
|
16
|
+
edgesCnt++;
|
|
17
|
+
const edgeType = getPropType(refProp[key]);
|
|
18
|
+
const edge = {
|
|
19
|
+
__isPropDef: true,
|
|
20
|
+
__isEdge: true,
|
|
21
|
+
prop: edgesCnt,
|
|
22
|
+
name: key,
|
|
23
|
+
typeIndex: TYPE_INDEX_MAP[edgeType],
|
|
24
|
+
len: SIZE_MAP[edgeType],
|
|
25
|
+
separate: true,
|
|
26
|
+
path: [...prop.path, key],
|
|
27
|
+
};
|
|
28
|
+
if (edge.len == 0) {
|
|
29
|
+
prop.edgesTotalLen = 0;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// [field] [size] [data]
|
|
33
|
+
prop.edgesTotalLen += 1 + 2 + edge.len; // field len
|
|
34
|
+
}
|
|
35
|
+
if (edge.typeIndex === 10) {
|
|
36
|
+
edge.enum = Array.isArray(refProp[key])
|
|
37
|
+
? refProp[key]
|
|
38
|
+
: refProp[key].enum;
|
|
39
|
+
edge.reverseEnum = {};
|
|
40
|
+
for (let i = 0; i < edge.enum.length; i++) {
|
|
41
|
+
edge.reverseEnum[edge.enum[i]] = i;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (edge.typeIndex === 14) {
|
|
45
|
+
edge.inverseTypeName = refProp[key].items.ref;
|
|
46
|
+
}
|
|
47
|
+
else if (edge.typeIndex === 13) {
|
|
48
|
+
edge.inverseTypeName = refProp[key].ref;
|
|
49
|
+
}
|
|
50
|
+
prop.edges[key] = edge;
|
|
51
|
+
prop.reverseEdges[edge.prop] = edge;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export const updateTypeDefs = (schema, schemaTypesParsed, schemaTypesParsedById) => {
|
|
56
|
+
for (const field in schemaTypesParsed) {
|
|
57
|
+
if (field in schema.types) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const id = schemaTypesParsed[field].id;
|
|
61
|
+
delete schemaTypesParsed[field];
|
|
62
|
+
delete schemaTypesParsedById[id];
|
|
63
|
+
}
|
|
64
|
+
for (const field in schema.types) {
|
|
65
|
+
const type = schema.types[field];
|
|
66
|
+
if (schemaTypesParsed[field] &&
|
|
67
|
+
schemaTypesParsed[field].checksum === hashObjectIgnoreKeyOrder(type) // bit weird..
|
|
68
|
+
) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (!type.id) {
|
|
73
|
+
throw new Error('NEED ID ON TYPE');
|
|
74
|
+
}
|
|
75
|
+
const def = createSchemaTypeDef(field, type, schemaTypesParsed, schema.locales ?? {
|
|
76
|
+
en: {},
|
|
77
|
+
});
|
|
78
|
+
def.blockCapacity =
|
|
79
|
+
field === '_root' ? 2147483647 : DEFAULT_BLOCK_CAPACITY; // TODO this should come from somewhere else
|
|
80
|
+
schemaTypesParsed[field] = def;
|
|
81
|
+
schemaTypesParsedById[type.id] = def;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
|
|
86
|
+
cnt: 0,
|
|
87
|
+
checksum: hashObjectIgnoreKeyOrder(type),
|
|
88
|
+
type: typeName,
|
|
89
|
+
props: {},
|
|
90
|
+
reverseProps: {},
|
|
91
|
+
idUint8: new Uint8Array([0, 0]),
|
|
92
|
+
id: 0,
|
|
93
|
+
mainLen: 0,
|
|
94
|
+
separate: [],
|
|
95
|
+
tree: {},
|
|
96
|
+
total: 0,
|
|
97
|
+
lastId: 0,
|
|
98
|
+
main: {},
|
|
99
|
+
hasSeperateSort: false,
|
|
100
|
+
seperateSort: {
|
|
101
|
+
size: 0,
|
|
102
|
+
props: [],
|
|
103
|
+
buffer: new Uint8Array([]),
|
|
104
|
+
bufferTmp: new Uint8Array([]),
|
|
105
|
+
},
|
|
106
|
+
hasSeperateTextSort: false,
|
|
107
|
+
seperateTextSort: {
|
|
108
|
+
size: 0, // prop len
|
|
109
|
+
props: [],
|
|
110
|
+
buffer: new Uint8Array([]),
|
|
111
|
+
bufferTmp: new Uint8Array([]),
|
|
112
|
+
},
|
|
113
|
+
}, path = [], top = true) => {
|
|
114
|
+
if (result.id == 0 && top) {
|
|
115
|
+
if ('id' in type) {
|
|
116
|
+
result.id = type.id;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error(`Invalid schema type id ${result.type}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
result.locales = locales;
|
|
123
|
+
result.localeSize = Object.keys(locales).length;
|
|
124
|
+
result.idUint8[0] = result.id & 255;
|
|
125
|
+
result.idUint8[1] = result.id >> 8;
|
|
126
|
+
const encoder = new TextEncoder();
|
|
127
|
+
const target = type.props;
|
|
128
|
+
let separateSortProps = 0;
|
|
129
|
+
let separateSortText = 0;
|
|
130
|
+
for (const key in target) {
|
|
131
|
+
const schemaProp = target[key];
|
|
132
|
+
const propPath = [...path, key];
|
|
133
|
+
const propType = getPropType(schemaProp);
|
|
134
|
+
if (propType === 'object') {
|
|
135
|
+
createSchemaTypeDef(typeName, schemaProp, parsed, locales, result, propPath, false);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
let len = SIZE_MAP[propType];
|
|
139
|
+
if (isPropType('string', schemaProp) ||
|
|
140
|
+
isPropType('alias', schemaProp) ||
|
|
141
|
+
isPropType('cardinality', schemaProp)) {
|
|
142
|
+
if (typeof schemaProp === 'object') {
|
|
143
|
+
if (schemaProp.maxBytes < 61) {
|
|
144
|
+
len = schemaProp.maxBytes + 1;
|
|
145
|
+
}
|
|
146
|
+
else if ('max' in schemaProp && schemaProp.max < 31) {
|
|
147
|
+
len = schemaProp.max * 2 + 1;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
separateSortProps++;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
separateSortProps++;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else if (isPropType('vector', schemaProp)) {
|
|
158
|
+
len = 4 * schemaProp.size;
|
|
159
|
+
}
|
|
160
|
+
else if (isPropType('text', schemaProp)) {
|
|
161
|
+
separateSortText++;
|
|
162
|
+
}
|
|
163
|
+
const isseparate = len === 0 || isPropType('vector', schemaProp);
|
|
164
|
+
if (isseparate) {
|
|
165
|
+
result.cnt++;
|
|
166
|
+
}
|
|
167
|
+
const prop = {
|
|
168
|
+
typeIndex: TYPE_INDEX_MAP[propType],
|
|
169
|
+
__isPropDef: true,
|
|
170
|
+
separate: isseparate,
|
|
171
|
+
path: propPath,
|
|
172
|
+
start: 0,
|
|
173
|
+
len,
|
|
174
|
+
prop: isseparate ? result.cnt : 0,
|
|
175
|
+
};
|
|
176
|
+
if (isPropType('enum', schemaProp)) {
|
|
177
|
+
prop.enum = Array.isArray(schemaProp) ? schemaProp : schemaProp.enum;
|
|
178
|
+
prop.reverseEnum = {};
|
|
179
|
+
for (let i = 0; i < prop.enum.length; i++) {
|
|
180
|
+
prop.reverseEnum[prop.enum[i]] = i;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (isPropType('references', schemaProp)) {
|
|
184
|
+
prop.inversePropName = schemaProp.items.prop;
|
|
185
|
+
prop.inverseTypeName = schemaProp.items.ref;
|
|
186
|
+
prop.dependent = schemaProp.items.dependent;
|
|
187
|
+
addEdges(prop, schemaProp.items);
|
|
188
|
+
}
|
|
189
|
+
else if (isPropType('reference', schemaProp)) {
|
|
190
|
+
prop.inversePropName = schemaProp.prop;
|
|
191
|
+
prop.inverseTypeName = schemaProp.ref;
|
|
192
|
+
prop.dependent = schemaProp.dependent;
|
|
193
|
+
addEdges(prop, schemaProp);
|
|
194
|
+
}
|
|
195
|
+
else if (typeof schemaProp === 'object') {
|
|
196
|
+
if (isPropType('string', schemaProp) ||
|
|
197
|
+
isPropType('text', schemaProp)) {
|
|
198
|
+
prop.compression =
|
|
199
|
+
'compression' in schemaProp && schemaProp.compression === 'none'
|
|
200
|
+
? 0
|
|
201
|
+
: 1;
|
|
202
|
+
}
|
|
203
|
+
else if (isPropType('timestamp', schemaProp) && 'on' in schemaProp) {
|
|
204
|
+
if (schemaProp.on[0] === 'c') {
|
|
205
|
+
result.createTs ??= [];
|
|
206
|
+
result.createTs.push(prop);
|
|
207
|
+
}
|
|
208
|
+
else if (schemaProp.on[0] === 'u') {
|
|
209
|
+
result.createTs ??= [];
|
|
210
|
+
result.createTs.push(prop);
|
|
211
|
+
result.updateTs ??= [];
|
|
212
|
+
result.updateTs.push(prop);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
result.props[propPath.join('.')] = prop;
|
|
217
|
+
if (isseparate) {
|
|
218
|
+
result.separate.push(prop);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (top) {
|
|
223
|
+
const vals = Object.values(result.props);
|
|
224
|
+
vals.sort((a, b) => {
|
|
225
|
+
if (b.separate &&
|
|
226
|
+
(a.typeIndex === REFERENCES || a.typeIndex === REFERENCE)) {
|
|
227
|
+
return -1;
|
|
228
|
+
}
|
|
229
|
+
return a.prop - b.prop;
|
|
230
|
+
});
|
|
231
|
+
let lastProp = 0;
|
|
232
|
+
for (const p of vals) {
|
|
233
|
+
if (p.separate) {
|
|
234
|
+
lastProp++;
|
|
235
|
+
p.prop = lastProp;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
let len = 2;
|
|
239
|
+
for (const f of vals) {
|
|
240
|
+
if (f.separate) {
|
|
241
|
+
len += 2;
|
|
242
|
+
setByPath(result.tree, f.path, f);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
if (!result.mainLen) {
|
|
246
|
+
len += 2;
|
|
247
|
+
}
|
|
248
|
+
len += 1;
|
|
249
|
+
f.start = result.mainLen;
|
|
250
|
+
result.mainLen += f.len;
|
|
251
|
+
setByPath(result.tree, f.path, f);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const mainFields = [];
|
|
255
|
+
const restFields = [];
|
|
256
|
+
for (const f of vals) {
|
|
257
|
+
if (f.separate) {
|
|
258
|
+
restFields.push(f);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
mainFields.push(f);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// make packed version
|
|
265
|
+
result.buf = new Uint8Array(len);
|
|
266
|
+
result.buf[0] = result.idUint8[0];
|
|
267
|
+
result.buf[1] = result.idUint8[1];
|
|
268
|
+
const fieldNames = [];
|
|
269
|
+
const tNameBuf = encoder.encode(typeName);
|
|
270
|
+
fieldNames.push(tNameBuf);
|
|
271
|
+
let fieldNameLen = tNameBuf.byteLength + 1;
|
|
272
|
+
let i = 2;
|
|
273
|
+
if (result.mainLen) {
|
|
274
|
+
result.buf[i] = 0;
|
|
275
|
+
for (const f of vals) {
|
|
276
|
+
if (!f.separate) {
|
|
277
|
+
i++;
|
|
278
|
+
result.buf[i] = f.typeIndex;
|
|
279
|
+
const name = encoder.encode(f.path.join('.'));
|
|
280
|
+
fieldNames.push(name);
|
|
281
|
+
fieldNameLen += name.byteLength + 1;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
i++;
|
|
285
|
+
result.buf[i] = 0;
|
|
286
|
+
}
|
|
287
|
+
for (const f of vals) {
|
|
288
|
+
if (f.separate) {
|
|
289
|
+
i++;
|
|
290
|
+
result.buf[i] = f.prop;
|
|
291
|
+
i++;
|
|
292
|
+
result.buf[i] = f.typeIndex;
|
|
293
|
+
const name = encoder.encode(f.path.join('.'));
|
|
294
|
+
fieldNames.push(name);
|
|
295
|
+
fieldNameLen += name.byteLength + 1;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
result.propNames = new Uint8Array(fieldNameLen);
|
|
299
|
+
let lastWritten = 0;
|
|
300
|
+
for (const f of fieldNames) {
|
|
301
|
+
result.propNames[lastWritten] = f.byteLength;
|
|
302
|
+
result.propNames.set(f, lastWritten + 1);
|
|
303
|
+
lastWritten += f.byteLength + 1;
|
|
304
|
+
}
|
|
305
|
+
let bufLen = result.buf.length;
|
|
306
|
+
result.packed = new Uint8Array(2 + bufLen + result.propNames.length);
|
|
307
|
+
result.packed[0] = bufLen;
|
|
308
|
+
result.packed[1] = bufLen >>>= 8;
|
|
309
|
+
result.packed.set(result.buf, 2);
|
|
310
|
+
result.packed.set(result.propNames, result.buf.length + 2);
|
|
311
|
+
// done making packed bversion
|
|
312
|
+
if (separateSortText > 0) {
|
|
313
|
+
result.hasSeperateTextSort = true;
|
|
314
|
+
let max = 0;
|
|
315
|
+
for (const f of result.separate) {
|
|
316
|
+
if (f.typeIndex === TEXT) {
|
|
317
|
+
if (f.prop > max) {
|
|
318
|
+
max = f.prop;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
result.seperateTextSort.buffer = new Uint8Array(max * result.localeSize + 1);
|
|
323
|
+
for (const f of result.separate) {
|
|
324
|
+
if (f.typeIndex === TEXT) {
|
|
325
|
+
result.seperateTextSort.buffer[f.prop] = 1;
|
|
326
|
+
result.seperateTextSort.props.push(f);
|
|
327
|
+
result.seperateTextSort.size += result.localeSize;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
result.seperateTextSort.bufferTmp = new Uint8Array(max * result.localeSize + 1);
|
|
331
|
+
result.seperateTextSort.buffer.set(result.seperateTextSort.bufferTmp);
|
|
332
|
+
}
|
|
333
|
+
if (separateSortProps > 0) {
|
|
334
|
+
result.hasSeperateSort = true;
|
|
335
|
+
let max = 0;
|
|
336
|
+
for (const f of result.separate) {
|
|
337
|
+
if (f.typeIndex === STRING ||
|
|
338
|
+
f.typeIndex === ALIAS ||
|
|
339
|
+
f.typeIndex === CARDINALITY) {
|
|
340
|
+
if (f.prop > max) {
|
|
341
|
+
max = f.prop;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
result.seperateSort.buffer = new Uint8Array(max + 1);
|
|
346
|
+
for (const f of result.separate) {
|
|
347
|
+
if (f.typeIndex === STRING ||
|
|
348
|
+
f.typeIndex === ALIAS ||
|
|
349
|
+
f.typeIndex === CARDINALITY) {
|
|
350
|
+
result.seperateSort.buffer[f.prop] = 1;
|
|
351
|
+
result.seperateSort.props.push(f);
|
|
352
|
+
result.seperateSort.size++;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
result.seperateSort.bufferTmp = new Uint8Array(max + 1);
|
|
356
|
+
result.seperateSort.buffer.set(result.seperateSort.bufferTmp);
|
|
357
|
+
}
|
|
358
|
+
for (const p in result.props) {
|
|
359
|
+
const x = result.props[p];
|
|
360
|
+
if (!x.separate) {
|
|
361
|
+
result.main[x.start] = x;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
result.reverseProps[x.prop] = x;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return result;
|
|
369
|
+
};
|
|
370
|
+
//# sourceMappingURL=typeDef.js.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { SchemaLocales } from '../index.js';
|
|
2
|
+
export declare const NULL = 0;
|
|
3
|
+
export declare const TIMESTAMP = 1;
|
|
4
|
+
export declare const CREATED = 2;
|
|
5
|
+
export declare const UPDATED = 3;
|
|
6
|
+
export declare const NUMBER = 4;
|
|
7
|
+
export declare const CARDINALITY = 5;
|
|
8
|
+
export declare const INT8 = 20;
|
|
9
|
+
export declare const UINT8 = 6;
|
|
10
|
+
export declare const INT16 = 21;
|
|
11
|
+
export declare const UINT16 = 22;
|
|
12
|
+
export declare const INT32 = 23;
|
|
13
|
+
export declare const UINT32 = 7;
|
|
14
|
+
export declare const INT64 = 24;
|
|
15
|
+
export declare const BOOLEAN = 9;
|
|
16
|
+
export declare const ENUM = 10;
|
|
17
|
+
export declare const STRING = 11;
|
|
18
|
+
export declare const TEXT = 12;
|
|
19
|
+
export declare const REFERENCE = 13;
|
|
20
|
+
export declare const REFERENCES = 14;
|
|
21
|
+
export declare const WEAK_REFERENCE = 15;
|
|
22
|
+
export declare const WEAK_REFERENCES = 16;
|
|
23
|
+
export declare const MICRO_BUFFER = 17;
|
|
24
|
+
export declare const ALIAS = 18;
|
|
25
|
+
export declare const ALIASES = 19;
|
|
26
|
+
export declare const BINARY = 25;
|
|
27
|
+
export declare const ID = 26;
|
|
28
|
+
export declare const VECTOR = 27;
|
|
29
|
+
export declare const JSON = 28;
|
|
30
|
+
export declare const TYPE_INDEX_MAP: {
|
|
31
|
+
alias: number;
|
|
32
|
+
aliases: number;
|
|
33
|
+
microbuffer: number;
|
|
34
|
+
references: number;
|
|
35
|
+
reference: number;
|
|
36
|
+
timestamp: number;
|
|
37
|
+
boolean: number;
|
|
38
|
+
created: number;
|
|
39
|
+
updated: number;
|
|
40
|
+
number: number;
|
|
41
|
+
string: number;
|
|
42
|
+
text: number;
|
|
43
|
+
uint16: number;
|
|
44
|
+
uint32: number;
|
|
45
|
+
int16: number;
|
|
46
|
+
int32: number;
|
|
47
|
+
uint8: number;
|
|
48
|
+
enum: number;
|
|
49
|
+
int8: number;
|
|
50
|
+
id: number;
|
|
51
|
+
binary: number;
|
|
52
|
+
vector: number;
|
|
53
|
+
cardinality: number;
|
|
54
|
+
json: number;
|
|
55
|
+
};
|
|
56
|
+
export type InternalSchemaProp = keyof typeof TYPE_INDEX_MAP;
|
|
57
|
+
export type TypeIndex = (typeof TYPE_INDEX_MAP)[InternalSchemaProp];
|
|
58
|
+
export type PropDef = {
|
|
59
|
+
__isPropDef: true;
|
|
60
|
+
prop: number;
|
|
61
|
+
typeIndex: TypeIndex;
|
|
62
|
+
separate: boolean;
|
|
63
|
+
path: string[];
|
|
64
|
+
start: number;
|
|
65
|
+
len: number;
|
|
66
|
+
inverseTypeName?: string;
|
|
67
|
+
inversePropName?: string;
|
|
68
|
+
compression?: 0 | 1;
|
|
69
|
+
inverseTypeId?: number;
|
|
70
|
+
inversePropNumber?: number;
|
|
71
|
+
enum?: any[];
|
|
72
|
+
reverseEnum?: {
|
|
73
|
+
[key: string]: number;
|
|
74
|
+
};
|
|
75
|
+
edgesTotalLen?: number;
|
|
76
|
+
edges?: {
|
|
77
|
+
[key: string]: PropDefEdge;
|
|
78
|
+
};
|
|
79
|
+
reverseEdges?: {
|
|
80
|
+
[prop: string]: PropDefEdge;
|
|
81
|
+
};
|
|
82
|
+
__isEdge?: boolean;
|
|
83
|
+
dependent?: boolean;
|
|
84
|
+
};
|
|
85
|
+
export type PropDefEdge = Partial<PropDef> & {
|
|
86
|
+
__isPropDef: true;
|
|
87
|
+
typeIndex: TypeIndex;
|
|
88
|
+
len: number;
|
|
89
|
+
prop: number;
|
|
90
|
+
name: string;
|
|
91
|
+
edgesTotalLen?: number;
|
|
92
|
+
__isEdge: true;
|
|
93
|
+
};
|
|
94
|
+
export type SchemaPropTree = {
|
|
95
|
+
[key: string]: SchemaPropTree | PropDef;
|
|
96
|
+
};
|
|
97
|
+
export type SchemaSortUndefinedHandler = {
|
|
98
|
+
size: number;
|
|
99
|
+
buffer: Uint8Array;
|
|
100
|
+
bufferTmp: Uint8Array;
|
|
101
|
+
props: PropDef[];
|
|
102
|
+
};
|
|
103
|
+
export type SchemaTypeDef = {
|
|
104
|
+
cnt: number;
|
|
105
|
+
checksum: number;
|
|
106
|
+
total: number;
|
|
107
|
+
type: string;
|
|
108
|
+
lastId: number;
|
|
109
|
+
blockCapacity: number;
|
|
110
|
+
mainLen: number;
|
|
111
|
+
buf: Uint8Array;
|
|
112
|
+
propNames: Uint8Array;
|
|
113
|
+
packed: Uint8Array;
|
|
114
|
+
props: {
|
|
115
|
+
[path: string]: PropDef;
|
|
116
|
+
};
|
|
117
|
+
reverseProps: {
|
|
118
|
+
[field: string]: PropDef;
|
|
119
|
+
};
|
|
120
|
+
id: number;
|
|
121
|
+
idUint8: Uint8Array;
|
|
122
|
+
separate: PropDef[];
|
|
123
|
+
main: {
|
|
124
|
+
[start: string]: PropDef;
|
|
125
|
+
};
|
|
126
|
+
tree: SchemaPropTree;
|
|
127
|
+
hasSeperateSort: boolean;
|
|
128
|
+
seperateSort: SchemaSortUndefinedHandler;
|
|
129
|
+
hasSeperateTextSort: boolean;
|
|
130
|
+
seperateTextSort: SchemaSortUndefinedHandler;
|
|
131
|
+
createTs?: PropDef[];
|
|
132
|
+
updateTs?: PropDef[];
|
|
133
|
+
locales: Partial<SchemaLocales>;
|
|
134
|
+
localeSize: number;
|
|
135
|
+
};
|
|
136
|
+
export declare const SIZE_MAP: Record<InternalSchemaProp, number>;
|
|
137
|
+
export declare let REVERSE_SIZE_MAP: Record<TypeIndex, number>;
|
|
138
|
+
export declare const REVERSE_TYPE_INDEX_MAP: Record<TypeIndex, InternalSchemaProp>;
|
|
139
|
+
export declare const ID_FIELD_DEF: PropDef;
|
|
140
|
+
export declare const EMPTY_MICRO_BUFFER: PropDef;
|
|
141
|
+
export declare const getPropTypeName: (propType: TypeIndex) => InternalSchemaProp;
|
|
142
|
+
export declare const isPropDef: (prop: any) => prop is PropDef;
|
|
143
|
+
export type SchemaTypesParsed = {
|
|
144
|
+
[key: string]: SchemaTypeDef;
|
|
145
|
+
};
|
|
146
|
+
export type SchemaTypesParsedById = Record<number, SchemaTypeDef>;
|
|
147
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// WARN: The following type codes are used in js and zig but selva has its own typing.
|
|
2
|
+
export const NULL = 0;
|
|
3
|
+
export const TIMESTAMP = 1;
|
|
4
|
+
export const CREATED = 2;
|
|
5
|
+
export const UPDATED = 3;
|
|
6
|
+
export const NUMBER = 4;
|
|
7
|
+
export const CARDINALITY = 5;
|
|
8
|
+
export const INT8 = 20;
|
|
9
|
+
export const UINT8 = 6;
|
|
10
|
+
export const INT16 = 21;
|
|
11
|
+
export const UINT16 = 22;
|
|
12
|
+
export const INT32 = 23;
|
|
13
|
+
export const UINT32 = 7;
|
|
14
|
+
export const INT64 = 24;
|
|
15
|
+
export const BOOLEAN = 9;
|
|
16
|
+
export const ENUM = 10;
|
|
17
|
+
export const STRING = 11;
|
|
18
|
+
export const TEXT = 12;
|
|
19
|
+
export const REFERENCE = 13;
|
|
20
|
+
export const REFERENCES = 14;
|
|
21
|
+
export const WEAK_REFERENCE = 15;
|
|
22
|
+
export const WEAK_REFERENCES = 16;
|
|
23
|
+
export const MICRO_BUFFER = 17;
|
|
24
|
+
export const ALIAS = 18;
|
|
25
|
+
export const ALIASES = 19;
|
|
26
|
+
export const BINARY = 25;
|
|
27
|
+
export const ID = 26;
|
|
28
|
+
export const VECTOR = 27;
|
|
29
|
+
export const JSON = 28;
|
|
30
|
+
export const TYPE_INDEX_MAP = {
|
|
31
|
+
alias: ALIAS,
|
|
32
|
+
aliases: ALIASES,
|
|
33
|
+
microbuffer: MICRO_BUFFER,
|
|
34
|
+
references: REFERENCES,
|
|
35
|
+
reference: REFERENCE,
|
|
36
|
+
timestamp: TIMESTAMP,
|
|
37
|
+
boolean: BOOLEAN,
|
|
38
|
+
created: CREATED,
|
|
39
|
+
updated: UPDATED,
|
|
40
|
+
number: NUMBER,
|
|
41
|
+
string: STRING,
|
|
42
|
+
text: TEXT,
|
|
43
|
+
uint16: UINT16,
|
|
44
|
+
uint32: UINT32,
|
|
45
|
+
int16: INT16,
|
|
46
|
+
int32: INT32,
|
|
47
|
+
uint8: UINT8,
|
|
48
|
+
enum: ENUM,
|
|
49
|
+
int8: INT8,
|
|
50
|
+
id: NULL,
|
|
51
|
+
binary: BINARY,
|
|
52
|
+
vector: VECTOR,
|
|
53
|
+
cardinality: CARDINALITY,
|
|
54
|
+
json: JSON,
|
|
55
|
+
};
|
|
56
|
+
export const SIZE_MAP = {
|
|
57
|
+
timestamp: 8, // 64bit
|
|
58
|
+
created: 8,
|
|
59
|
+
updated: 8,
|
|
60
|
+
// double-precision 64-bit binary format IEEE 754 value
|
|
61
|
+
number: 8, // 64bit
|
|
62
|
+
int8: 1,
|
|
63
|
+
uint8: 1,
|
|
64
|
+
int16: 2,
|
|
65
|
+
uint16: 2,
|
|
66
|
+
int32: 4,
|
|
67
|
+
uint32: 4,
|
|
68
|
+
boolean: 1,
|
|
69
|
+
reference: 0, // separate
|
|
70
|
+
enum: 1, // enum
|
|
71
|
+
string: 0, // separate
|
|
72
|
+
text: 0, // separate
|
|
73
|
+
cardinality: 0, // separate
|
|
74
|
+
references: 0, // separate
|
|
75
|
+
microbuffer: 0, // separate
|
|
76
|
+
alias: 0,
|
|
77
|
+
aliases: 0,
|
|
78
|
+
id: 4,
|
|
79
|
+
binary: 0,
|
|
80
|
+
vector: 0, // separate
|
|
81
|
+
json: 0,
|
|
82
|
+
};
|
|
83
|
+
const reverseMap = {};
|
|
84
|
+
for (const k in TYPE_INDEX_MAP) {
|
|
85
|
+
reverseMap[TYPE_INDEX_MAP[k]] = k;
|
|
86
|
+
}
|
|
87
|
+
export let REVERSE_SIZE_MAP;
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
REVERSE_SIZE_MAP = {};
|
|
90
|
+
for (const k in SIZE_MAP) {
|
|
91
|
+
REVERSE_SIZE_MAP[TYPE_INDEX_MAP[k]] = SIZE_MAP[k];
|
|
92
|
+
}
|
|
93
|
+
export const REVERSE_TYPE_INDEX_MAP = reverseMap;
|
|
94
|
+
export const ID_FIELD_DEF = {
|
|
95
|
+
typeIndex: TYPE_INDEX_MAP['id'],
|
|
96
|
+
separate: true,
|
|
97
|
+
path: ['id'],
|
|
98
|
+
start: 0,
|
|
99
|
+
prop: 255,
|
|
100
|
+
len: 4,
|
|
101
|
+
__isPropDef: true,
|
|
102
|
+
};
|
|
103
|
+
export const EMPTY_MICRO_BUFFER = {
|
|
104
|
+
typeIndex: TYPE_INDEX_MAP['microbuffer'],
|
|
105
|
+
separate: true,
|
|
106
|
+
path: [''],
|
|
107
|
+
start: 0,
|
|
108
|
+
prop: 0,
|
|
109
|
+
len: 1,
|
|
110
|
+
__isPropDef: true,
|
|
111
|
+
};
|
|
112
|
+
export const getPropTypeName = (propType) => {
|
|
113
|
+
return REVERSE_TYPE_INDEX_MAP[propType];
|
|
114
|
+
};
|
|
115
|
+
export const isPropDef = (prop) => {
|
|
116
|
+
if ('__isPropDef' in prop && prop.__isPropDef === true) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { INT16, INT32, INT64, INT8, UINT16, UINT32, UINT8, NUMBER, TIMESTAMP, } from './types.js';
|
|
2
|
+
export const propIsSigned = (prop) => {
|
|
3
|
+
const t = prop.typeIndex;
|
|
4
|
+
if (t === INT16 || t === INT32 || t === INT64 || t === INT8) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
};
|
|
9
|
+
export const propIsNumerical = (prop) => {
|
|
10
|
+
const t = prop.typeIndex;
|
|
11
|
+
if (t === INT16 ||
|
|
12
|
+
t === INT32 ||
|
|
13
|
+
t === INT64 ||
|
|
14
|
+
t === INT8 ||
|
|
15
|
+
t === UINT8 ||
|
|
16
|
+
t === UINT16 ||
|
|
17
|
+
t === UINT32 ||
|
|
18
|
+
t === NUMBER ||
|
|
19
|
+
t === TIMESTAMP) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=utils.js.map
|
package/dist/lang.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ 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 | 1 | 2 | 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
149
|
export declare const inverseLangMap: Map<any, any>;
|
|
150
150
|
export type LangName = keyof typeof langCodes;
|
|
151
151
|
export type LangCode = (typeof langCodes)[LangName];
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/schema",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.4",
|
|
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
|
+
"exports": {
|
|
12
|
+
"./def": "./dist/def/index.js",
|
|
13
|
+
".": "./dist/index.js"
|
|
14
|
+
},
|
|
12
15
|
"scripts": {
|
|
13
16
|
"build": "tsc",
|
|
14
17
|
"watch": "tsc --watch",
|
|
15
|
-
"test": "tsc && tsc
|
|
16
|
-
"test1": "tsc && tsc $npm_config --noEmit && tsx --test $npm_config"
|
|
18
|
+
"test": "tsc && tsc $npm_config --noEmit && tsx --test $npm_config"
|
|
17
19
|
},
|
|
18
20
|
"prettier": "@saulx/prettier-config",
|
|
19
21
|
"sideEffects": false,
|
|
@@ -26,6 +28,7 @@
|
|
|
26
28
|
"typescript": "^5.6.3"
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
31
|
+
"@saulx/utils": "^5.0.0",
|
|
29
32
|
"picocolors": "^1.1.0"
|
|
30
33
|
}
|
|
31
34
|
}
|