@dads-framework/postgres 0.4.0 → 0.5.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.
Files changed (88) hide show
  1. package/README.md +31 -0
  2. package/dist/live-actions/index.d.ts +5 -0
  3. package/dist/live-actions/index.d.ts.map +1 -0
  4. package/dist/live-actions/index.js +4 -0
  5. package/dist/live-actions/index.js.map +1 -0
  6. package/dist/live-actions/live-action-run-types.d.ts +9 -0
  7. package/dist/live-actions/live-action-run-types.d.ts.map +1 -0
  8. package/dist/live-actions/live-action-run-types.js +2 -0
  9. package/dist/live-actions/live-action-run-types.js.map +1 -0
  10. package/dist/live-actions/live-action-runs-migration.d.ts +9 -0
  11. package/dist/live-actions/live-action-runs-migration.d.ts.map +1 -0
  12. package/dist/live-actions/live-action-runs-migration.js +31 -0
  13. package/dist/live-actions/live-action-runs-migration.js.map +1 -0
  14. package/dist/live-actions/live-action-runs.table.d.ts +218 -0
  15. package/dist/live-actions/live-action-runs.table.d.ts.map +1 -0
  16. package/dist/live-actions/live-action-runs.table.js +20 -0
  17. package/dist/live-actions/live-action-runs.table.js.map +1 -0
  18. package/dist/live-actions/postgres-live-action-run-store.d.ts +7 -0
  19. package/dist/live-actions/postgres-live-action-run-store.d.ts.map +1 -0
  20. package/dist/live-actions/postgres-live-action-run-store.js +146 -0
  21. package/dist/live-actions/postgres-live-action-run-store.js.map +1 -0
  22. package/dist/migrations/index.d.ts +1 -1
  23. package/dist/migrations/index.d.ts.map +1 -1
  24. package/dist/migrations/index.js +1 -1
  25. package/dist/migrations/index.js.map +1 -1
  26. package/dist/migrations/lib/node-pg/migration-workspace.d.ts +13 -0
  27. package/dist/migrations/lib/node-pg/migration-workspace.d.ts.map +1 -1
  28. package/dist/migrations/lib/node-pg/migration-workspace.js +26 -0
  29. package/dist/migrations/lib/node-pg/migration-workspace.js.map +1 -1
  30. package/dist/postgres.tsbuildinfo +1 -1
  31. package/dist/schema-generate/catalog-types.d.ts +62 -0
  32. package/dist/schema-generate/catalog-types.d.ts.map +1 -0
  33. package/dist/schema-generate/catalog-types.js +2 -0
  34. package/dist/schema-generate/catalog-types.js.map +1 -0
  35. package/dist/schema-generate/default-table-metadata.d.ts +12 -0
  36. package/dist/schema-generate/default-table-metadata.d.ts.map +1 -0
  37. package/dist/schema-generate/default-table-metadata.js +36 -0
  38. package/dist/schema-generate/default-table-metadata.js.map +1 -0
  39. package/dist/schema-generate/generate-database-tables.d.ts +54 -0
  40. package/dist/schema-generate/generate-database-tables.d.ts.map +1 -0
  41. package/dist/schema-generate/generate-database-tables.js +201 -0
  42. package/dist/schema-generate/generate-database-tables.js.map +1 -0
  43. package/dist/schema-generate/index.d.ts +10 -0
  44. package/dist/schema-generate/index.d.ts.map +1 -0
  45. package/dist/schema-generate/index.js +9 -0
  46. package/dist/schema-generate/index.js.map +1 -0
  47. package/dist/schema-generate/introspect-catalog-queries.d.ts +10 -0
  48. package/dist/schema-generate/introspect-catalog-queries.d.ts.map +1 -0
  49. package/dist/schema-generate/introspect-catalog-queries.js +161 -0
  50. package/dist/schema-generate/introspect-catalog-queries.js.map +1 -0
  51. package/dist/schema-generate/introspect-database.d.ts +19 -0
  52. package/dist/schema-generate/introspect-database.d.ts.map +1 -0
  53. package/dist/schema-generate/introspect-database.js +247 -0
  54. package/dist/schema-generate/introspect-database.js.map +1 -0
  55. package/dist/schema-generate/normalize-catalog.d.ts +7 -0
  56. package/dist/schema-generate/normalize-catalog.d.ts.map +1 -0
  57. package/dist/schema-generate/normalize-catalog.js +58 -0
  58. package/dist/schema-generate/normalize-catalog.js.map +1 -0
  59. package/dist/schema-generate/render-column-builder.d.ts +32 -0
  60. package/dist/schema-generate/render-column-builder.d.ts.map +1 -0
  61. package/dist/schema-generate/render-column-builder.js +191 -0
  62. package/dist/schema-generate/render-column-builder.js.map +1 -0
  63. package/dist/schema-generate/render-column-default.d.ts +13 -0
  64. package/dist/schema-generate/render-column-default.d.ts.map +1 -0
  65. package/dist/schema-generate/render-column-default.js +69 -0
  66. package/dist/schema-generate/render-column-default.js.map +1 -0
  67. package/dist/schema-generate/render-column.d.ts +41 -0
  68. package/dist/schema-generate/render-column.d.ts.map +1 -0
  69. package/dist/schema-generate/render-column.js +111 -0
  70. package/dist/schema-generate/render-column.js.map +1 -0
  71. package/dist/schema-generate/render-table-extras.d.ts +24 -0
  72. package/dist/schema-generate/render-table-extras.d.ts.map +1 -0
  73. package/dist/schema-generate/render-table-extras.js +204 -0
  74. package/dist/schema-generate/render-table-extras.js.map +1 -0
  75. package/dist/schema-generate/render-table-module.d.ts +18 -0
  76. package/dist/schema-generate/render-table-module.d.ts.map +1 -0
  77. package/dist/schema-generate/render-table-module.js +259 -0
  78. package/dist/schema-generate/render-table-module.js.map +1 -0
  79. package/dist/schema-generate/table-metadata.schema.d.ts +112 -0
  80. package/dist/schema-generate/table-metadata.schema.d.ts.map +1 -0
  81. package/dist/schema-generate/table-metadata.schema.js +54 -0
  82. package/dist/schema-generate/table-metadata.schema.js.map +1 -0
  83. package/dist/schema-generate/table-schema-fingerprint.d.ts +15 -0
  84. package/dist/schema-generate/table-schema-fingerprint.d.ts.map +1 -0
  85. package/dist/schema-generate/table-schema-fingerprint.js +41 -0
  86. package/dist/schema-generate/table-schema-fingerprint.js.map +1 -0
  87. package/migrations/README.md +7 -0
  88. package/package.json +10 -2
package/README.md CHANGED
@@ -84,6 +84,37 @@ schema-generic query type. The query type follows the native factory result
84
84
  and preserves the original default schema. The root still exports
85
85
  `DrizzleHandle` for compatibility.
86
86
 
87
+ ## Schema generation (`@dads-framework/postgres/schema-generate`)
88
+
89
+ Introspect a migrated PostgreSQL database (`introspectPostgresCatalog`) and
90
+ emit deterministic Drizzle table modules (`generateDatabaseTableFiles`,
91
+ `introspectAndGenerateTables`). Each generated file opens with a header and a
92
+ 16-hex SHA-256 table fingerprint covering every column, constraint, index, and
93
+ trigger—including retired columns omitted from the rendered Drizzle table.
94
+
95
+ - `inferDefaultTableMetadata(table, outputDir)` derives a `camelCase` export
96
+ symbol and `<outputDir>/<kebab-table>.tables.ts` path without requiring
97
+ sidecar metadata files.
98
+ - Pass explicit `TableMetadata` entries (validated by `tableMetadataSchema`)
99
+ when adding branded IDs (`brandType`/`brandImport`), typed JSONB payloads
100
+ (`jsonType`/`jsonImport`), enum overrides, `onUpdateNow`, `relations`, or
101
+ `retiredColumns`.
102
+ - `writeGeneratedTableFiles(files, outputRoot)` writes generated modules to
103
+ disk and refuses paths that escape `outputRoot`.
104
+ - `checkGeneratedTableFiles(files, outputRoot)` compares generated output
105
+ against disk and returns `{ ok, drifted, missing }` for CI drift checks.
106
+
107
+ ## Live action run store (`@dads-framework/postgres/live-actions`)
108
+
109
+ Persist operational action runs in PostgreSQL:
110
+
111
+ - `liveActionRunsMigration` and `applyLiveActionRunsMigration(client)` create
112
+ the `live_action_runs` table and lookup indexes idempotently.
113
+ - `liveActionRunsTable` exports the matching Drizzle `pgTable` definition.
114
+ - `createPostgresLiveActionRunStore(pool)` implements `LiveActionRunStore`
115
+ (`recordStart`, `recordFinish`, `getById`, `listRecent`) with Zod validation
116
+ at both input and database-row boundaries.
117
+
87
118
  ## Plugin service tokens
88
119
 
89
120
  Import `databaseService` (`DrizzleHandle`) or `postgresPoolService` (`PgPool`)
@@ -0,0 +1,5 @@
1
+ export type { FinishLiveActionRunInput, ListRecentLiveActionRunsOptions, LiveActionQueryClient, LiveActionRedactedInput, LiveActionRunOutcome, LiveActionRunRecord, LiveActionRunStore, } from "./live-action-run-types.js";
2
+ export { applyLiveActionRunsMigration, liveActionRunsMigration } from "./live-action-runs-migration.js";
3
+ export { liveActionRunsTable } from "./live-action-runs.table.js";
4
+ export { createPostgresLiveActionRunStore } from "./postgres-live-action-run-store.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/live-actions/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,+BAA+B,EAC/B,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { applyLiveActionRunsMigration, liveActionRunsMigration } from "./live-action-runs-migration.js";
2
+ export { liveActionRunsTable } from "./live-action-runs.table.js";
3
+ export { createPostgresLiveActionRunStore } from "./postgres-live-action-run-store.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/live-actions/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { FinishLiveActionRunInput, ListRecentLiveActionRunsOptions, LiveActionDangerLevel, LiveActionRedactedInput, LiveActionRunOutcome, LiveActionRunRecord, LiveActionRunStore } from "@dads-framework/core/contract";
2
+ /** Minimal queryable PostgreSQL pool or client surface used by the live-action store. */
3
+ export type LiveActionQueryClient = {
4
+ query(text: string, values?: unknown[]): Promise<{
5
+ readonly rows: readonly unknown[];
6
+ }>;
7
+ };
8
+ export type { FinishLiveActionRunInput, ListRecentLiveActionRunsOptions, LiveActionDangerLevel, LiveActionRedactedInput, LiveActionRunOutcome, LiveActionRunRecord, LiveActionRunStore, };
9
+ //# sourceMappingURL=live-action-run-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-action-run-types.d.ts","sourceRoot":"","sources":["../../src/live-actions/live-action-run-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,+BAA+B,EAC/B,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AAEvC,yFAAyF;AACzF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;CACzF,CAAC;AAEF,YAAY,EACV,wBAAwB,EACxB,+BAA+B,EAC/B,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=live-action-run-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-action-run-types.js","sourceRoot":"","sources":["../../src/live-actions/live-action-run-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { LiveActionQueryClient } from "./live-action-run-types.js";
2
+ /**
3
+ * Idempotent DDL creating the `live_action_runs` audit table and its lookup
4
+ * indexes. Safe to run repeatedly on startup or from a migration script.
5
+ */
6
+ export declare const liveActionRunsMigration: string;
7
+ /** Applies the idempotent `live_action_runs` table migration against `client`. */
8
+ export declare function applyLiveActionRunsMigration(client: LiveActionQueryClient): Promise<void>;
9
+ //# sourceMappingURL=live-action-runs-migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-action-runs-migration.d.ts","sourceRoot":"","sources":["../../src/live-actions/live-action-runs-migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAqB5B,CAAC;AAET,kFAAkF;AAClF,wBAAsB,4BAA4B,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/F"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Idempotent DDL creating the `live_action_runs` audit table and its lookup
3
+ * indexes. Safe to run repeatedly on startup or from a migration script.
4
+ */
5
+ export const liveActionRunsMigration = `
6
+ CREATE TABLE IF NOT EXISTS live_action_runs (
7
+ id uuid PRIMARY KEY,
8
+ action_name text NOT NULL,
9
+ danger_level text NOT NULL,
10
+ actor_type text NOT NULL,
11
+ actor_id text NOT NULL,
12
+ reason text NOT NULL,
13
+ redacted_input jsonb NOT NULL,
14
+ outcome text NOT NULL,
15
+ summary text,
16
+ error_message text,
17
+ started_at timestamptz NOT NULL,
18
+ finished_at timestamptz
19
+ );
20
+
21
+ CREATE INDEX IF NOT EXISTS live_action_runs_started_at_idx
22
+ ON live_action_runs (started_at DESC);
23
+
24
+ CREATE INDEX IF NOT EXISTS live_action_runs_action_started_at_idx
25
+ ON live_action_runs (action_name, started_at DESC);
26
+ `.trim();
27
+ /** Applies the idempotent `live_action_runs` table migration against `client`. */
28
+ export async function applyLiveActionRunsMigration(client) {
29
+ await client.query(liveActionRunsMigration);
30
+ }
31
+ //# sourceMappingURL=live-action-runs-migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-action-runs-migration.js","sourceRoot":"","sources":["../../src/live-actions/live-action-runs-migration.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBtC,CAAC,IAAI,EAAE,CAAC;AAET,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,MAA6B;IAC9E,MAAM,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,218 @@
1
+ import type { LiveActionRedactedInput, LiveActionRunOutcome } from "./live-action-run-types.js";
2
+ /** Drizzle table definition matching `liveActionRunsMigration`. */
3
+ export declare const liveActionRunsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
4
+ name: "live_action_runs";
5
+ schema: undefined;
6
+ columns: {
7
+ id: import("drizzle-orm/pg-core").PgColumn<{
8
+ name: "id";
9
+ tableName: "live_action_runs";
10
+ dataType: "string";
11
+ columnType: "PgUUID";
12
+ data: string;
13
+ driverParam: string;
14
+ notNull: true;
15
+ hasDefault: false;
16
+ isPrimaryKey: true;
17
+ isAutoincrement: false;
18
+ hasRuntimeDefault: false;
19
+ enumValues: undefined;
20
+ baseColumn: never;
21
+ identity: undefined;
22
+ generated: undefined;
23
+ }, {}, {}>;
24
+ actionName: import("drizzle-orm/pg-core").PgColumn<{
25
+ name: "action_name";
26
+ tableName: "live_action_runs";
27
+ dataType: "string";
28
+ columnType: "PgText";
29
+ data: string;
30
+ driverParam: string;
31
+ notNull: true;
32
+ hasDefault: false;
33
+ isPrimaryKey: false;
34
+ isAutoincrement: false;
35
+ hasRuntimeDefault: false;
36
+ enumValues: [string, ...string[]];
37
+ baseColumn: never;
38
+ identity: undefined;
39
+ generated: undefined;
40
+ }, {}, {}>;
41
+ dangerLevel: import("drizzle-orm/pg-core").PgColumn<{
42
+ name: "danger_level";
43
+ tableName: "live_action_runs";
44
+ dataType: "string";
45
+ columnType: "PgText";
46
+ data: string;
47
+ driverParam: string;
48
+ notNull: true;
49
+ hasDefault: false;
50
+ isPrimaryKey: false;
51
+ isAutoincrement: false;
52
+ hasRuntimeDefault: false;
53
+ enumValues: [string, ...string[]];
54
+ baseColumn: never;
55
+ identity: undefined;
56
+ generated: undefined;
57
+ }, {}, {}>;
58
+ actorType: import("drizzle-orm/pg-core").PgColumn<{
59
+ name: "actor_type";
60
+ tableName: "live_action_runs";
61
+ dataType: "string";
62
+ columnType: "PgText";
63
+ data: string;
64
+ driverParam: string;
65
+ notNull: true;
66
+ hasDefault: false;
67
+ isPrimaryKey: false;
68
+ isAutoincrement: false;
69
+ hasRuntimeDefault: false;
70
+ enumValues: [string, ...string[]];
71
+ baseColumn: never;
72
+ identity: undefined;
73
+ generated: undefined;
74
+ }, {}, {}>;
75
+ actorId: import("drizzle-orm/pg-core").PgColumn<{
76
+ name: "actor_id";
77
+ tableName: "live_action_runs";
78
+ dataType: "string";
79
+ columnType: "PgText";
80
+ data: string;
81
+ driverParam: string;
82
+ notNull: true;
83
+ hasDefault: false;
84
+ isPrimaryKey: false;
85
+ isAutoincrement: false;
86
+ hasRuntimeDefault: false;
87
+ enumValues: [string, ...string[]];
88
+ baseColumn: never;
89
+ identity: undefined;
90
+ generated: undefined;
91
+ }, {}, {}>;
92
+ reason: import("drizzle-orm/pg-core").PgColumn<{
93
+ name: "reason";
94
+ tableName: "live_action_runs";
95
+ dataType: "string";
96
+ columnType: "PgText";
97
+ data: string;
98
+ driverParam: string;
99
+ notNull: true;
100
+ hasDefault: false;
101
+ isPrimaryKey: false;
102
+ isAutoincrement: false;
103
+ hasRuntimeDefault: false;
104
+ enumValues: [string, ...string[]];
105
+ baseColumn: never;
106
+ identity: undefined;
107
+ generated: undefined;
108
+ }, {}, {}>;
109
+ redactedInput: import("drizzle-orm/pg-core").PgColumn<{
110
+ name: "redacted_input";
111
+ tableName: "live_action_runs";
112
+ dataType: "json";
113
+ columnType: "PgJsonb";
114
+ data: LiveActionRedactedInput;
115
+ driverParam: unknown;
116
+ notNull: true;
117
+ hasDefault: false;
118
+ isPrimaryKey: false;
119
+ isAutoincrement: false;
120
+ hasRuntimeDefault: false;
121
+ enumValues: undefined;
122
+ baseColumn: never;
123
+ identity: undefined;
124
+ generated: undefined;
125
+ }, {}, {
126
+ $type: LiveActionRedactedInput;
127
+ }>;
128
+ outcome: import("drizzle-orm/pg-core").PgColumn<{
129
+ name: "outcome";
130
+ tableName: "live_action_runs";
131
+ dataType: "string";
132
+ columnType: "PgText";
133
+ data: LiveActionRunOutcome;
134
+ driverParam: string;
135
+ notNull: true;
136
+ hasDefault: false;
137
+ isPrimaryKey: false;
138
+ isAutoincrement: false;
139
+ hasRuntimeDefault: false;
140
+ enumValues: [string, ...string[]];
141
+ baseColumn: never;
142
+ identity: undefined;
143
+ generated: undefined;
144
+ }, {}, {
145
+ $type: LiveActionRunOutcome;
146
+ }>;
147
+ summary: import("drizzle-orm/pg-core").PgColumn<{
148
+ name: "summary";
149
+ tableName: "live_action_runs";
150
+ dataType: "string";
151
+ columnType: "PgText";
152
+ data: string;
153
+ driverParam: string;
154
+ notNull: false;
155
+ hasDefault: false;
156
+ isPrimaryKey: false;
157
+ isAutoincrement: false;
158
+ hasRuntimeDefault: false;
159
+ enumValues: [string, ...string[]];
160
+ baseColumn: never;
161
+ identity: undefined;
162
+ generated: undefined;
163
+ }, {}, {}>;
164
+ errorMessage: import("drizzle-orm/pg-core").PgColumn<{
165
+ name: "error_message";
166
+ tableName: "live_action_runs";
167
+ dataType: "string";
168
+ columnType: "PgText";
169
+ data: string;
170
+ driverParam: string;
171
+ notNull: false;
172
+ hasDefault: false;
173
+ isPrimaryKey: false;
174
+ isAutoincrement: false;
175
+ hasRuntimeDefault: false;
176
+ enumValues: [string, ...string[]];
177
+ baseColumn: never;
178
+ identity: undefined;
179
+ generated: undefined;
180
+ }, {}, {}>;
181
+ startedAt: import("drizzle-orm/pg-core").PgColumn<{
182
+ name: "started_at";
183
+ tableName: "live_action_runs";
184
+ dataType: "date";
185
+ columnType: "PgTimestamp";
186
+ data: Date;
187
+ driverParam: string;
188
+ notNull: true;
189
+ hasDefault: false;
190
+ isPrimaryKey: false;
191
+ isAutoincrement: false;
192
+ hasRuntimeDefault: false;
193
+ enumValues: undefined;
194
+ baseColumn: never;
195
+ identity: undefined;
196
+ generated: undefined;
197
+ }, {}, {}>;
198
+ finishedAt: import("drizzle-orm/pg-core").PgColumn<{
199
+ name: "finished_at";
200
+ tableName: "live_action_runs";
201
+ dataType: "date";
202
+ columnType: "PgTimestamp";
203
+ data: Date;
204
+ driverParam: string;
205
+ notNull: false;
206
+ hasDefault: false;
207
+ isPrimaryKey: false;
208
+ isAutoincrement: false;
209
+ hasRuntimeDefault: false;
210
+ enumValues: undefined;
211
+ baseColumn: never;
212
+ identity: undefined;
213
+ generated: undefined;
214
+ }, {}, {}>;
215
+ };
216
+ dialect: 'pg';
217
+ }>;
218
+ //# sourceMappingURL=live-action-runs.table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-action-runs.table.d.ts","sourceRoot":"","sources":["../../src/live-actions/live-action-runs.table.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEhG,mEAAmE;AACnE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoB/B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { index, jsonb, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
2
+ /** Drizzle table definition matching `liveActionRunsMigration`. */
3
+ export const liveActionRunsTable = pgTable("live_action_runs", {
4
+ id: uuid("id").primaryKey().notNull(),
5
+ actionName: text("action_name").notNull(),
6
+ dangerLevel: text("danger_level").notNull(),
7
+ actorType: text("actor_type").notNull(),
8
+ actorId: text("actor_id").notNull(),
9
+ reason: text("reason").notNull(),
10
+ redactedInput: jsonb("redacted_input").$type().notNull(),
11
+ outcome: text("outcome").notNull().$type(),
12
+ summary: text("summary"),
13
+ errorMessage: text("error_message"),
14
+ startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
15
+ finishedAt: timestamp("finished_at", { withTimezone: true }),
16
+ }, (table) => [
17
+ index("live_action_runs_started_at_idx").on(table.startedAt),
18
+ index("live_action_runs_action_started_at_idx").on(table.actionName, table.startedAt),
19
+ ]);
20
+ //# sourceMappingURL=live-action-runs.table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-action-runs.table.js","sourceRoot":"","sources":["../../src/live-actions/live-action-runs.table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGnF,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CACxC,kBAAkB,EAClB;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE;IACrC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;IACzC,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE;IAC3C,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;IAChC,aAAa,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,EAA2B,CAAC,OAAO,EAAE;IACjF,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,EAAwB;IAChE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;IACxB,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC;IACnC,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE;IACpE,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;CAC7D,EACD,CAAC,KAAK,EAAE,EAAE,CAAC;IACT,KAAK,CAAC,iCAAiC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;IAC5D,KAAK,CAAC,wCAAwC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;CACtF,CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { LiveActionQueryClient, LiveActionRunStore } from "./live-action-run-types.js";
2
+ /**
3
+ * Creates a PostgreSQL-backed `LiveActionRunStore` persisting runs into the
4
+ * `live_action_runs` table created by `liveActionRunsMigration`.
5
+ */
6
+ export declare function createPostgresLiveActionRunStore(pool: LiveActionQueryClient): LiveActionRunStore;
7
+ //# sourceMappingURL=postgres-live-action-run-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-live-action-run-store.d.ts","sourceRoot":"","sources":["../../src/live-actions/postgres-live-action-run-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,qBAAqB,EAErB,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAkGpC;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,qBAAqB,GAAG,kBAAkB,CAqEhG"}
@@ -0,0 +1,146 @@
1
+ import { z } from "zod";
2
+ const DEFAULT_RECENT_LIMIT = 50;
3
+ const MAX_RECENT_LIMIT = 500;
4
+ const liveActionDangerLevelSchema = z.enum(["safe", "cautious", "destructive"]);
5
+ const liveActionOutcomeSchema = z.enum(["running", "succeeded", "failed"]);
6
+ const pgTimestampSchema = z.union([z.date(), z.string().min(1)]).transform((value, ctx) => {
7
+ const date = value instanceof Date ? value : new Date(value);
8
+ if (Number.isNaN(date.getTime())) {
9
+ ctx.addIssue({ code: "custom", message: "Invalid timestamp value in live_action_runs row" });
10
+ return z.NEVER;
11
+ }
12
+ return date;
13
+ });
14
+ const liveActionRunRowSchema = z.object({
15
+ id: z.string().min(1),
16
+ action_name: z.string().min(1),
17
+ danger_level: liveActionDangerLevelSchema,
18
+ actor_type: z.string().min(1),
19
+ actor_id: z.string().min(1),
20
+ reason: z.string(),
21
+ redacted_input: z.unknown(),
22
+ outcome: liveActionOutcomeSchema,
23
+ summary: z.string().nullable(),
24
+ error_message: z.string().nullable(),
25
+ started_at: pgTimestampSchema,
26
+ finished_at: pgTimestampSchema.nullable(),
27
+ });
28
+ const startRunInputSchema = z.strictObject({
29
+ id: z.string().min(1),
30
+ actionName: z.string().min(1),
31
+ dangerLevel: liveActionDangerLevelSchema,
32
+ actorType: z.string().min(1),
33
+ actorId: z.string().min(1),
34
+ reason: z.string(),
35
+ redactedInput: z.unknown(),
36
+ outcome: liveActionOutcomeSchema,
37
+ summary: z.string().nullable(),
38
+ errorMessage: z.string().nullable(),
39
+ startedAt: z.date(),
40
+ finishedAt: z.date().nullable(),
41
+ });
42
+ const finishRunInputSchema = z.strictObject({
43
+ id: z.string().min(1),
44
+ outcome: z.enum(["succeeded", "failed"]),
45
+ summary: z.string().nullable(),
46
+ errorMessage: z.string().nullable(),
47
+ finishedAt: z.date(),
48
+ });
49
+ const listRecentOptionsSchema = z.strictObject({
50
+ actionName: z.string().min(1).optional(),
51
+ limit: z.number().int().min(1).max(MAX_RECENT_LIMIT).optional(),
52
+ });
53
+ const SELECT_RUN_COLUMNS = `
54
+ id,
55
+ action_name,
56
+ danger_level,
57
+ actor_type,
58
+ actor_id,
59
+ reason,
60
+ redacted_input,
61
+ outcome,
62
+ summary,
63
+ error_message,
64
+ started_at,
65
+ finished_at
66
+ `.trim();
67
+ function mapLiveActionRunRow(rawRow) {
68
+ const row = liveActionRunRowSchema.parse(rawRow);
69
+ return {
70
+ id: row.id,
71
+ actionName: row.action_name,
72
+ dangerLevel: row.danger_level,
73
+ actorType: row.actor_type,
74
+ actorId: row.actor_id,
75
+ reason: row.reason,
76
+ redactedInput: row.redacted_input,
77
+ outcome: row.outcome,
78
+ summary: row.summary,
79
+ errorMessage: row.error_message,
80
+ startedAt: row.started_at,
81
+ finishedAt: row.finished_at,
82
+ };
83
+ }
84
+ function serializeRedactedInput(value) {
85
+ const encoded = JSON.stringify(value === undefined ? null : value);
86
+ return typeof encoded === "string" ? encoded : "null";
87
+ }
88
+ /**
89
+ * Creates a PostgreSQL-backed `LiveActionRunStore` persisting runs into the
90
+ * `live_action_runs` table created by `liveActionRunsMigration`.
91
+ */
92
+ export function createPostgresLiveActionRunStore(pool) {
93
+ return {
94
+ async recordStart(run) {
95
+ const valid = startRunInputSchema.parse(run);
96
+ await pool.query(`INSERT INTO live_action_runs (
97
+ id, action_name, danger_level, actor_type, actor_id, reason,
98
+ redacted_input, outcome, summary, error_message, started_at, finished_at
99
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8, $9, $10, $11, $12)`, [
100
+ valid.id,
101
+ valid.actionName,
102
+ valid.dangerLevel,
103
+ valid.actorType,
104
+ valid.actorId,
105
+ valid.reason,
106
+ serializeRedactedInput(valid.redactedInput),
107
+ valid.outcome,
108
+ valid.summary,
109
+ valid.errorMessage,
110
+ valid.startedAt,
111
+ valid.finishedAt,
112
+ ]);
113
+ },
114
+ async recordFinish(input) {
115
+ const valid = finishRunInputSchema.parse(input);
116
+ await pool.query(`UPDATE live_action_runs
117
+ SET outcome = $2,
118
+ summary = $3,
119
+ error_message = $4,
120
+ finished_at = $5
121
+ WHERE id = $1`, [valid.id, valid.outcome, valid.summary, valid.errorMessage, valid.finishedAt]);
122
+ },
123
+ async getById(id) {
124
+ const validId = z.string().min(1).parse(id);
125
+ const result = await pool.query(`SELECT ${SELECT_RUN_COLUMNS} FROM live_action_runs WHERE id = $1`, [validId]);
126
+ const firstRow = result.rows[0];
127
+ return firstRow === undefined ? undefined : mapLiveActionRunRow(firstRow);
128
+ },
129
+ async listRecent(options) {
130
+ const valid = options === undefined ? {} : listRecentOptionsSchema.parse(options);
131
+ const limit = valid.limit ?? DEFAULT_RECENT_LIMIT;
132
+ const result = valid.actionName !== undefined
133
+ ? await pool.query(`SELECT ${SELECT_RUN_COLUMNS}
134
+ FROM live_action_runs
135
+ WHERE action_name = $1
136
+ ORDER BY started_at DESC, id DESC
137
+ LIMIT $2`, [valid.actionName, limit])
138
+ : await pool.query(`SELECT ${SELECT_RUN_COLUMNS}
139
+ FROM live_action_runs
140
+ ORDER BY started_at DESC, id DESC
141
+ LIMIT $1`, [limit]);
142
+ return result.rows.map(mapLiveActionRunRow);
143
+ },
144
+ };
145
+ }
146
+ //# sourceMappingURL=postgres-live-action-run-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-live-action-run-store.js","sourceRoot":"","sources":["../../src/live-actions/postgres-live-action-run-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;AAChF,MAAM,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE3E,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACxF,MAAM,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACjC,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC,CAAC;QAC7F,OAAO,CAAC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K,CAAC,CACR,CAAC;YACR,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -7,6 +7,6 @@ export { inspectNodePgMigrations } from "./lib/node-pg/inspect-node-pg-migration
7
7
  export { planMigrationOrder } from "./lib/node-pg/plan-migration-order.js";
8
8
  export { NODE_PG_APPLIED_TABLE, NODE_PG_CHECKSUM_TABLE, NODE_PG_JOURNAL_SCHEMA, NodePgMigrationJournalError, runNodePgMigrations, stampNodePgJournalAsApplied, } from "./lib/node-pg/run-node-pg-migrations.js";
9
9
  export { runDatabaseMigrations, type MigrationLog, type RunDatabaseMigrationsInput, } from "./lib/run-database-migrations.js";
10
- export { defaultMigrationWorkspace, type MigrationSource, type MigrationWorkspace, } from "./lib/node-pg/migration-workspace.js";
10
+ export { applicationMigrationWorkspace, defaultMigrationWorkspace, type ApplicationMigrationWorkspaceOptions, type MigrationSource, type MigrationWorkspace, } from "./lib/node-pg/migration-workspace.js";
11
11
  export { EquivalentSchemaMismatchError, stampJournalWhenSchemaMatches, } from "./lib/stamp-journal-when-schema-matches.js";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC5G,OAAO,EAAE,yBAAyB,EAAE,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClH,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,YAAY,EACV,6BAA6B,EAC7B,yBAAyB,EACzB,eAAe,EACf,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAA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CAAoC,EACzC,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,4CAA4C,CAAC"}
@@ -6,6 +6,6 @@ export { inspectNodePgMigrations } from "./lib/node-pg/inspect-node-pg-migration
6
6
  export { planMigrationOrder } from "./lib/node-pg/plan-migration-order.js";
7
7
  export { NODE_PG_APPLIED_TABLE, NODE_PG_CHECKSUM_TABLE, NODE_PG_JOURNAL_SCHEMA, NodePgMigrationJournalError, runNodePgMigrations, stampNodePgJournalAsApplied, } from "./lib/node-pg/run-node-pg-migrations.js";
8
8
  export { runDatabaseMigrations, } from "./lib/run-database-migrations.js";
9
- export { defaultMigrationWorkspace, } from "./lib/node-pg/migration-workspace.js";
9
+ export { applicationMigrationWorkspace, defaultMigrationWorkspace, } from "./lib/node-pg/migration-workspace.js";
10
10
  export { EquivalentSchemaMismatchError, stampJournalWhenSchemaMatches, } from "./lib/stamp-journal-when-schema-matches.js";
11
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAyB,MAAM,2CAA2C,CAAC;AAC5G,OAAO,EAAE,yBAAyB,EAA6B,MAAM,4CAA4C,CAAC;AAClH,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAOvF,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,qBAAqB,GAGtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,yBAAyB,GAG1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,4CAA4C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAyB,MAAM,2CAA2C,CAAC;AAC5G,OAAO,EAAE,yBAAyB,EAA6B,MAAM,4CAA4C,CAAC;AAClH,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAOvF,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,qBAAqB,GAGtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,GAI1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,4CAA4C,CAAC"}
@@ -31,10 +31,23 @@ export type MigrationWorkspace = {
31
31
  */
32
32
  readonly moduleAliases: Readonly<Record<string, string>>;
33
33
  };
34
+ export type ApplicationMigrationWorkspaceOptions = {
35
+ /** Extra migration sources (for example, framework package migrations). */
36
+ readonly extraSources?: readonly MigrationSource[];
37
+ /** Module aliases a migration file may import, each mapped relative to `root`. */
38
+ readonly moduleAliases?: Readonly<Record<string, string>>;
39
+ };
34
40
  /**
35
41
  * This repository's layout: every server part's
36
42
  * `src/lib/**\/migrations/` folder, owned by the part, plus an optional
37
43
  * top-level `migrations/` folder owned by the application.
38
44
  */
39
45
  export declare function defaultMigrationWorkspace(root: string): MigrationWorkspace;
46
+ /**
47
+ * An application workspace layout: an optional top-level `migrations/` folder
48
+ * owned by `"app"`, optional per-domain migrations under
49
+ * `domains/*\/server/migrations/` or `domains/*\/server/src/lib/database/migrations/`
50
+ * owned by the domain directory name, plus any caller-supplied extra sources.
51
+ */
52
+ export declare function applicationMigrationWorkspace(root: string, options?: ApplicationMigrationWorkspaceOptions): MigrationWorkspace;
40
53
  //# sourceMappingURL=migration-workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-workspace.d.ts","sourceRoot":"","sources":["../../../../src/migrations/lib/node-pg/migration-workspace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAkB1E"}
1
+ {"version":3,"file":"migration-workspace.d.ts","sourceRoot":"","sources":["../../../../src/migrations/lib/node-pg/migration-workspace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACnD,kFAAkF;IAClF,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAkB1E;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,oCAAoC,GAC7C,kBAAkB,CAmBpB"}
@@ -28,4 +28,30 @@ export function defaultMigrationWorkspace(root) {
28
28
  moduleAliases: {},
29
29
  };
30
30
  }
31
+ /**
32
+ * An application workspace layout: an optional top-level `migrations/` folder
33
+ * owned by `"app"`, optional per-domain migrations under
34
+ * `domains/*\/server/migrations/` or `domains/*\/server/src/lib/database/migrations/`
35
+ * owned by the domain directory name, plus any caller-supplied extra sources.
36
+ */
37
+ export function applicationMigrationWorkspace(root, options) {
38
+ return {
39
+ root,
40
+ sources: [
41
+ {
42
+ root: "migrations",
43
+ files: /^migrations\/[^/]+\.migration\.ts$/,
44
+ owner: "app",
45
+ required: false,
46
+ },
47
+ {
48
+ root: "domains",
49
+ files: /^domains\/([^/]+)\/server\/(?:src\/lib\/database\/)?migrations\/[^/]+\.migration\.ts$/,
50
+ required: false,
51
+ },
52
+ ...(options?.extraSources ?? []),
53
+ ],
54
+ moduleAliases: options?.moduleAliases ?? {},
55
+ };
56
+ }
31
57
  //# sourceMappingURL=migration-workspace.js.map