@metaobjectsdev/sdk 0.20.11 → 0.20.12-rc.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.
|
@@ -10,8 +10,8 @@ spine; generated code is the disposable artifact. Regenerate with `{{codegenComm
|
|
|
10
10
|
|
|
11
11
|
## Principles
|
|
12
12
|
- **Adopting onto existing code? Metadata FOLLOWS the code.** On a migration (existing working code / live DB), author metadata + tune codegen to *reproduce* what the code already is — native types (`field.uuid` when the code uses `UUID`, not `field.string`), names, nullability — so regen changes as little existing code as possible. The only existing code that should change is the hand-written layer codegen replaces; ask when a modeling choice is ambiguous. (Greenfield: model-first, below.)
|
|
13
|
-
- Pattern-derivable from metadata = codegen, never hand-write — FKs, CRUD, validators, finders, and the database schema and migrations. The schema is a disposable, generated artifact: change the metadata and regenerate
|
|
14
|
-
- The **live database** is a derived artifact too — never hand-apply a schema change to a running DB (ad-hoc `psql`/console `ALTER`/`CREATE`/`DROP`), not even to preview a column or unblock a boot.
|
|
13
|
+
- Pattern-derivable from metadata = codegen, never hand-write — FKs, CRUD, validators, finders, and the database schema and migrations. The schema is a disposable, generated artifact: change the metadata and regenerate. Don't hand-write divergent SQL; where a stack owns its own migration files (Flyway/Liquibase), they must **match** the generated schema, not invent it.
|
|
14
|
+
- The **live database** is a derived artifact too — never hand-apply a schema change to a running DB (ad-hoc `psql`/console `ALTER`/`CREATE`/`DROP`), not even to preview a column or unblock a boot. Drive every schema change from the metadata, never ad-hoc: on the Node/TS-owned migrate stack that is `meta migrate` (metadata → DDL, ADR-0015); on a JVM stack whose migration tool `meta migrate` does not emit for (e.g. **Flyway**/Liquibase) author the migration to match the generated schema (the source of truth). A hand-applied ad-hoc change drifts the live DB from the metadata + migration history and collides at the next migrate/boot ("column already exists") — a state no migration can reproduce. Run `meta verify --db` after any DB-touching work to catch that drift early.
|
|
15
15
|
- Never hand-edit generated files — change the metadata and regenerate (three-way merge preserves hand-written regions).
|
|
16
16
|
- Use the generated constants for any string that names metadata.
|
|
17
17
|
- The loaded metadata model is READ-ONLY — never inject nodes or mutate the tree at load time (no "enrich the model on load" hooks). Need an extra field/column? Author it in the metadata, or derive it during codegen (read the metadata, emit output). Mutating the loaded model makes it diverge from what's declared — a bad practice reserved for very rare cases.
|
package/dist/config.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
42
42
|
outDir: z.ZodOptional<z.ZodString>;
|
|
43
43
|
databaseUrl: z.ZodOptional<z.ZodString>;
|
|
44
44
|
dialect: z.ZodOptional<z.ZodEnum<["sqlite", "postgres", "d1"]>>;
|
|
45
|
+
format: z.ZodOptional<z.ZodEnum<["default", "flyway"]>>;
|
|
45
46
|
onAmbiguous: z.ZodOptional<z.ZodEnum<["abort", "rename", "drop-add"]>>;
|
|
46
47
|
allow: z.ZodOptional<z.ZodArray<z.ZodEnum<["drop-column", "drop-table", "type-change", "drop-index", "drop-fk", "nullable-to-not-null"]>, "many">>;
|
|
47
48
|
d1: z.ZodOptional<z.ZodObject<{
|
|
@@ -70,6 +71,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
70
71
|
outDir?: string | undefined;
|
|
71
72
|
databaseUrl?: string | undefined;
|
|
72
73
|
dialect?: "sqlite" | "postgres" | "d1" | undefined;
|
|
74
|
+
format?: "default" | "flyway" | undefined;
|
|
73
75
|
onAmbiguous?: "abort" | "rename" | "drop-add" | undefined;
|
|
74
76
|
allow?: ("drop-column" | "drop-table" | "type-change" | "drop-index" | "drop-fk" | "nullable-to-not-null")[] | undefined;
|
|
75
77
|
}, {
|
|
@@ -82,6 +84,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
82
84
|
outDir?: string | undefined;
|
|
83
85
|
databaseUrl?: string | undefined;
|
|
84
86
|
dialect?: "sqlite" | "postgres" | "d1" | undefined;
|
|
87
|
+
format?: "default" | "flyway" | undefined;
|
|
85
88
|
onAmbiguous?: "abort" | "rename" | "drop-add" | undefined;
|
|
86
89
|
allow?: ("drop-column" | "drop-table" | "type-change" | "drop-index" | "drop-fk" | "nullable-to-not-null")[] | undefined;
|
|
87
90
|
}>>;
|
|
@@ -112,6 +115,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
112
115
|
outDir?: string | undefined;
|
|
113
116
|
databaseUrl?: string | undefined;
|
|
114
117
|
dialect?: "sqlite" | "postgres" | "d1" | undefined;
|
|
118
|
+
format?: "default" | "flyway" | undefined;
|
|
115
119
|
onAmbiguous?: "abort" | "rename" | "drop-add" | undefined;
|
|
116
120
|
allow?: ("drop-column" | "drop-table" | "type-change" | "drop-index" | "drop-fk" | "nullable-to-not-null")[] | undefined;
|
|
117
121
|
} | undefined;
|
|
@@ -142,6 +146,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
142
146
|
outDir?: string | undefined;
|
|
143
147
|
databaseUrl?: string | undefined;
|
|
144
148
|
dialect?: "sqlite" | "postgres" | "d1" | undefined;
|
|
149
|
+
format?: "default" | "flyway" | undefined;
|
|
145
150
|
onAmbiguous?: "abort" | "rename" | "drop-add" | undefined;
|
|
146
151
|
allow?: ("drop-column" | "drop-table" | "type-change" | "drop-index" | "drop-fk" | "nullable-to-not-null")[] | undefined;
|
|
147
152
|
} | undefined;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqCxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBvB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc,EAAE,MAAkD,CAAC;AAIhF,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlE;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhF"}
|
package/dist/config.js
CHANGED
|
@@ -17,10 +17,13 @@ const D1Block = z.object({
|
|
|
17
17
|
autoApply: z.boolean(),
|
|
18
18
|
wranglerConfigPath: z.string(),
|
|
19
19
|
}).partial();
|
|
20
|
+
/** #192 — migration output-format adapters; orthogonal to dialect. */
|
|
21
|
+
const MigrateFormatEnum = z.enum(["default", "flyway"]);
|
|
20
22
|
const MigrateBlock = z.object({
|
|
21
23
|
outDir: z.string(),
|
|
22
24
|
databaseUrl: z.string(),
|
|
23
25
|
dialect: DialectEnum,
|
|
26
|
+
format: MigrateFormatEnum,
|
|
24
27
|
onAmbiguous: OnAmbiguousEnum,
|
|
25
28
|
allow: z.array(AllowTokenEnum),
|
|
26
29
|
d1: D1Block,
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AAEzD,MAAM,eAAe,G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d,OAAO,EAAE,YAAY,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,cAAc,GAAW,YAAY,CAAC,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC;AAEhF,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;IAChE,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB,EAAE,MAAc;IAC/D,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,0BAA0B;IACtD,MAAM,SAAS,CACb,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,EAC3B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EACtC,MAAM,CACP,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metaobjectsdev/sdk",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.12-rc.1",
|
|
4
4
|
"description": "Workspace helpers and agent-docs utilities for MetaObjects projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@metaobjectsdev/metadata": "0.20.
|
|
59
|
+
"@metaobjectsdev/metadata": "0.20.12-rc.1",
|
|
60
60
|
"zod": "^3.23.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
package/src/config.ts
CHANGED
|
@@ -22,10 +22,14 @@ const D1Block = z.object({
|
|
|
22
22
|
wranglerConfigPath: z.string(),
|
|
23
23
|
}).partial();
|
|
24
24
|
|
|
25
|
+
/** #192 — migration output-format adapters; orthogonal to dialect. */
|
|
26
|
+
const MigrateFormatEnum = z.enum(["default", "flyway"]);
|
|
27
|
+
|
|
25
28
|
const MigrateBlock = z.object({
|
|
26
29
|
outDir: z.string(),
|
|
27
30
|
databaseUrl: z.string(),
|
|
28
31
|
dialect: DialectEnum,
|
|
32
|
+
format: MigrateFormatEnum,
|
|
29
33
|
onAmbiguous: OnAmbiguousEnum,
|
|
30
34
|
allow: z.array(AllowTokenEnum),
|
|
31
35
|
d1: D1Block,
|