@prisma/param-graph 7.7.0-integration-feat-prisma-bootstrap.7 → 7.7.0-integration-feat-bootstrap-ux-fixes.2

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.
@@ -1,276 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var serialization_exports = {};
20
- __export(serialization_exports, {
21
- deserializeParamGraph: () => deserializeParamGraph,
22
- serializeParamGraph: () => serializeParamGraph
23
- });
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
- }
31
- function encodeBase64url(bytes) {
32
- return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64url");
33
- }
34
- function decodeBase64url(str) {
35
- return Buffer.from(str, "base64url");
36
- }
37
- function varuintSize(value) {
38
- let size = 1;
39
- while (value >= 128) {
40
- size++;
41
- value >>>= 7;
42
- }
43
- return size;
44
- }
45
- class Serializer {
46
- #data;
47
- #buffer;
48
- #view;
49
- #offset = 0;
50
- #rootKeys;
51
- constructor(data) {
52
- this.#data = data;
53
- this.#rootKeys = Object.keys(data.roots);
54
- const size = this.#calculateBufferSize();
55
- this.#buffer = new ArrayBuffer(size);
56
- this.#view = new DataView(this.#buffer);
57
- }
58
- serialize() {
59
- this.#writeHeader();
60
- this.#writeInputNodes();
61
- this.#writeOutputNodes();
62
- this.#writeRoots();
63
- return {
64
- strings: this.#data.strings,
65
- graph: encodeBase64url(new Uint8Array(this.#buffer, 0, this.#offset))
66
- };
67
- }
68
- #writeVaruint(value) {
69
- while (value >= 128) {
70
- this.#view.setUint8(this.#offset++, value & 127 | 128);
71
- value >>>= 7;
72
- }
73
- this.#view.setUint8(this.#offset++, value);
74
- }
75
- #writeOptionalVaruint(value) {
76
- this.#writeVaruint(value === void 0 ? 0 : value + 1);
77
- }
78
- #writeByte(value) {
79
- this.#view.setUint8(this.#offset, value);
80
- this.#offset += 1;
81
- }
82
- #writeU16(value) {
83
- this.#view.setUint16(this.#offset, value, true);
84
- this.#offset += 2;
85
- }
86
- #calculateBufferSize() {
87
- let size = 0;
88
- size += varuintSize(this.#data.inputNodes.length);
89
- size += varuintSize(this.#data.outputNodes.length);
90
- size += varuintSize(this.#rootKeys.length);
91
- for (const node of this.#data.inputNodes) {
92
- const fieldIndices = Object.keys(node.edges).map(Number);
93
- size += varuintSize(fieldIndices.length);
94
- for (const fieldIndex of fieldIndices) {
95
- const edge = node.edges[fieldIndex];
96
- size += varuintSize(fieldIndex);
97
- size += 2;
98
- size += varuintSize(edge.childNodeId === void 0 ? 0 : edge.childNodeId + 1);
99
- size += varuintSize(edge.enumNameIndex === void 0 ? 0 : edge.enumNameIndex + 1);
100
- size += 1;
101
- }
102
- }
103
- for (const node of this.#data.outputNodes) {
104
- const fieldIndices = Object.keys(node.edges).map(Number);
105
- size += varuintSize(fieldIndices.length);
106
- for (const fieldIndex of fieldIndices) {
107
- const edge = node.edges[fieldIndex];
108
- size += varuintSize(fieldIndex);
109
- size += varuintSize(edge.argsNodeId === void 0 ? 0 : edge.argsNodeId + 1);
110
- size += varuintSize(edge.outputNodeId === void 0 ? 0 : edge.outputNodeId + 1);
111
- }
112
- }
113
- for (const key of this.#rootKeys) {
114
- const root = this.#data.roots[key];
115
- const keyIndex = this.#data.strings.indexOf(key);
116
- size += varuintSize(keyIndex);
117
- size += varuintSize(root.argsNodeId === void 0 ? 0 : root.argsNodeId + 1);
118
- size += varuintSize(root.outputNodeId === void 0 ? 0 : root.outputNodeId + 1);
119
- }
120
- return size;
121
- }
122
- #writeHeader() {
123
- this.#writeVaruint(this.#data.inputNodes.length);
124
- this.#writeVaruint(this.#data.outputNodes.length);
125
- this.#writeVaruint(this.#rootKeys.length);
126
- }
127
- #writeInputNodes() {
128
- for (const node of this.#data.inputNodes) {
129
- const fieldIndices = Object.keys(node.edges).map(Number);
130
- this.#writeVaruint(fieldIndices.length);
131
- for (const fieldIndex of fieldIndices) {
132
- const edge = node.edges[fieldIndex];
133
- this.#writeVaruint(fieldIndex);
134
- this.#writeU16(edge.scalarMask ?? 0);
135
- this.#writeOptionalVaruint(edge.childNodeId);
136
- this.#writeOptionalVaruint(edge.enumNameIndex);
137
- this.#writeByte(edge.flags);
138
- }
139
- }
140
- }
141
- #writeOutputNodes() {
142
- for (const node of this.#data.outputNodes) {
143
- const fieldIndices = Object.keys(node.edges).map(Number);
144
- this.#writeVaruint(fieldIndices.length);
145
- for (const fieldIndex of fieldIndices) {
146
- const edge = node.edges[fieldIndex];
147
- this.#writeVaruint(fieldIndex);
148
- this.#writeOptionalVaruint(edge.argsNodeId);
149
- this.#writeOptionalVaruint(edge.outputNodeId);
150
- }
151
- }
152
- }
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
- if (keyIndex === -1) {
158
- throw new Error(`Root key "${key}" not found in strings table`);
159
- }
160
- this.#writeVaruint(keyIndex);
161
- this.#writeOptionalVaruint(root.argsNodeId);
162
- this.#writeOptionalVaruint(root.outputNodeId);
163
- }
164
- }
165
- }
166
- class Deserializer {
167
- #serialized;
168
- #view;
169
- #offset = 0;
170
- constructor(serialized) {
171
- this.#serialized = serialized;
172
- const bytes = decodeBase64url(serialized.graph);
173
- this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
174
- }
175
- deserialize() {
176
- const { inputNodeCount, outputNodeCount, rootCount } = this.#readHeader();
177
- const inputNodes = this.#readInputNodes(inputNodeCount);
178
- const outputNodes = this.#readOutputNodes(outputNodeCount);
179
- const roots = this.#readRoots(rootCount);
180
- return {
181
- strings: this.#serialized.strings,
182
- inputNodes,
183
- outputNodes,
184
- roots
185
- };
186
- }
187
- #readVaruint() {
188
- let value = 0;
189
- let shift = 0;
190
- let byte;
191
- do {
192
- byte = this.#view.getUint8(this.#offset++);
193
- value |= (byte & 127) << shift;
194
- shift += 7;
195
- } while (byte >= 128);
196
- return value;
197
- }
198
- #readOptionalVaruint() {
199
- const value = this.#readVaruint();
200
- return value === 0 ? void 0 : value - 1;
201
- }
202
- #readByte() {
203
- const value = this.#view.getUint8(this.#offset);
204
- this.#offset += 1;
205
- return value;
206
- }
207
- #readU16() {
208
- const value = this.#view.getUint16(this.#offset, true);
209
- this.#offset += 2;
210
- return value;
211
- }
212
- #readHeader() {
213
- const inputNodeCount = this.#readVaruint();
214
- const outputNodeCount = this.#readVaruint();
215
- const rootCount = this.#readVaruint();
216
- return { inputNodeCount, outputNodeCount, rootCount };
217
- }
218
- #readInputNodes(count) {
219
- const inputNodes = [];
220
- for (let i = 0; i < count; i++) {
221
- const edgeCount = this.#readVaruint();
222
- const edges = {};
223
- for (let j = 0; j < edgeCount; j++) {
224
- const fieldIndex = this.#readVaruint();
225
- const scalarMask = this.#readU16();
226
- const childNodeId = this.#readOptionalVaruint();
227
- const enumNameIndex = this.#readOptionalVaruint();
228
- const flags = this.#readByte();
229
- const edge = { flags };
230
- if (scalarMask !== 0) edge.scalarMask = scalarMask;
231
- if (childNodeId !== void 0) edge.childNodeId = childNodeId;
232
- if (enumNameIndex !== void 0) edge.enumNameIndex = enumNameIndex;
233
- edges[fieldIndex] = edge;
234
- }
235
- inputNodes.push({ edges });
236
- }
237
- return inputNodes;
238
- }
239
- #readOutputNodes(count) {
240
- const outputNodes = [];
241
- for (let i = 0; i < count; i++) {
242
- const edgeCount = this.#readVaruint();
243
- const edges = {};
244
- for (let j = 0; j < edgeCount; j++) {
245
- const fieldIndex = this.#readVaruint();
246
- const argsNodeId = this.#readOptionalVaruint();
247
- const outputNodeId = this.#readOptionalVaruint();
248
- const edge = {};
249
- if (argsNodeId !== void 0) edge.argsNodeId = argsNodeId;
250
- if (outputNodeId !== void 0) edge.outputNodeId = outputNodeId;
251
- edges[fieldIndex] = edge;
252
- }
253
- outputNodes.push({ edges });
254
- }
255
- return outputNodes;
256
- }
257
- #readRoots(count) {
258
- const roots = {};
259
- for (let i = 0; i < count; i++) {
260
- const keyIndex = this.#readVaruint();
261
- const argsNodeId = this.#readOptionalVaruint();
262
- const outputNodeId = this.#readOptionalVaruint();
263
- const key = this.#serialized.strings[keyIndex];
264
- const root = {};
265
- if (argsNodeId !== void 0) root.argsNodeId = argsNodeId;
266
- if (outputNodeId !== void 0) root.outputNodeId = outputNodeId;
267
- roots[key] = root;
268
- }
269
- return roots;
270
- }
271
- }
272
- // Annotate the CommonJS export names for ESM import in node:
273
- 0 && (module.exports = {
274
- deserializeParamGraph,
275
- serializeParamGraph
276
- });
@@ -1,251 +0,0 @@
1
- function serializeParamGraph(data) {
2
- return new Serializer(data).serialize();
3
- }
4
- function deserializeParamGraph(serialized) {
5
- return new Deserializer(serialized).deserialize();
6
- }
7
- function encodeBase64url(bytes) {
8
- return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64url");
9
- }
10
- function decodeBase64url(str) {
11
- return Buffer.from(str, "base64url");
12
- }
13
- function varuintSize(value) {
14
- let size = 1;
15
- while (value >= 128) {
16
- size++;
17
- value >>>= 7;
18
- }
19
- return size;
20
- }
21
- class Serializer {
22
- #data;
23
- #buffer;
24
- #view;
25
- #offset = 0;
26
- #rootKeys;
27
- constructor(data) {
28
- this.#data = data;
29
- this.#rootKeys = Object.keys(data.roots);
30
- const size = this.#calculateBufferSize();
31
- this.#buffer = new ArrayBuffer(size);
32
- this.#view = new DataView(this.#buffer);
33
- }
34
- serialize() {
35
- this.#writeHeader();
36
- this.#writeInputNodes();
37
- this.#writeOutputNodes();
38
- this.#writeRoots();
39
- return {
40
- strings: this.#data.strings,
41
- graph: encodeBase64url(new Uint8Array(this.#buffer, 0, this.#offset))
42
- };
43
- }
44
- #writeVaruint(value) {
45
- while (value >= 128) {
46
- this.#view.setUint8(this.#offset++, value & 127 | 128);
47
- value >>>= 7;
48
- }
49
- this.#view.setUint8(this.#offset++, value);
50
- }
51
- #writeOptionalVaruint(value) {
52
- this.#writeVaruint(value === void 0 ? 0 : value + 1);
53
- }
54
- #writeByte(value) {
55
- this.#view.setUint8(this.#offset, value);
56
- this.#offset += 1;
57
- }
58
- #writeU16(value) {
59
- this.#view.setUint16(this.#offset, value, true);
60
- this.#offset += 2;
61
- }
62
- #calculateBufferSize() {
63
- let size = 0;
64
- size += varuintSize(this.#data.inputNodes.length);
65
- size += varuintSize(this.#data.outputNodes.length);
66
- size += varuintSize(this.#rootKeys.length);
67
- for (const node of this.#data.inputNodes) {
68
- const fieldIndices = Object.keys(node.edges).map(Number);
69
- size += varuintSize(fieldIndices.length);
70
- for (const fieldIndex of fieldIndices) {
71
- const edge = node.edges[fieldIndex];
72
- size += varuintSize(fieldIndex);
73
- size += 2;
74
- size += varuintSize(edge.childNodeId === void 0 ? 0 : edge.childNodeId + 1);
75
- size += varuintSize(edge.enumNameIndex === void 0 ? 0 : edge.enumNameIndex + 1);
76
- size += 1;
77
- }
78
- }
79
- for (const node of this.#data.outputNodes) {
80
- const fieldIndices = Object.keys(node.edges).map(Number);
81
- size += varuintSize(fieldIndices.length);
82
- for (const fieldIndex of fieldIndices) {
83
- const edge = node.edges[fieldIndex];
84
- size += varuintSize(fieldIndex);
85
- size += varuintSize(edge.argsNodeId === void 0 ? 0 : edge.argsNodeId + 1);
86
- size += varuintSize(edge.outputNodeId === void 0 ? 0 : edge.outputNodeId + 1);
87
- }
88
- }
89
- for (const key of this.#rootKeys) {
90
- const root = this.#data.roots[key];
91
- const keyIndex = this.#data.strings.indexOf(key);
92
- size += varuintSize(keyIndex);
93
- size += varuintSize(root.argsNodeId === void 0 ? 0 : root.argsNodeId + 1);
94
- size += varuintSize(root.outputNodeId === void 0 ? 0 : root.outputNodeId + 1);
95
- }
96
- return size;
97
- }
98
- #writeHeader() {
99
- this.#writeVaruint(this.#data.inputNodes.length);
100
- this.#writeVaruint(this.#data.outputNodes.length);
101
- this.#writeVaruint(this.#rootKeys.length);
102
- }
103
- #writeInputNodes() {
104
- for (const node of this.#data.inputNodes) {
105
- const fieldIndices = Object.keys(node.edges).map(Number);
106
- this.#writeVaruint(fieldIndices.length);
107
- for (const fieldIndex of fieldIndices) {
108
- const edge = node.edges[fieldIndex];
109
- this.#writeVaruint(fieldIndex);
110
- this.#writeU16(edge.scalarMask ?? 0);
111
- this.#writeOptionalVaruint(edge.childNodeId);
112
- this.#writeOptionalVaruint(edge.enumNameIndex);
113
- this.#writeByte(edge.flags);
114
- }
115
- }
116
- }
117
- #writeOutputNodes() {
118
- for (const node of this.#data.outputNodes) {
119
- const fieldIndices = Object.keys(node.edges).map(Number);
120
- this.#writeVaruint(fieldIndices.length);
121
- for (const fieldIndex of fieldIndices) {
122
- const edge = node.edges[fieldIndex];
123
- this.#writeVaruint(fieldIndex);
124
- this.#writeOptionalVaruint(edge.argsNodeId);
125
- this.#writeOptionalVaruint(edge.outputNodeId);
126
- }
127
- }
128
- }
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
- if (keyIndex === -1) {
134
- throw new Error(`Root key "${key}" not found in strings table`);
135
- }
136
- this.#writeVaruint(keyIndex);
137
- this.#writeOptionalVaruint(root.argsNodeId);
138
- this.#writeOptionalVaruint(root.outputNodeId);
139
- }
140
- }
141
- }
142
- class Deserializer {
143
- #serialized;
144
- #view;
145
- #offset = 0;
146
- constructor(serialized) {
147
- this.#serialized = serialized;
148
- const bytes = decodeBase64url(serialized.graph);
149
- this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
150
- }
151
- deserialize() {
152
- const { inputNodeCount, outputNodeCount, rootCount } = this.#readHeader();
153
- const inputNodes = this.#readInputNodes(inputNodeCount);
154
- const outputNodes = this.#readOutputNodes(outputNodeCount);
155
- const roots = this.#readRoots(rootCount);
156
- return {
157
- strings: this.#serialized.strings,
158
- inputNodes,
159
- outputNodes,
160
- roots
161
- };
162
- }
163
- #readVaruint() {
164
- let value = 0;
165
- let shift = 0;
166
- let byte;
167
- do {
168
- byte = this.#view.getUint8(this.#offset++);
169
- value |= (byte & 127) << shift;
170
- shift += 7;
171
- } while (byte >= 128);
172
- return value;
173
- }
174
- #readOptionalVaruint() {
175
- const value = this.#readVaruint();
176
- return value === 0 ? void 0 : value - 1;
177
- }
178
- #readByte() {
179
- const value = this.#view.getUint8(this.#offset);
180
- this.#offset += 1;
181
- return value;
182
- }
183
- #readU16() {
184
- const value = this.#view.getUint16(this.#offset, true);
185
- this.#offset += 2;
186
- return value;
187
- }
188
- #readHeader() {
189
- const inputNodeCount = this.#readVaruint();
190
- const outputNodeCount = this.#readVaruint();
191
- const rootCount = this.#readVaruint();
192
- return { inputNodeCount, outputNodeCount, rootCount };
193
- }
194
- #readInputNodes(count) {
195
- const inputNodes = [];
196
- for (let i = 0; i < count; i++) {
197
- const edgeCount = this.#readVaruint();
198
- const edges = {};
199
- for (let j = 0; j < edgeCount; j++) {
200
- const fieldIndex = this.#readVaruint();
201
- const scalarMask = this.#readU16();
202
- const childNodeId = this.#readOptionalVaruint();
203
- const enumNameIndex = this.#readOptionalVaruint();
204
- const flags = this.#readByte();
205
- const edge = { flags };
206
- if (scalarMask !== 0) edge.scalarMask = scalarMask;
207
- if (childNodeId !== void 0) edge.childNodeId = childNodeId;
208
- if (enumNameIndex !== void 0) edge.enumNameIndex = enumNameIndex;
209
- edges[fieldIndex] = edge;
210
- }
211
- inputNodes.push({ edges });
212
- }
213
- return inputNodes;
214
- }
215
- #readOutputNodes(count) {
216
- const outputNodes = [];
217
- for (let i = 0; i < count; i++) {
218
- const edgeCount = this.#readVaruint();
219
- const edges = {};
220
- for (let j = 0; j < edgeCount; j++) {
221
- const fieldIndex = this.#readVaruint();
222
- const argsNodeId = this.#readOptionalVaruint();
223
- const outputNodeId = this.#readOptionalVaruint();
224
- const edge = {};
225
- if (argsNodeId !== void 0) edge.argsNodeId = argsNodeId;
226
- if (outputNodeId !== void 0) edge.outputNodeId = outputNodeId;
227
- edges[fieldIndex] = edge;
228
- }
229
- outputNodes.push({ edges });
230
- }
231
- return outputNodes;
232
- }
233
- #readRoots(count) {
234
- const roots = {};
235
- for (let i = 0; i < count; i++) {
236
- const keyIndex = this.#readVaruint();
237
- const argsNodeId = this.#readOptionalVaruint();
238
- const outputNodeId = this.#readOptionalVaruint();
239
- const key = this.#serialized.strings[keyIndex];
240
- const root = {};
241
- if (argsNodeId !== void 0) root.argsNodeId = argsNodeId;
242
- if (outputNodeId !== void 0) root.outputNodeId = outputNodeId;
243
- roots[key] = root;
244
- }
245
- return roots;
246
- }
247
- }
248
- export {
249
- deserializeParamGraph,
250
- serializeParamGraph
251
- };
@@ -1,169 +0,0 @@
1
- "use strict";
2
- var import_vitest = require("vitest");
3
- var import_serialization = require("./serialization");
4
- (0, import_vitest.describe)("param-graph serialization", () => {
5
- (0, import_vitest.test)("roundtrip with empty data", () => {
6
- const data = {
7
- strings: ["root1"],
8
- inputNodes: [],
9
- outputNodes: [],
10
- roots: { root1: {} }
11
- };
12
- const serialized = (0, import_serialization.serializeParamGraph)(data);
13
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
14
- (0, import_vitest.expect)(deserialized.strings).toEqual(data.strings);
15
- (0, import_vitest.expect)(deserialized.inputNodes).toEqual(data.inputNodes);
16
- (0, import_vitest.expect)(deserialized.outputNodes).toEqual(data.outputNodes);
17
- (0, import_vitest.expect)(deserialized.roots).toEqual(data.roots);
18
- });
19
- (0, import_vitest.test)("roundtrip with small data", () => {
20
- const data = {
21
- strings: ["findMany", "where", "id"],
22
- inputNodes: [{ edges: { 1: { flags: 0, scalarMask: 1 } } }],
23
- outputNodes: [{ edges: { 2: { argsNodeId: 0 } } }],
24
- roots: { findMany: { argsNodeId: 0, outputNodeId: 0 } }
25
- };
26
- const serialized = (0, import_serialization.serializeParamGraph)(data);
27
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
28
- (0, import_vitest.expect)(deserialized.strings).toEqual(data.strings);
29
- (0, import_vitest.expect)(deserialized.inputNodes.length).toBe(data.inputNodes.length);
30
- (0, import_vitest.expect)(deserialized.outputNodes.length).toBe(data.outputNodes.length);
31
- (0, import_vitest.expect)(Object.keys(deserialized.roots)).toEqual(Object.keys(data.roots));
32
- });
33
- (0, import_vitest.test)("roundtrip with multiple nodes and edges", () => {
34
- const data = {
35
- strings: ["findMany", "create", "update", "where", "data", "id", "name", "Status"],
36
- inputNodes: [
37
- { edges: { 3: { flags: 1, scalarMask: 1, childNodeId: 1 }, 4: { flags: 0, scalarMask: 2 } } },
38
- { edges: { 5: { flags: 2, enumNameIndex: 7 } } }
39
- ],
40
- outputNodes: [{ edges: { 6: { argsNodeId: 0, outputNodeId: 1 } } }, { edges: {} }],
41
- roots: {
42
- findMany: { argsNodeId: 0, outputNodeId: 0 },
43
- create: { argsNodeId: 1, outputNodeId: 1 },
44
- update: { argsNodeId: 0 }
45
- }
46
- };
47
- const serialized = (0, import_serialization.serializeParamGraph)(data);
48
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
49
- (0, import_vitest.expect)(deserialized.inputNodes.length).toBe(2);
50
- (0, import_vitest.expect)(deserialized.outputNodes.length).toBe(2);
51
- (0, import_vitest.expect)(Object.keys(deserialized.roots).length).toBe(3);
52
- const inputEdge = deserialized.inputNodes[0].edges[3];
53
- (0, import_vitest.expect)(inputEdge.flags).toBe(1);
54
- (0, import_vitest.expect)(inputEdge.scalarMask).toBe(1);
55
- (0, import_vitest.expect)(inputEdge.childNodeId).toBe(1);
56
- const enumEdge = deserialized.inputNodes[1].edges[5];
57
- (0, import_vitest.expect)(enumEdge.flags).toBe(2);
58
- (0, import_vitest.expect)(enumEdge.enumNameIndex).toBe(7);
59
- });
60
- (0, import_vitest.test)("handles undefined values correctly", () => {
61
- const data = {
62
- strings: ["root"],
63
- inputNodes: [{ edges: { 0: { flags: 0 } } }],
64
- outputNodes: [{ edges: { 0: {} } }],
65
- roots: { root: { argsNodeId: 0 } }
66
- };
67
- const serialized = (0, import_serialization.serializeParamGraph)(data);
68
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
69
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].childNodeId).toBeUndefined();
70
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].scalarMask).toBeUndefined();
71
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].enumNameIndex).toBeUndefined();
72
- (0, import_vitest.expect)(deserialized.outputNodes[0].edges[0].argsNodeId).toBeUndefined();
73
- (0, import_vitest.expect)(deserialized.outputNodes[0].edges[0].outputNodeId).toBeUndefined();
74
- (0, import_vitest.expect)(deserialized.roots["root"].outputNodeId).toBeUndefined();
75
- });
76
- (0, import_vitest.test)("base64url encoding produces URL-safe output", () => {
77
- const data = {
78
- strings: ["test"],
79
- inputNodes: [{ edges: { 255: { flags: 255, scalarMask: 65535, childNodeId: 0, enumNameIndex: 0 } } }],
80
- outputNodes: [],
81
- roots: { test: { argsNodeId: 0 } }
82
- };
83
- const serialized = (0, import_serialization.serializeParamGraph)(data);
84
- (0, import_vitest.expect)(serialized.graph).toMatch(/^[A-Za-z0-9_-]+$/);
85
- });
86
- (0, import_vitest.test)("handles large indices requiring multi-byte varints (128-16383)", () => {
87
- const strings = Array.from({ length: 200 }, (_, i) => `field${i}`);
88
- const data = {
89
- strings,
90
- inputNodes: [
91
- {
92
- edges: {
93
- // Use indices that require 2-byte encoding (128+)
94
- 128: { flags: 1, childNodeId: 150 },
95
- 150: { flags: 2, enumNameIndex: 180 }
96
- }
97
- }
98
- ],
99
- outputNodes: [{ edges: { 199: { argsNodeId: 0, outputNodeId: 0 } } }],
100
- roots: { field0: { argsNodeId: 0, outputNodeId: 0 } }
101
- };
102
- const serialized = (0, import_serialization.serializeParamGraph)(data);
103
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
104
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[128].flags).toBe(1);
105
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[128].childNodeId).toBe(150);
106
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[150].flags).toBe(2);
107
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[150].enumNameIndex).toBe(180);
108
- (0, import_vitest.expect)(deserialized.outputNodes[0].edges[199].argsNodeId).toBe(0);
109
- (0, import_vitest.expect)(deserialized.outputNodes[0].edges[199].outputNodeId).toBe(0);
110
- });
111
- (0, import_vitest.test)("handles very large indices requiring 3-byte varints (16384+)", () => {
112
- const strings = Array.from({ length: 17e3 }, (_, i) => `f${i}`);
113
- const data = {
114
- strings,
115
- inputNodes: [
116
- {
117
- edges: {
118
- 16384: { flags: 1, childNodeId: 16500 }
119
- }
120
- }
121
- ],
122
- outputNodes: [{ edges: { 16999: { argsNodeId: 0, outputNodeId: 0 } } }],
123
- roots: { f0: { argsNodeId: 0, outputNodeId: 0 } }
124
- };
125
- const serialized = (0, import_serialization.serializeParamGraph)(data);
126
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
127
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[16384].flags).toBe(1);
128
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[16384].childNodeId).toBe(16500);
129
- (0, import_vitest.expect)(deserialized.outputNodes[0].edges[16999].argsNodeId).toBe(0);
130
- });
131
- (0, import_vitest.test)("varint boundary values encode and decode correctly", () => {
132
- const boundaryValues = [0, 1, 127, 128, 16383, 16384];
133
- for (const value of boundaryValues) {
134
- const strings = Array.from({ length: Math.max(value + 1, 2) }, (_, i) => `s${i}`);
135
- const data = {
136
- strings,
137
- inputNodes: [{ edges: { [value]: { flags: 0 } } }],
138
- outputNodes: [],
139
- roots: { s0: {} }
140
- };
141
- const serialized = (0, import_serialization.serializeParamGraph)(data);
142
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
143
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[value]).toBeDefined();
144
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[value].flags).toBe(0);
145
- }
146
- });
147
- (0, import_vitest.test)("optional value 0 is correctly distinguished from undefined", () => {
148
- const data = {
149
- strings: ["root", "field"],
150
- inputNodes: [
151
- { edges: { 1: { flags: 0, childNodeId: 0 } } }
152
- // childNodeId = 0 (not undefined)
153
- ],
154
- outputNodes: [
155
- { edges: { 1: { argsNodeId: 0, outputNodeId: 0 } } }
156
- // both are 0 (not undefined)
157
- ],
158
- roots: { root: { argsNodeId: 0, outputNodeId: 0 } }
159
- // both are 0 (not undefined)
160
- };
161
- const serialized = (0, import_serialization.serializeParamGraph)(data);
162
- const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
163
- (0, import_vitest.expect)(deserialized.inputNodes[0].edges[1].childNodeId).toBe(0);
164
- (0, import_vitest.expect)(deserialized.outputNodes[0].edges[1].argsNodeId).toBe(0);
165
- (0, import_vitest.expect)(deserialized.outputNodes[0].edges[1].outputNodeId).toBe(0);
166
- (0, import_vitest.expect)(deserialized.roots["root"].argsNodeId).toBe(0);
167
- (0, import_vitest.expect)(deserialized.roots["root"].outputNodeId).toBe(0);
168
- });
169
- });