@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.
@@ -32,7 +32,7 @@ const mongoStringCodec = mongoCodec({
32
32
  });
33
33
  const mongoDoubleCodec = mongoCodec({
34
34
  typeId: MONGO_DOUBLE_CODEC_ID,
35
- targetTypes: ["float"],
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-9xSaT_DN.mjs.map
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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,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"}
@@ -1,10 +1,8 @@
1
1
  import { Db, Document, MongoClient } from "mongodb";
2
- import { initMarker, readMarker, updateMarker, writeLedgerEntry } from "@prisma-next/target-mongo/control";
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 { ControlAdapterDescriptor, ControlDriverInstance, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerResult, MigrationRunner, MigrationRunnerExecutionChecks, MigrationRunnerResult } from "@prisma-next/framework-components/control";
6
- import { MongoContract } from "@prisma-next/mongo-contract";
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/mongo-ops-serializer.d.ts
42
- declare function deserializeMongoOps(json: readonly unknown[]): MongoMigrationPlanOperation[];
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, MongoMigrationPlanner, MongoMigrationRunner, contractToMongoSchemaIR, createMongoControlDriver, mongoAdapterDescriptor as default, deserializeMongoOps, formatMongoOperations, initMarker, introspectSchema, readMarker, serializeMongoOps, updateMarker, writeLedgerEntry };
39
+ export { MongoCommandExecutor, type MongoControlDriverInstance, MongoInspectionExecutor, createMongoControlDriver, createMongoRunnerDeps, mongoAdapterDescriptor as default, introspectSchema };
79
40
  //# sourceMappingURL=control.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/command-executor.ts","../src/core/contract-to-schema.ts","../src/core/ddl-formatter.ts","../src/core/introspect-schema.ts","../src/core/mongo-control-driver.ts","../src/core/mongo-ops-serializer.ts","../src/core/mongo-planner.ts","../src/core/mongo-runner.ts","../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAca,oBAAA,YAAgC,uBAAuB;;kBACjC;mBAEV,qBAAqB;iBAmBvB,mBAAmB;wBAIZ,0BAA0B;sBAgB5B,wBAAwB;EA1CvC,OAAA,CAAA,GAAA,EA8CQ,cA9Ca,CAAA,EA8CI,OA9CJ,CAAA,IAAA,CAAA;;AACC,cAwDtB,uBAAA,YAAmC,6BAxDb,CAwD2C,OAxD3C,CAwDmD,QAxDnD,EAAA,CAAA,CAAA,CAAA;EAEV,iBAAA,EAAA;EAAqB,WAAA,CAAA,EAAA,EAuDX,EAvDW;EAmBvB,WAAA,CAAA,GAAA,EAsCE,kBAtCF,CAAA,EAsCuB,OAtCvB,CAsC+B,QAtC/B,EAAA,CAAA;EAAmB,eAAA,CAAA,IAAA,EAiDZ,sBAjDY,CAAA,EAiDa,OAjDb,CAiDqB,QAjDrB,EAAA,CAAA;;;;iBCgB1B,uBAAA,WAAkC,uBAAuB;;;iBC6CzD,qBAAA,sBAA2C;;;iBCXrC,gBAAA,KAAqB,KAAK,QAAQ;;;UCnFvC,0BAAA,SAAmC;eACrC;;iBAuBC,wBAAA,KAA6B,YAAY,cAAc;;;iBCiPvD,mBAAA,4BAA+C;iBAI/C,iBAAA,eAAgC;;;cCiFnC,qBAAA,YAAiC;;;;qBAIzB;kCACa,cAAc;MAC1C;ANzVN;;;cO0Ca,oBAAA,YAAgC;;mBAE1B;qBACE;;qBAEA;;MP/CR,gBAAqB,EAAA,EAAA,EOiDN,sBPjDM,CAAA,EAAA,IAAA;MAAkC,mBAAA,EAAA,EAAA,EOkDrC,sBPlDqC,CAAA,EAAA,IAAA;IACjC,CAAA;IAEV,SAAA,eAAA,CAAA,EOiDM,8BPjDN;IAAqB,SAAA,mBAAA,EOkDZ,aPlDY,COkDE,8BPlDF,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA;EAmBvB,CAAA,CAAA,EOgCjB,OPhCiB,COgCT,qBPhCS,CAAA;EAAmB,QAAA,cAAA;EAIZ,QAAA,kBAAA;EAA0B,QAAA,0BAAA;EAgB5B,QAAA,yBAAA;;;;cQ1BtB,sBRhB8D,EQgBtC,wBRhBsC,CAAA,OAAA,EAAA,OAAA,CAAA"}
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"}