@prisma/orm-target-mongo 8.0.0-rc.18-dev.28 → 8.0.0-rc.18-dev.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.mjs +1 -1
- package/dist/adapter__control.mjs +1 -1
- package/dist/adapter__runtime.mjs +2 -2
- package/dist/{codecs-9hW1zPTj-UIJ0Z1th.mjs → codecs-BVrMDhha-DBl_TLS8.mjs} +3 -3
- package/dist/{codecs-9hW1zPTj-UIJ0Z1th.mjs.map → codecs-BVrMDhha-DBl_TLS8.mjs.map} +1 -1
- package/dist/{control-CDY-DZw5.mjs → control-8KJTXiJ_.mjs} +204 -88
- package/dist/control-8KJTXiJ_.mjs.map +1 -0
- package/dist/{control-rl8nrKoA.d.mts → control-DPT2hXVf.d.mts} +5 -1
- package/dist/control-DPT2hXVf.d.mts.map +1 -0
- package/dist/{data-types-CfdzqGSQ-NIDeT9x3.mjs → data-types-vptiHFHC-LUJwNRIq.mjs} +3 -3
- package/dist/{data-types-CfdzqGSQ-NIDeT9x3.mjs.map → data-types-vptiHFHC-LUJwNRIq.mjs.map} +1 -1
- package/dist/{descriptor-meta-BcqjYuQn-BguYOxpH.mjs → descriptor-meta-CYXIYjq7-DpMc5Tnm.mjs} +3 -3
- package/dist/{descriptor-meta-BcqjYuQn-BguYOxpH.mjs.map → descriptor-meta-CYXIYjq7-DpMc5Tnm.mjs.map} +1 -1
- package/dist/{descriptor-meta-runtime-BtNLF4vW-Dbt6W7RT.mjs → descriptor-meta-runtime-D0YxXi85-CjeTEg7T.mjs} +4 -4
- package/dist/{descriptor-meta-runtime-BtNLF4vW-Dbt6W7RT.mjs.map → descriptor-meta-runtime-D0YxXi85-CjeTEg7T.mjs.map} +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/driver__control.mjs +1 -1
- package/dist/driver__control.mjs.map +1 -1
- package/dist/{mongo-adapter-Bo6ciURK-DRuYz-F7.mjs → mongo-adapter-Bo6ciURK-Cy0xnkRa.mjs} +2 -2
- package/dist/{mongo-adapter-Bo6ciURK-DRuYz-F7.mjs.map → mongo-adapter-Bo6ciURK-Cy0xnkRa.mjs.map} +1 -1
- package/dist/{mongo-driver-Bim0d3Y1-DmdzEYr_.mjs → mongo-driver-Bqompjve-D7hiX2sT.mjs} +3 -3
- package/dist/{mongo-driver-Bim0d3Y1-DmdzEYr_.mjs.map → mongo-driver-Bqompjve-D7hiX2sT.mjs.map} +1 -1
- package/dist/{prisma6-binding-ZruukPaf.mjs → prisma6-binding-DUUKAo0Q.mjs} +2 -2
- package/dist/{prisma6-binding-ZruukPaf.mjs.map → prisma6-binding-DUUKAo0Q.mjs.map} +1 -1
- package/dist/target.d.mts +1 -1
- package/dist/target.mjs +4 -4
- package/dist/target__codecs.mjs +1 -1
- package/dist/target__control.d.mts +1 -1
- package/dist/target__control.mjs +1 -1
- package/dist/target__data-types.mjs +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__pack.mjs.map +1 -1
- package/dist/target__prisma6-binding.mjs +1 -1
- package/dist/target__runtime.mjs +1 -1
- package/dist/target__runtime.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/control-CDY-DZw5.mjs.map +0 -1
- package/dist/control-rl8nrKoA.d.mts.map +0 -1
package/dist/adapter.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { p as MONGO_VECTOR_CODEC_ID } from "./codec-ids-WdrumsYA-BkQfspmL.mjs";
|
|
2
|
-
import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-
|
|
2
|
+
import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-Cy0xnkRa.mjs";
|
|
3
3
|
//#region ../../../3-mongo-target/2-mongo-adapter/dist/index.mjs
|
|
4
4
|
const mongoVectorNearOperation = Object.freeze({
|
|
5
5
|
self: { codecId: MONGO_VECTOR_CODEC_ID },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as MONGO_DECIMAL128_CODEC_ID, c as MONGO_INT64_CODEC_ID, d as MONGO_OBJECTID_CODEC_ID, f as MONGO_STRING_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_INT64_NUMBER_CODEC_ID, n as MONGO_BOOLEAN_CODEC_ID, o as MONGO_DOUBLE_CODEC_ID, r as MONGO_BSON_CODEC_ID, s as MONGO_INT32_CODEC_ID, t as MONGO_BINARY_CODEC_ID, u as MONGO_JSON_CODEC_ID } from "./codec-ids-WdrumsYA-BkQfspmL.mjs";
|
|
2
|
-
import { t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-
|
|
2
|
+
import { t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-Cy0xnkRa.mjs";
|
|
3
3
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
4
4
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
5
5
|
import { type } from "arktype";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as buildStandardCodecRegistry } from "./codecs-
|
|
2
|
-
import { t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-
|
|
1
|
+
import { t as buildStandardCodecRegistry } from "./codecs-BVrMDhha-DBl_TLS8.mjs";
|
|
2
|
+
import { t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-Cy0xnkRa.mjs";
|
|
3
3
|
import { timestampNowRuntimeGenerator } from "@prisma/orm-family-mongo/family/runtime";
|
|
4
4
|
//#region ../../../3-mongo-target/2-mongo-adapter/dist/runtime.mjs
|
|
5
5
|
const mongoRuntimeAdapterDescriptor = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { a as MONGO_DECIMAL128_CODEC_ID, c as MONGO_INT64_CODEC_ID, d as MONGO_OBJECTID_CODEC_ID, f as MONGO_STRING_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_INT64_NUMBER_CODEC_ID, n as MONGO_BOOLEAN_CODEC_ID, o as MONGO_DOUBLE_CODEC_ID, p as MONGO_VECTOR_CODEC_ID, r as MONGO_BSON_CODEC_ID, s as MONGO_INT32_CODEC_ID, t as MONGO_BINARY_CODEC_ID, u as MONGO_JSON_CODEC_ID } from "./codec-ids-WdrumsYA-BkQfspmL.mjs";
|
|
2
2
|
import { t as mongoTargetError } from "./mongo-target-errors-Btf3ML1w-B5EMYbz1.mjs";
|
|
3
|
-
import { A as int64ToJson, B as mongoInt32, C as int32ToJson, D as int64NumberEncode, E as int64NumberDecode, F as mongoBson, G as mongoVector, H as mongoJson, J as objectIdToJson, L as mongoDate, M as isPlainObject, N as mongoBinary, O as int64NumberFromDigits, P as mongoBool, Q as where, R as mongoDecimal128, S as int32Encode, T as int64Encode, U as mongoObjectId, V as mongoInt64, W as mongoString, X as stringEncode, Y as readBsonJson, Z as vectorEncode, _ as decimalTextBigintLiteral, a as booleanEncode, b as doubleEncode, c as bsonTypeTag, d as dateEncode, f as dateToJson, g as decimal128ToJson, h as decimal128Encode, i as binaryToBase64, j as isPlainArray, k as int64NumberToJson, l as child, m as decimal128Decode, n as binaryEncode, o as bsonClassTag, p as dbRefEntries, q as objectIdEncode, r as binaryFromBase64, s as bsonToJson, t as binaryDecode, u as constructorName, v as decimalTextNumberLiteral, w as int64Decode, x as encodeBsonValue, y as decodeBsonValue, z as mongoDouble } from "./data-types-
|
|
3
|
+
import { A as int64ToJson, B as mongoInt32, C as int32ToJson, D as int64NumberEncode, E as int64NumberDecode, F as mongoBson, G as mongoVector, H as mongoJson, J as objectIdToJson, L as mongoDate, M as isPlainObject, N as mongoBinary, O as int64NumberFromDigits, P as mongoBool, Q as where, R as mongoDecimal128, S as int32Encode, T as int64Encode, U as mongoObjectId, V as mongoInt64, W as mongoString, X as stringEncode, Y as readBsonJson, Z as vectorEncode, _ as decimalTextBigintLiteral, a as booleanEncode, b as doubleEncode, c as bsonTypeTag, d as dateEncode, f as dateToJson, g as decimal128ToJson, h as decimal128Encode, i as binaryToBase64, j as isPlainArray, k as int64NumberToJson, l as child, m as decimal128Decode, n as binaryEncode, o as bsonClassTag, p as dbRefEntries, q as objectIdEncode, r as binaryFromBase64, s as bsonToJson, t as binaryDecode, u as constructorName, v as decimalTextNumberLiteral, w as int64Decode, x as encodeBsonValue, y as decodeBsonValue, z as mongoDouble } from "./data-types-vptiHFHC-LUJwNRIq.mjs";
|
|
4
4
|
import { floatToJson, readJsonFloat, renderTsLiteral } from "@prisma/orm-framework/components/codec";
|
|
5
5
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
6
6
|
import { mongoCodec, newMongoCodecRegistry } from "@prisma/orm-family-mongo/codec";
|
|
7
7
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
8
|
-
//#region ../../../3-mongo-target/1-mongo-target/dist/codecs-
|
|
8
|
+
//#region ../../../3-mongo-target/1-mongo-target/dist/codecs-BVrMDhha.mjs
|
|
9
9
|
const BSON_TYPE_BY_TAG = {
|
|
10
10
|
ObjectId: "objectId",
|
|
11
11
|
Decimal128: "decimal",
|
|
@@ -385,4 +385,4 @@ function buildStandardCodecRegistry() {
|
|
|
385
385
|
//#endregion
|
|
386
386
|
export { mongoStandardCodecs as i, mongoCodecDescriptors as n, mongoDescriptorById as r, buildStandardCodecRegistry as t };
|
|
387
387
|
|
|
388
|
-
//# sourceMappingURL=codecs-
|
|
388
|
+
//# sourceMappingURL=codecs-BVrMDhha-DBl_TLS8.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs-9hW1zPTj-UIJ0Z1th.mjs","names":[],"sources":["../../../../3-mongo-target/1-mongo-target/dist/codecs-9hW1zPTj.mjs"],"sourcesContent":["import { a as MONGO_DECIMAL128_CODEC_ID, c as MONGO_INT64_CODEC_ID, d as MONGO_OBJECTID_CODEC_ID, f as MONGO_STRING_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_INT64_NUMBER_CODEC_ID, n as MONGO_BOOLEAN_CODEC_ID, o as MONGO_DOUBLE_CODEC_ID, p as MONGO_VECTOR_CODEC_ID, r as MONGO_BSON_CODEC_ID, s as MONGO_INT32_CODEC_ID, t as MONGO_BINARY_CODEC_ID, u as MONGO_JSON_CODEC_ID } from \"./codec-ids-WdrumsYA.mjs\";\nimport { A as int64Decode, B as vectorEncode, C as decimal128Encode, D as doubleEncode, E as decimalTextNumberLiteral, F as int64NumberToJson, G as bsonClassTag, H as decodeBsonValue, I as int64ToJson, J as constructorName, K as bsonTypeTag, L as objectIdEncode, M as int64NumberDecode, N as int64NumberEncode, O as int32Encode, P as int64NumberFromDigits, Q as where, R as objectIdToJson, S as decimal128Decode, T as decimalTextBigintLiteral, U as encodeBsonValue, V as bsonToJson, W as readBsonJson, X as isPlainArray, Y as dbRefEntries, Z as isPlainObject, _ as binaryFromBase64, a as mongoDate, b as dateEncode, c as mongoInt32, d as mongoObjectId, f as mongoString, g as binaryEncode, h as binaryDecode, j as int64Encode, k as int32ToJson, l as mongoInt64, n as mongoBool, o as mongoDecimal128, p as mongoVector, q as child, r as mongoBson, s as mongoDouble, t as mongoBinary, u as mongoJson, v as binaryToBase64, w as decimal128ToJson, x as dateToJson, y as booleanEncode, z as stringEncode } from \"./data-types-CfdzqGSQ.mjs\";\nimport { t as mongoTargetError } from \"./mongo-target-errors-Btf3ML1w.mjs\";\nimport { floatToJson, readJsonFloat, renderTsLiteral } from \"@internal/framework-components/codec\";\nimport { mongoCodec, newMongoCodecRegistry } from \"@internal/mongo-codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/core/json-codec-helpers.ts\nconst BSON_TYPE_BY_TAG = {\n\tObjectId: \"objectId\",\n\tDecimal128: \"decimal\",\n\tBinary: \"binData\",\n\tBSONRegExp: \"regex\",\n\tTimestamp: \"timestamp\",\n\tBSONSymbol: \"symbol\",\n\tCode: \"javascript\",\n\tMinKey: \"minKey\",\n\tMaxKey: \"maxKey\"\n};\nconst NOT_FINITE_FIX = \"JSON has no NaN or Infinity; store null or a string, or declare the field Bson.\";\nconst BSON_FIX = \"Declare the field Bson to store BSON values.\";\nconst PLAIN_VALUE_FIX = \"Convert it to a plain object or array.\";\nconst ENCODE_FIX_BY_RECEIVED = {\n\tDate: \"Store the date as an ISO 8601 string, or declare the field Bson.\",\n\tbigint: \"Store it as a number in the safe-integer range or as decimal text, or declare the field Int64 or Bson.\",\n\tNaN: NOT_FINITE_FIX,\n\tInfinity: NOT_FINITE_FIX,\n\t\"-Infinity\": NOT_FINITE_FIX,\n\tundefined: \"Leave the key out, or store null.\",\n\tUint8Array: \"Store the bytes as a base64 string, or declare the field Binary or Bson.\",\n\tBuffer: \"Store the bytes as a base64 string, or declare the field Binary or Bson.\",\n\tBinary: \"Store the bytes as a base64 string, or declare the field Binary or Bson.\",\n\tObjectId: \"Store its hex string, or declare the field ObjectId or Bson.\",\n\tLong: \"Store a number in the safe-integer range or decimal text, or declare the field Int64 or Bson.\",\n\tDecimal128: \"Store the decimal text, or declare the field Decimal128 or Bson.\",\n\tInt32: \"Pass a plain number.\",\n\tDouble: \"Pass a plain number.\",\n\tRegExp: \"Store the pattern as a string, or declare the field Bson.\",\n\tBSONRegExp: \"Store the pattern as a string, or declare the field Bson.\",\n\tsymbol: \"Store a string instead.\",\n\tfunction: \"Store data, not a function.\",\n\t\"circular reference\": \"Remove the cycle; a JSON value is a tree.\",\n\t\"sparse array hole\": \"Fill the hole with null.\",\n\tDBRef: \"Write it as a { $ref, $id } document instead.\"\n};\nfunction encodeFix(received) {\n\treturn ENCODE_FIX_BY_RECEIVED[received] ?? (Object.hasOwn(BSON_TYPE_BY_TAG, received) ? BSON_FIX : PLAIN_VALUE_FIX);\n}\nfunction encodeRefused(received, path) {\n\tthrow mongoTargetError(\"RUNTIME.ENCODE_FAILED\", `${MONGO_JSON_CODEC_ID} value must be a JSON value; received ${received} at ${where(path)}. ${encodeFix(received)}`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived,\n\t\tvaluePath: path\n\t} });\n}\nfunction describeNonJson(value) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return void 0;\n\tif (typeof value === \"number\") return Number.isFinite(value) ? void 0 : String(value);\n\tif (typeof value !== \"object\") return typeof value;\n\tconst tag = bsonTypeTag(value);\n\tif (tag !== void 0) return tag;\n\tif (value instanceof Date) return \"Date\";\n\tif (isPlainArray(value)) return void 0;\n\treturn isPlainObject(value) ? void 0 : constructorName(value);\n}\nfunction assertJsonValue(value, path, ancestors) {\n\tconst received = describeNonJson(value);\n\tif (received !== void 0) encodeRefused(received, path);\n\tif (typeof value !== \"object\" || value === null) return;\n\tif (ancestors.has(value)) encodeRefused(\"circular reference\", path);\n\tancestors.add(value);\n\tif (Array.isArray(value)) for (let index = 0; index < value.length; index++) {\n\t\tif (!(index in value)) encodeRefused(\"sparse array hole\", child(path, index));\n\t\tassertJsonValue(value[index], child(path, index), ancestors);\n\t}\n\telse for (const [key, entry] of Object.entries(value)) assertJsonValue(entry, child(path, key), ancestors);\n\tancestors.delete(value);\n}\n/**\n* Returns `value` unchanged when it is a plain JSON value at every depth, and throws `RUNTIME.ENCODE_FAILED` naming the first value that is not, with its path.\n*/\nfunction encodeJsonValue(value) {\n\tassertJsonValue(value, \"\", /* @__PURE__ */ new Set());\n\treturn value;\n}\nfunction decodeRefused(bsonType, path) {\n\tthrow mongoTargetError(\"RUNTIME.DECODE_FAILED\", `${MONGO_JSON_CODEC_ID} wire value contains a non-JSON BSON ${bsonType} at ${where(path)}`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived: bsonType,\n\t\tvaluePath: path\n\t} });\n}\nfunction safeLong(value, path) {\n\tconst number = Number(value);\n\treturn Number.isSafeInteger(number) && BigInt(number) === value ? number : decodeRefused(\"long\", path);\n}\nfunction finiteDouble(value, path) {\n\tif (Number.isFinite(value)) return value;\n\tconst received = String(value);\n\tthrow mongoTargetError(\"RUNTIME.DECODE_FAILED\", `${MONGO_JSON_CODEC_ID} wire value contains ${received} at ${where(path)}; a JSON number cannot be NaN or Infinity`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived,\n\t\tvaluePath: path\n\t} });\n}\nfunction decodeEntries(entries, path) {\n\treturn Object.fromEntries(entries.map(([key, entry]) => [key, decodeValue(entry, child(path, key))]));\n}\nfunction decodeTagged(value, tag, path) {\n\tswitch (tag) {\n\t\tcase \"DBRef\": return decodeEntries(dbRefEntries(value), path);\n\t\tcase \"Long\": return safeLong(blindCast(value).toBigInt(), path);\n\t\tcase \"Int32\":\n\t\tcase \"Double\": return finiteDouble(Number(value.valueOf()), path);\n\t}\n\treturn decodeRefused(BSON_TYPE_BY_TAG[tag] ?? tag, path);\n}\nfunction decodeValue(value, path) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return finiteDouble(value, path);\n\tif (typeof value === \"bigint\") return safeLong(value, path);\n\tif (typeof value === \"undefined\") return decodeRefused(\"undefined\", path);\n\tif (typeof value === \"symbol\") return decodeRefused(\"symbol\", path);\n\tif (typeof value === \"function\") return decodeRefused(\"javascript\", path);\n\tconst tag = bsonClassTag(value);\n\tif (tag !== void 0) return decodeTagged(value, tag, path);\n\tif (value instanceof Date) return decodeRefused(\"date\", path);\n\tif (value instanceof RegExp) return decodeRefused(\"regex\", path);\n\tif (value instanceof Uint8Array) return decodeRefused(\"binData\", path);\n\tif (Array.isArray(value)) {\n\t\tconst decoded = value.map((entry, index) => decodeValue(entry, child(path, index)));\n\t\treturn decoded.some((entry, index) => entry !== value[index]) ? decoded : value;\n\t}\n\tif (!isPlainObject(value)) return decodeRefused(constructorName(value), path);\n\tconst entries = Object.entries(value);\n\tconst decoded = decodeEntries(entries, path);\n\treturn entries.some(([key, entry]) => decoded[key] !== entry) ? decoded : blindCast(value);\n}\n/**\n* Decodes a wire value to the JSON value it holds: a `long` in the safe-integer range and the driver's `Int32` and `Double` wrappers become numbers. Only the objects and arrays around a converted value are copied; a wire value that is already JSON is returned as the same object. Throws `RUNTIME.DECODE_FAILED` naming the BSON type and path of the first value that is not JSON.\n*/\nfunction decodeJsonValue(wire) {\n\treturn decodeValue(wire, \"\");\n}\n//#endregion\n//#region src/core/codecs.ts\nconst mongoObjectIdCodec = mongoCodec({\n\ttypeId: MONGO_OBJECTID_CODEC_ID,\n\tdataType: mongoObjectId,\n\tfromWire: (wire) => wire.toHexString(),\n\ttoWire: (value) => objectIdEncode(MONGO_OBJECTID_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoObjectId.valueFrom(objectIdToJson(MONGO_OBJECTID_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoStringCodec = mongoCodec({\n\ttypeId: MONGO_STRING_CODEC_ID,\n\tdataType: mongoString,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => stringEncode(MONGO_STRING_CODEC_ID, value),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoDoubleCodec = mongoCodec({\n\ttypeId: MONGO_DOUBLE_CODEC_ID,\n\tdataType: mongoDouble,\n\tfromWire: (wire) => Number(wire),\n\ttoWire: (value) => doubleEncode(MONGO_DOUBLE_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDouble.valueFrom(floatToJson(value), {}),\n\tfromDataTypeValue: (value) => readJsonFloat(MONGO_DOUBLE_CODEC_ID, value.value)\n});\nconst mongoInt32Codec = mongoCodec({\n\ttypeId: MONGO_INT32_CODEC_ID,\n\tdataType: mongoInt32,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => int32Encode(MONGO_INT32_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt32.valueFrom(int32ToJson(MONGO_INT32_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoBooleanCodec = mongoCodec({\n\ttypeId: MONGO_BOOLEAN_CODEC_ID,\n\tdataType: mongoBool,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => booleanEncode(MONGO_BOOLEAN_CODEC_ID, value),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoDateCodec = mongoCodec({\n\ttypeId: MONGO_DATE_CODEC_ID,\n\tdataType: mongoDate,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => dateEncode(MONGO_DATE_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDate.valueFrom(dateToJson(MONGO_DATE_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => new Date(value.value)\n});\n/** The vector codec for a column of `mongo/vector` with `params`. The dimension reaches only the TypeScript type `Vector<n>`. */\nfunction vectorCodec(params) {\n\treturn mongoCodec({\n\t\ttypeId: MONGO_VECTOR_CODEC_ID,\n\t\tdataType: mongoVector,\n\t\t...ifDefined(\"params\", params),\n\t\tfromWire: (wire) => wire,\n\t\ttoWire: (value) => vectorEncode(MONGO_VECTOR_CODEC_ID, value),\n\t\tfromDataTypeValue: (value) => value.value\n\t});\n}\nconst mongoVectorCodec = vectorCodec();\n/**\n* A BSON `long`. The application value is a `bigint`, because a `number` cannot hold the full 64-bit range; its stored form is decimal text.\n*/\nconst mongoInt64Codec = mongoCodec({\n\ttypeId: MONGO_INT64_CODEC_ID,\n\tdataType: mongoInt64,\n\tfromWire: (wire) => int64Decode(MONGO_INT64_CODEC_ID, wire),\n\ttoWire: (value) => int64Encode(MONGO_INT64_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt64.valueFrom(int64ToJson(MONGO_INT64_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => BigInt(value.value)\n});\n/**\n* A BSON `long` read and written as a `number` from -(2^53 - 1) to 2^53 - 1, the value a Prisma 6 `Int` presents. A value outside that range, or with a fraction, is refused rather than rounded.\n*/\nconst mongoInt64NumberCodec = mongoCodec({\n\ttypeId: MONGO_INT64_NUMBER_CODEC_ID,\n\tdataType: mongoInt64,\n\tfromWire: (wire) => int64NumberDecode(MONGO_INT64_NUMBER_CODEC_ID, wire),\n\ttoWire: (value) => int64NumberEncode(MONGO_INT64_NUMBER_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt64.valueFrom(int64NumberToJson(MONGO_INT64_NUMBER_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => int64NumberFromDigits(MONGO_INT64_NUMBER_CODEC_ID, value.value)\n});\n/**\n* A BSON `decimal`. The application value and its stored form are the same decimal text, written without an exponent.\n*/\nconst mongoDecimal128Codec = mongoCodec({\n\ttypeId: MONGO_DECIMAL128_CODEC_ID,\n\tdataType: mongoDecimal128,\n\tfromWire: (wire) => decimal128Decode(MONGO_DECIMAL128_CODEC_ID, wire),\n\ttoWire: (value) => decimal128Encode(MONGO_DECIMAL128_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDecimal128.valueFrom(decimal128ToJson(MONGO_DECIMAL128_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\n/**\n* BSON `binData`. The application value is a `Uint8Array`; its stored form is unwrapped base64.\n*/\nconst mongoBinaryCodec = mongoCodec({\n\ttypeId: MONGO_BINARY_CODEC_ID,\n\tdataType: mongoBinary,\n\tfromWire: (wire) => binaryDecode(MONGO_BINARY_CODEC_ID, wire),\n\ttoWire: (value) => binaryEncode(MONGO_BINARY_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoBinary.valueFrom(binaryToBase64(value), {}),\n\tfromDataTypeValue: (value) => binaryFromBase64(value.value)\n});\n/**\n* A JSON value, stored as the BSON object, array, string, number, boolean or null it maps to. Encode and decode refuse any other value at any depth, naming its path.\n*/\nconst mongoJsonCodec = mongoCodec({\n\ttypeId: MONGO_JSON_CODEC_ID,\n\tdataType: mongoJson,\n\tfromWire: (wire) => decodeJsonValue(wire),\n\ttoWire: (value) => encodeJsonValue(value)\n});\n/**\n* Any BSON value, passed through unchanged except that decode turns a `DBRef` back into the `{ $ref, $id }` document it was stored as. Encode takes a `BsonInputValue` and decode returns a `BsonValue`. Its stored form is canonical MongoDB Extended JSON v2, written with each number and `Uint8Array` as the BSON type the driver stores, so a round trip keeps the BSON bytes but may return wrapper classes such as `Int32` and `Double`.\n*/\nconst mongoBsonCodec = mongoCodec({\n\ttypeId: MONGO_BSON_CODEC_ID,\n\tdataType: mongoBson,\n\tfromWire: (wire) => decodeBsonValue(wire),\n\ttoWire: (value) => encodeBsonValue(value),\n\ttoDataTypeValue: (value) => mongoBson.valueFrom(bsonToJson(value), {}),\n\tfromDataTypeValue: (value) => readBsonJson(MONGO_BSON_CODEC_ID, value.value)\n});\n/**\n* The canonical set of Mongo wire-type codecs.\n*\n* Single source of truth for both control- and runtime-plane adapter descriptors. Don't duplicate this list — import it.\n*/\nconst mongoStandardCodecs = [\n\tmongoObjectIdCodec,\n\tmongoStringCodec,\n\tmongoDoubleCodec,\n\tmongoInt32Codec,\n\tmongoBooleanCodec,\n\tmongoDateCodec,\n\tmongoVectorCodec,\n\tmongoInt64Codec,\n\tmongoInt64NumberCodec,\n\tmongoDecimal128Codec,\n\tmongoBinaryCodec,\n\tmongoJsonCodec,\n\tmongoBsonCodec\n];\n/**\n* Build a {@link CodecDescriptor} for a Mongo wire-type codec.\n*\n* Wraps an existing {@link MongoCodec} instance into a descriptor whose factory hands out the same shared codec, or, for a codec whose data type has parameters, one built for the column's parameters. Mongo's full migration to descriptor-first authoring is tracked under TML-2324; for now the descriptor view is composed from the existing `mongoCodec()` outputs.\n*/\nfunction descriptorFor(codec, metadata) {\n\treturn {\n\t\tcodecId: codec.id,\n\t\tdataType: codec.dataType.id,\n\t\ttraits: metadata.traits,\n\t\tparamsSchema: blindCast(codec.dataType.params),\n\t\tisParameterized: codec.dataType.params !== void 0,\n\t\tfactory: blindCast((params) => {\n\t\t\tconst built = metadata.withParams === void 0 || params === void 0 ? codec : metadata.withParams(params);\n\t\t\treturn () => built;\n\t\t}),\n\t\t...ifDefined(\"renderValueLiteral\", metadata.renderValueLiteral)\n\t};\n}\n/**\n* Mongo wire-type codec descriptors. Static metadata such as `traits` lives here (the descriptor shape) — `MongoCodec` itself carries its data type and the four conversion methods (TML-2357).\n*/\nconst mongoCodecDescriptors = [\n\tdescriptorFor(mongoObjectIdCodec, { traits: [\"equality\"] }),\n\tdescriptorFor(mongoStringCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"textual\"\n\t\t],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tdescriptorFor(mongoDoubleCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: (value) => typeof value === \"number\" ? String(value) : void 0\n\t}),\n\tdescriptorFor(mongoInt32Codec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tdescriptorFor(mongoBooleanCodec, {\n\t\ttraits: [\"equality\", \"boolean\"],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tdescriptorFor(mongoDateCodec, { traits: [\"equality\", \"order\"] }),\n\tdescriptorFor(mongoVectorCodec, {\n\t\ttraits: [\"equality\"],\n\t\twithParams: vectorCodec\n\t}),\n\tdescriptorFor(mongoInt64Codec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: decimalTextBigintLiteral\n\t}),\n\tdescriptorFor(mongoInt64NumberCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: decimalTextNumberLiteral\n\t}),\n\tdescriptorFor(mongoDecimal128Codec, { traits: [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"numeric\"\n\t] }),\n\tdescriptorFor(mongoBinaryCodec, { traits: [\"equality\"] }),\n\tdescriptorFor(mongoJsonCodec, { traits: [] }),\n\tdescriptorFor(mongoBsonCodec, { traits: [] })\n];\n/**\n* Lookup descriptor metadata by codec id — used by tests and for descriptor-side reads of static metadata.\n*/\nfunction mongoDescriptorById(codecId) {\n\treturn mongoCodecDescriptors.find((d) => d.codecId === codecId);\n}\n/**\n* Build a {@link MongoCodecRegistry} preloaded with the standard Mongo wire-type codecs.\n*\n* Single point of truth for adapter-side codec construction: used by the legacy synchronous `createMongoAdapter()` factory and by the runtime adapter descriptor's `codecs()` getter. Userland code obtains a registry via the framework's execution-stack composition (see `createMongoExecutionContext`) instead of calling this directly.\n*/\nfunction buildStandardCodecRegistry() {\n\tconst registry = newMongoCodecRegistry();\n\tfor (const codec of mongoStandardCodecs) registry.register(codec);\n\treturn registry;\n}\n//#endregion\nexport { mongoStandardCodecs as i, mongoCodecDescriptors as n, mongoDescriptorById as r, buildStandardCodecRegistry as t };\n\n//# sourceMappingURL=codecs-9hW1zPTj.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,mBAAmB;CACxB,UAAU;CACV,YAAY;CACZ,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,YAAY;CACZ,MAAM;CACN,QAAQ;CACR,QAAQ;AACT;AACA,MAAM,iBAAiB;AACvB,MAAM,WAAW;AACjB,MAAM,kBAAkB;AACxB,MAAM,yBAAyB;CAC9B,MAAM;CACN,QAAQ;CACR,KAAK;CACL,UAAU;CACV,aAAa;CACb,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,MAAM;CACN,YAAY;CACZ,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,UAAU;CACV,sBAAsB;CACtB,qBAAqB;CACrB,OAAO;AACR;AACA,SAAS,UAAU,UAAU;CAC5B,OAAO,uBAAuB,cAAc,OAAO,OAAO,kBAAkB,QAAQ,IAAI,WAAW;AACpG;AACA,SAAS,cAAc,UAAU,MAAM;CACtC,MAAM,iBAAiB,yBAAyB,GAAG,oBAAoB,wCAAwC,SAAS,MAAM,MAAM,IAAI,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EACpC,QAAQ;GACP;GACA;GACA;EACD;EACA,oBAAoB;CACrB,CAAC;CACD,cAAc,sBAAsB,EAAE,QAAQ;EAC7C;EACA;EACA;CACD,EAAE,CAAC;CACH,cAAc,kBAAkB,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;CACxD,cAAc,gBAAgB,EAAE,QAAQ,CAAC,EAAE,CAAC;CAC5C,cAAc,gBAAgB,EAAE,QAAQ,CAAC,EAAE,CAAC;AAC7C;;;;AAIA,SAAS,oBAAoB,SAAS;CACrC,OAAO,sBAAsB,MAAM,MAAM,EAAE,YAAY,OAAO;AAC/D;;;;;;AAMA,SAAS,6BAA6B;CACrC,MAAM,WAAW,sBAAsB;CACvC,KAAK,MAAM,SAAS,qBAAqB,SAAS,SAAS,KAAK;CAChE,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"codecs-BVrMDhha-DBl_TLS8.mjs","names":[],"sources":["../../../../3-mongo-target/1-mongo-target/dist/codecs-BVrMDhha.mjs"],"sourcesContent":["import { a as MONGO_DECIMAL128_CODEC_ID, c as MONGO_INT64_CODEC_ID, d as MONGO_OBJECTID_CODEC_ID, f as MONGO_STRING_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_INT64_NUMBER_CODEC_ID, n as MONGO_BOOLEAN_CODEC_ID, o as MONGO_DOUBLE_CODEC_ID, p as MONGO_VECTOR_CODEC_ID, r as MONGO_BSON_CODEC_ID, s as MONGO_INT32_CODEC_ID, t as MONGO_BINARY_CODEC_ID, u as MONGO_JSON_CODEC_ID } from \"./codec-ids-WdrumsYA.mjs\";\nimport { A as int64Decode, B as vectorEncode, C as decimal128Encode, D as doubleEncode, E as decimalTextNumberLiteral, F as int64NumberToJson, G as bsonClassTag, H as decodeBsonValue, I as int64ToJson, J as constructorName, K as bsonTypeTag, L as objectIdEncode, M as int64NumberDecode, N as int64NumberEncode, O as int32Encode, P as int64NumberFromDigits, Q as where, R as objectIdToJson, S as decimal128Decode, T as decimalTextBigintLiteral, U as encodeBsonValue, V as bsonToJson, W as readBsonJson, X as isPlainArray, Y as dbRefEntries, Z as isPlainObject, _ as binaryFromBase64, a as mongoDate, b as dateEncode, c as mongoInt32, d as mongoObjectId, f as mongoString, g as binaryEncode, h as binaryDecode, j as int64Encode, k as int32ToJson, l as mongoInt64, n as mongoBool, o as mongoDecimal128, p as mongoVector, q as child, r as mongoBson, s as mongoDouble, t as mongoBinary, u as mongoJson, v as binaryToBase64, w as decimal128ToJson, x as dateToJson, y as booleanEncode, z as stringEncode } from \"./data-types-vptiHFHC.mjs\";\nimport { t as mongoTargetError } from \"./mongo-target-errors-Btf3ML1w.mjs\";\nimport { floatToJson, readJsonFloat, renderTsLiteral } from \"@internal/framework-components/codec\";\nimport { mongoCodec, newMongoCodecRegistry } from \"@internal/mongo-codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/core/json-codec-helpers.ts\nconst BSON_TYPE_BY_TAG = {\n\tObjectId: \"objectId\",\n\tDecimal128: \"decimal\",\n\tBinary: \"binData\",\n\tBSONRegExp: \"regex\",\n\tTimestamp: \"timestamp\",\n\tBSONSymbol: \"symbol\",\n\tCode: \"javascript\",\n\tMinKey: \"minKey\",\n\tMaxKey: \"maxKey\"\n};\nconst NOT_FINITE_FIX = \"JSON has no NaN or Infinity; store null or a string, or declare the field Bson.\";\nconst BSON_FIX = \"Declare the field Bson to store BSON values.\";\nconst PLAIN_VALUE_FIX = \"Convert it to a plain object or array.\";\nconst ENCODE_FIX_BY_RECEIVED = {\n\tDate: \"Store the date as an ISO 8601 string, or declare the field Bson.\",\n\tbigint: \"Store it as a number in the safe-integer range or as decimal text, or declare the field Int64 or Bson.\",\n\tNaN: NOT_FINITE_FIX,\n\tInfinity: NOT_FINITE_FIX,\n\t\"-Infinity\": NOT_FINITE_FIX,\n\tundefined: \"Leave the key out, or store null.\",\n\tUint8Array: \"Store the bytes as a base64 string, or declare the field Binary or Bson.\",\n\tBuffer: \"Store the bytes as a base64 string, or declare the field Binary or Bson.\",\n\tBinary: \"Store the bytes as a base64 string, or declare the field Binary or Bson.\",\n\tObjectId: \"Store its hex string, or declare the field ObjectId or Bson.\",\n\tLong: \"Store a number in the safe-integer range or decimal text, or declare the field Int64 or Bson.\",\n\tDecimal128: \"Store the decimal text, or declare the field Decimal128 or Bson.\",\n\tInt32: \"Pass a plain number.\",\n\tDouble: \"Pass a plain number.\",\n\tRegExp: \"Store the pattern as a string, or declare the field Bson.\",\n\tBSONRegExp: \"Store the pattern as a string, or declare the field Bson.\",\n\tsymbol: \"Store a string instead.\",\n\tfunction: \"Store data, not a function.\",\n\t\"circular reference\": \"Remove the cycle; a JSON value is a tree.\",\n\t\"sparse array hole\": \"Fill the hole with null.\",\n\tDBRef: \"Write it as a { $ref, $id } document instead.\"\n};\nfunction encodeFix(received) {\n\treturn ENCODE_FIX_BY_RECEIVED[received] ?? (Object.hasOwn(BSON_TYPE_BY_TAG, received) ? BSON_FIX : PLAIN_VALUE_FIX);\n}\nfunction encodeRefused(received, path) {\n\tthrow mongoTargetError(\"RUNTIME.ENCODE_FAILED\", `${MONGO_JSON_CODEC_ID} value must be a JSON value; received ${received} at ${where(path)}. ${encodeFix(received)}`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived,\n\t\tvaluePath: path\n\t} });\n}\nfunction describeNonJson(value) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return void 0;\n\tif (typeof value === \"number\") return Number.isFinite(value) ? void 0 : String(value);\n\tif (typeof value !== \"object\") return typeof value;\n\tconst tag = bsonTypeTag(value);\n\tif (tag !== void 0) return tag;\n\tif (value instanceof Date) return \"Date\";\n\tif (isPlainArray(value)) return void 0;\n\treturn isPlainObject(value) ? void 0 : constructorName(value);\n}\nfunction assertJsonValue(value, path, ancestors) {\n\tconst received = describeNonJson(value);\n\tif (received !== void 0) encodeRefused(received, path);\n\tif (typeof value !== \"object\" || value === null) return;\n\tif (ancestors.has(value)) encodeRefused(\"circular reference\", path);\n\tancestors.add(value);\n\tif (Array.isArray(value)) for (let index = 0; index < value.length; index++) {\n\t\tif (!(index in value)) encodeRefused(\"sparse array hole\", child(path, index));\n\t\tassertJsonValue(value[index], child(path, index), ancestors);\n\t}\n\telse for (const [key, entry] of Object.entries(value)) assertJsonValue(entry, child(path, key), ancestors);\n\tancestors.delete(value);\n}\n/**\n* Returns `value` unchanged when it is a plain JSON value at every depth, and throws `RUNTIME.ENCODE_FAILED` naming the first value that is not, with its path.\n*/\nfunction encodeJsonValue(value) {\n\tassertJsonValue(value, \"\", /* @__PURE__ */ new Set());\n\treturn value;\n}\nfunction decodeRefused(bsonType, path) {\n\tthrow mongoTargetError(\"RUNTIME.DECODE_FAILED\", `${MONGO_JSON_CODEC_ID} wire value contains a non-JSON BSON ${bsonType} at ${where(path)}`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived: bsonType,\n\t\tvaluePath: path\n\t} });\n}\nfunction safeLong(value, path) {\n\tconst number = Number(value);\n\treturn Number.isSafeInteger(number) && BigInt(number) === value ? number : decodeRefused(\"long\", path);\n}\nfunction finiteDouble(value, path) {\n\tif (Number.isFinite(value)) return value;\n\tconst received = String(value);\n\tthrow mongoTargetError(\"RUNTIME.DECODE_FAILED\", `${MONGO_JSON_CODEC_ID} wire value contains ${received} at ${where(path)}; a JSON number cannot be NaN or Infinity`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived,\n\t\tvaluePath: path\n\t} });\n}\nfunction decodeEntries(entries, path) {\n\treturn Object.fromEntries(entries.map(([key, entry]) => [key, decodeValue(entry, child(path, key))]));\n}\nfunction decodeTagged(value, tag, path) {\n\tswitch (tag) {\n\t\tcase \"DBRef\": return decodeEntries(dbRefEntries(value), path);\n\t\tcase \"Long\": return safeLong(blindCast(value).toBigInt(), path);\n\t\tcase \"Int32\":\n\t\tcase \"Double\": return finiteDouble(Number(value.valueOf()), path);\n\t}\n\treturn decodeRefused(BSON_TYPE_BY_TAG[tag] ?? tag, path);\n}\nfunction decodeValue(value, path) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return finiteDouble(value, path);\n\tif (typeof value === \"bigint\") return safeLong(value, path);\n\tif (typeof value === \"undefined\") return decodeRefused(\"undefined\", path);\n\tif (typeof value === \"symbol\") return decodeRefused(\"symbol\", path);\n\tif (typeof value === \"function\") return decodeRefused(\"javascript\", path);\n\tconst tag = bsonClassTag(value);\n\tif (tag !== void 0) return decodeTagged(value, tag, path);\n\tif (value instanceof Date) return decodeRefused(\"date\", path);\n\tif (value instanceof RegExp) return decodeRefused(\"regex\", path);\n\tif (value instanceof Uint8Array) return decodeRefused(\"binData\", path);\n\tif (Array.isArray(value)) {\n\t\tconst decoded = value.map((entry, index) => decodeValue(entry, child(path, index)));\n\t\treturn decoded.some((entry, index) => entry !== value[index]) ? decoded : value;\n\t}\n\tif (!isPlainObject(value)) return decodeRefused(constructorName(value), path);\n\tconst entries = Object.entries(value);\n\tconst decoded = decodeEntries(entries, path);\n\treturn entries.some(([key, entry]) => decoded[key] !== entry) ? decoded : blindCast(value);\n}\n/**\n* Decodes a wire value to the JSON value it holds: a `long` in the safe-integer range and the driver's `Int32` and `Double` wrappers become numbers. Only the objects and arrays around a converted value are copied; a wire value that is already JSON is returned as the same object. Throws `RUNTIME.DECODE_FAILED` naming the BSON type and path of the first value that is not JSON.\n*/\nfunction decodeJsonValue(wire) {\n\treturn decodeValue(wire, \"\");\n}\n//#endregion\n//#region src/core/codecs.ts\nconst mongoObjectIdCodec = mongoCodec({\n\ttypeId: MONGO_OBJECTID_CODEC_ID,\n\tdataType: mongoObjectId,\n\tfromWire: (wire) => wire.toHexString(),\n\ttoWire: (value) => objectIdEncode(MONGO_OBJECTID_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoObjectId.valueFrom(objectIdToJson(MONGO_OBJECTID_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoStringCodec = mongoCodec({\n\ttypeId: MONGO_STRING_CODEC_ID,\n\tdataType: mongoString,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => stringEncode(MONGO_STRING_CODEC_ID, value),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoDoubleCodec = mongoCodec({\n\ttypeId: MONGO_DOUBLE_CODEC_ID,\n\tdataType: mongoDouble,\n\tfromWire: (wire) => Number(wire),\n\ttoWire: (value) => doubleEncode(MONGO_DOUBLE_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDouble.valueFrom(floatToJson(value), {}),\n\tfromDataTypeValue: (value) => readJsonFloat(MONGO_DOUBLE_CODEC_ID, value.value)\n});\nconst mongoInt32Codec = mongoCodec({\n\ttypeId: MONGO_INT32_CODEC_ID,\n\tdataType: mongoInt32,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => int32Encode(MONGO_INT32_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt32.valueFrom(int32ToJson(MONGO_INT32_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoBooleanCodec = mongoCodec({\n\ttypeId: MONGO_BOOLEAN_CODEC_ID,\n\tdataType: mongoBool,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => booleanEncode(MONGO_BOOLEAN_CODEC_ID, value),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoDateCodec = mongoCodec({\n\ttypeId: MONGO_DATE_CODEC_ID,\n\tdataType: mongoDate,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => dateEncode(MONGO_DATE_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDate.valueFrom(dateToJson(MONGO_DATE_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => new Date(value.value)\n});\n/** The vector codec for a column of `mongo/vector` with `params`. The dimension reaches only the TypeScript type `Vector<n>`. */\nfunction vectorCodec(params) {\n\treturn mongoCodec({\n\t\ttypeId: MONGO_VECTOR_CODEC_ID,\n\t\tdataType: mongoVector,\n\t\t...ifDefined(\"params\", params),\n\t\tfromWire: (wire) => wire,\n\t\ttoWire: (value) => vectorEncode(MONGO_VECTOR_CODEC_ID, value),\n\t\tfromDataTypeValue: (value) => value.value\n\t});\n}\nconst mongoVectorCodec = vectorCodec();\n/**\n* A BSON `long`. The application value is a `bigint`, because a `number` cannot hold the full 64-bit range; its stored form is decimal text.\n*/\nconst mongoInt64Codec = mongoCodec({\n\ttypeId: MONGO_INT64_CODEC_ID,\n\tdataType: mongoInt64,\n\tfromWire: (wire) => int64Decode(MONGO_INT64_CODEC_ID, wire),\n\ttoWire: (value) => int64Encode(MONGO_INT64_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt64.valueFrom(int64ToJson(MONGO_INT64_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => BigInt(value.value)\n});\n/**\n* A BSON `long` read and written as a `number` from -(2^53 - 1) to 2^53 - 1, the value a Prisma 6 `Int` presents. A value outside that range, or with a fraction, is refused rather than rounded.\n*/\nconst mongoInt64NumberCodec = mongoCodec({\n\ttypeId: MONGO_INT64_NUMBER_CODEC_ID,\n\tdataType: mongoInt64,\n\tfromWire: (wire) => int64NumberDecode(MONGO_INT64_NUMBER_CODEC_ID, wire),\n\ttoWire: (value) => int64NumberEncode(MONGO_INT64_NUMBER_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt64.valueFrom(int64NumberToJson(MONGO_INT64_NUMBER_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => int64NumberFromDigits(MONGO_INT64_NUMBER_CODEC_ID, value.value)\n});\n/**\n* A BSON `decimal`. The application value and its stored form are the same decimal text, written without an exponent.\n*/\nconst mongoDecimal128Codec = mongoCodec({\n\ttypeId: MONGO_DECIMAL128_CODEC_ID,\n\tdataType: mongoDecimal128,\n\tfromWire: (wire) => decimal128Decode(MONGO_DECIMAL128_CODEC_ID, wire),\n\ttoWire: (value) => decimal128Encode(MONGO_DECIMAL128_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDecimal128.valueFrom(decimal128ToJson(MONGO_DECIMAL128_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\n/**\n* BSON `binData`. The application value is a `Uint8Array`; its stored form is unwrapped base64.\n*/\nconst mongoBinaryCodec = mongoCodec({\n\ttypeId: MONGO_BINARY_CODEC_ID,\n\tdataType: mongoBinary,\n\tfromWire: (wire) => binaryDecode(MONGO_BINARY_CODEC_ID, wire),\n\ttoWire: (value) => binaryEncode(MONGO_BINARY_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoBinary.valueFrom(binaryToBase64(value), {}),\n\tfromDataTypeValue: (value) => binaryFromBase64(value.value)\n});\n/**\n* A JSON value, stored as the BSON object, array, string, number, boolean or null it maps to. Encode and decode refuse any other value at any depth, naming its path.\n*/\nconst mongoJsonCodec = mongoCodec({\n\ttypeId: MONGO_JSON_CODEC_ID,\n\tdataType: mongoJson,\n\tfromWire: (wire) => decodeJsonValue(wire),\n\ttoWire: (value) => encodeJsonValue(value)\n});\n/**\n* Any BSON value, passed through unchanged except that decode turns a `DBRef` back into the `{ $ref, $id }` document it was stored as. Encode takes a `BsonInputValue` and decode returns a `BsonValue`. Its stored form is canonical MongoDB Extended JSON v2, written with each number and `Uint8Array` as the BSON type the driver stores, so a round trip keeps the BSON bytes but may return wrapper classes such as `Int32` and `Double`.\n*/\nconst mongoBsonCodec = mongoCodec({\n\ttypeId: MONGO_BSON_CODEC_ID,\n\tdataType: mongoBson,\n\tfromWire: (wire) => decodeBsonValue(wire),\n\ttoWire: (value) => encodeBsonValue(value),\n\ttoDataTypeValue: (value) => mongoBson.valueFrom(bsonToJson(value), {}),\n\tfromDataTypeValue: (value) => readBsonJson(MONGO_BSON_CODEC_ID, value.value)\n});\n/**\n* The canonical set of Mongo wire-type codecs.\n*\n* Single source of truth for both control- and runtime-plane adapter descriptors. Don't duplicate this list — import it.\n*/\nconst mongoStandardCodecs = [\n\tmongoObjectIdCodec,\n\tmongoStringCodec,\n\tmongoDoubleCodec,\n\tmongoInt32Codec,\n\tmongoBooleanCodec,\n\tmongoDateCodec,\n\tmongoVectorCodec,\n\tmongoInt64Codec,\n\tmongoInt64NumberCodec,\n\tmongoDecimal128Codec,\n\tmongoBinaryCodec,\n\tmongoJsonCodec,\n\tmongoBsonCodec\n];\n/**\n* Build a {@link CodecDescriptor} for a Mongo wire-type codec.\n*\n* Wraps an existing {@link MongoCodec} instance into a descriptor whose factory hands out the same shared codec, or, for a codec whose data type has parameters, one built for the column's parameters. Mongo's full migration to descriptor-first authoring is tracked under TML-2324; for now the descriptor view is composed from the existing `mongoCodec()` outputs.\n*/\nfunction descriptorFor(codec, metadata) {\n\treturn {\n\t\tcodecId: codec.id,\n\t\tdataType: codec.dataType.id,\n\t\ttraits: metadata.traits,\n\t\tparamsSchema: blindCast(codec.dataType.params),\n\t\tisParameterized: codec.dataType.params !== void 0,\n\t\tfactory: blindCast((params) => {\n\t\t\tconst built = metadata.withParams === void 0 || params === void 0 ? codec : metadata.withParams(params);\n\t\t\treturn () => built;\n\t\t}),\n\t\t...ifDefined(\"renderValueLiteral\", metadata.renderValueLiteral)\n\t};\n}\n/**\n* Mongo wire-type codec descriptors. Static metadata such as `traits` lives here (the descriptor shape) — `MongoCodec` itself carries its data type and the four conversion methods (TML-2357).\n*/\nconst mongoCodecDescriptors = [\n\tdescriptorFor(mongoObjectIdCodec, { traits: [\"equality\"] }),\n\tdescriptorFor(mongoStringCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"textual\"\n\t\t],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tdescriptorFor(mongoDoubleCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: (value) => typeof value === \"number\" ? String(value) : void 0\n\t}),\n\tdescriptorFor(mongoInt32Codec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tdescriptorFor(mongoBooleanCodec, {\n\t\ttraits: [\"equality\", \"boolean\"],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tdescriptorFor(mongoDateCodec, { traits: [\"equality\", \"order\"] }),\n\tdescriptorFor(mongoVectorCodec, {\n\t\ttraits: [\"equality\"],\n\t\twithParams: vectorCodec\n\t}),\n\tdescriptorFor(mongoInt64Codec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: decimalTextBigintLiteral\n\t}),\n\tdescriptorFor(mongoInt64NumberCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: decimalTextNumberLiteral\n\t}),\n\tdescriptorFor(mongoDecimal128Codec, { traits: [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"numeric\"\n\t] }),\n\tdescriptorFor(mongoBinaryCodec, { traits: [\"equality\"] }),\n\tdescriptorFor(mongoJsonCodec, { traits: [] }),\n\tdescriptorFor(mongoBsonCodec, { traits: [] })\n];\n/**\n* Lookup descriptor metadata by codec id — used by tests and for descriptor-side reads of static metadata.\n*/\nfunction mongoDescriptorById(codecId) {\n\treturn mongoCodecDescriptors.find((d) => d.codecId === codecId);\n}\n/**\n* Build a {@link MongoCodecRegistry} preloaded with the standard Mongo wire-type codecs.\n*\n* Single point of truth for adapter-side codec construction: used by the legacy synchronous `createMongoAdapter()` factory and by the runtime adapter descriptor's `codecs()` getter. Userland code obtains a registry via the framework's execution-stack composition (see `createMongoExecutionContext`) instead of calling this directly.\n*/\nfunction buildStandardCodecRegistry() {\n\tconst registry = newMongoCodecRegistry();\n\tfor (const codec of mongoStandardCodecs) registry.register(codec);\n\treturn registry;\n}\n//#endregion\nexport { mongoStandard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S,qBAAqB,SAAS,SAAS,KAAK;CAChE,OAAO;AACR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as mongoTargetError } from "./mongo-target-errors-Btf3ML1w-B5EMYbz1.mjs";
|
|
2
|
-
import { t as mongoTargetDescriptorMeta } from "./descriptor-meta-
|
|
2
|
+
import { t as mongoTargetDescriptorMeta } from "./descriptor-meta-CYXIYjq7-DpMc5Tnm.mjs";
|
|
3
3
|
import { a as dropCollection, c as renameField, d as unsetField, n as createCollection, o as dropIndex, r as createIndex, s as renameCollection, t as collMod, u as unrewritableFieldNameReason } from "./migration-factories-jwrORVMV-BGqJk_WT.mjs";
|
|
4
4
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
5
5
|
import { type } from "arktype";
|
|
@@ -12,9 +12,9 @@ import { AggregateCommand, MongoAddFieldsStage, MongoLimitStage, MongoLookupStag
|
|
|
12
12
|
import { canonicalizeSchemasForVerification, contractToMongoSchemaIR, diffMongoSchemas, fieldRewriteOf } from "@prisma/orm-family-mongo/family/control";
|
|
13
13
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
14
14
|
import { MongoContractSerializerBase, MongoSchemaVerifierBase } from "@prisma/orm-family-mongo/family/ir";
|
|
15
|
-
import { MongoStorage } from "@prisma/orm-family-mongo/contract";
|
|
15
|
+
import { MongoCollection, MongoStorage, collectionControlPoliciesOf, collectionControlPolicyOf, collectionRootModelsOf, storedFieldNameOf, storesField, validatorFieldNamesOf, validatorRootShapesOf } from "@prisma/orm-family-mongo/contract";
|
|
16
16
|
import { composeMongoEntityKinds } from "@prisma/orm-family-mongo/contract/entity-kinds";
|
|
17
|
-
import { asNamespaceId,
|
|
17
|
+
import { asNamespaceId, governingControlPolicy } from "@prisma/orm-framework/contract/types";
|
|
18
18
|
import { TsExpression, jsonToTsSource, renderImports } from "@prisma/orm-framework/ts-render";
|
|
19
19
|
import { Migration } from "@prisma/orm-toolchain/migration-tools/migration";
|
|
20
20
|
import { resolveRequirementSpecifiers } from "@prisma/orm-framework/components/emission";
|
|
@@ -399,8 +399,28 @@ function variantFilter(contract, coordinate) {
|
|
|
399
399
|
const value = Object.entries(baseModel?.variants ?? {}).find(([, variant]) => variant.namespace === coordinate.namespaceId && variant.model === coordinate.model)?.[0];
|
|
400
400
|
return field === void 0 || value === void 0 ? void 0 : { [field]: value };
|
|
401
401
|
}
|
|
402
|
+
function declaredCollection(contract, collection) {
|
|
403
|
+
return Object.values(contract.storage.namespaces).map((namespace) => namespace.entries["collection"]?.[collection]).find((entry) => entry instanceof MongoCollection);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* The control policy of `collection`. A collection the contract leaves out keeps the policy `fromContract` gave it, when that was not `managed`, so leaving an `external` collection out of the contract does not drop it.
|
|
407
|
+
*/
|
|
408
|
+
function collectionControlOf(contract, fromContract, collection) {
|
|
409
|
+
const declared = declaredCollection(contract, collection);
|
|
410
|
+
const original = declared === void 0 && fromContract !== null ? declaredCollection(fromContract, collection) : void 0;
|
|
411
|
+
const policy = collectionControlPolicyOf(collection, collectionControlPoliciesOf(contract));
|
|
412
|
+
if (original === void 0 || fromContract === null) return {
|
|
413
|
+
policy,
|
|
414
|
+
declared: declared?.control
|
|
415
|
+
};
|
|
416
|
+
const originalPolicy = governingControlPolicy({ explicitNodeControlPolicy: original.control }, fromContract.defaultControlPolicy);
|
|
417
|
+
return {
|
|
418
|
+
policy: originalPolicy === "managed" ? policy : originalPolicy,
|
|
419
|
+
declared: original.control
|
|
420
|
+
};
|
|
421
|
+
}
|
|
402
422
|
function collectionControlPolicy(contract, collection) {
|
|
403
|
-
return
|
|
423
|
+
return collectionControlOf(contract, null, collection).policy;
|
|
404
424
|
}
|
|
405
425
|
/** Why MongoDB would refuse a collection name, if it would. */
|
|
406
426
|
function invalidCollectionNameReason(name) {
|
|
@@ -428,6 +448,65 @@ function refused(statement, label, reason, why) {
|
|
|
428
448
|
};
|
|
429
449
|
}
|
|
430
450
|
const LEAVE_OUT = "Leave out this statement.";
|
|
451
|
+
const SEPARATE_THE_MODELS = "move the models to separate collections, or carry out the change in a dataTransform operation of a migration.ts, with a filter that selects only their documents";
|
|
452
|
+
/**
|
|
453
|
+
* The discriminator field and value a variant's filter selects, or `undefined` for a filter that selects by anything else, or no filter.
|
|
454
|
+
*/
|
|
455
|
+
function discriminatorValueOf(filter) {
|
|
456
|
+
const entries = Object.entries(filter ?? {});
|
|
457
|
+
if (entries.length !== 1) return void 0;
|
|
458
|
+
const [entry] = entries;
|
|
459
|
+
if (entry === void 0) return void 0;
|
|
460
|
+
const [field, value] = entry;
|
|
461
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? {
|
|
462
|
+
field,
|
|
463
|
+
value
|
|
464
|
+
} : void 0;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* The other models stored in `collection`, root models and their variants, whose documents a change of `storedName` with `filter` reaches, and which store the field themselves or through their base. No discriminator tells the documents of several root models apart, so without a filter, or with a base model's filter, every other root model's documents are reached. A variant's filter, one discriminator value, reaches a model only when its documents can hold that value: a variant of another root model with the same discriminator field and value, or a model that declares the discriminator field itself.
|
|
468
|
+
*/
|
|
469
|
+
function otherModelsReached(contract, model, collection, filter, storedName) {
|
|
470
|
+
const models = contract.domain.namespaces[model.namespaceId]?.models ?? {};
|
|
471
|
+
const baseOf = (name) => {
|
|
472
|
+
const base = models[name]?.base;
|
|
473
|
+
return base === void 0 ? void 0 : models[base.model];
|
|
474
|
+
};
|
|
475
|
+
const storesOrInherits = (name, field) => {
|
|
476
|
+
const each = models[name];
|
|
477
|
+
const base = baseOf(name);
|
|
478
|
+
return each !== void 0 && storesField(each, field) || base !== void 0 && storesField(base, field);
|
|
479
|
+
};
|
|
480
|
+
const selected = discriminatorValueOf(filter);
|
|
481
|
+
const canHold = (name) => {
|
|
482
|
+
if (selected === void 0) return true;
|
|
483
|
+
const base = baseOf(name);
|
|
484
|
+
if (base?.discriminator?.field === selected.field) return Object.entries(base.variants ?? {}).some(([value, variant]) => variant.model === name && value === selected.value);
|
|
485
|
+
return storesOrInherits(name, selected.field);
|
|
486
|
+
};
|
|
487
|
+
const subjectRoot = modelAt(contract, model)?.base?.model ?? model.model;
|
|
488
|
+
return (collectionRootModelsOf(models)[collection] ?? []).filter((name) => name !== subjectRoot).flatMap((name) => [name, ...Object.values(models[name]?.variants ?? {}).map((variant) => variant.model)]).filter((name) => canHold(name) && storesOrInherits(name, storedName));
|
|
489
|
+
}
|
|
490
|
+
function sharedCollectionWhy(collection, others, change) {
|
|
491
|
+
const names = others.map((name) => JSON.stringify(name)).join(", ");
|
|
492
|
+
return `Collection ${JSON.stringify(collection)} stores several models and no discriminator tells their documents apart, so ${change} of ${names} too.`;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* A removal the plan cannot carry out because another root model stored in the same collection still stores the field, and no discriminator selects the documents of the model that loses it.
|
|
496
|
+
*/
|
|
497
|
+
function sharedCollectionRemovalRefusals(removals, contract) {
|
|
498
|
+
return removals.flatMap((removal) => {
|
|
499
|
+
const { subject, call } = removal;
|
|
500
|
+
if (subject.kind !== "field") return [];
|
|
501
|
+
const others = otherModelsReached(contract, subject, call.collection, call.filter, call.field);
|
|
502
|
+
if (others.length === 0) return [];
|
|
503
|
+
return [{
|
|
504
|
+
kind: "fieldRemovalRefused",
|
|
505
|
+
summary: `Cannot remove field ${JSON.stringify(call.field)} of model ${JSON.stringify(subject.model)} from collection ${JSON.stringify(call.collection)}: model ${others.map((name) => JSON.stringify(name)).join(", ")} stores it in the same collection`,
|
|
506
|
+
why: `${sharedCollectionWhy(call.collection, others, "removing the field would remove it from the documents")} To keep it in ${others.map((name) => JSON.stringify(name)).join(", ")} documents only, ${SEPARATE_THE_MODELS}.`
|
|
507
|
+
}];
|
|
508
|
+
});
|
|
509
|
+
}
|
|
431
510
|
const TIME_SERIES_UPDATES = "MongoDB updates the documents of a time-series collection only through its metaField";
|
|
432
511
|
/**
|
|
433
512
|
* A removal the plan cannot carry out because its collection is a time-series collection, whose
|
|
@@ -465,7 +544,14 @@ function planStatements(input) {
|
|
|
465
544
|
renamedCollections.set(outcome.call.from, outcome.call.to);
|
|
466
545
|
collectionRenames.push(outcome.call);
|
|
467
546
|
}
|
|
468
|
-
if (outcome.kind === "renameField")
|
|
547
|
+
if (outcome.kind === "renameField") {
|
|
548
|
+
const same = fieldRenames.find((call) => sameFieldRename(call, outcome.call));
|
|
549
|
+
if (same !== void 0) {
|
|
550
|
+
callOfStatement.push(same);
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
fieldRenames.push(outcome.call);
|
|
554
|
+
}
|
|
469
555
|
callOfStatement.push(outcome.kind === "unchanged" ? void 0 : outcome.call);
|
|
470
556
|
}
|
|
471
557
|
return conflicts.length > 0 ? notOk(conflicts) : ok({
|
|
@@ -475,6 +561,10 @@ function planStatements(input) {
|
|
|
475
561
|
callOfStatement
|
|
476
562
|
});
|
|
477
563
|
}
|
|
564
|
+
/** Whether two field renames rewrite the same documents the same way, as when every root model of a shared collection renames a field together. */
|
|
565
|
+
function sameFieldRename(a, b) {
|
|
566
|
+
return a.collection === b.collection && a.from === b.from && a.to === b.to && JSON.stringify(a.filter) === JSON.stringify(b.filter);
|
|
567
|
+
}
|
|
478
568
|
function renameInSchema(schema, from, to) {
|
|
479
569
|
return new MongoSchemaIR(schema.collections.map((collection) => collection.name === from ? new MongoSchemaCollection({
|
|
480
570
|
name: to,
|
|
@@ -556,7 +646,12 @@ function planFieldStatement(statement, label, renamedCollections, schema, input)
|
|
|
556
646
|
if (schema.collection(collection)?.options?.timeseries !== void 0) return refuse(`collection "${collection}" is a time-series collection`, `${TIME_SERIES_UPDATES}, so a statement cannot move the values of a field in them. Keep the stored name: name the field ${JSON.stringify(statement.from.field)} in the contract (with @map(${JSON.stringify(statement.from.field)}) in PSL), then run this command again without this statement.`);
|
|
557
647
|
const policyRefusal = controlPolicyRefusal(statement, label, input.contract, collection);
|
|
558
648
|
if (policyRefusal !== void 0) return policyRefusal;
|
|
559
|
-
const
|
|
649
|
+
const variant = variantFilter(input.fromContract, statement.from);
|
|
650
|
+
const fromModel = modelAt(input.fromContract, statement.from);
|
|
651
|
+
const renamedTogether = new Set(input.statements.flatMap((other) => other.entity === "field" && other.from.namespaceId === statement.from.namespaceId && other.from.field === statement.from.field && other.to.field === statement.to.field ? [other.from.model] : []));
|
|
652
|
+
const others = otherModelsReached(input.fromContract, statement.from, originCollection, variant, fromModel === void 0 ? statement.from.field : storedFieldNameOf(fromModel, statement.from.field)).filter((name) => !renamedTogether.has(name));
|
|
653
|
+
if (others.length > 0) return refuse(`model ${others.map((name) => JSON.stringify(name)).join(", ")} stores field ${JSON.stringify(statement.from.field)} in the same collection, ${JSON.stringify(collection)}`, `${sharedCollectionWhy(collection, others, "renaming the field would rename it in the documents")} To change it, ${SEPARATE_THE_MODELS}.`);
|
|
654
|
+
const filter = variant ?? rootDocumentsLosing(input.contract, statement.to, statement.from.field)?.filter;
|
|
560
655
|
return {
|
|
561
656
|
kind: "renameField",
|
|
562
657
|
call: new RenameFieldCall(collection, statement.from.field, statement.to.field, filter)
|
|
@@ -664,28 +759,17 @@ function planFieldRemovals(input) {
|
|
|
664
759
|
});
|
|
665
760
|
});
|
|
666
761
|
}
|
|
667
|
-
function isRecord$1(value) {
|
|
668
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
669
|
-
}
|
|
670
|
-
function propertyNames(schema) {
|
|
671
|
-
const properties = isRecord$1(schema) ? schema["properties"] : void 0;
|
|
672
|
-
return isRecord$1(properties) ? Object.keys(properties) : [];
|
|
673
|
-
}
|
|
674
|
-
function branchPropertyNames(schema) {
|
|
675
|
-
const branches = isRecord$1(schema) ? schema["oneOf"] : void 0;
|
|
676
|
-
return Array.isArray(branches) ? branches.flatMap(propertyNames) : [];
|
|
677
|
-
}
|
|
678
762
|
/**
|
|
679
|
-
* Without an origin contract, a field is known removed when the origin validator declares it
|
|
680
|
-
*
|
|
763
|
+
* Without an origin contract, a field is known removed when the origin validator declares it for a
|
|
764
|
+
* root model and the destination validator declares it nowhere. It is named by its storage name.
|
|
681
765
|
*/
|
|
682
766
|
function planValidatorFieldRemovals(input) {
|
|
683
767
|
return input.origin.collections.flatMap((originCollection) => {
|
|
684
768
|
if (collectionControlPolicy(input.contract, originCollection.name) !== "managed") return [];
|
|
685
769
|
const destination = input.destination.collection(originCollection.name);
|
|
686
770
|
if (destination?.validator === void 0 || originCollection.validator === void 0) return [];
|
|
687
|
-
const kept =
|
|
688
|
-
return
|
|
771
|
+
const kept = validatorFieldNamesOf(destination.validator.jsonSchema);
|
|
772
|
+
return [...new Set(validatorRootShapesOf(originCollection.validator.jsonSchema).flatMap((root) => Object.keys(root.properties)))].filter((field) => unrewritableFieldNameReason(field) === void 0 && !kept.has(field)).sort().map((field) => ({
|
|
689
773
|
call: new UnsetFieldCall(originCollection.name, field),
|
|
690
774
|
subject: {
|
|
691
775
|
kind: "storage",
|
|
@@ -852,35 +936,6 @@ var PlannerProducedMongoMigration = class extends Migration {
|
|
|
852
936
|
});
|
|
853
937
|
}
|
|
854
938
|
};
|
|
855
|
-
const SAME_HASH = "the migration would start and end at the same contract hash";
|
|
856
|
-
function why(collection) {
|
|
857
|
-
return `The contract gives collection ${JSON.stringify(collection)} no validator, so the names of its fields are not part of the contract's storage hash; a contract written in TypeScript has none yet. A migration that only renames or removes a field would start and end at the same hash, and db migrate refuses such a migration. Use prisma db update for this change instead: it carries the change out with the same --rename or --delete and writes no migration. Or write the migration by hand: run prisma migration new --from <hash of the migration the database is at>, and carry the change out in a dataTransform operation of its migration.ts, since db migrate accepts a migration that starts and ends at the same hash when it runs a dataTransform.`;
|
|
858
|
-
}
|
|
859
|
-
/**
|
|
860
|
-
* Refuses, for a migration package, each field rename and field removal of a plan whose contract
|
|
861
|
-
* storage hash does not change: the collection has no validator in the contract, so its field
|
|
862
|
-
* names are not in the hash, and `db migrate` refuses a migration that starts and ends at the same
|
|
863
|
-
* hash. `db update` writes no migration and plans without an origin, so it is not refused.
|
|
864
|
-
*/
|
|
865
|
-
function sameHashFieldChangeRefusals(input) {
|
|
866
|
-
if (input.origin === null || input.origin.storageHash !== input.contract.storage.storageHash) return [];
|
|
867
|
-
const renames = input.statements.flatMap((statement, index) => {
|
|
868
|
-
const call = input.callOfStatement[index];
|
|
869
|
-
if (!(call instanceof RenameFieldCall)) return [];
|
|
870
|
-
return [{
|
|
871
|
-
kind: "statementRefused",
|
|
872
|
-
summary: `Cannot ${describeMigrationStatement(statement, input.fromContract, input.contract)}: ${SAME_HASH}`,
|
|
873
|
-
why: why(call.collection),
|
|
874
|
-
refusedStatement: statement
|
|
875
|
-
}];
|
|
876
|
-
});
|
|
877
|
-
const removals = input.removals.map(({ call }) => ({
|
|
878
|
-
kind: "fieldRemovalRefused",
|
|
879
|
-
summary: `Cannot remove field ${JSON.stringify(call.field)} from collection ${JSON.stringify(call.collection)}: ${SAME_HASH}`,
|
|
880
|
-
why: why(call.collection)
|
|
881
|
-
}));
|
|
882
|
-
return [...renames, ...removals];
|
|
883
|
-
}
|
|
884
939
|
function validatorsEqual(a, b) {
|
|
885
940
|
if (!a && !b) return true;
|
|
886
941
|
if (!a || !b) return false;
|
|
@@ -889,8 +944,11 @@ function validatorsEqual(a, b) {
|
|
|
889
944
|
function isPlainObject(v) {
|
|
890
945
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
891
946
|
}
|
|
947
|
+
/** Each field a root model of the validator declares, with the distinct schemas the root models give it, in canonical form. */
|
|
892
948
|
function propertiesOf(schema) {
|
|
893
|
-
|
|
949
|
+
const schemas = /* @__PURE__ */ new Map();
|
|
950
|
+
for (const root of validatorRootShapesOf(schema)) for (const [field, fieldSchema] of Object.entries(root.properties)) schemas.set(field, (schemas.get(field) ?? /* @__PURE__ */ new Set()).add(canonicalize(fieldSchema)));
|
|
951
|
+
return Object.fromEntries([...schemas].map(([field, distinct]) => [field, [...distinct].sort().join("|")]));
|
|
894
952
|
}
|
|
895
953
|
/**
|
|
896
954
|
* A label naming the properties whose schema changed, so a dry run shows what a validator update does: `Update validator on items (changed: meta; added: note)`.
|
|
@@ -898,7 +956,7 @@ function propertiesOf(schema) {
|
|
|
898
956
|
function validatorUpdateLabel(collName, origin, dest) {
|
|
899
957
|
const originProps = propertiesOf(origin.jsonSchema);
|
|
900
958
|
const destProps = propertiesOf(dest.jsonSchema);
|
|
901
|
-
const changed = Object.keys(destProps).filter((field) => Object.hasOwn(originProps, field) &&
|
|
959
|
+
const changed = Object.keys(destProps).filter((field) => Object.hasOwn(originProps, field) && originProps[field] !== destProps[field]);
|
|
902
960
|
const added = Object.keys(destProps).filter((field) => !Object.hasOwn(originProps, field));
|
|
903
961
|
const removed = Object.keys(originProps).filter((field) => !Object.hasOwn(destProps, field));
|
|
904
962
|
const parts = [
|
|
@@ -1011,6 +1069,72 @@ function modelStoredInDestination(contract, model) {
|
|
|
1011
1069
|
const namespace = contract.domain.namespaces[model.namespaceId];
|
|
1012
1070
|
return namespace !== void 0 && Object.hasOwn(namespace.models, model.model) ? collectionOf(contract, model) : void 0;
|
|
1013
1071
|
}
|
|
1072
|
+
function callsOf(diff) {
|
|
1073
|
+
return [
|
|
1074
|
+
...diff.collCreates,
|
|
1075
|
+
...diff.drops,
|
|
1076
|
+
...diff.creates,
|
|
1077
|
+
...diff.validatorOps,
|
|
1078
|
+
...diff.mutableOptionOps,
|
|
1079
|
+
...diff.collDrops
|
|
1080
|
+
];
|
|
1081
|
+
}
|
|
1082
|
+
function planCollectionDiff(collName, originColl, destColl) {
|
|
1083
|
+
const collCreates = [];
|
|
1084
|
+
const drops = [];
|
|
1085
|
+
const creates = [];
|
|
1086
|
+
const validatorOps = [];
|
|
1087
|
+
const mutableOptionOps = [];
|
|
1088
|
+
const collDrops = [];
|
|
1089
|
+
const conflicts = [];
|
|
1090
|
+
if (!originColl) {
|
|
1091
|
+
if (destColl && (collectionHasOptions(destColl) || destColl.indexes.length === 0)) {
|
|
1092
|
+
const opts = collectionHasOptions(destColl) ? schemaCollectionToCreateCollectionOptions(destColl) : void 0;
|
|
1093
|
+
collCreates.push(new CreateCollectionCall(collName, opts));
|
|
1094
|
+
}
|
|
1095
|
+
} else if (!destColl) collDrops.push(new DropCollectionCall(collName));
|
|
1096
|
+
else {
|
|
1097
|
+
const immutableChange = hasImmutableOptionChange(originColl.options, destColl.options);
|
|
1098
|
+
if (immutableChange) conflicts.push({
|
|
1099
|
+
kind: "policy-violation",
|
|
1100
|
+
summary: `Cannot change immutable collection option '${immutableChange}' on ${collName}`,
|
|
1101
|
+
why: `MongoDB does not support modifying the '${immutableChange}' option after collection creation`
|
|
1102
|
+
});
|
|
1103
|
+
const mutableCall = planMutableOptionsDiffCall(collName, originColl.options, destColl.options);
|
|
1104
|
+
if (mutableCall) mutableOptionOps.push(mutableCall);
|
|
1105
|
+
const validatorCall = planValidatorDiffCall(collName, originColl.validator, destColl.validator);
|
|
1106
|
+
if (validatorCall) validatorOps.push(validatorCall);
|
|
1107
|
+
}
|
|
1108
|
+
const originLookup = /* @__PURE__ */ new Map();
|
|
1109
|
+
if (originColl) for (const idx of originColl.indexes) originLookup.set(indexLookupKey(idx), idx);
|
|
1110
|
+
const destLookup = /* @__PURE__ */ new Map();
|
|
1111
|
+
if (destColl) for (const idx of destColl.indexes) destLookup.set(indexLookupKey(idx), idx);
|
|
1112
|
+
for (const [lookupKey, idx] of originLookup) if (!destLookup.has(lookupKey)) drops.push(new DropIndexCall(collName, idx.keys));
|
|
1113
|
+
for (const [lookupKey, idx] of destLookup) if (!originLookup.has(lookupKey)) creates.push(new CreateIndexCall(collName, idx.keys, schemaIndexToCreateIndexOptions(idx)));
|
|
1114
|
+
return {
|
|
1115
|
+
collCreates,
|
|
1116
|
+
drops,
|
|
1117
|
+
creates,
|
|
1118
|
+
validatorOps,
|
|
1119
|
+
mutableOptionOps,
|
|
1120
|
+
collDrops,
|
|
1121
|
+
conflicts
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* The warning for a change a collection's control policy left out of the plan, worded as the Postgres planner words a suppressed call.
|
|
1126
|
+
*/
|
|
1127
|
+
function suppressedCallWarning(call, collection, control) {
|
|
1128
|
+
const declared = control.declared !== void 0 && control.declared !== control.policy ? ` but declared '${control.declared}'` : "";
|
|
1129
|
+
return {
|
|
1130
|
+
kind: "controlPolicySuppressedCall",
|
|
1131
|
+
summary: `control policy suppressed: ${call.label} — collection "${collection}" has effective control '${control.policy}'${declared}`,
|
|
1132
|
+
meta: {
|
|
1133
|
+
controlPolicy: control.policy,
|
|
1134
|
+
...ifDefined("declaredControlPolicy", control.declared)
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1014
1138
|
var MongoMigrationPlanner = class {
|
|
1015
1139
|
planCalls(options) {
|
|
1016
1140
|
const contract = blindCast(options.contract);
|
|
@@ -1023,34 +1147,23 @@ var MongoMigrationPlanner = class {
|
|
|
1023
1147
|
const mutableOptionOps = [];
|
|
1024
1148
|
const collDrops = [];
|
|
1025
1149
|
const conflicts = [];
|
|
1150
|
+
const warnings = [];
|
|
1026
1151
|
const allCollectionNames = /* @__PURE__ */ new Set([...originIR.collectionNames, ...destinationIR.collectionNames]);
|
|
1027
1152
|
for (const collName of [...allCollectionNames].sort()) {
|
|
1028
1153
|
const originColl = originIR.collection(collName);
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
}
|
|
1035
|
-
} else if (!destColl) collDrops.push(new DropCollectionCall(collName));
|
|
1036
|
-
else {
|
|
1037
|
-
const immutableChange = hasImmutableOptionChange(originColl.options, destColl.options);
|
|
1038
|
-
if (immutableChange) conflicts.push({
|
|
1039
|
-
kind: "policy-violation",
|
|
1040
|
-
summary: `Cannot change immutable collection option '${immutableChange}' on ${collName}`,
|
|
1041
|
-
why: `MongoDB does not support modifying the '${immutableChange}' option after collection creation`
|
|
1042
|
-
});
|
|
1043
|
-
const mutableCall = planMutableOptionsDiffCall(collName, originColl.options, destColl.options);
|
|
1044
|
-
if (mutableCall) mutableOptionOps.push(mutableCall);
|
|
1045
|
-
const validatorCall = planValidatorDiffCall(collName, originColl.validator, destColl.validator);
|
|
1046
|
-
if (validatorCall) validatorOps.push(validatorCall);
|
|
1154
|
+
const planned = planCollectionDiff(collName, originColl, destinationIR.collection(collName));
|
|
1155
|
+
const control = collectionControlOf(contract, options.fromContract, collName);
|
|
1156
|
+
if (!plansChangesTo(control.policy, originColl !== void 0)) {
|
|
1157
|
+
warnings.push(...callsOf(planned).map((call) => suppressedCallWarning(call, collName, control)));
|
|
1158
|
+
continue;
|
|
1047
1159
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1160
|
+
collCreates.push(...planned.collCreates);
|
|
1161
|
+
drops.push(...planned.drops);
|
|
1162
|
+
creates.push(...planned.creates);
|
|
1163
|
+
validatorOps.push(...planned.validatorOps);
|
|
1164
|
+
mutableOptionOps.push(...planned.mutableOptionOps);
|
|
1165
|
+
collDrops.push(...planned.collDrops);
|
|
1166
|
+
conflicts.push(...planned.conflicts);
|
|
1054
1167
|
}
|
|
1055
1168
|
if (conflicts.length > 0) return {
|
|
1056
1169
|
kind: "failure",
|
|
@@ -1078,7 +1191,8 @@ var MongoMigrationPlanner = class {
|
|
|
1078
1191
|
};
|
|
1079
1192
|
return {
|
|
1080
1193
|
kind: "success",
|
|
1081
|
-
calls: allCalls
|
|
1194
|
+
calls: allCalls,
|
|
1195
|
+
warnings
|
|
1082
1196
|
};
|
|
1083
1197
|
}
|
|
1084
1198
|
plan(options) {
|
|
@@ -1115,14 +1229,7 @@ var MongoMigrationPlanner = class {
|
|
|
1115
1229
|
collectionAfterRenames: (collection) => renamedTo.get(collection) ?? collection,
|
|
1116
1230
|
keptCollections: new Set(schema.collectionNames.filter((name) => destinationIR.collection(name) !== void 0))
|
|
1117
1231
|
});
|
|
1118
|
-
const removalRefusals = [...timeSeriesRemovalRefusals(removals, schema), ...
|
|
1119
|
-
origin: options.origin,
|
|
1120
|
-
fromContract: fromContract ?? contract,
|
|
1121
|
-
contract,
|
|
1122
|
-
statements: renames,
|
|
1123
|
-
callOfStatement,
|
|
1124
|
-
removals
|
|
1125
|
-
})];
|
|
1232
|
+
const removalRefusals = [...timeSeriesRemovalRefusals(removals, schema), ...sharedCollectionRemovalRefusals(removals, contract)];
|
|
1126
1233
|
if (removalRefusals.length > 0) return {
|
|
1127
1234
|
kind: "failure",
|
|
1128
1235
|
conflicts: removalRefusals
|
|
@@ -1136,7 +1243,7 @@ var MongoMigrationPlanner = class {
|
|
|
1136
1243
|
}
|
|
1137
1244
|
});
|
|
1138
1245
|
if (result.kind === "failure") return result;
|
|
1139
|
-
const { calls } = result;
|
|
1246
|
+
const { calls, warnings } = result;
|
|
1140
1247
|
const fieldLoss = removals.map((removal) => ({
|
|
1141
1248
|
operationIndex: calls.indexOf(removal.call),
|
|
1142
1249
|
subject: removal.subject,
|
|
@@ -1161,7 +1268,8 @@ var MongoMigrationPlanner = class {
|
|
|
1161
1268
|
destination: destinationIR
|
|
1162
1269
|
}), ...fieldLoss].sort((a, b) => a.operationIndex - b.operationIndex),
|
|
1163
1270
|
accessWidening: [],
|
|
1164
|
-
temporaryValues: []
|
|
1271
|
+
temporaryValues: [],
|
|
1272
|
+
...warnings.length > 0 ? { warnings } : {}
|
|
1165
1273
|
};
|
|
1166
1274
|
}
|
|
1167
1275
|
/**
|
|
@@ -1180,6 +1288,14 @@ var MongoMigrationPlanner = class {
|
|
|
1180
1288
|
}, context.snapshotsImportPath);
|
|
1181
1289
|
}
|
|
1182
1290
|
};
|
|
1291
|
+
function plansChangesTo(policy, collectionExists) {
|
|
1292
|
+
switch (policy) {
|
|
1293
|
+
case "managed": return true;
|
|
1294
|
+
case "tolerated": return !collectionExists;
|
|
1295
|
+
case "external":
|
|
1296
|
+
case "observed": return false;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1183
1299
|
function planValidatorDiffCall(collName, originValidator, destValidator) {
|
|
1184
1300
|
if (validatorsEqual(originValidator, destValidator)) return void 0;
|
|
1185
1301
|
if (destValidator) return new CollModCall(collName, {
|
|
@@ -2244,4 +2360,4 @@ const mongoTargetDescriptor = {
|
|
|
2244
2360
|
//#endregion
|
|
2245
2361
|
export { schemaIndexToCreateIndexOptions as C, schemaCollectionToCreateCollectionOptions as S, deserializeMongoOp as _, DropIndexCall as a, renderCallsToTypeScript as b, MongoMigrationRunner as c, MongoTargetSchemaVerifier as d, MongoTargetUnboundDatabase as f, UnsetFieldCall as g, RenameFieldCall as h, DropCollectionCall as i, MongoTargetContractSerializer as l, RenameCollectionCall as m, CreateCollectionCall as n, FilterEvaluator as o, PlannerProducedMongoMigration as p, CreateIndexCall as r, MongoMigrationPlanner as s, CollModCall as t, MongoTargetDatabase as u, deserializeMongoOps as v, serializeMongoOps as w, renderOps as x, mongoTargetDescriptor as y };
|
|
2246
2362
|
|
|
2247
|
-
//# sourceMappingURL=control-
|
|
2363
|
+
//# sourceMappingURL=control-8KJTXiJ_.mjs.map
|