@prisma-next/adapter-mongo 0.4.0-dev.7 → 0.4.0-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,85 +0,0 @@
1
- import { mongoCodec } from "@prisma-next/mongo-codec";
2
- import { ObjectId } from "mongodb";
3
-
4
- //#region src/core/codec-ids.ts
5
- const MONGO_OBJECTID_CODEC_ID = "mongo/objectId@1";
6
- const MONGO_STRING_CODEC_ID = "mongo/string@1";
7
- const MONGO_DOUBLE_CODEC_ID = "mongo/double@1";
8
- const MONGO_INT32_CODEC_ID = "mongo/int32@1";
9
- const MONGO_BOOLEAN_CODEC_ID = "mongo/bool@1";
10
- const MONGO_DATE_CODEC_ID = "mongo/date@1";
11
- const MONGO_VECTOR_CODEC_ID = "mongo/vector@1";
12
-
13
- //#endregion
14
- //#region src/core/codecs.ts
15
- const mongoObjectIdCodec = mongoCodec({
16
- typeId: MONGO_OBJECTID_CODEC_ID,
17
- targetTypes: ["objectId"],
18
- traits: ["equality"],
19
- decode: (wire) => wire.toHexString(),
20
- encode: (value) => new ObjectId(value)
21
- });
22
- const mongoStringCodec = mongoCodec({
23
- typeId: MONGO_STRING_CODEC_ID,
24
- targetTypes: ["string"],
25
- traits: [
26
- "equality",
27
- "order",
28
- "textual"
29
- ],
30
- decode: (wire) => wire,
31
- encode: (value) => value
32
- });
33
- const mongoDoubleCodec = mongoCodec({
34
- typeId: MONGO_DOUBLE_CODEC_ID,
35
- targetTypes: ["double"],
36
- traits: [
37
- "equality",
38
- "order",
39
- "numeric"
40
- ],
41
- decode: (wire) => wire,
42
- encode: (value) => value
43
- });
44
- const mongoInt32Codec = mongoCodec({
45
- typeId: MONGO_INT32_CODEC_ID,
46
- targetTypes: ["int"],
47
- traits: [
48
- "equality",
49
- "order",
50
- "numeric"
51
- ],
52
- decode: (wire) => wire,
53
- encode: (value) => value
54
- });
55
- const mongoBooleanCodec = mongoCodec({
56
- typeId: MONGO_BOOLEAN_CODEC_ID,
57
- targetTypes: ["bool"],
58
- traits: ["equality", "boolean"],
59
- decode: (wire) => wire,
60
- encode: (value) => value
61
- });
62
- const mongoDateCodec = mongoCodec({
63
- typeId: MONGO_DATE_CODEC_ID,
64
- targetTypes: ["date"],
65
- traits: ["equality", "order"],
66
- decode: (wire) => wire,
67
- encode: (value) => value
68
- });
69
- const mongoVectorCodec = mongoCodec({
70
- typeId: MONGO_VECTOR_CODEC_ID,
71
- targetTypes: ["vector"],
72
- traits: ["equality"],
73
- decode: (wire) => wire,
74
- encode: (value) => value,
75
- renderOutputType: (typeParams) => {
76
- const length = typeParams["length"];
77
- if (length === void 0) return void 0;
78
- if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw new Error("renderOutputType: expected positive integer \"length\" for Vector");
79
- return `Vector<${length}>`;
80
- }
81
- });
82
-
83
- //#endregion
84
- export { mongoObjectIdCodec as a, MONGO_INT32_CODEC_ID as c, mongoInt32Codec as i, MONGO_VECTOR_CODEC_ID as l, mongoDateCodec as n, mongoStringCodec as o, mongoDoubleCodec as r, mongoVectorCodec as s, mongoBooleanCodec as t };
85
- //# sourceMappingURL=codecs-DGN3pWRt.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codecs-DGN3pWRt.mjs","names":[],"sources":["../src/core/codec-ids.ts","../src/core/codecs.ts"],"sourcesContent":["export const MONGO_OBJECTID_CODEC_ID = 'mongo/objectId@1' as const;\nexport const MONGO_STRING_CODEC_ID = 'mongo/string@1' as const;\nexport const MONGO_DOUBLE_CODEC_ID = 'mongo/double@1' as const;\nexport const MONGO_INT32_CODEC_ID = 'mongo/int32@1' as const;\nexport const MONGO_BOOLEAN_CODEC_ID = 'mongo/bool@1' as const;\nexport const MONGO_DATE_CODEC_ID = 'mongo/date@1' as const;\nexport const MONGO_VECTOR_CODEC_ID = 'mongo/vector@1' as const;\n","import { mongoCodec } from '@prisma-next/mongo-codec';\nimport { ObjectId } from 'mongodb';\nimport {\n MONGO_BOOLEAN_CODEC_ID,\n MONGO_DATE_CODEC_ID,\n MONGO_DOUBLE_CODEC_ID,\n MONGO_INT32_CODEC_ID,\n MONGO_OBJECTID_CODEC_ID,\n MONGO_STRING_CODEC_ID,\n MONGO_VECTOR_CODEC_ID,\n} from './codec-ids';\n\nexport const mongoObjectIdCodec = mongoCodec({\n typeId: MONGO_OBJECTID_CODEC_ID,\n targetTypes: ['objectId'],\n traits: ['equality'],\n decode: (wire: ObjectId) => wire.toHexString(),\n encode: (value: string) => new ObjectId(value),\n});\n\nexport const mongoStringCodec = mongoCodec({\n typeId: MONGO_STRING_CODEC_ID,\n targetTypes: ['string'],\n traits: ['equality', 'order', 'textual'],\n decode: (wire: string) => wire,\n encode: (value: string) => value,\n});\n\nexport const mongoDoubleCodec = mongoCodec({\n typeId: MONGO_DOUBLE_CODEC_ID,\n targetTypes: ['double'],\n traits: ['equality', 'order', 'numeric'],\n decode: (wire: number) => wire,\n encode: (value: number) => value,\n});\n\nexport const mongoInt32Codec = mongoCodec({\n typeId: MONGO_INT32_CODEC_ID,\n targetTypes: ['int'],\n traits: ['equality', 'order', 'numeric'],\n decode: (wire: number) => wire,\n encode: (value: number) => value,\n});\n\nexport const mongoBooleanCodec = mongoCodec({\n typeId: MONGO_BOOLEAN_CODEC_ID,\n targetTypes: ['bool'],\n traits: ['equality', 'boolean'],\n decode: (wire: boolean) => wire,\n encode: (value: boolean) => value,\n});\n\nexport const mongoDateCodec = mongoCodec({\n typeId: MONGO_DATE_CODEC_ID,\n targetTypes: ['date'],\n traits: ['equality', 'order'],\n decode: (wire: Date) => wire,\n encode: (value: Date) => value,\n});\n\nexport const mongoVectorCodec = mongoCodec({\n typeId: MONGO_VECTOR_CODEC_ID,\n targetTypes: ['vector'],\n traits: ['equality'],\n decode: (wire: readonly number[]) => wire,\n encode: (value: readonly number[]) => value,\n renderOutputType: (typeParams) => {\n const length = typeParams['length'];\n if (length === undefined) return undefined;\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error('renderOutputType: expected positive integer \"length\" for Vector');\n }\n return `Vector<${length}>`;\n },\n});\n"],"mappings":";;;;AAAA,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,uBAAuB;AACpC,MAAa,yBAAyB;AACtC,MAAa,sBAAsB;AACnC,MAAa,wBAAwB;;;;ACMrC,MAAa,qBAAqB,WAAW;CAC3C,QAAQ;CACR,aAAa,CAAC,WAAW;CACzB,QAAQ,CAAC,WAAW;CACpB,SAAS,SAAmB,KAAK,aAAa;CAC9C,SAAS,UAAkB,IAAI,SAAS,MAAM;CAC/C,CAAC;AAEF,MAAa,mBAAmB,WAAW;CACzC,QAAQ;CACR,aAAa,CAAC,SAAS;CACvB,QAAQ;EAAC;EAAY;EAAS;EAAU;CACxC,SAAS,SAAiB;CAC1B,SAAS,UAAkB;CAC5B,CAAC;AAEF,MAAa,mBAAmB,WAAW;CACzC,QAAQ;CACR,aAAa,CAAC,SAAS;CACvB,QAAQ;EAAC;EAAY;EAAS;EAAU;CACxC,SAAS,SAAiB;CAC1B,SAAS,UAAkB;CAC5B,CAAC;AAEF,MAAa,kBAAkB,WAAW;CACxC,QAAQ;CACR,aAAa,CAAC,MAAM;CACpB,QAAQ;EAAC;EAAY;EAAS;EAAU;CACxC,SAAS,SAAiB;CAC1B,SAAS,UAAkB;CAC5B,CAAC;AAEF,MAAa,oBAAoB,WAAW;CAC1C,QAAQ;CACR,aAAa,CAAC,OAAO;CACrB,QAAQ,CAAC,YAAY,UAAU;CAC/B,SAAS,SAAkB;CAC3B,SAAS,UAAmB;CAC7B,CAAC;AAEF,MAAa,iBAAiB,WAAW;CACvC,QAAQ;CACR,aAAa,CAAC,OAAO;CACrB,QAAQ,CAAC,YAAY,QAAQ;CAC7B,SAAS,SAAe;CACxB,SAAS,UAAgB;CAC1B,CAAC;AAEF,MAAa,mBAAmB,WAAW;CACzC,QAAQ;CACR,aAAa,CAAC,SAAS;CACvB,QAAQ,CAAC,WAAW;CACpB,SAAS,SAA4B;CACrC,SAAS,UAA6B;CACtC,mBAAmB,eAAe;EAChC,MAAM,SAAS,WAAW;AAC1B,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,SAAS,OAAO,IAAI,CAAC,OAAO,UAAU,OAAO,CACrF,OAAM,IAAI,MAAM,oEAAkE;AAEpF,SAAO,UAAU,OAAO;;CAE3B,CAAC"}