@prisma/orm-mongo 8.0.0-rc.24-dev.27 → 8.0.0-rc.24-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.
Files changed (40) hide show
  1. package/README.md +4 -2
  2. package/dist/components-CWskH7lF-Dkc9ysZz.mjs +18 -0
  3. package/dist/components-CWskH7lF-Dkc9ysZz.mjs.map +1 -0
  4. package/dist/config.mjs +12 -10
  5. package/dist/config.mjs.map +1 -1
  6. package/dist/contract-types.d.mts +3 -0
  7. package/dist/contract-types.mjs +1 -0
  8. package/dist/control.mjs +2 -8
  9. package/dist/control.mjs.map +1 -1
  10. package/dist/init-quick-reference.md +116 -0
  11. package/dist/init-readme.md +35 -0
  12. package/dist/init.d.mts +7 -0
  13. package/dist/init.d.mts.map +1 -0
  14. package/dist/init.mjs +245 -0
  15. package/dist/init.mjs.map +1 -0
  16. package/dist/migration.d.mts +1 -0
  17. package/dist/migration.mjs +2 -0
  18. package/dist/module-base-B70DHaBE-k_c3Klu4.mjs +6 -0
  19. package/dist/module-base-B70DHaBE-k_c3Klu4.mjs.map +1 -0
  20. package/dist/{mongo-static-HTJYAz-i-yiZaZLPj.mjs → mongo-static-DActAfeF-vDjIxfAZ.mjs} +3 -3
  21. package/dist/{mongo-static-HTJYAz-i-yiZaZLPj.mjs.map → mongo-static-DActAfeF-vDjIxfAZ.mjs.map} +1 -1
  22. package/dist/runtime.mjs +1 -1
  23. package/dist/runtime.mjs.map +1 -1
  24. package/dist/static.mjs +1 -1
  25. package/package.json +11 -8
  26. package/skills/prisma-8/SKILL.md +10 -10
  27. package/skills/prisma-8/references/build.md +12 -16
  28. package/skills/prisma-8/references/contract.md +35 -33
  29. package/skills/prisma-8/references/debug.md +5 -3
  30. package/skills/prisma-8/references/feedback.md +8 -8
  31. package/skills/prisma-8/references/migration-model.md +4 -0
  32. package/skills/prisma-8/references/migration-review.md +6 -5
  33. package/skills/prisma-8/references/migrations.md +73 -26
  34. package/skills/prisma-8/references/queries-mongo.md +3 -3
  35. package/skills/prisma-8/references/queries-postgres.md +25 -9
  36. package/skills/prisma-8/references/queries.md +9 -8
  37. package/skills/prisma-8/references/quickstart.md +19 -19
  38. package/skills/prisma-8/references/runtime.md +23 -23
  39. package/skills/prisma-8/references/supabase.md +7 -7
  40. package/skills/prisma-8/references/upgrade-app.md +1 -1
package/README.md CHANGED
@@ -25,12 +25,14 @@ pnpm add @prisma/orm-mongo mongodb
25
25
  | `/runtime` | `mongo(url)` — the lazy query client |
26
26
  | `/static` | statically composed runtime for pre-wired deployments |
27
27
  | `/config` | `defineConfig` for `prisma.config.ts`, and `prisma6Schema` to read a Prisma 6 MongoDB schema as the contract source |
28
+ | `/contract-types` | the types a generated `contract.d.ts` imports |
28
29
  | `/contract-builder` | `defineContract` and Mongo contract authoring |
29
30
  | `/bson` | BSON value helpers (`ObjectId`, `Decimal128`, …) |
30
31
  | `/target`, `/family` | the Mongo target pack and the Mongo family pack |
31
- | `/control` | the control client |
32
+ | `/migration`, `/control` | migration planning and the control client |
33
+ | `/init` | the init contribution `prisma orm init` writes a project from |
32
34
 
33
- Generated contract files import their types from the facade, so an application never has to depend on a package it did not install:
35
+ A generated `contract.d.ts` imports every framework, family and target type it names from `/contract-types`, and a generated `migration.ts` imports from `/migration`: the modules this package's `defineConfig` sets as `contract.typesModule` and `migrations.module`. The facade also forwards the namespaces of the packages it is built from, so an application never has to depend on a package it did not install:
34
36
 
35
37
  | Namespace | Forwards |
36
38
  | --- | --- |
@@ -0,0 +1,18 @@
1
+ import { t as moduleBase } from "./module-base-B70DHaBE-k_c3Klu4.mjs";
2
+ import mongoAdapter from "@prisma/orm-target-mongo/adapter/control";
3
+ import mongoDriver from "@prisma/orm-target-mongo/driver/control";
4
+ import { mongoFamilyDescriptor } from "@prisma/orm-family-mongo/family/control";
5
+ import { mongoTargetDescriptor } from "@prisma/orm-target-mongo/target/control";
6
+ import { restateTypeDeclarations } from "@prisma/orm-framework/target-package-config/type-declarations";
7
+ //#region ../../../3-targets/mongo/9-facade/dist/components-CWskH7lF.mjs
8
+ const contractTypesModule = `${moduleBase}/contract-types`;
9
+ const controlComponents = {
10
+ family: mongoFamilyDescriptor,
11
+ target: restateTypeDeclarations(mongoTargetDescriptor, contractTypesModule),
12
+ adapter: restateTypeDeclarations(mongoAdapter, contractTypesModule),
13
+ driver: mongoDriver
14
+ };
15
+ //#endregion
16
+ export { controlComponents as n, contractTypesModule as t };
17
+
18
+ //# sourceMappingURL=components-CWskH7lF-Dkc9ysZz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components-CWskH7lF-Dkc9ysZz.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/components-CWskH7lF.mjs"],"sourcesContent":["import { t as moduleBase } from \"./module-base-B70DHaBE.mjs\";\nimport mongoAdapter from \"@internal/adapter-mongo/control\";\nimport mongoDriver from \"@internal/driver-mongo/control\";\nimport { mongoFamilyDescriptor } from \"@internal/family-mongo/control\";\nimport { mongoTargetDescriptor } from \"@internal/target-mongo/control\";\nimport { restateTypeDeclarations } from \"@internal/target-package-config/type-declarations\";\n//#region src/config/components.ts\nconst contractTypesModule = `${moduleBase}/contract-types`;\nconst controlComponents = {\n\tfamily: mongoFamilyDescriptor,\n\ttarget: restateTypeDeclarations(mongoTargetDescriptor, contractTypesModule),\n\tadapter: restateTypeDeclarations(mongoAdapter, contractTypesModule),\n\tdriver: mongoDriver\n};\n//#endregion\nexport { controlComponents as n, contractTypesModule as t };\n\n//# sourceMappingURL=components-CWskH7lF.mjs.map"],"mappings":";;;;;;;AAOA,MAAM,sBAAsB,GAAG,WAAW;AAC1C,MAAM,oBAAoB;CACzB,QAAQ;CACR,QAAQ,wBAAwB,uBAAuB,mBAAmB;CAC1E,SAAS,wBAAwB,cAAc,mBAAmB;CAClE,QAAQ;AACT"}
package/dist/config.mjs CHANGED
@@ -1,11 +1,9 @@
1
- import mongoAdapter from "@prisma/orm-target-mongo/adapter/control";
1
+ import { t as moduleBase } from "./module-base-B70DHaBE-k_c3Klu4.mjs";
2
+ import { n as controlComponents, t as contractTypesModule } from "./components-CWskH7lF-Dkc9ysZz.mjs";
2
3
  import { defaultContractOutputPath, defineConfig as defineConfig$1 } from "@prisma/orm-framework/config/config-types";
3
- import mongoDriver from "@prisma/orm-target-mongo/driver/control";
4
- import { mongoFamilyDescriptor } from "@prisma/orm-family-mongo/family/control";
5
4
  import { mongoContract } from "@prisma/orm-family-mongo/contract-psl/provider";
6
5
  import { typescriptContractFromPath } from "@prisma/orm-family-mongo/contract-ts/config-types";
7
6
  import { MONGO_INT32_CODEC_ID, MONGO_STRING_CODEC_ID } from "@prisma/orm-target-mongo/target/codec-ids";
8
- import { mongoTargetDescriptor } from "@prisma/orm-target-mongo/target/control";
9
7
  import mongoTargetPack from "@prisma/orm-target-mongo/target/pack";
10
8
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
11
9
  import { extname, join } from "pathe";
@@ -35,15 +33,19 @@ function resolveContractConfig(options, extensions) {
35
33
  }
36
34
  function defineConfig(options) {
37
35
  const extensions = options.extensions ?? [];
36
+ const contractConfig = resolveContractConfig(options, extensions);
38
37
  return defineConfig$1({
39
- family: mongoFamilyDescriptor,
40
- target: mongoTargetDescriptor,
41
- adapter: mongoAdapter,
42
- driver: mongoDriver,
38
+ ...controlComponents,
43
39
  extensions,
44
- contract: resolveContractConfig(options, extensions),
40
+ contract: {
41
+ ...contractConfig,
42
+ typesModule: contractTypesModule
43
+ },
44
+ migrations: {
45
+ ...options.migrations,
46
+ module: `${moduleBase}/migration`
47
+ },
45
48
  ...ifDefined("db", options.db),
46
- ...ifDefined("migrations", options.migrations),
47
49
  ...ifDefined("formatter", options.formatter)
48
50
  });
49
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/config.mjs"],"sourcesContent":["import mongoAdapter from \"@internal/adapter-mongo/control\";\nimport { defaultContractOutputPath, defineConfig as defineConfig$1 } from \"@internal/config/config-types\";\nimport mongoDriver from \"@internal/driver-mongo/control\";\nimport { mongoFamilyDescriptor } from \"@internal/family-mongo/control\";\nimport { mongoContract } from \"@internal/mongo-contract-psl/provider\";\nimport { typescriptContractFromPath } from \"@internal/mongo-contract-ts/config-types\";\nimport { MONGO_INT32_CODEC_ID, MONGO_STRING_CODEC_ID } from \"@internal/target-mongo/codec-ids\";\nimport { mongoTargetDescriptor } from \"@internal/target-mongo/control\";\nimport mongoTargetPack from \"@internal/target-mongo/pack\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { extname, join } from \"pathe\";\nimport { prisma6Contract } from \"@internal/mongo-contract-prisma6/provider\";\nimport { prisma6MongoBinding } from \"@internal/target-mongo/prisma6-binding\";\n//#region src/config/define-config.ts\nfunction contractConfigFromPath(contractPath, output, extensions) {\n\treturn extname(contractPath) === \".ts\" ? typescriptContractFromPath(contractPath, output) : mongoContract(contractPath, {\n\t\ttarget: mongoTargetPack,\n\t\textensionPacks: Object.fromEntries(extensions.map((extension) => [extension.id, extension])),\n\t\toutput,\n\t\tenumInferenceCodecs: {\n\t\t\ttext: MONGO_STRING_CODEC_ID,\n\t\t\tint: MONGO_INT32_CODEC_ID\n\t\t}\n\t});\n}\nfunction resolveContractConfig(options, extensions) {\n\tconst explicitOutput = options.output !== void 0 ? join(options.output, \"contract.json\") : void 0;\n\tif (typeof options.contract === \"string\") return contractConfigFromPath(options.contract, explicitOutput ?? defaultContractOutputPath(options.contract), extensions);\n\tconst firstInput = options.contract.source.inputs?.[0];\n\tconst output = explicitOutput ?? options.contract.output ?? (firstInput !== void 0 ? defaultContractOutputPath(firstInput) : void 0);\n\treturn {\n\t\t...options.contract,\n\t\t...ifDefined(\"output\", output)\n\t};\n}\nfunction defineConfig(options) {\n\tconst extensions = options.extensions ?? [];\n\treturn defineConfig$1({\n\t\tfamily: mongoFamilyDescriptor,\n\t\ttarget: mongoTargetDescriptor,\n\t\tadapter: mongoAdapter,\n\t\tdriver: mongoDriver,\n\t\textensions,\n\t\tcontract: resolveContractConfig(options, extensions),\n\t\t...ifDefined(\"db\", options.db),\n\t\t...ifDefined(\"migrations\", options.migrations),\n\t\t...ifDefined(\"formatter\", options.formatter)\n\t});\n}\n//#endregion\n//#region src/config/prisma6-schema.ts\n/**\n* Reads a Prisma 6 MongoDB `schema.prisma` (or a directory of `.prisma` files) as the\n* contract source, so Prisma 8 can adopt a database a Prisma 6 application still uses.\n*/\nfunction prisma6Schema(schemaPath) {\n\treturn prisma6Contract(schemaPath, { binding: prisma6MongoBinding });\n}\n//#endregion\nexport { defineConfig, prisma6Schema };\n\n//# sourceMappingURL=config.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,uBAAuB,cAAc,QAAQ,YAAY;CACjE,OAAO,QAAQ,YAAY,MAAM,QAAQ,2BAA2B,cAAc,MAAM,IAAI,cAAc,cAAc;EACvH,QAAQ;EACR,gBAAgB,OAAO,YAAY,WAAW,KAAK,cAAc,CAAC,UAAU,IAAI,SAAS,CAAC,CAAC;EAC3F;EACA,qBAAqB;GACpB,MAAM;GACN,KAAK;EACN;CACD,CAAC;AACF;AACA,SAAS,sBAAsB,SAAS,YAAY;CACnD,MAAM,iBAAiB,QAAQ,WAAW,KAAK,IAAI,KAAK,QAAQ,QAAQ,eAAe,IAAI,KAAK;CAChG,IAAI,OAAO,QAAQ,aAAa,UAAU,OAAO,uBAAuB,QAAQ,UAAU,kBAAkB,0BAA0B,QAAQ,QAAQ,GAAG,UAAU;CACnK,MAAM,aAAa,QAAQ,SAAS,OAAO,SAAS;CACpD,MAAM,SAAS,kBAAkB,QAAQ,SAAS,WAAW,eAAe,KAAK,IAAI,0BAA0B,UAAU,IAAI,KAAK;CAClI,OAAO;EACN,GAAG,QAAQ;EACX,GAAG,UAAU,UAAU,MAAM;CAC9B;AACD;AACA,SAAS,aAAa,SAAS;CAC9B,MAAM,aAAa,QAAQ,cAAc,CAAC;CAC1C,OAAO,eAAe;EACrB,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR;EACA,UAAU,sBAAsB,SAAS,UAAU;EACnD,GAAG,UAAU,MAAM,QAAQ,EAAE;EAC7B,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,aAAa,QAAQ,SAAS;CAC5C,CAAC;AACF;;;;;AAOA,SAAS,cAAc,YAAY;CAClC,OAAO,gBAAgB,YAAY,EAAE,SAAS,oBAAoB,CAAC;AACpE"}
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/config.mjs"],"sourcesContent":["import { t as moduleBase } from \"./module-base-B70DHaBE.mjs\";\nimport { n as controlComponents, t as contractTypesModule } from \"./components-CWskH7lF.mjs\";\nimport { defaultContractOutputPath, defineConfig as defineConfig$1 } from \"@internal/config/config-types\";\nimport { mongoContract } from \"@internal/mongo-contract-psl/provider\";\nimport { typescriptContractFromPath } from \"@internal/mongo-contract-ts/config-types\";\nimport { MONGO_INT32_CODEC_ID, MONGO_STRING_CODEC_ID } from \"@internal/target-mongo/codec-ids\";\nimport mongoTargetPack from \"@internal/target-mongo/pack\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { extname, join } from \"pathe\";\nimport { prisma6Contract } from \"@internal/mongo-contract-prisma6/provider\";\nimport { prisma6MongoBinding } from \"@internal/target-mongo/prisma6-binding\";\n//#region src/config/define-config.ts\nfunction contractConfigFromPath(contractPath, output, extensions) {\n\treturn extname(contractPath) === \".ts\" ? typescriptContractFromPath(contractPath, output) : mongoContract(contractPath, {\n\t\ttarget: mongoTargetPack,\n\t\textensionPacks: Object.fromEntries(extensions.map((extension) => [extension.id, extension])),\n\t\toutput,\n\t\tenumInferenceCodecs: {\n\t\t\ttext: MONGO_STRING_CODEC_ID,\n\t\t\tint: MONGO_INT32_CODEC_ID\n\t\t}\n\t});\n}\nfunction resolveContractConfig(options, extensions) {\n\tconst explicitOutput = options.output !== void 0 ? join(options.output, \"contract.json\") : void 0;\n\tif (typeof options.contract === \"string\") return contractConfigFromPath(options.contract, explicitOutput ?? defaultContractOutputPath(options.contract), extensions);\n\tconst firstInput = options.contract.source.inputs?.[0];\n\tconst output = explicitOutput ?? options.contract.output ?? (firstInput !== void 0 ? defaultContractOutputPath(firstInput) : void 0);\n\treturn {\n\t\t...options.contract,\n\t\t...ifDefined(\"output\", output)\n\t};\n}\nfunction defineConfig(options) {\n\tconst extensions = options.extensions ?? [];\n\tconst contractConfig = resolveContractConfig(options, extensions);\n\treturn defineConfig$1({\n\t\t...controlComponents,\n\t\textensions,\n\t\tcontract: {\n\t\t\t...contractConfig,\n\t\t\ttypesModule: contractTypesModule\n\t\t},\n\t\tmigrations: {\n\t\t\t...options.migrations,\n\t\t\tmodule: `${moduleBase}/migration`\n\t\t},\n\t\t...ifDefined(\"db\", options.db),\n\t\t...ifDefined(\"formatter\", options.formatter)\n\t});\n}\n//#endregion\n//#region src/config/prisma6-schema.ts\n/**\n* Reads a Prisma 6 MongoDB `schema.prisma` (or a directory of `.prisma` files) as the\n* contract source, so Prisma 8 can adopt a database a Prisma 6 application still uses.\n*/\nfunction prisma6Schema(schemaPath) {\n\treturn prisma6Contract(schemaPath, { binding: prisma6MongoBinding });\n}\n//#endregion\nexport { defineConfig, prisma6Schema };\n\n//# sourceMappingURL=config.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,uBAAuB,cAAc,QAAQ,YAAY;CACjE,OAAO,QAAQ,YAAY,MAAM,QAAQ,2BAA2B,cAAc,MAAM,IAAI,cAAc,cAAc;EACvH,QAAQ;EACR,gBAAgB,OAAO,YAAY,WAAW,KAAK,cAAc,CAAC,UAAU,IAAI,SAAS,CAAC,CAAC;EAC3F;EACA,qBAAqB;GACpB,MAAM;GACN,KAAK;EACN;CACD,CAAC;AACF;AACA,SAAS,sBAAsB,SAAS,YAAY;CACnD,MAAM,iBAAiB,QAAQ,WAAW,KAAK,IAAI,KAAK,QAAQ,QAAQ,eAAe,IAAI,KAAK;CAChG,IAAI,OAAO,QAAQ,aAAa,UAAU,OAAO,uBAAuB,QAAQ,UAAU,kBAAkB,0BAA0B,QAAQ,QAAQ,GAAG,UAAU;CACnK,MAAM,aAAa,QAAQ,SAAS,OAAO,SAAS;CACpD,MAAM,SAAS,kBAAkB,QAAQ,SAAS,WAAW,eAAe,KAAK,IAAI,0BAA0B,UAAU,IAAI,KAAK;CAClI,OAAO;EACN,GAAG,QAAQ;EACX,GAAG,UAAU,UAAU,MAAM;CAC9B;AACD;AACA,SAAS,aAAa,SAAS;CAC9B,MAAM,aAAa,QAAQ,cAAc,CAAC;CAC1C,MAAM,iBAAiB,sBAAsB,SAAS,UAAU;CAChE,OAAO,eAAe;EACrB,GAAG;EACH;EACA,UAAU;GACT,GAAG;GACH,aAAa;EACd;EACA,YAAY;GACX,GAAG,QAAQ;GACX,QAAQ,GAAG,WAAW;EACvB;EACA,GAAG,UAAU,MAAM,QAAQ,EAAE;EAC7B,GAAG,UAAU,aAAa,QAAQ,SAAS;CAC5C,CAAC;AACF;;;;;AAOA,SAAS,cAAc,YAAY;CAClC,OAAO,gBAAgB,YAAY,EAAE,SAAS,oBAAoB,CAAC;AACpE"}
@@ -0,0 +1,3 @@
1
+ export * from "@prisma/orm-framework/contract/types";
2
+ export * from "@prisma/orm-family-mongo/contract";
3
+ export * from "@prisma/orm-target-mongo/target/codec-types";
@@ -0,0 +1 @@
1
+ export {};
package/dist/control.mjs CHANGED
@@ -1,16 +1,10 @@
1
- import mongoAdapter from "@prisma/orm-target-mongo/adapter/control";
2
- import mongoDriver from "@prisma/orm-target-mongo/driver/control";
3
- import { mongoFamilyDescriptor } from "@prisma/orm-family-mongo/family/control";
4
- import { mongoTargetDescriptor } from "@prisma/orm-target-mongo/target/control";
1
+ import { n as controlComponents } from "./components-CWskH7lF-Dkc9ysZz.mjs";
5
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
6
3
  import { createControlClient } from "@prisma/orm-toolchain/cli/control-api";
7
4
  //#region ../../../3-targets/mongo/9-facade/dist/control.mjs
8
5
  function createMongoControlClient(options = {}) {
9
6
  return createControlClient({
10
- family: mongoFamilyDescriptor,
11
- target: mongoTargetDescriptor,
12
- adapter: mongoAdapter,
13
- driver: mongoDriver,
7
+ ...controlComponents,
14
8
  ...ifDefined("connection", options.connection),
15
9
  ...ifDefined("extensions", options.extensions)
16
10
  });
@@ -1 +1 @@
1
- {"version":3,"file":"control.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/control.mjs"],"sourcesContent":["import mongoAdapter from \"@internal/adapter-mongo/control\";\nimport mongoDriver from \"@internal/driver-mongo/control\";\nimport { mongoFamilyDescriptor } from \"@internal/family-mongo/control\";\nimport { mongoTargetDescriptor } from \"@internal/target-mongo/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { createControlClient } from \"@internal/cli/control-api\";\n//#region src/exports/control.ts\nfunction createMongoControlClient(options = {}) {\n\treturn createControlClient({\n\t\tfamily: mongoFamilyDescriptor,\n\t\ttarget: mongoTargetDescriptor,\n\t\tadapter: mongoAdapter,\n\t\tdriver: mongoDriver,\n\t\t...ifDefined(\"connection\", options.connection),\n\t\t...ifDefined(\"extensions\", options.extensions)\n\t});\n}\n//#endregion\nexport { createMongoControlClient };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;AAOA,SAAS,yBAAyB,UAAU,CAAC,GAAG;CAC/C,OAAO,oBAAoB;EAC1B,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,cAAc,QAAQ,UAAU;CAC9C,CAAC;AACF"}
1
+ {"version":3,"file":"control.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/control.mjs"],"sourcesContent":["import { n as controlComponents } from \"./components-CWskH7lF.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { createControlClient } from \"@internal/cli/control-api\";\n//#region src/exports/control.ts\nfunction createMongoControlClient(options = {}) {\n\treturn createControlClient({\n\t\t...controlComponents,\n\t\t...ifDefined(\"connection\", options.connection),\n\t\t...ifDefined(\"extensions\", options.extensions)\n\t});\n}\n//#endregion\nexport { createMongoControlClient };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;AAIA,SAAS,yBAAyB,UAAU,CAAC,GAAG;CAC/C,OAAO,oBAAoB;EAC1B,GAAG;EACH,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,cAAc,QAAQ,UAAU;CAC9C,CAAC;AACF"}
@@ -0,0 +1,116 @@
1
+ # Welcome to Prisma ORM!
2
+
3
+ Prisma ORM lets you query your database in simple, easy-to-read TypeScript. Define what your data looks like, and Prisma ORM gives you a fully typed client — with autocomplete for every collection, field, and relation.
4
+
5
+ This project is set up for MongoDB. Prisma ORM also supports other databases.
6
+
7
+ {{requirements}}
8
+
9
+ ## Your data contract
10
+
11
+ Your data contract is the heart of your application. It lives at [`{{schemaPath}}`]({{schemaPath}}) and describes your models:
12
+
13
+ {{schemaSample}}
14
+
15
+ Every model you define in your contract can be queried from your app. Your editor will autocomplete the query methods and show you what type each field is:
16
+
17
+ ```typescript
18
+ import { db } from '{{dbImportPath}}';
19
+
20
+ const user = await db.orm.users
21
+ .where({ email: 'alice@example.com' })
22
+ .first();
23
+
24
+ // Your editor will show the type of user as
25
+ // { id: ObjectId; email: string; username: string | null; name: string | null; posts: Post[] } | null
26
+ ```
27
+
28
+ `db` connects to MongoDB lazily on the first query, so there is no manual `connect(...)` step in your application code. Call `await db.close()` if you need to release the underlying connection (typically only in tests or short-lived scripts). After `close()` the client is single-shot — any further query, `connect()`, or `runtime()` call rejects with `"Mongo client is closed"`. Construct a new `mongo({...})` if you need to use it again.
29
+
30
+ Your contract has two companion files in the same directory:
31
+
32
+ - **`contract.json`** — this tells your application what models exist, just like `package-lock.json` tells your package manager what dependencies your project has
33
+ - **`contract.d.ts`** — this powers autocomplete and type checking in your editor
34
+
35
+ Commit both files to git. When you change your contract, run `{{pkgRun}} contract emit` to update them.
36
+
37
+ If you use a framework like Next.js or Vite, the Prisma ORM plugin will do this for you automatically.
38
+
39
+ ## Configuration
40
+
41
+ [`prisma.config.ts`](prisma.config.ts) tells the CLI where your contract lives and how to connect to your database. It loads environment variables from `.env` automatically:
42
+
43
+ ```typescript
44
+ import 'dotenv/config';
45
+ import { definePrismaConfig } from '@prisma/cli-engine';
46
+ import { defineConfig as ormConfig } from '{{configEntrypoint}}';
47
+
48
+ export default definePrismaConfig({
49
+ orm: ormConfig({
50
+ contract: './{{schemaPath}}',
51
+ db: {
52
+ connection: process.env['DATABASE_URL']!,
53
+ },
54
+ }),
55
+ });
56
+ ```
57
+
58
+ Notice the `DATABASE_URL` above? It's defined in your [`.env`](./.env) file:
59
+
60
+ ```env
61
+ DATABASE_URL="mongodb://localhost:27017/mydb"
62
+ ```
63
+
64
+ You can customize how your environment variables are loaded by changing or removing the `import 'dotenv/config'` line.
65
+
66
+ ## Quick reference
67
+
68
+ ### Commands
69
+
70
+ ```bash
71
+ {{pkgRun}} contract emit # Update contract.json and contract.d.ts
72
+ {{pkgRun}} db init # Create collections in the database
73
+ {{pkgRun}} migration status # Show migration status
74
+ ```
75
+
76
+ ### Files
77
+
78
+ | File | Purpose |
79
+ |---|---|
80
+ | [`{{schemaPath}}`]({{schemaPath}}) | Your data contract — define your models here |
81
+ | [`prisma.config.ts`](prisma.config.ts) | CLI configuration |
82
+ | [`{{schemaDir}}/db.ts`]({{schemaDir}}/db.ts) | Database client — `import { db } from '{{dbImportPath}}'` |
83
+ | `{{schemaDir}}/contract.json` | Compiled contract (generated) |
84
+ | `{{schemaDir}}/contract.d.ts` | Contract types (generated) |
85
+
86
+ ### Workflow
87
+
88
+ 1. Edit [`{{schemaPath}}`]({{schemaPath}}) to add or change models.
89
+ 2. Run `{{pkgRun}} contract emit` to regenerate the contract.
90
+ 3. Query your models — your IDE will autocomplete everything.
91
+
92
+ ## Transactions and change streams (Mongo)
93
+
94
+ Multi-document transactions and change streams require MongoDB to run as a **replica set** — even single-node setups for development. A standalone `mongod` will reject `withTransaction()` at runtime. For local development you have a few options:
95
+
96
+ - **Docker Compose:** start `mongo` with `--replSet rs0` and run `rs.initiate()` once.
97
+ - **`mongodb-memory-server`:** use `MongoMemoryReplSet` instead of `MongoMemoryServer` in tests.
98
+ - **MongoDB Atlas:** every Atlas cluster is already a replica set.
99
+
100
+ The transaction API (`db.transaction(...)`) is on the roadmap and tracked under [TML-2313](https://linear.app/prisma-company/issue/TML-2313/mongo-dev-replica-set-story-is-missing-transactions-change-streams). Prisma ORM's Mongo facade does not expose it yet — until that ticket lands, drive transactions yourself with a raw `MongoClient` using the escape hatch in the next section.
101
+
102
+ ## Escape hatches
103
+
104
+ The ORM covers the common cases. For the rest, two escape hatches are designed in:
105
+
106
+ - **Typed raw aggregations — `db.query`.** The facade exposes `db.query`, a typed builder for aggregation pipelines that runs through the same runtime + middleware + codec stack as `db.orm`. Reach for it when the ORM can't express a `$lookup`/`$facet`/`$graphLookup`/window-function pipeline.
107
+ - **Direct `mongodb` driver control — `mongoClient` binding.** Construct your own `MongoClient` and pass it to `mongo({ contract, mongoClient, dbName })`. Your code keeps the `MongoClient` reference and uses it directly (transactions, change streams, sessions, anything Prisma ORM doesn't surface yet); the same `db` object continues to give you the typed ORM.
108
+
109
+ `db.runtime()` is **not** the escape hatch — it returns the internal executor (`MongoRuntime`), not a `mongodb` `MongoClient` or `Db`. Use `db.query` for raw aggregations and the `mongoClient` binding for direct driver control.
110
+
111
+ ## Monorepo notes (pnpm workspaces)
112
+
113
+ If this project lives inside a pnpm workspace, a few things are worth knowing:
114
+
115
+ - **Catalogs.** When the workspace's `pnpm-workspace.yaml` defines a `catalogs` entry for `prisma` or `{{pkg}}`, pnpm uses the catalog version everywhere — `init` does too. If you wanted the published `latest` instead, update or remove the catalog entry, then re-run `pnpm install`.
116
+ - **`pnpm dlx`.** `pnpm dlx prisma@latest orm init …` works in any directory. Inside a workspace, pnpm still resolves dependencies through the workspace's catalog/overrides rather than the registry; expect the installed Prisma ORM packages to reflect the workspace's catalog rather than `latest`.
@@ -0,0 +1,35 @@
1
+ # {{projectName}}
2
+
3
+ Generated by `prisma orm init` with the Minimal template.
4
+
5
+ ## First run
6
+
7
+ 1. `{{runDbUp}}` — start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
8
+ 2. `{{runDev}}` — runs `src/index.ts`, which writes one row and reads it back.
9
+
10
+ ## Available scripts
11
+
12
+ - `{{runDev}}` — run the Prisma ORM sample script
13
+
14
+ ### Database and migrations
15
+
16
+ - `{{runContractEmit}}` — emit contract artifacts after contract changes
17
+ - `{{runDbUp}}` — start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
18
+ - `{{runDbDown}}` — stop the local MongoDB process (data preserved)
19
+ - `{{runDbReset}}` — stop and wipe `.mongo-data/` for a clean slate
20
+ - `{{runMigrationPlan}}` — create a MongoDB migration plan
21
+ - `{{runMigrate}}` — apply the planned MongoDB migration
22
+ - `{{runDbSeed}}` — insert sample users manually
23
+
24
+ ## Prisma ORM
25
+
26
+ Prisma ORM setup is scaffolded in:
27
+
28
+ - `{{contractPath}}`
29
+ - `prisma.config.ts`
30
+ - `prisma/db.ts`
31
+ - `src/lib/prisma.ts`
32
+
33
+ For provider-specific Prisma ORM reference docs, see `prisma-8.md`. Prisma ORM skills live in the upstream `skills/` directory: https://github.com/prisma/prisma/tree/main/skills.
34
+
35
+ Node-based Prisma ORM projects expect Node.js 24 LTS or newer.
@@ -0,0 +1,7 @@
1
+ import { InitContribution } from "@prisma/orm-toolchain/cli/init-contribution";
2
+ //#region ../../../3-targets/mongo/9-facade/dist/init.d.mts
3
+ //#region src/init/init-contribution.d.ts
4
+ declare const contribution: InitContribution;
5
+ //#endregion
6
+ export { contribution as default };
7
+ //# sourceMappingURL=init.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.mts","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/init.d.mts"],"mappings":";;;cAEc,cAAc"}
package/dist/init.mjs ADDED
@@ -0,0 +1,245 @@
1
+ import { t as moduleBase } from "./module-base-B70DHaBE-k_c3Klu4.mjs";
2
+ import { dirname, join } from "pathe";
3
+ import { MONGO_MIN_SERVER_VERSION } from "@prisma/orm-target-mongo/target/server-version";
4
+ import { readFileSync } from "node:fs";
5
+ //#region ../../../3-targets/mongo/9-facade/dist/init.mjs
6
+ /**
7
+ * The driver's own deadlines, which every 7.x driver honours: `serverSelectionTimeoutMS` for finding
8
+ * a server, `connectTimeoutMS` for opening the connection and its handshake, and `socketTimeoutMS`
9
+ * for a reply, so an unreachable server or a stalled `buildInfo` rejects instead of hanging. Not
10
+ * `timeoutMS`: the driver ignores it from 7.8 on.
11
+ */
12
+ const PROBE_TIMEOUT_MS = 2e4;
13
+ function isModuleNotFound(error) {
14
+ return error instanceof Error && Reflect.get(error, "code") === "ERR_MODULE_NOT_FOUND";
15
+ }
16
+ function causeMessage(error) {
17
+ return error instanceof Error ? error.message : String(error);
18
+ }
19
+ async function probeMongo(databaseUrl, signal, loadDriver = () => import("mongodb")) {
20
+ let mongodb;
21
+ try {
22
+ mongodb = await loadDriver();
23
+ } catch (error) {
24
+ return {
25
+ kind: isModuleNotFound(error) ? "driver-missing" : "driver-failed",
26
+ driver: "mongodb",
27
+ cause: causeMessage(error)
28
+ };
29
+ }
30
+ const client = new mongodb.MongoClient(databaseUrl, {
31
+ serverSelectionTimeoutMS: PROBE_TIMEOUT_MS,
32
+ connectTimeoutMS: PROBE_TIMEOUT_MS,
33
+ socketTimeoutMS: PROBE_TIMEOUT_MS
34
+ });
35
+ const closeOnAbort = () => {
36
+ client.close().catch(() => void 0);
37
+ };
38
+ signal.addEventListener("abort", closeOnAbort, { once: true });
39
+ try {
40
+ await client.connect();
41
+ let buildInfo;
42
+ try {
43
+ buildInfo = await client.db().admin().command({ buildInfo: 1 });
44
+ } catch (error) {
45
+ return {
46
+ kind: "version-unreadable",
47
+ detail: `buildInfo failed: ${causeMessage(error)}`
48
+ };
49
+ }
50
+ const versionString = String(buildInfo["version"] ?? "");
51
+ return versionString.length === 0 ? {
52
+ kind: "version-unreadable",
53
+ detail: "buildInfo did not include a `version` field"
54
+ } : {
55
+ kind: "server-version",
56
+ serverVersion: versionString
57
+ };
58
+ } finally {
59
+ signal.removeEventListener("abort", closeOnAbort);
60
+ await client.close().catch(() => void 0);
61
+ }
62
+ }
63
+ /**
64
+ * Fills each `{{name}}` of the template in one pass, so a value is inserted as it is: a value
65
+ * holding `$&` or another placeholder is not read again.
66
+ */
67
+ function renderTemplate(templateFile, vars) {
68
+ return readFileSync(join(import.meta.dirname, templateFile), "utf-8").replace(/\{\{(\w+)\}\}/g, (placeholder, name) => Object.hasOwn(vars, name) ? vars[name] ?? placeholder : placeholder);
69
+ }
70
+ const configModule = `${moduleBase}/config`;
71
+ const builder = `${moduleBase}/contract-builder`;
72
+ function starterContract(mode) {
73
+ return mode === "typescript" ? starterContractTs() : starterContractPsl();
74
+ }
75
+ function contractSample(mode) {
76
+ return mode === "typescript" ? contractSampleTs() : contractSamplePsl();
77
+ }
78
+ function contractSamplePsl() {
79
+ return `\`\`\`prisma
80
+ model User {
81
+ id ObjectId @id @map("_id")
82
+ email String @unique
83
+ username String?
84
+ name String?
85
+ @@map("users")
86
+ }
87
+ \`\`\``;
88
+ }
89
+ function contractSampleTs() {
90
+ return `\`\`\`typescript
91
+ import { defineContract } from '${builder}';
92
+
93
+ export const contract = defineContract(
94
+ {},
95
+ ({ field, model, type }) => ({
96
+ models: {
97
+ User: model('User', {
98
+ collection: 'users',
99
+ fields: {
100
+ id: field.scalar(type.ObjectId()).mongo({ field: '_id' }),
101
+ email: field.scalar(type.String()),
102
+ username: field.scalar(type.String()).optional(),
103
+ name: field.scalar(type.String()).optional(),
104
+ },
105
+ }),
106
+ },
107
+ }),
108
+ );
109
+ \`\`\``;
110
+ }
111
+ function starterContractPsl() {
112
+ return `// use prisma-8
113
+
114
+ model User {
115
+ id ObjectId @id @map("_id")
116
+ email String @unique
117
+ username String?
118
+ name String?
119
+ posts Post[]
120
+ @@map("users")
121
+ }
122
+
123
+ model Post {
124
+ id ObjectId @id @map("_id")
125
+ title String
126
+ content String?
127
+ author User @relation(fields: [authorId], references: [id])
128
+ authorId ObjectId
129
+ @@map("posts")
130
+ }
131
+ `;
132
+ }
133
+ function starterContractTs() {
134
+ return `import { defineContract } from '${builder}';
135
+
136
+ export const contract = defineContract(
137
+ {},
138
+ ({ field, model, rel, type }) => ({
139
+ models: {
140
+ User: model('User', {
141
+ collection: 'users',
142
+ fields: {
143
+ id: field.scalar(type.ObjectId()).mongo({ field: '_id' }),
144
+ email: field.scalar(type.String()),
145
+ username: field.scalar(type.String()).optional(),
146
+ name: field.scalar(type.String()).optional(),
147
+ },
148
+ relations: {
149
+ posts: rel.hasMany('Post', { from: 'id', to: 'authorId' }),
150
+ },
151
+ }),
152
+
153
+ Post: model('Post', {
154
+ collection: 'posts',
155
+ fields: {
156
+ id: field.scalar(type.ObjectId()).mongo({ field: '_id' }),
157
+ title: field.scalar(type.String()),
158
+ content: field.scalar(type.String()).optional(),
159
+ authorId: field.scalar(type.ObjectId()),
160
+ },
161
+ relations: {
162
+ author: rel.belongsTo('User', { from: 'authorId', to: 'id' }),
163
+ },
164
+ }),
165
+ },
166
+ }),
167
+ );
168
+ `;
169
+ }
170
+ function databaseFile() {
171
+ return `import 'dotenv/config';
172
+ import mongo from '${moduleBase}/runtime';
173
+ import { contractFromJson } from '${moduleBase}/static';
174
+ import type { Contract } from './contract.d.js';
175
+ import contractJson from './contract.json' with { type: 'json' };
176
+
177
+ export const contract = contractFromJson<Contract>(contractJson);
178
+
179
+ export const db = mongo({
180
+ contract,
181
+ url: process.env['DATABASE_URL']!,
182
+ });
183
+ `;
184
+ }
185
+ function envExample() {
186
+ return [
187
+ "# Connection string for MongoDB.",
188
+ `# Requires MongoDB >= ${MONGO_MIN_SERVER_VERSION}.`,
189
+ "",
190
+ "# Standalone local mongod / `docker run mongo:8` — no replica set required for first-run queries.",
191
+ "# Transactions and change streams need a replica set; add ?replicaSet=... only after initiating one.",
192
+ "",
193
+ "DATABASE_URL=\"mongodb://user:password@localhost:27017/mydb\"",
194
+ ""
195
+ ].join("\n");
196
+ }
197
+ function quickReference(input) {
198
+ const schemaDir = dirname(input.schemaPath);
199
+ return renderTemplate("init-quick-reference.md", {
200
+ schemaPath: input.schemaPath,
201
+ schemaDir,
202
+ dbImportPath: `./${schemaDir}/db`,
203
+ pkgRun: input.cliCommand,
204
+ pkg: moduleBase,
205
+ configEntrypoint: configModule,
206
+ schemaSample: contractSample(input.mode),
207
+ requirements: input.requirements
208
+ });
209
+ }
210
+ function readme(input) {
211
+ const run = input.runScript;
212
+ return renderTemplate("init-readme.md", {
213
+ projectName: input.projectName,
214
+ contractPath: input.contractPath,
215
+ runDev: run("dev"),
216
+ runContractEmit: run("contract:emit"),
217
+ runDbUp: run("db:up"),
218
+ runDbDown: run("db:down"),
219
+ runDbReset: run("db:reset"),
220
+ runMigrationPlan: run("migration:plan"),
221
+ runMigrate: run("migrate"),
222
+ runDbSeed: run("db:seed")
223
+ });
224
+ }
225
+ const contribution = {
226
+ label: "MongoDB",
227
+ configModule,
228
+ peerPackages: ["mongodb"],
229
+ authoringModes: ["psl", "typescript"],
230
+ starterContract,
231
+ contractSample,
232
+ databaseFile,
233
+ envExample,
234
+ quickReference,
235
+ readme,
236
+ serverRequirement: {
237
+ minVersion: MONGO_MIN_SERVER_VERSION,
238
+ checkCommand: "db.runCommand({ buildInfo: 1 })"
239
+ },
240
+ probe: (databaseUrl, signal) => probeMongo(databaseUrl, signal)
241
+ };
242
+ //#endregion
243
+ export { contribution as default };
244
+
245
+ //# sourceMappingURL=init.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/init.mjs"],"sourcesContent":["import { t as moduleBase } from \"./module-base-B70DHaBE.mjs\";\nimport { dirname, join } from \"pathe\";\nimport { MONGO_MIN_SERVER_VERSION } from \"@internal/target-mongo/server-version\";\nimport { readFileSync } from \"node:fs\";\n//#region src/init/probe.ts\n/**\n* The driver's own deadlines, which every 7.x driver honours: `serverSelectionTimeoutMS` for finding\n* a server, `connectTimeoutMS` for opening the connection and its handshake, and `socketTimeoutMS`\n* for a reply, so an unreachable server or a stalled `buildInfo` rejects instead of hanging. Not\n* `timeoutMS`: the driver ignores it from 7.8 on.\n*/\nconst PROBE_TIMEOUT_MS = 2e4;\nfunction isModuleNotFound(error) {\n\treturn error instanceof Error && Reflect.get(error, \"code\") === \"ERR_MODULE_NOT_FOUND\";\n}\nfunction causeMessage(error) {\n\treturn error instanceof Error ? error.message : String(error);\n}\nasync function probeMongo(databaseUrl, signal, loadDriver = () => import(\"mongodb\")) {\n\tlet mongodb;\n\ttry {\n\t\tmongodb = await loadDriver();\n\t} catch (error) {\n\t\treturn {\n\t\t\tkind: isModuleNotFound(error) ? \"driver-missing\" : \"driver-failed\",\n\t\t\tdriver: \"mongodb\",\n\t\t\tcause: causeMessage(error)\n\t\t};\n\t}\n\tconst client = new mongodb.MongoClient(databaseUrl, {\n\t\tserverSelectionTimeoutMS: PROBE_TIMEOUT_MS,\n\t\tconnectTimeoutMS: PROBE_TIMEOUT_MS,\n\t\tsocketTimeoutMS: PROBE_TIMEOUT_MS\n\t});\n\tconst closeOnAbort = () => {\n\t\tclient.close().catch(() => void 0);\n\t};\n\tsignal.addEventListener(\"abort\", closeOnAbort, { once: true });\n\ttry {\n\t\tawait client.connect();\n\t\tlet buildInfo;\n\t\ttry {\n\t\t\tbuildInfo = await client.db().admin().command({ buildInfo: 1 });\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tkind: \"version-unreadable\",\n\t\t\t\tdetail: `buildInfo failed: ${causeMessage(error)}`\n\t\t\t};\n\t\t}\n\t\tconst versionString = String(buildInfo[\"version\"] ?? \"\");\n\t\treturn versionString.length === 0 ? {\n\t\t\tkind: \"version-unreadable\",\n\t\t\tdetail: \"buildInfo did not include a `version` field\"\n\t\t} : {\n\t\t\tkind: \"server-version\",\n\t\t\tserverVersion: versionString\n\t\t};\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", closeOnAbort);\n\t\tawait client.close().catch(() => void 0);\n\t}\n}\n//#endregion\n//#region src/init/render.ts\n/**\n* Fills each `{{name}}` of the template in one pass, so a value is inserted as it is: a value\n* holding `$&` or another placeholder is not read again.\n*/\nfunction renderTemplate(templateFile, vars) {\n\treturn readFileSync(join(import.meta.dirname, templateFile), \"utf-8\").replace(/\\{\\{(\\w+)\\}\\}/g, (placeholder, name) => Object.hasOwn(vars, name) ? vars[name] ?? placeholder : placeholder);\n}\n//#endregion\n//#region src/init/templates.ts\nconst configModule = `${moduleBase}/config`;\nconst builder = `${moduleBase}/contract-builder`;\nfunction starterContract(mode) {\n\treturn mode === \"typescript\" ? starterContractTs() : starterContractPsl();\n}\nfunction contractSample(mode) {\n\treturn mode === \"typescript\" ? contractSampleTs() : contractSamplePsl();\n}\nfunction contractSamplePsl() {\n\treturn `\\`\\`\\`prisma\nmodel User {\n id ObjectId @id @map(\"_id\")\n email String @unique\n username String?\n name String?\n @@map(\"users\")\n}\n\\`\\`\\``;\n}\nfunction contractSampleTs() {\n\treturn `\\`\\`\\`typescript\nimport { defineContract } from '${builder}';\n\nexport const contract = defineContract(\n {},\n ({ field, model, type }) => ({\n models: {\n User: model('User', {\n collection: 'users',\n fields: {\n id: field.scalar(type.ObjectId()).mongo({ field: '_id' }),\n email: field.scalar(type.String()),\n username: field.scalar(type.String()).optional(),\n name: field.scalar(type.String()).optional(),\n },\n }),\n },\n }),\n);\n\\`\\`\\``;\n}\nfunction starterContractPsl() {\n\treturn `// use prisma-8\n\nmodel User {\n id ObjectId @id @map(\"_id\")\n email String @unique\n username String?\n name String?\n posts Post[]\n @@map(\"users\")\n}\n\nmodel Post {\n id ObjectId @id @map(\"_id\")\n title String\n content String?\n author User @relation(fields: [authorId], references: [id])\n authorId ObjectId\n @@map(\"posts\")\n}\n`;\n}\nfunction starterContractTs() {\n\treturn `import { defineContract } from '${builder}';\n\nexport const contract = defineContract(\n {},\n ({ field, model, rel, type }) => ({\n models: {\n User: model('User', {\n collection: 'users',\n fields: {\n id: field.scalar(type.ObjectId()).mongo({ field: '_id' }),\n email: field.scalar(type.String()),\n username: field.scalar(type.String()).optional(),\n name: field.scalar(type.String()).optional(),\n },\n relations: {\n posts: rel.hasMany('Post', { from: 'id', to: 'authorId' }),\n },\n }),\n\n Post: model('Post', {\n collection: 'posts',\n fields: {\n id: field.scalar(type.ObjectId()).mongo({ field: '_id' }),\n title: field.scalar(type.String()),\n content: field.scalar(type.String()).optional(),\n authorId: field.scalar(type.ObjectId()),\n },\n relations: {\n author: rel.belongsTo('User', { from: 'authorId', to: 'id' }),\n },\n }),\n },\n }),\n);\n`;\n}\nfunction databaseFile() {\n\treturn `import 'dotenv/config';\nimport mongo from '${moduleBase}/runtime';\nimport { contractFromJson } from '${moduleBase}/static';\nimport type { Contract } from './contract.d.js';\nimport contractJson from './contract.json' with { type: 'json' };\n\nexport const contract = contractFromJson<Contract>(contractJson);\n\nexport const db = mongo({\n contract,\n url: process.env['DATABASE_URL']!,\n});\n`;\n}\nfunction envExample() {\n\treturn [\n\t\t\"# Connection string for MongoDB.\",\n\t\t`# Requires MongoDB >= ${MONGO_MIN_SERVER_VERSION}.`,\n\t\t\"\",\n\t\t\"# Standalone local mongod / `docker run mongo:8` — no replica set required for first-run queries.\",\n\t\t\"# Transactions and change streams need a replica set; add ?replicaSet=... only after initiating one.\",\n\t\t\"\",\n\t\t\"DATABASE_URL=\\\"mongodb://user:password@localhost:27017/mydb\\\"\",\n\t\t\"\"\n\t].join(\"\\n\");\n}\n//#endregion\n//#region src/init/init-contribution.ts\nfunction quickReference(input) {\n\tconst schemaDir = dirname(input.schemaPath);\n\treturn renderTemplate(\"init-quick-reference.md\", {\n\t\tschemaPath: input.schemaPath,\n\t\tschemaDir,\n\t\tdbImportPath: `./${schemaDir}/db`,\n\t\tpkgRun: input.cliCommand,\n\t\tpkg: moduleBase,\n\t\tconfigEntrypoint: configModule,\n\t\tschemaSample: contractSample(input.mode),\n\t\trequirements: input.requirements\n\t});\n}\nfunction readme(input) {\n\tconst run = input.runScript;\n\treturn renderTemplate(\"init-readme.md\", {\n\t\tprojectName: input.projectName,\n\t\tcontractPath: input.contractPath,\n\t\trunDev: run(\"dev\"),\n\t\trunContractEmit: run(\"contract:emit\"),\n\t\trunDbUp: run(\"db:up\"),\n\t\trunDbDown: run(\"db:down\"),\n\t\trunDbReset: run(\"db:reset\"),\n\t\trunMigrationPlan: run(\"migration:plan\"),\n\t\trunMigrate: run(\"migrate\"),\n\t\trunDbSeed: run(\"db:seed\")\n\t});\n}\nconst contribution = {\n\tlabel: \"MongoDB\",\n\tconfigModule,\n\tpeerPackages: [\"mongodb\"],\n\tauthoringModes: [\"psl\", \"typescript\"],\n\tstarterContract,\n\tcontractSample,\n\tdatabaseFile,\n\tenvExample,\n\tquickReference,\n\treadme,\n\tserverRequirement: {\n\t\tminVersion: MONGO_MIN_SERVER_VERSION,\n\t\tcheckCommand: \"db.runCommand({ buildInfo: 1 })\"\n\t},\n\tprobe: (databaseUrl, signal) => probeMongo(databaseUrl, signal)\n};\n//#endregion\nexport { contribution as default };\n\n//# sourceMappingURL=init.mjs.map"],"mappings":"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"}
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-target-mongo/target/migration";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-target-mongo/target/migration";
2
+ export {};
@@ -0,0 +1,6 @@
1
+ //#region ../../../3-targets/mongo/9-facade/dist/module-base-B70DHaBE.mjs
2
+ const moduleBase = "@prisma/orm-mongo";
3
+ //#endregion
4
+ export { moduleBase as t };
5
+
6
+ //# sourceMappingURL=module-base-B70DHaBE-k_c3Klu4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-base-B70DHaBE-k_c3Klu4.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/module-base-B70DHaBE.mjs"],"sourcesContent":["//#region src/config/module-base.ts\nconst moduleBase = typeof __PRISMA_PUBLISHED_MODULE_BASE__MONGO === \"string\" ? __PRISMA_PUBLISHED_MODULE_BASE__MONGO : \"@internal/mongo\";\n//#endregion\nexport { moduleBase as t };\n\n//# sourceMappingURL=module-base-B70DHaBE.mjs.map"],"mappings":";AACA,MAAM,aAAA"}
@@ -8,8 +8,8 @@ import { buildNamespacedEnums } from "@prisma/orm-framework/contract/enum-access
8
8
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
9
9
  import { mongoQuery } from "@prisma/orm-family-mongo/query-builder";
10
10
  import { assertDefined } from "@prisma/orm-framework/utils/assertions";
11
- //#region ../../../3-targets/mongo/9-facade/dist/mongo-static-HTJYAz-i.mjs
12
- var version = "8.0.0-rc.24-dev.27";
11
+ //#region ../../../3-targets/mongo/9-facade/dist/mongo-static-DActAfeF.mjs
12
+ var version = "8.0.0-rc.24-dev.29";
13
13
  const serializer = new MongoContractSerializer();
14
14
  const validator = `${mongoRuntimeTarget.targetId}@${version}`;
15
15
  /**
@@ -69,4 +69,4 @@ function mongoStatic(options) {
69
69
  //#endregion
70
70
  export { validateMongoContract as i, contractFromJson as n, mongoStatic as r, buildMongoStaticContext as t };
71
71
 
72
- //# sourceMappingURL=mongo-static-HTJYAz-i-yiZaZLPj.mjs.map
72
+ //# sourceMappingURL=mongo-static-DActAfeF-vDjIxfAZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mongo-static-HTJYAz-i-yiZaZLPj.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/mongo-static-HTJYAz-i.mjs"],"sourcesContent":["import mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport { mongoRaw } from \"@internal/mongo-orm\";\nimport { createMongoExecutionContext, createMongoExecutionStack, enumMemberCodecFor } from \"@internal/mongo-runtime\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { mongoQuery } from \"@internal/mongo-query-builder\";\nimport { assertDefined } from \"@internal/utils/assertions\";\n//#region package.json\nvar version = \"8.0.0-rc.24-dev.27\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MongoContractSerializer();\nconst validator = `${mongoRuntimeTarget.targetId}@${version}`;\n/**\n* Validates an emitted Mongo `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mongo({ contract })` and `mongoStatic({ contract })`. Clients built from\n* the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateMongoContract(contract) {\n\treturn contractFromJson(contract);\n}\n//#endregion\n//#region src/static/mongo-static.ts\nfunction buildMongoStaticContext(contract, stack) {\n\tconst context = createMongoExecutionContext({\n\t\tcontract,\n\t\tstack\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, enumMemberCodecFor(context.codecs)))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a mongo builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tquery: mongoQuery({ context }),\n\t\traw: mongoRaw({ context })\n\t};\n}\n/**\n* The query surfaces of a Mongo client without a driver: `query`, `raw` and `enums`. Use it where\n* loading `mongodb` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mongoStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mongoStatic(options) {\n\tconst stack = createMongoExecutionStack({\n\t\ttarget: mongoRuntimeTarget,\n\t\tadapter: mongoRuntimeAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMongoStaticContext(validateMongoContract(options.contract), stack);\n}\n//#endregion\nexport { validateMongoContract as i, mongoStatic as n, contractFromJson as r, buildMongoStaticContext as t };\n\n//# sourceMappingURL=mongo-static-HTJYAz-i.mjs.map"],"mappings":";;;;;;;;;;;AAWA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,mBAAmB,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiBpD,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,iBAAiB,QAAQ;AACjC;AAGA,SAAS,wBAAwB,UAAU,OAAO;CACjD,MAAM,UAAU,4BAA4B;EAC3C;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,QAAQ,mBAAmB,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC;CAC/G,cAAc,OAAO,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,OAAO,WAAW,EAAE,QAAQ,CAAC;EAC7B,KAAK,SAAS,EAAE,QAAQ,CAAC;CAC1B;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,QAAQ,0BAA0B;EACvC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,sBAAsB,QAAQ,QAAQ,GAAG,KAAK;AAC9E"}
1
+ {"version":3,"file":"mongo-static-DActAfeF-vDjIxfAZ.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/mongo-static-DActAfeF.mjs"],"sourcesContent":["import mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport { mongoRaw } from \"@internal/mongo-orm\";\nimport { createMongoExecutionContext, createMongoExecutionStack, enumMemberCodecFor } from \"@internal/mongo-runtime\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { mongoQuery } from \"@internal/mongo-query-builder\";\nimport { assertDefined } from \"@internal/utils/assertions\";\n//#region package.json\nvar version = \"8.0.0-rc.24-dev.29\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MongoContractSerializer();\nconst validator = `${mongoRuntimeTarget.targetId}@${version}`;\n/**\n* Validates an emitted Mongo `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mongo({ contract })` and `mongoStatic({ contract })`. Clients built from\n* the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateMongoContract(contract) {\n\treturn contractFromJson(contract);\n}\n//#endregion\n//#region src/static/mongo-static.ts\nfunction buildMongoStaticContext(contract, stack) {\n\tconst context = createMongoExecutionContext({\n\t\tcontract,\n\t\tstack\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, enumMemberCodecFor(context.codecs)))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a mongo builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tquery: mongoQuery({ context }),\n\t\traw: mongoRaw({ context })\n\t};\n}\n/**\n* The query surfaces of a Mongo client without a driver: `query`, `raw` and `enums`. Use it where\n* loading `mongodb` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mongoStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mongoStatic(options) {\n\tconst stack = createMongoExecutionStack({\n\t\ttarget: mongoRuntimeTarget,\n\t\tadapter: mongoRuntimeAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMongoStaticContext(validateMongoContract(options.contract), stack);\n}\n//#endregion\nexport { validateMongoContract as i, mongoStatic as n, contractFromJson as r, buildMongoStaticContext as t };\n\n//# sourceMappingURL=mongo-static-DActAfeF.mjs.map"],"mappings":";;;;;;;;;;;AAWA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,mBAAmB,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiBpD,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,iBAAiB,QAAQ;AACjC;AAGA,SAAS,wBAAwB,UAAU,OAAO;CACjD,MAAM,UAAU,4BAA4B;EAC3C;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,QAAQ,mBAAmB,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC;CAC/G,cAAc,OAAO,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,OAAO,WAAW,EAAE,QAAQ,CAAC;EAC7B,KAAK,SAAS,EAAE,QAAQ,CAAC;CAC1B;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,QAAQ,0BAA0B;EACvC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,sBAAsB,QAAQ,QAAQ,GAAG,KAAK;AAC9E"}