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
126
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.6
to
7.4.0-integration-parameterization.7
+25
dist/serialization.d.ts
/**
* Binary serialization for ParamGraph.
*
* This module handles compact binary encoding/decoding of the param graph structure.
* The format uses a hybrid approach: JSON string array for field names + binary blob
* for structural data (nodes, edges, roots).
*/
import type { ParamGraphData } from './types';
/**
* Serialized format stored in the generated client.
*/
export interface SerializedParamGraph {
/** String table (field names, enum names, root keys) */
strings: string[];
/** Base64url-encoded binary blob for structural data */
graph: string;
}
/**
* Serializes a ParamGraphData to the compact binary format.
*/
export declare function serializeParamGraph(data: ParamGraphData): SerializedParamGraph;
/**
* Deserializes a binary-encoded ParamGraph.
*/
export declare function deserializeParamGraph(serialized: SerializedParamGraph): ParamGraphData;
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var serialization_exports = {};
__export(serialization_exports, {
deserializeParamGraph: () => deserializeParamGraph,
serializeParamGraph: () => serializeParamGraph
});
module.exports = __toCommonJS(serialization_exports);
const FORMAT_COMPACT = 0;
const FORMAT_WIDE = 1;
const NONE_16 = 65535;
const NONE_32 = 4294967295;
const MAX_COMPACT_INDEX = 65534;
const BASE64URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
function encodeBase64url(bytes) {
let result = "";
const len = bytes.length;
let i = 0;
while (i < len) {
const b0 = bytes[i++];
const hasB1 = i < len;
const b1 = hasB1 ? bytes[i++] : 0;
const hasB2 = i < len;
const b2 = hasB2 ? bytes[i++] : 0;
result += BASE64URL_CHARS[b0 >> 2 & 63];
result += BASE64URL_CHARS[(b0 << 4 | b1 >> 4) & 63];
if (hasB1) {
result += BASE64URL_CHARS[(b1 << 2 | b2 >> 6) & 63];
}
if (hasB2) {
result += BASE64URL_CHARS[b2 & 63];
}
}
return result;
}
function decodeBase64url(str) {
const charToIndex = new Uint8Array(128);
for (let i = 0; i < BASE64URL_CHARS.length; i++) {
charToIndex[BASE64URL_CHARS.charCodeAt(i)] = i;
}
const len = str.length;
const outputLen = Math.floor(len * 3 / 4);
const bytes = new Uint8Array(outputLen);
let bi = 0;
for (let i = 0; i < len; ) {
const c0 = charToIndex[str.charCodeAt(i++)];
const c1 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
const c2 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
const c3 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
bytes[bi++] = c0 << 2 | c1 >> 4;
if (bi < outputLen) bytes[bi++] = (c1 << 4 | c2 >> 2) & 255;
if (bi < outputLen) bytes[bi++] = (c2 << 6 | c3) & 255;
}
return bytes;
}
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);
}
for (const node of data.outputNodes) {
size += useWide ? 4 : 2;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (useWide ? 12 : 6);
}
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;
}
for (const node of data.inputNodes) {
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.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;
}
}
}
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;
}
}
}
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;
}
}
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;
}
const inputNodes = [];
for (let i = 0; i < inputNodeCount; 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 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;
}
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 });
}
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;
}
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 });
}
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;
}
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 {
strings: serialized.strings,
inputNodes,
outputNodes,
roots
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
deserializeParamGraph,
serializeParamGraph
});
const FORMAT_COMPACT = 0;
const FORMAT_WIDE = 1;
const NONE_16 = 65535;
const NONE_32 = 4294967295;
const MAX_COMPACT_INDEX = 65534;
const BASE64URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
function encodeBase64url(bytes) {
let result = "";
const len = bytes.length;
let i = 0;
while (i < len) {
const b0 = bytes[i++];
const hasB1 = i < len;
const b1 = hasB1 ? bytes[i++] : 0;
const hasB2 = i < len;
const b2 = hasB2 ? bytes[i++] : 0;
result += BASE64URL_CHARS[b0 >> 2 & 63];
result += BASE64URL_CHARS[(b0 << 4 | b1 >> 4) & 63];
if (hasB1) {
result += BASE64URL_CHARS[(b1 << 2 | b2 >> 6) & 63];
}
if (hasB2) {
result += BASE64URL_CHARS[b2 & 63];
}
}
return result;
}
function decodeBase64url(str) {
const charToIndex = new Uint8Array(128);
for (let i = 0; i < BASE64URL_CHARS.length; i++) {
charToIndex[BASE64URL_CHARS.charCodeAt(i)] = i;
}
const len = str.length;
const outputLen = Math.floor(len * 3 / 4);
const bytes = new Uint8Array(outputLen);
let bi = 0;
for (let i = 0; i < len; ) {
const c0 = charToIndex[str.charCodeAt(i++)];
const c1 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
const c2 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
const c3 = i < len ? charToIndex[str.charCodeAt(i++)] : 0;
bytes[bi++] = c0 << 2 | c1 >> 4;
if (bi < outputLen) bytes[bi++] = (c1 << 4 | c2 >> 2) & 255;
if (bi < outputLen) bytes[bi++] = (c2 << 6 | c3) & 255;
}
return bytes;
}
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);
}
for (const node of data.outputNodes) {
size += useWide ? 4 : 2;
const edgeCount = Object.keys(node.edges).length;
size += edgeCount * (useWide ? 12 : 6);
}
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;
}
for (const node of data.inputNodes) {
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.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;
}
}
}
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;
}
}
}
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;
}
}
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;
}
const inputNodes = [];
for (let i = 0; i < inputNodeCount; 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 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;
}
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 });
}
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;
}
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 });
}
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;
}
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 {
strings: serialized.strings,
inputNodes,
outputNodes,
roots
};
}
export {
deserializeParamGraph,
serializeParamGraph
};
"use strict";
var import_vitest = require("vitest");
var import_serialization = require("./serialization");
(0, import_vitest.describe)("param-graph serialization", () => {
(0, import_vitest.test)("roundtrip with empty data", () => {
const data = {
strings: ["root1"],
inputNodes: [],
outputNodes: [],
roots: { root1: {} }
};
const serialized = (0, import_serialization.serializeParamGraph)(data);
const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
(0, import_vitest.expect)(deserialized.strings).toEqual(data.strings);
(0, import_vitest.expect)(deserialized.inputNodes).toEqual(data.inputNodes);
(0, import_vitest.expect)(deserialized.outputNodes).toEqual(data.outputNodes);
(0, import_vitest.expect)(deserialized.roots).toEqual(data.roots);
});
(0, import_vitest.test)("roundtrip with small data", () => {
const data = {
strings: ["findMany", "where", "id"],
inputNodes: [{ edges: { 1: { flags: 0, scalarMask: 1 } } }],
outputNodes: [{ edges: { 2: { argsNodeId: 0 } } }],
roots: { findMany: { argsNodeId: 0, outputNodeId: 0 } }
};
const serialized = (0, import_serialization.serializeParamGraph)(data);
const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
(0, import_vitest.expect)(deserialized.strings).toEqual(data.strings);
(0, import_vitest.expect)(deserialized.inputNodes.length).toBe(data.inputNodes.length);
(0, import_vitest.expect)(deserialized.outputNodes.length).toBe(data.outputNodes.length);
(0, import_vitest.expect)(Object.keys(deserialized.roots)).toEqual(Object.keys(data.roots));
});
(0, import_vitest.test)("roundtrip with multiple nodes and edges", () => {
const data = {
strings: ["findMany", "create", "update", "where", "data", "id", "name", "Status"],
inputNodes: [
{ edges: { 3: { flags: 1, scalarMask: 1, childNodeId: 1 }, 4: { flags: 0, scalarMask: 2 } } },
{ edges: { 5: { flags: 2, enumNameIndex: 7 } } }
],
outputNodes: [{ edges: { 6: { argsNodeId: 0, outputNodeId: 1 } } }, { edges: {} }],
roots: {
findMany: { argsNodeId: 0, outputNodeId: 0 },
create: { argsNodeId: 1, outputNodeId: 1 },
update: { argsNodeId: 0 }
}
};
const serialized = (0, import_serialization.serializeParamGraph)(data);
const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
(0, import_vitest.expect)(deserialized.inputNodes.length).toBe(2);
(0, import_vitest.expect)(deserialized.outputNodes.length).toBe(2);
(0, import_vitest.expect)(Object.keys(deserialized.roots).length).toBe(3);
const inputEdge = deserialized.inputNodes[0].edges[3];
(0, import_vitest.expect)(inputEdge.flags).toBe(1);
(0, import_vitest.expect)(inputEdge.scalarMask).toBe(1);
(0, import_vitest.expect)(inputEdge.childNodeId).toBe(1);
const enumEdge = deserialized.inputNodes[1].edges[5];
(0, import_vitest.expect)(enumEdge.flags).toBe(2);
(0, import_vitest.expect)(enumEdge.enumNameIndex).toBe(7);
});
(0, import_vitest.test)("handles undefined values correctly", () => {
const data = {
strings: ["root"],
inputNodes: [{ edges: { 0: { flags: 0 } } }],
outputNodes: [{ edges: { 0: {} } }],
roots: { root: { argsNodeId: 0 } }
};
const serialized = (0, import_serialization.serializeParamGraph)(data);
const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
(0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].childNodeId).toBeUndefined();
(0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].scalarMask).toBeUndefined();
(0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].enumNameIndex).toBeUndefined();
(0, import_vitest.expect)(deserialized.outputNodes[0].edges[0].argsNodeId).toBeUndefined();
(0, import_vitest.expect)(deserialized.outputNodes[0].edges[0].outputNodeId).toBeUndefined();
(0, import_vitest.expect)(deserialized.roots["root"].outputNodeId).toBeUndefined();
});
(0, import_vitest.test)("base64url encoding produces URL-safe output", () => {
const data = {
strings: ["test"],
inputNodes: [{ edges: { 255: { flags: 255, scalarMask: 65535, childNodeId: 0, enumNameIndex: 0 } } }],
outputNodes: [],
roots: { test: { argsNodeId: 0 } }
};
const serialized = (0, import_serialization.serializeParamGraph)(data);
(0, import_vitest.expect)(serialized.graph).toMatch(/^[A-Za-z0-9_-]+$/);
});
});
import { describe, expect, test } from "vitest";
import { serializeParamGraph, deserializeParamGraph } from "./serialization";
describe("param-graph serialization", () => {
test("roundtrip with empty data", () => {
const data = {
strings: ["root1"],
inputNodes: [],
outputNodes: [],
roots: { root1: {} }
};
const serialized = serializeParamGraph(data);
const deserialized = deserializeParamGraph(serialized);
expect(deserialized.strings).toEqual(data.strings);
expect(deserialized.inputNodes).toEqual(data.inputNodes);
expect(deserialized.outputNodes).toEqual(data.outputNodes);
expect(deserialized.roots).toEqual(data.roots);
});
test("roundtrip with small data", () => {
const data = {
strings: ["findMany", "where", "id"],
inputNodes: [{ edges: { 1: { flags: 0, scalarMask: 1 } } }],
outputNodes: [{ edges: { 2: { argsNodeId: 0 } } }],
roots: { findMany: { argsNodeId: 0, outputNodeId: 0 } }
};
const serialized = serializeParamGraph(data);
const deserialized = deserializeParamGraph(serialized);
expect(deserialized.strings).toEqual(data.strings);
expect(deserialized.inputNodes.length).toBe(data.inputNodes.length);
expect(deserialized.outputNodes.length).toBe(data.outputNodes.length);
expect(Object.keys(deserialized.roots)).toEqual(Object.keys(data.roots));
});
test("roundtrip with multiple nodes and edges", () => {
const data = {
strings: ["findMany", "create", "update", "where", "data", "id", "name", "Status"],
inputNodes: [
{ edges: { 3: { flags: 1, scalarMask: 1, childNodeId: 1 }, 4: { flags: 0, scalarMask: 2 } } },
{ edges: { 5: { flags: 2, enumNameIndex: 7 } } }
],
outputNodes: [{ edges: { 6: { argsNodeId: 0, outputNodeId: 1 } } }, { edges: {} }],
roots: {
findMany: { argsNodeId: 0, outputNodeId: 0 },
create: { argsNodeId: 1, outputNodeId: 1 },
update: { argsNodeId: 0 }
}
};
const serialized = serializeParamGraph(data);
const deserialized = deserializeParamGraph(serialized);
expect(deserialized.inputNodes.length).toBe(2);
expect(deserialized.outputNodes.length).toBe(2);
expect(Object.keys(deserialized.roots).length).toBe(3);
const inputEdge = deserialized.inputNodes[0].edges[3];
expect(inputEdge.flags).toBe(1);
expect(inputEdge.scalarMask).toBe(1);
expect(inputEdge.childNodeId).toBe(1);
const enumEdge = deserialized.inputNodes[1].edges[5];
expect(enumEdge.flags).toBe(2);
expect(enumEdge.enumNameIndex).toBe(7);
});
test("handles undefined values correctly", () => {
const data = {
strings: ["root"],
inputNodes: [{ edges: { 0: { flags: 0 } } }],
outputNodes: [{ edges: { 0: {} } }],
roots: { root: { argsNodeId: 0 } }
};
const serialized = serializeParamGraph(data);
const deserialized = deserializeParamGraph(serialized);
expect(deserialized.inputNodes[0].edges[0].childNodeId).toBeUndefined();
expect(deserialized.inputNodes[0].edges[0].scalarMask).toBeUndefined();
expect(deserialized.inputNodes[0].edges[0].enumNameIndex).toBeUndefined();
expect(deserialized.outputNodes[0].edges[0].argsNodeId).toBeUndefined();
expect(deserialized.outputNodes[0].edges[0].outputNodeId).toBeUndefined();
expect(deserialized.roots["root"].outputNodeId).toBeUndefined();
});
test("base64url encoding produces URL-safe output", () => {
const data = {
strings: ["test"],
inputNodes: [{ edges: { 255: { flags: 255, scalarMask: 65535, childNodeId: 0, enumNameIndex: 0 } } }],
outputNodes: [],
roots: { test: { argsNodeId: 0 } }
};
const serialized = serializeParamGraph(data);
expect(serialized.graph).toMatch(/^[A-Za-z0-9_-]+$/);
});
});
/**
* Internal data types for ParamGraph.
*
* These types represent the in-memory structure of the param graph,
* used both during building and after deserialization.
*/
/**
* Complete param graph data structure.
* This is the internal representation, not the serialized format.
*/
export interface ParamGraphData {
/** String table containing field names and enum names */
strings: string[];
/** Input nodes for argument objects and input types */
inputNodes: InputNodeData[];
/** Output nodes for selection traversal */
outputNodes: OutputNodeData[];
/** Root mapping: "Model.action" -> entry */
roots: Record<string, RootEntryData>;
}
/**
* Input node data: describes parameterizable fields in an input object.
*/
export interface InputNodeData {
/** Map from string-table index to edge descriptor */
edges: Record<number, InputEdgeData>;
}
/**
* Output node data: describes fields in a selection set.
*/
export interface OutputNodeData {
/** Map from string-table index to edge descriptor */
edges: Record<number, OutputEdgeData>;
}
/**
* Input edge data: describes what a field accepts.
*/
export interface InputEdgeData {
/** Bit flags describing field capabilities (see EdgeFlag) */
flags: number;
/** Child input node id (for object values) */
childNodeId?: number;
/** Scalar type mask (see ScalarMask) */
scalarMask?: number;
/** Enum name index into string table */
enumNameIndex?: number;
}
/**
* Output edge data: describes a field in a selection set.
*/
export interface OutputEdgeData {
/** Args node id for this field */
argsNodeId?: number;
/** Next output node id for nested selection */
outputNodeId?: number;
}
/**
* Root entry data: entry point for an operation.
*/
export interface RootEntryData {
/** Args node id */
argsNodeId?: number;
/** Output node id */
outputNodeId?: number;
}
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var types_exports = {};
module.exports = __toCommonJS(types_exports);
+6
-1

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

export type { EdgeFlagValue, InputEdge, InputNode, NodeId, OutputEdge, OutputNode, ParamGraph, RootEntry, ScalarMaskValue, } from './param-graph';
export { ParamGraph } from './param-graph';
export type { EnumLookup, InputEdge, InputNode, OutputEdge, OutputNode, RootEntry } from './param-graph';
export type { InputEdgeData, InputNodeData, OutputEdgeData, OutputNodeData, ParamGraphData, RootEntryData, } from './param-graph';
export { EdgeFlag, getScalarMask, hasFlag, ScalarMask, scalarTypeToMask } from './param-graph';
export type { EdgeFlagValue, ScalarMaskValue } from './param-graph';
export { deserializeParamGraph, serializeParamGraph } from './serialization';
export type { SerializedParamGraph } from './serialization';
+14
-6

@@ -21,17 +21,25 @@ "use strict";

__export(index_exports, {
EdgeFlag: () => import_param_graph.EdgeFlag,
ScalarMask: () => import_param_graph.ScalarMask,
getScalarMask: () => import_param_graph.getScalarMask,
hasFlag: () => import_param_graph.hasFlag,
scalarTypeToMask: () => import_param_graph.scalarTypeToMask
EdgeFlag: () => import_param_graph2.EdgeFlag,
ParamGraph: () => import_param_graph.ParamGraph,
ScalarMask: () => import_param_graph2.ScalarMask,
deserializeParamGraph: () => import_serialization.deserializeParamGraph,
getScalarMask: () => import_param_graph2.getScalarMask,
hasFlag: () => import_param_graph2.hasFlag,
scalarTypeToMask: () => import_param_graph2.scalarTypeToMask,
serializeParamGraph: () => import_serialization.serializeParamGraph
});
module.exports = __toCommonJS(index_exports);
var import_param_graph = require("./param-graph");
var import_param_graph2 = require("./param-graph");
var import_serialization = require("./serialization");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
EdgeFlag,
ParamGraph,
ScalarMask,
deserializeParamGraph,
getScalarMask,
hasFlag,
scalarTypeToMask
scalarTypeToMask,
serializeParamGraph
});

@@ -0,8 +1,13 @@

import { ParamGraph } from "./param-graph";
import { EdgeFlag, getScalarMask, hasFlag, ScalarMask, scalarTypeToMask } from "./param-graph";
import { deserializeParamGraph, serializeParamGraph } from "./serialization";
export {
EdgeFlag,
ParamGraph,
ScalarMask,
deserializeParamGraph,
getScalarMask,
hasFlag,
scalarTypeToMask
scalarTypeToMask,
serializeParamGraph
};
/**
* ParamGraph: Compact schema for runtime parameterization.
* ParamGraph: Runtime class for schema-aware parameterization.
*
* This data structure is generated from DMMF at client generation time
* and embedded in the generated client. It enables schema-aware
* parameterization where values are only parameterized when both schema
* rules and runtime value types agree.
* This class provides a readable API for navigating the param graph structure
* at runtime. It's created once per PrismaClient instance from the serialized
* format embedded in the generated client.
*/
import type { SerializedParamGraph } from './serialization';
import type { InputEdgeData, InputNodeData, OutputEdgeData, OutputNodeData, ParamGraphData, RootEntryData } from './types';
/**
* Compact schema embedded in the generated client.
* Function type for looking up enum values by name.
* This allows ParamGraph to remain decoupled from RuntimeDataModel.
*/
export type ParamGraph = {
export type EnumLookup = (enumName: string) => readonly string[] | undefined;
/**
* Readable view of root entry.
*/
export interface RootEntry {
readonly argsNodeId: number | undefined;
readonly outputNodeId: number | undefined;
}
/**
* Readable view of input node.
*/
export interface InputNode {
readonly id: number;
}
/**
* Readable view of output node.
*/
export interface OutputNode {
readonly id: number;
}
/**
* Readable view of input edge.
*/
export interface InputEdge {
readonly flags: number;
readonly childNodeId: number | undefined;
readonly scalarMask: number;
readonly enumNameIndex: number | undefined;
}
/**
* Readable view of output edge.
*/
export interface OutputEdge {
readonly argsNodeId: number | undefined;
readonly outputNodeId: number | undefined;
}
/**
* ParamGraph provides runtime access to the schema information
* needed for parameterization decisions.
*/
export declare class ParamGraph {
#private;
private constructor();
/**
* String table to avoid repeating field names.
* Field names are referenced by index throughout the graph.
* Creates a ParamGraph from serialized format.
* This is the primary factory method for runtime use.
*/
s: string[];
static deserialize(serialized: SerializedParamGraph, enumLookup: EnumLookup): ParamGraph;
/**
* User enum names for runtime membership checks.
* Values are looked up via `runtimeDataModel.enums[enumName].values`.
* Creates a ParamGraph from builder data.
* Used by the builder for testing and direct construction.
*/
e: string[];
static fromData(data: ParamGraphData, enumLookup: EnumLookup): ParamGraph;
/**
* Input nodes used for argument objects and input types.
* Each node describes which fields are parameterizable or lead to
* parameterizable descendants.
* Look up a root entry by "Model.action" or "action".
*/
i: InputNode[];
root(key: string): RootEntry | undefined;
/**
* Output nodes used for selection traversal.
* Each node describes which fields have arguments or lead to
* nested selections with arguments.
* Get an input node by ID.
*/
o: OutputNode[];
inputNode(id: number | undefined): InputNode | undefined;
/**
* Root mapping: "Model.action" or "action" (for non-model ops).
* Points to the args node (input) and root output node.
* Get an output node by ID.
*/
r: Record<string, RootEntry>;
};
/**
* Entry point for a root operation.
*/
export type RootEntry = {
/** Args node id (into `i` array) */
a?: NodeId;
/** Output node id (into `o` array) */
o?: NodeId;
};
/**
* Node ID is an index into `i` or `o` array.
*/
export type NodeId = number;
/**
* Input node: describes parameterizable fields in an input object.
* Only fields that are parameterizable or lead to parameterizable
* descendants are present.
*/
export type InputNode = {
outputNode(id: number | undefined): OutputNode | undefined;
/**
* Map from string-table index to edge descriptor.
* Omitted if the node has no fields (shouldn't happen in practice).
* Get an input edge for a field name within a node.
*/
f?: Record<number, InputEdge>;
};
/**
* Output node: describes fields in a selection set that have args
* or nested selections that may contain parameterizable args.
*/
export type OutputNode = {
inputEdge(node: InputNode | undefined, fieldName: string): InputEdge | undefined;
/**
* Map from string-table index to edge descriptor.
* Get an output edge for a field name within a node.
*/
f?: Record<number, OutputEdge>;
};
/**
* Edge descriptor for input fields.
* Encodes what kinds of values the field accepts and how to handle them.
*/
export type InputEdge = {
outputEdge(node: OutputNode | undefined, fieldName: string): OutputEdge | undefined;
/**
* Bit flags describing field capabilities.
* See EdgeFlag enum below.
* Get enum values for an edge that references a user enum.
* Returns undefined if the edge doesn't reference an enum.
*/
k: number;
enumValues(edge: InputEdge | undefined): readonly string[] | undefined;
/**
* Child input node id (for object values or list of objects).
* Present when the field accepts input object types.
* Get a string from the string table by index.
*/
c?: NodeId;
/**
* Scalar type mask for allowed scalar categories.
* Present when field accepts scalar values.
* See ScalarMask enum below.
*/
m?: number;
/**
* Enum name id (index into `en` array).
* Present when field accepts a user enum without a plain String scalar.
* Used for runtime membership validation.
*/
e?: number;
};
getString(index: number): string | undefined;
}
/**
* Edge descriptor for output fields.
* Bit flags for InputEdge.flags describing what the field accepts.
*/
export type OutputEdge = {
/** Args node for this field (if it accepts arguments) */
a?: NodeId;
/** Next output node for nested selection traversal */
o?: NodeId;
};
/**
* Bit flags for InputEdge.k describing what the field accepts.
*/
export declare const EdgeFlag: {

@@ -151,3 +135,3 @@ /**

* Bit mask for scalar type categories.
* Used in InputEdge.m to validate runtime value types.
* Used in InputEdge.scalarMask to validate runtime value types.
*/

@@ -178,1 +162,2 @@ export declare const ScalarMask: {

export declare function scalarTypeToMask(typeName: string): number;
export type { InputEdgeData, InputNodeData, OutputEdgeData, OutputNodeData, ParamGraphData, RootEntryData };

@@ -22,2 +22,3 @@ "use strict";

EdgeFlag: () => EdgeFlag,
ParamGraph: () => ParamGraph,
ScalarMask: () => ScalarMask,

@@ -29,2 +30,132 @@ getScalarMask: () => getScalarMask,

module.exports = __toCommonJS(param_graph_exports);
var import_serialization = require("./serialization");
class ParamGraph {
#data;
#stringIndex;
#enumLookup;
constructor(data, enumLookup) {
this.#data = data;
this.#enumLookup = enumLookup;
this.#stringIndex = /* @__PURE__ */ new Map();
for (let i = 0; i < data.strings.length; i++) {
this.#stringIndex.set(data.strings[i], i);
}
}
/**
* Creates a ParamGraph from serialized format.
* This is the primary factory method for runtime use.
*/
static deserialize(serialized, enumLookup) {
const data = (0, import_serialization.deserializeParamGraph)(serialized);
return new ParamGraph(data, enumLookup);
}
/**
* Creates a ParamGraph from builder data.
* Used by the builder for testing and direct construction.
*/
static fromData(data, enumLookup) {
return new ParamGraph(data, enumLookup);
}
/**
* Look up a root entry by "Model.action" or "action".
*/
root(key) {
const entry = this.#data.roots[key];
if (!entry) {
return void 0;
}
return {
argsNodeId: entry.argsNodeId,
outputNodeId: entry.outputNodeId
};
}
/**
* Get an input node by ID.
*/
inputNode(id) {
if (id === void 0 || id < 0 || id >= this.#data.inputNodes.length) {
return void 0;
}
return { id };
}
/**
* Get an output node by ID.
*/
outputNode(id) {
if (id === void 0 || id < 0 || id >= this.#data.outputNodes.length) {
return void 0;
}
return { id };
}
/**
* Get an input edge for a field name within a node.
*/
inputEdge(node, fieldName) {
if (!node) {
return void 0;
}
const nodeData = this.#data.inputNodes[node.id];
if (!nodeData) {
return void 0;
}
const fieldIndex = this.#stringIndex.get(fieldName);
if (fieldIndex === void 0) {
return void 0;
}
const edge = nodeData.edges[fieldIndex];
if (!edge) {
return void 0;
}
return {
flags: edge.flags,
childNodeId: edge.childNodeId,
scalarMask: edge.scalarMask ?? 0,
enumNameIndex: edge.enumNameIndex
};
}
/**
* Get an output edge for a field name within a node.
*/
outputEdge(node, fieldName) {
if (!node) {
return void 0;
}
const nodeData = this.#data.outputNodes[node.id];
if (!nodeData) {
return void 0;
}
const fieldIndex = this.#stringIndex.get(fieldName);
if (fieldIndex === void 0) {
return void 0;
}
const edge = nodeData.edges[fieldIndex];
if (!edge) {
return void 0;
}
return {
argsNodeId: edge.argsNodeId,
outputNodeId: edge.outputNodeId
};
}
/**
* Get enum values for an edge that references a user enum.
* Returns undefined if the edge doesn't reference an enum.
*/
enumValues(edge) {
if (edge?.enumNameIndex === void 0) {
return void 0;
}
const enumName = this.#data.strings[edge.enumNameIndex];
if (!enumName) {
return void 0;
}
return this.#enumLookup(enumName);
}
/**
* Get a string from the string table by index.
*/
getString(index) {
return this.#data.strings[index];
}
}
const EdgeFlag = {

@@ -74,6 +205,6 @@ /**

function hasFlag(edge, flag) {
return (edge.k & flag) !== 0;
return (edge.flags & flag) !== 0;
}
function getScalarMask(edge) {
return edge.m ?? 0;
return edge.scalarMask;
}

@@ -108,2 +239,3 @@ function scalarTypeToMask(typeName) {

EdgeFlag,
ParamGraph,
ScalarMask,

@@ -110,0 +242,0 @@ getScalarMask,

@@ -0,1 +1,131 @@

import { deserializeParamGraph } from "./serialization";
class ParamGraph {
#data;
#stringIndex;
#enumLookup;
constructor(data, enumLookup) {
this.#data = data;
this.#enumLookup = enumLookup;
this.#stringIndex = /* @__PURE__ */ new Map();
for (let i = 0; i < data.strings.length; i++) {
this.#stringIndex.set(data.strings[i], i);
}
}
/**
* Creates a ParamGraph from serialized format.
* This is the primary factory method for runtime use.
*/
static deserialize(serialized, enumLookup) {
const data = deserializeParamGraph(serialized);
return new ParamGraph(data, enumLookup);
}
/**
* Creates a ParamGraph from builder data.
* Used by the builder for testing and direct construction.
*/
static fromData(data, enumLookup) {
return new ParamGraph(data, enumLookup);
}
/**
* Look up a root entry by "Model.action" or "action".
*/
root(key) {
const entry = this.#data.roots[key];
if (!entry) {
return void 0;
}
return {
argsNodeId: entry.argsNodeId,
outputNodeId: entry.outputNodeId
};
}
/**
* Get an input node by ID.
*/
inputNode(id) {
if (id === void 0 || id < 0 || id >= this.#data.inputNodes.length) {
return void 0;
}
return { id };
}
/**
* Get an output node by ID.
*/
outputNode(id) {
if (id === void 0 || id < 0 || id >= this.#data.outputNodes.length) {
return void 0;
}
return { id };
}
/**
* Get an input edge for a field name within a node.
*/
inputEdge(node, fieldName) {
if (!node) {
return void 0;
}
const nodeData = this.#data.inputNodes[node.id];
if (!nodeData) {
return void 0;
}
const fieldIndex = this.#stringIndex.get(fieldName);
if (fieldIndex === void 0) {
return void 0;
}
const edge = nodeData.edges[fieldIndex];
if (!edge) {
return void 0;
}
return {
flags: edge.flags,
childNodeId: edge.childNodeId,
scalarMask: edge.scalarMask ?? 0,
enumNameIndex: edge.enumNameIndex
};
}
/**
* Get an output edge for a field name within a node.
*/
outputEdge(node, fieldName) {
if (!node) {
return void 0;
}
const nodeData = this.#data.outputNodes[node.id];
if (!nodeData) {
return void 0;
}
const fieldIndex = this.#stringIndex.get(fieldName);
if (fieldIndex === void 0) {
return void 0;
}
const edge = nodeData.edges[fieldIndex];
if (!edge) {
return void 0;
}
return {
argsNodeId: edge.argsNodeId,
outputNodeId: edge.outputNodeId
};
}
/**
* Get enum values for an edge that references a user enum.
* Returns undefined if the edge doesn't reference an enum.
*/
enumValues(edge) {
if (edge?.enumNameIndex === void 0) {
return void 0;
}
const enumName = this.#data.strings[edge.enumNameIndex];
if (!enumName) {
return void 0;
}
return this.#enumLookup(enumName);
}
/**
* Get a string from the string table by index.
*/
getString(index) {
return this.#data.strings[index];
}
}
const EdgeFlag = {

@@ -45,6 +175,6 @@ /**

function hasFlag(edge, flag) {
return (edge.k & flag) !== 0;
return (edge.flags & flag) !== 0;
}
function getScalarMask(edge) {
return edge.m ?? 0;
return edge.scalarMask;
}

@@ -78,2 +208,3 @@ function scalarTypeToMask(typeName) {

EdgeFlag,
ParamGraph,
ScalarMask,

@@ -80,0 +211,0 @@ getScalarMask,

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

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

"license": "Apache-2.0",
"devDependencies": {
"vitest": "^2.1.8"
},
"files": [

@@ -33,4 +36,5 @@ "dist"

"dev": "DEV=true tsx helpers/build.ts",
"build": "tsx helpers/build.ts"
"build": "tsx helpers/build.ts",
"test": "vitest run"
}
}