@prisma-next/sql-contract-ts 0.6.0-dev.1 → 0.6.0-dev.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;iBAMgB,kBAAA,CAAmB,QAAA,EAAU,QAAA,EAAU,MAAA,YAAkB,gBAAA;AAAA,iBASzD,0BAAA,CAA2B,YAAA,UAAsB,MAAA,YAAkB,gBAAA"}
1
+ {"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;iBAmBgB,kBAAA,CAAmB,QAAA,EAAU,QAAA,EAAU,MAAA,YAAkB,gBAAA;AAAA,iBAWzD,0BAAA,CAA2B,YAAA,UAAsB,MAAA,YAAkB,gBAAA"}
@@ -1,7 +1,19 @@
1
1
  import { ifDefined } from "@prisma-next/utils/defined";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import { ok } from "@prisma-next/utils/result";
4
+ import { extname } from "pathe";
4
5
  //#region src/config-types.ts
6
+ /**
7
+ * Derives the emit output path from the TS contract input so artefacts land
8
+ * colocated with the source (e.g. `prisma/contract.ts` →
9
+ * `prisma/contract.json`). Mirrors the same default-derivation logic in
10
+ * `@prisma-next/sql-contract-psl/provider`.
11
+ */
12
+ function defaultOutputFromContractPath(contractPath) {
13
+ const ext = extname(contractPath);
14
+ if (ext.length === 0) return `${contractPath}.json`;
15
+ return `${contractPath.slice(0, -ext.length)}.json`;
16
+ }
5
17
  function typescriptContract(contract, output) {
6
18
  return {
7
19
  source: { load: async () => ok(contract) },
@@ -21,7 +33,7 @@ function typescriptContractFromPath(contractPath, output) {
21
33
  return ok(contract);
22
34
  }
23
35
  },
24
- ...ifDefined("output", output)
36
+ output: output ?? defaultOutputFromContractPath(contractPath)
25
37
  };
26
38
  }
27
39
  //#endregion
@@ -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 type { Contract } from '@prisma-next/contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\n\nexport function typescriptContract(contract: Contract, output?: string): ContractConfig {\n return {\n source: {\n load: async () => ok(contract),\n },\n ...ifDefined('output', output),\n };\n}\n\nexport function typescriptContractFromPath(contractPath: string, output?: string): 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(contract);\n },\n },\n ...ifDefined('output', output),\n };\n}\n"],"mappings":";;;;AAMA,SAAgB,mBAAmB,UAAoB,QAAiC;CACtF,OAAO;EACL,QAAQ,EACN,MAAM,YAAY,GAAG,SAAS,EAC/B;EACD,GAAG,UAAU,UAAU,OAAO;EAC/B;;AAGH,SAAgB,2BAA2B,cAAsB,QAAiC;CAChG,OAAO;EACL,QAAQ;GACN,QAAQ,CAAC,aAAa;GACtB,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,gBAAgB,QAAQ;IAC/B,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,MACR,+IACD;IAEH,MAAM,MAAM,MAAM,OAAO,cAAc,aAAa,CAAC;IACrD,MAAM,WAAiC,IAAI,WAAW,IAAI;IAC1D,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MACR,0CAA0C,aAAa,0CACxD;IAEH,OAAO,GAAG,SAAS;;GAEtB;EACD,GAAG,UAAU,UAAU,OAAO;EAC/B"}
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 type { Contract } from '@prisma-next/contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\nimport { extname } from 'pathe';\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 function typescriptContract(contract: Contract, output?: string): ContractConfig {\n return {\n source: {\n load: async () => ok(contract),\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(contractPath: string, output?: string): 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(contract);\n },\n },\n output: output ?? defaultOutputFromContractPath(contractPath),\n };\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAS,8BAA8B,cAA8B;CACnE,MAAM,MAAM,QAAQ,aAAa;CACjC,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,aAAa;CAC7C,OAAO,GAAG,aAAa,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC;;AAG/C,SAAgB,mBAAmB,UAAoB,QAAiC;CACtF,OAAO;EACL,QAAQ,EACN,MAAM,YAAY,GAAG,SAAS,EAC/B;EAGD,GAAG,UAAU,UAAU,OAAO;EAC/B;;AAGH,SAAgB,2BAA2B,cAAsB,QAAiC;CAChG,OAAO;EACL,QAAQ;GACN,QAAQ,CAAC,aAAa;GACtB,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,gBAAgB,QAAQ;IAC/B,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,MACR,+IACD;IAEH,MAAM,MAAM,MAAM,OAAO,cAAc,aAAa,CAAC;IACrD,MAAM,WAAiC,IAAI,WAAW,IAAI;IAC1D,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MACR,0CAA0C,aAAa,0CACxD;IAEH,OAAO,GAAG,SAAS;;GAEtB;EACD,QAAQ,UAAU,8BAA8B,aAAa;EAC9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma-next/sql-contract-ts",
3
- "version": "0.6.0-dev.1",
3
+ "version": "0.6.0-dev.10",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,12 +9,12 @@
9
9
  "arktype": "^2.1.29",
10
10
  "pathe": "^2.0.3",
11
11
  "ts-toolbelt": "^9.6.0",
12
- "@prisma-next/contract": "0.6.0-dev.1",
13
- "@prisma-next/config": "0.6.0-dev.1",
14
- "@prisma-next/contract-authoring": "0.6.0-dev.1",
15
- "@prisma-next/framework-components": "0.6.0-dev.1",
16
- "@prisma-next/sql-contract": "0.6.0-dev.1",
17
- "@prisma-next/utils": "0.6.0-dev.1"
12
+ "@prisma-next/config": "0.6.0-dev.10",
13
+ "@prisma-next/contract": "0.6.0-dev.10",
14
+ "@prisma-next/sql-contract": "0.6.0-dev.10",
15
+ "@prisma-next/framework-components": "0.6.0-dev.10",
16
+ "@prisma-next/contract-authoring": "0.6.0-dev.10",
17
+ "@prisma-next/utils": "0.6.0-dev.10"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/pg": "8.20.0",
@@ -22,9 +22,9 @@
22
22
  "tsdown": "0.22.0",
23
23
  "typescript": "5.9.3",
24
24
  "vitest": "4.1.5",
25
- "@prisma-next/test-utils": "0.0.1",
26
25
  "@prisma-next/tsconfig": "0.0.0",
27
- "@prisma-next/tsdown": "0.0.0"
26
+ "@prisma-next/tsdown": "0.0.0",
27
+ "@prisma-next/test-utils": "0.0.1"
28
28
  },
29
29
  "files": [
30
30
  "dist",
@@ -3,12 +3,27 @@ import type { ContractConfig } from '@prisma-next/config/config-types';
3
3
  import type { Contract } from '@prisma-next/contract/types';
4
4
  import { ifDefined } from '@prisma-next/utils/defined';
5
5
  import { ok } from '@prisma-next/utils/result';
6
+ import { extname } from 'pathe';
7
+
8
+ /**
9
+ * Derives the emit output path from the TS contract input so artefacts land
10
+ * colocated with the source (e.g. `prisma/contract.ts` →
11
+ * `prisma/contract.json`). Mirrors the same default-derivation logic in
12
+ * `@prisma-next/sql-contract-psl/provider`.
13
+ */
14
+ function defaultOutputFromContractPath(contractPath: string): string {
15
+ const ext = extname(contractPath);
16
+ if (ext.length === 0) return `${contractPath}.json`;
17
+ return `${contractPath.slice(0, -ext.length)}.json`;
18
+ }
6
19
 
7
20
  export function typescriptContract(contract: Contract, output?: string): ContractConfig {
8
21
  return {
9
22
  source: {
10
23
  load: async () => ok(contract),
11
24
  },
25
+ // The in-memory variant has no input path to anchor on; fall through to
26
+ // the global default in `normalizeContractConfig` when caller doesn't pin it.
12
27
  ...ifDefined('output', output),
13
28
  };
14
29
  }
@@ -34,6 +49,6 @@ export function typescriptContractFromPath(contractPath: string, output?: string
34
49
  return ok(contract);
35
50
  },
36
51
  },
37
- ...ifDefined('output', output),
52
+ output: output ?? defaultOutputFromContractPath(contractPath),
38
53
  };
39
54
  }