@based/db 0.0.18 → 0.0.20
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/lib/darwin_aarch64/include/selva/db.h +89 -6
- package/dist/lib/darwin_aarch64/include/selva/fields.h +28 -39
- package/dist/lib/darwin_aarch64/include/selva/types.h +0 -10
- package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +89 -6
- package/dist/lib/linux_aarch64/include/selva/fields.h +28 -39
- package/dist/lib/linux_aarch64/include/selva/types.h +0 -10
- package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +89 -6
- package/dist/lib/linux_x86_64/include/selva/fields.h +28 -39
- package/dist/lib/linux_x86_64/include/selva/types.h +0 -10
- package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/index.js +8 -3
- package/dist/src/client/modify/ModifyRes.d.ts +1 -1
- package/dist/src/client/modify/ModifyRes.js +1 -1
- package/dist/src/client/modify/alias.d.ts +1 -1
- package/dist/src/client/modify/binary.d.ts +1 -1
- package/dist/src/client/modify/cardinality.d.ts +1 -1
- package/dist/src/client/modify/cardinality.js +1 -1
- package/dist/src/client/modify/create.js +2 -2
- package/dist/src/client/modify/delete.js +1 -1
- package/dist/src/client/modify/expire.js +1 -1
- package/dist/src/client/modify/fixed.d.ts +1 -1
- package/dist/src/client/modify/fixed.js +1 -1
- package/dist/src/client/modify/json.d.ts +1 -1
- package/dist/src/client/modify/modify.d.ts +1 -1
- package/dist/src/client/modify/modify.js +1 -1
- package/dist/src/client/modify/references/edge.d.ts +1 -1
- package/dist/src/client/modify/references/edge.js +1 -1
- package/dist/src/client/modify/references/reference.d.ts +1 -1
- package/dist/src/client/modify/references/references.d.ts +1 -1
- package/dist/src/client/modify/references/references.js +1 -1
- package/dist/src/client/modify/setCursor.d.ts +1 -1
- package/dist/src/client/modify/string.d.ts +1 -1
- package/dist/src/client/modify/text.d.ts +1 -1
- package/dist/src/client/modify/text.js +6 -0
- package/dist/src/client/modify/update.js +1 -1
- package/dist/src/client/modify/upsert.js +1 -1
- package/dist/src/client/modify/vector.d.ts +1 -1
- package/dist/src/client/operations.d.ts +2 -1
- package/dist/src/client/operations.js +1 -0
- package/dist/src/client/query/BasedDbQuery.js +1 -1
- package/dist/src/client/query/debug.js +1 -1
- package/dist/src/client/query/display.d.ts +1 -1
- package/dist/src/client/query/display.js +1 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.d.ts +1 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +1 -2
- package/dist/src/client/query/filter/createReferenceFilter.d.ts +1 -1
- package/dist/src/client/query/filter/createVariableFilterBuffer.d.ts +1 -1
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +1 -1
- package/dist/src/client/query/filter/filter.d.ts +1 -1
- package/dist/src/client/query/filter/filter.js +1 -1
- package/dist/src/client/query/filter/parseFilterValue.d.ts +1 -1
- package/dist/src/client/query/filter/parseFilterValue.js +1 -1
- package/dist/src/client/query/filter/primitiveFilter.d.ts +1 -1
- package/dist/src/client/query/filter/primitiveFilter.js +4 -1
- package/dist/src/client/query/include/props.d.ts +1 -1
- package/dist/src/client/query/include/props.js +1 -1
- package/dist/src/client/query/include/utils.d.ts +1 -1
- package/dist/src/client/query/include/utils.js +1 -1
- package/dist/src/client/query/include/walk.js +1 -1
- package/dist/src/client/query/read/read.js +1 -1
- package/dist/src/client/query/search/index.js +1 -1
- package/dist/src/client/query/subscription/markers.d.ts +1 -1
- package/dist/src/client/query/types.d.ts +1 -1
- package/dist/src/client/query/validation.d.ts +1 -1
- package/dist/src/client/query/validation.js +9 -8
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/server/index.d.ts +3 -5
- package/dist/src/server/index.js +11 -5
- package/dist/src/server/migrate/worker.js +1 -1
- package/dist/src/server/start.d.ts +0 -1
- package/dist/src/server/start.js +1 -1
- package/dist/src/server/tree.d.ts +1 -1
- package/package.json +2 -2
- package/dist/lib/darwin_aarch64/libxxhash.0.8.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.0.dylib +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so.0.8.2 +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so.0.8.2 +0 -0
- package/dist/src/server/schema/schema.d.ts +0 -3
- package/dist/src/server/schema/schema.js +0 -4
- package/dist/src/server/schema/selvaBuffer.d.ts +0 -4
- package/dist/src/server/schema/selvaBuffer.js +0 -112
- package/dist/src/server/schema/typeDef.d.ts +0 -6
- package/dist/src/server/schema/typeDef.js +0 -337
- package/dist/src/server/schema/types.d.ts +0 -140
- package/dist/src/server/schema/types.js +0 -121
- package/dist/src/server/schema/utils.d.ts +0 -7
- package/dist/src/server/schema/utils.js +0 -34
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { isPropType, getPropType, } from '@based/schema';
|
|
2
|
-
import { setByPath } from '@saulx/utils';
|
|
3
|
-
import { hashObjectIgnoreKeyOrder } from '@saulx/hash';
|
|
4
|
-
import { SIZE_MAP, TYPE_INDEX_MAP, STRING, ALIAS, CARDINALITY, } from './types.js';
|
|
5
|
-
import { genId } from './utils.js';
|
|
6
|
-
import { DEFAULT_BLOCK_CAPACITY } from '../start.js';
|
|
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 = (db) => {
|
|
56
|
-
for (const field in db.schemaTypesParsed) {
|
|
57
|
-
if (field in db.schema.types) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const id = db.schemaTypesParsed[field].id;
|
|
61
|
-
delete db.schemaTypesParsed[field];
|
|
62
|
-
delete db.schemaTypesParsedById[id];
|
|
63
|
-
}
|
|
64
|
-
for (const field in db.schema.types) {
|
|
65
|
-
const type = db.schema.types[field];
|
|
66
|
-
if (db.schemaTypesParsed[field] &&
|
|
67
|
-
db.schemaTypesParsed[field].checksum === hashObjectIgnoreKeyOrder(type) // bit weird..
|
|
68
|
-
) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
if (!type.id) {
|
|
73
|
-
type.id = genId(db);
|
|
74
|
-
}
|
|
75
|
-
const def = createSchemaTypeDef(field, type, db.schemaTypesParsed, db.schema.locales ?? {
|
|
76
|
-
en: {},
|
|
77
|
-
});
|
|
78
|
-
def.blockCapacity =
|
|
79
|
-
field === '_root' ? 2147483647 : DEFAULT_BLOCK_CAPACITY; // TODO this should come from somewhere else
|
|
80
|
-
db.schemaTypesParsed[field] = def;
|
|
81
|
-
db.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: Buffer.allocUnsafe(0),
|
|
104
|
-
bufferTmp: Buffer.allocUnsafe(0),
|
|
105
|
-
},
|
|
106
|
-
hasSeperateTextSort: false,
|
|
107
|
-
seperateTextSort: {
|
|
108
|
-
size: 0,
|
|
109
|
-
props: [],
|
|
110
|
-
buffer: Buffer.allocUnsafe(0),
|
|
111
|
-
bufferTmp: Buffer.allocUnsafe(0),
|
|
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.idUint8[0] = result.id & 255;
|
|
124
|
-
result.idUint8[1] = result.id >> 8;
|
|
125
|
-
const encoder = new TextEncoder();
|
|
126
|
-
const target = type.props;
|
|
127
|
-
let separateSortProps = 0;
|
|
128
|
-
let separateSortText = 0;
|
|
129
|
-
for (const key in target) {
|
|
130
|
-
const schemaProp = target[key];
|
|
131
|
-
const propPath = [...path, key];
|
|
132
|
-
const propType = getPropType(schemaProp);
|
|
133
|
-
if (propType === 'object') {
|
|
134
|
-
createSchemaTypeDef(typeName, schemaProp, parsed, locales, result, propPath, false);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
let len = SIZE_MAP[propType];
|
|
138
|
-
if (isPropType('string', schemaProp) ||
|
|
139
|
-
isPropType('alias', schemaProp) ||
|
|
140
|
-
isPropType('cardinality', schemaProp)) {
|
|
141
|
-
if (typeof schemaProp === 'object') {
|
|
142
|
-
if (schemaProp.maxBytes < 61) {
|
|
143
|
-
len = schemaProp.maxBytes + 1;
|
|
144
|
-
}
|
|
145
|
-
else if ('max' in schemaProp && schemaProp.max < 31) {
|
|
146
|
-
len = schemaProp.max * 2 + 1;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
separateSortProps++;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
separateSortProps++;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else if (isPropType('vector', schemaProp)) {
|
|
157
|
-
len = 4 * schemaProp.size;
|
|
158
|
-
}
|
|
159
|
-
const isseparate = len === 0 || isPropType('vector', schemaProp);
|
|
160
|
-
if (isseparate) {
|
|
161
|
-
result.cnt++;
|
|
162
|
-
}
|
|
163
|
-
const prop = {
|
|
164
|
-
typeIndex: TYPE_INDEX_MAP[propType],
|
|
165
|
-
__isPropDef: true,
|
|
166
|
-
separate: isseparate,
|
|
167
|
-
path: propPath,
|
|
168
|
-
start: 0,
|
|
169
|
-
len,
|
|
170
|
-
prop: isseparate ? result.cnt : 0,
|
|
171
|
-
};
|
|
172
|
-
if (isPropType('enum', schemaProp)) {
|
|
173
|
-
prop.enum = Array.isArray(schemaProp) ? schemaProp : schemaProp.enum;
|
|
174
|
-
prop.reverseEnum = {};
|
|
175
|
-
for (let i = 0; i < prop.enum.length; i++) {
|
|
176
|
-
prop.reverseEnum[prop.enum[i]] = i;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else if (isPropType('references', schemaProp)) {
|
|
180
|
-
prop.inversePropName = schemaProp.items.prop;
|
|
181
|
-
prop.inverseTypeName = schemaProp.items.ref;
|
|
182
|
-
prop.dependent = schemaProp.items.dependent;
|
|
183
|
-
addEdges(prop, schemaProp.items);
|
|
184
|
-
}
|
|
185
|
-
else if (isPropType('reference', schemaProp)) {
|
|
186
|
-
prop.inversePropName = schemaProp.prop;
|
|
187
|
-
prop.inverseTypeName = schemaProp.ref;
|
|
188
|
-
prop.dependent = schemaProp.dependent;
|
|
189
|
-
addEdges(prop, schemaProp);
|
|
190
|
-
}
|
|
191
|
-
else if (typeof schemaProp === 'object') {
|
|
192
|
-
if (isPropType('string', schemaProp) ||
|
|
193
|
-
isPropType('text', schemaProp)) {
|
|
194
|
-
prop.compression =
|
|
195
|
-
'compression' in schemaProp && schemaProp.compression === 'none'
|
|
196
|
-
? 0
|
|
197
|
-
: 1;
|
|
198
|
-
}
|
|
199
|
-
else if (isPropType('timestamp', schemaProp) && 'on' in schemaProp) {
|
|
200
|
-
if (schemaProp.on[0] === 'c') {
|
|
201
|
-
result.createTs ??= [];
|
|
202
|
-
result.createTs.push(prop);
|
|
203
|
-
}
|
|
204
|
-
else if (schemaProp.on[0] === 'u') {
|
|
205
|
-
result.createTs ??= [];
|
|
206
|
-
result.createTs.push(prop);
|
|
207
|
-
result.updateTs ??= [];
|
|
208
|
-
result.updateTs.push(prop);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
result.props[propPath.join('.')] = prop;
|
|
213
|
-
if (isseparate) {
|
|
214
|
-
result.separate.push(prop);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (top) {
|
|
219
|
-
const vals = Object.values(result.props);
|
|
220
|
-
vals.sort((a, b) => {
|
|
221
|
-
if (b.separate && (a.typeIndex === 14 || a.typeIndex === 13)) {
|
|
222
|
-
return -1;
|
|
223
|
-
}
|
|
224
|
-
return a.prop - b.prop;
|
|
225
|
-
});
|
|
226
|
-
let lastProp = 0;
|
|
227
|
-
for (const p of vals) {
|
|
228
|
-
if (p.separate) {
|
|
229
|
-
lastProp++;
|
|
230
|
-
p.prop = lastProp;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
let len = 2;
|
|
234
|
-
for (const f of vals) {
|
|
235
|
-
if (f.separate) {
|
|
236
|
-
len += 2;
|
|
237
|
-
setByPath(result.tree, f.path, f);
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
if (!result.mainLen) {
|
|
241
|
-
len += 2;
|
|
242
|
-
}
|
|
243
|
-
len += 1;
|
|
244
|
-
f.start = result.mainLen;
|
|
245
|
-
result.mainLen += f.len;
|
|
246
|
-
setByPath(result.tree, f.path, f);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const mainFields = [];
|
|
250
|
-
const restFields = [];
|
|
251
|
-
for (const f of vals) {
|
|
252
|
-
if (f.separate) {
|
|
253
|
-
restFields.push(f);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
mainFields.push(f);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
result.buf = Buffer.allocUnsafe(len);
|
|
260
|
-
result.buf[0] = result.idUint8[0];
|
|
261
|
-
result.buf[1] = result.idUint8[1];
|
|
262
|
-
const fieldNames = [];
|
|
263
|
-
const tNameBuf = encoder.encode(typeName);
|
|
264
|
-
fieldNames.push(tNameBuf);
|
|
265
|
-
let fieldNameLen = tNameBuf.byteLength + 1;
|
|
266
|
-
let i = 2;
|
|
267
|
-
if (result.mainLen) {
|
|
268
|
-
result.buf[i] = 0;
|
|
269
|
-
for (const f of vals) {
|
|
270
|
-
if (!f.separate) {
|
|
271
|
-
i++;
|
|
272
|
-
result.buf[i] = f.typeIndex;
|
|
273
|
-
const name = encoder.encode(f.path.join('.'));
|
|
274
|
-
fieldNames.push(name);
|
|
275
|
-
fieldNameLen += name.byteLength + 1;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
i++;
|
|
279
|
-
result.buf[i] = 0;
|
|
280
|
-
}
|
|
281
|
-
for (const f of vals) {
|
|
282
|
-
if (f.separate) {
|
|
283
|
-
i++;
|
|
284
|
-
result.buf[i] = f.prop;
|
|
285
|
-
i++;
|
|
286
|
-
result.buf[i] = f.typeIndex;
|
|
287
|
-
const name = encoder.encode(f.path.join('.'));
|
|
288
|
-
fieldNames.push(name);
|
|
289
|
-
fieldNameLen += name.byteLength + 1;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
result.propNames = Buffer.allocUnsafe(fieldNameLen);
|
|
293
|
-
let lastWritten = 0;
|
|
294
|
-
for (const f of fieldNames) {
|
|
295
|
-
result.propNames[lastWritten] = f.byteLength;
|
|
296
|
-
result.propNames.set(f, lastWritten + 1);
|
|
297
|
-
lastWritten += f.byteLength + 1;
|
|
298
|
-
}
|
|
299
|
-
if (separateSortProps > 0) {
|
|
300
|
-
result.hasSeperateSort = true;
|
|
301
|
-
let max = 0;
|
|
302
|
-
for (const f of result.separate) {
|
|
303
|
-
// Does not only need to be on string can also be HLL
|
|
304
|
-
if (f.typeIndex === STRING ||
|
|
305
|
-
f.typeIndex === ALIAS ||
|
|
306
|
-
f.typeIndex === CARDINALITY) {
|
|
307
|
-
if (f.prop > max) {
|
|
308
|
-
max = f.prop;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
result.seperateSort.buffer = Buffer.allocUnsafe(max + 1);
|
|
313
|
-
for (const f of result.separate) {
|
|
314
|
-
if (f.typeIndex === STRING ||
|
|
315
|
-
f.typeIndex === ALIAS ||
|
|
316
|
-
f.typeIndex === CARDINALITY) {
|
|
317
|
-
result.seperateSort.buffer[f.prop] = 1;
|
|
318
|
-
result.seperateSort.props.push(f);
|
|
319
|
-
result.seperateSort.size++;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
result.seperateSort.bufferTmp = Buffer.allocUnsafe(max + 1);
|
|
323
|
-
result.seperateSort.buffer.copy(result.seperateSort.bufferTmp);
|
|
324
|
-
}
|
|
325
|
-
for (const p in result.props) {
|
|
326
|
-
const x = result.props[p];
|
|
327
|
-
if (!x.separate) {
|
|
328
|
-
result.main[x.start] = x;
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
result.reverseProps[x.prop] = x;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return result;
|
|
336
|
-
};
|
|
337
|
-
//# sourceMappingURL=typeDef.js.map
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { SchemaLocales } from '@based/schema';
|
|
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: Buffer;
|
|
100
|
-
bufferTmp: Buffer;
|
|
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: Buffer;
|
|
112
|
-
propNames: Buffer;
|
|
113
|
-
props: {
|
|
114
|
-
[path: string]: PropDef;
|
|
115
|
-
};
|
|
116
|
-
reverseProps: {
|
|
117
|
-
[field: string]: PropDef;
|
|
118
|
-
};
|
|
119
|
-
id: number;
|
|
120
|
-
idUint8: Uint8Array;
|
|
121
|
-
separate: PropDef[];
|
|
122
|
-
main: {
|
|
123
|
-
[start: string]: PropDef;
|
|
124
|
-
};
|
|
125
|
-
tree: SchemaPropTree;
|
|
126
|
-
hasSeperateSort: boolean;
|
|
127
|
-
seperateSort: SchemaSortUndefinedHandler;
|
|
128
|
-
hasSeperateTextSort: boolean;
|
|
129
|
-
seperateTextSort: SchemaSortUndefinedHandler;
|
|
130
|
-
createTs?: PropDef[];
|
|
131
|
-
updateTs?: PropDef[];
|
|
132
|
-
locales: Partial<SchemaLocales>;
|
|
133
|
-
};
|
|
134
|
-
export declare const SIZE_MAP: Record<InternalSchemaProp, number>;
|
|
135
|
-
export declare let REVERSE_SIZE_MAP: Record<TypeIndex, number>;
|
|
136
|
-
export declare const REVERSE_TYPE_INDEX_MAP: Record<TypeIndex, InternalSchemaProp>;
|
|
137
|
-
export declare const ID_FIELD_DEF: PropDef;
|
|
138
|
-
export declare const EMPTY_MICRO_BUFFER: PropDef;
|
|
139
|
-
export declare const getPropTypeName: (propType: TypeIndex) => InternalSchemaProp;
|
|
140
|
-
export declare const isPropDef: (prop: any) => prop is PropDef;
|
|
@@ -1,121 +0,0 @@
|
|
|
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
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DbClient } from '../../client/index.js';
|
|
2
|
-
import { DbServer } from '../index.js';
|
|
3
|
-
import { PropDef, PropDefEdge } from './types.js';
|
|
4
|
-
export declare const propIsSigned: (prop: PropDef | PropDefEdge) => boolean;
|
|
5
|
-
export declare const propIsNumerical: (prop: PropDef | PropDefEdge) => boolean;
|
|
6
|
-
export declare const genRootId: () => number;
|
|
7
|
-
export declare const genId: (db: DbServer | DbClient) => number;
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
const genIdFromInt = (n) => {
|
|
25
|
-
return n;
|
|
26
|
-
};
|
|
27
|
-
export const genRootId = () => {
|
|
28
|
-
return genIdFromInt(1);
|
|
29
|
-
};
|
|
30
|
-
export const genId = (db) => {
|
|
31
|
-
db.schema.lastId++;
|
|
32
|
-
return genIdFromInt(db.schema.lastId);
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=utils.js.map
|