@based/schema 5.0.0-alpha.6 → 5.0.0-alpha.7
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/addEdges.js +24 -17
- package/dist/def/selvaBuffer.js +34 -33
- package/dist/def/types.d.ts +14 -3
- package/dist/lang.d.ts +1 -1
- package/package.json +1 -1
package/dist/def/addEdges.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import { getPropType } from '../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TYPE_INDEX_MAP, REFERENCES, REFERENCE, ENUM, } from './types.js';
|
|
3
|
+
import { getPropLen, isSeparate } from './utils.js';
|
|
3
4
|
export const addEdges = (prop, refProp) => {
|
|
4
|
-
let edgesCnt = 0;
|
|
5
5
|
for (const key in refProp) {
|
|
6
6
|
if (key[0] === '$') {
|
|
7
7
|
if (!prop.edges) {
|
|
8
|
+
prop.edgeMainLen = 0;
|
|
8
9
|
prop.edges = {};
|
|
9
|
-
prop.
|
|
10
|
-
prop.
|
|
10
|
+
prop.reverseSeperateEdges = {};
|
|
11
|
+
prop.reverseMainEdges = {};
|
|
12
|
+
prop.edgesSeperateCnt = 0;
|
|
13
|
+
}
|
|
14
|
+
const edgeProp = refProp[key];
|
|
15
|
+
const edgeType = getPropType(edgeProp);
|
|
16
|
+
const len = getPropLen(edgeProp);
|
|
17
|
+
const separate = isSeparate(edgeProp, len);
|
|
18
|
+
if (separate) {
|
|
19
|
+
prop.edgesSeperateCnt++;
|
|
11
20
|
}
|
|
12
|
-
edgesCnt++;
|
|
13
|
-
const edgeType = getPropType(refProp[key]);
|
|
14
21
|
const edge = {
|
|
15
22
|
__isPropDef: true,
|
|
16
23
|
__isEdge: true,
|
|
17
|
-
prop:
|
|
24
|
+
prop: separate ? prop.edgesSeperateCnt : 0,
|
|
18
25
|
name: key,
|
|
19
26
|
typeIndex: TYPE_INDEX_MAP[edgeType],
|
|
20
|
-
len
|
|
21
|
-
separate
|
|
27
|
+
len,
|
|
28
|
+
separate,
|
|
22
29
|
path: [...prop.path, key],
|
|
30
|
+
start: prop.edgeMainLen,
|
|
23
31
|
};
|
|
24
|
-
|
|
25
|
-
prop.edgesTotalLen = 0;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// [field] [size] [data]
|
|
29
|
-
prop.edgesTotalLen += 1 + 2 + edge.len; // field len
|
|
30
|
-
}
|
|
32
|
+
prop.edgeMainLen += edge.len;
|
|
31
33
|
if (edge.typeIndex === ENUM) {
|
|
32
34
|
edge.enum = Array.isArray(refProp[key])
|
|
33
35
|
? refProp[key]
|
|
@@ -44,7 +46,12 @@ export const addEdges = (prop, refProp) => {
|
|
|
44
46
|
edge.inverseTypeName = refProp[key].ref;
|
|
45
47
|
}
|
|
46
48
|
prop.edges[key] = edge;
|
|
47
|
-
|
|
49
|
+
if (separate) {
|
|
50
|
+
prop.reverseSeperateEdges[edge.prop] = edge;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
prop.reverseMainEdges[edge.start] = edge;
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
57
|
};
|
package/dist/def/selvaBuffer.js
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
import { ALIAS, ALIASES, BINARY,
|
|
1
|
+
import { ALIAS, ALIASES, BINARY, EMPTY_MICRO_BUFFER, CARDINALITY, MICRO_BUFFER, REFERENCE, REFERENCES, STRING, TEXT, VECTOR, WEAK_REFERENCE, WEAK_REFERENCES, JSON, } from './types.js';
|
|
2
2
|
const selvaTypeMap = new Uint8Array(32); // 1.2x faster than JS array
|
|
3
|
-
selvaTypeMap[
|
|
4
|
-
selvaTypeMap[
|
|
5
|
-
selvaTypeMap[
|
|
6
|
-
selvaTypeMap[
|
|
7
|
-
selvaTypeMap[
|
|
8
|
-
selvaTypeMap[
|
|
9
|
-
selvaTypeMap[
|
|
10
|
-
selvaTypeMap[
|
|
11
|
-
selvaTypeMap[
|
|
12
|
-
selvaTypeMap[
|
|
13
|
-
selvaTypeMap[
|
|
14
|
-
selvaTypeMap[
|
|
15
|
-
selvaTypeMap[
|
|
16
|
-
selvaTypeMap[ENUM] = 10;
|
|
17
|
-
selvaTypeMap[STRING] = 11;
|
|
18
|
-
selvaTypeMap[TEXT] = 12;
|
|
19
|
-
selvaTypeMap[REFERENCE] = 13;
|
|
20
|
-
selvaTypeMap[REFERENCES] = 14;
|
|
21
|
-
selvaTypeMap[WEAK_REFERENCE] = 15;
|
|
22
|
-
selvaTypeMap[WEAK_REFERENCES] = 16;
|
|
23
|
-
selvaTypeMap[MICRO_BUFFER] = 17;
|
|
24
|
-
selvaTypeMap[ALIAS] = 18;
|
|
25
|
-
selvaTypeMap[ALIASES] = 19;
|
|
26
|
-
selvaTypeMap[BINARY] = 11;
|
|
27
|
-
selvaTypeMap[VECTOR] = 17;
|
|
28
|
-
selvaTypeMap[JSON] = 11;
|
|
3
|
+
selvaTypeMap[MICRO_BUFFER] = 1;
|
|
4
|
+
selvaTypeMap[VECTOR] = 1;
|
|
5
|
+
selvaTypeMap[BINARY] = 2;
|
|
6
|
+
selvaTypeMap[CARDINALITY] = 2;
|
|
7
|
+
selvaTypeMap[JSON] = 2;
|
|
8
|
+
selvaTypeMap[STRING] = 2;
|
|
9
|
+
selvaTypeMap[TEXT] = 3;
|
|
10
|
+
selvaTypeMap[REFERENCE] = 4;
|
|
11
|
+
selvaTypeMap[REFERENCES] = 5;
|
|
12
|
+
selvaTypeMap[WEAK_REFERENCE] = 6;
|
|
13
|
+
selvaTypeMap[WEAK_REFERENCES] = 7;
|
|
14
|
+
selvaTypeMap[ALIAS] = 8;
|
|
15
|
+
selvaTypeMap[ALIASES] = 9;
|
|
29
16
|
const EDGE_FIELD_CONSTRAINT_FLAG_DEPENDENT = 0x01;
|
|
30
17
|
function blockCapacity(blockCapacity) {
|
|
31
18
|
const buf = new Uint8Array(Uint32Array.BYTES_PER_ELEMENT);
|
|
@@ -64,12 +51,26 @@ const propDefBuffer = (schema, prop, isEdge) => {
|
|
|
64
51
|
prop.inversePropNumber = dstType.props[prop.inversePropName].prop;
|
|
65
52
|
buf[4] = prop.inversePropNumber;
|
|
66
53
|
if (prop.edges) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
const edgesS = Object.values(prop.edges);
|
|
55
|
+
if (edgesS.length) {
|
|
56
|
+
const props = edgesS
|
|
57
|
+
.filter((v) => v.separate === true)
|
|
58
|
+
.sort((a, b) => (a.prop > b.prop ? 1 : -1));
|
|
59
|
+
const p = [
|
|
60
|
+
{
|
|
61
|
+
...EMPTY_MICRO_BUFFER,
|
|
62
|
+
len: prop.edgeMainLen || 1, // allow zero here... else useless padding
|
|
63
|
+
__isEdgeDef: true,
|
|
64
|
+
},
|
|
65
|
+
// or handle this here...
|
|
66
|
+
...props,
|
|
67
|
+
];
|
|
68
|
+
eschema = p
|
|
69
|
+
.map((prop) => propDefBuffer(schema, prop, true))
|
|
70
|
+
.flat(1);
|
|
71
|
+
eschema.unshift(0, 0, 0, 0, sepPropCount(p), 0);
|
|
72
|
+
view.setUint32(5, eschema.length, true);
|
|
73
|
+
}
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
return [...buf, ...eschema];
|
package/dist/def/types.d.ts
CHANGED
|
@@ -68,18 +68,22 @@ export type PropDef = {
|
|
|
68
68
|
inverseTypeId?: number;
|
|
69
69
|
inversePropNumber?: number;
|
|
70
70
|
enum?: any[];
|
|
71
|
+
dependent?: boolean;
|
|
72
|
+
edgeMainLen?: 0;
|
|
71
73
|
reverseEnum?: {
|
|
72
74
|
[key: string]: number;
|
|
73
75
|
};
|
|
74
|
-
|
|
76
|
+
edgesSeperateCnt?: number;
|
|
75
77
|
edges?: {
|
|
76
78
|
[key: string]: PropDefEdge;
|
|
77
79
|
};
|
|
78
|
-
|
|
80
|
+
reverseSeperateEdges?: {
|
|
79
81
|
[prop: string]: PropDefEdge;
|
|
80
82
|
};
|
|
83
|
+
reverseMainEdges?: {
|
|
84
|
+
[start: string]: PropDefEdge;
|
|
85
|
+
};
|
|
81
86
|
__isEdge?: boolean;
|
|
82
|
-
dependent?: boolean;
|
|
83
87
|
};
|
|
84
88
|
export type PropDefEdge = Partial<PropDef> & {
|
|
85
89
|
__isPropDef: true;
|
|
@@ -90,6 +94,13 @@ export type PropDefEdge = Partial<PropDef> & {
|
|
|
90
94
|
edgesTotalLen?: number;
|
|
91
95
|
__isEdge: true;
|
|
92
96
|
};
|
|
97
|
+
export type PropDefAggregate = Partial<PropDef> & {
|
|
98
|
+
__isPropDef: true;
|
|
99
|
+
typeIndex: TypeIndex;
|
|
100
|
+
len: number;
|
|
101
|
+
prop: number;
|
|
102
|
+
name: string;
|
|
103
|
+
};
|
|
93
104
|
export type SchemaPropTree = {
|
|
94
105
|
[key: string]: SchemaPropTree | PropDef;
|
|
95
106
|
};
|
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];
|