@prisma-next/mongo-contract-ts 0.4.0-dev.9 → 0.4.1
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
CHANGED
|
@@ -3,6 +3,7 @@ import { Contract } from "@prisma-next/contract/types";
|
|
|
3
3
|
|
|
4
4
|
//#region src/config-types.d.ts
|
|
5
5
|
declare function typescriptContract(contract: Contract, output?: string): ContractConfig$1;
|
|
6
|
+
declare function typescriptContractFromPath(contractPath: string, output?: string): ContractConfig$1;
|
|
6
7
|
//#endregion
|
|
7
|
-
export { type ContractConfig, typescriptContract };
|
|
8
|
+
export { type ContractConfig, typescriptContract, typescriptContractFromPath };
|
|
8
9
|
//# sourceMappingURL=config-types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;iBAQgB,kBAAA,WAA6B,4BAA4B;iBASzD,0BAAA,yCAAmE"}
|
package/dist/config-types.mjs
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
1
2
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
2
3
|
import { ok } from "@prisma-next/utils/result";
|
|
3
4
|
|
|
4
5
|
//#region src/config-types.ts
|
|
5
6
|
function typescriptContract(contract, output) {
|
|
6
7
|
return {
|
|
7
|
-
source: async (
|
|
8
|
+
source: { load: async () => ok(contract) },
|
|
9
|
+
...ifDefined("output", output)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function typescriptContractFromPath(contractPath, output) {
|
|
13
|
+
return {
|
|
14
|
+
source: {
|
|
15
|
+
inputs: [contractPath],
|
|
16
|
+
load: async (context) => {
|
|
17
|
+
const [absolutePath] = context.resolvedInputs;
|
|
18
|
+
if (absolutePath === void 0) throw new Error("typescriptContractFromPath: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.");
|
|
19
|
+
const mod = await import(pathToFileURL(absolutePath).href);
|
|
20
|
+
const contract = mod.default ?? mod.contract;
|
|
21
|
+
if (contract === void 0) throw new Error(`typescriptContractFromPath: module at "${absolutePath}" has no "default" or "contract" export.`);
|
|
22
|
+
return ok(contract);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
8
25
|
...ifDefined("output", output)
|
|
9
26
|
};
|
|
10
27
|
}
|
|
11
28
|
|
|
12
29
|
//#endregion
|
|
13
|
-
export { typescriptContract };
|
|
30
|
+
export { typescriptContract, typescriptContractFromPath };
|
|
14
31
|
//# sourceMappingURL=config-types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import 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\n// This helper stays family-agnostic and intentionally accepts the base Contract shape even when\n// re-exported from a Mongo-specific package.\nexport function typescriptContract(contract: Contract, output?: string): ContractConfig {\n return {\n source: async (
|
|
1
|
+
{"version":3,"file":"config-types.mjs","names":["contract: Contract | undefined"],"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\n// This helper stays family-agnostic and intentionally accepts the base Contract shape even when\n// re-exported from a Mongo-specific package.\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":";;;;;AAQA,SAAgB,mBAAmB,UAAoB,QAAiC;AACtF,QAAO;EACL,QAAQ,EACN,MAAM,YAAY,GAAG,SAAS,EAC/B;EACD,GAAG,UAAU,UAAU,OAAO;EAC/B;;AAGH,SAAgB,2BAA2B,cAAsB,QAAiC;AAChG,QAAO;EACL,QAAQ;GACN,QAAQ,CAAC,aAAa;GACtB,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,gBAAgB,QAAQ;AAC/B,QAAI,iBAAiB,OACnB,OAAM,IAAI,MACR,+IACD;IAEH,MAAM,MAAM,MAAM,OAAO,cAAc,aAAa,CAAC;IACrD,MAAMA,WAAiC,IAAI,WAAW,IAAI;AAC1D,QAAI,aAAa,OACf,OAAM,IAAI,MACR,0CAA0C,aAAa,0CACxD;AAEH,WAAO,GAAG,SAAS;;GAEtB;EACD,GAAG,UAAU,UAAU,OAAO;EAC/B"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo-contract-ts",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Mongo-specific TypeScript contract authoring surface for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/mongo-contract": "0.4.
|
|
12
|
-
"@prisma-next/utils": "0.4.
|
|
8
|
+
"pathe": "^2.0.3",
|
|
9
|
+
"@prisma-next/framework-components": "0.4.1",
|
|
10
|
+
"@prisma-next/config": "0.4.1",
|
|
11
|
+
"@prisma-next/mongo-contract": "0.4.1",
|
|
12
|
+
"@prisma-next/utils": "0.4.1",
|
|
13
|
+
"@prisma-next/contract": "0.4.1"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"tsdown": "0.18.4",
|
package/src/config-types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
1
2
|
import type { ContractConfig } from '@prisma-next/config/config-types';
|
|
2
3
|
import type { Contract } from '@prisma-next/contract/types';
|
|
3
4
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
@@ -7,7 +8,34 @@ import { ok } from '@prisma-next/utils/result';
|
|
|
7
8
|
// re-exported from a Mongo-specific package.
|
|
8
9
|
export function typescriptContract(contract: Contract, output?: string): ContractConfig {
|
|
9
10
|
return {
|
|
10
|
-
source:
|
|
11
|
+
source: {
|
|
12
|
+
load: async () => ok(contract),
|
|
13
|
+
},
|
|
14
|
+
...ifDefined('output', output),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function typescriptContractFromPath(contractPath: string, output?: string): ContractConfig {
|
|
19
|
+
return {
|
|
20
|
+
source: {
|
|
21
|
+
inputs: [contractPath],
|
|
22
|
+
load: async (context) => {
|
|
23
|
+
const [absolutePath] = context.resolvedInputs;
|
|
24
|
+
if (absolutePath === undefined) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
'typescriptContractFromPath: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const mod = await import(pathToFileURL(absolutePath).href);
|
|
30
|
+
const contract: Contract | undefined = mod.default ?? mod.contract;
|
|
31
|
+
if (contract === undefined) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`typescriptContractFromPath: module at "${absolutePath}" has no "default" or "contract" export.`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return ok(contract);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
11
39
|
...ifDefined('output', output),
|
|
12
40
|
};
|
|
13
41
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { ContractConfig } from '@prisma-next/config/config-types';
|
|
2
|
-
export { typescriptContract } from '../config-types';
|
|
2
|
+
export { typescriptContract, typescriptContractFromPath } from '../config-types';
|