🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma-next/sql-runtime

Package Overview
Dependencies
Maintainers
4
Versions
1012
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/sql-runtime - npm Package Compare versions

Comparing version
0.16.0-dev.25
to
0.16.0-dev.26
+61
-8
dist/test/utils.d.mts

@@ -178,11 +178,59 @@ import { C as SqlRuntimeTargetDescriptor, H as decodeRow, S as SqlRuntimeExtensionInstance, V as buildDecodeContext, b as SqlRuntimeDriverInstance, f as ExecutionContext, i as Runtime, o as RuntimeOptions, v as SqlRuntimeAdapterDescriptor, x as SqlRuntimeExtensionDescriptor, y as SqlRuntimeAdapterInstance } from "../prepared-statement-ChI7xyxZ.mjs";

//#region ../1-core/contract/src/ir/sql-index.d.ts
interface IndexInput {
/**
* An index's element structure — exactly one of a column tuple or an opaque
* expression, made unrepresentable-otherwise at the type level. No
* discriminant is stored: the JSON shape stays flat (`columns` or
* `expression`, never both), and the runtime xor guard in the constructor
* remains as the backstop for JSON loads that bypass this input type.
*/
type IndexElements = {
/** Column-tuple elements. */
readonly columns: readonly string[];
readonly name?: string;
readonly type?: string;
readonly options?: Record<string, unknown>;
}
readonly expression?: never;
} | {
readonly columns?: never;
/**
* Opaque SQL: the entire element list between the parens of CREATE
* INDEX — one string, never parsed.
*/
readonly expression: string;
};
/**
* SQL Contract IR node for a table-level secondary index.
* Construction input for {@link Index}. Internal seam (built by lowering and
* FK materialization, not by end users), so every non-element key is
* required and absence is stated explicitly as `undefined` — matching the
* `SqlIndexIRInput` convention.
*/
type IndexInput = IndexElements & {
/** Full wire name (managed) or verbatim physical name (exact). Always present. */
readonly name: string;
/**
* The managed-mode name prefix — its PRESENCE is the naming-mode
* discriminator (there is no stored enum). Present ⇔ managed: the
* toolchain owns the physical name and `name === formatWireName(prefix,
* <8hex content hash>)`, so the author chooses the prefix but never the
* whole name. Absent ⇔ exact: `name` is an adopted verbatim physical name
* (PSL `map:`) whose identity the author owns entirely.
*/
readonly prefix: string | undefined;
/** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */
readonly where: string | undefined;
/** Rendered as CREATE UNIQUE INDEX. */
readonly unique: boolean;
readonly type: string | undefined;
readonly options: Record<string, unknown> | undefined;
};
/**
* SQL Contract IR node for a table-level secondary index, name-identified:
* `name` is the full physical name; a present `prefix` marks the index as
* managed (`name` is `formatWireName(prefix, <8hex>)`), an absent `prefix`
* marks it exact (the name is adopted verbatim).
*
* `expression`, `where`, and `unique` are genuine SQL-family attributes —
* functional and partial indexes are standard SQL supported natively by
* Postgres and SQLite alike, and the family IR must be able to represent
* anything any SQL target can introspect. A target declining to AUTHOR them
* (SQLite's rejection at namespace construction) is a capability decision,
* not evidence of target-specificity.
*
* Note that this class shadows the global TypeScript `Index` lib type

@@ -194,4 +242,9 @@ * at the family-shared name; consumer files that need both should

declare class Index extends SqlNode {
readonly columns: readonly string[];
readonly name?: string;
readonly name: string;
readonly unique: boolean;
/** See {@link IndexInput.prefix} — presence is the naming-mode discriminator. */
readonly prefix?: string;
readonly columns?: readonly string[];
readonly expression?: string;
readonly where?: string;
readonly type?: string;

@@ -198,0 +251,0 @@ readonly options?: Record<string, unknown>;

+1
-1

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

{"version":3,"file":"utils.d.mts","names":[],"sources":["../../../1-core/contract/src/ir/sql-node.ts","../../../1-core/contract/src/ir/check-constraint.ts","../../../1-core/contract/src/ir/foreign-key-reference.ts","../../../1-core/contract/src/ir/foreign-key.ts","../../../1-core/contract/src/ir/primary-key.ts","../../../1-core/contract/src/ir/sql-index.ts","../../../1-core/contract/src/ir/storage-column.ts","../../../1-core/contract/src/ir/unique-constraint.ts","../../../1-core/contract/src/ir/storage-table.ts","../../../1-core/contract/src/ir/storage-value-set.ts","../../../1-core/contract/src/ir/sql-storage.ts","../../../1-core/contract/test/test-support.ts","../../test/utils.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,QAAQ,cAAc,iBACrB,cAAc;iBAuCD,4BACd,SAAS,cACR;;;;iBAoBa,8BAA8B;;;;;;iBAmB9B,kBAAkB,kBAAkB,SAAS,aAC3D,UAAU,WACV,SAAS,aACT;EACE,aAAa,cAAc;IAE5B,iBAAiB;iBAWJ,wBAAwB;EACtC,aAAa,cAAc;EAC3B,SAAS,oDAIP;0DAEH,0CAAA,uCAAA,sCAAA;;;;KAcW,cAAc,QAAQ,WAAW,SAAS,aAAa;WACxD,UAAU,cAAc;;;;;;;iBAQnB,qBAAqB;iBA0FrB,2BACd,QAAQ,eAAe,qBACtB,kBAAkB;iBAIL,4DAAkB;iBAIlB,mBACd,UAAU,QAAQ,KAAK,SAAS;EAC9B;EACA;EACA,SAAS,eAAe;EACxB,SAAS,SAAS;EAClB,UAAU,QAAQ,KAAK;IAExB,SAAS;iBA+BI,WAAW"}
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../../1-core/contract/src/ir/sql-node.ts","../../../1-core/contract/src/ir/check-constraint.ts","../../../1-core/contract/src/ir/foreign-key-reference.ts","../../../1-core/contract/src/ir/foreign-key.ts","../../../1-core/contract/src/ir/primary-key.ts","../../../1-core/contract/src/ir/sql-index.ts","../../../1-core/contract/src/ir/storage-column.ts","../../../1-core/contract/src/ir/unique-constraint.ts","../../../1-core/contract/src/ir/storage-table.ts","../../../1-core/contract/src/ir/storage-value-set.ts","../../../1-core/contract/src/ir/sql-storage.ts","../../../1-core/contract/test/test-support.ts","../../test/utils.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAkCsB,gBAAgB;WAC3B;;;;;;;;;;UC1BM;WACN;WACA;WACA,UAAU;;;;;;;;;;;;;;;;cAiBR,wBAAwB;WAC1B;WACA;WACA,UAAU;cAEP,OAAO;;;;;;;;;;;;;;;UCnBJ;WACN;WACA;WACA;WACA;;;;;;;;;;;;;;;;;;cAmBE,4BAA4B;WAC9B,aAAa;WACb;WACA;WACQ;cA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E,aAAa,cAAc;IAE5B,iBAAiB;iBAWJ,wBAAwB;EACtC,aAAa,cAAc;EAC3B,SAAS,oDAIP;0DAEH,0CAAA,uCAAA,sCAAA;;;;KAcW,cAAc,QAAQ,WAAW,SAAS,aAAa;WACxD,UAAU,cAAc;;;;;;;iBAQnB,qBAAqB;iBA0FrB,2BACd,QAAQ,eAAe,qBACtB,kBAAkB;iBAIL,4DAAkB;iBAIlB,mBACd,UAAU,QAAQ,KAAK,SAAS;EAC9B;EACA;EACA,SAAS,eAAe;EACxB,SAAS,SAAS;EAClB,UAAU,QAAQ,KAAK;IAExB,SAAS;iBA+BI,WAAW"}

@@ -8,2 +8,3 @@ import { a as createExecutionContext, i as decodeRow, o as createSqlExecutionStack, r as buildDecodeContext, t as SqlRuntimeBase } from "../exports-tFHOjuUO.mjs";

import { blindCast } from "@prisma-next/utils/casts";
import "node:crypto";
import { asNamespaceId, coreHash, profileHash } from "@prisma-next/contract/types";

@@ -19,2 +20,3 @@ import { APP_SPACE_ID } from "@prisma-next/framework-components/control";

import { InternalError } from "@prisma-next/utils/internal-error";
import { ContractValidationError } from "@prisma-next/contract/contract-validation-error";
//#region ../1-core/contract/src/contract-errors.ts

@@ -78,4 +80,8 @@ function contractError(code, message, options) {

const IndexSchema = type({
columns: type.string.array().readonly(),
"name?": "string",
name: "string",
"prefix?": "string",
"columns?": type.string.array().readonly(),
"expression?": "string",
"where?": "string",
unique: "boolean",
"type?": "string",

@@ -276,6 +282,45 @@ "options?": "Record<string, unknown>"

//#endregion
//#region ../1-core/schema-ir/dist/naming-BD7Y-Fq1.mjs
const WIRE_NAME_PATTERN = /^(.+)_([0-9a-f]{8})$/;
/**
* Assembles a wire name from its user-supplied prefix and its 8-hex
* content-hash suffix. This module owns the `<prefix>_<hash>` format on both
* sides — construction here and parsing in {@link parseWireName} — so the two
* never drift.
*/
function formatWireName(prefix, hash) {
return `${prefix}_${hash}`;
}
/**
* Splits a wire name (`<prefix>_<8hex>`) into its prefix and content-hash
* suffix. Returns `undefined` when the name does not follow the wire-name
* shape (e.g. an object created outside the toolchain) — callers treat such
* names as all-prefix. Consumed by introspection (prefix extraction) and by
* rename pairing (same hash, different prefix).
*/
function parseWireName(name) {
const match = WIRE_NAME_PATTERN.exec(name);
const prefix = match?.[1];
const hash = match?.[2];
if (prefix === void 0 || hash === void 0) return void 0;
return {
prefix,
hash
};
}
//#endregion
//#region ../1-core/contract/src/ir/sql-index.ts
/**
* SQL Contract IR node for a table-level secondary index.
* SQL Contract IR node for a table-level secondary index, name-identified:
* `name` is the full physical name; a present `prefix` marks the index as
* managed (`name` is `formatWireName(prefix, <8hex>)`), an absent `prefix`
* marks it exact (the name is adopted verbatim).
*
* `expression`, `where`, and `unique` are genuine SQL-family attributes —
* functional and partial indexes are standard SQL supported natively by
* Postgres and SQLite alike, and the family IR must be able to represent
* anything any SQL target can introspect. A target declining to AUTHOR them
* (SQLite's rejection at namespace construction) is a capability decision,
* not evidence of target-specificity.
*
* Note that this class shadows the global TypeScript `Index` lib type

@@ -287,7 +332,18 @@ * at the family-shared name; consumer files that need both should

var Index = class extends SqlNode {
columns;
name;
unique;
constructor(input) {
super();
this.columns = input.columns;
if (input.name !== void 0) this.name = input.name;
if (input.name === void 0 || input.name.length === 0) throw new ContractValidationError("Index: every index carries a full physical name; an expression index must be explicitly named (a default name cannot be derived from an expression).", "storage");
if (input.columns === void 0 === (input.expression === void 0)) throw new ContractValidationError(`Index "${input.name}": exactly one of columns or expression must be set.`, "storage");
if (input.prefix !== void 0) {
const parsed = parseWireName(input.name);
if (parsed === void 0 || parsed.prefix !== input.prefix) throw new ContractValidationError(`Index "${input.name}": prefix "${input.prefix}" does not match the wire name (expected "${formatWireName(input.prefix, "<8hex>")}").`, "storage");
}
this.name = input.name;
this.unique = input.unique;
if (input.prefix !== void 0) this.prefix = input.prefix;
if (input.columns !== void 0) this.columns = input.columns;
if (input.expression !== void 0) this.expression = input.expression;
if (input.where !== void 0) this.where = input.where;
if (input.type !== void 0) this.type = input.type;

@@ -294,0 +350,0 @@ if (input.options !== void 0) this.options = input.options;

{
"name": "@prisma-next/sql-runtime",
"version": "0.16.0-dev.25",
"version": "0.16.0-dev.26",
"license": "Apache-2.0",

@@ -9,18 +9,18 @@ "type": "module",

"dependencies": {
"@prisma-next/contract": "0.16.0-dev.25",
"@prisma-next/utils": "0.16.0-dev.25",
"@prisma-next/framework-components": "0.16.0-dev.25",
"@prisma-next/ids": "0.16.0-dev.25",
"@prisma-next/operations": "0.16.0-dev.25",
"@prisma-next/sql-contract": "0.16.0-dev.25",
"@prisma-next/sql-operations": "0.16.0-dev.25",
"@prisma-next/sql-relational-core": "0.16.0-dev.25",
"@prisma-next/contract": "0.16.0-dev.26",
"@prisma-next/utils": "0.16.0-dev.26",
"@prisma-next/framework-components": "0.16.0-dev.26",
"@prisma-next/ids": "0.16.0-dev.26",
"@prisma-next/operations": "0.16.0-dev.26",
"@prisma-next/sql-contract": "0.16.0-dev.26",
"@prisma-next/sql-operations": "0.16.0-dev.26",
"@prisma-next/sql-relational-core": "0.16.0-dev.26",
"arktype": "^2.2.2"
},
"devDependencies": {
"@prisma-next/test-utils": "0.16.0-dev.25",
"@prisma-next/tsconfig": "0.16.0-dev.25",
"@prisma-next/test-utils": "0.16.0-dev.26",
"@prisma-next/tsconfig": "0.16.0-dev.26",
"@types/pg": "8.20.0",
"pg": "8.22.0",
"@prisma-next/tsdown": "0.16.0-dev.25",
"@prisma-next/tsdown": "0.16.0-dev.26",
"tsdown": "0.22.8",

@@ -27,0 +27,0 @@ "typescript": "5.9.3",

Sorry, the diff of this file is too big to display