@based/schema 5.0.0-alpha.21 → 5.0.0-alpha.22
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/createEmptyDef.d.ts +7 -7
- package/dist/def/fillEmptyMain.d.ts +1 -1
- package/dist/def/typeDef.js +12 -2
- package/dist/def/types.d.ts +5 -0
- package/dist/def/validation.js +0 -1
- package/dist/lang.d.ts +1 -1
- package/dist/parse/index.js +1 -0
- package/dist/parse/props.js +1 -1
- package/dist/serialize.js +38 -21
- package/package.json +2 -2
- package/dist/def/DEFAULT_MAP.d.ts +0 -3
- package/dist/def/DEFAULT_MAP.js +0 -29
- package/dist/def/getPropLen.d.ts +0 -3
- package/dist/def/getPropLen.js +0 -23
- package/dist/def/makePacked.d.ts +0 -3
- package/dist/def/makePacked.js +0 -50
- package/dist/def/readFromPacked.d.ts +0 -3
- package/dist/def/readFromPacked.js +0 -140
- package/dist/def/timestamp.d.ts +0 -2
- package/dist/def/timestamp.js +0 -67
- package/dist/mermaid.d.ts +0 -3
- package/dist/mermaid.js +0 -24
- package/dist/validation/validation.d.ts +0 -2
- package/dist/validation/validation.js +0 -6
|
@@ -8,9 +8,9 @@ export declare const createEmptyDef: (typeName: string, type: StrictSchemaType |
|
|
|
8
8
|
type: string;
|
|
9
9
|
props: {};
|
|
10
10
|
reverseProps: {};
|
|
11
|
-
idUint8: Uint8Array
|
|
11
|
+
idUint8: Uint8Array<ArrayBuffer>;
|
|
12
12
|
id: number;
|
|
13
|
-
mainEmpty: Uint8Array
|
|
13
|
+
mainEmpty: Uint8Array<ArrayBuffer>;
|
|
14
14
|
mainLen: number;
|
|
15
15
|
separate: any[];
|
|
16
16
|
tree: {};
|
|
@@ -25,16 +25,16 @@ export declare const createEmptyDef: (typeName: string, type: StrictSchemaType |
|
|
|
25
25
|
seperateSort: {
|
|
26
26
|
size: number;
|
|
27
27
|
props: any[];
|
|
28
|
-
buffer: Uint8Array
|
|
29
|
-
bufferTmp: Uint8Array
|
|
28
|
+
buffer: Uint8Array<ArrayBuffer>;
|
|
29
|
+
bufferTmp: Uint8Array<ArrayBuffer>;
|
|
30
30
|
};
|
|
31
31
|
hasSeperateTextSort: boolean;
|
|
32
32
|
seperateTextSort: {
|
|
33
33
|
size: number;
|
|
34
34
|
props: any[];
|
|
35
|
-
buffer: Uint8Array
|
|
36
|
-
noUndefined: Uint8Array
|
|
37
|
-
bufferTmp: Uint8Array
|
|
35
|
+
buffer: Uint8Array<ArrayBuffer>;
|
|
36
|
+
noUndefined: Uint8Array<ArrayBuffer>;
|
|
37
|
+
bufferTmp: Uint8Array<ArrayBuffer>;
|
|
38
38
|
localeStringToIndex: Map<any, any>;
|
|
39
39
|
localeToIndex: Map<any, any>;
|
|
40
40
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropDef } from './types.js';
|
|
2
2
|
export declare const ENCODER: TextEncoder;
|
|
3
|
-
export declare const fillEmptyMain: (vals: PropDef[], mainLen: number) => Uint8Array
|
|
3
|
+
export declare const fillEmptyMain: (vals: PropDef[], mainLen: number) => Uint8Array<ArrayBuffer>;
|
|
4
4
|
export declare const isZeroes: (buf: Uint8Array) => boolean;
|
|
5
5
|
//# sourceMappingURL=fillEmptyMain.d.ts.map
|
package/dist/def/typeDef.js
CHANGED
|
@@ -45,13 +45,16 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = cr
|
|
|
45
45
|
}
|
|
46
46
|
if (result.blockCapacity == 0) {
|
|
47
47
|
if ('blockCapacity' in type) {
|
|
48
|
-
if (typeof type.blockCapacity !== 'number' ||
|
|
48
|
+
if (typeof type.blockCapacity !== 'number' ||
|
|
49
|
+
type.blockCapacity < BLOCK_CAPACITY_MIN ||
|
|
50
|
+
type.blockCapacity > BLOCK_CAPACITY_MAX) {
|
|
49
51
|
throw new Error('Invalid blockCapacity');
|
|
50
52
|
}
|
|
51
53
|
result.blockCapacity = type.blockCapacity;
|
|
52
54
|
}
|
|
53
55
|
else {
|
|
54
|
-
result.blockCapacity =
|
|
56
|
+
result.blockCapacity =
|
|
57
|
+
typeName === '_root' ? BLOCK_CAPACITY_MAX : BLOCK_CAPACITY_DEFAULT;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
if (result.insertOnly == false && 'insertOnly' in type) {
|
|
@@ -197,6 +200,13 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = cr
|
|
|
197
200
|
if (f.separate) {
|
|
198
201
|
len += 2;
|
|
199
202
|
setByPath(result.tree, f.path, f);
|
|
203
|
+
if (f.default !== undefined) {
|
|
204
|
+
result.hasSeperateDefaults = true;
|
|
205
|
+
if (!result.seperateDefaults) {
|
|
206
|
+
// result.seperateDefaults = []
|
|
207
|
+
}
|
|
208
|
+
// result.seperateDefaults.push(f)
|
|
209
|
+
}
|
|
200
210
|
}
|
|
201
211
|
else {
|
|
202
212
|
if (!result.mainLen) {
|
package/dist/def/types.d.ts
CHANGED
|
@@ -167,6 +167,11 @@ export type SchemaTypeDef = {
|
|
|
167
167
|
localeStringToIndex: Map<string, Uint8Array>;
|
|
168
168
|
localeToIndex: Map<LangCode, number>;
|
|
169
169
|
};
|
|
170
|
+
hasSeperateDefaults: boolean;
|
|
171
|
+
seperateDefaults?: {
|
|
172
|
+
props: Map<number, PropDef>;
|
|
173
|
+
bufferTmp: Uint8Array;
|
|
174
|
+
};
|
|
170
175
|
createTs?: PropDef[];
|
|
171
176
|
updateTs?: PropDef[];
|
|
172
177
|
locales: Partial<SchemaLocales>;
|
package/dist/def/validation.js
CHANGED
package/dist/lang.d.ts
CHANGED
|
@@ -147,7 +147,7 @@ declare const langCodes: {
|
|
|
147
147
|
readonly ka: 145;
|
|
148
148
|
readonly cnr: 146;
|
|
149
149
|
};
|
|
150
|
-
export declare const langCodesMap: Map<string, 0 |
|
|
150
|
+
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 | 145 | 146>;
|
|
151
151
|
export declare const inverseLangMap: Map<any, any>;
|
|
152
152
|
export type LangName = keyof typeof langCodes;
|
|
153
153
|
export type LangCode = (typeof langCodes)[LangName];
|
package/dist/parse/index.js
CHANGED
package/dist/parse/props.js
CHANGED
|
@@ -128,7 +128,7 @@ export const isDefault = (val, prop, ctx) => {
|
|
|
128
128
|
enum: prop.enum,
|
|
129
129
|
validation,
|
|
130
130
|
default: DEFAULT_MAP[typeIndex],
|
|
131
|
-
step: parseMinMaxStep(prop.step ?? typeIndex === NUMBER ? 0 : 1),
|
|
131
|
+
step: parseMinMaxStep((prop.step ?? typeIndex === NUMBER) ? 0 : 1),
|
|
132
132
|
max: parseMinMaxStep(prop.max),
|
|
133
133
|
min: parseMinMaxStep(prop.min),
|
|
134
134
|
};
|
package/dist/serialize.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import * as deflate from 'fflate'
|
|
2
2
|
import { stringFormats } from './types.js';
|
|
3
|
-
import { REVERSE_TYPE_INDEX_MAP, TYPE_INDEX_MAP } from './def/types.js';
|
|
3
|
+
import { ENUM, REVERSE_TYPE_INDEX_MAP, TYPE_INDEX_MAP } from './def/types.js';
|
|
4
4
|
import { readDoubleLE, readUint16, readUint24, readUint32, writeDoubleLE, writeUint16, writeUint24, writeUint32, } from '@saulx/utils';
|
|
5
5
|
const ENCODER = new TextEncoder();
|
|
6
6
|
const UINT8 = 245;
|
|
@@ -35,7 +35,7 @@ const ensureCapacity = (required) => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
let schemaBuffer;
|
|
38
|
-
const handleSingleValue = (ops, val, obj, prev, fromObject, key
|
|
38
|
+
const handleSingleValue = (ops, val, obj, prev, fromObject, key) => {
|
|
39
39
|
const type = typeof val;
|
|
40
40
|
// typed Array - single PROP
|
|
41
41
|
if (val instanceof Uint8Array) {
|
|
@@ -69,10 +69,10 @@ const handleSingleValue = (ops, val, obj, prev, fromObject, key, isTypes) => {
|
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
71
71
|
if (!fromObject && key === 'props' && obj.type === 'object') {
|
|
72
|
-
walk(ops, val, obj, prev, true, schemaBuffer
|
|
72
|
+
walk(ops, val, obj, prev, true, schemaBuffer);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
|
-
walk(ops, val, obj, prev, fromObject, schemaBuffer
|
|
75
|
+
walk(ops, val, obj, prev, fromObject, schemaBuffer);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -158,22 +158,22 @@ const encodeKey = (key, schemaBuffer) => {
|
|
|
158
158
|
// 0 for queries (min)
|
|
159
159
|
// 1 for modify
|
|
160
160
|
// 2 fulls schema
|
|
161
|
-
const walk = (opts, obj, prev, prev2, fromObject, schemaBuffer
|
|
161
|
+
const walk = (opts, obj, prev, prev2, fromObject, schemaBuffer) => {
|
|
162
162
|
let start = schemaBuffer.len;
|
|
163
163
|
const isArray = Array.isArray(obj);
|
|
164
164
|
const isFromObj = prev2?.type === 'object' || fromObject === false;
|
|
165
|
-
const isSchemaProp = 'type' in obj && isFromObj;
|
|
166
|
-
ensureCapacity(1 +
|
|
165
|
+
const isSchemaProp = ('enum' in obj || ('type' in obj && TYPE_INDEX_MAP[obj.type])) && isFromObj;
|
|
166
|
+
ensureCapacity(1 + 5); // Type byte + size
|
|
167
167
|
if (isSchemaProp) {
|
|
168
168
|
schemaBuffer.buf[schemaBuffer.len++] = SCHEMA_PROP;
|
|
169
|
-
const typeIndex = TYPE_INDEX_MAP[obj.type];
|
|
169
|
+
const typeIndex = TYPE_INDEX_MAP['enum' in obj ? 'enum' : obj.type];
|
|
170
170
|
schemaBuffer.buf[schemaBuffer.len++] = typeIndex;
|
|
171
171
|
}
|
|
172
172
|
else {
|
|
173
173
|
schemaBuffer.buf[schemaBuffer.len++] = isArray ? ARRAY : OBJECT;
|
|
174
174
|
}
|
|
175
175
|
let sizeIndex = schemaBuffer.len;
|
|
176
|
-
schemaBuffer.len +=
|
|
176
|
+
schemaBuffer.len += 5;
|
|
177
177
|
if (isArray) {
|
|
178
178
|
const len = obj.length;
|
|
179
179
|
ensureCapacity(2 * len + 2);
|
|
@@ -251,12 +251,7 @@ const walk = (opts, obj, prev, prev2, fromObject, schemaBuffer, isTypes) => {
|
|
|
251
251
|
continue;
|
|
252
252
|
}
|
|
253
253
|
else {
|
|
254
|
-
let isTypes = false;
|
|
255
254
|
if (key === 'types') {
|
|
256
|
-
// undefined undefined false
|
|
257
|
-
if (!prev && !prev2 && !fromObject) {
|
|
258
|
-
isTypes = true;
|
|
259
|
-
}
|
|
260
255
|
ensureCapacity(1);
|
|
261
256
|
schemaBuffer.buf[schemaBuffer.len] = TYPES;
|
|
262
257
|
schemaBuffer.len += 1;
|
|
@@ -269,13 +264,25 @@ const walk = (opts, obj, prev, prev2, fromObject, schemaBuffer, isTypes) => {
|
|
|
269
264
|
else {
|
|
270
265
|
encodeKey(key, schemaBuffer);
|
|
271
266
|
}
|
|
272
|
-
|
|
267
|
+
// important to handle the size here...
|
|
268
|
+
handleSingleValue(opts, obj[key], obj, prev, fromObject, key);
|
|
273
269
|
}
|
|
274
270
|
}
|
|
275
271
|
}
|
|
276
272
|
let size = schemaBuffer.len - start;
|
|
277
|
-
|
|
278
|
-
|
|
273
|
+
// 3
|
|
274
|
+
// if (size < 252) {
|
|
275
|
+
// console.log('FLAP>', size)
|
|
276
|
+
// schemaBuffer.buf[sizeIndex] = size + 3
|
|
277
|
+
// schemaBuffer.buf.set(
|
|
278
|
+
// schemaBuffer.buf.subarray(sizeIndex + 4, sizeIndex + size),
|
|
279
|
+
// sizeIndex + 1,
|
|
280
|
+
// )
|
|
281
|
+
// schemaBuffer.len -= 4
|
|
282
|
+
// } else {
|
|
283
|
+
schemaBuffer.buf[sizeIndex] = 0; // means 4
|
|
284
|
+
writeUint32(schemaBuffer.buf, size, sizeIndex + 1);
|
|
285
|
+
// }
|
|
279
286
|
};
|
|
280
287
|
export const serialize = (schema, opts = {}) => {
|
|
281
288
|
if (!schemaBuffer) {
|
|
@@ -289,7 +296,7 @@ export const serialize = (schema, opts = {}) => {
|
|
|
289
296
|
schemaBuffer.dictMap = {};
|
|
290
297
|
// defalte not supported in unpacking yet
|
|
291
298
|
const isDeflate = 0; // opts.deflate ? 1 : 0
|
|
292
|
-
walk(opts, schema, undefined, undefined, false, schemaBuffer
|
|
299
|
+
walk(opts, schema, undefined, undefined, false, schemaBuffer);
|
|
293
300
|
const packed = new Uint8Array(schemaBuffer.buf.subarray(0, schemaBuffer.len));
|
|
294
301
|
// if (isDeflate) {
|
|
295
302
|
// // add extra byte! see if nessecary
|
|
@@ -334,11 +341,21 @@ export const deSerializeInner = (buf, obj, start, fromArray) => {
|
|
|
334
341
|
if (isSchemaProp) {
|
|
335
342
|
const type = buf[i];
|
|
336
343
|
const parsedType = REVERSE_TYPE_INDEX_MAP[type];
|
|
337
|
-
|
|
344
|
+
if (type !== ENUM) {
|
|
345
|
+
obj.type = parsedType;
|
|
346
|
+
}
|
|
347
|
+
i += 1;
|
|
348
|
+
}
|
|
349
|
+
let size;
|
|
350
|
+
if (buf[i] === 0) {
|
|
351
|
+
size = readUint32(buf, i + 1);
|
|
352
|
+
i += 5;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
size = buf[i] - 3;
|
|
356
|
+
console.log('yo', size);
|
|
338
357
|
i += 1;
|
|
339
358
|
}
|
|
340
|
-
const size = readUint16(buf, i);
|
|
341
|
-
i += 2;
|
|
342
359
|
const end = size + start;
|
|
343
360
|
if (fromArray) {
|
|
344
361
|
i += 2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/schema",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typescript": "^5.6.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@saulx/utils": "^6.7.
|
|
32
|
+
"@saulx/utils": "^6.7.2",
|
|
33
33
|
"picocolors": "^1.1.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/dist/def/DEFAULT_MAP.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { TYPE_INDEX_MAP } from './types.js';
|
|
2
|
-
// TODO update defaults
|
|
3
|
-
export const DEFAULT_MAP = {
|
|
4
|
-
[TYPE_INDEX_MAP.alias]: '',
|
|
5
|
-
[TYPE_INDEX_MAP.binary]: undefined,
|
|
6
|
-
[TYPE_INDEX_MAP.boolean]: false,
|
|
7
|
-
[TYPE_INDEX_MAP.cardinality]: 0,
|
|
8
|
-
[TYPE_INDEX_MAP.created]: 0,
|
|
9
|
-
[TYPE_INDEX_MAP.updated]: 0,
|
|
10
|
-
[TYPE_INDEX_MAP.number]: 0,
|
|
11
|
-
[TYPE_INDEX_MAP.timestamp]: 0,
|
|
12
|
-
[TYPE_INDEX_MAP.enum]: 0,
|
|
13
|
-
[TYPE_INDEX_MAP.id]: 0,
|
|
14
|
-
[TYPE_INDEX_MAP.int16]: 0,
|
|
15
|
-
[TYPE_INDEX_MAP.int32]: 0,
|
|
16
|
-
[TYPE_INDEX_MAP.int8]: 0,
|
|
17
|
-
[TYPE_INDEX_MAP.uint8]: 0,
|
|
18
|
-
[TYPE_INDEX_MAP.uint16]: 0,
|
|
19
|
-
[TYPE_INDEX_MAP.uint32]: 0,
|
|
20
|
-
[TYPE_INDEX_MAP.json]: undefined,
|
|
21
|
-
[TYPE_INDEX_MAP.microbuffer]: undefined,
|
|
22
|
-
[TYPE_INDEX_MAP.reference]: undefined,
|
|
23
|
-
[TYPE_INDEX_MAP.references]: [],
|
|
24
|
-
[TYPE_INDEX_MAP.string]: '',
|
|
25
|
-
[TYPE_INDEX_MAP.aliases]: [],
|
|
26
|
-
[TYPE_INDEX_MAP.text]: '',
|
|
27
|
-
[TYPE_INDEX_MAP.vector]: undefined, // maybe not can set a vec with 0
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=DEFAULT_MAP.js.map
|
package/dist/def/getPropLen.d.ts
DELETED
package/dist/def/getPropLen.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { getPropType } from '../parse/utils.js';
|
|
2
|
-
import { isPropType } from '../types.js';
|
|
3
|
-
import { SIZE_MAP } from './types.js';
|
|
4
|
-
export function getPropLen(schemaProp) {
|
|
5
|
-
let len = SIZE_MAP[getPropType(schemaProp)];
|
|
6
|
-
if (isPropType('string', schemaProp) ||
|
|
7
|
-
isPropType('alias', schemaProp) ||
|
|
8
|
-
isPropType('cardinality', schemaProp)) {
|
|
9
|
-
if (typeof schemaProp === 'object') {
|
|
10
|
-
if (schemaProp.maxBytes < 61) {
|
|
11
|
-
len = schemaProp.maxBytes + 1;
|
|
12
|
-
}
|
|
13
|
-
else if ('max' in schemaProp && schemaProp.max < 31) {
|
|
14
|
-
len = schemaProp.max * 2 + 1;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
else if (isPropType('vector', schemaProp)) {
|
|
19
|
-
len = 4 * schemaProp.size;
|
|
20
|
-
}
|
|
21
|
-
return len;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=getPropLen.js.map
|
package/dist/def/makePacked.d.ts
DELETED
package/dist/def/makePacked.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export function makePacked(result, typeName, vals, len) {
|
|
2
|
-
const encoder = new TextEncoder();
|
|
3
|
-
result.buf = new Uint8Array(len);
|
|
4
|
-
result.buf[0] = result.idUint8[0];
|
|
5
|
-
result.buf[1] = result.idUint8[1];
|
|
6
|
-
const fieldNames = [];
|
|
7
|
-
const tNameBuf = encoder.encode(typeName);
|
|
8
|
-
fieldNames.push(tNameBuf);
|
|
9
|
-
let fieldNameLen = tNameBuf.byteLength + 1;
|
|
10
|
-
let i = 2;
|
|
11
|
-
if (result.mainLen) {
|
|
12
|
-
result.buf[i] = 0;
|
|
13
|
-
for (const f of vals) {
|
|
14
|
-
if (!f.separate) {
|
|
15
|
-
i++;
|
|
16
|
-
result.buf[i] = f.typeIndex;
|
|
17
|
-
const name = encoder.encode(f.path.join('.'));
|
|
18
|
-
fieldNames.push(name);
|
|
19
|
-
fieldNameLen += name.byteLength + 1;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
i++;
|
|
23
|
-
result.buf[i] = 0;
|
|
24
|
-
}
|
|
25
|
-
for (const f of vals) {
|
|
26
|
-
if (f.separate) {
|
|
27
|
-
i++;
|
|
28
|
-
result.buf[i] = f.prop;
|
|
29
|
-
i++;
|
|
30
|
-
result.buf[i] = f.typeIndex;
|
|
31
|
-
const name = encoder.encode(f.path.join('.'));
|
|
32
|
-
fieldNames.push(name);
|
|
33
|
-
fieldNameLen += name.byteLength + 1;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
result.propNames = new Uint8Array(fieldNameLen);
|
|
37
|
-
let lastWritten = 0;
|
|
38
|
-
for (const f of fieldNames) {
|
|
39
|
-
result.propNames[lastWritten] = f.byteLength;
|
|
40
|
-
result.propNames.set(f, lastWritten + 1);
|
|
41
|
-
lastWritten += f.byteLength + 1;
|
|
42
|
-
}
|
|
43
|
-
let bufLen = result.buf.length;
|
|
44
|
-
result.packed = new Uint8Array(2 + bufLen + result.propNames.length);
|
|
45
|
-
result.packed[0] = bufLen;
|
|
46
|
-
result.packed[1] = bufLen >>>= 8;
|
|
47
|
-
result.packed.set(result.buf, 2);
|
|
48
|
-
result.packed.set(result.propNames, result.buf.length + 2);
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=makePacked.js.map
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { REVERSE_SIZE_MAP } from './types.js';
|
|
2
|
-
import { DEFAULT_MAP } from './defaultMap.js';
|
|
3
|
-
import { VALIDATION_MAP } from './validation.js';
|
|
4
|
-
export const readFromPacked = (packed) => {
|
|
5
|
-
const size = (packed[0] | (packed[1] << 8)) >>> 0;
|
|
6
|
-
const props = [];
|
|
7
|
-
const b = packed.subarray(2, 2 + size);
|
|
8
|
-
let collectMain = false;
|
|
9
|
-
const mainProps = [];
|
|
10
|
-
const typeId = b.subarray(0, 2);
|
|
11
|
-
const typeIdNr = (typeId[0] | (typeId[1] << 8)) >>> 0;
|
|
12
|
-
for (let i = 2; i < b.length; i++) {
|
|
13
|
-
const prop = b[i];
|
|
14
|
-
if (collectMain) {
|
|
15
|
-
if (prop === 0) {
|
|
16
|
-
collectMain = false;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
mainProps.push({
|
|
20
|
-
prop: 0,
|
|
21
|
-
typeIndex: b[i],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (prop == 0) {
|
|
27
|
-
collectMain = true;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
props.push({ prop, typeIndex: b[i + 1] });
|
|
31
|
-
i++;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const decoder = new TextDecoder();
|
|
36
|
-
const fields = [];
|
|
37
|
-
const f = packed.subarray(2 + size, packed.length);
|
|
38
|
-
for (let i = 0; i < f.length; i++) {
|
|
39
|
-
const size = f[i];
|
|
40
|
-
fields.push(decoder.decode(f.subarray(i + 1, i + 1 + size)));
|
|
41
|
-
i += size;
|
|
42
|
-
}
|
|
43
|
-
for (let i = 0; i < mainProps.length; i++) {
|
|
44
|
-
mainProps[i].path = fields[i + 1];
|
|
45
|
-
}
|
|
46
|
-
for (let i = 0; i < props.length; i++) {
|
|
47
|
-
props[i].path = fields[i + 1 + mainProps.length];
|
|
48
|
-
}
|
|
49
|
-
// Fixed len strings not supported
|
|
50
|
-
// Refs also not supported
|
|
51
|
-
// Text not supported yet
|
|
52
|
-
// Ref not supported yet
|
|
53
|
-
// compression: 1 (0)
|
|
54
|
-
const result = {
|
|
55
|
-
cnt: 0,
|
|
56
|
-
checksum: 0,
|
|
57
|
-
total: 0,
|
|
58
|
-
type: fields[0],
|
|
59
|
-
lastId: 0,
|
|
60
|
-
blockCapacity: 0,
|
|
61
|
-
mainLen: mainProps.length,
|
|
62
|
-
buf: b,
|
|
63
|
-
propNames: f,
|
|
64
|
-
packed,
|
|
65
|
-
props: {},
|
|
66
|
-
reverseProps: {}, // in a bit
|
|
67
|
-
id: typeIdNr,
|
|
68
|
-
idUint8: typeId,
|
|
69
|
-
separate: [],
|
|
70
|
-
main: {},
|
|
71
|
-
tree: {},
|
|
72
|
-
// not nessecary...
|
|
73
|
-
hasSeperateSort: false,
|
|
74
|
-
seperateSort: {
|
|
75
|
-
size: 0,
|
|
76
|
-
buffer: new Uint8Array([]),
|
|
77
|
-
bufferTmp: new Uint8Array([]),
|
|
78
|
-
props: [],
|
|
79
|
-
},
|
|
80
|
-
hasSeperateTextSort: false,
|
|
81
|
-
seperateTextSort: {
|
|
82
|
-
localeToIndex: new Map(),
|
|
83
|
-
localeStringToIndex: new Map(),
|
|
84
|
-
noUndefined: new Uint8Array([]),
|
|
85
|
-
size: 0,
|
|
86
|
-
buffer: new Uint8Array([]),
|
|
87
|
-
bufferTmp: new Uint8Array([]),
|
|
88
|
-
props: [],
|
|
89
|
-
},
|
|
90
|
-
mainEmpty: new Uint8Array([]),
|
|
91
|
-
mainEmptyAllZeroes: true,
|
|
92
|
-
// need this...
|
|
93
|
-
locales: {},
|
|
94
|
-
localeSize: 0,
|
|
95
|
-
};
|
|
96
|
-
let s = 0;
|
|
97
|
-
for (const p of mainProps) {
|
|
98
|
-
const len = REVERSE_SIZE_MAP[p.typeIndex];
|
|
99
|
-
const prop = {
|
|
100
|
-
prop: p.prop,
|
|
101
|
-
separate: false,
|
|
102
|
-
__isPropDef: true,
|
|
103
|
-
validation: VALIDATION_MAP[p.typeIndex],
|
|
104
|
-
start: s,
|
|
105
|
-
default: DEFAULT_MAP[p.typeIndex], // tmp
|
|
106
|
-
typeIndex: p.typeIndex,
|
|
107
|
-
path: p.path.split('.'),
|
|
108
|
-
len,
|
|
109
|
-
};
|
|
110
|
-
result.props[p.path] = prop;
|
|
111
|
-
result.main[prop.start] = prop;
|
|
112
|
-
s += len;
|
|
113
|
-
}
|
|
114
|
-
for (const p of props) {
|
|
115
|
-
const prop = {
|
|
116
|
-
prop: p.prop,
|
|
117
|
-
separate: true,
|
|
118
|
-
__isPropDef: true,
|
|
119
|
-
validation: VALIDATION_MAP[p.typeIndex],
|
|
120
|
-
start: 0,
|
|
121
|
-
typeIndex: p.typeIndex,
|
|
122
|
-
default: DEFAULT_MAP[p.typeIndex], // tmp
|
|
123
|
-
path: p.path.split('.'),
|
|
124
|
-
len: 0,
|
|
125
|
-
compression: 1,
|
|
126
|
-
};
|
|
127
|
-
result.props[p.path] = prop;
|
|
128
|
-
result.reverseProps[prop.prop] = prop;
|
|
129
|
-
}
|
|
130
|
-
// make this into a typeDef
|
|
131
|
-
// return {
|
|
132
|
-
// type: fields[0],
|
|
133
|
-
// fields,
|
|
134
|
-
// typeId,
|
|
135
|
-
// props,
|
|
136
|
-
// mainProps,
|
|
137
|
-
// }
|
|
138
|
-
return result;
|
|
139
|
-
};
|
|
140
|
-
//# sourceMappingURL=readFromPacked.js.map
|
package/dist/def/timestamp.d.ts
DELETED
package/dist/def/timestamp.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const timeToNumber = (ex) => {
|
|
2
|
-
if (ex === 's') {
|
|
3
|
-
return 1000;
|
|
4
|
-
}
|
|
5
|
-
if (ex === 'm') {
|
|
6
|
-
return 1000 * 60;
|
|
7
|
-
}
|
|
8
|
-
if (ex === 'h') {
|
|
9
|
-
return 1000 * 60 * 60;
|
|
10
|
-
}
|
|
11
|
-
if (ex === 'd') {
|
|
12
|
-
return 1000 * 60 * 60 * 24;
|
|
13
|
-
}
|
|
14
|
-
if (ex === 'y') {
|
|
15
|
-
return 31556952000;
|
|
16
|
-
}
|
|
17
|
-
return 1;
|
|
18
|
-
};
|
|
19
|
-
export const convertToTimestamp = (value) => {
|
|
20
|
-
if (value instanceof Date) {
|
|
21
|
-
return value.valueOf();
|
|
22
|
-
}
|
|
23
|
-
if (typeof value === 'string') {
|
|
24
|
-
if (value === 'now') {
|
|
25
|
-
return Date.now();
|
|
26
|
-
}
|
|
27
|
-
const y = value.replace(/([+-])/g, ' $1 ');
|
|
28
|
-
const arr = y.split(/ +/);
|
|
29
|
-
let newValue = 0;
|
|
30
|
-
let now;
|
|
31
|
-
let op = 1;
|
|
32
|
-
for (const seg of arr) {
|
|
33
|
-
if (seg === '-') {
|
|
34
|
-
op = -1;
|
|
35
|
-
}
|
|
36
|
-
else if (seg === '+') {
|
|
37
|
-
op = 1;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
var v = 0;
|
|
41
|
-
if (seg === 'now') {
|
|
42
|
-
if (!now) {
|
|
43
|
-
now = Date.now();
|
|
44
|
-
}
|
|
45
|
-
v = now;
|
|
46
|
-
}
|
|
47
|
-
else if (/[smhdy]$/.test(seg)) {
|
|
48
|
-
const ex = seg[seg.length - 1];
|
|
49
|
-
const number = parseInt(seg, 10);
|
|
50
|
-
v = number * timeToNumber(ex);
|
|
51
|
-
}
|
|
52
|
-
else if (seg) {
|
|
53
|
-
v = new Date(seg).valueOf();
|
|
54
|
-
}
|
|
55
|
-
if (op === -1) {
|
|
56
|
-
newValue -= v;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
newValue += v;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return newValue;
|
|
64
|
-
}
|
|
65
|
-
return value;
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=timestamp.js.map
|
package/dist/mermaid.d.ts
DELETED
package/dist/mermaid.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getPropType } from './parse/utils.js';
|
|
2
|
-
import { isPropType } from './types.js';
|
|
3
|
-
export const mermaid = (schema) => {
|
|
4
|
-
let mermaid = 'classDiagram';
|
|
5
|
-
if (schema.types) {
|
|
6
|
-
for (const type in schema.types) {
|
|
7
|
-
for (const key in schema.types[type].props) {
|
|
8
|
-
const prop = schema.types[type].props[key];
|
|
9
|
-
const propType = getPropType(prop);
|
|
10
|
-
if (isPropType('reference', prop)) {
|
|
11
|
-
mermaid += `\n${type} --> ${prop.ref} : ${key}`;
|
|
12
|
-
}
|
|
13
|
-
else if (isPropType('references', prop)) {
|
|
14
|
-
mermaid += `\n${type} --> ${prop.items.ref} : ${key}[]`;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
mermaid += `\n${type} : ${propType} ${key}`;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return mermaid;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=mermaid.js.map
|