@prisma-next/mongo-contract-ts 0.12.0-dev.30 → 0.12.0-dev.32
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/README.md +4 -0
- package/dist/config-types.d.mts +6 -3
- package/dist/config-types.d.mts.map +1 -1
- package/dist/config-types.mjs +5 -4
- package/dist/config-types.mjs.map +1 -1
- package/package.json +10 -10
- package/src/config-types.ts +19 -5
package/README.md
CHANGED
|
@@ -83,6 +83,10 @@ export const contract = defineContract({
|
|
|
83
83
|
});
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
## Config helper
|
|
87
|
+
|
|
88
|
+
`typescriptContract` and `typescriptContractFromPath` accept an optional third options bag with `defaultControlPolicy`. The specifier applies it only when the loaded contract omits `defaultControlPolicy`.
|
|
89
|
+
|
|
86
90
|
## Notes
|
|
87
91
|
|
|
88
92
|
- Use `@prisma-next/family-mongo/pack` and `@prisma-next/target-mongo/pack` in authoring flows. They are pure pack refs and do not pull in control-plane runtime code.
|
package/dist/config-types.d.mts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
1
|
+
import { Contract, ControlPolicy } from "@prisma-next/contract/types";
|
|
2
2
|
import { ContractConfig, ContractConfig as ContractConfig$1 } from "@prisma-next/config/config-types";
|
|
3
3
|
|
|
4
4
|
//#region src/config-types.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
interface TypeScriptContractSpecifierOptions {
|
|
6
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
7
|
+
}
|
|
8
|
+
declare function typescriptContract(contract: Contract, output?: string, options?: TypeScriptContractSpecifierOptions): ContractConfig$1;
|
|
9
|
+
declare function typescriptContractFromPath(contractPath: string, output?: string, options?: TypeScriptContractSpecifierOptions): ContractConfig$1;
|
|
7
10
|
//#endregion
|
|
8
11
|
export { type ContractConfig, typescriptContract, typescriptContractFromPath };
|
|
9
12
|
//# sourceMappingURL=config-types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;UAOiB,kCAAA;EAAA,SACN,oBAAA,GAAuB,aAAa;AAAA;AAAA,iBAK/B,kBAAA,CACd,QAAA,EAAU,QAAA,EACV,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAA;AAAA,iBAUa,0BAAA,CACd,YAAA,UACA,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAc"}
|
package/dist/config-types.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { applySpecifierDefaultControlPolicy } from "@prisma-next/contract/apply-specifier-default-control-policy";
|
|
3
4
|
import { ok } from "@prisma-next/utils/result";
|
|
4
5
|
//#region src/config-types.ts
|
|
5
|
-
function typescriptContract(contract, output) {
|
|
6
|
+
function typescriptContract(contract, output, options) {
|
|
6
7
|
return {
|
|
7
|
-
source: { load: async () => ok(contract) },
|
|
8
|
+
source: { load: async () => ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)) },
|
|
8
9
|
...ifDefined("output", output)
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
|
-
function typescriptContractFromPath(contractPath, output) {
|
|
12
|
+
function typescriptContractFromPath(contractPath, output, options) {
|
|
12
13
|
return {
|
|
13
14
|
source: {
|
|
14
15
|
inputs: [contractPath],
|
|
@@ -18,7 +19,7 @@ function typescriptContractFromPath(contractPath, output) {
|
|
|
18
19
|
const mod = await import(pathToFileURL(absolutePath).href);
|
|
19
20
|
const contract = mod.default ?? mod.contract;
|
|
20
21
|
if (contract === void 0) throw new Error(`typescriptContractFromPath: module at "${absolutePath}" has no "default" or "contract" export.`);
|
|
21
|
-
return ok(contract);
|
|
22
|
+
return ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy));
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
...ifDefined("output", output)
|
|
@@ -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\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
|
|
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 { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\n\nexport interface TypeScriptContractSpecifierOptions {\n readonly defaultControlPolicy?: ControlPolicy;\n}\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(\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 ...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 ...ifDefined('output', output),\n };\n}\n"],"mappings":";;;;;AAaA,SAAgB,mBACd,UACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ,EACN,MAAM,YACJ,GAAG,mCAAmC,UAAU,SAAS,oBAAoB,CAAC,EAClF;EACA,GAAG,UAAU,UAAU,MAAM;CAC/B;AACF;AAEA,SAAgB,2BACd,cACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ;GACN,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,EAAE;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,GAAG,UAAU,UAAU,MAAM;CAC/B;AACF"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo-contract-ts",
|
|
3
|
-
"version": "0.12.0-dev.
|
|
3
|
+
"version": "0.12.0-dev.32",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Mongo-specific TypeScript contract authoring surface for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/config": "0.12.0-dev.
|
|
10
|
-
"@prisma-next/contract": "0.12.0-dev.
|
|
11
|
-
"@prisma-next/contract-authoring": "0.12.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.12.0-dev.
|
|
13
|
-
"@prisma-next/mongo-contract": "0.12.0-dev.
|
|
14
|
-
"@prisma-next/utils": "0.12.0-dev.
|
|
9
|
+
"@prisma-next/config": "0.12.0-dev.32",
|
|
10
|
+
"@prisma-next/contract": "0.12.0-dev.32",
|
|
11
|
+
"@prisma-next/contract-authoring": "0.12.0-dev.32",
|
|
12
|
+
"@prisma-next/framework-components": "0.12.0-dev.32",
|
|
13
|
+
"@prisma-next/mongo-contract": "0.12.0-dev.32",
|
|
14
|
+
"@prisma-next/utils": "0.12.0-dev.32",
|
|
15
15
|
"pathe": "^2.0.3"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@prisma-next/test-utils": "0.12.0-dev.
|
|
19
|
-
"@prisma-next/tsconfig": "0.12.0-dev.
|
|
20
|
-
"@prisma-next/tsdown": "0.12.0-dev.
|
|
18
|
+
"@prisma-next/test-utils": "0.12.0-dev.32",
|
|
19
|
+
"@prisma-next/tsconfig": "0.12.0-dev.32",
|
|
20
|
+
"@prisma-next/tsdown": "0.12.0-dev.32",
|
|
21
21
|
"tsdown": "0.22.0",
|
|
22
22
|
"typescript": "5.9.3",
|
|
23
23
|
"vitest": "4.1.6"
|
package/src/config-types.ts
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { pathToFileURL } from 'node:url';
|
|
2
2
|
import type { ContractConfig } from '@prisma-next/config/config-types';
|
|
3
|
-
import
|
|
3
|
+
import { applySpecifierDefaultControlPolicy } from '@prisma-next/contract/apply-specifier-default-control-policy';
|
|
4
|
+
import type { Contract, ControlPolicy } from '@prisma-next/contract/types';
|
|
4
5
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
5
6
|
import { ok } from '@prisma-next/utils/result';
|
|
6
7
|
|
|
8
|
+
export interface TypeScriptContractSpecifierOptions {
|
|
9
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
// This helper stays family-agnostic and intentionally accepts the base Contract shape even when
|
|
8
13
|
// re-exported from a Mongo-specific package.
|
|
9
|
-
export function typescriptContract(
|
|
14
|
+
export function typescriptContract(
|
|
15
|
+
contract: Contract,
|
|
16
|
+
output?: string,
|
|
17
|
+
options?: TypeScriptContractSpecifierOptions,
|
|
18
|
+
): ContractConfig {
|
|
10
19
|
return {
|
|
11
20
|
source: {
|
|
12
|
-
load: async () =>
|
|
21
|
+
load: async () =>
|
|
22
|
+
ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)),
|
|
13
23
|
},
|
|
14
24
|
...ifDefined('output', output),
|
|
15
25
|
};
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
export function typescriptContractFromPath(
|
|
28
|
+
export function typescriptContractFromPath(
|
|
29
|
+
contractPath: string,
|
|
30
|
+
output?: string,
|
|
31
|
+
options?: TypeScriptContractSpecifierOptions,
|
|
32
|
+
): ContractConfig {
|
|
19
33
|
return {
|
|
20
34
|
source: {
|
|
21
35
|
inputs: [contractPath],
|
|
@@ -33,7 +47,7 @@ export function typescriptContractFromPath(contractPath: string, output?: string
|
|
|
33
47
|
`typescriptContractFromPath: module at "${absolutePath}" has no "default" or "contract" export.`,
|
|
34
48
|
);
|
|
35
49
|
}
|
|
36
|
-
return ok(contract);
|
|
50
|
+
return ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy));
|
|
37
51
|
},
|
|
38
52
|
},
|
|
39
53
|
...ifDefined('output', output),
|