@prisma-next/sql-contract-ts 0.14.0-dev.3 → 0.14.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-types.d.mts.map +1 -1
- package/dist/config-types.mjs +14 -7
- package/dist/config-types.mjs.map +1 -1
- package/package.json +10 -10
- package/src/config-types.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;;UAsBiB,kCAAA;EAAA,SACN,oBAAA,GAAuB,aAAa;AAAA;AAAA,iBAG/B,aAAA,CAAc,OAAA;EAAA,SACnB,MAAA;EAAA,SACA,MAAA,EAAQ,aAAA;EAAA,SACR,oBAAA,GAAuB,aAAA;AAAA,IAC9B,gBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;;UAsBiB,kCAAA;EAAA,SACN,oBAAA,GAAuB,aAAa;AAAA;AAAA,iBAG/B,aAAA,CAAc,OAAA;EAAA,SACnB,MAAA;EAAA,SACA,MAAA,EAAQ,aAAA;EAAA,SACR,oBAAA,GAAuB,aAAA;AAAA,IAC9B,gBAAA;AAAA,iBAaY,kBAAA,CACd,QAAA,EAAU,QAAA,EACV,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAA;AAAA,iBAaa,0BAAA,CACd,YAAA,UACA,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAc"}
|
package/dist/config-types.mjs
CHANGED
|
@@ -18,24 +18,31 @@ function defaultOutputFromContractPath(contractPath) {
|
|
|
18
18
|
}
|
|
19
19
|
function emptyContract(options) {
|
|
20
20
|
return {
|
|
21
|
-
source: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
source: {
|
|
22
|
+
sourceFormat: "typescript",
|
|
23
|
+
load: async () => {
|
|
24
|
+
return ok(applySpecifierDefaultControlPolicy(buildSqlContractFromDefinition({
|
|
25
|
+
target: options.target,
|
|
26
|
+
models: []
|
|
27
|
+
}), options.defaultControlPolicy));
|
|
28
|
+
}
|
|
29
|
+
},
|
|
27
30
|
...ifDefined("output", options.output)
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
function typescriptContract(contract, output, options) {
|
|
31
34
|
return {
|
|
32
|
-
source: {
|
|
35
|
+
source: {
|
|
36
|
+
sourceFormat: "typescript",
|
|
37
|
+
load: async () => ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy))
|
|
38
|
+
},
|
|
33
39
|
...ifDefined("output", output)
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
42
|
function typescriptContractFromPath(contractPath, output, options) {
|
|
37
43
|
return {
|
|
38
44
|
source: {
|
|
45
|
+
sourceFormat: "typescript",
|
|
39
46
|
inputs: [contractPath],
|
|
40
47
|
load: async (context) => {
|
|
41
48
|
const [absolutePath] = context.resolvedInputs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport type { ContractConfig } from '@prisma-next/config/config-types';\nimport { applySpecifierDefaultControlPolicy } from '@prisma-next/contract/apply-specifier-default-control-policy';\nimport type { Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { TargetPackRef } from '@prisma-next/framework-components/components';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\nimport { extname } from 'pathe';\nimport { buildSqlContractFromDefinition } from './build-contract';\n\n/**\n * Derives the emit output path from the TS contract input so artefacts land\n * colocated with the source (e.g. `prisma/contract.ts` →\n * `prisma/contract.json`). Mirrors the same default-derivation logic in\n * `@prisma-next/sql-contract-psl/provider`.\n */\nfunction defaultOutputFromContractPath(contractPath: string): string {\n const ext = extname(contractPath);\n if (ext.length === 0) return `${contractPath}.json`;\n return `${contractPath.slice(0, -ext.length)}.json`;\n}\n\nexport interface TypeScriptContractSpecifierOptions {\n readonly defaultControlPolicy?: ControlPolicy;\n}\n\nexport function emptyContract(options: {\n readonly output?: string;\n readonly target: TargetPackRef<'sql', string>;\n readonly defaultControlPolicy?: ControlPolicy;\n}): ContractConfig {\n return {\n source: {\n load: async () => {\n const built = buildSqlContractFromDefinition({ target: options.target, models: [] });\n return ok(applySpecifierDefaultControlPolicy(built, options.defaultControlPolicy));\n },\n },\n ...ifDefined('output', options.output),\n };\n}\n\nexport function typescriptContract(\n contract: Contract,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n load: async () =>\n ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)),\n },\n // The in-memory variant has no input path to anchor on; fall through to\n // the global default in `normalizeContractConfig` when caller doesn't pin it.\n ...ifDefined('output', output),\n };\n}\n\nexport function typescriptContractFromPath(\n contractPath: string,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n inputs: [contractPath],\n load: async (context) => {\n const [absolutePath] = context.resolvedInputs;\n if (absolutePath === undefined) {\n throw new Error(\n 'typescriptContractFromPath: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',\n );\n }\n const mod = await import(pathToFileURL(absolutePath).href);\n const contract: Contract | undefined = mod.default ?? mod.contract;\n if (contract === undefined) {\n throw new Error(\n `typescriptContractFromPath: module at \"${absolutePath}\" has no \"default\" or \"contract\" export.`,\n );\n }\n return ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy));\n },\n },\n output: output ?? defaultOutputFromContractPath(contractPath),\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAS,8BAA8B,cAA8B;CACnE,MAAM,MAAM,QAAQ,YAAY;CAChC,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,aAAa;CAC7C,OAAO,GAAG,aAAa,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE;AAC/C;AAMA,SAAgB,cAAc,SAIX;CACjB,OAAO;EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport type { ContractConfig } from '@prisma-next/config/config-types';\nimport { applySpecifierDefaultControlPolicy } from '@prisma-next/contract/apply-specifier-default-control-policy';\nimport type { Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { TargetPackRef } from '@prisma-next/framework-components/components';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\nimport { extname } from 'pathe';\nimport { buildSqlContractFromDefinition } from './build-contract';\n\n/**\n * Derives the emit output path from the TS contract input so artefacts land\n * colocated with the source (e.g. `prisma/contract.ts` →\n * `prisma/contract.json`). Mirrors the same default-derivation logic in\n * `@prisma-next/sql-contract-psl/provider`.\n */\nfunction defaultOutputFromContractPath(contractPath: string): string {\n const ext = extname(contractPath);\n if (ext.length === 0) return `${contractPath}.json`;\n return `${contractPath.slice(0, -ext.length)}.json`;\n}\n\nexport interface TypeScriptContractSpecifierOptions {\n readonly defaultControlPolicy?: ControlPolicy;\n}\n\nexport function emptyContract(options: {\n readonly output?: string;\n readonly target: TargetPackRef<'sql', string>;\n readonly defaultControlPolicy?: ControlPolicy;\n}): ContractConfig {\n return {\n source: {\n sourceFormat: 'typescript',\n load: async () => {\n const built = buildSqlContractFromDefinition({ target: options.target, models: [] });\n return ok(applySpecifierDefaultControlPolicy(built, options.defaultControlPolicy));\n },\n },\n ...ifDefined('output', options.output),\n };\n}\n\nexport function typescriptContract(\n contract: Contract,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n sourceFormat: 'typescript',\n load: async () =>\n ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)),\n },\n // The in-memory variant has no input path to anchor on; fall through to\n // the global default in `normalizeContractConfig` when caller doesn't pin it.\n ...ifDefined('output', output),\n };\n}\n\nexport function typescriptContractFromPath(\n contractPath: string,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n sourceFormat: 'typescript',\n inputs: [contractPath],\n load: async (context) => {\n const [absolutePath] = context.resolvedInputs;\n if (absolutePath === undefined) {\n throw new Error(\n 'typescriptContractFromPath: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',\n );\n }\n const mod = await import(pathToFileURL(absolutePath).href);\n const contract: Contract | undefined = mod.default ?? mod.contract;\n if (contract === undefined) {\n throw new Error(\n `typescriptContractFromPath: module at \"${absolutePath}\" has no \"default\" or \"contract\" export.`,\n );\n }\n return ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy));\n },\n },\n output: output ?? defaultOutputFromContractPath(contractPath),\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAS,8BAA8B,cAA8B;CACnE,MAAM,MAAM,QAAQ,YAAY;CAChC,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,aAAa;CAC7C,OAAO,GAAG,aAAa,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE;AAC/C;AAMA,SAAgB,cAAc,SAIX;CACjB,OAAO;EACL,QAAQ;GACN,cAAc;GACd,MAAM,YAAY;IAEhB,OAAO,GAAG,mCADI,+BAA+B;KAAE,QAAQ,QAAQ;KAAQ,QAAQ,CAAC;IAAE,CACjC,GAAG,QAAQ,oBAAoB,CAAC;GACnF;EACF;EACA,GAAG,UAAU,UAAU,QAAQ,MAAM;CACvC;AACF;AAEA,SAAgB,mBACd,UACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ;GACN,cAAc;GACd,MAAM,YACJ,GAAG,mCAAmC,UAAU,SAAS,oBAAoB,CAAC;EAClF;EAGA,GAAG,UAAU,UAAU,MAAM;CAC/B;AACF;AAEA,SAAgB,2BACd,cACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ;GACN,cAAc;GACd,QAAQ,CAAC,YAAY;GACrB,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,gBAAgB,QAAQ;IAC/B,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,MACR,8IACF;IAEF,MAAM,MAAM,MAAM,OAAO,cAAc,YAAY,CAAC,CAAC;IACrD,MAAM,WAAiC,IAAI,WAAW,IAAI;IAC1D,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MACR,0CAA0C,aAAa,yCACzD;IAEF,OAAO,GAAG,mCAAmC,UAAU,SAAS,oBAAoB,CAAC;GACvF;EACF;EACA,QAAQ,UAAU,8BAA8B,YAAY;CAC9D;AACF"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-contract-ts",
|
|
3
|
-
"version": "0.14.0-dev.
|
|
3
|
+
"version": "0.14.0-dev.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "SQL-specific TypeScript contract authoring surface for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/config": "0.14.0-dev.
|
|
10
|
-
"@prisma-next/contract": "0.14.0-dev.
|
|
11
|
-
"@prisma-next/contract-authoring": "0.14.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.14.0-dev.
|
|
13
|
-
"@prisma-next/sql-contract": "0.14.0-dev.
|
|
14
|
-
"@prisma-next/utils": "0.14.0-dev.
|
|
9
|
+
"@prisma-next/config": "0.14.0-dev.4",
|
|
10
|
+
"@prisma-next/contract": "0.14.0-dev.4",
|
|
11
|
+
"@prisma-next/contract-authoring": "0.14.0-dev.4",
|
|
12
|
+
"@prisma-next/framework-components": "0.14.0-dev.4",
|
|
13
|
+
"@prisma-next/sql-contract": "0.14.0-dev.4",
|
|
14
|
+
"@prisma-next/utils": "0.14.0-dev.4",
|
|
15
15
|
"arktype": "^2.2.0",
|
|
16
16
|
"pathe": "^2.0.3",
|
|
17
17
|
"ts-toolbelt": "^9.6.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@prisma-next/test-utils": "0.14.0-dev.
|
|
21
|
-
"@prisma-next/tsconfig": "0.14.0-dev.
|
|
20
|
+
"@prisma-next/test-utils": "0.14.0-dev.4",
|
|
21
|
+
"@prisma-next/tsconfig": "0.14.0-dev.4",
|
|
22
22
|
"@types/pg": "8.20.0",
|
|
23
23
|
"pg": "8.21.0",
|
|
24
|
-
"@prisma-next/tsdown": "0.14.0-dev.
|
|
24
|
+
"@prisma-next/tsdown": "0.14.0-dev.4",
|
|
25
25
|
"tsdown": "0.22.1",
|
|
26
26
|
"typescript": "5.9.3",
|
|
27
27
|
"vitest": "4.1.8"
|
package/src/config-types.ts
CHANGED
|
@@ -31,6 +31,7 @@ export function emptyContract(options: {
|
|
|
31
31
|
}): ContractConfig {
|
|
32
32
|
return {
|
|
33
33
|
source: {
|
|
34
|
+
sourceFormat: 'typescript',
|
|
34
35
|
load: async () => {
|
|
35
36
|
const built = buildSqlContractFromDefinition({ target: options.target, models: [] });
|
|
36
37
|
return ok(applySpecifierDefaultControlPolicy(built, options.defaultControlPolicy));
|
|
@@ -47,6 +48,7 @@ export function typescriptContract(
|
|
|
47
48
|
): ContractConfig {
|
|
48
49
|
return {
|
|
49
50
|
source: {
|
|
51
|
+
sourceFormat: 'typescript',
|
|
50
52
|
load: async () =>
|
|
51
53
|
ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)),
|
|
52
54
|
},
|
|
@@ -63,6 +65,7 @@ export function typescriptContractFromPath(
|
|
|
63
65
|
): ContractConfig {
|
|
64
66
|
return {
|
|
65
67
|
source: {
|
|
68
|
+
sourceFormat: 'typescript',
|
|
66
69
|
inputs: [contractPath],
|
|
67
70
|
load: async (context) => {
|
|
68
71
|
const [absolutePath] = context.resolvedInputs;
|