@prisma-next/mongo 0.12.0-dev.42 → 0.12.0-dev.43
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,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildBoundContract, field, index, model, rel, valueObject } from "@prisma-next/mongo-contract-ts/contract-builder";
|
|
2
2
|
import mongoFamilyPack from "@prisma-next/family-mongo/pack";
|
|
3
3
|
import mongoTargetPack from "@prisma-next/target-mongo/pack";
|
|
4
4
|
//#region src/contract/define-contract.ts
|
|
5
5
|
function defineContract(definition, factory) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
family: mongoFamilyPack,
|
|
9
|
-
target: mongoTargetPack
|
|
10
|
-
};
|
|
11
|
-
if (factory !== void 0) return defineContract$1(full, factory);
|
|
12
|
-
return defineContract$1(full);
|
|
6
|
+
if (factory !== void 0) return buildBoundContract(mongoFamilyPack, mongoTargetPack, definition, factory);
|
|
7
|
+
return buildBoundContract(mongoFamilyPack, mongoTargetPack, definition);
|
|
13
8
|
}
|
|
14
9
|
//#endregion
|
|
15
10
|
export { defineContract, field, index, model, rel, valueObject };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-builder.mjs","names":[
|
|
1
|
+
{"version":3,"file":"contract-builder.mjs","names":[],"sources":["../src/contract/define-contract.ts"],"sourcesContent":["import mongoFamilyPack from '@prisma-next/family-mongo/pack';\nimport type {\n ContractDefinition,\n ContractFactory,\n ContractScaffold,\n MongoContractResult,\n} from '@prisma-next/mongo-contract-ts/contract-builder';\nimport { buildBoundContract } from '@prisma-next/mongo-contract-ts/contract-builder';\nimport mongoTargetPack from '@prisma-next/target-mongo/pack';\n\ntype MongoFamilyPack = typeof mongoFamilyPack;\ntype MongoTargetPack = typeof mongoTargetPack;\n\n// Helpers type derived from the exported ContractFactory rather than the\n// un-exported ContractAuthoringHelpers, so we stay inside the public surface.\ntype MongoHelpers = Parameters<\n ContractFactory<\n Record<never, never>,\n Record<never, never>,\n undefined,\n MongoFamilyPack,\n MongoTargetPack,\n undefined\n >\n>[0];\n\n// Input types omit family + target AND explicitly forbid them so that\n// `@ts-expect-error` tests can verify the fields are rejected.\ntype MongoDefinitionInput = Omit<\n ContractDefinition<MongoFamilyPack, MongoTargetPack>,\n 'family' | 'target'\n> & {\n readonly family?: never;\n readonly target?: never;\n};\n\ntype MongoScaffoldInput = Omit<\n ContractScaffold<MongoFamilyPack, MongoTargetPack>,\n 'family' | 'target'\n> & {\n readonly family?: never;\n readonly target?: never;\n};\n\n// Overload 1: definition form — models / valueObjects inline in the definition object.\nexport function defineContract<const Definition extends MongoDefinitionInput>(\n definition: Definition,\n): MongoContractResult<\n Definition & { readonly family: MongoFamilyPack; readonly target: MongoTargetPack }\n>;\n\n// Overload 2: factory form — models / valueObjects provided by a factory function.\nexport function defineContract<\n const Definition extends MongoScaffoldInput,\n const Built extends {\n readonly models?: Record<string, unknown>;\n readonly valueObjects?: Record<string, unknown>;\n readonly roots?: Record<string, string>;\n },\n>(\n scaffold: Definition,\n factory: (helpers: MongoHelpers) => Built,\n): MongoContractResult<\n Definition & Built & { readonly family: MongoFamilyPack; readonly target: MongoTargetPack }\n>;\n\n// Implementation — delegates to buildBoundContract which pre-binds family/target\n// and calls buildContractFromDefinition directly, carrying zero casts at this layer.\nexport function defineContract(\n definition: MongoDefinitionInput,\n factory?: ContractFactory<\n Record<string, never>,\n Record<string, never>,\n undefined,\n MongoFamilyPack,\n MongoTargetPack,\n undefined\n >,\n) {\n if (factory !== undefined) {\n return buildBoundContract(mongoFamilyPack, mongoTargetPack, definition, factory);\n }\n return buildBoundContract(mongoFamilyPack, mongoTargetPack, definition);\n}\n"],"mappings":";;;;AAoEA,SAAgB,eACd,YACA,SAQA;CACA,IAAI,YAAY,KAAA,GACd,OAAO,mBAAmB,iBAAiB,iBAAiB,YAAY,OAAO;CAEjF,OAAO,mBAAmB,iBAAiB,iBAAiB,UAAU;AACxE"}
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo",
|
|
3
|
-
"version": "0.12.0-dev.
|
|
3
|
+
"version": "0.12.0-dev.43",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "One-package Mongo setup for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/adapter-mongo": "0.12.0-dev.
|
|
10
|
-
"@prisma-next/cli": "0.12.0-dev.
|
|
11
|
-
"@prisma-next/config": "0.12.0-dev.
|
|
12
|
-
"@prisma-next/contract": "0.12.0-dev.
|
|
13
|
-
"@prisma-next/driver-mongo": "0.12.0-dev.
|
|
14
|
-
"@prisma-next/family-mongo": "0.12.0-dev.
|
|
15
|
-
"@prisma-next/framework-components": "0.12.0-dev.
|
|
16
|
-
"@prisma-next/mongo-contract": "0.12.0-dev.
|
|
17
|
-
"@prisma-next/mongo-contract-psl": "0.12.0-dev.
|
|
18
|
-
"@prisma-next/mongo-contract-ts": "0.12.0-dev.
|
|
19
|
-
"@prisma-next/mongo-orm": "0.12.0-dev.
|
|
20
|
-
"@prisma-next/mongo-query-builder": "0.12.0-dev.
|
|
21
|
-
"@prisma-next/mongo-runtime": "0.12.0-dev.
|
|
22
|
-
"@prisma-next/target-mongo": "0.12.0-dev.
|
|
23
|
-
"@prisma-next/utils": "0.12.0-dev.
|
|
9
|
+
"@prisma-next/adapter-mongo": "0.12.0-dev.43",
|
|
10
|
+
"@prisma-next/cli": "0.12.0-dev.43",
|
|
11
|
+
"@prisma-next/config": "0.12.0-dev.43",
|
|
12
|
+
"@prisma-next/contract": "0.12.0-dev.43",
|
|
13
|
+
"@prisma-next/driver-mongo": "0.12.0-dev.43",
|
|
14
|
+
"@prisma-next/family-mongo": "0.12.0-dev.43",
|
|
15
|
+
"@prisma-next/framework-components": "0.12.0-dev.43",
|
|
16
|
+
"@prisma-next/mongo-contract": "0.12.0-dev.43",
|
|
17
|
+
"@prisma-next/mongo-contract-psl": "0.12.0-dev.43",
|
|
18
|
+
"@prisma-next/mongo-contract-ts": "0.12.0-dev.43",
|
|
19
|
+
"@prisma-next/mongo-orm": "0.12.0-dev.43",
|
|
20
|
+
"@prisma-next/mongo-query-builder": "0.12.0-dev.43",
|
|
21
|
+
"@prisma-next/mongo-runtime": "0.12.0-dev.43",
|
|
22
|
+
"@prisma-next/target-mongo": "0.12.0-dev.43",
|
|
23
|
+
"@prisma-next/utils": "0.12.0-dev.43",
|
|
24
24
|
"pathe": "^2.0.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"mongodb": "^7.2.0",
|
|
28
|
-
"@prisma-next/test-utils": "0.12.0-dev.
|
|
29
|
-
"@prisma-next/tsconfig": "0.12.0-dev.
|
|
30
|
-
"@prisma-next/tsdown": "0.12.0-dev.
|
|
28
|
+
"@prisma-next/test-utils": "0.12.0-dev.43",
|
|
29
|
+
"@prisma-next/tsconfig": "0.12.0-dev.43",
|
|
30
|
+
"@prisma-next/tsdown": "0.12.0-dev.43",
|
|
31
31
|
"mongodb-memory-server": "11.1.0",
|
|
32
32
|
"tsdown": "0.22.0",
|
|
33
33
|
"typescript": "5.9.3",
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
ContractScaffold,
|
|
6
6
|
MongoContractResult,
|
|
7
7
|
} from '@prisma-next/mongo-contract-ts/contract-builder';
|
|
8
|
-
import {
|
|
8
|
+
import { buildBoundContract } from '@prisma-next/mongo-contract-ts/contract-builder';
|
|
9
9
|
import mongoTargetPack from '@prisma-next/target-mongo/pack';
|
|
10
10
|
|
|
11
11
|
type MongoFamilyPack = typeof mongoFamilyPack;
|
|
@@ -64,36 +64,21 @@ export function defineContract<
|
|
|
64
64
|
Definition & Built & { readonly family: MongoFamilyPack; readonly target: MongoTargetPack }
|
|
65
65
|
>;
|
|
66
66
|
|
|
67
|
-
// Implementation — pre-binds family
|
|
68
|
-
//
|
|
69
|
-
// and the only difference between the public overload signatures and the impl is
|
|
70
|
-
// that we union both call forms here.
|
|
67
|
+
// Implementation — delegates to buildBoundContract which pre-binds family/target
|
|
68
|
+
// and calls buildContractFromDefinition directly, carrying zero casts at this layer.
|
|
71
69
|
export function defineContract(
|
|
72
70
|
definition: MongoDefinitionInput,
|
|
73
|
-
factory?:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
...definition,
|
|
83
|
-
family: mongoFamilyPack,
|
|
84
|
-
target: mongoTargetPack,
|
|
85
|
-
} as ContractDefinition<MongoFamilyPack, MongoTargetPack>;
|
|
86
|
-
|
|
71
|
+
factory?: ContractFactory<
|
|
72
|
+
Record<string, never>,
|
|
73
|
+
Record<string, never>,
|
|
74
|
+
undefined,
|
|
75
|
+
MongoFamilyPack,
|
|
76
|
+
MongoTargetPack,
|
|
77
|
+
undefined
|
|
78
|
+
>,
|
|
79
|
+
) {
|
|
87
80
|
if (factory !== undefined) {
|
|
88
|
-
return
|
|
89
|
-
full as ContractScaffold<MongoFamilyPack, MongoTargetPack>,
|
|
90
|
-
factory as unknown as Parameters<typeof baseDefineContract>[1],
|
|
91
|
-
) as unknown as MongoContractResult<
|
|
92
|
-
MongoDefinitionInput & { readonly family: MongoFamilyPack; readonly target: MongoTargetPack }
|
|
93
|
-
>;
|
|
81
|
+
return buildBoundContract(mongoFamilyPack, mongoTargetPack, definition, factory);
|
|
94
82
|
}
|
|
95
|
-
|
|
96
|
-
return baseDefineContract(full) as unknown as MongoContractResult<
|
|
97
|
-
MongoDefinitionInput & { readonly family: MongoFamilyPack; readonly target: MongoTargetPack }
|
|
98
|
-
>;
|
|
83
|
+
return buildBoundContract(mongoFamilyPack, mongoTargetPack, definition);
|
|
99
84
|
}
|