@prisma/param-graph 7.4.0-integration-parameterization.8 → 7.4.0-integration-parameterization.10
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/serialization.js +224 -289
- package/dist/serialization.mjs +224 -289
- package/package.json +1 -1
package/dist/serialization.js
CHANGED
|
@@ -22,329 +22,264 @@ __export(serialization_exports, {
|
|
|
22
22
|
serializeParamGraph: () => serializeParamGraph
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(serialization_exports);
|
|
25
|
+
function serializeParamGraph(data) {
|
|
26
|
+
return new Serializer(data).serialize();
|
|
27
|
+
}
|
|
28
|
+
function deserializeParamGraph(serialized) {
|
|
29
|
+
return new Deserializer(serialized).deserialize();
|
|
30
|
+
}
|
|
25
31
|
const FORMAT_COMPACT = 0;
|
|
26
32
|
const FORMAT_WIDE = 1;
|
|
27
33
|
const NONE_16 = 65535;
|
|
28
34
|
const NONE_32 = 4294967295;
|
|
29
35
|
const MAX_COMPACT_INDEX = 65534;
|
|
30
|
-
const BASE64URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
31
36
|
function encodeBase64url(bytes) {
|
|
32
|
-
|
|
33
|
-
const len = bytes.length;
|
|
34
|
-
let i = 0;
|
|
35
|
-
while (i < len) {
|
|
36
|
-
const b0 = bytes[i++];
|
|
37
|
-
const hasB1 = i < len;
|
|
38
|
-
const b1 = hasB1 ? bytes[i++] : 0;
|
|
39
|
-
const hasB2 = i < len;
|
|
40
|
-
const b2 = hasB2 ? bytes[i++] : 0;
|
|
41
|
-
result += BASE64URL_CHARS[b0 >> 2 & 63];
|
|
42
|
-
result += BASE64URL_CHARS[(b0 << 4 | b1 >> 4) & 63];
|
|
43
|
-
if (hasB1) {
|
|
44
|
-
result += BASE64URL_CHARS[(b1 << 2 | b2 >> 6) & 63];
|
|
45
|
-
}
|
|
46
|
-
if (hasB2) {
|
|
47
|
-
result += BASE64URL_CHARS[b2 & 63];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
37
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64url");
|
|
51
38
|
}
|
|
52
39
|
function decodeBase64url(str) {
|
|
53
|
-
|
|
54
|
-
for (let i = 0; i < BASE64URL_CHARS.length; i++) {
|
|
55
|
-
charToIndex[BASE64URL_CHARS.charCodeAt(i)] = i;
|
|
56
|
-
}
|
|
57
|
-
const len = str.length;
|
|
58
|
-
const outputLen = Math.floor(len * 3 / 4);
|
|
59
|
-
const bytes = new Uint8Array(outputLen);
|
|
60
|
-
let bi = 0;
|
|
61
|
-
for (let i = 0; i < len; ) {
|
|
62
|
-
const c0 = charToIndex[str.charCodeAt(i++)];
|
|
63
|
-
const c1 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
|
|
64
|
-
const c2 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
|
|
65
|
-
const c3 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
|
|
66
|
-
bytes[bi++] = c0 << 2 | c1 >> 4;
|
|
67
|
-
if (bi < outputLen) bytes[bi++] = (c1 << 4 | c2 >> 2) & 255;
|
|
68
|
-
if (bi < outputLen) bytes[bi++] = (c2 << 6 | c3) & 255;
|
|
69
|
-
}
|
|
70
|
-
return bytes;
|
|
40
|
+
return Buffer.from(str, "base64url");
|
|
71
41
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
42
|
+
class Serializer {
|
|
43
|
+
#data;
|
|
44
|
+
#useWide;
|
|
45
|
+
#buffer;
|
|
46
|
+
#view;
|
|
47
|
+
#offset = 0;
|
|
48
|
+
#rootKeys;
|
|
49
|
+
constructor(data) {
|
|
50
|
+
this.#data = data;
|
|
51
|
+
this.#rootKeys = Object.keys(data.roots);
|
|
52
|
+
const maxIndex = Math.max(
|
|
53
|
+
data.strings.length,
|
|
54
|
+
data.inputNodes.length,
|
|
55
|
+
data.outputNodes.length,
|
|
56
|
+
this.#rootKeys.length
|
|
57
|
+
);
|
|
58
|
+
this.#useWide = maxIndex > MAX_COMPACT_INDEX;
|
|
59
|
+
const size = this.#calculateBufferSize();
|
|
60
|
+
this.#buffer = new ArrayBuffer(size);
|
|
61
|
+
this.#view = new DataView(this.#buffer);
|
|
62
|
+
}
|
|
63
|
+
serialize() {
|
|
64
|
+
this.#writeHeader();
|
|
65
|
+
this.#writeInputNodes();
|
|
66
|
+
this.#writeOutputNodes();
|
|
67
|
+
this.#writeRoots();
|
|
68
|
+
return {
|
|
69
|
+
strings: this.#data.strings,
|
|
70
|
+
graph: encodeBase64url(new Uint8Array(this.#buffer))
|
|
71
|
+
};
|
|
87
72
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const edgeCount = Object.keys(node.edges).length;
|
|
91
|
-
size += edgeCount * (useWide ? 12 : 6);
|
|
73
|
+
get #wordSize() {
|
|
74
|
+
return this.#useWide ? 4 : 2;
|
|
92
75
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const view = new DataView(buffer);
|
|
96
|
-
let offset = 0;
|
|
97
|
-
view.setUint8(offset++, useWide ? FORMAT_WIDE : FORMAT_COMPACT);
|
|
98
|
-
if (useWide) {
|
|
99
|
-
view.setUint32(offset, data.inputNodes.length, true);
|
|
100
|
-
offset += 4;
|
|
101
|
-
view.setUint32(offset, data.outputNodes.length, true);
|
|
102
|
-
offset += 4;
|
|
103
|
-
view.setUint32(offset, rootKeys.length, true);
|
|
104
|
-
offset += 4;
|
|
105
|
-
} else {
|
|
106
|
-
view.setUint16(offset, data.inputNodes.length, true);
|
|
107
|
-
offset += 2;
|
|
108
|
-
view.setUint16(offset, data.outputNodes.length, true);
|
|
109
|
-
offset += 2;
|
|
110
|
-
view.setUint16(offset, rootKeys.length, true);
|
|
111
|
-
offset += 2;
|
|
76
|
+
get #noneValue() {
|
|
77
|
+
return this.#useWide ? NONE_32 : NONE_16;
|
|
112
78
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
view.setUint32(offset, fieldIndices.length, true);
|
|
117
|
-
offset += 4;
|
|
79
|
+
#writeWord(value) {
|
|
80
|
+
if (this.#useWide) {
|
|
81
|
+
this.#view.setUint32(this.#offset, value, true);
|
|
118
82
|
} else {
|
|
119
|
-
view.setUint16(offset,
|
|
120
|
-
offset += 2;
|
|
83
|
+
this.#view.setUint16(this.#offset, value, true);
|
|
121
84
|
}
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
85
|
+
this.#offset += this.#wordSize;
|
|
86
|
+
}
|
|
87
|
+
#writeOptionalWord(value) {
|
|
88
|
+
this.#writeWord(value ?? this.#noneValue);
|
|
89
|
+
}
|
|
90
|
+
#writeByte(value) {
|
|
91
|
+
this.#view.setUint8(this.#offset, value);
|
|
92
|
+
this.#offset += 1;
|
|
93
|
+
}
|
|
94
|
+
#writeU16(value) {
|
|
95
|
+
this.#view.setUint16(this.#offset, value, true);
|
|
96
|
+
this.#offset += 2;
|
|
97
|
+
}
|
|
98
|
+
#skip(bytes) {
|
|
99
|
+
this.#offset += bytes;
|
|
100
|
+
}
|
|
101
|
+
#calculateBufferSize() {
|
|
102
|
+
let size = 1;
|
|
103
|
+
size += this.#useWide ? 12 : 6;
|
|
104
|
+
for (const node of this.#data.inputNodes) {
|
|
105
|
+
size += this.#wordSize;
|
|
106
|
+
const edgeCount = Object.keys(node.edges).length;
|
|
107
|
+
size += edgeCount * (this.#useWide ? 20 : 10);
|
|
108
|
+
}
|
|
109
|
+
for (const node of this.#data.outputNodes) {
|
|
110
|
+
size += this.#wordSize;
|
|
111
|
+
const edgeCount = Object.keys(node.edges).length;
|
|
112
|
+
size += edgeCount * (this.#useWide ? 12 : 6);
|
|
150
113
|
}
|
|
114
|
+
size += this.#rootKeys.length * (this.#useWide ? 12 : 6);
|
|
115
|
+
return size;
|
|
151
116
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
117
|
+
#writeHeader() {
|
|
118
|
+
this.#writeByte(this.#useWide ? FORMAT_WIDE : FORMAT_COMPACT);
|
|
119
|
+
this.#writeWord(this.#data.inputNodes.length);
|
|
120
|
+
this.#writeWord(this.#data.outputNodes.length);
|
|
121
|
+
this.#writeWord(this.#rootKeys.length);
|
|
122
|
+
}
|
|
123
|
+
#writeInputNodes() {
|
|
124
|
+
for (const node of this.#data.inputNodes) {
|
|
125
|
+
const fieldIndices = Object.keys(node.edges).map(Number);
|
|
126
|
+
this.#writeWord(fieldIndices.length);
|
|
127
|
+
for (const fieldIndex of fieldIndices) {
|
|
128
|
+
const edge = node.edges[fieldIndex];
|
|
129
|
+
this.#writeWord(fieldIndex);
|
|
130
|
+
this.#writeU16(edge.scalarMask ?? 0);
|
|
131
|
+
if (this.#useWide) {
|
|
132
|
+
this.#skip(2);
|
|
133
|
+
}
|
|
134
|
+
this.#writeOptionalWord(edge.childNodeId);
|
|
135
|
+
this.#writeOptionalWord(edge.enumNameIndex);
|
|
136
|
+
this.#writeByte(edge.flags);
|
|
137
|
+
this.#skip(this.#useWide ? 3 : 1);
|
|
138
|
+
}
|
|
160
139
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
view.setUint16(offset, fieldIndex, true);
|
|
172
|
-
offset += 2;
|
|
173
|
-
view.setUint16(offset, edge.argsNodeId ?? NONE_16, true);
|
|
174
|
-
offset += 2;
|
|
175
|
-
view.setUint16(offset, edge.outputNodeId ?? NONE_16, true);
|
|
176
|
-
offset += 2;
|
|
140
|
+
}
|
|
141
|
+
#writeOutputNodes() {
|
|
142
|
+
for (const node of this.#data.outputNodes) {
|
|
143
|
+
const fieldIndices = Object.keys(node.edges).map(Number);
|
|
144
|
+
this.#writeWord(fieldIndices.length);
|
|
145
|
+
for (const fieldIndex of fieldIndices) {
|
|
146
|
+
const edge = node.edges[fieldIndex];
|
|
147
|
+
this.#writeWord(fieldIndex);
|
|
148
|
+
this.#writeOptionalWord(edge.argsNodeId);
|
|
149
|
+
this.#writeOptionalWord(edge.outputNodeId);
|
|
177
150
|
}
|
|
178
151
|
}
|
|
179
152
|
}
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
offset += 4;
|
|
188
|
-
view.setUint32(offset, root.outputNodeId ?? NONE_32, true);
|
|
189
|
-
offset += 4;
|
|
190
|
-
} else {
|
|
191
|
-
view.setUint16(offset, keyIndex, true);
|
|
192
|
-
offset += 2;
|
|
193
|
-
view.setUint16(offset, root.argsNodeId ?? NONE_16, true);
|
|
194
|
-
offset += 2;
|
|
195
|
-
view.setUint16(offset, root.outputNodeId ?? NONE_16, true);
|
|
196
|
-
offset += 2;
|
|
153
|
+
#writeRoots() {
|
|
154
|
+
for (const key of this.#rootKeys) {
|
|
155
|
+
const root = this.#data.roots[key];
|
|
156
|
+
const keyIndex = this.#data.strings.indexOf(key);
|
|
157
|
+
this.#writeWord(keyIndex);
|
|
158
|
+
this.#writeOptionalWord(root.argsNodeId);
|
|
159
|
+
this.#writeOptionalWord(root.outputNodeId);
|
|
197
160
|
}
|
|
198
161
|
}
|
|
199
|
-
return {
|
|
200
|
-
strings: data.strings,
|
|
201
|
-
graph: encodeBase64url(new Uint8Array(buffer))
|
|
202
|
-
};
|
|
203
162
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
163
|
+
class Deserializer {
|
|
164
|
+
#serialized;
|
|
165
|
+
#view;
|
|
166
|
+
#offset = 0;
|
|
167
|
+
#useWide = false;
|
|
168
|
+
constructor(serialized) {
|
|
169
|
+
this.#serialized = serialized;
|
|
170
|
+
const bytes = decodeBase64url(serialized.graph);
|
|
171
|
+
this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
172
|
+
}
|
|
173
|
+
deserialize() {
|
|
174
|
+
const { inputNodeCount, outputNodeCount, rootCount } = this.#readHeader();
|
|
175
|
+
const inputNodes = this.#readInputNodes(inputNodeCount);
|
|
176
|
+
const outputNodes = this.#readOutputNodes(outputNodeCount);
|
|
177
|
+
const roots = this.#readRoots(rootCount);
|
|
178
|
+
return {
|
|
179
|
+
strings: this.#serialized.strings,
|
|
180
|
+
inputNodes,
|
|
181
|
+
outputNodes,
|
|
182
|
+
roots
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
get #wordSize() {
|
|
186
|
+
return this.#useWide ? 4 : 2;
|
|
187
|
+
}
|
|
188
|
+
get #noneValue() {
|
|
189
|
+
return this.#useWide ? NONE_32 : NONE_16;
|
|
227
190
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
edgeCount = view.getUint32(offset, true);
|
|
233
|
-
offset += 4;
|
|
191
|
+
#readWord() {
|
|
192
|
+
let value;
|
|
193
|
+
if (this.#useWide) {
|
|
194
|
+
value = this.#view.getUint32(this.#offset, true);
|
|
234
195
|
} else {
|
|
235
|
-
|
|
236
|
-
offset += 2;
|
|
196
|
+
value = this.#view.getUint16(this.#offset, true);
|
|
237
197
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
198
|
+
this.#offset += this.#wordSize;
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
#readOptionalWord() {
|
|
202
|
+
const value = this.#readWord();
|
|
203
|
+
return value === this.#noneValue ? void 0 : value;
|
|
204
|
+
}
|
|
205
|
+
#readByte() {
|
|
206
|
+
const value = this.#view.getUint8(this.#offset);
|
|
207
|
+
this.#offset += 1;
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
#readU16() {
|
|
211
|
+
const value = this.#view.getUint16(this.#offset, true);
|
|
212
|
+
this.#offset += 2;
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
#skip(bytes) {
|
|
216
|
+
this.#offset += bytes;
|
|
217
|
+
}
|
|
218
|
+
#readHeader() {
|
|
219
|
+
const format = this.#readByte();
|
|
220
|
+
this.#useWide = format === FORMAT_WIDE;
|
|
221
|
+
const inputNodeCount = this.#readWord();
|
|
222
|
+
const outputNodeCount = this.#readWord();
|
|
223
|
+
const rootCount = this.#readWord();
|
|
224
|
+
return { inputNodeCount, outputNodeCount, rootCount };
|
|
225
|
+
}
|
|
226
|
+
#readInputNodes(count) {
|
|
227
|
+
const inputNodes = [];
|
|
228
|
+
for (let i = 0; i < count; i++) {
|
|
229
|
+
const edgeCount = this.#readWord();
|
|
230
|
+
const edges = {};
|
|
231
|
+
for (let j = 0; j < edgeCount; j++) {
|
|
232
|
+
const fieldIndex = this.#readWord();
|
|
233
|
+
const scalarMask = this.#readU16();
|
|
234
|
+
if (this.#useWide) {
|
|
235
|
+
this.#skip(2);
|
|
236
|
+
}
|
|
237
|
+
const childNodeId = this.#readOptionalWord();
|
|
238
|
+
const enumNameIndex = this.#readOptionalWord();
|
|
239
|
+
const flags = this.#readByte();
|
|
240
|
+
this.#skip(this.#useWide ? 3 : 1);
|
|
241
|
+
const edge = { flags };
|
|
242
|
+
if (scalarMask !== 0) edge.scalarMask = scalarMask;
|
|
243
|
+
if (childNodeId !== void 0) edge.childNodeId = childNodeId;
|
|
244
|
+
if (enumNameIndex !== void 0) edge.enumNameIndex = enumNameIndex;
|
|
245
|
+
edges[fieldIndex] = edge;
|
|
270
246
|
}
|
|
271
|
-
|
|
272
|
-
if (scalarMask !== 0) edge.scalarMask = scalarMask;
|
|
273
|
-
if (childNodeId !== (useWide ? NONE_32 : NONE_16)) edge.childNodeId = childNodeId;
|
|
274
|
-
if (enumNameIndex !== (useWide ? NONE_32 : NONE_16)) edge.enumNameIndex = enumNameIndex;
|
|
275
|
-
edges[fieldIndex] = edge;
|
|
247
|
+
inputNodes.push({ edges });
|
|
276
248
|
}
|
|
277
|
-
inputNodes
|
|
249
|
+
return inputNodes;
|
|
278
250
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
let argsNodeId;
|
|
293
|
-
let outputNodeId;
|
|
294
|
-
if (useWide) {
|
|
295
|
-
fieldIndex = view.getUint32(offset, true);
|
|
296
|
-
offset += 4;
|
|
297
|
-
argsNodeId = view.getUint32(offset, true);
|
|
298
|
-
offset += 4;
|
|
299
|
-
outputNodeId = view.getUint32(offset, true);
|
|
300
|
-
offset += 4;
|
|
301
|
-
} else {
|
|
302
|
-
fieldIndex = view.getUint16(offset, true);
|
|
303
|
-
offset += 2;
|
|
304
|
-
argsNodeId = view.getUint16(offset, true);
|
|
305
|
-
offset += 2;
|
|
306
|
-
outputNodeId = view.getUint16(offset, true);
|
|
307
|
-
offset += 2;
|
|
251
|
+
#readOutputNodes(count) {
|
|
252
|
+
const outputNodes = [];
|
|
253
|
+
for (let i = 0; i < count; i++) {
|
|
254
|
+
const edgeCount = this.#readWord();
|
|
255
|
+
const edges = {};
|
|
256
|
+
for (let j = 0; j < edgeCount; j++) {
|
|
257
|
+
const fieldIndex = this.#readWord();
|
|
258
|
+
const argsNodeId = this.#readOptionalWord();
|
|
259
|
+
const outputNodeId = this.#readOptionalWord();
|
|
260
|
+
const edge = {};
|
|
261
|
+
if (argsNodeId !== void 0) edge.argsNodeId = argsNodeId;
|
|
262
|
+
if (outputNodeId !== void 0) edge.outputNodeId = outputNodeId;
|
|
263
|
+
edges[fieldIndex] = edge;
|
|
308
264
|
}
|
|
309
|
-
|
|
310
|
-
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) edge.argsNodeId = argsNodeId;
|
|
311
|
-
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) edge.outputNodeId = outputNodeId;
|
|
312
|
-
edges[fieldIndex] = edge;
|
|
265
|
+
outputNodes.push({ edges });
|
|
313
266
|
}
|
|
314
|
-
outputNodes
|
|
267
|
+
return outputNodes;
|
|
315
268
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
let
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
argsNodeId
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
offset += 4;
|
|
328
|
-
} else {
|
|
329
|
-
keyIndex = view.getUint16(offset, true);
|
|
330
|
-
offset += 2;
|
|
331
|
-
argsNodeId = view.getUint16(offset, true);
|
|
332
|
-
offset += 2;
|
|
333
|
-
outputNodeId = view.getUint16(offset, true);
|
|
334
|
-
offset += 2;
|
|
269
|
+
#readRoots(count) {
|
|
270
|
+
const roots = {};
|
|
271
|
+
for (let i = 0; i < count; i++) {
|
|
272
|
+
const keyIndex = this.#readWord();
|
|
273
|
+
const argsNodeId = this.#readOptionalWord();
|
|
274
|
+
const outputNodeId = this.#readOptionalWord();
|
|
275
|
+
const key = this.#serialized.strings[keyIndex];
|
|
276
|
+
const root = {};
|
|
277
|
+
if (argsNodeId !== void 0) root.argsNodeId = argsNodeId;
|
|
278
|
+
if (outputNodeId !== void 0) root.outputNodeId = outputNodeId;
|
|
279
|
+
roots[key] = root;
|
|
335
280
|
}
|
|
336
|
-
|
|
337
|
-
const root = {};
|
|
338
|
-
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) root.argsNodeId = argsNodeId;
|
|
339
|
-
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) root.outputNodeId = outputNodeId;
|
|
340
|
-
roots[key] = root;
|
|
281
|
+
return roots;
|
|
341
282
|
}
|
|
342
|
-
return {
|
|
343
|
-
strings: serialized.strings,
|
|
344
|
-
inputNodes,
|
|
345
|
-
outputNodes,
|
|
346
|
-
roots
|
|
347
|
-
};
|
|
348
283
|
}
|
|
349
284
|
// Annotate the CommonJS export names for ESM import in node:
|
|
350
285
|
0 && (module.exports = {
|
package/dist/serialization.mjs
CHANGED
|
@@ -1,326 +1,261 @@
|
|
|
1
|
+
function serializeParamGraph(data) {
|
|
2
|
+
return new Serializer(data).serialize();
|
|
3
|
+
}
|
|
4
|
+
function deserializeParamGraph(serialized) {
|
|
5
|
+
return new Deserializer(serialized).deserialize();
|
|
6
|
+
}
|
|
1
7
|
const FORMAT_COMPACT = 0;
|
|
2
8
|
const FORMAT_WIDE = 1;
|
|
3
9
|
const NONE_16 = 65535;
|
|
4
10
|
const NONE_32 = 4294967295;
|
|
5
11
|
const MAX_COMPACT_INDEX = 65534;
|
|
6
|
-
const BASE64URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
7
12
|
function encodeBase64url(bytes) {
|
|
8
|
-
|
|
9
|
-
const len = bytes.length;
|
|
10
|
-
let i = 0;
|
|
11
|
-
while (i < len) {
|
|
12
|
-
const b0 = bytes[i++];
|
|
13
|
-
const hasB1 = i < len;
|
|
14
|
-
const b1 = hasB1 ? bytes[i++] : 0;
|
|
15
|
-
const hasB2 = i < len;
|
|
16
|
-
const b2 = hasB2 ? bytes[i++] : 0;
|
|
17
|
-
result += BASE64URL_CHARS[b0 >> 2 & 63];
|
|
18
|
-
result += BASE64URL_CHARS[(b0 << 4 | b1 >> 4) & 63];
|
|
19
|
-
if (hasB1) {
|
|
20
|
-
result += BASE64URL_CHARS[(b1 << 2 | b2 >> 6) & 63];
|
|
21
|
-
}
|
|
22
|
-
if (hasB2) {
|
|
23
|
-
result += BASE64URL_CHARS[b2 & 63];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
13
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64url");
|
|
27
14
|
}
|
|
28
15
|
function decodeBase64url(str) {
|
|
29
|
-
|
|
30
|
-
for (let i = 0; i < BASE64URL_CHARS.length; i++) {
|
|
31
|
-
charToIndex[BASE64URL_CHARS.charCodeAt(i)] = i;
|
|
32
|
-
}
|
|
33
|
-
const len = str.length;
|
|
34
|
-
const outputLen = Math.floor(len * 3 / 4);
|
|
35
|
-
const bytes = new Uint8Array(outputLen);
|
|
36
|
-
let bi = 0;
|
|
37
|
-
for (let i = 0; i < len; ) {
|
|
38
|
-
const c0 = charToIndex[str.charCodeAt(i++)];
|
|
39
|
-
const c1 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
|
|
40
|
-
const c2 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
|
|
41
|
-
const c3 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
|
|
42
|
-
bytes[bi++] = c0 << 2 | c1 >> 4;
|
|
43
|
-
if (bi < outputLen) bytes[bi++] = (c1 << 4 | c2 >> 2) & 255;
|
|
44
|
-
if (bi < outputLen) bytes[bi++] = (c2 << 6 | c3) & 255;
|
|
45
|
-
}
|
|
46
|
-
return bytes;
|
|
16
|
+
return Buffer.from(str, "base64url");
|
|
47
17
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
18
|
+
class Serializer {
|
|
19
|
+
#data;
|
|
20
|
+
#useWide;
|
|
21
|
+
#buffer;
|
|
22
|
+
#view;
|
|
23
|
+
#offset = 0;
|
|
24
|
+
#rootKeys;
|
|
25
|
+
constructor(data) {
|
|
26
|
+
this.#data = data;
|
|
27
|
+
this.#rootKeys = Object.keys(data.roots);
|
|
28
|
+
const maxIndex = Math.max(
|
|
29
|
+
data.strings.length,
|
|
30
|
+
data.inputNodes.length,
|
|
31
|
+
data.outputNodes.length,
|
|
32
|
+
this.#rootKeys.length
|
|
33
|
+
);
|
|
34
|
+
this.#useWide = maxIndex > MAX_COMPACT_INDEX;
|
|
35
|
+
const size = this.#calculateBufferSize();
|
|
36
|
+
this.#buffer = new ArrayBuffer(size);
|
|
37
|
+
this.#view = new DataView(this.#buffer);
|
|
38
|
+
}
|
|
39
|
+
serialize() {
|
|
40
|
+
this.#writeHeader();
|
|
41
|
+
this.#writeInputNodes();
|
|
42
|
+
this.#writeOutputNodes();
|
|
43
|
+
this.#writeRoots();
|
|
44
|
+
return {
|
|
45
|
+
strings: this.#data.strings,
|
|
46
|
+
graph: encodeBase64url(new Uint8Array(this.#buffer))
|
|
47
|
+
};
|
|
63
48
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const edgeCount = Object.keys(node.edges).length;
|
|
67
|
-
size += edgeCount * (useWide ? 12 : 6);
|
|
49
|
+
get #wordSize() {
|
|
50
|
+
return this.#useWide ? 4 : 2;
|
|
68
51
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const view = new DataView(buffer);
|
|
72
|
-
let offset = 0;
|
|
73
|
-
view.setUint8(offset++, useWide ? FORMAT_WIDE : FORMAT_COMPACT);
|
|
74
|
-
if (useWide) {
|
|
75
|
-
view.setUint32(offset, data.inputNodes.length, true);
|
|
76
|
-
offset += 4;
|
|
77
|
-
view.setUint32(offset, data.outputNodes.length, true);
|
|
78
|
-
offset += 4;
|
|
79
|
-
view.setUint32(offset, rootKeys.length, true);
|
|
80
|
-
offset += 4;
|
|
81
|
-
} else {
|
|
82
|
-
view.setUint16(offset, data.inputNodes.length, true);
|
|
83
|
-
offset += 2;
|
|
84
|
-
view.setUint16(offset, data.outputNodes.length, true);
|
|
85
|
-
offset += 2;
|
|
86
|
-
view.setUint16(offset, rootKeys.length, true);
|
|
87
|
-
offset += 2;
|
|
52
|
+
get #noneValue() {
|
|
53
|
+
return this.#useWide ? NONE_32 : NONE_16;
|
|
88
54
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
view.setUint32(offset, fieldIndices.length, true);
|
|
93
|
-
offset += 4;
|
|
55
|
+
#writeWord(value) {
|
|
56
|
+
if (this.#useWide) {
|
|
57
|
+
this.#view.setUint32(this.#offset, value, true);
|
|
94
58
|
} else {
|
|
95
|
-
view.setUint16(offset,
|
|
96
|
-
offset += 2;
|
|
59
|
+
this.#view.setUint16(this.#offset, value, true);
|
|
97
60
|
}
|
|
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
|
-
|
|
61
|
+
this.#offset += this.#wordSize;
|
|
62
|
+
}
|
|
63
|
+
#writeOptionalWord(value) {
|
|
64
|
+
this.#writeWord(value ?? this.#noneValue);
|
|
65
|
+
}
|
|
66
|
+
#writeByte(value) {
|
|
67
|
+
this.#view.setUint8(this.#offset, value);
|
|
68
|
+
this.#offset += 1;
|
|
69
|
+
}
|
|
70
|
+
#writeU16(value) {
|
|
71
|
+
this.#view.setUint16(this.#offset, value, true);
|
|
72
|
+
this.#offset += 2;
|
|
73
|
+
}
|
|
74
|
+
#skip(bytes) {
|
|
75
|
+
this.#offset += bytes;
|
|
76
|
+
}
|
|
77
|
+
#calculateBufferSize() {
|
|
78
|
+
let size = 1;
|
|
79
|
+
size += this.#useWide ? 12 : 6;
|
|
80
|
+
for (const node of this.#data.inputNodes) {
|
|
81
|
+
size += this.#wordSize;
|
|
82
|
+
const edgeCount = Object.keys(node.edges).length;
|
|
83
|
+
size += edgeCount * (this.#useWide ? 20 : 10);
|
|
84
|
+
}
|
|
85
|
+
for (const node of this.#data.outputNodes) {
|
|
86
|
+
size += this.#wordSize;
|
|
87
|
+
const edgeCount = Object.keys(node.edges).length;
|
|
88
|
+
size += edgeCount * (this.#useWide ? 12 : 6);
|
|
126
89
|
}
|
|
90
|
+
size += this.#rootKeys.length * (this.#useWide ? 12 : 6);
|
|
91
|
+
return size;
|
|
127
92
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
93
|
+
#writeHeader() {
|
|
94
|
+
this.#writeByte(this.#useWide ? FORMAT_WIDE : FORMAT_COMPACT);
|
|
95
|
+
this.#writeWord(this.#data.inputNodes.length);
|
|
96
|
+
this.#writeWord(this.#data.outputNodes.length);
|
|
97
|
+
this.#writeWord(this.#rootKeys.length);
|
|
98
|
+
}
|
|
99
|
+
#writeInputNodes() {
|
|
100
|
+
for (const node of this.#data.inputNodes) {
|
|
101
|
+
const fieldIndices = Object.keys(node.edges).map(Number);
|
|
102
|
+
this.#writeWord(fieldIndices.length);
|
|
103
|
+
for (const fieldIndex of fieldIndices) {
|
|
104
|
+
const edge = node.edges[fieldIndex];
|
|
105
|
+
this.#writeWord(fieldIndex);
|
|
106
|
+
this.#writeU16(edge.scalarMask ?? 0);
|
|
107
|
+
if (this.#useWide) {
|
|
108
|
+
this.#skip(2);
|
|
109
|
+
}
|
|
110
|
+
this.#writeOptionalWord(edge.childNodeId);
|
|
111
|
+
this.#writeOptionalWord(edge.enumNameIndex);
|
|
112
|
+
this.#writeByte(edge.flags);
|
|
113
|
+
this.#skip(this.#useWide ? 3 : 1);
|
|
114
|
+
}
|
|
136
115
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
view.setUint16(offset, fieldIndex, true);
|
|
148
|
-
offset += 2;
|
|
149
|
-
view.setUint16(offset, edge.argsNodeId ?? NONE_16, true);
|
|
150
|
-
offset += 2;
|
|
151
|
-
view.setUint16(offset, edge.outputNodeId ?? NONE_16, true);
|
|
152
|
-
offset += 2;
|
|
116
|
+
}
|
|
117
|
+
#writeOutputNodes() {
|
|
118
|
+
for (const node of this.#data.outputNodes) {
|
|
119
|
+
const fieldIndices = Object.keys(node.edges).map(Number);
|
|
120
|
+
this.#writeWord(fieldIndices.length);
|
|
121
|
+
for (const fieldIndex of fieldIndices) {
|
|
122
|
+
const edge = node.edges[fieldIndex];
|
|
123
|
+
this.#writeWord(fieldIndex);
|
|
124
|
+
this.#writeOptionalWord(edge.argsNodeId);
|
|
125
|
+
this.#writeOptionalWord(edge.outputNodeId);
|
|
153
126
|
}
|
|
154
127
|
}
|
|
155
128
|
}
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
offset += 4;
|
|
164
|
-
view.setUint32(offset, root.outputNodeId ?? NONE_32, true);
|
|
165
|
-
offset += 4;
|
|
166
|
-
} else {
|
|
167
|
-
view.setUint16(offset, keyIndex, true);
|
|
168
|
-
offset += 2;
|
|
169
|
-
view.setUint16(offset, root.argsNodeId ?? NONE_16, true);
|
|
170
|
-
offset += 2;
|
|
171
|
-
view.setUint16(offset, root.outputNodeId ?? NONE_16, true);
|
|
172
|
-
offset += 2;
|
|
129
|
+
#writeRoots() {
|
|
130
|
+
for (const key of this.#rootKeys) {
|
|
131
|
+
const root = this.#data.roots[key];
|
|
132
|
+
const keyIndex = this.#data.strings.indexOf(key);
|
|
133
|
+
this.#writeWord(keyIndex);
|
|
134
|
+
this.#writeOptionalWord(root.argsNodeId);
|
|
135
|
+
this.#writeOptionalWord(root.outputNodeId);
|
|
173
136
|
}
|
|
174
137
|
}
|
|
175
|
-
return {
|
|
176
|
-
strings: data.strings,
|
|
177
|
-
graph: encodeBase64url(new Uint8Array(buffer))
|
|
178
|
-
};
|
|
179
138
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
139
|
+
class Deserializer {
|
|
140
|
+
#serialized;
|
|
141
|
+
#view;
|
|
142
|
+
#offset = 0;
|
|
143
|
+
#useWide = false;
|
|
144
|
+
constructor(serialized) {
|
|
145
|
+
this.#serialized = serialized;
|
|
146
|
+
const bytes = decodeBase64url(serialized.graph);
|
|
147
|
+
this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
148
|
+
}
|
|
149
|
+
deserialize() {
|
|
150
|
+
const { inputNodeCount, outputNodeCount, rootCount } = this.#readHeader();
|
|
151
|
+
const inputNodes = this.#readInputNodes(inputNodeCount);
|
|
152
|
+
const outputNodes = this.#readOutputNodes(outputNodeCount);
|
|
153
|
+
const roots = this.#readRoots(rootCount);
|
|
154
|
+
return {
|
|
155
|
+
strings: this.#serialized.strings,
|
|
156
|
+
inputNodes,
|
|
157
|
+
outputNodes,
|
|
158
|
+
roots
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
get #wordSize() {
|
|
162
|
+
return this.#useWide ? 4 : 2;
|
|
163
|
+
}
|
|
164
|
+
get #noneValue() {
|
|
165
|
+
return this.#useWide ? NONE_32 : NONE_16;
|
|
203
166
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
edgeCount = view.getUint32(offset, true);
|
|
209
|
-
offset += 4;
|
|
167
|
+
#readWord() {
|
|
168
|
+
let value;
|
|
169
|
+
if (this.#useWide) {
|
|
170
|
+
value = this.#view.getUint32(this.#offset, true);
|
|
210
171
|
} else {
|
|
211
|
-
|
|
212
|
-
offset += 2;
|
|
172
|
+
value = this.#view.getUint16(this.#offset, true);
|
|
213
173
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
174
|
+
this.#offset += this.#wordSize;
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
#readOptionalWord() {
|
|
178
|
+
const value = this.#readWord();
|
|
179
|
+
return value === this.#noneValue ? void 0 : value;
|
|
180
|
+
}
|
|
181
|
+
#readByte() {
|
|
182
|
+
const value = this.#view.getUint8(this.#offset);
|
|
183
|
+
this.#offset += 1;
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
#readU16() {
|
|
187
|
+
const value = this.#view.getUint16(this.#offset, true);
|
|
188
|
+
this.#offset += 2;
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
#skip(bytes) {
|
|
192
|
+
this.#offset += bytes;
|
|
193
|
+
}
|
|
194
|
+
#readHeader() {
|
|
195
|
+
const format = this.#readByte();
|
|
196
|
+
this.#useWide = format === FORMAT_WIDE;
|
|
197
|
+
const inputNodeCount = this.#readWord();
|
|
198
|
+
const outputNodeCount = this.#readWord();
|
|
199
|
+
const rootCount = this.#readWord();
|
|
200
|
+
return { inputNodeCount, outputNodeCount, rootCount };
|
|
201
|
+
}
|
|
202
|
+
#readInputNodes(count) {
|
|
203
|
+
const inputNodes = [];
|
|
204
|
+
for (let i = 0; i < count; i++) {
|
|
205
|
+
const edgeCount = this.#readWord();
|
|
206
|
+
const edges = {};
|
|
207
|
+
for (let j = 0; j < edgeCount; j++) {
|
|
208
|
+
const fieldIndex = this.#readWord();
|
|
209
|
+
const scalarMask = this.#readU16();
|
|
210
|
+
if (this.#useWide) {
|
|
211
|
+
this.#skip(2);
|
|
212
|
+
}
|
|
213
|
+
const childNodeId = this.#readOptionalWord();
|
|
214
|
+
const enumNameIndex = this.#readOptionalWord();
|
|
215
|
+
const flags = this.#readByte();
|
|
216
|
+
this.#skip(this.#useWide ? 3 : 1);
|
|
217
|
+
const edge = { flags };
|
|
218
|
+
if (scalarMask !== 0) edge.scalarMask = scalarMask;
|
|
219
|
+
if (childNodeId !== void 0) edge.childNodeId = childNodeId;
|
|
220
|
+
if (enumNameIndex !== void 0) edge.enumNameIndex = enumNameIndex;
|
|
221
|
+
edges[fieldIndex] = edge;
|
|
246
222
|
}
|
|
247
|
-
|
|
248
|
-
if (scalarMask !== 0) edge.scalarMask = scalarMask;
|
|
249
|
-
if (childNodeId !== (useWide ? NONE_32 : NONE_16)) edge.childNodeId = childNodeId;
|
|
250
|
-
if (enumNameIndex !== (useWide ? NONE_32 : NONE_16)) edge.enumNameIndex = enumNameIndex;
|
|
251
|
-
edges[fieldIndex] = edge;
|
|
223
|
+
inputNodes.push({ edges });
|
|
252
224
|
}
|
|
253
|
-
inputNodes
|
|
225
|
+
return inputNodes;
|
|
254
226
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
let
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
let argsNodeId;
|
|
269
|
-
let outputNodeId;
|
|
270
|
-
if (useWide) {
|
|
271
|
-
fieldIndex = view.getUint32(offset, true);
|
|
272
|
-
offset += 4;
|
|
273
|
-
argsNodeId = view.getUint32(offset, true);
|
|
274
|
-
offset += 4;
|
|
275
|
-
outputNodeId = view.getUint32(offset, true);
|
|
276
|
-
offset += 4;
|
|
277
|
-
} else {
|
|
278
|
-
fieldIndex = view.getUint16(offset, true);
|
|
279
|
-
offset += 2;
|
|
280
|
-
argsNodeId = view.getUint16(offset, true);
|
|
281
|
-
offset += 2;
|
|
282
|
-
outputNodeId = view.getUint16(offset, true);
|
|
283
|
-
offset += 2;
|
|
227
|
+
#readOutputNodes(count) {
|
|
228
|
+
const outputNodes = [];
|
|
229
|
+
for (let i = 0; i < count; i++) {
|
|
230
|
+
const edgeCount = this.#readWord();
|
|
231
|
+
const edges = {};
|
|
232
|
+
for (let j = 0; j < edgeCount; j++) {
|
|
233
|
+
const fieldIndex = this.#readWord();
|
|
234
|
+
const argsNodeId = this.#readOptionalWord();
|
|
235
|
+
const outputNodeId = this.#readOptionalWord();
|
|
236
|
+
const edge = {};
|
|
237
|
+
if (argsNodeId !== void 0) edge.argsNodeId = argsNodeId;
|
|
238
|
+
if (outputNodeId !== void 0) edge.outputNodeId = outputNodeId;
|
|
239
|
+
edges[fieldIndex] = edge;
|
|
284
240
|
}
|
|
285
|
-
|
|
286
|
-
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) edge.argsNodeId = argsNodeId;
|
|
287
|
-
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) edge.outputNodeId = outputNodeId;
|
|
288
|
-
edges[fieldIndex] = edge;
|
|
241
|
+
outputNodes.push({ edges });
|
|
289
242
|
}
|
|
290
|
-
outputNodes
|
|
243
|
+
return outputNodes;
|
|
291
244
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
let
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
argsNodeId
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
offset += 4;
|
|
304
|
-
} else {
|
|
305
|
-
keyIndex = view.getUint16(offset, true);
|
|
306
|
-
offset += 2;
|
|
307
|
-
argsNodeId = view.getUint16(offset, true);
|
|
308
|
-
offset += 2;
|
|
309
|
-
outputNodeId = view.getUint16(offset, true);
|
|
310
|
-
offset += 2;
|
|
245
|
+
#readRoots(count) {
|
|
246
|
+
const roots = {};
|
|
247
|
+
for (let i = 0; i < count; i++) {
|
|
248
|
+
const keyIndex = this.#readWord();
|
|
249
|
+
const argsNodeId = this.#readOptionalWord();
|
|
250
|
+
const outputNodeId = this.#readOptionalWord();
|
|
251
|
+
const key = this.#serialized.strings[keyIndex];
|
|
252
|
+
const root = {};
|
|
253
|
+
if (argsNodeId !== void 0) root.argsNodeId = argsNodeId;
|
|
254
|
+
if (outputNodeId !== void 0) root.outputNodeId = outputNodeId;
|
|
255
|
+
roots[key] = root;
|
|
311
256
|
}
|
|
312
|
-
|
|
313
|
-
const root = {};
|
|
314
|
-
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) root.argsNodeId = argsNodeId;
|
|
315
|
-
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) root.outputNodeId = outputNodeId;
|
|
316
|
-
roots[key] = root;
|
|
257
|
+
return roots;
|
|
317
258
|
}
|
|
318
|
-
return {
|
|
319
|
-
strings: serialized.strings,
|
|
320
|
-
inputNodes,
|
|
321
|
-
outputNodes,
|
|
322
|
-
roots
|
|
323
|
-
};
|
|
324
259
|
}
|
|
325
260
|
export {
|
|
326
261
|
deserializeParamGraph,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/param-graph",
|
|
3
|
-
"version": "7.4.0-integration-parameterization.
|
|
3
|
+
"version": "7.4.0-integration-parameterization.10",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|