@prisma-next/family-mongo 0.3.0-dev.164 → 0.4.0-dev.1
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/README.md +33 -1
- package/dist/migration.d.mts +8 -0
- package/dist/migration.d.mts.map +1 -0
- package/dist/migration.mjs +8 -0
- package/dist/migration.mjs.map +1 -0
- package/package.json +15 -12
- package/src/core/mongo-migration.ts +4 -0
- package/src/exports/migration.ts +1 -0
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ This package is the Mongo family integration point for both control-plane assemb
|
|
|
21
21
|
## Entrypoints
|
|
22
22
|
|
|
23
23
|
- `./control`: control-plane entrypoint exporting `mongoFamilyDescriptor`, `mongoTargetDescriptor`, `createMongoFamilyInstance`, and `MongoControlFamilyInstance`
|
|
24
|
+
- `./migration`: migration authoring — `Migration` class, factory functions, and strategies (re-exported from `@prisma-next/target-mongo/migration`)
|
|
24
25
|
- `./pack`: pure pack ref for TypeScript authoring flows such as `@prisma-next/mongo-contract-ts/contract-builder`
|
|
25
26
|
|
|
26
27
|
## Usage
|
|
@@ -95,18 +96,49 @@ export const contract = defineContract({
|
|
|
95
96
|
|
|
96
97
|
The current `contract.ts` slice supports roots and collections, typed reference relations, owned models with `storage.relations`, value objects, and discriminator-based polymorphism.
|
|
97
98
|
|
|
99
|
+
### Migration authoring
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { Migration, createIndex, createCollection }
|
|
103
|
+
from "@prisma-next/family-mongo/migration"
|
|
104
|
+
|
|
105
|
+
export default class extends Migration {
|
|
106
|
+
describe() {
|
|
107
|
+
return { from: "abc123", to: "def456", labels: ["add-users"] }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
plan() {
|
|
111
|
+
return [
|
|
112
|
+
createCollection("users", {
|
|
113
|
+
validator: { $jsonSchema: { required: ["email"] } },
|
|
114
|
+
validationLevel: "strict",
|
|
115
|
+
}),
|
|
116
|
+
createIndex("users", [{ field: "email", direction: 1 }], { unique: true }),
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Migration.run(import.meta.url)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Run `node migration.ts` to produce `ops.json` and `migration.json`. Use `--dry-run` to preview without writing.
|
|
125
|
+
|
|
98
126
|
## Package Structure
|
|
99
127
|
|
|
100
128
|
- `src/core/control-descriptor.ts`: `MongoFamilyDescriptor` implementation
|
|
101
129
|
- `src/core/control-instance.ts`: `createMongoFamilyInstance()` and `MongoControlFamilyInstance`
|
|
102
130
|
- `src/core/mongo-target-descriptor.ts`: pre-built control target descriptor derived from `@prisma-next/target-mongo/pack`
|
|
131
|
+
- `src/core/mongo-migration.ts`: `MongoMigration` class (fixes the `Migration<TOperation>` type parameter to `MongoMigrationPlanOperation`)
|
|
103
132
|
- `src/exports/control.ts`: control-plane entrypoint
|
|
133
|
+
- `src/exports/migration.ts`: migration authoring entrypoint
|
|
104
134
|
- `src/exports/pack.ts`: authoring-time family pack ref
|
|
105
135
|
|
|
106
136
|
## Dependencies
|
|
107
137
|
|
|
108
138
|
- `@prisma-next/framework-components`: control-plane types and stack assembly
|
|
139
|
+
- `@prisma-next/migration-tools`: generic `Migration<TOperation>` base class
|
|
109
140
|
- `@prisma-next/mongo-contract`: Mongo contract validation and types
|
|
110
141
|
- `@prisma-next/mongo-contract-ts`: Mongo `contract.ts` authoring surface
|
|
111
142
|
- `@prisma-next/mongo-emitter`: Mongo family emission hook
|
|
112
|
-
- `@prisma-next/
|
|
143
|
+
- `@prisma-next/mongo-query-ast`: Mongo command AST types (`MongoMigrationPlanOperation`)
|
|
144
|
+
- `@prisma-next/target-mongo`: Mongo target pack metadata and migration factories
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Migration } from "@prisma-next/migration-tools/migration";
|
|
2
|
+
import { MongoMigrationPlanOperation } from "@prisma-next/mongo-query-ast/control";
|
|
3
|
+
|
|
4
|
+
//#region src/core/mongo-migration.d.ts
|
|
5
|
+
declare abstract class MongoMigration extends Migration<MongoMigrationPlanOperation> {}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { MongoMigration as Migration };
|
|
8
|
+
//# sourceMappingURL=migration.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.mts","names":[],"sources":["../src/core/mongo-migration.ts"],"sourcesContent":[],"mappings":";;;;uBAGsB,cAAA,SAAuB,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.mjs","names":[],"sources":["../src/core/mongo-migration.ts"],"sourcesContent":["import { Migration } from '@prisma-next/migration-tools/migration';\nimport type { MongoMigrationPlanOperation } from '@prisma-next/mongo-query-ast/control';\n\nexport abstract class MongoMigration extends Migration<MongoMigrationPlanOperation> {}\n"],"mappings":";;;AAGA,IAAsB,iBAAtB,cAA6C,UAAuC"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/family-mongo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-dev.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Mongo family descriptor for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"mongodb": "^6.16.0",
|
|
9
|
-
"@prisma-next/adapter-mongo": "0.
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/
|
|
13
|
-
"@prisma-next/mongo-contract": "0.
|
|
14
|
-
"@prisma-next/mongo-emitter": "0.
|
|
15
|
-
"@prisma-next/
|
|
16
|
-
"@prisma-next/
|
|
17
|
-
"@prisma-next/
|
|
9
|
+
"@prisma-next/adapter-mongo": "0.4.0-dev.1",
|
|
10
|
+
"@prisma-next/framework-components": "0.4.0-dev.1",
|
|
11
|
+
"@prisma-next/contract": "0.4.0-dev.1",
|
|
12
|
+
"@prisma-next/emitter": "0.4.0-dev.1",
|
|
13
|
+
"@prisma-next/mongo-contract": "0.4.0-dev.1",
|
|
14
|
+
"@prisma-next/mongo-emitter": "0.4.0-dev.1",
|
|
15
|
+
"@prisma-next/migration-tools": "0.4.0-dev.1",
|
|
16
|
+
"@prisma-next/mongo-schema-ir": "0.4.0-dev.1",
|
|
17
|
+
"@prisma-next/target-mongo": "0.4.0-dev.1",
|
|
18
|
+
"@prisma-next/utils": "0.4.0-dev.1",
|
|
19
|
+
"@prisma-next/mongo-query-ast": "0.4.0-dev.1"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
22
|
"tsdown": "0.18.4",
|
|
21
23
|
"typescript": "5.9.3",
|
|
22
24
|
"vitest": "4.0.17",
|
|
23
25
|
"@prisma-next/tsconfig": "0.0.0",
|
|
24
|
-
"@prisma-next/
|
|
25
|
-
"@prisma-next/
|
|
26
|
+
"@prisma-next/mongo-contract-ts": "0.4.0-dev.1",
|
|
27
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
26
28
|
},
|
|
27
29
|
"files": [
|
|
28
30
|
"dist",
|
|
@@ -38,6 +40,7 @@
|
|
|
38
40
|
"types": "./dist/control.d.mts",
|
|
39
41
|
"exports": {
|
|
40
42
|
"./control": "./dist/control.mjs",
|
|
43
|
+
"./migration": "./dist/migration.mjs",
|
|
41
44
|
"./pack": "./dist/pack.mjs",
|
|
42
45
|
"./package.json": "./package.json"
|
|
43
46
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MongoMigration as Migration } from '../core/mongo-migration';
|