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

@prisma-next/sql-contract-psl

Package Overview
Dependencies
Maintainers
4
Versions
558
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/sql-contract-psl - npm Package Compare versions

Comparing version
0.16.0-dev.11
to
0.16.0-dev.12
dist/interpreter-wLRKYagL.mjs

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

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

+1
-1

@@ -34,3 +34,3 @@ import { Contract, ValueSetRef } from "@prisma-next/contract/types";

readonly target: TargetPackRef<'sql', string>;
readonly scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly scalarColumnDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly composedExtensionPacks?: readonly string[];

@@ -37,0 +37,0 @@ readonly composedExtensionPackRefs?: readonly ExtensionPackRef<'sql', string>[];

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

{"version":3,"file":"index.d.mts","names":[],"sources":["../src/psl-column-resolution.ts","../src/interpreter.ts"],"mappings":";;;;;;;;;;;KAsDY;WACD;WACA;WACA;WACA,aAAa;;;;;;;;;WASb,WAAW;;;;UCsDL;WACN,aAAa;WACb,YAAY;WACZ;WACA,QAAQ;WACR,uBAAuB,oBAAoB;WAC3C;WACA,qCAAqC;WACrC,0BAA0B;WAC1B,yBAAyB;;;;;;;;;;WAUzB,4BAA4B,oBAAoB;;WAEhD,kBAAkB,OAAO,sBAAsB;WAC/C,cAAc;WACd,2BAA2B;;WAE3B;aAAiC;aAAuB;;WACxD,cAAc;;iBAgxDT,kCACd,OAAO,yCACN,OAAO,UAAU"}
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/psl-column-resolution.ts","../src/interpreter.ts"],"mappings":";;;;;;;;;;;KAsDY;WACD;WACA;WACA;WACA,aAAa;;;;;;;;;WASb,WAAW;;;;UCmDL;WACN,aAAa;WACb,YAAY;WACZ;WACA,QAAQ;WACR,yBAAyB,oBAAoB;WAC7C;WACA,qCAAqC;WACrC,0BAA0B;WAC1B,yBAAyB;;;;;;;;;;WAUzB,4BAA4B,oBAAoB;;WAEhD,kBAAkB,OAAO,sBAAsB;WAC/C,cAAc;WACd,2BAA2B;;WAE3B;aAAiC;aAAuB;;WACxD,cAAc;;iBAgxDT,kCACd,OAAO,yCACN,OAAO,UAAU"}

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

import { t as interpretPslDocumentToSqlContract } from "./interpreter-DSPf6xXE.mjs";
import { t as interpretPslDocumentToSqlContract } from "./interpreter-wLRKYagL.mjs";
export { interpretPslDocumentToSqlContract };

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

{"version":3,"file":"provider.d.mts","names":[],"sources":["../src/provider.ts"],"mappings":";;;;;UAoBiB;WACN;WACA,QAAQ;WACR,qCAAqC;WACrC,kBAAkB,OAAO,sBAAsB;WAC/C,uBAAuB;;WAEvB;aAAiC;aAAuB;;;iBAkDnD,eAAe,oBAAoB,SAAS,wBAAwB"}
{"version":3,"file":"provider.d.mts","names":[],"sources":["../src/provider.ts"],"mappings":";;;;;UAoBiB;WACN;WACA,QAAQ;WACR,qCAAqC;WACrC,kBAAkB,OAAO,sBAAsB;WAC/C,uBAAuB;;WAEvB;aAAiC;aAAuB;;;iBAqCnD,eAAe,oBAAoB,SAAS,wBAAwB"}

@@ -1,2 +0,3 @@

import { t as interpretPslDocumentToSqlContract } from "./interpreter-DSPf6xXE.mjs";
import { t as interpretPslDocumentToSqlContract } from "./interpreter-wLRKYagL.mjs";
import { collectScalarTypeConstructors } from "@prisma-next/framework-components/authoring";
import { buildSymbolTable, rangeToPslSpan } from "@prisma-next/psl-parser";

@@ -34,14 +35,2 @@ import { ifDefined } from "@prisma-next/utils/defined";

}
function buildColumnDescriptorMap(scalarTypeDescriptors, codecLookup) {
const result = /* @__PURE__ */ new Map();
for (const [typeName, codecId] of scalarTypeDescriptors) {
const nativeType = codecLookup.targetTypesFor(codecId)?.[0];
if (nativeType === void 0) continue;
result.set(typeName, {
codecId,
nativeType
});
}
return result;
}
function prismaContract(schemaPath, options) {

@@ -53,3 +42,3 @@ return {

interpret(input, context) {
const scalarTypeDescriptors = buildColumnDescriptorMap(context.scalarTypeDescriptors, context.codecLookup);
const scalarColumnDescriptors = collectScalarTypeConstructors(context.authoringContributions.type);
return interpretPslDocumentToSqlContract({

@@ -62,3 +51,3 @@ symbolTable: input.symbolTable,

authoringContributions: context.authoringContributions,
scalarTypeDescriptors,
scalarColumnDescriptors,
...ifDefined("composedExtensionPacks", context.composedExtensionPacks.length > 0 ? [...context.composedExtensionPacks] : void 0),

@@ -100,3 +89,2 @@ composedExtensionContracts: context.composedExtensionContracts,

sourceFile,
scalarTypes: [...context.scalarTypeDescriptors.keys()],
pslBlockDescriptors: context.authoringContributions.pslBlockDescriptors

@@ -103,0 +91,0 @@ });

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

{"version":3,"file":"provider.mjs","names":[],"sources":["../src/provider.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { ContractConfig, ContractSourceDiagnostic } from '@prisma-next/config/config-types';\nimport { applySpecifierDefaultControlPolicy } from '@prisma-next/contract/apply-specifier-default-control-policy';\nimport type { ControlPolicy } from '@prisma-next/contract/types';\nimport type { CodecLookup } from '@prisma-next/framework-components/codec';\nimport type { ExtensionPackRef, TargetPackRef } from '@prisma-next/framework-components/components';\nimport { buildSymbolTable, rangeToPslSpan } from '@prisma-next/psl-parser';\nimport type { PslInterpretCapable } from '@prisma-next/psl-parser/interpret';\nimport { withSeedDiagnostics } from '@prisma-next/psl-parser/interpret';\nimport type { ParseDiagnostic, SourceFile } from '@prisma-next/psl-parser/syntax';\nimport { parse } from '@prisma-next/psl-parser/syntax';\nimport type { SqlNamespaceBase, SqlNamespaceInput } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { InternalError } from '@prisma-next/utils/internal-error';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { basename, extname } from 'pathe';\n\nimport { interpretPslDocumentToSqlContract } from './interpreter';\nimport type { ColumnDescriptor } from './psl-column-resolution';\n\nexport interface PrismaContractOptions {\n readonly output?: string;\n readonly target: TargetPackRef<'sql', string>;\n readonly composedExtensionPackRefs?: readonly ExtensionPackRef<'sql', string>[];\n readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;\n readonly defaultControlPolicy?: ControlPolicy;\n /** The target's default codec ids for an `enum` block that omits `@@type`. */\n readonly enumInferenceCodecs?: { readonly text: string; readonly int: string };\n}\n\n/**\n * Derives the emit output path from the schema input path so artefacts land\n * colocated with the source (e.g. `src/contract/schema.prisma` →\n * `src/contract/contract.json`). The provider owns this because it is the\n * only layer that knows the input path; the upstream `normalizeContractConfig`\n * default is a last-resort fallback for providers that don't carry one.\n */\nfunction defaultOutputFromSchemaPath(schemaPath: string): string {\n const ext = extname(schemaPath);\n if (ext.length === 0) return `${schemaPath}.json`;\n const base = schemaPath.slice(0, -ext.length);\n // PSL schemas commonly use `schema.prisma`; the emitted JSON is called\n // `contract.json` to mirror the rest of the toolchain, not `schema.json`.\n // Match only the exact basename `schema` so files like `my-schema.prisma`\n // are not silently rewritten to `my-contract.json`.\n if (basename(base) === 'schema') {\n return `${base.slice(0, -'schema'.length)}contract.json`;\n }\n return `${base}.json`;\n}\n\nfunction mapParseDiagnostics(\n diagnostics: readonly ParseDiagnostic[],\n sourceFile: SourceFile,\n sourceId: string,\n): ContractSourceDiagnostic[] {\n return diagnostics.map((diagnostic) => ({\n code: diagnostic.code,\n message: diagnostic.message,\n sourceId,\n span: rangeToPslSpan(diagnostic.range, sourceFile),\n }));\n}\n\nfunction buildColumnDescriptorMap(\n scalarTypeDescriptors: ReadonlyMap<string, string>,\n codecLookup: CodecLookup,\n): ReadonlyMap<string, ColumnDescriptor> {\n const result = new Map<string, ColumnDescriptor>();\n for (const [typeName, codecId] of scalarTypeDescriptors) {\n const nativeType = codecLookup.targetTypesFor(codecId)?.[0];\n if (nativeType === undefined) continue;\n result.set(typeName, { codecId, nativeType });\n }\n return result;\n}\n\nexport function prismaContract(schemaPath: string, options: PrismaContractOptions): ContractConfig {\n const source: PslInterpretCapable = {\n sourceFormat: 'psl',\n inputs: [schemaPath],\n interpret(input, context) {\n const scalarTypeDescriptors = buildColumnDescriptorMap(\n context.scalarTypeDescriptors,\n context.codecLookup,\n );\n return interpretPslDocumentToSqlContract({\n symbolTable: input.symbolTable,\n sourceFile: input.sourceFile,\n sourceId: input.sourceId,\n seedDiagnostics: [],\n target: options.target,\n authoringContributions: context.authoringContributions,\n scalarTypeDescriptors,\n ...ifDefined(\n 'composedExtensionPacks',\n context.composedExtensionPacks.length > 0\n ? [...context.composedExtensionPacks]\n : undefined,\n ),\n composedExtensionContracts: context.composedExtensionContracts,\n ...ifDefined(\n 'composedExtensionPackRefs',\n options.composedExtensionPackRefs?.length ? options.composedExtensionPackRefs : undefined,\n ),\n controlMutationDefaults: context.controlMutationDefaults,\n createNamespace: options.createNamespace,\n capabilities: context.capabilities,\n codecLookup: context.codecLookup,\n ...ifDefined('enumInferenceCodecs', options.enumInferenceCodecs),\n });\n },\n async load(context) {\n const [absoluteSchemaPath] = context.resolvedInputs;\n if (absoluteSchemaPath === undefined) {\n throw new InternalError(\n 'prismaContract: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',\n );\n }\n let schema: string;\n try {\n schema = await readFile(absoluteSchemaPath, 'utf-8');\n } catch (error) {\n const message = String(error);\n return notOk({\n summary: `Failed to read Prisma schema at \"${schemaPath}\"`,\n diagnostics: [\n {\n code: 'PSL_SCHEMA_READ_FAILED',\n message,\n sourceId: schemaPath,\n },\n ],\n meta: { schemaPath, absoluteSchemaPath, cause: message },\n });\n }\n\n const { document, sourceFile, diagnostics: parseDiagnostics } = parse(schema);\n const { table: symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({\n document,\n sourceFile,\n scalarTypes: [...context.scalarTypeDescriptors.keys()],\n pslBlockDescriptors: context.authoringContributions.pslBlockDescriptors,\n });\n\n // Do not short-circuit on provider-level diagnostics; recovered CST can\n // still produce interpreter diagnostics in the same response.\n const seedDiagnostics = [\n ...mapParseDiagnostics(parseDiagnostics, sourceFile, schemaPath),\n ...mapParseDiagnostics(symbolTableDiagnostics, sourceFile, schemaPath),\n ];\n\n const interpreted = withSeedDiagnostics(\n this.interpret({ document, sourceFile, symbolTable, sourceId: schemaPath }, context),\n seedDiagnostics,\n );\n if (!interpreted.ok) {\n return interpreted;\n }\n\n return ok(\n applySpecifierDefaultControlPolicy(interpreted.value, options.defaultControlPolicy),\n );\n },\n };\n\n return {\n source,\n output: options.output ?? defaultOutputFromSchemaPath(schemaPath),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqCA,SAAS,4BAA4B,YAA4B;CAC/D,MAAM,MAAM,QAAQ,UAAU;CAC9B,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,WAAW;CAC3C,MAAM,OAAO,WAAW,MAAM,GAAG,CAAC,IAAI,MAAM;CAK5C,IAAI,SAAS,IAAI,MAAM,UACrB,OAAO,GAAG,KAAK,MAAM,GAAG,EAAgB,EAAE;CAE5C,OAAO,GAAG,KAAK;AACjB;AAEA,SAAS,oBACP,aACA,YACA,UAC4B;CAC5B,OAAO,YAAY,KAAK,gBAAgB;EACtC,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB;EACA,MAAM,eAAe,WAAW,OAAO,UAAU;CACnD,EAAE;AACJ;AAEA,SAAS,yBACP,uBACA,aACuC;CACvC,MAAM,yBAAS,IAAI,IAA8B;CACjD,KAAK,MAAM,CAAC,UAAU,YAAY,uBAAuB;EACvD,MAAM,aAAa,YAAY,eAAe,OAAO,CAAC,GAAG;EACzD,IAAI,eAAe,KAAA,GAAW;EAC9B,OAAO,IAAI,UAAU;GAAE;GAAS;EAAW,CAAC;CAC9C;CACA,OAAO;AACT;AAEA,SAAgB,eAAe,YAAoB,SAAgD;CAyFjG,OAAO;EACL,QAAA;GAxFA,cAAc;GACd,QAAQ,CAAC,UAAU;GACnB,UAAU,OAAO,SAAS;IAC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,cAAc,oBAClB,KAAK,UAAU;KAAE;KAAU;KAAY;KAAa,UAAU;IAAW,GAAG,OAAO,GACnF,eACF;IACA,IAAI,CAAC,YAAY,IACf,OAAO;IAGT,OAAO,GACL,mCAAmC,YAAY,OAAO,QAAQ,oBAAoB,CACpF;GACF;EAIK;EACL,QAAQ,QAAQ,UAAU,4BAA4B,UAAU;CAClE;AACF"}
{"version":3,"file":"provider.mjs","names":[],"sources":["../src/provider.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { ContractConfig, ContractSourceDiagnostic } from '@prisma-next/config/config-types';\nimport { applySpecifierDefaultControlPolicy } from '@prisma-next/contract/apply-specifier-default-control-policy';\nimport type { ControlPolicy } from '@prisma-next/contract/types';\nimport { collectScalarTypeConstructors } from '@prisma-next/framework-components/authoring';\nimport type { ExtensionPackRef, TargetPackRef } from '@prisma-next/framework-components/components';\nimport { buildSymbolTable, rangeToPslSpan } from '@prisma-next/psl-parser';\nimport type { PslInterpretCapable } from '@prisma-next/psl-parser/interpret';\nimport { withSeedDiagnostics } from '@prisma-next/psl-parser/interpret';\nimport type { ParseDiagnostic, SourceFile } from '@prisma-next/psl-parser/syntax';\nimport { parse } from '@prisma-next/psl-parser/syntax';\nimport type { SqlNamespaceBase, SqlNamespaceInput } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { InternalError } from '@prisma-next/utils/internal-error';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { basename, extname } from 'pathe';\n\nimport { interpretPslDocumentToSqlContract } from './interpreter';\nimport type { ColumnDescriptor } from './psl-column-resolution';\n\nexport interface PrismaContractOptions {\n readonly output?: string;\n readonly target: TargetPackRef<'sql', string>;\n readonly composedExtensionPackRefs?: readonly ExtensionPackRef<'sql', string>[];\n readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;\n readonly defaultControlPolicy?: ControlPolicy;\n /** The target's default codec ids for an `enum` block that omits `@@type`. */\n readonly enumInferenceCodecs?: { readonly text: string; readonly int: string };\n}\n\n/**\n * Derives the emit output path from the schema input path so artefacts land\n * colocated with the source (e.g. `src/contract/schema.prisma` →\n * `src/contract/contract.json`). The provider owns this because it is the\n * only layer that knows the input path; the upstream `normalizeContractConfig`\n * default is a last-resort fallback for providers that don't carry one.\n */\nfunction defaultOutputFromSchemaPath(schemaPath: string): string {\n const ext = extname(schemaPath);\n if (ext.length === 0) return `${schemaPath}.json`;\n const base = schemaPath.slice(0, -ext.length);\n // PSL schemas commonly use `schema.prisma`; the emitted JSON is called\n // `contract.json` to mirror the rest of the toolchain, not `schema.json`.\n // Match only the exact basename `schema` so files like `my-schema.prisma`\n // are not silently rewritten to `my-contract.json`.\n if (basename(base) === 'schema') {\n return `${base.slice(0, -'schema'.length)}contract.json`;\n }\n return `${base}.json`;\n}\n\nfunction mapParseDiagnostics(\n diagnostics: readonly ParseDiagnostic[],\n sourceFile: SourceFile,\n sourceId: string,\n): ContractSourceDiagnostic[] {\n return diagnostics.map((diagnostic) => ({\n code: diagnostic.code,\n message: diagnostic.message,\n sourceId,\n span: rangeToPslSpan(diagnostic.range, sourceFile),\n }));\n}\n\nexport function prismaContract(schemaPath: string, options: PrismaContractOptions): ContractConfig {\n const source: PslInterpretCapable = {\n sourceFormat: 'psl',\n inputs: [schemaPath],\n interpret(input, context) {\n const scalarColumnDescriptors: ReadonlyMap<string, ColumnDescriptor> =\n collectScalarTypeConstructors(context.authoringContributions.type);\n return interpretPslDocumentToSqlContract({\n symbolTable: input.symbolTable,\n sourceFile: input.sourceFile,\n sourceId: input.sourceId,\n seedDiagnostics: [],\n target: options.target,\n authoringContributions: context.authoringContributions,\n scalarColumnDescriptors,\n ...ifDefined(\n 'composedExtensionPacks',\n context.composedExtensionPacks.length > 0\n ? [...context.composedExtensionPacks]\n : undefined,\n ),\n composedExtensionContracts: context.composedExtensionContracts,\n ...ifDefined(\n 'composedExtensionPackRefs',\n options.composedExtensionPackRefs?.length ? options.composedExtensionPackRefs : undefined,\n ),\n controlMutationDefaults: context.controlMutationDefaults,\n createNamespace: options.createNamespace,\n capabilities: context.capabilities,\n codecLookup: context.codecLookup,\n ...ifDefined('enumInferenceCodecs', options.enumInferenceCodecs),\n });\n },\n async load(context) {\n const [absoluteSchemaPath] = context.resolvedInputs;\n if (absoluteSchemaPath === undefined) {\n throw new InternalError(\n 'prismaContract: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',\n );\n }\n let schema: string;\n try {\n schema = await readFile(absoluteSchemaPath, 'utf-8');\n } catch (error) {\n const message = String(error);\n return notOk({\n summary: `Failed to read Prisma schema at \"${schemaPath}\"`,\n diagnostics: [\n {\n code: 'PSL_SCHEMA_READ_FAILED',\n message,\n sourceId: schemaPath,\n },\n ],\n meta: { schemaPath, absoluteSchemaPath, cause: message },\n });\n }\n\n const { document, sourceFile, diagnostics: parseDiagnostics } = parse(schema);\n const { table: symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({\n document,\n sourceFile,\n pslBlockDescriptors: context.authoringContributions.pslBlockDescriptors,\n });\n\n // Do not short-circuit on provider-level diagnostics; recovered CST can\n // still produce interpreter diagnostics in the same response.\n const seedDiagnostics = [\n ...mapParseDiagnostics(parseDiagnostics, sourceFile, schemaPath),\n ...mapParseDiagnostics(symbolTableDiagnostics, sourceFile, schemaPath),\n ];\n\n const interpreted = withSeedDiagnostics(\n this.interpret({ document, sourceFile, symbolTable, sourceId: schemaPath }, context),\n seedDiagnostics,\n );\n if (!interpreted.ok) {\n return interpreted;\n }\n\n return ok(\n applySpecifierDefaultControlPolicy(interpreted.value, options.defaultControlPolicy),\n );\n },\n };\n\n return {\n source,\n output: options.output ?? defaultOutputFromSchemaPath(schemaPath),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,SAAS,4BAA4B,YAA4B;CAC/D,MAAM,MAAM,QAAQ,UAAU;CAC9B,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,WAAW;CAC3C,MAAM,OAAO,WAA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MAAM;OACN;OACA,UAAU;MACZ,CACF;MACA,MAAM;OAAE;OAAY;OAAoB,OAAO;MAAQ;KACzD,CAAC;IACH;IAEA,MAAM,EAAE,UAAU,YAAY,aAAa,qBAAqB,MAAM,MAAM;IAC5E,MAAM,EAAE,OAAO,aAAa,aAAa,2BAA2B,iBAAiB;KACnF;KACA;KACA,qBAAqB,QAAQ,uBAAuB;IACtD,CAAC;IAID,MAAM,kBAAkB,CACtB,GAAG,oBAAoB,kBAAkB,YAAY,UAAU,GAC/D,GAAG,oBAAoB,wBAAwB,YAAY,UAAU,CACvE;IAEA,MAAM,cAAc,oBAClB,KAAK,UAAU;KAAE;KAAU;KAAY;KAAa,UAAU;IAAW,GAAG,OAAO,GACnF,eACF;IACA,IAAI,CAAC,YAAY,IACf,OAAO;IAGT,OAAO,GACL,mCAAmC,YAAY,OAAO,QAAQ,oBAAoB,CACpF;GACF;EAIK;EACL,QAAQ,QAAQ,UAAU,4BAA4B,UAAU;CAClE;AACF"}
{
"name": "@prisma-next/sql-contract-psl",
"version": "0.16.0-dev.11",
"version": "0.16.0-dev.12",
"license": "Apache-2.0",

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

"dependencies": {
"@prisma-next/config": "0.16.0-dev.11",
"@prisma-next/contract": "0.16.0-dev.11",
"@prisma-next/framework-components": "0.16.0-dev.11",
"@prisma-next/psl-parser": "0.16.0-dev.11",
"@prisma-next/sql-contract": "0.16.0-dev.11",
"@prisma-next/sql-contract-ts": "0.16.0-dev.11",
"@prisma-next/utils": "0.16.0-dev.11",
"@prisma-next/config": "0.16.0-dev.12",
"@prisma-next/contract": "0.16.0-dev.12",
"@prisma-next/framework-components": "0.16.0-dev.12",
"@prisma-next/psl-parser": "0.16.0-dev.12",
"@prisma-next/sql-contract": "0.16.0-dev.12",
"@prisma-next/sql-contract-ts": "0.16.0-dev.12",
"@prisma-next/utils": "0.16.0-dev.12",
"pathe": "^2.0.3"
},
"devDependencies": {
"@prisma-next/contract-authoring": "0.16.0-dev.11",
"@prisma-next/test-utils": "0.16.0-dev.11",
"@prisma-next/tsconfig": "0.16.0-dev.11",
"@prisma-next/tsdown": "0.16.0-dev.11",
"@prisma-next/contract-authoring": "0.16.0-dev.12",
"@prisma-next/test-utils": "0.16.0-dev.12",
"@prisma-next/tsconfig": "0.16.0-dev.12",
"@prisma-next/tsdown": "0.16.0-dev.12",
"arktype": "^2.2.2",

@@ -25,0 +25,0 @@ "tsdown": "0.22.8",

@@ -85,5 +85,5 @@ # @prisma-next/sql-contract-psl

- `@prisma-next/sql-contract-psl`
- `interpretPslDocumentToSqlContract({ symbolTable, sourceFile, sourceId, target, scalarTypeDescriptors, composedExtensionContracts, seedDiagnostics?, authoringContributions?, controlMutationDefaults?, composedExtensionPacks? })` — build `symbolTable`/`sourceFile` via `parse(schema)` + `buildSymbolTable(...)` from `@prisma-next/psl-parser`.
- `interpretPslDocumentToSqlContract({ symbolTable, sourceFile, sourceId, target, scalarColumnDescriptors, composedExtensionContracts, seedDiagnostics?, authoringContributions?, controlMutationDefaults?, composedExtensionPacks? })` — build `symbolTable`/`sourceFile` via `parse(schema)` + `buildSymbolTable(...)` from `@prisma-next/psl-parser`.
- `@prisma-next/sql-contract-psl/provider`
- `prismaContract(schemaPath, { output?, target, defaultControlPolicy?, scalarTypeDescriptors, composedExtensionContracts?, authoringContributions?, controlMutationDefaults?, composedExtensionPacks? })`
- `prismaContract(schemaPath, { output?, target, createNamespace, composedExtensionPackRefs?, defaultControlPolicy?, enumInferenceCodecs? })` — scalar column descriptors are derived from the composed stack's authoring type namespace at load time.
- Provider input is fully preassembled by composition layers (for example `@prisma-next/family-sql/control` helpers).

@@ -90,0 +90,0 @@

@@ -5,3 +5,3 @@ import { readFile } from 'node:fs/promises';

import type { ControlPolicy } from '@prisma-next/contract/types';
import type { CodecLookup } from '@prisma-next/framework-components/codec';
import { collectScalarTypeConstructors } from '@prisma-next/framework-components/authoring';
import type { ExtensionPackRef, TargetPackRef } from '@prisma-next/framework-components/components';

@@ -66,15 +66,2 @@ import { buildSymbolTable, rangeToPslSpan } from '@prisma-next/psl-parser';

function buildColumnDescriptorMap(
scalarTypeDescriptors: ReadonlyMap<string, string>,
codecLookup: CodecLookup,
): ReadonlyMap<string, ColumnDescriptor> {
const result = new Map<string, ColumnDescriptor>();
for (const [typeName, codecId] of scalarTypeDescriptors) {
const nativeType = codecLookup.targetTypesFor(codecId)?.[0];
if (nativeType === undefined) continue;
result.set(typeName, { codecId, nativeType });
}
return result;
}
export function prismaContract(schemaPath: string, options: PrismaContractOptions): ContractConfig {

@@ -85,6 +72,4 @@ const source: PslInterpretCapable = {

interpret(input, context) {
const scalarTypeDescriptors = buildColumnDescriptorMap(
context.scalarTypeDescriptors,
context.codecLookup,
);
const scalarColumnDescriptors: ReadonlyMap<string, ColumnDescriptor> =
collectScalarTypeConstructors(context.authoringContributions.type);
return interpretPslDocumentToSqlContract({

@@ -97,3 +82,3 @@ symbolTable: input.symbolTable,

authoringContributions: context.authoringContributions,
scalarTypeDescriptors,
scalarColumnDescriptors,
...ifDefined(

@@ -146,3 +131,2 @@ 'composedExtensionPacks',

sourceFile,
scalarTypes: [...context.scalarTypeDescriptors.keys()],
pslBlockDescriptors: context.authoringContributions.pslBlockDescriptors,

@@ -149,0 +133,0 @@ });

@@ -557,3 +557,3 @@ import type { ContractSourceDiagnostic } from '@prisma-next/config/config-types';

readonly namedTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly scalarColumnDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly authoringContributions: AuthoringContributions | undefined;

@@ -693,3 +693,3 @@ readonly composedExtensions: ReadonlySet<string>;

input.namedTypeDescriptors,
input.scalarTypeDescriptors,
input.scalarColumnDescriptors,
);

@@ -987,3 +987,3 @@ if (!descriptor) {

namedTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>,
scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>,
scalarColumnDescriptors: ReadonlyMap<string, ColumnDescriptor>,
): ColumnDescriptor | undefined {

@@ -996,3 +996,3 @@ if (namedTypeDescriptors.has(field.typeName)) {

}
return scalarTypeDescriptors.get(field.typeName);
return scalarColumnDescriptors.get(field.typeName);
}

@@ -146,3 +146,3 @@ import type { ContractSourceDiagnostic } from '@prisma-next/config/config-types';

readonly sourceFile: SourceFile;
readonly scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly scalarColumnDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly enumHandles?: ReadonlyMap<string, EnumTypeHandle>;

@@ -315,3 +315,3 @@ readonly capabilities: CapabilityMatrix;

sourceId,
scalarTypeDescriptors,
scalarColumnDescriptors,
enumHandles,

@@ -324,2 +324,3 @@ capabilities,

const resolvedFields: ResolvedField[] = [];
const valueObjectStorageTypeName = authoringContributions?.valueObjectStorageType;

@@ -372,3 +373,3 @@ for (const field of Object.values(model.fields)) {

namedTypeDescriptors,
scalarTypeDescriptors,
scalarColumnDescriptors,
authoringContributions,

@@ -387,3 +388,8 @@ composedExtensions,

if (isValueObjectField) {
descriptor = scalarTypeDescriptors.get('Json');
// A stack that declares no valueObjectStorageType has no value-object
// storage — the field is skipped.
descriptor =
valueObjectStorageTypeName !== undefined
? scalarColumnDescriptors.get(valueObjectStorageTypeName)
: undefined;
} else if (isListField) {

@@ -521,12 +527,2 @@ if (capabilities['sql']?.['scalarList'] !== true) {

}
const fieldUsesNamedType = namedTypeDescriptors.has(field.typeName);
if (loweredOnCreate && !fieldUsesNamedType) {
const generatorDescriptor = generatorDescriptorById.get(loweredOnCreate.id);
const generatedDescriptor = generatorDescriptor?.resolveGeneratedColumnDescriptor?.({
generated: loweredOnCreate,
});
if (generatedDescriptor) {
descriptor = generatedDescriptor;
}
}
const mappedColumnName = mapping.fieldColumns.get(field.name) ?? field.name;

@@ -533,0 +529,0 @@ const { idAttribute, uniqueAttribute, idName, uniqueName } = extractFieldConstraintNames({

import type { ContractSourceDiagnostic } from '@prisma-next/config/config-types';
import type { AuthoringContributions } from '@prisma-next/framework-components/authoring';
import type { ResolvedAttribute, ScalarSymbol, TypeAliasSymbol } from '@prisma-next/psl-parser';
import type { NamedTypeSymbol, ResolvedAttribute } from '@prisma-next/psl-parser';
import type { StorageTypeInstance } from '@prisma-next/sql-contract/types';

@@ -15,4 +15,2 @@ import {

type NamedTypeSymbol = ScalarSymbol | TypeAliasSymbol;
export interface ResolveNamedTypeDeclarationsInput {

@@ -22,3 +20,3 @@ readonly declarations: readonly NamedTypeSymbol[];

readonly enumTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly scalarTypeDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly scalarColumnDescriptors: ReadonlyMap<string, ColumnDescriptor>;
readonly composedExtensions: ReadonlySet<string>;

@@ -183,3 +181,3 @@ readonly familyId: string;

const baseDescriptor =
input.enumTypeDescriptors.get(baseType) ?? input.scalarTypeDescriptors.get(baseType);
input.enumTypeDescriptors.get(baseType) ?? input.scalarColumnDescriptors.get(baseType);
if (!baseDescriptor) {

@@ -247,3 +245,3 @@ input.diagnostics.push({

nativeType: baseDescriptor.nativeType,
typeParams: {},
typeParams: baseDescriptor.typeParams ?? {},
},

@@ -250,0 +248,0 @@ ]);

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

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

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