@prisma-next/adapter-mongo 0.4.0-dev.1 → 0.4.0-dev.3
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/{codecs-9xSaT_DN.mjs → codecs-DGN3pWRt.mjs} +2 -2
- package/dist/codecs-DGN3pWRt.mjs.map +1 -0
- package/dist/control.d.mts +6 -45
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +30 -795
- package/dist/control.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +14 -14
- package/src/core/codecs.ts +1 -1
- package/src/core/runner-deps.ts +37 -0
- package/src/exports/control.ts +9 -11
- package/dist/codecs-9xSaT_DN.mjs.map +0 -1
- package/src/core/contract-to-schema.ts +0 -63
- package/src/core/ddl-formatter.ts +0 -112
- package/src/core/filter-evaluator.ts +0 -84
- package/src/core/mongo-ops-serializer.ts +0 -275
- package/src/core/mongo-planner.ts +0 -470
- package/src/core/mongo-runner.ts +0 -277
|
@@ -32,7 +32,7 @@ const mongoStringCodec = mongoCodec({
|
|
|
32
32
|
});
|
|
33
33
|
const mongoDoubleCodec = mongoCodec({
|
|
34
34
|
typeId: MONGO_DOUBLE_CODEC_ID,
|
|
35
|
-
targetTypes: ["
|
|
35
|
+
targetTypes: ["double"],
|
|
36
36
|
traits: [
|
|
37
37
|
"equality",
|
|
38
38
|
"order",
|
|
@@ -82,4 +82,4 @@ const mongoVectorCodec = mongoCodec({
|
|
|
82
82
|
|
|
83
83
|
//#endregion
|
|
84
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-
|
|
85
|
+
//# sourceMappingURL=codecs-DGN3pWRt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/control.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Db, Document, MongoClient } from "mongodb";
|
|
2
|
-
import {
|
|
3
|
-
import { CollModCommand, CreateCollectionCommand, CreateIndexCommand, DropCollectionCommand, DropIndexCommand, ListCollectionsCommand, ListIndexesCommand, MongoDdlCommandVisitor, MongoInspectionCommandVisitor, MongoMigrationPlanOperation } from "@prisma-next/mongo-query-ast/control";
|
|
2
|
+
import { CollModCommand, CreateCollectionCommand, CreateIndexCommand, DropCollectionCommand, DropIndexCommand, ListCollectionsCommand, ListIndexesCommand, MongoDdlCommandVisitor, MongoInspectionCommandVisitor } from "@prisma-next/mongo-query-ast/control";
|
|
4
3
|
import { MongoSchemaIR } from "@prisma-next/mongo-schema-ir";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
4
|
+
import { MongoRunnerDependencies } from "@prisma-next/target-mongo/control";
|
|
5
|
+
import { ControlAdapterDescriptor, ControlDriverInstance } from "@prisma-next/framework-components/control";
|
|
8
6
|
|
|
9
7
|
//#region src/core/command-executor.d.ts
|
|
10
8
|
declare class MongoCommandExecutor implements MongoDdlCommandVisitor<Promise<void>> {
|
|
@@ -23,12 +21,6 @@ declare class MongoInspectionExecutor implements MongoInspectionCommandVisitor<P
|
|
|
23
21
|
listCollections(_cmd: ListCollectionsCommand): Promise<Document[]>;
|
|
24
22
|
}
|
|
25
23
|
//#endregion
|
|
26
|
-
//#region src/core/contract-to-schema.d.ts
|
|
27
|
-
declare function contractToMongoSchemaIR(contract: MongoContract | null): MongoSchemaIR;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/core/ddl-formatter.d.ts
|
|
30
|
-
declare function formatMongoOperations(operations: readonly MigrationPlanOperation[]): string[];
|
|
31
|
-
//#endregion
|
|
32
24
|
//#region src/core/introspect-schema.d.ts
|
|
33
25
|
declare function introspectSchema(db: Db): Promise<MongoSchemaIR>;
|
|
34
26
|
//#endregion
|
|
@@ -38,42 +30,11 @@ interface MongoControlDriverInstance extends ControlDriverInstance<'mongo', 'mon
|
|
|
38
30
|
}
|
|
39
31
|
declare function createMongoControlDriver(db: Db, client: MongoClient): MongoControlDriverInstance;
|
|
40
32
|
//#endregion
|
|
41
|
-
//#region src/core/
|
|
42
|
-
declare function
|
|
43
|
-
declare function serializeMongoOps(ops: readonly MongoMigrationPlanOperation[]): string;
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/core/mongo-planner.d.ts
|
|
46
|
-
declare class MongoMigrationPlanner implements MigrationPlanner<'mongo', 'mongo'> {
|
|
47
|
-
plan(options: {
|
|
48
|
-
readonly contract: unknown;
|
|
49
|
-
readonly schema: unknown;
|
|
50
|
-
readonly policy: MigrationOperationPolicy;
|
|
51
|
-
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'mongo', 'mongo'>>;
|
|
52
|
-
}): MigrationPlannerResult;
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/core/mongo-runner.d.ts
|
|
56
|
-
declare class MongoMigrationRunner implements MigrationRunner<'mongo', 'mongo'> {
|
|
57
|
-
execute(options: {
|
|
58
|
-
readonly plan: MigrationPlan;
|
|
59
|
-
readonly driver: ControlDriverInstance<'mongo', 'mongo'>;
|
|
60
|
-
readonly destinationContract: unknown;
|
|
61
|
-
readonly policy: MigrationOperationPolicy;
|
|
62
|
-
readonly callbacks?: {
|
|
63
|
-
onOperationStart?(op: MigrationPlanOperation): void;
|
|
64
|
-
onOperationComplete?(op: MigrationPlanOperation): void;
|
|
65
|
-
};
|
|
66
|
-
readonly executionChecks?: MigrationRunnerExecutionChecks;
|
|
67
|
-
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'mongo', 'mongo'>>;
|
|
68
|
-
}): Promise<MigrationRunnerResult>;
|
|
69
|
-
private evaluateChecks;
|
|
70
|
-
private allChecksSatisfied;
|
|
71
|
-
private enforcePolicyCompatibility;
|
|
72
|
-
private ensureMarkerCompatibility;
|
|
73
|
-
}
|
|
33
|
+
//#region src/core/runner-deps.d.ts
|
|
34
|
+
declare function createMongoRunnerDeps(driver: ControlDriverInstance<'mongo', 'mongo'>): MongoRunnerDependencies;
|
|
74
35
|
//#endregion
|
|
75
36
|
//#region src/exports/control.d.ts
|
|
76
37
|
declare const mongoAdapterDescriptor: ControlAdapterDescriptor<'mongo', 'mongo'>;
|
|
77
38
|
//#endregion
|
|
78
|
-
export { MongoCommandExecutor, type MongoControlDriverInstance, MongoInspectionExecutor,
|
|
39
|
+
export { MongoCommandExecutor, type MongoControlDriverInstance, MongoInspectionExecutor, createMongoControlDriver, createMongoRunnerDeps, mongoAdapterDescriptor as default, introspectSchema };
|
|
79
40
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/command-executor.ts","../src/core/
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/command-executor.ts","../src/core/introspect-schema.ts","../src/core/mongo-control-driver.ts","../src/core/runner-deps.ts","../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;;;;;cAca,oBAAA,YAAgC,uBAAuB;;kBACjC;mBAEV,qBAAqB;iBAmBvB,mBAAmB;EAtB7B,gBAAA,CAAA,GAAA,EA0BiB,uBA1BI,CAAA,EA0BsB,OA1BtB,CAAA,IAAA,CAAA;EAAkC,cAAA,CAAA,GAAA,EA0CxC,qBA1CwC,CAAA,EA0ChB,OA1CgB,CAAA,IAAA,CAAA;EACjC,OAAA,CAAA,GAAA,EA6Cd,cA7Cc,CAAA,EA6CG,OA7CH,CAAA,IAAA,CAAA;;AAEW,cAsDjC,uBAAA,YAAmC,6BAtDF,CAsDgC,OAtDhC,CAsDwC,QAtDxC,EAAA,CAAA,CAAA,CAAA;EAmBvB,iBAAA,EAAA;EAAmB,WAAA,CAAA,EAAA,EAoCP,EApCO;EAIZ,WAAA,CAAA,GAAA,EAkCL,kBAlCK,CAAA,EAkCgB,OAlChB,CAkCwB,QAlCxB,EAAA,CAAA;EAA0B,eAAA,CAAA,IAAA,EA6C1B,sBA7C0B,CAAA,EA6CD,OA7CC,CA6CO,QA7CP,EAAA,CAAA;;;;iBC8ClC,gBAAA,KAAqB,KAAK,QAAQ;;;UCnFvC,0BAAA,SAAmC;eACrC;;iBAuBC,wBAAA,KAA6B,YAAY,cAAc;;;iBCLvD,qBAAA,SACN,0CACP;;;cCJG,wBAAwB"}
|