You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@prisma/param-graph

Package Overview
Dependencies
Maintainers
7
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/param-graph - npm Package Compare versions

Comparing version
7.4.0-integration-parameterization.9
to
7.4.0-integration-parameterization.10
+222
-246
dist/serialization.js

@@ -25,2 +25,8 @@ "use strict";

module.exports = __toCommonJS(serialization_exports);
function serializeParamGraph(data) {
return new Serializer(data).serialize();
}
function deserializeParamGraph(serialized) {
return new Deserializer(serialized).deserialize();
}
const FORMAT_COMPACT = 0;

@@ -37,273 +43,243 @@ const FORMAT_WIDE = 1;

}
function serializeParamGraph(data) {
const rootKeys = Object.keys(data.roots);
const maxIndex = Math.max(data.strings.length, data.inputNodes.length, data.outputNodes.length, rootKeys.length);
const useWide = maxIndex > MAX_COMPACT_INDEX;
let size = 1;
size += useWide ? 12 : 6;
for (const node of data.inputNodes) {
size += useWide ? 4 : 2;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (useWide ? 20 : 10);
class Serializer {
#data;
#useWide;
#buffer;
#view;
#offset = 0;
#rootKeys;
constructor(data) {
this.#data = data;
this.#rootKeys = Object.keys(data.roots);
const maxIndex = Math.max(
data.strings.length,
data.inputNodes.length,
data.outputNodes.length,
this.#rootKeys.length
);
this.#useWide = maxIndex > MAX_COMPACT_INDEX;
const size = this.#calculateBufferSize();
this.#buffer = new ArrayBuffer(size);
this.#view = new DataView(this.#buffer);
}
for (const node of data.outputNodes) {
size += useWide ? 4 : 2;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (useWide ? 12 : 6);
serialize() {
this.#writeHeader();
this.#writeInputNodes();
this.#writeOutputNodes();
this.#writeRoots();
return {
strings: this.#data.strings,
graph: encodeBase64url(new Uint8Array(this.#buffer))
};
}
size += rootKeys.length * (useWide ? 12 : 6);
const buffer = new ArrayBuffer(size);
const view = new DataView(buffer);
let offset = 0;
view.setUint8(offset++, useWide ? FORMAT_WIDE : FORMAT_COMPACT);
if (useWide) {
view.setUint32(offset, data.inputNodes.length, true);
offset += 4;
view.setUint32(offset, data.outputNodes.length, true);
offset += 4;
view.setUint32(offset, rootKeys.length, true);
offset += 4;
} else {
view.setUint16(offset, data.inputNodes.length, true);
offset += 2;
view.setUint16(offset, data.outputNodes.length, true);
offset += 2;
view.setUint16(offset, rootKeys.length, true);
offset += 2;
get #wordSize() {
return this.#useWide ? 4 : 2;
}
for (const node of data.inputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
if (useWide) {
view.setUint32(offset, fieldIndices.length, true);
offset += 4;
get #noneValue() {
return this.#useWide ? NONE_32 : NONE_16;
}
#writeWord(value) {
if (this.#useWide) {
this.#view.setUint32(this.#offset, value, true);
} else {
view.setUint16(offset, fieldIndices.length, true);
offset += 2;
this.#view.setUint16(this.#offset, value, true);
}
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
if (useWide) {
view.setUint32(offset, fieldIndex, true);
offset += 4;
view.setUint16(offset, edge.scalarMask ?? 0, true);
offset += 2;
offset += 2;
view.setUint32(offset, edge.childNodeId ?? NONE_32, true);
offset += 4;
view.setUint32(offset, edge.enumNameIndex ?? NONE_32, true);
offset += 4;
view.setUint8(offset, edge.flags);
offset += 1;
offset += 3;
} else {
view.setUint16(offset, fieldIndex, true);
offset += 2;
view.setUint16(offset, edge.scalarMask ?? 0, true);
offset += 2;
view.setUint16(offset, edge.childNodeId ?? NONE_16, true);
offset += 2;
view.setUint16(offset, edge.enumNameIndex ?? NONE_16, true);
offset += 2;
view.setUint8(offset, edge.flags);
offset += 1;
offset += 1;
this.#offset += this.#wordSize;
}
#writeOptionalWord(value) {
this.#writeWord(value ?? this.#noneValue);
}
#writeByte(value) {
this.#view.setUint8(this.#offset, value);
this.#offset += 1;
}
#writeU16(value) {
this.#view.setUint16(this.#offset, value, true);
this.#offset += 2;
}
#skip(bytes) {
this.#offset += bytes;
}
#calculateBufferSize() {
let size = 1;
size += this.#useWide ? 12 : 6;
for (const node of this.#data.inputNodes) {
size += this.#wordSize;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (this.#useWide ? 20 : 10);
}
for (const node of this.#data.outputNodes) {
size += this.#wordSize;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (this.#useWide ? 12 : 6);
}
size += this.#rootKeys.length * (this.#useWide ? 12 : 6);
return size;
}
#writeHeader() {
this.#writeByte(this.#useWide ? FORMAT_WIDE : FORMAT_COMPACT);
this.#writeWord(this.#data.inputNodes.length);
this.#writeWord(this.#data.outputNodes.length);
this.#writeWord(this.#rootKeys.length);
}
#writeInputNodes() {
for (const node of this.#data.inputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
this.#writeWord(fieldIndices.length);
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
this.#writeWord(fieldIndex);
this.#writeU16(edge.scalarMask ?? 0);
if (this.#useWide) {
this.#skip(2);
}
this.#writeOptionalWord(edge.childNodeId);
this.#writeOptionalWord(edge.enumNameIndex);
this.#writeByte(edge.flags);
this.#skip(this.#useWide ? 3 : 1);
}
}
}
for (const node of data.outputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
if (useWide) {
view.setUint32(offset, fieldIndices.length, true);
offset += 4;
} else {
view.setUint16(offset, fieldIndices.length, true);
offset += 2;
}
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
if (useWide) {
view.setUint32(offset, fieldIndex, true);
offset += 4;
view.setUint32(offset, edge.argsNodeId ?? NONE_32, true);
offset += 4;
view.setUint32(offset, edge.outputNodeId ?? NONE_32, true);
offset += 4;
} else {
view.setUint16(offset, fieldIndex, true);
offset += 2;
view.setUint16(offset, edge.argsNodeId ?? NONE_16, true);
offset += 2;
view.setUint16(offset, edge.outputNodeId ?? NONE_16, true);
offset += 2;
#writeOutputNodes() {
for (const node of this.#data.outputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
this.#writeWord(fieldIndices.length);
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
this.#writeWord(fieldIndex);
this.#writeOptionalWord(edge.argsNodeId);
this.#writeOptionalWord(edge.outputNodeId);
}
}
}
for (const key of rootKeys) {
const root = data.roots[key];
const keyIndex = data.strings.indexOf(key);
if (useWide) {
view.setUint32(offset, keyIndex, true);
offset += 4;
view.setUint32(offset, root.argsNodeId ?? NONE_32, true);
offset += 4;
view.setUint32(offset, root.outputNodeId ?? NONE_32, true);
offset += 4;
} else {
view.setUint16(offset, keyIndex, true);
offset += 2;
view.setUint16(offset, root.argsNodeId ?? NONE_16, true);
offset += 2;
view.setUint16(offset, root.outputNodeId ?? NONE_16, true);
offset += 2;
#writeRoots() {
for (const key of this.#rootKeys) {
const root = this.#data.roots[key];
const keyIndex = this.#data.strings.indexOf(key);
this.#writeWord(keyIndex);
this.#writeOptionalWord(root.argsNodeId);
this.#writeOptionalWord(root.outputNodeId);
}
}
return {
strings: data.strings,
graph: encodeBase64url(new Uint8Array(buffer))
};
}
function deserializeParamGraph(serialized) {
const bytes = decodeBase64url(serialized.graph);
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
let offset = 0;
const format = view.getUint8(offset++);
const useWide = format === FORMAT_WIDE;
let inputNodeCount;
let outputNodeCount;
let rootCount;
if (useWide) {
inputNodeCount = view.getUint32(offset, true);
offset += 4;
outputNodeCount = view.getUint32(offset, true);
offset += 4;
rootCount = view.getUint32(offset, true);
offset += 4;
} else {
inputNodeCount = view.getUint16(offset, true);
offset += 2;
outputNodeCount = view.getUint16(offset, true);
offset += 2;
rootCount = view.getUint16(offset, true);
offset += 2;
class Deserializer {
#serialized;
#view;
#offset = 0;
#useWide = false;
constructor(serialized) {
this.#serialized = serialized;
const bytes = decodeBase64url(serialized.graph);
this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
}
const inputNodes = [];
for (let i = 0; i < inputNodeCount; i++) {
let edgeCount;
if (useWide) {
edgeCount = view.getUint32(offset, true);
offset += 4;
deserialize() {
const { inputNodeCount, outputNodeCount, rootCount } = this.#readHeader();
const inputNodes = this.#readInputNodes(inputNodeCount);
const outputNodes = this.#readOutputNodes(outputNodeCount);
const roots = this.#readRoots(rootCount);
return {
strings: this.#serialized.strings,
inputNodes,
outputNodes,
roots
};
}
get #wordSize() {
return this.#useWide ? 4 : 2;
}
get #noneValue() {
return this.#useWide ? NONE_32 : NONE_16;
}
#readWord() {
let value;
if (this.#useWide) {
value = this.#view.getUint32(this.#offset, true);
} else {
edgeCount = view.getUint16(offset, true);
offset += 2;
value = this.#view.getUint16(this.#offset, true);
}
const edges = {};
for (let j = 0; j < edgeCount; j++) {
let fieldIndex;
let scalarMask;
let childNodeId;
let enumNameIndex;
let flags;
if (useWide) {
fieldIndex = view.getUint32(offset, true);
offset += 4;
scalarMask = view.getUint16(offset, true);
offset += 2;
offset += 2;
childNodeId = view.getUint32(offset, true);
offset += 4;
enumNameIndex = view.getUint32(offset, true);
offset += 4;
flags = view.getUint8(offset);
offset += 1;
offset += 3;
} else {
fieldIndex = view.getUint16(offset, true);
offset += 2;
scalarMask = view.getUint16(offset, true);
offset += 2;
childNodeId = view.getUint16(offset, true);
offset += 2;
enumNameIndex = view.getUint16(offset, true);
offset += 2;
flags = view.getUint8(offset);
offset += 1;
offset += 1;
this.#offset += this.#wordSize;
return value;
}
#readOptionalWord() {
const value = this.#readWord();
return value === this.#noneValue ? void 0 : value;
}
#readByte() {
const value = this.#view.getUint8(this.#offset);
this.#offset += 1;
return value;
}
#readU16() {
const value = this.#view.getUint16(this.#offset, true);
this.#offset += 2;
return value;
}
#skip(bytes) {
this.#offset += bytes;
}
#readHeader() {
const format = this.#readByte();
this.#useWide = format === FORMAT_WIDE;
const inputNodeCount = this.#readWord();
const outputNodeCount = this.#readWord();
const rootCount = this.#readWord();
return { inputNodeCount, outputNodeCount, rootCount };
}
#readInputNodes(count) {
const inputNodes = [];
for (let i = 0; i < count; i++) {
const edgeCount = this.#readWord();
const edges = {};
for (let j = 0; j < edgeCount; j++) {
const fieldIndex = this.#readWord();
const scalarMask = this.#readU16();
if (this.#useWide) {
this.#skip(2);
}
const childNodeId = this.#readOptionalWord();
const enumNameIndex = this.#readOptionalWord();
const flags = this.#readByte();
this.#skip(this.#useWide ? 3 : 1);
const edge = { flags };
if (scalarMask !== 0) edge.scalarMask = scalarMask;
if (childNodeId !== void 0) edge.childNodeId = childNodeId;
if (enumNameIndex !== void 0) edge.enumNameIndex = enumNameIndex;
edges[fieldIndex] = edge;
}
const edge = { flags };
if (scalarMask !== 0) edge.scalarMask = scalarMask;
if (childNodeId !== (useWide ? NONE_32 : NONE_16)) edge.childNodeId = childNodeId;
if (enumNameIndex !== (useWide ? NONE_32 : NONE_16)) edge.enumNameIndex = enumNameIndex;
edges[fieldIndex] = edge;
inputNodes.push({ edges });
}
inputNodes.push({ edges });
return inputNodes;
}
const outputNodes = [];
for (let i = 0; i < outputNodeCount; i++) {
let edgeCount;
if (useWide) {
edgeCount = view.getUint32(offset, true);
offset += 4;
} else {
edgeCount = view.getUint16(offset, true);
offset += 2;
}
const edges = {};
for (let j = 0; j < edgeCount; j++) {
let fieldIndex;
let argsNodeId;
let outputNodeId;
if (useWide) {
fieldIndex = view.getUint32(offset, true);
offset += 4;
argsNodeId = view.getUint32(offset, true);
offset += 4;
outputNodeId = view.getUint32(offset, true);
offset += 4;
} else {
fieldIndex = view.getUint16(offset, true);
offset += 2;
argsNodeId = view.getUint16(offset, true);
offset += 2;
outputNodeId = view.getUint16(offset, true);
offset += 2;
#readOutputNodes(count) {
const outputNodes = [];
for (let i = 0; i < count; i++) {
const edgeCount = this.#readWord();
const edges = {};
for (let j = 0; j < edgeCount; j++) {
const fieldIndex = this.#readWord();
const argsNodeId = this.#readOptionalWord();
const outputNodeId = this.#readOptionalWord();
const edge = {};
if (argsNodeId !== void 0) edge.argsNodeId = argsNodeId;
if (outputNodeId !== void 0) edge.outputNodeId = outputNodeId;
edges[fieldIndex] = edge;
}
const edge = {};
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) edge.argsNodeId = argsNodeId;
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) edge.outputNodeId = outputNodeId;
edges[fieldIndex] = edge;
outputNodes.push({ edges });
}
outputNodes.push({ edges });
return outputNodes;
}
const roots = {};
for (let i = 0; i < rootCount; i++) {
let keyIndex;
let argsNodeId;
let outputNodeId;
if (useWide) {
keyIndex = view.getUint32(offset, true);
offset += 4;
argsNodeId = view.getUint32(offset, true);
offset += 4;
outputNodeId = view.getUint32(offset, true);
offset += 4;
} else {
keyIndex = view.getUint16(offset, true);
offset += 2;
argsNodeId = view.getUint16(offset, true);
offset += 2;
outputNodeId = view.getUint16(offset, true);
offset += 2;
#readRoots(count) {
const roots = {};
for (let i = 0; i < count; i++) {
const keyIndex = this.#readWord();
const argsNodeId = this.#readOptionalWord();
const outputNodeId = this.#readOptionalWord();
const key = this.#serialized.strings[keyIndex];
const root = {};
if (argsNodeId !== void 0) root.argsNodeId = argsNodeId;
if (outputNodeId !== void 0) root.outputNodeId = outputNodeId;
roots[key] = root;
}
const key = serialized.strings[keyIndex];
const root = {};
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) root.argsNodeId = argsNodeId;
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) root.outputNodeId = outputNodeId;
roots[key] = root;
return roots;
}
return {
strings: serialized.strings,
inputNodes,
outputNodes,
roots
};
}

@@ -310,0 +286,0 @@ // Annotate the CommonJS export names for ESM import in node:

@@ -0,1 +1,7 @@

function serializeParamGraph(data) {
return new Serializer(data).serialize();
}
function deserializeParamGraph(serialized) {
return new Deserializer(serialized).deserialize();
}
const FORMAT_COMPACT = 0;

@@ -12,273 +18,243 @@ const FORMAT_WIDE = 1;

}
function serializeParamGraph(data) {
const rootKeys = Object.keys(data.roots);
const maxIndex = Math.max(data.strings.length, data.inputNodes.length, data.outputNodes.length, rootKeys.length);
const useWide = maxIndex > MAX_COMPACT_INDEX;
let size = 1;
size += useWide ? 12 : 6;
for (const node of data.inputNodes) {
size += useWide ? 4 : 2;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (useWide ? 20 : 10);
class Serializer {
#data;
#useWide;
#buffer;
#view;
#offset = 0;
#rootKeys;
constructor(data) {
this.#data = data;
this.#rootKeys = Object.keys(data.roots);
const maxIndex = Math.max(
data.strings.length,
data.inputNodes.length,
data.outputNodes.length,
this.#rootKeys.length
);
this.#useWide = maxIndex > MAX_COMPACT_INDEX;
const size = this.#calculateBufferSize();
this.#buffer = new ArrayBuffer(size);
this.#view = new DataView(this.#buffer);
}
for (const node of data.outputNodes) {
size += useWide ? 4 : 2;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (useWide ? 12 : 6);
serialize() {
this.#writeHeader();
this.#writeInputNodes();
this.#writeOutputNodes();
this.#writeRoots();
return {
strings: this.#data.strings,
graph: encodeBase64url(new Uint8Array(this.#buffer))
};
}
size += rootKeys.length * (useWide ? 12 : 6);
const buffer = new ArrayBuffer(size);
const view = new DataView(buffer);
let offset = 0;
view.setUint8(offset++, useWide ? FORMAT_WIDE : FORMAT_COMPACT);
if (useWide) {
view.setUint32(offset, data.inputNodes.length, true);
offset += 4;
view.setUint32(offset, data.outputNodes.length, true);
offset += 4;
view.setUint32(offset, rootKeys.length, true);
offset += 4;
} else {
view.setUint16(offset, data.inputNodes.length, true);
offset += 2;
view.setUint16(offset, data.outputNodes.length, true);
offset += 2;
view.setUint16(offset, rootKeys.length, true);
offset += 2;
get #wordSize() {
return this.#useWide ? 4 : 2;
}
for (const node of data.inputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
if (useWide) {
view.setUint32(offset, fieldIndices.length, true);
offset += 4;
get #noneValue() {
return this.#useWide ? NONE_32 : NONE_16;
}
#writeWord(value) {
if (this.#useWide) {
this.#view.setUint32(this.#offset, value, true);
} else {
view.setUint16(offset, fieldIndices.length, true);
offset += 2;
this.#view.setUint16(this.#offset, value, true);
}
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
if (useWide) {
view.setUint32(offset, fieldIndex, true);
offset += 4;
view.setUint16(offset, edge.scalarMask ?? 0, true);
offset += 2;
offset += 2;
view.setUint32(offset, edge.childNodeId ?? NONE_32, true);
offset += 4;
view.setUint32(offset, edge.enumNameIndex ?? NONE_32, true);
offset += 4;
view.setUint8(offset, edge.flags);
offset += 1;
offset += 3;
} else {
view.setUint16(offset, fieldIndex, true);
offset += 2;
view.setUint16(offset, edge.scalarMask ?? 0, true);
offset += 2;
view.setUint16(offset, edge.childNodeId ?? NONE_16, true);
offset += 2;
view.setUint16(offset, edge.enumNameIndex ?? NONE_16, true);
offset += 2;
view.setUint8(offset, edge.flags);
offset += 1;
offset += 1;
this.#offset += this.#wordSize;
}
#writeOptionalWord(value) {
this.#writeWord(value ?? this.#noneValue);
}
#writeByte(value) {
this.#view.setUint8(this.#offset, value);
this.#offset += 1;
}
#writeU16(value) {
this.#view.setUint16(this.#offset, value, true);
this.#offset += 2;
}
#skip(bytes) {
this.#offset += bytes;
}
#calculateBufferSize() {
let size = 1;
size += this.#useWide ? 12 : 6;
for (const node of this.#data.inputNodes) {
size += this.#wordSize;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (this.#useWide ? 20 : 10);
}
for (const node of this.#data.outputNodes) {
size += this.#wordSize;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (this.#useWide ? 12 : 6);
}
size += this.#rootKeys.length * (this.#useWide ? 12 : 6);
return size;
}
#writeHeader() {
this.#writeByte(this.#useWide ? FORMAT_WIDE : FORMAT_COMPACT);
this.#writeWord(this.#data.inputNodes.length);
this.#writeWord(this.#data.outputNodes.length);
this.#writeWord(this.#rootKeys.length);
}
#writeInputNodes() {
for (const node of this.#data.inputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
this.#writeWord(fieldIndices.length);
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
this.#writeWord(fieldIndex);
this.#writeU16(edge.scalarMask ?? 0);
if (this.#useWide) {
this.#skip(2);
}
this.#writeOptionalWord(edge.childNodeId);
this.#writeOptionalWord(edge.enumNameIndex);
this.#writeByte(edge.flags);
this.#skip(this.#useWide ? 3 : 1);
}
}
}
for (const node of data.outputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
if (useWide) {
view.setUint32(offset, fieldIndices.length, true);
offset += 4;
} else {
view.setUint16(offset, fieldIndices.length, true);
offset += 2;
}
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
if (useWide) {
view.setUint32(offset, fieldIndex, true);
offset += 4;
view.setUint32(offset, edge.argsNodeId ?? NONE_32, true);
offset += 4;
view.setUint32(offset, edge.outputNodeId ?? NONE_32, true);
offset += 4;
} else {
view.setUint16(offset, fieldIndex, true);
offset += 2;
view.setUint16(offset, edge.argsNodeId ?? NONE_16, true);
offset += 2;
view.setUint16(offset, edge.outputNodeId ?? NONE_16, true);
offset += 2;
#writeOutputNodes() {
for (const node of this.#data.outputNodes) {
const fieldIndices = Object.keys(node.edges).map(Number);
this.#writeWord(fieldIndices.length);
for (const fieldIndex of fieldIndices) {
const edge = node.edges[fieldIndex];
this.#writeWord(fieldIndex);
this.#writeOptionalWord(edge.argsNodeId);
this.#writeOptionalWord(edge.outputNodeId);
}
}
}
for (const key of rootKeys) {
const root = data.roots[key];
const keyIndex = data.strings.indexOf(key);
if (useWide) {
view.setUint32(offset, keyIndex, true);
offset += 4;
view.setUint32(offset, root.argsNodeId ?? NONE_32, true);
offset += 4;
view.setUint32(offset, root.outputNodeId ?? NONE_32, true);
offset += 4;
} else {
view.setUint16(offset, keyIndex, true);
offset += 2;
view.setUint16(offset, root.argsNodeId ?? NONE_16, true);
offset += 2;
view.setUint16(offset, root.outputNodeId ?? NONE_16, true);
offset += 2;
#writeRoots() {
for (const key of this.#rootKeys) {
const root = this.#data.roots[key];
const keyIndex = this.#data.strings.indexOf(key);
this.#writeWord(keyIndex);
this.#writeOptionalWord(root.argsNodeId);
this.#writeOptionalWord(root.outputNodeId);
}
}
return {
strings: data.strings,
graph: encodeBase64url(new Uint8Array(buffer))
};
}
function deserializeParamGraph(serialized) {
const bytes = decodeBase64url(serialized.graph);
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
let offset = 0;
const format = view.getUint8(offset++);
const useWide = format === FORMAT_WIDE;
let inputNodeCount;
let outputNodeCount;
let rootCount;
if (useWide) {
inputNodeCount = view.getUint32(offset, true);
offset += 4;
outputNodeCount = view.getUint32(offset, true);
offset += 4;
rootCount = view.getUint32(offset, true);
offset += 4;
} else {
inputNodeCount = view.getUint16(offset, true);
offset += 2;
outputNodeCount = view.getUint16(offset, true);
offset += 2;
rootCount = view.getUint16(offset, true);
offset += 2;
class Deserializer {
#serialized;
#view;
#offset = 0;
#useWide = false;
constructor(serialized) {
this.#serialized = serialized;
const bytes = decodeBase64url(serialized.graph);
this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
}
const inputNodes = [];
for (let i = 0; i < inputNodeCount; i++) {
let edgeCount;
if (useWide) {
edgeCount = view.getUint32(offset, true);
offset += 4;
deserialize() {
const { inputNodeCount, outputNodeCount, rootCount } = this.#readHeader();
const inputNodes = this.#readInputNodes(inputNodeCount);
const outputNodes = this.#readOutputNodes(outputNodeCount);
const roots = this.#readRoots(rootCount);
return {
strings: this.#serialized.strings,
inputNodes,
outputNodes,
roots
};
}
get #wordSize() {
return this.#useWide ? 4 : 2;
}
get #noneValue() {
return this.#useWide ? NONE_32 : NONE_16;
}
#readWord() {
let value;
if (this.#useWide) {
value = this.#view.getUint32(this.#offset, true);
} else {
edgeCount = view.getUint16(offset, true);
offset += 2;
value = this.#view.getUint16(this.#offset, true);
}
const edges = {};
for (let j = 0; j < edgeCount; j++) {
let fieldIndex;
let scalarMask;
let childNodeId;
let enumNameIndex;
let flags;
if (useWide) {
fieldIndex = view.getUint32(offset, true);
offset += 4;
scalarMask = view.getUint16(offset, true);
offset += 2;
offset += 2;
childNodeId = view.getUint32(offset, true);
offset += 4;
enumNameIndex = view.getUint32(offset, true);
offset += 4;
flags = view.getUint8(offset);
offset += 1;
offset += 3;
} else {
fieldIndex = view.getUint16(offset, true);
offset += 2;
scalarMask = view.getUint16(offset, true);
offset += 2;
childNodeId = view.getUint16(offset, true);
offset += 2;
enumNameIndex = view.getUint16(offset, true);
offset += 2;
flags = view.getUint8(offset);
offset += 1;
offset += 1;
this.#offset += this.#wordSize;
return value;
}
#readOptionalWord() {
const value = this.#readWord();
return value === this.#noneValue ? void 0 : value;
}
#readByte() {
const value = this.#view.getUint8(this.#offset);
this.#offset += 1;
return value;
}
#readU16() {
const value = this.#view.getUint16(this.#offset, true);
this.#offset += 2;
return value;
}
#skip(bytes) {
this.#offset += bytes;
}
#readHeader() {
const format = this.#readByte();
this.#useWide = format === FORMAT_WIDE;
const inputNodeCount = this.#readWord();
const outputNodeCount = this.#readWord();
const rootCount = this.#readWord();
return { inputNodeCount, outputNodeCount, rootCount };
}
#readInputNodes(count) {
const inputNodes = [];
for (let i = 0; i < count; i++) {
const edgeCount = this.#readWord();
const edges = {};
for (let j = 0; j < edgeCount; j++) {
const fieldIndex = this.#readWord();
const scalarMask = this.#readU16();
if (this.#useWide) {
this.#skip(2);
}
const childNodeId = this.#readOptionalWord();
const enumNameIndex = this.#readOptionalWord();
const flags = this.#readByte();
this.#skip(this.#useWide ? 3 : 1);
const edge = { flags };
if (scalarMask !== 0) edge.scalarMask = scalarMask;
if (childNodeId !== void 0) edge.childNodeId = childNodeId;
if (enumNameIndex !== void 0) edge.enumNameIndex = enumNameIndex;
edges[fieldIndex] = edge;
}
const edge = { flags };
if (scalarMask !== 0) edge.scalarMask = scalarMask;
if (childNodeId !== (useWide ? NONE_32 : NONE_16)) edge.childNodeId = childNodeId;
if (enumNameIndex !== (useWide ? NONE_32 : NONE_16)) edge.enumNameIndex = enumNameIndex;
edges[fieldIndex] = edge;
inputNodes.push({ edges });
}
inputNodes.push({ edges });
return inputNodes;
}
const outputNodes = [];
for (let i = 0; i < outputNodeCount; i++) {
let edgeCount;
if (useWide) {
edgeCount = view.getUint32(offset, true);
offset += 4;
} else {
edgeCount = view.getUint16(offset, true);
offset += 2;
}
const edges = {};
for (let j = 0; j < edgeCount; j++) {
let fieldIndex;
let argsNodeId;
let outputNodeId;
if (useWide) {
fieldIndex = view.getUint32(offset, true);
offset += 4;
argsNodeId = view.getUint32(offset, true);
offset += 4;
outputNodeId = view.getUint32(offset, true);
offset += 4;
} else {
fieldIndex = view.getUint16(offset, true);
offset += 2;
argsNodeId = view.getUint16(offset, true);
offset += 2;
outputNodeId = view.getUint16(offset, true);
offset += 2;
#readOutputNodes(count) {
const outputNodes = [];
for (let i = 0; i < count; i++) {
const edgeCount = this.#readWord();
const edges = {};
for (let j = 0; j < edgeCount; j++) {
const fieldIndex = this.#readWord();
const argsNodeId = this.#readOptionalWord();
const outputNodeId = this.#readOptionalWord();
const edge = {};
if (argsNodeId !== void 0) edge.argsNodeId = argsNodeId;
if (outputNodeId !== void 0) edge.outputNodeId = outputNodeId;
edges[fieldIndex] = edge;
}
const edge = {};
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) edge.argsNodeId = argsNodeId;
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) edge.outputNodeId = outputNodeId;
edges[fieldIndex] = edge;
outputNodes.push({ edges });
}
outputNodes.push({ edges });
return outputNodes;
}
const roots = {};
for (let i = 0; i < rootCount; i++) {
let keyIndex;
let argsNodeId;
let outputNodeId;
if (useWide) {
keyIndex = view.getUint32(offset, true);
offset += 4;
argsNodeId = view.getUint32(offset, true);
offset += 4;
outputNodeId = view.getUint32(offset, true);
offset += 4;
} else {
keyIndex = view.getUint16(offset, true);
offset += 2;
argsNodeId = view.getUint16(offset, true);
offset += 2;
outputNodeId = view.getUint16(offset, true);
offset += 2;
#readRoots(count) {
const roots = {};
for (let i = 0; i < count; i++) {
const keyIndex = this.#readWord();
const argsNodeId = this.#readOptionalWord();
const outputNodeId = this.#readOptionalWord();
const key = this.#serialized.strings[keyIndex];
const root = {};
if (argsNodeId !== void 0) root.argsNodeId = argsNodeId;
if (outputNodeId !== void 0) root.outputNodeId = outputNodeId;
roots[key] = root;
}
const key = serialized.strings[keyIndex];
const root = {};
if (argsNodeId !== (useWide ? NONE_32 : NONE_16)) root.argsNodeId = argsNodeId;
if (outputNodeId !== (useWide ? NONE_32 : NONE_16)) root.outputNodeId = outputNodeId;
roots[key] = root;
return roots;
}
return {
strings: serialized.strings,
inputNodes,
outputNodes,
roots
};
}

@@ -285,0 +261,0 @@ export {

{
"name": "@prisma/param-graph",
"version": "7.4.0-integration-parameterization.9",
"version": "7.4.0-integration-parameterization.10",
"description": "This package is intended for Prisma's internal use",

@@ -5,0 +5,0 @@ "main": "dist/index.js",