@prisma/orm-family-mongo 0.16.0-dev.36
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/README.md +27 -0
- package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs +176 -0
- package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs.map +1 -0
- package/dist/canonicalization-hooks-DF3Z6sjO.mjs +22 -0
- package/dist/canonicalization-hooks-DF3Z6sjO.mjs.map +1 -0
- package/dist/codec.d.mts +2 -0
- package/dist/codec.mjs +2 -0
- package/dist/config-types-CFDf9ivE.mjs +37 -0
- package/dist/config-types-CFDf9ivE.mjs.map +1 -0
- package/dist/config-types-CQOf5N7R.d.mts +12 -0
- package/dist/config-types-CQOf5N7R.d.mts.map +1 -0
- package/dist/contract-builder-BFq0gOMV.mjs +634 -0
- package/dist/contract-builder-BFq0gOMV.mjs.map +1 -0
- package/dist/contract-builder-DB8nguDE.d.mts +445 -0
- package/dist/contract-builder-DB8nguDE.d.mts.map +1 -0
- package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs +9 -0
- package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs.map +1 -0
- package/dist/contract-psl.d.mts +45 -0
- package/dist/contract-psl.d.mts.map +1 -0
- package/dist/contract-psl.mjs +2 -0
- package/dist/contract-psl__provider.d.mts +15 -0
- package/dist/contract-psl__provider.d.mts.map +1 -0
- package/dist/contract-psl__provider.mjs +82 -0
- package/dist/contract-psl__provider.mjs.map +1 -0
- package/dist/contract-ts.d.mts +3 -0
- package/dist/contract-ts.mjs +3 -0
- package/dist/contract-ts__config-types.d.mts +2 -0
- package/dist/contract-ts__config-types.mjs +2 -0
- package/dist/contract-ts__contract-builder.d.mts +2 -0
- package/dist/contract-ts__contract-builder.mjs +2 -0
- package/dist/contract.d.mts +3 -0
- package/dist/contract.mjs +3 -0
- package/dist/contract__canonicalization-hooks.d.mts +9 -0
- package/dist/contract__canonicalization-hooks.d.mts.map +1 -0
- package/dist/contract__canonicalization-hooks.mjs +2 -0
- package/dist/contract__entity-kinds.d.mts +17 -0
- package/dist/contract__entity-kinds.d.mts.map +1 -0
- package/dist/contract__entity-kinds.mjs +2 -0
- package/dist/control-C7-kthr1.d.mts +193 -0
- package/dist/control-C7-kthr1.d.mts.map +1 -0
- package/dist/control-CClR5JMr.mjs +127 -0
- package/dist/control-CClR5JMr.mjs.map +1 -0
- package/dist/control-CFr3tYsg.mjs +398 -0
- package/dist/control-CFr3tYsg.mjs.map +1 -0
- package/dist/control-Cj81sPbj.d.mts +101 -0
- package/dist/control-Cj81sPbj.d.mts.map +1 -0
- package/dist/control-adapter-Db5pT77b.d.mts +83 -0
- package/dist/control-adapter-Db5pT77b.d.mts.map +1 -0
- package/dist/dist-C7Ykq48Q.mjs +19 -0
- package/dist/dist-C7Ykq48Q.mjs.map +1 -0
- package/dist/dist-Czwqx_i3.mjs +58 -0
- package/dist/dist-Czwqx_i3.mjs.map +1 -0
- package/dist/dist-DHrEJnhK.mjs +236 -0
- package/dist/dist-DHrEJnhK.mjs.map +1 -0
- package/dist/dist-Dyp05u64.mjs +1546 -0
- package/dist/dist-Dyp05u64.mjs.map +1 -0
- package/dist/emitter.d.mts +22 -0
- package/dist/emitter.d.mts.map +1 -0
- package/dist/emitter.mjs +2 -0
- package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs +603 -0
- package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs.map +1 -0
- package/dist/execution-CKnUiOfm.d.mts +48 -0
- package/dist/execution-CKnUiOfm.d.mts.map +1 -0
- package/dist/execution-D5XyZ5XS.mjs +1269 -0
- package/dist/execution-D5XyZ5XS.mjs.map +1 -0
- package/dist/exports-Bx-hlnZ3.mjs +209 -0
- package/dist/exports-Bx-hlnZ3.mjs.map +1 -0
- package/dist/exports-CJMh0VTU.mjs +156 -0
- package/dist/exports-CJMh0VTU.mjs.map +1 -0
- package/dist/family.d.mts +10 -0
- package/dist/family.mjs +9 -0
- package/dist/family__control-adapter.d.mts +2 -0
- package/dist/family__control-adapter.mjs +1 -0
- package/dist/family__control.d.mts +2 -0
- package/dist/family__control.mjs +3 -0
- package/dist/family__ir.d.mts +3 -0
- package/dist/family__ir.mjs +4 -0
- package/dist/family__migration.d.mts +2 -0
- package/dist/family__migration.mjs +2 -0
- package/dist/family__pack.d.mts +2 -0
- package/dist/family__pack.mjs +16 -0
- package/dist/family__pack.mjs.map +1 -0
- package/dist/family__runtime.d.mts +3 -0
- package/dist/family__runtime.mjs +2 -0
- package/dist/family__schema-verify.d.mts +2 -0
- package/dist/family__schema-verify.mjs +2 -0
- package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs +234 -0
- package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs.map +1 -0
- package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts +588 -0
- package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts.map +1 -0
- package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs +181 -0
- package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs.map +1 -0
- package/dist/index-BR0ue13b.d.mts +136 -0
- package/dist/index-BR0ue13b.d.mts.map +1 -0
- package/dist/index-Cd2zLiU6.d.mts +128 -0
- package/dist/index-Cd2zLiU6.d.mts.map +1 -0
- package/dist/index-DAOkcTCK.d.mts +151 -0
- package/dist/index-DAOkcTCK.d.mts.map +1 -0
- package/dist/index-Dv2PNMiG.d.mts +53 -0
- package/dist/index-Dv2PNMiG.d.mts.map +1 -0
- package/dist/index-DxoO-ywI.d.mts +178 -0
- package/dist/index-DxoO-ywI.d.mts.map +1 -0
- package/dist/index-wKMm41HC.d.mts +30 -0
- package/dist/index-wKMm41HC.d.mts.map +1 -0
- package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs +1091 -0
- package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs.map +1 -0
- package/dist/ir-CQrenTYt.d.mts +147 -0
- package/dist/ir-CQrenTYt.d.mts.map +1 -0
- package/dist/ir-Ch2aPr7a.mjs +62 -0
- package/dist/ir-Ch2aPr7a.mjs.map +1 -0
- package/dist/lowering.d.mts +2 -0
- package/dist/lowering.mjs +1 -0
- package/dist/migration-CNDQv5yB.d.mts +50 -0
- package/dist/migration-CNDQv5yB.d.mts.map +1 -0
- package/dist/migration-dcM7u4HG.mjs +52 -0
- package/dist/migration-dcM7u4HG.mjs.map +1 -0
- package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs +119 -0
- package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs.map +1 -0
- package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts +27 -0
- package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts.map +1 -0
- package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs +17 -0
- package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs.map +1 -0
- package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts +536 -0
- package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts.map +1 -0
- package/dist/mongodb-types-B4HmhF1S.d.mts +2 -0
- package/dist/orm.d.mts +311 -0
- package/dist/orm.d.mts.map +1 -0
- package/dist/orm.mjs +664 -0
- package/dist/orm.mjs.map +1 -0
- package/dist/pack-D9aLY50F.d.mts +44 -0
- package/dist/pack-D9aLY50F.d.mts.map +1 -0
- package/dist/query-ast.d.mts +5 -0
- package/dist/query-ast.mjs +4 -0
- package/dist/query-ast__control.d.mts +4 -0
- package/dist/query-ast__control.mjs +3 -0
- package/dist/query-ast__execution.d.mts +3 -0
- package/dist/query-ast__execution.mjs +3 -0
- package/dist/query-builder.d.mts +836 -0
- package/dist/query-builder.d.mts.map +1 -0
- package/dist/query-builder.mjs +3 -0
- package/dist/query-builder__contract-free.d.mts +83 -0
- package/dist/query-builder__contract-free.d.mts.map +1 -0
- package/dist/query-builder__contract-free.mjs +107 -0
- package/dist/query-builder__contract-free.mjs.map +1 -0
- package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts +822 -0
- package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts.map +1 -0
- package/dist/runtime-DPkRW4iu.d.mts +1 -0
- package/dist/runtime.d.mts +286 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +532 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-ir.d.mts +2 -0
- package/dist/schema-ir.mjs +2 -0
- package/dist/schema-verify-DJGr28XW.d.mts +23 -0
- package/dist/schema-verify-DJGr28XW.d.mts.map +1 -0
- package/dist/value.d.mts +2 -0
- package/dist/value.mjs +2 -0
- package/dist/value__mongodb-types.d.mts +2 -0
- package/dist/value__mongodb-types.mjs +1 -0
- package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs +447 -0
- package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs.map +1 -0
- package/dist/wire.d.mts +3 -0
- package/dist/wire.mjs +190 -0
- package/dist/wire.mjs.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { n as MongoContractSerializerBase, t as MongoContractSerializer } from "./mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs";
|
|
2
|
+
import { t as MongoContractView$1 } from "./mongo-contract-view-rcWzby6f-wRBCUnBt.mjs";
|
|
3
|
+
import { t as MongoSchemaVerifierBase } from "./ir-Ch2aPr7a.mjs";
|
|
4
|
+
export { MongoContractSerializer, MongoContractSerializerBase, MongoContractView$1 as MongoContractView, MongoSchemaVerifierBase };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from "./authoring-entity-types-BGtkMyoN-D32kzx28.mjs";
|
|
2
|
+
//#region ../../../2-mongo-family/9-family/dist/pack.mjs
|
|
3
|
+
const mongoFamilyPack = {
|
|
4
|
+
kind: "family",
|
|
5
|
+
id: "mongo",
|
|
6
|
+
familyId: "mongo",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
authoring: {
|
|
9
|
+
entityTypes: mongoFamilyEntityTypes,
|
|
10
|
+
pslBlockDescriptors: mongoFamilyPslBlockDescriptors
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { mongoFamilyPack as default, mongoFamilyEntityTypes, mongoFamilyPslBlockDescriptors };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=family__pack.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"family__pack.mjs","names":[],"sources":["../../../../2-mongo-family/9-family/dist/pack.mjs"],"sourcesContent":["import { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from \"./authoring-entity-types-BGtkMyoN.mjs\";\n//#region src/exports/pack.ts\nconst mongoFamilyPack = {\n\tkind: \"family\",\n\tid: \"mongo\",\n\tfamilyId: \"mongo\",\n\tversion: \"0.0.1\",\n\tauthoring: {\n\t\tentityTypes: mongoFamilyEntityTypes,\n\t\tpslBlockDescriptors: mongoFamilyPslBlockDescriptors\n\t}\n};\n//#endregion\nexport { mongoFamilyPack as default, mongoFamilyEntityTypes, mongoFamilyPslBlockDescriptors };\n\n//# sourceMappingURL=pack.mjs.map"],"mappings":";;AAEA,MAAM,kBAAkB;CACvB,MAAM;CACN,IAAI;CACJ,UAAU;CACV,SAAS;CACT,WAAW;EACV,aAAa;EACb,qBAAqB;CACtB;AACD"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { a as MongoFieldFilter, i as MongoExprFilter, r as MongoExistsExpr } from "./filter-expressions-Uo8ZdzwB-53qnqceS.mjs";
|
|
2
|
+
import { I as MongoReplaceRootStage, P as MongoProjectStage, c as MongoAddFieldsStage, f as MongoAggFieldRef } from "./execution-D5XyZ5XS.mjs";
|
|
3
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
4
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
5
|
+
//#region ../../../2-mongo-family/5-query-builders/query-builder/dist/field-accessor-0oUt6RZC.mjs
|
|
6
|
+
function ormError(code, message, options) {
|
|
7
|
+
return structuredError(code, message, options);
|
|
8
|
+
}
|
|
9
|
+
const setOp = (path, value) => ({
|
|
10
|
+
op: "$set",
|
|
11
|
+
path,
|
|
12
|
+
value
|
|
13
|
+
});
|
|
14
|
+
const unsetOp = (path) => ({
|
|
15
|
+
op: "$unset",
|
|
16
|
+
path
|
|
17
|
+
});
|
|
18
|
+
const renameOp = (path, newName) => ({
|
|
19
|
+
op: "$rename",
|
|
20
|
+
path,
|
|
21
|
+
newName
|
|
22
|
+
});
|
|
23
|
+
const incOp = (path, amount) => ({
|
|
24
|
+
op: "$inc",
|
|
25
|
+
path,
|
|
26
|
+
amount
|
|
27
|
+
});
|
|
28
|
+
const mulOp = (path, factor) => ({
|
|
29
|
+
op: "$mul",
|
|
30
|
+
path,
|
|
31
|
+
factor
|
|
32
|
+
});
|
|
33
|
+
const minOp = (path, value) => ({
|
|
34
|
+
op: "$min",
|
|
35
|
+
path,
|
|
36
|
+
value
|
|
37
|
+
});
|
|
38
|
+
const maxOp = (path, value) => ({
|
|
39
|
+
op: "$max",
|
|
40
|
+
path,
|
|
41
|
+
value
|
|
42
|
+
});
|
|
43
|
+
const pushOp = (path, value) => ({
|
|
44
|
+
op: "$push",
|
|
45
|
+
path,
|
|
46
|
+
value
|
|
47
|
+
});
|
|
48
|
+
const addToSetOp = (path, value) => ({
|
|
49
|
+
op: "$addToSet",
|
|
50
|
+
path,
|
|
51
|
+
value
|
|
52
|
+
});
|
|
53
|
+
const popOp = (path, direction) => ({
|
|
54
|
+
op: "$pop",
|
|
55
|
+
path,
|
|
56
|
+
direction
|
|
57
|
+
});
|
|
58
|
+
const pullOp = (path, value) => ({
|
|
59
|
+
op: "$pull",
|
|
60
|
+
path,
|
|
61
|
+
value
|
|
62
|
+
});
|
|
63
|
+
const pullAllOp = (path, values) => ({
|
|
64
|
+
op: "$pullAll",
|
|
65
|
+
path,
|
|
66
|
+
values
|
|
67
|
+
});
|
|
68
|
+
const currentDateOp = (path) => ({
|
|
69
|
+
op: "$currentDate",
|
|
70
|
+
path
|
|
71
|
+
});
|
|
72
|
+
const setOnInsertOp = (path, value) => ({
|
|
73
|
+
op: "$setOnInsert",
|
|
74
|
+
path,
|
|
75
|
+
value
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Fold an array of `TypedUpdateOp` into the non-pipeline variant of
|
|
79
|
+
* `MongoUpdateSpec` (`{ $set: { … }, $inc: { … }, … }`).
|
|
80
|
+
*
|
|
81
|
+
* Throws if the same operator targets the same path twice — a clear authoring
|
|
82
|
+
* error that Mongo would otherwise silently coalesce.
|
|
83
|
+
*/
|
|
84
|
+
function foldUpdateOps(ops) {
|
|
85
|
+
const buckets = {};
|
|
86
|
+
const seen = /* @__PURE__ */ new Set();
|
|
87
|
+
const ensure = (key) => {
|
|
88
|
+
let bucket = buckets[key];
|
|
89
|
+
if (!bucket) {
|
|
90
|
+
bucket = {};
|
|
91
|
+
buckets[key] = bucket;
|
|
92
|
+
}
|
|
93
|
+
return bucket;
|
|
94
|
+
};
|
|
95
|
+
const claim = (op, path) => {
|
|
96
|
+
const k = `${op}::${path}`;
|
|
97
|
+
if (seen.has(k)) throw ormError("ORM.ARGUMENT_INVALID", `Update spec collision: ${op} on '${path}' was specified more than once. Combine the operations into a single call site.`);
|
|
98
|
+
seen.add(k);
|
|
99
|
+
};
|
|
100
|
+
for (const entry of ops) {
|
|
101
|
+
claim(entry.op, entry.path);
|
|
102
|
+
switch (entry.op) {
|
|
103
|
+
case "$set":
|
|
104
|
+
case "$min":
|
|
105
|
+
case "$max":
|
|
106
|
+
case "$push":
|
|
107
|
+
case "$addToSet":
|
|
108
|
+
case "$pull":
|
|
109
|
+
case "$setOnInsert":
|
|
110
|
+
ensure(entry.op)[entry.path] = entry.value;
|
|
111
|
+
break;
|
|
112
|
+
case "$unset":
|
|
113
|
+
ensure("$unset")[entry.path] = "";
|
|
114
|
+
break;
|
|
115
|
+
case "$rename":
|
|
116
|
+
ensure("$rename")[entry.path] = entry.newName;
|
|
117
|
+
break;
|
|
118
|
+
case "$inc":
|
|
119
|
+
ensure("$inc")[entry.path] = entry.amount;
|
|
120
|
+
break;
|
|
121
|
+
case "$mul":
|
|
122
|
+
ensure("$mul")[entry.path] = entry.factor;
|
|
123
|
+
break;
|
|
124
|
+
case "$pop":
|
|
125
|
+
ensure("$pop")[entry.path] = entry.direction;
|
|
126
|
+
break;
|
|
127
|
+
case "$pullAll":
|
|
128
|
+
ensure("$pullAll")[entry.path] = entry.values;
|
|
129
|
+
break;
|
|
130
|
+
case "$currentDate":
|
|
131
|
+
ensure("$currentDate")[entry.path] = true;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return buckets;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Classify an array of updater items and produce a `MongoUpdateSpec`.
|
|
139
|
+
*
|
|
140
|
+
* - All `TypedUpdateOp` → fold via `foldUpdateOps` (classic `{ $set, $inc, … }`)
|
|
141
|
+
* - All `MongoUpdatePipelineStage` → return as-is (pipeline-style update)
|
|
142
|
+
* - Mixed → throw (also a type error at the call site via the union shape)
|
|
143
|
+
*/
|
|
144
|
+
function resolveUpdaterResult(items) {
|
|
145
|
+
if (items.length === 0) throw ormError("ORM.MUTATION_DATA_MISSING", "Updater returned no operations. Return at least one update from the callback (e.g. `[f.amount.set(0)]`).");
|
|
146
|
+
const isOp = (item) => "op" in item && typeof item.op === "string";
|
|
147
|
+
const first = items[0];
|
|
148
|
+
if (first === void 0) throw new InternalError("Unreachable: items.length > 0 but first is undefined");
|
|
149
|
+
const firstIsOp = isOp(first);
|
|
150
|
+
for (let i = 1; i < items.length; i++) {
|
|
151
|
+
const item = items[i];
|
|
152
|
+
if (item === void 0) continue;
|
|
153
|
+
if (isOp(item) !== firstIsOp) throw ormError("ORM.ARGUMENT_INVALID", "Cannot mix TypedUpdateOp values and pipeline stages in a single updater. Use either `[f.amount.set(0)]` (operator form) or `[f.stage.set({...})]` (pipeline form), not both.");
|
|
154
|
+
}
|
|
155
|
+
if (firstIsOp) return foldUpdateOps(items);
|
|
156
|
+
return items;
|
|
157
|
+
}
|
|
158
|
+
function buildStageEmitters() {
|
|
159
|
+
return {
|
|
160
|
+
set: (fields) => new MongoAddFieldsStage(fields),
|
|
161
|
+
unset: (...paths) => {
|
|
162
|
+
const spec = {};
|
|
163
|
+
for (const p of paths) spec[p] = 0;
|
|
164
|
+
return new MongoProjectStage(spec);
|
|
165
|
+
},
|
|
166
|
+
replaceRoot: (newRoot) => new MongoReplaceRootStage(newRoot),
|
|
167
|
+
replaceWith: (newRoot) => new MongoReplaceRootStage(newRoot)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Wrap a boolean aggregation expression as an `$expr` filter
|
|
172
|
+
* (`MongoExprFilter`). Lets a `$match` express an aggregation-expression
|
|
173
|
+
* predicate — e.g. comparing two field references via `fn.eq(a, b)` — in
|
|
174
|
+
* the typed AST rather than via a raw escape hatch. Pairs with `.type()`
|
|
175
|
+
* to express filters like `{ _id: { $type: 'string' }, $expr: { $eq: ['$_id', '$space'] } }`.
|
|
176
|
+
*/
|
|
177
|
+
function expr(predicate) {
|
|
178
|
+
return MongoExprFilter.of(predicate.node);
|
|
179
|
+
}
|
|
180
|
+
function buildExpression(path) {
|
|
181
|
+
return {
|
|
182
|
+
_field: void 0,
|
|
183
|
+
_path: path,
|
|
184
|
+
node: MongoAggFieldRef.of(path),
|
|
185
|
+
eq: (value) => MongoFieldFilter.eq(path, value),
|
|
186
|
+
ne: (value) => MongoFieldFilter.neq(path, value),
|
|
187
|
+
gt: (value) => MongoFieldFilter.gt(path, value),
|
|
188
|
+
gte: (value) => MongoFieldFilter.gte(path, value),
|
|
189
|
+
lt: (value) => MongoFieldFilter.lt(path, value),
|
|
190
|
+
lte: (value) => MongoFieldFilter.lte(path, value),
|
|
191
|
+
in: (values) => MongoFieldFilter.in(path, values),
|
|
192
|
+
nin: (values) => MongoFieldFilter.nin(path, values),
|
|
193
|
+
exists: (flag) => flag === false ? MongoExistsExpr.notExists(path) : MongoExistsExpr.exists(path),
|
|
194
|
+
type: (bsonType) => MongoFieldFilter.of(path, "$type", bsonType),
|
|
195
|
+
set: (value) => setOp(path, value),
|
|
196
|
+
unset: () => unsetOp(path),
|
|
197
|
+
rename: (newName) => renameOp(path, newName),
|
|
198
|
+
inc: (amount) => incOp(path, amount),
|
|
199
|
+
mul: (factor) => mulOp(path, factor),
|
|
200
|
+
min: (value) => minOp(path, value),
|
|
201
|
+
max: (value) => maxOp(path, value),
|
|
202
|
+
push: (value) => pushOp(path, value),
|
|
203
|
+
addToSet: (value) => addToSetOp(path, value),
|
|
204
|
+
pop: (direction = 1) => popOp(path, direction),
|
|
205
|
+
pull: (value) => pullOp(path, value),
|
|
206
|
+
pullAll: (values) => pullAllOp(path, values),
|
|
207
|
+
currentDate: () => currentDateOp(path),
|
|
208
|
+
setOnInsert: (value) => setOnInsertOp(path, value)
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Construct a unified `FieldAccessor<S, N>` proxy. Property access creates
|
|
213
|
+
* an `Expression` using the property name as the field path; callable
|
|
214
|
+
* form accepts a dot-path string validated against `N` at compile time.
|
|
215
|
+
*
|
|
216
|
+
* The proxy target is a function so the resulting object is both callable
|
|
217
|
+
* and indexable. Symbol-keyed accesses (e.g. `Symbol.toPrimitive`) return
|
|
218
|
+
* `undefined` to keep accidental coercion behaviour unsurprising —
|
|
219
|
+
* matching the previous `FieldProxy` / `FilterProxy` semantics.
|
|
220
|
+
*/
|
|
221
|
+
function createFieldAccessor() {
|
|
222
|
+
const stageInstance = buildStageEmitters();
|
|
223
|
+
const callable = ((path) => buildExpression(path));
|
|
224
|
+
return new Proxy(callable, { get(target, prop, receiver) {
|
|
225
|
+
if (typeof prop === "symbol") return Reflect.get(target, prop, receiver);
|
|
226
|
+
if (prop === "stage") return stageInstance;
|
|
227
|
+
if (prop === "rawPath") return (path) => buildExpression(path);
|
|
228
|
+
return buildExpression(prop);
|
|
229
|
+
} });
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { resolveUpdaterResult as i, expr as n, ormError as r, createFieldAccessor as t };
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=field-accessor-0oUt6RZC-B_Z30uAA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-accessor-0oUt6RZC-B_Z30uAA.mjs","names":[],"sources":["../../../../2-mongo-family/5-query-builders/query-builder/dist/field-accessor-0oUt6RZC.mjs"],"sourcesContent":["import { MongoAddFieldsStage, MongoAggFieldRef, MongoExistsExpr, MongoExprFilter, MongoFieldFilter, MongoProjectStage, MongoReplaceRootStage } from \"@internal/mongo-query-ast/execution\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/orm-errors.ts\nfunction ormError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/update-ops.ts\nconst setOp = (path, value) => ({\n\top: \"$set\",\n\tpath,\n\tvalue\n});\nconst unsetOp = (path) => ({\n\top: \"$unset\",\n\tpath\n});\nconst renameOp = (path, newName) => ({\n\top: \"$rename\",\n\tpath,\n\tnewName\n});\nconst incOp = (path, amount) => ({\n\top: \"$inc\",\n\tpath,\n\tamount\n});\nconst mulOp = (path, factor) => ({\n\top: \"$mul\",\n\tpath,\n\tfactor\n});\nconst minOp = (path, value) => ({\n\top: \"$min\",\n\tpath,\n\tvalue\n});\nconst maxOp = (path, value) => ({\n\top: \"$max\",\n\tpath,\n\tvalue\n});\nconst pushOp = (path, value) => ({\n\top: \"$push\",\n\tpath,\n\tvalue\n});\nconst addToSetOp = (path, value) => ({\n\top: \"$addToSet\",\n\tpath,\n\tvalue\n});\nconst popOp = (path, direction) => ({\n\top: \"$pop\",\n\tpath,\n\tdirection\n});\nconst pullOp = (path, value) => ({\n\top: \"$pull\",\n\tpath,\n\tvalue\n});\nconst pullAllOp = (path, values) => ({\n\top: \"$pullAll\",\n\tpath,\n\tvalues\n});\nconst currentDateOp = (path) => ({\n\top: \"$currentDate\",\n\tpath\n});\nconst setOnInsertOp = (path, value) => ({\n\top: \"$setOnInsert\",\n\tpath,\n\tvalue\n});\n/**\n* Fold an array of `TypedUpdateOp` into the non-pipeline variant of\n* `MongoUpdateSpec` (`{ $set: { … }, $inc: { … }, … }`).\n*\n* Throws if the same operator targets the same path twice — a clear authoring\n* error that Mongo would otherwise silently coalesce.\n*/\nfunction foldUpdateOps(ops) {\n\tconst buckets = {};\n\tconst seen = /* @__PURE__ */ new Set();\n\tconst ensure = (key) => {\n\t\tlet bucket = buckets[key];\n\t\tif (!bucket) {\n\t\t\tbucket = {};\n\t\t\tbuckets[key] = bucket;\n\t\t}\n\t\treturn bucket;\n\t};\n\tconst claim = (op, path) => {\n\t\tconst k = `${op}::${path}`;\n\t\tif (seen.has(k)) throw ormError(\"ORM.ARGUMENT_INVALID\", `Update spec collision: ${op} on '${path}' was specified more than once. Combine the operations into a single call site.`);\n\t\tseen.add(k);\n\t};\n\tfor (const entry of ops) {\n\t\tclaim(entry.op, entry.path);\n\t\tswitch (entry.op) {\n\t\t\tcase \"$set\":\n\t\t\tcase \"$min\":\n\t\t\tcase \"$max\":\n\t\t\tcase \"$push\":\n\t\t\tcase \"$addToSet\":\n\t\t\tcase \"$pull\":\n\t\t\tcase \"$setOnInsert\":\n\t\t\t\tensure(entry.op)[entry.path] = entry.value;\n\t\t\t\tbreak;\n\t\t\tcase \"$unset\":\n\t\t\t\tensure(\"$unset\")[entry.path] = \"\";\n\t\t\t\tbreak;\n\t\t\tcase \"$rename\":\n\t\t\t\tensure(\"$rename\")[entry.path] = entry.newName;\n\t\t\t\tbreak;\n\t\t\tcase \"$inc\":\n\t\t\t\tensure(\"$inc\")[entry.path] = entry.amount;\n\t\t\t\tbreak;\n\t\t\tcase \"$mul\":\n\t\t\t\tensure(\"$mul\")[entry.path] = entry.factor;\n\t\t\t\tbreak;\n\t\t\tcase \"$pop\":\n\t\t\t\tensure(\"$pop\")[entry.path] = entry.direction;\n\t\t\t\tbreak;\n\t\t\tcase \"$pullAll\":\n\t\t\t\tensure(\"$pullAll\")[entry.path] = entry.values;\n\t\t\t\tbreak;\n\t\t\tcase \"$currentDate\":\n\t\t\t\tensure(\"$currentDate\")[entry.path] = true;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn buckets;\n}\n/**\n* Classify an array of updater items and produce a `MongoUpdateSpec`.\n*\n* - All `TypedUpdateOp` → fold via `foldUpdateOps` (classic `{ $set, $inc, … }`)\n* - All `MongoUpdatePipelineStage` → return as-is (pipeline-style update)\n* - Mixed → throw (also a type error at the call site via the union shape)\n*/\nfunction resolveUpdaterResult(items) {\n\tif (items.length === 0) throw ormError(\"ORM.MUTATION_DATA_MISSING\", \"Updater returned no operations. Return at least one update from the callback (e.g. `[f.amount.set(0)]`).\");\n\tconst isOp = (item) => \"op\" in item && typeof item.op === \"string\";\n\tconst first = items[0];\n\tif (first === void 0) throw new InternalError(\"Unreachable: items.length > 0 but first is undefined\");\n\tconst firstIsOp = isOp(first);\n\tfor (let i = 1; i < items.length; i++) {\n\t\tconst item = items[i];\n\t\tif (item === void 0) continue;\n\t\tif (isOp(item) !== firstIsOp) throw ormError(\"ORM.ARGUMENT_INVALID\", \"Cannot mix TypedUpdateOp values and pipeline stages in a single updater. Use either `[f.amount.set(0)]` (operator form) or `[f.stage.set({...})]` (pipeline form), not both.\");\n\t}\n\tif (firstIsOp) return foldUpdateOps(items);\n\treturn items;\n}\n//#endregion\n//#region src/field-accessor.ts\nfunction buildStageEmitters() {\n\treturn {\n\t\tset: (fields) => new MongoAddFieldsStage(fields),\n\t\tunset: (...paths) => {\n\t\t\tconst spec = {};\n\t\t\tfor (const p of paths) spec[p] = 0;\n\t\t\treturn new MongoProjectStage(spec);\n\t\t},\n\t\treplaceRoot: (newRoot) => new MongoReplaceRootStage(newRoot),\n\t\treplaceWith: (newRoot) => new MongoReplaceRootStage(newRoot)\n\t};\n}\n/**\n* Wrap a boolean aggregation expression as an `$expr` filter\n* (`MongoExprFilter`). Lets a `$match` express an aggregation-expression\n* predicate — e.g. comparing two field references via `fn.eq(a, b)` — in\n* the typed AST rather than via a raw escape hatch. Pairs with `.type()`\n* to express filters like `{ _id: { $type: 'string' }, $expr: { $eq: ['$_id', '$space'] } }`.\n*/\nfunction expr(predicate) {\n\treturn MongoExprFilter.of(predicate.node);\n}\nfunction buildExpression(path) {\n\treturn {\n\t\t_field: void 0,\n\t\t_path: path,\n\t\tnode: MongoAggFieldRef.of(path),\n\t\teq: (value) => MongoFieldFilter.eq(path, value),\n\t\tne: (value) => MongoFieldFilter.neq(path, value),\n\t\tgt: (value) => MongoFieldFilter.gt(path, value),\n\t\tgte: (value) => MongoFieldFilter.gte(path, value),\n\t\tlt: (value) => MongoFieldFilter.lt(path, value),\n\t\tlte: (value) => MongoFieldFilter.lte(path, value),\n\t\tin: (values) => MongoFieldFilter.in(path, values),\n\t\tnin: (values) => MongoFieldFilter.nin(path, values),\n\t\texists: (flag) => flag === false ? MongoExistsExpr.notExists(path) : MongoExistsExpr.exists(path),\n\t\ttype: (bsonType) => MongoFieldFilter.of(path, \"$type\", bsonType),\n\t\tset: (value) => setOp(path, value),\n\t\tunset: () => unsetOp(path),\n\t\trename: (newName) => renameOp(path, newName),\n\t\tinc: (amount) => incOp(path, amount),\n\t\tmul: (factor) => mulOp(path, factor),\n\t\tmin: (value) => minOp(path, value),\n\t\tmax: (value) => maxOp(path, value),\n\t\tpush: (value) => pushOp(path, value),\n\t\taddToSet: (value) => addToSetOp(path, value),\n\t\tpop: (direction = 1) => popOp(path, direction),\n\t\tpull: (value) => pullOp(path, value),\n\t\tpullAll: (values) => pullAllOp(path, values),\n\t\tcurrentDate: () => currentDateOp(path),\n\t\tsetOnInsert: (value) => setOnInsertOp(path, value)\n\t};\n}\n/**\n* Construct a unified `FieldAccessor<S, N>` proxy. Property access creates\n* an `Expression` using the property name as the field path; callable\n* form accepts a dot-path string validated against `N` at compile time.\n*\n* The proxy target is a function so the resulting object is both callable\n* and indexable. Symbol-keyed accesses (e.g. `Symbol.toPrimitive`) return\n* `undefined` to keep accidental coercion behaviour unsurprising —\n* matching the previous `FieldProxy` / `FilterProxy` semantics.\n*/\nfunction createFieldAccessor() {\n\tconst stageInstance = buildStageEmitters();\n\tconst callable = ((path) => buildExpression(path));\n\treturn new Proxy(callable, { get(target, prop, receiver) {\n\t\tif (typeof prop === \"symbol\") return Reflect.get(target, prop, receiver);\n\t\tif (prop === \"stage\") return stageInstance;\n\t\tif (prop === \"rawPath\") return (path) => buildExpression(path);\n\t\treturn buildExpression(prop);\n\t} });\n}\n//#endregion\nexport { ormError as i, expr as n, resolveUpdaterResult as r, createFieldAccessor as t };\n\n//# sourceMappingURL=field-accessor-0oUt6RZC.mjs.map"],"mappings":";;;;;AAIA,SAAS,SAAS,MAAM,SAAS,SAAS;CACzC,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,MAAM,SAAS,MAAM,WAAW;CAC/B,IAAI;CACJ;CACA;AACD;AACA,MAAM,WAAW,UAAU;CAC1B,IAAI;CACJ;AACD;AACA,MAAM,YAAY,MAAM,aAAa;CACpC,IAAI;CACJ;CACA;AACD;AACA,MAAM,SAAS,MAAM,YAAY;CAChC,IAAI;CACJ;CACA;AACD;AACA,MAAM,SAAS,MAAM,YAAY;CAChC,IAAI;CACJ;CACA;AACD;AACA,MAAM,SAAS,MAAM,WAAW;CAC/B,IAAI;CACJ;CACA;AACD;AACA,MAAM,SAAS,MAAM,WAAW;CAC/B,IAAI;CACJ;CACA;AACD;AACA,MAAM,UAAU,MAAM,WAAW;CAChC,IAAI;CACJ;CACA;AACD;AACA,MAAM,cAAc,MAAM,W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