@prisma-next/mongo-contract-ts 0.0.1 → 0.3.0-dev.162
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/LICENSE +201 -0
- package/dist/config-types.d.mts +8 -0
- package/dist/config-types.d.mts.map +1 -0
- package/dist/config-types.mjs +14 -0
- package/dist/config-types.mjs.map +1 -0
- package/dist/contract-builder.d.mts +354 -0
- package/dist/contract-builder.d.mts.map +1 -0
- package/dist/contract-builder.mjs +376 -0
- package/dist/contract-builder.mjs.map +1 -0
- package/package.json +23 -23
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2026] [Prisma Data, Inc]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContractConfig, ContractConfig as ContractConfig$1 } from "@prisma-next/config/config-types";
|
|
2
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
3
|
+
|
|
4
|
+
//#region src/config-types.d.ts
|
|
5
|
+
declare function typescriptContract(contract: Contract, output?: string): ContractConfig$1;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type ContractConfig, typescriptContract };
|
|
8
|
+
//# sourceMappingURL=config-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;iBAOgB,kBAAA,WAA6B,4BAA4B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
2
|
+
import { ok } from "@prisma-next/utils/result";
|
|
3
|
+
|
|
4
|
+
//#region src/config-types.ts
|
|
5
|
+
function typescriptContract(contract, output) {
|
|
6
|
+
return {
|
|
7
|
+
source: async (_context) => ok(contract),
|
|
8
|
+
...ifDefined("output", output)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { typescriptContract };
|
|
14
|
+
//# sourceMappingURL=config-types.mjs.map
|
|
@@ -0,0 +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 (_context) => ok(contract),\n ...ifDefined('output', output),\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,mBAAmB,UAAoB,QAAiC;AACtF,QAAO;EACL,QAAQ,OAAO,aAAa,GAAG,SAAS;EACxC,GAAG,UAAU,UAAU,OAAO;EAC/B"}
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { MongoCollectionOptions, MongoContractWithTypeMaps, MongoIndex, MongoIndexFields, MongoIndexOptions, MongoStorage, MongoStorageCollection, MongoTypeMaps } from "@prisma-next/mongo-contract";
|
|
2
|
+
import { ContractFieldType, ProfileHashBase, StorageHashBase } from "@prisma-next/contract/types";
|
|
3
|
+
import { ExtensionPackRef, FamilyPackRef, TargetPackRef } from "@prisma-next/framework-components/components";
|
|
4
|
+
|
|
5
|
+
//#region src/contract-builder.d.ts
|
|
6
|
+
type VariantSpec = {
|
|
7
|
+
readonly value: string;
|
|
8
|
+
};
|
|
9
|
+
type StorageRelationSpec = {
|
|
10
|
+
readonly field: string;
|
|
11
|
+
};
|
|
12
|
+
type ContractCapabilities = Record<string, Record<string, boolean>>;
|
|
13
|
+
type StringListInput = string | readonly string[];
|
|
14
|
+
type Present<T> = Exclude<T, undefined>;
|
|
15
|
+
type EmptyObject = Record<never, never>;
|
|
16
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & EmptyObject;
|
|
17
|
+
type StrictShape<Actual, Shape> = Actual & Shape & Record<Exclude<keyof Actual, keyof Shape>, never>;
|
|
18
|
+
type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends ((value: infer Intersection) => void) ? Intersection : never;
|
|
19
|
+
type ExtractCodecTypesFromPack<P> = P extends {
|
|
20
|
+
__codecTypes?: infer CodecTypes;
|
|
21
|
+
} ? CodecTypes extends Record<string, {
|
|
22
|
+
output: unknown;
|
|
23
|
+
}> ? CodecTypes : Record<string, never> : Record<string, never>;
|
|
24
|
+
type MongoCodecTypes = {
|
|
25
|
+
readonly 'mongo/objectId@1': {
|
|
26
|
+
readonly input: string;
|
|
27
|
+
readonly output: string;
|
|
28
|
+
};
|
|
29
|
+
readonly 'mongo/string@1': {
|
|
30
|
+
readonly input: string;
|
|
31
|
+
readonly output: string;
|
|
32
|
+
};
|
|
33
|
+
readonly 'mongo/double@1': {
|
|
34
|
+
readonly input: number;
|
|
35
|
+
readonly output: number;
|
|
36
|
+
};
|
|
37
|
+
readonly 'mongo/int32@1': {
|
|
38
|
+
readonly input: number;
|
|
39
|
+
readonly output: number;
|
|
40
|
+
};
|
|
41
|
+
readonly 'mongo/bool@1': {
|
|
42
|
+
readonly input: boolean;
|
|
43
|
+
readonly output: boolean;
|
|
44
|
+
};
|
|
45
|
+
readonly 'mongo/date@1': {
|
|
46
|
+
readonly input: Date;
|
|
47
|
+
readonly output: Date;
|
|
48
|
+
};
|
|
49
|
+
readonly 'mongo/vector@1': {
|
|
50
|
+
readonly input: readonly number[];
|
|
51
|
+
readonly output: readonly number[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
type MergeExtensionCodecTypes<Packs extends Record<string, unknown>> = UnionToIntersection<{ [K in keyof Packs]: ExtractCodecTypesFromPack<Packs[K]> }[keyof Packs]>;
|
|
55
|
+
type MergeExtensionCodecTypesSafe<Packs> = Packs extends Record<string, unknown> ? keyof Packs extends never ? Record<string, never> : MergeExtensionCodecTypes<Packs> : Record<string, never>;
|
|
56
|
+
interface FieldBuilder<Type$1 extends ContractFieldType = ContractFieldType, Nullable$1 extends boolean = boolean, Many extends boolean = boolean> {
|
|
57
|
+
readonly __kind: 'field';
|
|
58
|
+
readonly __type: Type$1;
|
|
59
|
+
readonly __nullable: Nullable$1;
|
|
60
|
+
readonly __many: Many;
|
|
61
|
+
optional(): FieldBuilder<Type$1, true, Many>;
|
|
62
|
+
many(): FieldBuilder<Type$1, Nullable$1, true>;
|
|
63
|
+
}
|
|
64
|
+
interface ValueObjectBuilder<Name extends string = string, Fields$1 extends Record<string, FieldBuilder> = Record<string, FieldBuilder>> {
|
|
65
|
+
readonly __kind: 'valueObject';
|
|
66
|
+
readonly __name: Name;
|
|
67
|
+
readonly __fields: Fields$1;
|
|
68
|
+
}
|
|
69
|
+
interface FieldReference<ModelName extends string = string, FieldName extends string = string> {
|
|
70
|
+
readonly __kind: 'fieldRef';
|
|
71
|
+
readonly modelName: ModelName;
|
|
72
|
+
readonly fieldName: FieldName;
|
|
73
|
+
}
|
|
74
|
+
interface RelationOn<LocalFields extends readonly string[] = readonly string[], TargetFields extends readonly string[] = readonly string[]> {
|
|
75
|
+
readonly localFields: LocalFields;
|
|
76
|
+
readonly targetFields: TargetFields;
|
|
77
|
+
}
|
|
78
|
+
interface RelationBuilder<To$1 extends string = string, Cardinality$1 extends '1:1' | '1:N' | 'N:1' = '1:1' | '1:N' | 'N:1', On$1 extends RelationOn | undefined = RelationOn | undefined> {
|
|
79
|
+
readonly __kind: 'relation';
|
|
80
|
+
readonly __to: To$1;
|
|
81
|
+
readonly __cardinality: Cardinality$1;
|
|
82
|
+
readonly __on: On$1;
|
|
83
|
+
}
|
|
84
|
+
interface ModelBuilder<Name extends string = string, Fields$1 extends Record<string, FieldBuilder> = Record<string, FieldBuilder>, Relations$1 extends Record<string, RelationBuilder> = Record<string, RelationBuilder>, Collection extends string | undefined = string | undefined, Owner$1 extends string | undefined = string | undefined, Base$1 extends string | undefined = string | undefined, StorageRelations extends Record<string, StorageRelationSpec> | undefined = Record<string, StorageRelationSpec> | undefined, Discriminator$1 extends {
|
|
85
|
+
readonly field: string;
|
|
86
|
+
} | undefined = {
|
|
87
|
+
readonly field: string;
|
|
88
|
+
} | undefined, Variants$1 extends Record<string, VariantSpec> | undefined = Record<string, VariantSpec> | undefined> {
|
|
89
|
+
readonly __kind: 'model';
|
|
90
|
+
readonly __name: Name;
|
|
91
|
+
readonly __fields: Fields$1;
|
|
92
|
+
readonly __relations: Relations$1;
|
|
93
|
+
readonly __indexes: readonly MongoIndex[] | undefined;
|
|
94
|
+
readonly __collectionOptions: MongoCollectionOptions | undefined;
|
|
95
|
+
readonly __collection: Collection;
|
|
96
|
+
readonly __owner: Owner$1;
|
|
97
|
+
readonly __base: Base$1;
|
|
98
|
+
readonly __storageRelations: StorageRelations;
|
|
99
|
+
readonly __discriminator: Discriminator$1;
|
|
100
|
+
readonly __variants: Variants$1;
|
|
101
|
+
ref<const FieldName extends keyof Fields$1 & string>(fieldName: FieldName): FieldReference<Name, FieldName>;
|
|
102
|
+
}
|
|
103
|
+
type AnyFieldBuilder = FieldBuilder<ContractFieldType, boolean, boolean>;
|
|
104
|
+
type AnyReferenceRelationBuilder = RelationBuilder<string, '1:1' | '1:N' | 'N:1', RelationOn>;
|
|
105
|
+
type AnyEmbedRelationBuilder = RelationBuilder<string, '1:1' | '1:N', undefined>;
|
|
106
|
+
type AnyRelationBuilder = AnyReferenceRelationBuilder | AnyEmbedRelationBuilder;
|
|
107
|
+
type AnyFieldReference = FieldReference<string, string>;
|
|
108
|
+
type NamedValueObjectBuilder<Name extends string = string, Fields$1 extends Record<string, AnyFieldBuilder> = Record<string, AnyFieldBuilder>> = ValueObjectBuilder<Name, Fields$1>;
|
|
109
|
+
type AnyValueObjectBuilder = NamedValueObjectBuilder;
|
|
110
|
+
type NamedModelBuilder<Name extends string = string, Fields$1 extends Record<string, AnyFieldBuilder> = Record<string, AnyFieldBuilder>, Relations$1 extends Record<string, AnyRelationBuilder> = Record<string, AnyRelationBuilder>, Collection extends string | undefined = string | undefined, Owner$1 extends string | undefined = string | undefined, Base$1 extends string | undefined = string | undefined, StorageRelations extends Record<string, StorageRelationSpec> | undefined = Record<string, StorageRelationSpec> | undefined, Discriminator$1 extends {
|
|
111
|
+
readonly field: string;
|
|
112
|
+
} | undefined = {
|
|
113
|
+
readonly field: string;
|
|
114
|
+
} | undefined, Variants$1 extends Record<string, VariantSpec> | undefined = Record<string, VariantSpec> | undefined> = ModelBuilder<Name, Fields$1, Relations$1, Collection, Owner$1, Base$1, StorageRelations, Discriminator$1, Variants$1>;
|
|
115
|
+
type AnyModelBuilder = NamedModelBuilder;
|
|
116
|
+
type ExtractFieldReferenceName<T> = T extends FieldReference<string, infer FieldName extends string> ? FieldName : never;
|
|
117
|
+
type ExtractModelName<T> = T extends NamedModelBuilder<infer Name> ? Name : never;
|
|
118
|
+
type ExtractValueObjectName<T> = T extends NamedValueObjectBuilder<infer Name> ? Name : never;
|
|
119
|
+
type ExtractModelCollection<T> = T extends NamedModelBuilder<string, Record<string, AnyFieldBuilder>, Record<string, AnyRelationBuilder>, infer Collection> ? Collection : never;
|
|
120
|
+
type ExtractModelOwner<T> = T extends NamedModelBuilder<string, Record<string, AnyFieldBuilder>, Record<string, AnyRelationBuilder>, string | undefined, infer Owner> ? Owner : never;
|
|
121
|
+
type ExtractModelBase<T> = T extends NamedModelBuilder<string, Record<string, AnyFieldBuilder>, Record<string, AnyRelationBuilder>, string | undefined, string | undefined, infer Base> ? Base : never;
|
|
122
|
+
type ExtractModelStorageRelations<T> = T extends NamedModelBuilder<string, Record<string, AnyFieldBuilder>, Record<string, AnyRelationBuilder>, string | undefined, string | undefined, string | undefined, infer StorageRelations> ? StorageRelations : never;
|
|
123
|
+
type ModelStorageSection<T> = ExtractModelCollection<T> extends string ? {
|
|
124
|
+
readonly collection: ExtractModelCollection<T>;
|
|
125
|
+
} : EmptyObject;
|
|
126
|
+
type ModelStorageRelationsSection<T> = ExtractModelStorageRelations<T> extends Record<string, StorageRelationSpec> ? keyof ExtractModelStorageRelations<T> extends never ? EmptyObject : {
|
|
127
|
+
readonly relations: ExtractModelStorageRelations<T>;
|
|
128
|
+
} : EmptyObject;
|
|
129
|
+
type RootModelCollection<T> = ExtractModelCollection<T> extends string ? ExtractModelOwner<T> extends undefined ? ExtractModelBase<T> extends undefined ? ExtractModelCollection<T> : never : never : never;
|
|
130
|
+
type RootModelName<T> = RootModelCollection<T> extends never ? never : ExtractModelName<T>;
|
|
131
|
+
type CollectionName<T> = ExtractModelCollection<T> extends string ? ExtractModelCollection<T> : never;
|
|
132
|
+
type ModelNameInput = string | AnyModelBuilder;
|
|
133
|
+
type ValueObjectNameInput = string | AnyValueObjectBuilder;
|
|
134
|
+
type RelationTargetFieldsInput<TargetName extends string> = StringListInput | FieldReference<TargetName, string> | readonly FieldReference<TargetName, string>[];
|
|
135
|
+
type NormalizeModelName<T> = T extends string ? T : ExtractModelName<T>;
|
|
136
|
+
type NormalizeModelNameOrUndefined<T> = [T] extends [undefined] ? undefined : NormalizeModelName<Present<T>>;
|
|
137
|
+
type NormalizeValueObjectName<T> = T extends string ? T : ExtractValueObjectName<T>;
|
|
138
|
+
type NormalizeStringList<T> = T extends readonly string[] ? T : T extends string ? readonly [T] : readonly string[];
|
|
139
|
+
type NormalizeTargetFieldList<T> = T extends readonly AnyFieldReference[] ? { readonly [K in keyof T]: ExtractFieldReferenceName<T[K]> } : T extends AnyFieldReference ? readonly [ExtractFieldReferenceName<T>] : NormalizeStringList<T>;
|
|
140
|
+
type ContractFieldFromBuilder<TBuilder> = TBuilder extends FieldBuilder<infer Type extends ContractFieldType, infer Nullable extends boolean, infer Many extends boolean> ? Simplify<{
|
|
141
|
+
readonly type: Type;
|
|
142
|
+
readonly nullable: Nullable;
|
|
143
|
+
} & (Many extends true ? {
|
|
144
|
+
readonly many: true;
|
|
145
|
+
} : EmptyObject)> : never;
|
|
146
|
+
type ContractFieldsFromRecord<Fields$1 extends Record<string, AnyFieldBuilder>> = Simplify<{ readonly [K in keyof Fields$1]: ContractFieldFromBuilder<Fields$1[K]> }>;
|
|
147
|
+
type ContractValueObjectFromBuilder<TBuilder> = TBuilder extends ValueObjectBuilder<string, infer Fields extends Record<string, AnyFieldBuilder>> ? Simplify<{
|
|
148
|
+
readonly fields: ContractFieldsFromRecord<Fields>;
|
|
149
|
+
}> : never;
|
|
150
|
+
type ContractValueObjectsFromRecord<ValueObjects extends Record<string, AnyValueObjectBuilder>> = Simplify<{ readonly [K in keyof ValueObjects as ExtractValueObjectName<ValueObjects[K]>]: ContractValueObjectFromBuilder<ValueObjects[K]> }>;
|
|
151
|
+
type ContractRelationFromBuilder<TBuilder> = TBuilder extends RelationBuilder<infer To extends string, infer Cardinality extends '1:1' | '1:N' | 'N:1', infer On extends RelationOn | undefined> ? On extends RelationOn ? {
|
|
152
|
+
readonly to: To;
|
|
153
|
+
readonly cardinality: Cardinality;
|
|
154
|
+
readonly on: On;
|
|
155
|
+
} : {
|
|
156
|
+
readonly to: To;
|
|
157
|
+
readonly cardinality: Cardinality;
|
|
158
|
+
} : never;
|
|
159
|
+
type ContractRelationsFromRecord<Relations$1 extends Record<string, AnyRelationBuilder>> = keyof Relations$1 extends never ? Record<string, never> : Simplify<{ readonly [K in keyof Relations$1]: ContractRelationFromBuilder<Relations$1[K]> }>;
|
|
160
|
+
type ContractModelStorageFromBuilder<TBuilder> = ModelStorageSection<TBuilder> & ModelStorageRelationsSection<TBuilder>;
|
|
161
|
+
type MaybeOwner<Owner$1> = [Owner$1] extends [undefined] ? EmptyObject : {
|
|
162
|
+
readonly owner: Owner$1 & string;
|
|
163
|
+
};
|
|
164
|
+
type MaybeBase<Base$1> = [Base$1] extends [undefined] ? EmptyObject : {
|
|
165
|
+
readonly base: Base$1 & string;
|
|
166
|
+
};
|
|
167
|
+
type MaybeDiscriminator<Discriminator$1> = [Discriminator$1] extends [undefined] ? EmptyObject : {
|
|
168
|
+
readonly discriminator: Discriminator$1 & {
|
|
169
|
+
readonly field: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
type MaybeVariants<Variants$1> = [Variants$1] extends [undefined] ? EmptyObject : {
|
|
173
|
+
readonly variants: Variants$1;
|
|
174
|
+
};
|
|
175
|
+
type ContractModelFromBuilder<TBuilder> = TBuilder extends NamedModelBuilder<string, infer Fields extends Record<string, AnyFieldBuilder>, infer Relations extends Record<string, AnyRelationBuilder>, string | undefined, infer Owner, infer Base, Record<string, StorageRelationSpec> | undefined, infer Discriminator, infer Variants> ? Simplify<{
|
|
176
|
+
readonly fields: ContractFieldsFromRecord<Fields>;
|
|
177
|
+
readonly relations: ContractRelationsFromRecord<Relations>;
|
|
178
|
+
readonly storage: ContractModelStorageFromBuilder<TBuilder>;
|
|
179
|
+
} & MaybeOwner<Owner> & MaybeBase<Base> & MaybeDiscriminator<Discriminator> & MaybeVariants<Variants>> : never;
|
|
180
|
+
type ContractModelsFromRecord<Models extends Record<string, AnyModelBuilder>> = Simplify<{ readonly [K in keyof Models as ExtractModelName<Models[K]>]: ContractModelFromBuilder<Models[K]> }>;
|
|
181
|
+
type DerivedRootModels<Models extends Record<string, AnyModelBuilder>> = Simplify<{ readonly [K in keyof Models as RootModelCollection<Models[K]>]: RootModelName<Models[K]> }>;
|
|
182
|
+
type StorageCollectionsFromModels<Models extends Record<string, AnyModelBuilder>> = Simplify<{ readonly [K in keyof Models as CollectionName<Models[K]>]: MongoStorageCollection }>;
|
|
183
|
+
type NormalizeRoots<Roots$1 extends Record<string, ModelNameInput>> = Simplify<{ readonly [K in keyof Roots$1]: NormalizeModelName<Roots$1[K]> }>;
|
|
184
|
+
type DefinitionModels<Definition> = Definition extends {
|
|
185
|
+
readonly models?: infer Models extends Record<string, AnyModelBuilder>;
|
|
186
|
+
} ? Models : Record<never, never>;
|
|
187
|
+
type DefinitionValueObjects<Definition> = Definition extends {
|
|
188
|
+
readonly valueObjects?: infer ValueObjects extends Record<string, AnyValueObjectBuilder>;
|
|
189
|
+
} ? ValueObjects : Record<never, never>;
|
|
190
|
+
type DefinitionRoots<Definition> = Definition extends {
|
|
191
|
+
readonly roots?: infer Roots extends Record<string, ModelNameInput>;
|
|
192
|
+
} ? NormalizeRoots<Roots> : DerivedRootModels<DefinitionModels<Definition>>;
|
|
193
|
+
type DefinitionCapabilities<Definition> = Definition extends {
|
|
194
|
+
readonly capabilities?: infer Capabilities extends ContractCapabilities;
|
|
195
|
+
} ? Capabilities : Record<never, never>;
|
|
196
|
+
type DefinitionExtensionPacks<Definition> = Definition extends {
|
|
197
|
+
readonly extensionPacks?: infer ExtensionPacks extends Record<string, ExtensionPackRef<string, string>>;
|
|
198
|
+
} ? ExtensionPacks : Record<never, never>;
|
|
199
|
+
type DefinitionFamilyId<Definition> = Definition extends {
|
|
200
|
+
readonly family: FamilyPackRef<infer FamilyId>;
|
|
201
|
+
} ? FamilyId : string;
|
|
202
|
+
type DefinitionTargetId<Definition> = Definition extends {
|
|
203
|
+
readonly target: TargetPackRef<string, infer TargetId>;
|
|
204
|
+
} ? TargetId : string;
|
|
205
|
+
type DefinitionStorage<Definition> = Simplify<MongoStorage & {
|
|
206
|
+
readonly collections: StorageCollectionsFromModels<DefinitionModels<Definition>>;
|
|
207
|
+
readonly storageHash: StorageHashBase<string>;
|
|
208
|
+
}>;
|
|
209
|
+
type MaybeValueObjectsSection<ValueObjects extends Record<string, AnyValueObjectBuilder>> = keyof ValueObjects extends never ? EmptyObject : {
|
|
210
|
+
readonly valueObjects: ContractValueObjectsFromRecord<ValueObjects>;
|
|
211
|
+
};
|
|
212
|
+
type MongoContractBaseFromDefinition<Definition> = Simplify<{
|
|
213
|
+
readonly target: DefinitionTargetId<Definition>;
|
|
214
|
+
readonly targetFamily: DefinitionFamilyId<Definition>;
|
|
215
|
+
readonly roots: DefinitionRoots<Definition>;
|
|
216
|
+
readonly models: ContractModelsFromRecord<DefinitionModels<Definition>>;
|
|
217
|
+
readonly storage: DefinitionStorage<Definition>;
|
|
218
|
+
readonly capabilities: DefinitionCapabilities<Definition>;
|
|
219
|
+
readonly extensionPacks: DefinitionExtensionPacks<Definition>;
|
|
220
|
+
readonly profileHash: ProfileHashBase<string>;
|
|
221
|
+
readonly meta: Record<string, never>;
|
|
222
|
+
} & MaybeValueObjectsSection<DefinitionValueObjects<Definition>>>;
|
|
223
|
+
type CodecTypesFromDefinition<Definition> = MongoCodecTypes & MergeExtensionCodecTypesSafe<DefinitionExtensionPacks<Definition>>;
|
|
224
|
+
type MongoContractResult<Definition> = MongoContractWithTypeMaps<MongoContractBaseFromDefinition<Definition>, MongoTypeMaps<CodecTypesFromDefinition<Definition>>>;
|
|
225
|
+
type ContractAuthoringHelpers = {
|
|
226
|
+
readonly field: typeof field;
|
|
227
|
+
readonly index: typeof index;
|
|
228
|
+
readonly model: typeof model;
|
|
229
|
+
readonly rel: typeof rel;
|
|
230
|
+
readonly valueObject: typeof valueObject;
|
|
231
|
+
};
|
|
232
|
+
type ContractScaffold<Family extends FamilyPackRef<string>, Target extends TargetPackRef<string, string>, ExtensionPacks extends Record<string, ExtensionPackRef<string, string>> | undefined = undefined, Capabilities extends ContractCapabilities | undefined = undefined, Roots$1 extends Record<string, ModelNameInput> | undefined = undefined> = {
|
|
233
|
+
readonly family: Family;
|
|
234
|
+
readonly target: Target;
|
|
235
|
+
readonly extensionPacks?: ExtensionPacks;
|
|
236
|
+
readonly capabilities?: Capabilities;
|
|
237
|
+
readonly roots?: Roots$1;
|
|
238
|
+
};
|
|
239
|
+
type ContractDefinition<Family extends FamilyPackRef<string>, Target extends TargetPackRef<string, string>, Models extends Record<string, AnyModelBuilder> = Record<never, never>, ValueObjects extends Record<string, AnyValueObjectBuilder> = Record<never, never>, ExtensionPacks extends Record<string, ExtensionPackRef<string, string>> | undefined = undefined, Capabilities extends ContractCapabilities | undefined = undefined, Roots$1 extends Record<string, ModelNameInput> | undefined = undefined> = ContractScaffold<Family, Target, ExtensionPacks, Capabilities, Roots$1> & {
|
|
240
|
+
readonly models?: Models;
|
|
241
|
+
readonly valueObjects?: ValueObjects;
|
|
242
|
+
};
|
|
243
|
+
type ContractFactory<Models extends Record<string, AnyModelBuilder> = Record<never, never>, ValueObjects extends Record<string, AnyValueObjectBuilder> = Record<never, never>, Roots$1 extends Record<string, ModelNameInput> | undefined = undefined> = (helpers: ContractAuthoringHelpers) => {
|
|
244
|
+
readonly models?: Models;
|
|
245
|
+
readonly valueObjects?: ValueObjects;
|
|
246
|
+
readonly roots?: Roots$1;
|
|
247
|
+
};
|
|
248
|
+
declare function createScalarFieldBuilder<CodecId extends string, TypeParams extends Record<string, unknown> | undefined = undefined>(codecId: CodecId, options?: {
|
|
249
|
+
readonly typeParams?: TypeParams;
|
|
250
|
+
}): FieldBuilder<{
|
|
251
|
+
readonly kind: 'scalar';
|
|
252
|
+
readonly codecId: CodecId;
|
|
253
|
+
} & ([TypeParams] extends [undefined] ? EmptyObject : {
|
|
254
|
+
readonly typeParams: TypeParams;
|
|
255
|
+
}), false, false>;
|
|
256
|
+
declare const field: {
|
|
257
|
+
readonly scalar: typeof createScalarFieldBuilder;
|
|
258
|
+
readonly objectId: () => FieldBuilder<{
|
|
259
|
+
readonly kind: "scalar";
|
|
260
|
+
readonly codecId: "mongo/objectId@1";
|
|
261
|
+
} & EmptyObject, false, false>;
|
|
262
|
+
readonly string: () => FieldBuilder<{
|
|
263
|
+
readonly kind: "scalar";
|
|
264
|
+
readonly codecId: "mongo/string@1";
|
|
265
|
+
} & EmptyObject, false, false>;
|
|
266
|
+
readonly double: () => FieldBuilder<{
|
|
267
|
+
readonly kind: "scalar";
|
|
268
|
+
readonly codecId: "mongo/double@1";
|
|
269
|
+
} & EmptyObject, false, false>;
|
|
270
|
+
readonly int32: () => FieldBuilder<{
|
|
271
|
+
readonly kind: "scalar";
|
|
272
|
+
readonly codecId: "mongo/int32@1";
|
|
273
|
+
} & EmptyObject, false, false>;
|
|
274
|
+
readonly bool: () => FieldBuilder<{
|
|
275
|
+
readonly kind: "scalar";
|
|
276
|
+
readonly codecId: "mongo/bool@1";
|
|
277
|
+
} & EmptyObject, false, false>;
|
|
278
|
+
readonly date: () => FieldBuilder<{
|
|
279
|
+
readonly kind: "scalar";
|
|
280
|
+
readonly codecId: "mongo/date@1";
|
|
281
|
+
} & EmptyObject, false, false>;
|
|
282
|
+
readonly vector: <const TypeParams extends Record<string, unknown> | undefined = undefined>(options?: {
|
|
283
|
+
readonly typeParams?: TypeParams;
|
|
284
|
+
}) => FieldBuilder<{
|
|
285
|
+
readonly kind: "scalar";
|
|
286
|
+
readonly codecId: "mongo/vector@1";
|
|
287
|
+
} & ([TypeParams] extends [undefined] ? EmptyObject : {
|
|
288
|
+
readonly typeParams: TypeParams;
|
|
289
|
+
}), false, false>;
|
|
290
|
+
readonly valueObject: <const ValueObject extends ValueObjectNameInput>(valueObjectName: ValueObject) => FieldBuilder<{
|
|
291
|
+
readonly kind: "valueObject";
|
|
292
|
+
readonly name: NormalizeValueObjectName<ValueObject>;
|
|
293
|
+
}, false, false>;
|
|
294
|
+
};
|
|
295
|
+
declare function index<const Fields$1 extends MongoIndexFields>(fields: Fields$1): {
|
|
296
|
+
readonly fields: Fields$1;
|
|
297
|
+
};
|
|
298
|
+
declare function index<const Fields$1 extends MongoIndexFields, const Options>(fields: Fields$1, options: StrictShape<Options, MongoIndexOptions>): {
|
|
299
|
+
readonly fields: Fields$1;
|
|
300
|
+
readonly options: Options & MongoIndexOptions;
|
|
301
|
+
};
|
|
302
|
+
type ReferenceOptions<Target extends ModelNameInput, From extends StringListInput, To$1 extends RelationTargetFieldsInput<NormalizeModelName<Target>>> = {
|
|
303
|
+
readonly from: From;
|
|
304
|
+
readonly to: To$1;
|
|
305
|
+
};
|
|
306
|
+
type RelationOnFromOptions<From extends StringListInput, To$1 extends RelationTargetFieldsInput<string>> = {
|
|
307
|
+
readonly localFields: NormalizeStringList<From>;
|
|
308
|
+
readonly targetFields: NormalizeTargetFieldList<To$1>;
|
|
309
|
+
};
|
|
310
|
+
declare function hasOne<const Target extends ModelNameInput>(target: Target): RelationBuilder<NormalizeModelName<Target>, '1:1', undefined>;
|
|
311
|
+
declare function hasOne<const Target extends ModelNameInput, const From extends StringListInput, const To$1 extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To$1>): RelationBuilder<NormalizeModelName<Target>, '1:1', RelationOnFromOptions<From, To$1>>;
|
|
312
|
+
declare function hasMany<const Target extends ModelNameInput>(target: Target): RelationBuilder<NormalizeModelName<Target>, '1:N', undefined>;
|
|
313
|
+
declare function hasMany<const Target extends ModelNameInput, const From extends StringListInput, const To$1 extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To$1>): RelationBuilder<NormalizeModelName<Target>, '1:N', RelationOnFromOptions<From, To$1>>;
|
|
314
|
+
declare function belongsTo<const Target extends ModelNameInput, const From extends StringListInput, const To$1 extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To$1>): RelationBuilder<NormalizeModelName<Target>, 'N:1', RelationOnFromOptions<From, To$1>>;
|
|
315
|
+
declare const rel: {
|
|
316
|
+
readonly belongsTo: typeof belongsTo;
|
|
317
|
+
readonly hasMany: typeof hasMany;
|
|
318
|
+
readonly hasOne: typeof hasOne;
|
|
319
|
+
};
|
|
320
|
+
type ValueObjectInput<Fields$1 extends Record<string, AnyFieldBuilder>> = {
|
|
321
|
+
readonly fields: Fields$1;
|
|
322
|
+
};
|
|
323
|
+
declare function valueObject<const Name extends string, const Fields$1 extends Record<string, AnyFieldBuilder>>(name: Name, input: ValueObjectInput<Fields$1>): ValueObjectBuilder<Name, Fields$1>;
|
|
324
|
+
type ModelDiscriminatorInput<Variants$1 extends Record<string, VariantSpec>> = {
|
|
325
|
+
readonly field: string;
|
|
326
|
+
readonly variants: Variants$1;
|
|
327
|
+
};
|
|
328
|
+
type ModelInput<Fields$1 extends Record<string, AnyFieldBuilder>, Relations$1 extends Record<string, AnyRelationBuilder> | undefined, Collection extends string | undefined, Indexes extends readonly MongoIndex[] | undefined, CollectionOptions, Owner$1 extends ModelNameInput | undefined, Base$1 extends ModelNameInput | undefined, StorageRelations extends Record<string, StorageRelationSpec> | undefined, Discriminator$1 extends ModelDiscriminatorInput<Record<string, VariantSpec>> | undefined> = {
|
|
329
|
+
readonly collection?: Collection;
|
|
330
|
+
readonly indexes?: Indexes;
|
|
331
|
+
readonly collectionOptions?: StrictShape<CollectionOptions, MongoCollectionOptions>;
|
|
332
|
+
readonly storageRelations?: StorageRelations;
|
|
333
|
+
readonly fields: Fields$1;
|
|
334
|
+
readonly relations?: Relations$1;
|
|
335
|
+
readonly owner?: Owner$1;
|
|
336
|
+
readonly base?: Base$1;
|
|
337
|
+
readonly discriminator?: Discriminator$1;
|
|
338
|
+
};
|
|
339
|
+
declare function model<const Name extends string, const Fields$1 extends Record<string, AnyFieldBuilder>, const Relations$1 extends Record<string, AnyRelationBuilder> | undefined = undefined, const Collection extends string | undefined = undefined, const Indexes extends readonly MongoIndex[] | undefined = undefined, const CollectionOptions = undefined, const Owner$1 extends ModelNameInput | undefined = undefined, const Base$1 extends ModelNameInput | undefined = undefined, const StorageRelations extends Record<string, StorageRelationSpec> | undefined = undefined, const Discriminator$1 extends ModelDiscriminatorInput<Record<string, VariantSpec>> | undefined = undefined>(name: Name, input: ModelInput<Fields$1, Relations$1, Collection, Indexes, CollectionOptions, Owner$1, Base$1, StorageRelations, Discriminator$1>): ModelBuilder<Name, Fields$1, Relations$1 extends Record<string, AnyRelationBuilder> ? Relations$1 : Record<never, never>, Collection, NormalizeModelNameOrUndefined<Owner$1>, NormalizeModelNameOrUndefined<Base$1>, StorageRelations, Discriminator$1 extends {
|
|
340
|
+
readonly field: infer Field extends string;
|
|
341
|
+
} ? {
|
|
342
|
+
readonly field: Field;
|
|
343
|
+
} : undefined, Discriminator$1 extends {
|
|
344
|
+
readonly variants: infer Variants extends Record<string, VariantSpec>;
|
|
345
|
+
} ? Variants : undefined>;
|
|
346
|
+
declare function defineContract<const Definition extends ContractDefinition<FamilyPackRef<string>, TargetPackRef<string, string>, Record<string, AnyModelBuilder>, Record<string, AnyValueObjectBuilder>, Record<string, ExtensionPackRef<string, string>> | undefined, ContractCapabilities | undefined, Record<string, ModelNameInput> | undefined>>(definition: Definition): MongoContractResult<Definition>;
|
|
347
|
+
declare function defineContract<const Definition extends ContractScaffold<FamilyPackRef<string>, TargetPackRef<string, string>, Record<string, ExtensionPackRef<string, string>> | undefined, ContractCapabilities | undefined, Record<string, ModelNameInput> | undefined>, const Built extends {
|
|
348
|
+
readonly models?: Record<string, AnyModelBuilder>;
|
|
349
|
+
readonly valueObjects?: Record<string, AnyValueObjectBuilder>;
|
|
350
|
+
readonly roots?: Record<string, ModelNameInput>;
|
|
351
|
+
}>(definition: Definition, factory: (_helpers: ContractAuthoringHelpers) => Built): MongoContractResult<Definition & Built>;
|
|
352
|
+
//#endregion
|
|
353
|
+
export { type ContractDefinition, type ContractFactory, type ContractScaffold, type FieldBuilder, type FieldReference, type ModelBuilder, type MongoContractResult, type RelationBuilder, type ValueObjectBuilder, defineContract, field, index, model, rel, valueObject };
|
|
354
|
+
//# sourceMappingURL=contract-builder.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../src/contract-builder.ts"],"sourcesContent":[],"mappings":";;;;;KA8BK,WAAA;;AAFgC,CAAA;AAErB,KAIX,mBAAA,GAAmB;EAInB,SAAA,KAAA,EAAA,MAAA;AAA6B,CAAA;AACd,KADf,oBAAA,GAAuB,MAEV,CAAA,MAAO,EAFkB,MAElB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;AAAA,KADpB,eAAA,GAEW,MA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E,CAAA,yBAu9BS,gBAv9BT,CAw9Bd,aAx9Bc,CAAA,MAAA,CAAA,EAy9Bd,aAz9Bc,CAAA,MAAA,EAAA,MAAA,CAAA,EA09Bd,MA19Bc,CAAA,MAAA,EA09BC,gBA19BD,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA,GAAA,SAAA,EA29Bd,oBA39Bc,GAAA,SAAA,EA49Bd,MA59Bc,CAAA,MAAA,EA49BC,cA59BD,CAAA,GAAA,SAAA,CAAA,EAAA,oBAAA;EAAc,SAAA,MAAA,CAAA,EA+9BV,MA/9BU,CAAA,MAAA,EA+9BK,eA/9BL,CAAA;EAC5B,SAAA,YAAA,CAAA,EA+9BwB,MA/9BxB,CAAA,MAAA,EA+9BuC,qBA/9BvC,CAAA;EACqB,SAAA,KAAA,CAAA,EA+9BJ,MA/9BI,CAAA,MAAA,EA+9BW,cA/9BX,CAAA;CAAQ,CAAA,CAAA,UAAA,EAk+BnB,UAl+BmB,EAAA,OAAA,EAAA,CAAA,QAAA,EAm+BX,wBAn+BW,EAAA,GAm+BkB,KAn+BlB,CAAA,EAo+B9B,mBAp+B8B,CAo+BV,UAp+BU,GAo+BG,KAp+BH,CAAA"}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { computeProfileHash, computeStorageHash } from "@prisma-next/contract/hashing";
|
|
2
|
+
import { validateMongoContract } from "@prisma-next/mongo-contract";
|
|
3
|
+
|
|
4
|
+
//#region src/contract-builder.ts
|
|
5
|
+
function createFieldBuilder(spec) {
|
|
6
|
+
return {
|
|
7
|
+
__kind: "field",
|
|
8
|
+
__type: spec.type,
|
|
9
|
+
__nullable: spec.nullable,
|
|
10
|
+
__many: spec.many,
|
|
11
|
+
optional() {
|
|
12
|
+
return createFieldBuilder({
|
|
13
|
+
type: spec.type,
|
|
14
|
+
nullable: true,
|
|
15
|
+
many: spec.many
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
many() {
|
|
19
|
+
return createFieldBuilder({
|
|
20
|
+
type: spec.type,
|
|
21
|
+
nullable: spec.nullable,
|
|
22
|
+
many: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function normalizeOptionalTypeParams(typeParams) {
|
|
28
|
+
if (!typeParams) return {};
|
|
29
|
+
return { typeParams };
|
|
30
|
+
}
|
|
31
|
+
function createScalarFieldBuilder(codecId, options) {
|
|
32
|
+
return createFieldBuilder({
|
|
33
|
+
type: {
|
|
34
|
+
kind: "scalar",
|
|
35
|
+
codecId,
|
|
36
|
+
...normalizeOptionalTypeParams(options?.typeParams)
|
|
37
|
+
},
|
|
38
|
+
nullable: false,
|
|
39
|
+
many: false
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const field = {
|
|
43
|
+
scalar: createScalarFieldBuilder,
|
|
44
|
+
objectId() {
|
|
45
|
+
return createScalarFieldBuilder("mongo/objectId@1");
|
|
46
|
+
},
|
|
47
|
+
string() {
|
|
48
|
+
return createScalarFieldBuilder("mongo/string@1");
|
|
49
|
+
},
|
|
50
|
+
double() {
|
|
51
|
+
return createScalarFieldBuilder("mongo/double@1");
|
|
52
|
+
},
|
|
53
|
+
int32() {
|
|
54
|
+
return createScalarFieldBuilder("mongo/int32@1");
|
|
55
|
+
},
|
|
56
|
+
bool() {
|
|
57
|
+
return createScalarFieldBuilder("mongo/bool@1");
|
|
58
|
+
},
|
|
59
|
+
date() {
|
|
60
|
+
return createScalarFieldBuilder("mongo/date@1");
|
|
61
|
+
},
|
|
62
|
+
vector(options) {
|
|
63
|
+
return createScalarFieldBuilder("mongo/vector@1", options);
|
|
64
|
+
},
|
|
65
|
+
valueObject(valueObjectName) {
|
|
66
|
+
return createFieldBuilder({
|
|
67
|
+
type: {
|
|
68
|
+
kind: "valueObject",
|
|
69
|
+
name: resolveValueObjectName(valueObjectName)
|
|
70
|
+
},
|
|
71
|
+
nullable: false,
|
|
72
|
+
many: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
function index(fields, options) {
|
|
77
|
+
return {
|
|
78
|
+
fields,
|
|
79
|
+
...options ? { options } : {}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function createFieldReference(modelName, fieldName) {
|
|
83
|
+
return {
|
|
84
|
+
__kind: "fieldRef",
|
|
85
|
+
modelName,
|
|
86
|
+
fieldName
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function isFieldReference(value) {
|
|
90
|
+
return typeof value === "object" && value !== null && "__kind" in value && value.__kind === "fieldRef";
|
|
91
|
+
}
|
|
92
|
+
function resolveModelName(value) {
|
|
93
|
+
return typeof value === "string" ? value : value.__name;
|
|
94
|
+
}
|
|
95
|
+
function resolveValueObjectName(value) {
|
|
96
|
+
return typeof value === "string" ? value : value.__name;
|
|
97
|
+
}
|
|
98
|
+
function normalizeStringList(value) {
|
|
99
|
+
return typeof value === "string" ? [value] : [...value];
|
|
100
|
+
}
|
|
101
|
+
function normalizeTargetField(targetModelName, value) {
|
|
102
|
+
if (!isFieldReference(value)) return value;
|
|
103
|
+
if (value.modelName !== targetModelName) throw new Error(`Relation target "${targetModelName}" cannot reference field "${value.modelName}.${value.fieldName}".`);
|
|
104
|
+
return value.fieldName;
|
|
105
|
+
}
|
|
106
|
+
function normalizeTargetFields(targetModelName, value) {
|
|
107
|
+
if (typeof value === "string") return [value];
|
|
108
|
+
if (isFieldReference(value)) return [normalizeTargetField(targetModelName, value)];
|
|
109
|
+
return value.map((entry) => normalizeTargetField(targetModelName, entry));
|
|
110
|
+
}
|
|
111
|
+
function createRelationBuilder(spec) {
|
|
112
|
+
return {
|
|
113
|
+
__kind: "relation",
|
|
114
|
+
__to: spec.to,
|
|
115
|
+
__cardinality: spec.cardinality,
|
|
116
|
+
__on: spec.on
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function createReferenceRelationBuilder(target, cardinality, options) {
|
|
120
|
+
const targetModelName = resolveModelName(target);
|
|
121
|
+
return createRelationBuilder({
|
|
122
|
+
to: targetModelName,
|
|
123
|
+
cardinality,
|
|
124
|
+
on: {
|
|
125
|
+
localFields: normalizeStringList(options.from),
|
|
126
|
+
targetFields: normalizeTargetFields(targetModelName, options.to)
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function createEmbedRelationBuilder(target, cardinality) {
|
|
131
|
+
return createRelationBuilder({
|
|
132
|
+
to: resolveModelName(target),
|
|
133
|
+
cardinality,
|
|
134
|
+
on: void 0
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function hasOne(target, options) {
|
|
138
|
+
if (!options) return createEmbedRelationBuilder(target, "1:1");
|
|
139
|
+
return createReferenceRelationBuilder(target, "1:1", options);
|
|
140
|
+
}
|
|
141
|
+
function hasMany(target, options) {
|
|
142
|
+
if (!options) return createEmbedRelationBuilder(target, "1:N");
|
|
143
|
+
return createReferenceRelationBuilder(target, "1:N", options);
|
|
144
|
+
}
|
|
145
|
+
function belongsTo(target, options) {
|
|
146
|
+
return createReferenceRelationBuilder(target, "N:1", options);
|
|
147
|
+
}
|
|
148
|
+
const rel = {
|
|
149
|
+
belongsTo,
|
|
150
|
+
hasMany,
|
|
151
|
+
hasOne
|
|
152
|
+
};
|
|
153
|
+
function valueObject(name, input) {
|
|
154
|
+
return {
|
|
155
|
+
__kind: "valueObject",
|
|
156
|
+
__name: name,
|
|
157
|
+
__fields: input.fields
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function model(name, input) {
|
|
161
|
+
return {
|
|
162
|
+
__kind: "model",
|
|
163
|
+
__name: name,
|
|
164
|
+
__fields: input.fields,
|
|
165
|
+
__relations: input.relations ?? {},
|
|
166
|
+
__indexes: input.indexes,
|
|
167
|
+
__collectionOptions: input.collectionOptions,
|
|
168
|
+
__collection: input.collection,
|
|
169
|
+
__owner: input.owner ? resolveModelName(input.owner) : void 0,
|
|
170
|
+
__base: input.base ? resolveModelName(input.base) : void 0,
|
|
171
|
+
__storageRelations: input.storageRelations,
|
|
172
|
+
__discriminator: input.discriminator ? { field: input.discriminator.field } : void 0,
|
|
173
|
+
__variants: input.discriminator?.variants,
|
|
174
|
+
ref(fieldName) {
|
|
175
|
+
return createFieldReference(name, fieldName);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function validateTargetPackRef(family, target) {
|
|
180
|
+
if (family.familyId !== "mongo") throw new Error(`defineContract only accepts Mongo family packs. Received family "${family.familyId}".`);
|
|
181
|
+
if (target.familyId !== family.familyId) throw new Error(`target pack "${target.id}" targets family "${target.familyId}" but contract family is "${family.familyId}".`);
|
|
182
|
+
}
|
|
183
|
+
function validateExtensionPackRefs(target, extensionPacks) {
|
|
184
|
+
if (!extensionPacks) return;
|
|
185
|
+
for (const packRef of Object.values(extensionPacks)) {
|
|
186
|
+
if (packRef.kind !== "extension") throw new Error(`defineContract only accepts extension pack refs in extensionPacks. Received kind "${packRef.kind}".`);
|
|
187
|
+
if (packRef.familyId !== target.familyId) throw new Error(`extension pack "${packRef.id}" targets family "${packRef.familyId}" but contract target family is "${target.familyId}".`);
|
|
188
|
+
if (packRef.targetId && packRef.targetId !== target.targetId) throw new Error(`extension pack "${packRef.id}" targets "${packRef.targetId}" but contract target is "${target.targetId}".`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function isContractScaffold(value) {
|
|
192
|
+
if (typeof value !== "object" || value === null) return false;
|
|
193
|
+
return "family" in value && "target" in value;
|
|
194
|
+
}
|
|
195
|
+
function buildContractField(builder) {
|
|
196
|
+
return builder.__many ? {
|
|
197
|
+
type: builder.__type,
|
|
198
|
+
nullable: builder.__nullable,
|
|
199
|
+
many: true
|
|
200
|
+
} : {
|
|
201
|
+
type: builder.__type,
|
|
202
|
+
nullable: builder.__nullable
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function buildFields(fields) {
|
|
206
|
+
const builtFields = {};
|
|
207
|
+
for (const [fieldName, fieldBuilder] of Object.entries(fields)) builtFields[fieldName] = buildContractField(fieldBuilder);
|
|
208
|
+
return builtFields;
|
|
209
|
+
}
|
|
210
|
+
function buildRelation(relationBuilder) {
|
|
211
|
+
return relationBuilder.__on ? {
|
|
212
|
+
to: relationBuilder.__to,
|
|
213
|
+
cardinality: relationBuilder.__cardinality,
|
|
214
|
+
on: relationBuilder.__on
|
|
215
|
+
} : {
|
|
216
|
+
to: relationBuilder.__to,
|
|
217
|
+
cardinality: relationBuilder.__cardinality
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function buildRelations(relations) {
|
|
221
|
+
const builtRelations = {};
|
|
222
|
+
for (const [relationName, relationBuilder] of Object.entries(relations)) builtRelations[relationName] = buildRelation(relationBuilder);
|
|
223
|
+
return builtRelations;
|
|
224
|
+
}
|
|
225
|
+
function buildValueObjects(valueObjects) {
|
|
226
|
+
const builtValueObjects = {};
|
|
227
|
+
for (const valueObjectBuilder of Object.values(valueObjects ?? {})) {
|
|
228
|
+
if (valueObjectBuilder.__name in builtValueObjects) throw new Error(`Duplicate value object name "${valueObjectBuilder.__name}" in defineContract().`);
|
|
229
|
+
builtValueObjects[valueObjectBuilder.__name] = { fields: buildFields(valueObjectBuilder.__fields) };
|
|
230
|
+
}
|
|
231
|
+
return builtValueObjects;
|
|
232
|
+
}
|
|
233
|
+
function buildModels(models) {
|
|
234
|
+
const builtModels = {};
|
|
235
|
+
for (const modelBuilder of Object.values(models ?? {})) {
|
|
236
|
+
if (modelBuilder.__name in builtModels) throw new Error(`Duplicate model name "${modelBuilder.__name}" in defineContract().`);
|
|
237
|
+
const storage = {
|
|
238
|
+
...modelBuilder.__collection ? { collection: modelBuilder.__collection } : {},
|
|
239
|
+
...modelBuilder.__storageRelations ? { relations: modelBuilder.__storageRelations } : {}
|
|
240
|
+
};
|
|
241
|
+
builtModels[modelBuilder.__name] = {
|
|
242
|
+
fields: buildFields(modelBuilder.__fields),
|
|
243
|
+
relations: buildRelations(modelBuilder.__relations),
|
|
244
|
+
storage,
|
|
245
|
+
...modelBuilder.__owner ? { owner: modelBuilder.__owner } : {},
|
|
246
|
+
...modelBuilder.__base ? { base: modelBuilder.__base } : {},
|
|
247
|
+
...modelBuilder.__discriminator ? { discriminator: modelBuilder.__discriminator } : {},
|
|
248
|
+
...modelBuilder.__variants ? { variants: modelBuilder.__variants } : {}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return builtModels;
|
|
252
|
+
}
|
|
253
|
+
function deriveRoots(models) {
|
|
254
|
+
const roots = {};
|
|
255
|
+
for (const modelBuilder of Object.values(models ?? {})) {
|
|
256
|
+
if (!modelBuilder.__collection || modelBuilder.__owner || modelBuilder.__base) continue;
|
|
257
|
+
roots[modelBuilder.__collection] = modelBuilder.__name;
|
|
258
|
+
}
|
|
259
|
+
return roots;
|
|
260
|
+
}
|
|
261
|
+
function normalizeRoots(roots) {
|
|
262
|
+
const normalizedRoots = {};
|
|
263
|
+
for (const [rootName, rootValue] of Object.entries(roots ?? {})) normalizedRoots[rootName] = resolveModelName(rootValue);
|
|
264
|
+
return normalizedRoots;
|
|
265
|
+
}
|
|
266
|
+
function stableStringify(value) {
|
|
267
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
268
|
+
if (value && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(",")}}`;
|
|
269
|
+
return JSON.stringify(value);
|
|
270
|
+
}
|
|
271
|
+
function toStorageIndex(index$1) {
|
|
272
|
+
const result = { keys: Object.entries(index$1.fields).map(([field$1, direction]) => ({
|
|
273
|
+
field: field$1,
|
|
274
|
+
direction
|
|
275
|
+
})) };
|
|
276
|
+
if (index$1.options) {
|
|
277
|
+
for (const [key, value] of Object.entries(index$1.options)) if (value !== void 0) result[key] = value;
|
|
278
|
+
}
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
function toStorageCollectionOptions(opts) {
|
|
282
|
+
const result = {};
|
|
283
|
+
if (opts.capped) result["capped"] = {
|
|
284
|
+
size: opts.size ?? 0,
|
|
285
|
+
...opts.max != null ? { max: opts.max } : {}
|
|
286
|
+
};
|
|
287
|
+
if (opts.timeseries) result["timeseries"] = opts.timeseries;
|
|
288
|
+
if (opts.collation) result["collation"] = opts.collation;
|
|
289
|
+
if (opts.changeStreamPreAndPostImages) result["changeStreamPreAndPostImages"] = opts.changeStreamPreAndPostImages;
|
|
290
|
+
if (opts.clusteredIndex) result["clusteredIndex"] = { name: opts.clusteredIndex.name };
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
293
|
+
function buildCollections(models) {
|
|
294
|
+
const collections = {};
|
|
295
|
+
const declaredIndexOwners = /* @__PURE__ */ new Map();
|
|
296
|
+
for (const modelBuilder of Object.values(models ?? {})) {
|
|
297
|
+
if (!modelBuilder.__collection) {
|
|
298
|
+
if (modelBuilder.__indexes && modelBuilder.__indexes.length > 0) throw new Error(`Model "${modelBuilder.__name}" defines indexes but has no collection to attach them to.`);
|
|
299
|
+
if (modelBuilder.__collectionOptions) throw new Error(`Model "${modelBuilder.__name}" defines collectionOptions but has no collection to attach them to.`);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const existingCollection = collections[modelBuilder.__collection] ?? {};
|
|
303
|
+
const existingIndexes = existingCollection.indexes ?? [];
|
|
304
|
+
if (existingCollection.options && modelBuilder.__collectionOptions) throw new Error(`Collection "${modelBuilder.__collection}" has collectionOptions declared by multiple models. Author collectionOptions on a single model per collection.`);
|
|
305
|
+
for (const collectionIndex of modelBuilder.__indexes ?? []) {
|
|
306
|
+
const indexSignature = stableStringify(collectionIndex);
|
|
307
|
+
const collectionIndexKey = `${modelBuilder.__collection}:${indexSignature}`;
|
|
308
|
+
const firstOwner = declaredIndexOwners.get(collectionIndexKey);
|
|
309
|
+
if (firstOwner) throw new Error(`Collection "${modelBuilder.__collection}" defines duplicate index ${indexSignature}. First declared on model "${firstOwner}" and duplicated on model "${modelBuilder.__name}".`);
|
|
310
|
+
declaredIndexOwners.set(collectionIndexKey, modelBuilder.__name);
|
|
311
|
+
}
|
|
312
|
+
const storageIndexes = (modelBuilder.__indexes ?? []).map(toStorageIndex);
|
|
313
|
+
const storageOptions = modelBuilder.__collectionOptions ? toStorageCollectionOptions(modelBuilder.__collectionOptions) : void 0;
|
|
314
|
+
collections[modelBuilder.__collection] = storageIndexes.length > 0 ? {
|
|
315
|
+
...existingCollection,
|
|
316
|
+
indexes: [...existingIndexes, ...storageIndexes],
|
|
317
|
+
...storageOptions ? { options: storageOptions } : {}
|
|
318
|
+
} : storageOptions ? {
|
|
319
|
+
...existingCollection,
|
|
320
|
+
options: storageOptions
|
|
321
|
+
} : existingCollection;
|
|
322
|
+
}
|
|
323
|
+
return collections;
|
|
324
|
+
}
|
|
325
|
+
function buildContractFromDefinition(definition) {
|
|
326
|
+
validateTargetPackRef(definition.family, definition.target);
|
|
327
|
+
validateExtensionPackRefs(definition.target, definition.extensionPacks);
|
|
328
|
+
const builtModels = buildModels(definition.models);
|
|
329
|
+
const builtValueObjects = buildValueObjects(definition.valueObjects);
|
|
330
|
+
const roots = definition.roots ? normalizeRoots(definition.roots) : deriveRoots(definition.models);
|
|
331
|
+
const capabilities = definition.capabilities ?? {};
|
|
332
|
+
const storageBody = { collections: buildCollections(definition.models) };
|
|
333
|
+
const builtContract = {
|
|
334
|
+
target: definition.target.targetId,
|
|
335
|
+
targetFamily: definition.family.familyId,
|
|
336
|
+
roots,
|
|
337
|
+
models: builtModels,
|
|
338
|
+
...Object.keys(builtValueObjects).length > 0 ? { valueObjects: builtValueObjects } : {},
|
|
339
|
+
storage: {
|
|
340
|
+
...storageBody,
|
|
341
|
+
storageHash: computeStorageHash({
|
|
342
|
+
target: definition.target.targetId,
|
|
343
|
+
targetFamily: definition.family.familyId,
|
|
344
|
+
storage: storageBody
|
|
345
|
+
})
|
|
346
|
+
},
|
|
347
|
+
capabilities,
|
|
348
|
+
extensionPacks: definition.extensionPacks ?? {},
|
|
349
|
+
profileHash: computeProfileHash({
|
|
350
|
+
target: definition.target.targetId,
|
|
351
|
+
targetFamily: definition.family.familyId,
|
|
352
|
+
capabilities
|
|
353
|
+
}),
|
|
354
|
+
meta: {}
|
|
355
|
+
};
|
|
356
|
+
validateMongoContract(builtContract);
|
|
357
|
+
return builtContract;
|
|
358
|
+
}
|
|
359
|
+
function defineContract(definition, factory) {
|
|
360
|
+
if (!isContractScaffold(definition)) throw new TypeError("defineContract expects a contract definition object. Define your contract with defineContract({ family, target, models, ... }).");
|
|
361
|
+
if (!factory) return buildContractFromDefinition(definition);
|
|
362
|
+
return buildContractFromDefinition({
|
|
363
|
+
...definition,
|
|
364
|
+
...factory({
|
|
365
|
+
field,
|
|
366
|
+
index,
|
|
367
|
+
model,
|
|
368
|
+
rel,
|
|
369
|
+
valueObject
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
//#endregion
|
|
375
|
+
export { defineContract, field, index, model, rel, valueObject };
|
|
376
|
+
//# sourceMappingURL=contract-builder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-builder.mjs","names":["builtFields: Record<string, ContractField>","builtRelations: Record<string, ContractEmbedRelation | ContractReferenceRelation>","builtValueObjects: Record<string, ContractValueObject>","builtModels: Record<string, MongoContract['models'][string]>","roots: Record<string, string>","normalizedRoots: Record<string, string>","result: Record<string, unknown>","index","field","collections: Record<string, MongoStorageCollection>"],"sources":["../src/contract-builder.ts"],"sourcesContent":["import { computeProfileHash, computeStorageHash } from '@prisma-next/contract/hashing';\nimport type {\n ContractEmbedRelation,\n ContractField,\n ContractFieldType,\n ContractReferenceRelation,\n ContractValueObject,\n ProfileHashBase,\n StorageHashBase,\n} from '@prisma-next/contract/types';\nimport type {\n ExtensionPackRef,\n FamilyPackRef,\n TargetPackRef,\n} from '@prisma-next/framework-components/components';\nimport {\n type MongoCollectionOptions,\n type MongoContract,\n type MongoContractWithTypeMaps,\n type MongoIndex,\n type MongoIndexFields,\n type MongoIndexOptions,\n type MongoStorage,\n type MongoStorageCollection,\n type MongoStorageCollectionOptions,\n type MongoStorageIndex,\n type MongoTypeMaps,\n validateMongoContract,\n} from '@prisma-next/mongo-contract';\n\ntype VariantSpec = {\n readonly value: string;\n};\n\ntype StorageRelationSpec = {\n readonly field: string;\n};\n\ntype ContractCapabilities = Record<string, Record<string, boolean>>;\ntype StringListInput = string | readonly string[];\ntype Present<T> = Exclude<T, undefined>;\ntype EmptyObject = Record<never, never>;\ntype Simplify<T> = { [K in keyof T]: T[K] } & EmptyObject;\ntype StrictShape<Actual, Shape> = Actual &\n Shape &\n Record<Exclude<keyof Actual, keyof Shape>, never>;\n\ntype UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (\n value: infer Intersection,\n) => void\n ? Intersection\n : never;\n\nexport type ExtractCodecTypesFromPack<P> = P extends { __codecTypes?: infer CodecTypes }\n ? CodecTypes extends Record<string, { output: unknown }>\n ? CodecTypes\n : Record<string, never>\n : Record<string, never>;\n\n// This mirrors @prisma-next/target-mongo/codec-types because authoring must stay decoupled from\n// the target layer while still exposing the built-in Mongo codec registry to type inference.\ntype MongoCodecTypes = {\n readonly 'mongo/objectId@1': { readonly input: string; readonly output: string };\n readonly 'mongo/string@1': { readonly input: string; readonly output: string };\n readonly 'mongo/double@1': { readonly input: number; readonly output: number };\n readonly 'mongo/int32@1': { readonly input: number; readonly output: number };\n readonly 'mongo/bool@1': { readonly input: boolean; readonly output: boolean };\n readonly 'mongo/date@1': { readonly input: Date; readonly output: Date };\n readonly 'mongo/vector@1': {\n readonly input: readonly number[];\n readonly output: readonly number[];\n };\n};\n\ntype MergeExtensionCodecTypes<Packs extends Record<string, unknown>> = UnionToIntersection<\n {\n [K in keyof Packs]: ExtractCodecTypesFromPack<Packs[K]>;\n }[keyof Packs]\n>;\n\ntype MergeExtensionCodecTypesSafe<Packs> =\n Packs extends Record<string, unknown>\n ? keyof Packs extends never\n ? Record<string, never>\n : MergeExtensionCodecTypes<Packs>\n : Record<string, never>;\n\nexport interface FieldBuilder<\n Type extends ContractFieldType = ContractFieldType,\n Nullable extends boolean = boolean,\n Many extends boolean = boolean,\n> {\n readonly __kind: 'field';\n readonly __type: Type;\n readonly __nullable: Nullable;\n readonly __many: Many;\n optional(): FieldBuilder<Type, true, Many>;\n many(): FieldBuilder<Type, Nullable, true>;\n}\n\nexport interface ValueObjectBuilder<\n Name extends string = string,\n Fields extends Record<string, FieldBuilder> = Record<string, FieldBuilder>,\n> {\n readonly __kind: 'valueObject';\n readonly __name: Name;\n readonly __fields: Fields;\n}\n\nexport interface FieldReference<\n ModelName extends string = string,\n FieldName extends string = string,\n> {\n readonly __kind: 'fieldRef';\n readonly modelName: ModelName;\n readonly fieldName: FieldName;\n}\n\nexport interface RelationOn<\n LocalFields extends readonly string[] = readonly string[],\n TargetFields extends readonly string[] = readonly string[],\n> {\n readonly localFields: LocalFields;\n readonly targetFields: TargetFields;\n}\n\nexport interface RelationBuilder<\n To extends string = string,\n Cardinality extends '1:1' | '1:N' | 'N:1' = '1:1' | '1:N' | 'N:1',\n On extends RelationOn | undefined = RelationOn | undefined,\n> {\n readonly __kind: 'relation';\n readonly __to: To;\n readonly __cardinality: Cardinality;\n readonly __on: On;\n}\n\nexport interface ModelBuilder<\n Name extends string = string,\n Fields extends Record<string, FieldBuilder> = Record<string, FieldBuilder>,\n Relations extends Record<string, RelationBuilder> = Record<string, RelationBuilder>,\n Collection extends string | undefined = string | undefined,\n Owner extends string | undefined = string | undefined,\n Base extends string | undefined = string | undefined,\n StorageRelations extends Record<string, StorageRelationSpec> | undefined =\n | Record<string, StorageRelationSpec>\n | undefined,\n Discriminator extends { readonly field: string } | undefined =\n | { readonly field: string }\n | undefined,\n Variants extends Record<string, VariantSpec> | undefined =\n | Record<string, VariantSpec>\n | undefined,\n> {\n readonly __kind: 'model';\n readonly __name: Name;\n readonly __fields: Fields;\n readonly __relations: Relations;\n readonly __indexes: readonly MongoIndex[] | undefined;\n readonly __collectionOptions: MongoCollectionOptions | undefined;\n readonly __collection: Collection;\n readonly __owner: Owner;\n readonly __base: Base;\n readonly __storageRelations: StorageRelations;\n readonly __discriminator: Discriminator;\n readonly __variants: Variants;\n ref<const FieldName extends keyof Fields & string>(\n fieldName: FieldName,\n ): FieldReference<Name, FieldName>;\n}\n\ntype AnyFieldBuilder = FieldBuilder<ContractFieldType, boolean, boolean>;\ntype AnyReferenceRelationBuilder = RelationBuilder<string, '1:1' | '1:N' | 'N:1', RelationOn>;\ntype AnyEmbedRelationBuilder = RelationBuilder<string, '1:1' | '1:N', undefined>;\ntype AnyRelationBuilder = AnyReferenceRelationBuilder | AnyEmbedRelationBuilder;\ntype AnyFieldReference = FieldReference<string, string>;\ntype NamedValueObjectBuilder<\n Name extends string = string,\n Fields extends Record<string, AnyFieldBuilder> = Record<string, AnyFieldBuilder>,\n> = ValueObjectBuilder<Name, Fields>;\ntype AnyValueObjectBuilder = NamedValueObjectBuilder;\ntype NamedModelBuilder<\n Name extends string = string,\n Fields extends Record<string, AnyFieldBuilder> = Record<string, AnyFieldBuilder>,\n Relations extends Record<string, AnyRelationBuilder> = Record<string, AnyRelationBuilder>,\n Collection extends string | undefined = string | undefined,\n Owner extends string | undefined = string | undefined,\n Base extends string | undefined = string | undefined,\n StorageRelations extends Record<string, StorageRelationSpec> | undefined =\n | Record<string, StorageRelationSpec>\n | undefined,\n Discriminator extends { readonly field: string } | undefined =\n | { readonly field: string }\n | undefined,\n Variants extends Record<string, VariantSpec> | undefined =\n | Record<string, VariantSpec>\n | undefined,\n> = ModelBuilder<\n Name,\n Fields,\n Relations,\n Collection,\n Owner,\n Base,\n StorageRelations,\n Discriminator,\n Variants\n>;\ntype AnyModelBuilder = NamedModelBuilder;\n\ntype ExtractFieldReferenceName<T> =\n T extends FieldReference<string, infer FieldName extends string> ? FieldName : never;\ntype ExtractModelName<T> = T extends NamedModelBuilder<infer Name> ? Name : never;\ntype ExtractValueObjectName<T> = T extends NamedValueObjectBuilder<infer Name> ? Name : never;\ntype ExtractModelCollection<T> =\n T extends NamedModelBuilder<\n string,\n Record<string, AnyFieldBuilder>,\n Record<string, AnyRelationBuilder>,\n infer Collection\n >\n ? Collection\n : never;\ntype ExtractModelOwner<T> =\n T extends NamedModelBuilder<\n string,\n Record<string, AnyFieldBuilder>,\n Record<string, AnyRelationBuilder>,\n string | undefined,\n infer Owner\n >\n ? Owner\n : never;\ntype ExtractModelBase<T> =\n T extends NamedModelBuilder<\n string,\n Record<string, AnyFieldBuilder>,\n Record<string, AnyRelationBuilder>,\n string | undefined,\n string | undefined,\n infer Base\n >\n ? Base\n : never;\ntype ExtractModelStorageRelations<T> =\n T extends NamedModelBuilder<\n string,\n Record<string, AnyFieldBuilder>,\n Record<string, AnyRelationBuilder>,\n string | undefined,\n string | undefined,\n string | undefined,\n infer StorageRelations\n >\n ? StorageRelations\n : never;\n\ntype ModelStorageSection<T> =\n ExtractModelCollection<T> extends string\n ? { readonly collection: ExtractModelCollection<T> }\n : EmptyObject;\ntype ModelStorageRelationsSection<T> =\n ExtractModelStorageRelations<T> extends Record<string, StorageRelationSpec>\n ? keyof ExtractModelStorageRelations<T> extends never\n ? EmptyObject\n : { readonly relations: ExtractModelStorageRelations<T> }\n : EmptyObject;\ntype RootModelCollection<T> =\n ExtractModelCollection<T> extends string\n ? ExtractModelOwner<T> extends undefined\n ? ExtractModelBase<T> extends undefined\n ? ExtractModelCollection<T>\n : never\n : never\n : never;\ntype RootModelName<T> = RootModelCollection<T> extends never ? never : ExtractModelName<T>;\ntype CollectionName<T> =\n ExtractModelCollection<T> extends string ? ExtractModelCollection<T> : never;\n\ntype ModelNameInput = string | AnyModelBuilder;\ntype ValueObjectNameInput = string | AnyValueObjectBuilder;\ntype RelationTargetFieldsInput<TargetName extends string> =\n | StringListInput\n | FieldReference<TargetName, string>\n | readonly FieldReference<TargetName, string>[];\n\ntype NormalizeModelName<T> = T extends string ? T : ExtractModelName<T>;\n\ntype NormalizeModelNameOrUndefined<T> = [T] extends [undefined]\n ? undefined\n : NormalizeModelName<Present<T>>;\n\ntype NormalizeValueObjectName<T> = T extends string ? T : ExtractValueObjectName<T>;\n\ntype NormalizeStringList<T> = T extends readonly string[]\n ? T\n : T extends string\n ? readonly [T]\n : readonly string[];\n\ntype NormalizeTargetFieldList<T> = T extends readonly AnyFieldReference[]\n ? {\n readonly [K in keyof T]: ExtractFieldReferenceName<T[K]>;\n }\n : T extends AnyFieldReference\n ? readonly [ExtractFieldReferenceName<T>]\n : NormalizeStringList<T>;\n\ntype ContractFieldFromBuilder<TBuilder> =\n TBuilder extends FieldBuilder<\n infer Type extends ContractFieldType,\n infer Nullable extends boolean,\n infer Many extends boolean\n >\n ? Simplify<\n {\n readonly type: Type;\n readonly nullable: Nullable;\n } & (Many extends true ? { readonly many: true } : EmptyObject)\n >\n : never;\n\ntype ContractFieldsFromRecord<Fields extends Record<string, AnyFieldBuilder>> = Simplify<{\n readonly [K in keyof Fields]: ContractFieldFromBuilder<Fields[K]>;\n}>;\n\ntype ContractValueObjectFromBuilder<TBuilder> =\n TBuilder extends ValueObjectBuilder<string, infer Fields extends Record<string, AnyFieldBuilder>>\n ? Simplify<{\n readonly fields: ContractFieldsFromRecord<Fields>;\n }>\n : never;\n\ntype ContractValueObjectsFromRecord<ValueObjects extends Record<string, AnyValueObjectBuilder>> =\n Simplify<{\n readonly [K in keyof ValueObjects as ExtractValueObjectName<\n ValueObjects[K]\n >]: ContractValueObjectFromBuilder<ValueObjects[K]>;\n }>;\n\ntype ContractRelationFromBuilder<TBuilder> =\n TBuilder extends RelationBuilder<\n infer To extends string,\n infer Cardinality extends '1:1' | '1:N' | 'N:1',\n infer On extends RelationOn | undefined\n >\n ? On extends RelationOn\n ? {\n readonly to: To;\n readonly cardinality: Cardinality;\n readonly on: On;\n }\n : {\n readonly to: To;\n readonly cardinality: Cardinality;\n }\n : never;\n\ntype ContractRelationsFromRecord<Relations extends Record<string, AnyRelationBuilder>> =\n keyof Relations extends never\n ? Record<string, never>\n : Simplify<{\n readonly [K in keyof Relations]: ContractRelationFromBuilder<Relations[K]>;\n }>;\n\ntype ContractModelStorageFromBuilder<TBuilder> = ModelStorageSection<TBuilder> &\n ModelStorageRelationsSection<TBuilder>;\n\ntype MaybeOwner<Owner> = [Owner] extends [undefined]\n ? EmptyObject\n : { readonly owner: Owner & string };\ntype MaybeBase<Base> = [Base] extends [undefined] ? EmptyObject : { readonly base: Base & string };\ntype MaybeDiscriminator<Discriminator> = [Discriminator] extends [undefined]\n ? EmptyObject\n : { readonly discriminator: Discriminator & { readonly field: string } };\ntype MaybeVariants<Variants> = [Variants] extends [undefined]\n ? EmptyObject\n : { readonly variants: Variants };\n\ntype ContractModelFromBuilder<TBuilder> =\n TBuilder extends NamedModelBuilder<\n string,\n infer Fields extends Record<string, AnyFieldBuilder>,\n infer Relations extends Record<string, AnyRelationBuilder>,\n string | undefined,\n infer Owner,\n infer Base,\n Record<string, StorageRelationSpec> | undefined,\n infer Discriminator,\n infer Variants\n >\n ? Simplify<\n {\n readonly fields: ContractFieldsFromRecord<Fields>;\n readonly relations: ContractRelationsFromRecord<Relations>;\n readonly storage: ContractModelStorageFromBuilder<TBuilder>;\n } & MaybeOwner<Owner> &\n MaybeBase<Base> &\n MaybeDiscriminator<Discriminator> &\n MaybeVariants<Variants>\n >\n : never;\n\ntype ContractModelsFromRecord<Models extends Record<string, AnyModelBuilder>> = Simplify<{\n readonly [K in keyof Models as ExtractModelName<Models[K]>]: ContractModelFromBuilder<Models[K]>;\n}>;\n\ntype DerivedRootModels<Models extends Record<string, AnyModelBuilder>> = Simplify<{\n readonly [K in keyof Models as RootModelCollection<Models[K]>]: RootModelName<Models[K]>;\n}>;\n\ntype StorageCollectionsFromModels<Models extends Record<string, AnyModelBuilder>> = Simplify<{\n readonly [K in keyof Models as CollectionName<Models[K]>]: MongoStorageCollection;\n}>;\n\ntype NormalizeRoots<Roots extends Record<string, ModelNameInput>> = Simplify<{\n readonly [K in keyof Roots]: NormalizeModelName<Roots[K]>;\n}>;\n\ntype DefinitionModels<Definition> = Definition extends {\n readonly models?: infer Models extends Record<string, AnyModelBuilder>;\n}\n ? Models\n : Record<never, never>;\n\ntype DefinitionValueObjects<Definition> = Definition extends {\n readonly valueObjects?: infer ValueObjects extends Record<string, AnyValueObjectBuilder>;\n}\n ? ValueObjects\n : Record<never, never>;\n\ntype DefinitionRoots<Definition> = Definition extends {\n readonly roots?: infer Roots extends Record<string, ModelNameInput>;\n}\n ? NormalizeRoots<Roots>\n : DerivedRootModels<DefinitionModels<Definition>>;\n\ntype DefinitionCapabilities<Definition> = Definition extends {\n readonly capabilities?: infer Capabilities extends ContractCapabilities;\n}\n ? Capabilities\n : Record<never, never>;\n\ntype DefinitionExtensionPacks<Definition> = Definition extends {\n readonly extensionPacks?: infer ExtensionPacks extends Record<\n string,\n ExtensionPackRef<string, string>\n >;\n}\n ? ExtensionPacks\n : Record<never, never>;\n\ntype DefinitionFamilyId<Definition> = Definition extends {\n readonly family: FamilyPackRef<infer FamilyId>;\n}\n ? FamilyId\n : string;\n\ntype DefinitionTargetId<Definition> = Definition extends {\n readonly target: TargetPackRef<string, infer TargetId>;\n}\n ? TargetId\n : string;\n\ntype DefinitionStorage<Definition> = Simplify<\n MongoStorage & {\n readonly collections: StorageCollectionsFromModels<DefinitionModels<Definition>>;\n readonly storageHash: StorageHashBase<string>;\n }\n>;\n\ntype MaybeValueObjectsSection<ValueObjects extends Record<string, AnyValueObjectBuilder>> =\n keyof ValueObjects extends never\n ? EmptyObject\n : {\n readonly valueObjects: ContractValueObjectsFromRecord<ValueObjects>;\n };\n\ntype MongoContractBaseFromDefinition<Definition> = Simplify<\n {\n readonly target: DefinitionTargetId<Definition>;\n readonly targetFamily: DefinitionFamilyId<Definition>;\n readonly roots: DefinitionRoots<Definition>;\n readonly models: ContractModelsFromRecord<DefinitionModels<Definition>>;\n readonly storage: DefinitionStorage<Definition>;\n readonly capabilities: DefinitionCapabilities<Definition>;\n readonly extensionPacks: DefinitionExtensionPacks<Definition>;\n readonly profileHash: ProfileHashBase<string>;\n readonly meta: Record<string, never>;\n } & MaybeValueObjectsSection<DefinitionValueObjects<Definition>>\n>;\n\ntype CodecTypesFromDefinition<Definition> = MongoCodecTypes &\n MergeExtensionCodecTypesSafe<DefinitionExtensionPacks<Definition>>;\n\nexport type MongoContractResult<Definition> = MongoContractWithTypeMaps<\n MongoContractBaseFromDefinition<Definition>,\n MongoTypeMaps<CodecTypesFromDefinition<Definition>>\n>;\n\ntype ContractAuthoringHelpers = {\n readonly field: typeof field;\n readonly index: typeof index;\n readonly model: typeof model;\n readonly rel: typeof rel;\n readonly valueObject: typeof valueObject;\n};\n\nexport type ContractScaffold<\n Family extends FamilyPackRef<string>,\n Target extends TargetPackRef<string, string>,\n ExtensionPacks extends Record<string, ExtensionPackRef<string, string>> | undefined = undefined,\n Capabilities extends ContractCapabilities | undefined = undefined,\n Roots extends Record<string, ModelNameInput> | undefined = undefined,\n> = {\n readonly family: Family;\n readonly target: Target;\n readonly extensionPacks?: ExtensionPacks;\n readonly capabilities?: Capabilities;\n readonly roots?: Roots;\n};\n\nexport type ContractDefinition<\n Family extends FamilyPackRef<string>,\n Target extends TargetPackRef<string, string>,\n Models extends Record<string, AnyModelBuilder> = Record<never, never>,\n ValueObjects extends Record<string, AnyValueObjectBuilder> = Record<never, never>,\n ExtensionPacks extends Record<string, ExtensionPackRef<string, string>> | undefined = undefined,\n Capabilities extends ContractCapabilities | undefined = undefined,\n Roots extends Record<string, ModelNameInput> | undefined = undefined,\n> = ContractScaffold<Family, Target, ExtensionPacks, Capabilities, Roots> & {\n readonly models?: Models;\n readonly valueObjects?: ValueObjects;\n};\n\nexport type ContractFactory<\n Models extends Record<string, AnyModelBuilder> = Record<never, never>,\n ValueObjects extends Record<string, AnyValueObjectBuilder> = Record<never, never>,\n Roots extends Record<string, ModelNameInput> | undefined = undefined,\n> = (helpers: ContractAuthoringHelpers) => {\n readonly models?: Models;\n readonly valueObjects?: ValueObjects;\n readonly roots?: Roots;\n};\n\ntype FieldBuilderSpec<\n Type extends ContractFieldType,\n Nullable extends boolean,\n Many extends boolean,\n> = {\n readonly type: Type;\n readonly nullable: Nullable;\n readonly many: Many;\n};\n\nfunction createFieldBuilder<\n Type extends ContractFieldType,\n Nullable extends boolean,\n Many extends boolean,\n>(spec: FieldBuilderSpec<Type, Nullable, Many>): FieldBuilder<Type, Nullable, Many> {\n return {\n __kind: 'field',\n __type: spec.type,\n __nullable: spec.nullable,\n __many: spec.many,\n optional() {\n return createFieldBuilder<Type, true, Many>({\n type: spec.type,\n nullable: true,\n many: spec.many,\n });\n },\n many() {\n return createFieldBuilder<Type, Nullable, true>({\n type: spec.type,\n nullable: spec.nullable,\n many: true,\n });\n },\n };\n}\n\nfunction normalizeOptionalTypeParams(\n typeParams: Record<string, unknown> | undefined,\n): { readonly typeParams: Record<string, unknown> } | Record<never, never> {\n if (!typeParams) {\n return {};\n }\n\n return { typeParams };\n}\n\nfunction createScalarFieldBuilder<\n CodecId extends string,\n TypeParams extends Record<string, unknown> | undefined = undefined,\n>(\n codecId: CodecId,\n options?: { readonly typeParams?: TypeParams },\n): FieldBuilder<\n {\n readonly kind: 'scalar';\n readonly codecId: CodecId;\n } & ([TypeParams] extends [undefined] ? EmptyObject : { readonly typeParams: TypeParams }),\n false,\n false\n> {\n return createFieldBuilder({\n type: {\n kind: 'scalar',\n codecId,\n ...normalizeOptionalTypeParams(options?.typeParams),\n } as {\n readonly kind: 'scalar';\n readonly codecId: CodecId;\n } & ([TypeParams] extends [undefined] ? EmptyObject : { readonly typeParams: TypeParams }),\n nullable: false,\n many: false,\n });\n}\n\nexport const field = {\n scalar: createScalarFieldBuilder,\n objectId() {\n return createScalarFieldBuilder('mongo/objectId@1');\n },\n string() {\n return createScalarFieldBuilder('mongo/string@1');\n },\n double() {\n return createScalarFieldBuilder('mongo/double@1');\n },\n int32() {\n return createScalarFieldBuilder('mongo/int32@1');\n },\n bool() {\n return createScalarFieldBuilder('mongo/bool@1');\n },\n date() {\n return createScalarFieldBuilder('mongo/date@1');\n },\n vector<const TypeParams extends Record<string, unknown> | undefined = undefined>(options?: {\n readonly typeParams?: TypeParams;\n }) {\n return createScalarFieldBuilder('mongo/vector@1', options);\n },\n valueObject<const ValueObject extends ValueObjectNameInput>(valueObjectName: ValueObject) {\n return createFieldBuilder({\n type: {\n kind: 'valueObject',\n name: resolveValueObjectName(valueObjectName),\n } as {\n readonly kind: 'valueObject';\n readonly name: NormalizeValueObjectName<ValueObject>;\n },\n nullable: false,\n many: false,\n });\n },\n} as const;\n\nexport function index<const Fields extends MongoIndexFields>(\n fields: Fields,\n): {\n readonly fields: Fields;\n};\nexport function index<const Fields extends MongoIndexFields, const Options>(\n fields: Fields,\n options: StrictShape<Options, MongoIndexOptions>,\n): {\n readonly fields: Fields;\n readonly options: Options & MongoIndexOptions;\n};\nexport function index(\n fields: MongoIndexFields,\n options?: MongoIndexOptions,\n): {\n readonly fields: MongoIndexFields;\n readonly options?: MongoIndexOptions;\n} {\n return {\n fields,\n ...(options ? { options } : {}),\n };\n}\n\nfunction createFieldReference<const ModelName extends string, const FieldName extends string>(\n modelName: ModelName,\n fieldName: FieldName,\n): FieldReference<ModelName, FieldName> {\n return {\n __kind: 'fieldRef',\n modelName,\n fieldName,\n };\n}\n\nfunction isFieldReference(value: unknown): value is FieldReference<string, string> {\n return (\n typeof value === 'object' && value !== null && '__kind' in value && value.__kind === 'fieldRef'\n );\n}\n\nfunction resolveModelName(value: ModelNameInput): string {\n return typeof value === 'string' ? value : value.__name;\n}\n\nfunction resolveValueObjectName(value: ValueObjectNameInput): string {\n return typeof value === 'string' ? value : value.__name;\n}\n\nfunction normalizeStringList(value: StringListInput): readonly string[] {\n return typeof value === 'string' ? [value] : [...value];\n}\n\nfunction normalizeTargetField(\n targetModelName: string,\n value: string | FieldReference<string, string>,\n): string {\n if (!isFieldReference(value)) {\n return value;\n }\n\n if (value.modelName !== targetModelName) {\n throw new Error(\n `Relation target \"${targetModelName}\" cannot reference field \"${value.modelName}.${value.fieldName}\".`,\n );\n }\n\n return value.fieldName;\n}\n\nfunction normalizeTargetFields(\n targetModelName: string,\n value: RelationTargetFieldsInput<string>,\n): readonly string[] {\n if (typeof value === 'string') {\n return [value];\n }\n\n if (isFieldReference(value)) {\n return [normalizeTargetField(targetModelName, value)];\n }\n\n return value.map((entry) => normalizeTargetField(targetModelName, entry));\n}\n\ntype ReferenceOptions<\n Target extends ModelNameInput,\n From extends StringListInput,\n To extends RelationTargetFieldsInput<NormalizeModelName<Target>>,\n> = {\n readonly from: From;\n readonly to: To;\n};\n\ntype RelationOnFromOptions<\n From extends StringListInput,\n To extends RelationTargetFieldsInput<string>,\n> = {\n readonly localFields: NormalizeStringList<From>;\n readonly targetFields: NormalizeTargetFieldList<To>;\n};\n\nfunction createRelationBuilder<\n To extends string,\n Cardinality extends '1:1' | '1:N' | 'N:1',\n On extends RelationOn | undefined,\n>(spec: {\n readonly to: To;\n readonly cardinality: Cardinality;\n readonly on: On;\n}): RelationBuilder<To, Cardinality, On> {\n return {\n __kind: 'relation',\n __to: spec.to,\n __cardinality: spec.cardinality,\n __on: spec.on,\n };\n}\n\nfunction createReferenceRelationBuilder<\n Target extends ModelNameInput,\n Cardinality extends '1:1' | '1:N' | 'N:1',\n From extends StringListInput,\n To extends RelationTargetFieldsInput<NormalizeModelName<Target>>,\n>(\n target: Target,\n cardinality: Cardinality,\n options: ReferenceOptions<Target, From, To>,\n): RelationBuilder<NormalizeModelName<Target>, Cardinality, RelationOnFromOptions<From, To>> {\n const targetModelName = resolveModelName(target);\n\n return createRelationBuilder({\n to: targetModelName as NormalizeModelName<Target>,\n cardinality,\n on: {\n localFields: normalizeStringList(options.from) as NormalizeStringList<From>,\n targetFields: normalizeTargetFields(\n targetModelName,\n options.to,\n ) as NormalizeTargetFieldList<To>,\n },\n });\n}\n\nfunction createEmbedRelationBuilder<\n Target extends ModelNameInput,\n Cardinality extends '1:1' | '1:N',\n>(\n target: Target,\n cardinality: Cardinality,\n): RelationBuilder<NormalizeModelName<Target>, Cardinality, undefined> {\n return createRelationBuilder({\n to: resolveModelName(target) as NormalizeModelName<Target>,\n cardinality,\n on: undefined,\n });\n}\n\nfunction hasOne<const Target extends ModelNameInput>(\n target: Target,\n): RelationBuilder<NormalizeModelName<Target>, '1:1', undefined>;\nfunction hasOne<\n const Target extends ModelNameInput,\n const From extends StringListInput,\n const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>,\n>(\n target: Target,\n options: ReferenceOptions<Target, From, To>,\n): RelationBuilder<NormalizeModelName<Target>, '1:1', RelationOnFromOptions<From, To>>;\nfunction hasOne(\n target: ModelNameInput,\n options?: ReferenceOptions<ModelNameInput, StringListInput, RelationTargetFieldsInput<string>>,\n) {\n if (!options) {\n return createEmbedRelationBuilder(target, '1:1');\n }\n\n return createReferenceRelationBuilder(target, '1:1', options);\n}\n\nfunction hasMany<const Target extends ModelNameInput>(\n target: Target,\n): RelationBuilder<NormalizeModelName<Target>, '1:N', undefined>;\nfunction hasMany<\n const Target extends ModelNameInput,\n const From extends StringListInput,\n const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>,\n>(\n target: Target,\n options: ReferenceOptions<Target, From, To>,\n): RelationBuilder<NormalizeModelName<Target>, '1:N', RelationOnFromOptions<From, To>>;\nfunction hasMany(\n target: ModelNameInput,\n options?: ReferenceOptions<ModelNameInput, StringListInput, RelationTargetFieldsInput<string>>,\n) {\n if (!options) {\n return createEmbedRelationBuilder(target, '1:N');\n }\n\n return createReferenceRelationBuilder(target, '1:N', options);\n}\n\nfunction belongsTo<\n const Target extends ModelNameInput,\n const From extends StringListInput,\n const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>,\n>(\n target: Target,\n options: ReferenceOptions<Target, From, To>,\n): RelationBuilder<NormalizeModelName<Target>, 'N:1', RelationOnFromOptions<From, To>> {\n return createReferenceRelationBuilder(target, 'N:1', options);\n}\n\nexport const rel = {\n belongsTo,\n hasMany,\n hasOne,\n} as const;\n\ntype ValueObjectInput<Fields extends Record<string, AnyFieldBuilder>> = {\n readonly fields: Fields;\n};\n\nexport function valueObject<\n const Name extends string,\n const Fields extends Record<string, AnyFieldBuilder>,\n>(name: Name, input: ValueObjectInput<Fields>): ValueObjectBuilder<Name, Fields> {\n return {\n __kind: 'valueObject',\n __name: name,\n __fields: input.fields,\n };\n}\n\ntype ModelDiscriminatorInput<Variants extends Record<string, VariantSpec>> = {\n readonly field: string;\n readonly variants: Variants;\n};\n\ntype ModelInput<\n Fields extends Record<string, AnyFieldBuilder>,\n Relations extends Record<string, AnyRelationBuilder> | undefined,\n Collection extends string | undefined,\n Indexes extends readonly MongoIndex[] | undefined,\n CollectionOptions,\n Owner extends ModelNameInput | undefined,\n Base extends ModelNameInput | undefined,\n StorageRelations extends Record<string, StorageRelationSpec> | undefined,\n Discriminator extends ModelDiscriminatorInput<Record<string, VariantSpec>> | undefined,\n> = {\n readonly collection?: Collection;\n readonly indexes?: Indexes;\n readonly collectionOptions?: StrictShape<CollectionOptions, MongoCollectionOptions>;\n readonly storageRelations?: StorageRelations;\n readonly fields: Fields;\n readonly relations?: Relations;\n readonly owner?: Owner;\n readonly base?: Base;\n readonly discriminator?: Discriminator;\n};\n\nexport function model<\n const Name extends string,\n const Fields extends Record<string, AnyFieldBuilder>,\n const Relations extends Record<string, AnyRelationBuilder> | undefined = undefined,\n const Collection extends string | undefined = undefined,\n const Indexes extends readonly MongoIndex[] | undefined = undefined,\n const CollectionOptions = undefined,\n const Owner extends ModelNameInput | undefined = undefined,\n const Base extends ModelNameInput | undefined = undefined,\n const StorageRelations extends Record<string, StorageRelationSpec> | undefined = undefined,\n const Discriminator extends\n | ModelDiscriminatorInput<Record<string, VariantSpec>>\n | undefined = undefined,\n>(\n name: Name,\n input: ModelInput<\n Fields,\n Relations,\n Collection,\n Indexes,\n CollectionOptions,\n Owner,\n Base,\n StorageRelations,\n Discriminator\n >,\n): ModelBuilder<\n Name,\n Fields,\n Relations extends Record<string, AnyRelationBuilder> ? Relations : Record<never, never>,\n Collection,\n NormalizeModelNameOrUndefined<Owner>,\n NormalizeModelNameOrUndefined<Base>,\n StorageRelations,\n Discriminator extends { readonly field: infer Field extends string }\n ? { readonly field: Field }\n : undefined,\n Discriminator extends { readonly variants: infer Variants extends Record<string, VariantSpec> }\n ? Variants\n : undefined\n> {\n return {\n __kind: 'model',\n __name: name,\n __fields: input.fields,\n __relations: (input.relations ?? {}) as Relations extends Record<string, AnyRelationBuilder>\n ? Relations\n : Record<never, never>,\n __indexes: input.indexes,\n __collectionOptions: input.collectionOptions,\n __collection: input.collection as Collection,\n __owner: (input.owner\n ? resolveModelName(input.owner)\n : undefined) as NormalizeModelNameOrUndefined<Owner>,\n __base: (input.base\n ? resolveModelName(input.base)\n : undefined) as NormalizeModelNameOrUndefined<Base>,\n __storageRelations: input.storageRelations as StorageRelations,\n __discriminator: (input.discriminator\n ? { field: input.discriminator.field }\n : undefined) as Discriminator extends { readonly field: infer Field extends string }\n ? { readonly field: Field }\n : undefined,\n __variants: input.discriminator?.variants as Discriminator extends {\n readonly variants: infer Variants extends Record<string, VariantSpec>;\n }\n ? Variants\n : undefined,\n ref(fieldName) {\n return createFieldReference(name, fieldName);\n },\n };\n}\n\nfunction validateTargetPackRef(\n family: FamilyPackRef<string>,\n target: TargetPackRef<string, string>,\n): void {\n if (family.familyId !== 'mongo') {\n throw new Error(\n `defineContract only accepts Mongo family packs. Received family \"${family.familyId}\".`,\n );\n }\n\n if (target.familyId !== family.familyId) {\n throw new Error(\n `target pack \"${target.id}\" targets family \"${target.familyId}\" but contract family is \"${family.familyId}\".`,\n );\n }\n}\n\nfunction validateExtensionPackRefs(\n target: TargetPackRef<string, string>,\n extensionPacks?: Record<string, ExtensionPackRef<string, string>>,\n): void {\n if (!extensionPacks) {\n return;\n }\n\n for (const packRef of Object.values(extensionPacks)) {\n if (packRef.kind !== 'extension') {\n throw new Error(\n `defineContract only accepts extension pack refs in extensionPacks. Received kind \"${packRef.kind}\".`,\n );\n }\n\n if (packRef.familyId !== target.familyId) {\n throw new Error(\n `extension pack \"${packRef.id}\" targets family \"${packRef.familyId}\" but contract target family is \"${target.familyId}\".`,\n );\n }\n\n if (packRef.targetId && packRef.targetId !== target.targetId) {\n throw new Error(\n `extension pack \"${packRef.id}\" targets \"${packRef.targetId}\" but contract target is \"${target.targetId}\".`,\n );\n }\n }\n}\n\nfunction isContractScaffold(\n value: unknown,\n): value is ContractScaffold<\n FamilyPackRef<string>,\n TargetPackRef<string, string>,\n Record<string, ExtensionPackRef<string, string>> | undefined,\n ContractCapabilities | undefined,\n Record<string, ModelNameInput> | undefined\n> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n return 'family' in value && 'target' in value;\n}\n\nfunction buildContractField(builder: AnyFieldBuilder): ContractField {\n return builder.__many\n ? {\n type: builder.__type,\n nullable: builder.__nullable,\n many: true,\n }\n : {\n type: builder.__type,\n nullable: builder.__nullable,\n };\n}\n\nfunction buildFields(fields: Record<string, AnyFieldBuilder>): Record<string, ContractField> {\n const builtFields: Record<string, ContractField> = {};\n\n for (const [fieldName, fieldBuilder] of Object.entries(fields)) {\n builtFields[fieldName] = buildContractField(fieldBuilder);\n }\n\n return builtFields;\n}\n\nfunction buildRelation(\n relationBuilder: AnyRelationBuilder,\n): ContractEmbedRelation | ContractReferenceRelation {\n return relationBuilder.__on\n ? {\n to: relationBuilder.__to,\n cardinality: relationBuilder.__cardinality,\n on: relationBuilder.__on,\n }\n : {\n to: relationBuilder.__to,\n cardinality: relationBuilder.__cardinality,\n };\n}\n\nfunction buildRelations(\n relations: Record<string, AnyRelationBuilder>,\n): Record<string, ContractEmbedRelation | ContractReferenceRelation> {\n const builtRelations: Record<string, ContractEmbedRelation | ContractReferenceRelation> = {};\n\n for (const [relationName, relationBuilder] of Object.entries(relations)) {\n builtRelations[relationName] = buildRelation(relationBuilder);\n }\n\n return builtRelations;\n}\n\nfunction buildValueObjects(\n valueObjects: Record<string, AnyValueObjectBuilder> | undefined,\n): Record<string, ContractValueObject> {\n const builtValueObjects: Record<string, ContractValueObject> = {};\n\n for (const valueObjectBuilder of Object.values(valueObjects ?? {})) {\n if (valueObjectBuilder.__name in builtValueObjects) {\n throw new Error(\n `Duplicate value object name \"${valueObjectBuilder.__name}\" in defineContract().`,\n );\n }\n\n builtValueObjects[valueObjectBuilder.__name] = {\n fields: buildFields(valueObjectBuilder.__fields),\n };\n }\n\n return builtValueObjects;\n}\n\nfunction buildModels(\n models: Record<string, AnyModelBuilder> | undefined,\n): Record<string, MongoContract['models'][string]> {\n const builtModels: Record<string, MongoContract['models'][string]> = {};\n\n for (const modelBuilder of Object.values(models ?? {})) {\n if (modelBuilder.__name in builtModels) {\n throw new Error(`Duplicate model name \"${modelBuilder.__name}\" in defineContract().`);\n }\n\n const storage = {\n ...(modelBuilder.__collection ? { collection: modelBuilder.__collection } : {}),\n ...(modelBuilder.__storageRelations ? { relations: modelBuilder.__storageRelations } : {}),\n };\n\n builtModels[modelBuilder.__name] = {\n fields: buildFields(modelBuilder.__fields),\n relations: buildRelations(modelBuilder.__relations),\n storage,\n ...(modelBuilder.__owner ? { owner: modelBuilder.__owner } : {}),\n ...(modelBuilder.__base ? { base: modelBuilder.__base } : {}),\n ...(modelBuilder.__discriminator ? { discriminator: modelBuilder.__discriminator } : {}),\n ...(modelBuilder.__variants ? { variants: modelBuilder.__variants } : {}),\n };\n }\n\n return builtModels;\n}\n\nfunction deriveRoots(models: Record<string, AnyModelBuilder> | undefined): Record<string, string> {\n const roots: Record<string, string> = {};\n\n for (const modelBuilder of Object.values(models ?? {})) {\n if (!modelBuilder.__collection || modelBuilder.__owner || modelBuilder.__base) {\n continue;\n }\n\n roots[modelBuilder.__collection] = modelBuilder.__name;\n }\n\n return roots;\n}\n\nfunction normalizeRoots(roots: Record<string, ModelNameInput> | undefined): Record<string, string> {\n const normalizedRoots: Record<string, string> = {};\n\n for (const [rootName, rootValue] of Object.entries(roots ?? {})) {\n normalizedRoots[rootName] = resolveModelName(rootValue);\n }\n\n return normalizedRoots;\n}\n\nfunction stableStringify(value: unknown): string {\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(',')}]`;\n }\n\n if (value && typeof value === 'object') {\n return `{${Object.entries(value as Record<string, unknown>)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`)\n .join(',')}}`;\n }\n\n return JSON.stringify(value);\n}\n\nfunction toStorageIndex(index: MongoIndex): MongoStorageIndex {\n const keys = Object.entries(index.fields).map(([field, direction]) => ({\n field,\n direction,\n }));\n const result: Record<string, unknown> = { keys };\n if (index.options) {\n for (const [key, value] of Object.entries(index.options)) {\n if (value !== undefined) {\n result[key] = value;\n }\n }\n }\n return result as unknown as MongoStorageIndex;\n}\n\nfunction toStorageCollectionOptions(opts: MongoCollectionOptions): MongoStorageCollectionOptions {\n const result: Record<string, unknown> = {};\n if (opts.capped) {\n result['capped'] = { size: opts.size ?? 0, ...(opts.max != null ? { max: opts.max } : {}) };\n }\n if (opts.timeseries) result['timeseries'] = opts.timeseries;\n if (opts.collation) result['collation'] = opts.collation;\n if (opts.changeStreamPreAndPostImages)\n result['changeStreamPreAndPostImages'] = opts.changeStreamPreAndPostImages;\n if (opts.clusteredIndex) result['clusteredIndex'] = { name: opts.clusteredIndex.name };\n return result as unknown as MongoStorageCollectionOptions;\n}\n\nfunction buildCollections(\n models: Record<string, AnyModelBuilder> | undefined,\n): Record<string, MongoStorageCollection> {\n const collections: Record<string, MongoStorageCollection> = {};\n const declaredIndexOwners = new Map<string, string>();\n\n for (const modelBuilder of Object.values(models ?? {})) {\n if (!modelBuilder.__collection) {\n if (modelBuilder.__indexes && modelBuilder.__indexes.length > 0) {\n throw new Error(\n `Model \"${modelBuilder.__name}\" defines indexes but has no collection to attach them to.`,\n );\n }\n\n if (modelBuilder.__collectionOptions) {\n throw new Error(\n `Model \"${modelBuilder.__name}\" defines collectionOptions but has no collection to attach them to.`,\n );\n }\n\n continue;\n }\n\n const existingCollection = collections[modelBuilder.__collection] ?? {};\n const existingIndexes = existingCollection.indexes ?? [];\n\n if (existingCollection.options && modelBuilder.__collectionOptions) {\n throw new Error(\n `Collection \"${modelBuilder.__collection}\" has collectionOptions declared by multiple models. Author collectionOptions on a single model per collection.`,\n );\n }\n\n for (const collectionIndex of modelBuilder.__indexes ?? []) {\n const indexSignature = stableStringify(collectionIndex);\n const collectionIndexKey = `${modelBuilder.__collection}:${indexSignature}`;\n const firstOwner = declaredIndexOwners.get(collectionIndexKey);\n if (firstOwner) {\n throw new Error(\n `Collection \"${modelBuilder.__collection}\" defines duplicate index ${indexSignature}. First declared on model \"${firstOwner}\" and duplicated on model \"${modelBuilder.__name}\".`,\n );\n }\n declaredIndexOwners.set(collectionIndexKey, modelBuilder.__name);\n }\n\n const storageIndexes = (modelBuilder.__indexes ?? []).map(toStorageIndex);\n const storageOptions = modelBuilder.__collectionOptions\n ? toStorageCollectionOptions(modelBuilder.__collectionOptions)\n : undefined;\n\n collections[modelBuilder.__collection] =\n storageIndexes.length > 0\n ? {\n ...existingCollection,\n indexes: [...existingIndexes, ...storageIndexes],\n ...(storageOptions ? { options: storageOptions } : {}),\n }\n : storageOptions\n ? {\n ...existingCollection,\n options: storageOptions,\n }\n : existingCollection;\n }\n\n return collections;\n}\n\nfunction buildContractFromDefinition<\n const Definition extends ContractDefinition<\n FamilyPackRef<string>,\n TargetPackRef<string, string>,\n Record<string, AnyModelBuilder>,\n Record<string, AnyValueObjectBuilder>,\n Record<string, ExtensionPackRef<string, string>> | undefined,\n ContractCapabilities | undefined,\n Record<string, ModelNameInput> | undefined\n >,\n>(definition: Definition): MongoContractResult<Definition> {\n validateTargetPackRef(definition.family, definition.target);\n validateExtensionPackRefs(definition.target, definition.extensionPacks);\n\n const builtModels = buildModels(definition.models);\n const builtValueObjects = buildValueObjects(definition.valueObjects);\n const roots = definition.roots\n ? normalizeRoots(definition.roots)\n : deriveRoots(definition.models);\n const capabilities = definition.capabilities ?? {};\n const collections = buildCollections(definition.models);\n const storageBody = {\n collections,\n };\n\n const builtContract = {\n target: definition.target.targetId,\n targetFamily: definition.family.familyId,\n roots,\n models: builtModels,\n ...(Object.keys(builtValueObjects).length > 0 ? { valueObjects: builtValueObjects } : {}),\n storage: {\n ...storageBody,\n storageHash: computeStorageHash({\n target: definition.target.targetId,\n targetFamily: definition.family.familyId,\n storage: storageBody,\n }),\n },\n capabilities,\n extensionPacks: definition.extensionPacks ?? {},\n profileHash: computeProfileHash({\n target: definition.target.targetId,\n targetFamily: definition.family.familyId,\n capabilities,\n }),\n meta: {},\n } satisfies MongoContract;\n\n validateMongoContract(builtContract);\n\n return builtContract as MongoContractResult<Definition>;\n}\n\nexport function defineContract<\n const Definition extends ContractDefinition<\n FamilyPackRef<string>,\n TargetPackRef<string, string>,\n Record<string, AnyModelBuilder>,\n Record<string, AnyValueObjectBuilder>,\n Record<string, ExtensionPackRef<string, string>> | undefined,\n ContractCapabilities | undefined,\n Record<string, ModelNameInput> | undefined\n >,\n>(definition: Definition): MongoContractResult<Definition>;\nexport function defineContract<\n const Definition extends ContractScaffold<\n FamilyPackRef<string>,\n TargetPackRef<string, string>,\n Record<string, ExtensionPackRef<string, string>> | undefined,\n ContractCapabilities | undefined,\n Record<string, ModelNameInput> | undefined\n >,\n const Built extends {\n readonly models?: Record<string, AnyModelBuilder>;\n readonly valueObjects?: Record<string, AnyValueObjectBuilder>;\n readonly roots?: Record<string, ModelNameInput>;\n },\n>(\n definition: Definition,\n factory: (_helpers: ContractAuthoringHelpers) => Built,\n): MongoContractResult<Definition & Built>;\nexport function defineContract(\n definition: ContractScaffold<\n FamilyPackRef<string>,\n TargetPackRef<string, string>,\n Record<string, ExtensionPackRef<string, string>> | undefined,\n ContractCapabilities | undefined,\n Record<string, ModelNameInput> | undefined\n >,\n factory?: ContractFactory<\n Record<string, AnyModelBuilder>,\n Record<string, AnyValueObjectBuilder>,\n Record<string, ModelNameInput> | undefined\n >,\n) {\n if (!isContractScaffold(definition)) {\n throw new TypeError(\n 'defineContract expects a contract definition object. Define your contract with defineContract({ family, target, models, ... }).',\n );\n }\n\n if (!factory) {\n return buildContractFromDefinition(definition);\n }\n\n return buildContractFromDefinition({\n ...definition,\n ...factory({ field, index, model, rel, valueObject }),\n });\n}\n"],"mappings":";;;;AA2iBA,SAAS,mBAIP,MAAkF;AAClF,QAAO;EACL,QAAQ;EACR,QAAQ,KAAK;EACb,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb,WAAW;AACT,UAAO,mBAAqC;IAC1C,MAAM,KAAK;IACX,UAAU;IACV,MAAM,KAAK;IACZ,CAAC;;EAEJ,OAAO;AACL,UAAO,mBAAyC;IAC9C,MAAM,KAAK;IACX,UAAU,KAAK;IACf,MAAM;IACP,CAAC;;EAEL;;AAGH,SAAS,4BACP,YACyE;AACzE,KAAI,CAAC,WACH,QAAO,EAAE;AAGX,QAAO,EAAE,YAAY;;AAGvB,SAAS,yBAIP,SACA,SAQA;AACA,QAAO,mBAAmB;EACxB,MAAM;GACJ,MAAM;GACN;GACA,GAAG,4BAA4B,SAAS,WAAW;GACpD;EAID,UAAU;EACV,MAAM;EACP,CAAC;;AAGJ,MAAa,QAAQ;CACnB,QAAQ;CACR,WAAW;AACT,SAAO,yBAAyB,mBAAmB;;CAErD,SAAS;AACP,SAAO,yBAAyB,iBAAiB;;CAEnD,SAAS;AACP,SAAO,yBAAyB,iBAAiB;;CAEnD,QAAQ;AACN,SAAO,yBAAyB,gBAAgB;;CAElD,OAAO;AACL,SAAO,yBAAyB,eAAe;;CAEjD,OAAO;AACL,SAAO,yBAAyB,eAAe;;CAEjD,OAAiF,SAE9E;AACD,SAAO,yBAAyB,kBAAkB,QAAQ;;CAE5D,YAA4D,iBAA8B;AACxF,SAAO,mBAAmB;GACxB,MAAM;IACJ,MAAM;IACN,MAAM,uBAAuB,gBAAgB;IAC9C;GAID,UAAU;GACV,MAAM;GACP,CAAC;;CAEL;AAcD,SAAgB,MACd,QACA,SAIA;AACA,QA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,OAAO;CAClD,MAAM,oBAAoB,kBAAkB,WAAW,aAAa;CACpE,MAAM,QAAQ,WAAW,QACrB,eAAe,WAAW,MAAM,GAChC,YAAY,WAAW,OAAO;CAClC,MAAM,eAAe,WAAW,gBAAgB,EAAE;CAElD,MAAM,cAAc,EAClB,aAFkB,iBAAiB,WAAW,OAAO,EAGtD;CAED,MAAM,gBAAgB;EACpB,QAAQ,WAAW,OAAO;EAC1B,cAAc,WAAW,OAAO;EAChC;EACA,QAAQ;EACR,GAAI,OAAO,KAAK,kBAAkB,CAAC,SAAS,IAAI,EAAE,cAAc,mBAAmB,GAAG,EAAE;EACxF,SAAS;GACP,GAAG;GACH,aAAa,mBAAmB;IAC9B,QAAQ,WAAW,OAAO;IAC1B,cAAc,WAAW,OAAO;IAChC,SAAS;IACV,CAAC;GACH;EACD;EACA,gBAAgB,WAAW,kBAAkB,EAAE;EAC/C,aAAa,mBAAmB;GAC9B,QAAQ,WAAW,OAAO;GAC1B,cAAc,WAAW,OAAO;GAChC;GACD,CAAC;EACF,MAAM,EAAE;EACT;AAED,uBAAsB,cAAc;AAEpC,QAAO;;AA+BT,SAAgB,eACd,YAOA,SAKA;AACA,KAAI,CAAC,mBAAmB,WAAW,CACjC,OAAM,IAAI,UACR,kIACD;AAGH,KAAI,CAAC,QACH,QAAO,4BAA4B,WAAW;AAGhD,QAAO,4BAA4B;EACjC,GAAG;EACH,GAAG,QAAQ;GAAE;GAAO;GAAO;GAAO;GAAK;GAAa,CAAC;EACtD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo-contract-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.3.0-dev.162",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Mongo-specific TypeScript contract authoring surface for Prisma Next",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsdown",
|
|
9
|
-
"test": "vitest run",
|
|
10
|
-
"test:coverage": "vitest run --coverage",
|
|
11
|
-
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
12
|
-
"lint": "biome check . --error-on-warnings",
|
|
13
|
-
"lint:fix": "biome check --write .",
|
|
14
|
-
"lint:fix:unsafe": "biome check --write --unsafe .",
|
|
15
|
-
"clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
|
|
16
|
-
},
|
|
17
7
|
"dependencies": {
|
|
18
|
-
"@prisma-next/config": "
|
|
19
|
-
"@prisma-next/contract": "
|
|
20
|
-
"@prisma-next/framework-components": "
|
|
21
|
-
"@prisma-next/mongo-contract": "
|
|
22
|
-
"@prisma-next/utils": "
|
|
8
|
+
"@prisma-next/config": "0.3.0-dev.162",
|
|
9
|
+
"@prisma-next/contract": "0.3.0-dev.162",
|
|
10
|
+
"@prisma-next/framework-components": "0.3.0-dev.162",
|
|
11
|
+
"@prisma-next/mongo-contract": "0.3.0-dev.162",
|
|
12
|
+
"@prisma-next/utils": "0.3.0-dev.162"
|
|
23
13
|
},
|
|
24
14
|
"devDependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
15
|
+
"tsdown": "0.18.4",
|
|
16
|
+
"typescript": "5.9.3",
|
|
17
|
+
"vitest": "4.0.17",
|
|
18
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
19
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
20
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
31
21
|
},
|
|
32
22
|
"files": [
|
|
33
23
|
"dist",
|
|
@@ -42,5 +32,15 @@
|
|
|
42
32
|
"type": "git",
|
|
43
33
|
"url": "https://github.com/prisma/prisma-next.git",
|
|
44
34
|
"directory": "packages/2-mongo-family/2-authoring/contract-ts"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsdown",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:coverage": "vitest run --coverage",
|
|
40
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
41
|
+
"lint": "biome check . --error-on-warnings",
|
|
42
|
+
"lint:fix": "biome check --write .",
|
|
43
|
+
"lint:fix:unsafe": "biome check --write --unsafe .",
|
|
44
|
+
"clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|