frg-data-diff 2.0.0

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 (62) hide show
  1. package/README.md +628 -0
  2. package/dist/apply/apply-diff.d.ts +24 -0
  3. package/dist/apply/apply-diff.js +205 -0
  4. package/dist/apply/conflict.d.ts +20 -0
  5. package/dist/apply/conflict.js +14 -0
  6. package/dist/apply/plan.d.ts +13 -0
  7. package/dist/apply/plan.js +37 -0
  8. package/dist/cli/apply.d.ts +8 -0
  9. package/dist/cli/apply.js +270 -0
  10. package/dist/cli/generator.d.ts +9 -0
  11. package/dist/cli/generator.js +804 -0
  12. package/dist/cli/pg-triggers.d.ts +2 -0
  13. package/dist/cli/pg-triggers.js +185 -0
  14. package/dist/cli/root.d.ts +8 -0
  15. package/dist/cli/root.js +231 -0
  16. package/dist/cli/sql.d.ts +9 -0
  17. package/dist/cli/sql.js +158 -0
  18. package/dist/config/config-schema.d.ts +380 -0
  19. package/dist/config/config-schema.js +95 -0
  20. package/dist/config/load-config.d.ts +12 -0
  21. package/dist/config/load-config.js +87 -0
  22. package/dist/config/resolve-options.d.ts +95 -0
  23. package/dist/config/resolve-options.js +183 -0
  24. package/dist/config/write-config.d.ts +18 -0
  25. package/dist/config/write-config.js +103 -0
  26. package/dist/db/connection.d.ts +28 -0
  27. package/dist/db/connection.js +34 -0
  28. package/dist/db/metadata.d.ts +70 -0
  29. package/dist/db/metadata.js +238 -0
  30. package/dist/db/pg-triggers.d.ts +27 -0
  31. package/dist/db/pg-triggers.js +59 -0
  32. package/dist/db/sql.d.ts +72 -0
  33. package/dist/db/sql.js +250 -0
  34. package/dist/diff/diff-schema.d.ts +380 -0
  35. package/dist/diff/diff-schema.js +67 -0
  36. package/dist/diff/generate-diff.d.ts +20 -0
  37. package/dist/diff/generate-diff.js +224 -0
  38. package/dist/diff/pg-triggers-diff.d.ts +11 -0
  39. package/dist/diff/pg-triggers-diff.js +161 -0
  40. package/dist/diff/serialize-value.d.ts +35 -0
  41. package/dist/diff/serialize-value.js +242 -0
  42. package/dist/diff/write-diff-yaml.d.ts +3 -0
  43. package/dist/diff/write-diff-yaml.js +48 -0
  44. package/dist/schema-diff/generate-schema-diff.d.ts +12 -0
  45. package/dist/schema-diff/generate-schema-diff.js +355 -0
  46. package/dist/schema-diff/generate-schema-sql.d.ts +20 -0
  47. package/dist/schema-diff/generate-schema-sql.js +187 -0
  48. package/dist/schema-diff/schema-diff-schema.d.ts +1088 -0
  49. package/dist/schema-diff/schema-diff-schema.js +70 -0
  50. package/dist/shared/env-values.d.ts +11 -0
  51. package/dist/shared/env-values.js +100 -0
  52. package/dist/shared/generator-wizard.d.ts +10 -0
  53. package/dist/shared/generator-wizard.js +337 -0
  54. package/dist/shared/identifiers.d.ts +24 -0
  55. package/dist/shared/identifiers.js +45 -0
  56. package/dist/shared/prompts.d.ts +26 -0
  57. package/dist/shared/prompts.js +104 -0
  58. package/dist/shared/summary.d.ts +33 -0
  59. package/dist/shared/summary.js +41 -0
  60. package/dist/sql/generate-sql.d.ts +19 -0
  61. package/dist/sql/generate-sql.js +223 -0
  62. package/package.json +39 -0
@@ -0,0 +1,380 @@
1
+ import { z } from "zod";
2
+ export declare const generatorConfigSchema: z.ZodObject<{
3
+ sourcePgHost: z.ZodEffects<z.ZodString, string, string>;
4
+ sourcePgPort: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
5
+ sourcePgDatabase: z.ZodEffects<z.ZodString, string, string>;
6
+ sourcePgUser: z.ZodEffects<z.ZodString, string, string>;
7
+ sourcePgPassword: z.ZodEffects<z.ZodString, string, string>;
8
+ sourcePgSsl: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
9
+ destPgHost: z.ZodEffects<z.ZodString, string, string>;
10
+ destPgPort: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
11
+ destPgDatabase: z.ZodEffects<z.ZodString, string, string>;
12
+ destPgUser: z.ZodEffects<z.ZodString, string, string>;
13
+ destPgPassword: z.ZodEffects<z.ZodString, string, string>;
14
+ destPgSsl: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
15
+ schema: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
16
+ tables: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
17
+ excludeTables: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
18
+ schemaDiffTables: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
19
+ schemaDiffExcludeTables: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
20
+ pgTriggersTables: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
21
+ pgTriggersExcludeTables: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
22
+ ignoreColumns: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
23
+ tablesWhereDataFilters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, string, string>>>;
24
+ includeDeletes: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
25
+ skipMissingPk: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
26
+ output: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
27
+ schemaDiffOutput: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
28
+ pgTriggersOutput: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
29
+ pretty: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
30
+ generateSql: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
31
+ generatePgTriggers: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ schema: string;
34
+ includeDeletes: string | boolean;
35
+ tables: string[];
36
+ sourcePgHost: string;
37
+ sourcePgPort: string | number;
38
+ sourcePgDatabase: string;
39
+ sourcePgUser: string;
40
+ sourcePgPassword: string;
41
+ sourcePgSsl: string | boolean;
42
+ destPgHost: string;
43
+ destPgPort: string | number;
44
+ destPgDatabase: string;
45
+ destPgUser: string;
46
+ destPgPassword: string;
47
+ destPgSsl: string | boolean;
48
+ excludeTables: string[] | null;
49
+ ignoreColumns: string[] | null;
50
+ skipMissingPk: string | boolean;
51
+ output: string;
52
+ pretty: string | boolean;
53
+ schemaDiffTables?: string[] | undefined;
54
+ schemaDiffExcludeTables?: string[] | null | undefined;
55
+ pgTriggersTables?: string[] | undefined;
56
+ pgTriggersExcludeTables?: string[] | null | undefined;
57
+ tablesWhereDataFilters?: Record<string, string> | undefined;
58
+ schemaDiffOutput?: string | undefined;
59
+ pgTriggersOutput?: string | undefined;
60
+ generateSql?: string | boolean | undefined;
61
+ generatePgTriggers?: string | boolean | undefined;
62
+ }, {
63
+ tables: string[];
64
+ sourcePgHost: string;
65
+ sourcePgPort: string | number;
66
+ sourcePgDatabase: string;
67
+ sourcePgUser: string;
68
+ sourcePgPassword: string;
69
+ destPgHost: string;
70
+ destPgPort: string | number;
71
+ destPgDatabase: string;
72
+ destPgUser: string;
73
+ destPgPassword: string;
74
+ schema?: string | undefined;
75
+ includeDeletes?: string | boolean | undefined;
76
+ sourcePgSsl?: string | boolean | undefined;
77
+ destPgSsl?: string | boolean | undefined;
78
+ excludeTables?: string[] | null | undefined;
79
+ schemaDiffTables?: string[] | undefined;
80
+ schemaDiffExcludeTables?: string[] | null | undefined;
81
+ pgTriggersTables?: string[] | undefined;
82
+ pgTriggersExcludeTables?: string[] | null | undefined;
83
+ ignoreColumns?: string[] | null | undefined;
84
+ tablesWhereDataFilters?: Record<string, string> | undefined;
85
+ skipMissingPk?: string | boolean | undefined;
86
+ output?: string | undefined;
87
+ schemaDiffOutput?: string | undefined;
88
+ pgTriggersOutput?: string | undefined;
89
+ pretty?: string | boolean | undefined;
90
+ generateSql?: string | boolean | undefined;
91
+ generatePgTriggers?: string | boolean | undefined;
92
+ }>;
93
+ export declare const applyConfigSchema: z.ZodObject<{
94
+ destPgHost: z.ZodEffects<z.ZodString, string, string>;
95
+ destPgPort: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
96
+ destPgDatabase: z.ZodEffects<z.ZodString, string, string>;
97
+ destPgUser: z.ZodEffects<z.ZodString, string, string>;
98
+ destPgPassword: z.ZodEffects<z.ZodString, string, string>;
99
+ destPgSsl: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
100
+ input: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
101
+ dryRun: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
102
+ applyInserts: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
103
+ applyUpdates: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
104
+ applyDeletes: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
105
+ conflictMode: z.ZodDefault<z.ZodUnion<[z.ZodEnum<["abort", "skip", "overwrite"]>, z.ZodString]>>;
106
+ insertMode: z.ZodDefault<z.ZodUnion<[z.ZodEnum<["strict", "upsert"]>, z.ZodString]>>;
107
+ transaction: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ destPgHost: string;
110
+ destPgPort: string | number;
111
+ destPgDatabase: string;
112
+ destPgUser: string;
113
+ destPgPassword: string;
114
+ destPgSsl: string | boolean;
115
+ input: string;
116
+ dryRun: string | boolean;
117
+ applyInserts: string | boolean;
118
+ applyUpdates: string | boolean;
119
+ applyDeletes: string | boolean;
120
+ conflictMode: string;
121
+ insertMode: string;
122
+ transaction: string | boolean;
123
+ }, {
124
+ destPgHost: string;
125
+ destPgPort: string | number;
126
+ destPgDatabase: string;
127
+ destPgUser: string;
128
+ destPgPassword: string;
129
+ destPgSsl?: string | boolean | undefined;
130
+ input?: string | undefined;
131
+ dryRun?: string | boolean | undefined;
132
+ applyInserts?: string | boolean | undefined;
133
+ applyUpdates?: string | boolean | undefined;
134
+ applyDeletes?: string | boolean | undefined;
135
+ conflictMode?: string | undefined;
136
+ insertMode?: string | undefined;
137
+ transaction?: string | boolean | undefined;
138
+ }>;
139
+ export declare const configSchema: z.ZodObject<{
140
+ format: z.ZodLiteral<"frg-data-diff-config/v1">;
141
+ generator: z.ZodObject<{
142
+ sourcePgHost: z.ZodEffects<z.ZodString, string, string>;
143
+ sourcePgPort: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
144
+ sourcePgDatabase: z.ZodEffects<z.ZodString, string, string>;
145
+ sourcePgUser: z.ZodEffects<z.ZodString, string, string>;
146
+ sourcePgPassword: z.ZodEffects<z.ZodString, string, string>;
147
+ sourcePgSsl: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
148
+ destPgHost: z.ZodEffects<z.ZodString, string, string>;
149
+ destPgPort: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
150
+ destPgDatabase: z.ZodEffects<z.ZodString, string, string>;
151
+ destPgUser: z.ZodEffects<z.ZodString, string, string>;
152
+ destPgPassword: z.ZodEffects<z.ZodString, string, string>;
153
+ destPgSsl: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
154
+ schema: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
155
+ tables: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
156
+ excludeTables: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
157
+ schemaDiffTables: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
158
+ schemaDiffExcludeTables: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
159
+ pgTriggersTables: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
160
+ pgTriggersExcludeTables: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
161
+ ignoreColumns: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>>;
162
+ tablesWhereDataFilters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, string, string>>>;
163
+ includeDeletes: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
164
+ skipMissingPk: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
165
+ output: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
166
+ schemaDiffOutput: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
167
+ pgTriggersOutput: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
168
+ pretty: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
169
+ generateSql: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
170
+ generatePgTriggers: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
171
+ }, "strip", z.ZodTypeAny, {
172
+ schema: string;
173
+ includeDeletes: string | boolean;
174
+ tables: string[];
175
+ sourcePgHost: string;
176
+ sourcePgPort: string | number;
177
+ sourcePgDatabase: string;
178
+ sourcePgUser: string;
179
+ sourcePgPassword: string;
180
+ sourcePgSsl: string | boolean;
181
+ destPgHost: string;
182
+ destPgPort: string | number;
183
+ destPgDatabase: string;
184
+ destPgUser: string;
185
+ destPgPassword: string;
186
+ destPgSsl: string | boolean;
187
+ excludeTables: string[] | null;
188
+ ignoreColumns: string[] | null;
189
+ skipMissingPk: string | boolean;
190
+ output: string;
191
+ pretty: string | boolean;
192
+ schemaDiffTables?: string[] | undefined;
193
+ schemaDiffExcludeTables?: string[] | null | undefined;
194
+ pgTriggersTables?: string[] | undefined;
195
+ pgTriggersExcludeTables?: string[] | null | undefined;
196
+ tablesWhereDataFilters?: Record<string, string> | undefined;
197
+ schemaDiffOutput?: string | undefined;
198
+ pgTriggersOutput?: string | undefined;
199
+ generateSql?: string | boolean | undefined;
200
+ generatePgTriggers?: string | boolean | undefined;
201
+ }, {
202
+ tables: string[];
203
+ sourcePgHost: string;
204
+ sourcePgPort: string | number;
205
+ sourcePgDatabase: string;
206
+ sourcePgUser: string;
207
+ sourcePgPassword: string;
208
+ destPgHost: string;
209
+ destPgPort: string | number;
210
+ destPgDatabase: string;
211
+ destPgUser: string;
212
+ destPgPassword: string;
213
+ schema?: string | undefined;
214
+ includeDeletes?: string | boolean | undefined;
215
+ sourcePgSsl?: string | boolean | undefined;
216
+ destPgSsl?: string | boolean | undefined;
217
+ excludeTables?: string[] | null | undefined;
218
+ schemaDiffTables?: string[] | undefined;
219
+ schemaDiffExcludeTables?: string[] | null | undefined;
220
+ pgTriggersTables?: string[] | undefined;
221
+ pgTriggersExcludeTables?: string[] | null | undefined;
222
+ ignoreColumns?: string[] | null | undefined;
223
+ tablesWhereDataFilters?: Record<string, string> | undefined;
224
+ skipMissingPk?: string | boolean | undefined;
225
+ output?: string | undefined;
226
+ schemaDiffOutput?: string | undefined;
227
+ pgTriggersOutput?: string | undefined;
228
+ pretty?: string | boolean | undefined;
229
+ generateSql?: string | boolean | undefined;
230
+ generatePgTriggers?: string | boolean | undefined;
231
+ }>;
232
+ apply: z.ZodObject<{
233
+ destPgHost: z.ZodEffects<z.ZodString, string, string>;
234
+ destPgPort: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
235
+ destPgDatabase: z.ZodEffects<z.ZodString, string, string>;
236
+ destPgUser: z.ZodEffects<z.ZodString, string, string>;
237
+ destPgPassword: z.ZodEffects<z.ZodString, string, string>;
238
+ destPgSsl: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
239
+ input: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
240
+ dryRun: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
241
+ applyInserts: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
242
+ applyUpdates: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
243
+ applyDeletes: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
244
+ conflictMode: z.ZodDefault<z.ZodUnion<[z.ZodEnum<["abort", "skip", "overwrite"]>, z.ZodString]>>;
245
+ insertMode: z.ZodDefault<z.ZodUnion<[z.ZodEnum<["strict", "upsert"]>, z.ZodString]>>;
246
+ transaction: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
247
+ }, "strip", z.ZodTypeAny, {
248
+ destPgHost: string;
249
+ destPgPort: string | number;
250
+ destPgDatabase: string;
251
+ destPgUser: string;
252
+ destPgPassword: string;
253
+ destPgSsl: string | boolean;
254
+ input: string;
255
+ dryRun: string | boolean;
256
+ applyInserts: string | boolean;
257
+ applyUpdates: string | boolean;
258
+ applyDeletes: string | boolean;
259
+ conflictMode: string;
260
+ insertMode: string;
261
+ transaction: string | boolean;
262
+ }, {
263
+ destPgHost: string;
264
+ destPgPort: string | number;
265
+ destPgDatabase: string;
266
+ destPgUser: string;
267
+ destPgPassword: string;
268
+ destPgSsl?: string | boolean | undefined;
269
+ input?: string | undefined;
270
+ dryRun?: string | boolean | undefined;
271
+ applyInserts?: string | boolean | undefined;
272
+ applyUpdates?: string | boolean | undefined;
273
+ applyDeletes?: string | boolean | undefined;
274
+ conflictMode?: string | undefined;
275
+ insertMode?: string | undefined;
276
+ transaction?: string | boolean | undefined;
277
+ }>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ format: "frg-data-diff-config/v1";
280
+ generator: {
281
+ schema: string;
282
+ includeDeletes: string | boolean;
283
+ tables: string[];
284
+ sourcePgHost: string;
285
+ sourcePgPort: string | number;
286
+ sourcePgDatabase: string;
287
+ sourcePgUser: string;
288
+ sourcePgPassword: string;
289
+ sourcePgSsl: string | boolean;
290
+ destPgHost: string;
291
+ destPgPort: string | number;
292
+ destPgDatabase: string;
293
+ destPgUser: string;
294
+ destPgPassword: string;
295
+ destPgSsl: string | boolean;
296
+ excludeTables: string[] | null;
297
+ ignoreColumns: string[] | null;
298
+ skipMissingPk: string | boolean;
299
+ output: string;
300
+ pretty: string | boolean;
301
+ schemaDiffTables?: string[] | undefined;
302
+ schemaDiffExcludeTables?: string[] | null | undefined;
303
+ pgTriggersTables?: string[] | undefined;
304
+ pgTriggersExcludeTables?: string[] | null | undefined;
305
+ tablesWhereDataFilters?: Record<string, string> | undefined;
306
+ schemaDiffOutput?: string | undefined;
307
+ pgTriggersOutput?: string | undefined;
308
+ generateSql?: string | boolean | undefined;
309
+ generatePgTriggers?: string | boolean | undefined;
310
+ };
311
+ apply: {
312
+ destPgHost: string;
313
+ destPgPort: string | number;
314
+ destPgDatabase: string;
315
+ destPgUser: string;
316
+ destPgPassword: string;
317
+ destPgSsl: string | boolean;
318
+ input: string;
319
+ dryRun: string | boolean;
320
+ applyInserts: string | boolean;
321
+ applyUpdates: string | boolean;
322
+ applyDeletes: string | boolean;
323
+ conflictMode: string;
324
+ insertMode: string;
325
+ transaction: string | boolean;
326
+ };
327
+ }, {
328
+ format: "frg-data-diff-config/v1";
329
+ generator: {
330
+ tables: string[];
331
+ sourcePgHost: string;
332
+ sourcePgPort: string | number;
333
+ sourcePgDatabase: string;
334
+ sourcePgUser: string;
335
+ sourcePgPassword: string;
336
+ destPgHost: string;
337
+ destPgPort: string | number;
338
+ destPgDatabase: string;
339
+ destPgUser: string;
340
+ destPgPassword: string;
341
+ schema?: string | undefined;
342
+ includeDeletes?: string | boolean | undefined;
343
+ sourcePgSsl?: string | boolean | undefined;
344
+ destPgSsl?: string | boolean | undefined;
345
+ excludeTables?: string[] | null | undefined;
346
+ schemaDiffTables?: string[] | undefined;
347
+ schemaDiffExcludeTables?: string[] | null | undefined;
348
+ pgTriggersTables?: string[] | undefined;
349
+ pgTriggersExcludeTables?: string[] | null | undefined;
350
+ ignoreColumns?: string[] | null | undefined;
351
+ tablesWhereDataFilters?: Record<string, string> | undefined;
352
+ skipMissingPk?: string | boolean | undefined;
353
+ output?: string | undefined;
354
+ schemaDiffOutput?: string | undefined;
355
+ pgTriggersOutput?: string | undefined;
356
+ pretty?: string | boolean | undefined;
357
+ generateSql?: string | boolean | undefined;
358
+ generatePgTriggers?: string | boolean | undefined;
359
+ };
360
+ apply: {
361
+ destPgHost: string;
362
+ destPgPort: string | number;
363
+ destPgDatabase: string;
364
+ destPgUser: string;
365
+ destPgPassword: string;
366
+ destPgSsl?: string | boolean | undefined;
367
+ input?: string | undefined;
368
+ dryRun?: string | boolean | undefined;
369
+ applyInserts?: string | boolean | undefined;
370
+ applyUpdates?: string | boolean | undefined;
371
+ applyDeletes?: string | boolean | undefined;
372
+ conflictMode?: string | undefined;
373
+ insertMode?: string | undefined;
374
+ transaction?: string | boolean | undefined;
375
+ };
376
+ }>;
377
+ export type GeneratorConfig = z.infer<typeof generatorConfigSchema>;
378
+ export type ApplyConfig = z.infer<typeof applyConfigSchema>;
379
+ export type Config = z.infer<typeof configSchema>;
380
+ //# sourceMappingURL=config-schema.d.ts.map
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configSchema = exports.applyConfigSchema = exports.generatorConfigSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ENV_REFERENCE_PATTERN = /^\$[A-Za-z_][A-Za-z0-9_]*$/;
6
+ const envCapableString = zod_1.z
7
+ .string()
8
+ .min(1, "Value must not be empty")
9
+ .refine((value) => !value.startsWith("$") || ENV_REFERENCE_PATTERN.test(value), "Environment variable references must match /^\\$[A-Za-z_][A-Za-z0-9_]*$/");
10
+ const envCapablePort = zod_1.z.union([
11
+ zod_1.z.number().int().min(1).max(65535),
12
+ zod_1.z
13
+ .string()
14
+ .regex(ENV_REFERENCE_PATTERN, "Port env var reference must match /^\\$[A-Za-z_][A-Za-z0-9_]*$/"),
15
+ ]);
16
+ const envCapableBoolean = zod_1.z.union([
17
+ zod_1.z.boolean(),
18
+ zod_1.z
19
+ .string()
20
+ .regex(ENV_REFERENCE_PATTERN, "Boolean env var reference must match /^\\$[A-Za-z_][A-Za-z0-9_]*$/"),
21
+ ]);
22
+ const envCapableListItem = zod_1.z
23
+ .string()
24
+ .min(1, "List values must not be empty")
25
+ .refine((value) => !value.startsWith("$") || ENV_REFERENCE_PATTERN.test(value), "List env var references must match /^\\$[A-Za-z_][A-Za-z0-9_]*$/");
26
+ const tableWhereDataFilters = zod_1.z.record(zod_1.z.string().min(1, "Table names must not be empty"), zod_1.z
27
+ .string()
28
+ .refine((value) => value.trim().length > 0, "SQL WHERE fragments must not be empty"));
29
+ exports.generatorConfigSchema = zod_1.z.object({
30
+ sourcePgHost: envCapableString,
31
+ sourcePgPort: envCapablePort,
32
+ sourcePgDatabase: envCapableString,
33
+ sourcePgUser: envCapableString,
34
+ sourcePgPassword: envCapableString,
35
+ sourcePgSsl: envCapableBoolean.default(false),
36
+ destPgHost: envCapableString,
37
+ destPgPort: envCapablePort,
38
+ destPgDatabase: envCapableString,
39
+ destPgUser: envCapableString,
40
+ destPgPassword: envCapableString,
41
+ destPgSsl: envCapableBoolean.default(false),
42
+ schema: envCapableString.default("public"),
43
+ tables: zod_1.z.array(envCapableListItem),
44
+ excludeTables: zod_1.z.array(envCapableListItem).nullable().default([]),
45
+ schemaDiffTables: zod_1.z.array(envCapableListItem).optional(),
46
+ schemaDiffExcludeTables: zod_1.z.array(envCapableListItem).nullable().optional(),
47
+ pgTriggersTables: zod_1.z.array(envCapableListItem).optional(),
48
+ pgTriggersExcludeTables: zod_1.z.array(envCapableListItem).nullable().optional(),
49
+ ignoreColumns: zod_1.z.array(envCapableListItem).nullable().default([]),
50
+ tablesWhereDataFilters: tableWhereDataFilters.optional(),
51
+ includeDeletes: envCapableBoolean.default(true),
52
+ skipMissingPk: envCapableBoolean.default(true),
53
+ output: envCapableString.default("frg-data-diff.json"),
54
+ schemaDiffOutput: envCapableString.optional(),
55
+ pgTriggersOutput: envCapableString.optional(),
56
+ pretty: envCapableBoolean.default(true),
57
+ generateSql: envCapableBoolean.optional(),
58
+ generatePgTriggers: envCapableBoolean.optional(),
59
+ });
60
+ exports.applyConfigSchema = zod_1.z.object({
61
+ destPgHost: envCapableString,
62
+ destPgPort: envCapablePort,
63
+ destPgDatabase: envCapableString,
64
+ destPgUser: envCapableString,
65
+ destPgPassword: envCapableString,
66
+ destPgSsl: envCapableBoolean.default(false),
67
+ input: envCapableString.default("frg-data-diff.json"),
68
+ dryRun: envCapableBoolean.default(true),
69
+ applyInserts: envCapableBoolean.default(true),
70
+ applyUpdates: envCapableBoolean.default(true),
71
+ applyDeletes: envCapableBoolean.default(false),
72
+ conflictMode: zod_1.z
73
+ .union([
74
+ zod_1.z.enum(["abort", "skip", "overwrite"]),
75
+ zod_1.z
76
+ .string()
77
+ .regex(ENV_REFERENCE_PATTERN, "Conflict mode env var reference must match /^\\$[A-Za-z_][A-Za-z0-9_]*$/"),
78
+ ])
79
+ .default("abort"),
80
+ insertMode: zod_1.z
81
+ .union([
82
+ zod_1.z.enum(["strict", "upsert"]),
83
+ zod_1.z
84
+ .string()
85
+ .regex(ENV_REFERENCE_PATTERN, "Insert mode env var reference must match /^\\$[A-Za-z_][A-Za-z0-9_]*$/"),
86
+ ])
87
+ .default("strict"),
88
+ transaction: envCapableBoolean.default(true),
89
+ });
90
+ exports.configSchema = zod_1.z.object({
91
+ format: zod_1.z.literal("frg-data-diff-config/v1"),
92
+ generator: exports.generatorConfigSchema,
93
+ apply: exports.applyConfigSchema,
94
+ });
95
+ //# sourceMappingURL=config-schema.js.map
@@ -0,0 +1,12 @@
1
+ import { type Config } from "./config-schema";
2
+ export declare const DEFAULT_CONFIG_FILENAME = ".frg-data-diff.config.json";
3
+ /**
4
+ * Returns the path to the config file if it exists, or null.
5
+ */
6
+ export declare function findConfigFile(cwd?: string): string | null;
7
+ /**
8
+ * Loads and validates the config file at the given path.
9
+ * Exits with a clear error if validation fails.
10
+ */
11
+ export declare function loadConfig(configPath: string): Config;
12
+ //# sourceMappingURL=load-config.d.ts.map
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DEFAULT_CONFIG_FILENAME = void 0;
37
+ exports.findConfigFile = findConfigFile;
38
+ exports.loadConfig = loadConfig;
39
+ const fs = __importStar(require("fs"));
40
+ const path = __importStar(require("path"));
41
+ const config_schema_1 = require("./config-schema");
42
+ exports.DEFAULT_CONFIG_FILENAME = ".frg-data-diff.config.json";
43
+ /**
44
+ * Returns the path to the config file if it exists, or null.
45
+ */
46
+ function findConfigFile(cwd = process.cwd()) {
47
+ const configPath = path.join(cwd, exports.DEFAULT_CONFIG_FILENAME);
48
+ if (fs.existsSync(configPath)) {
49
+ return configPath;
50
+ }
51
+ return null;
52
+ }
53
+ /**
54
+ * Loads and validates the config file at the given path.
55
+ * Exits with a clear error if validation fails.
56
+ */
57
+ function loadConfig(configPath) {
58
+ let raw;
59
+ try {
60
+ raw = fs.readFileSync(configPath, "utf-8");
61
+ }
62
+ catch (err) {
63
+ console.error(`Failed to read config file: ${configPath}`);
64
+ if (err instanceof Error)
65
+ console.error(err.message);
66
+ process.exit(1);
67
+ }
68
+ let parsed;
69
+ try {
70
+ parsed = JSON.parse(raw);
71
+ }
72
+ catch (err) {
73
+ console.error(`Failed to parse config file as JSON: ${configPath}`);
74
+ if (err instanceof Error)
75
+ console.error(err.message);
76
+ process.exit(1);
77
+ }
78
+ const result = config_schema_1.configSchema.safeParse(parsed);
79
+ if (!result.success) {
80
+ console.error(`Config file validation failed: ${configPath}`);
81
+ const formatted = result.error.format();
82
+ console.error(JSON.stringify(formatted, null, 2));
83
+ process.exit(1);
84
+ }
85
+ return result.data;
86
+ }
87
+ //# sourceMappingURL=load-config.js.map
@@ -0,0 +1,95 @@
1
+ import { type GeneratorConfig, type ApplyConfig } from "./config-schema";
2
+ /**
3
+ * Resolved generator options merged from CLI args and config.
4
+ */
5
+ export interface ResolvedGeneratorOptions {
6
+ sourcePgHost: string;
7
+ sourcePgPort: number | string;
8
+ sourcePgDatabase: string;
9
+ sourcePgUser: string;
10
+ sourcePgPassword: string;
11
+ sourcePgSsl: boolean | string;
12
+ destPgHost: string;
13
+ destPgPort: number | string;
14
+ destPgDatabase: string;
15
+ destPgUser: string;
16
+ destPgPassword: string;
17
+ destPgSsl: boolean | string;
18
+ schema: string;
19
+ tables: string[];
20
+ excludeTables: string[];
21
+ schemaDiffTables: string[];
22
+ schemaDiffExcludeTables: string[];
23
+ pgTriggersTables: string[];
24
+ pgTriggersExcludeTables: string[];
25
+ ignoreColumns: string[];
26
+ tablesWhereDataFilters?: Record<string, string>;
27
+ includeDeletes: boolean | string;
28
+ skipMissingPk: boolean | string;
29
+ output: string;
30
+ schemaDiffOutput: string;
31
+ pgTriggersOutput: string;
32
+ pretty: boolean | string;
33
+ generateSql?: boolean | string;
34
+ generatePgTriggers?: boolean | string;
35
+ verbose: boolean;
36
+ }
37
+ export interface RuntimeGeneratorOptions extends Omit<ResolvedGeneratorOptions, "sourcePgSsl" | "destPgSsl" | "includeDeletes" | "skipMissingPk" | "pretty" | "generateSql" | "generatePgTriggers"> {
38
+ sourcePgSsl: boolean;
39
+ destPgSsl: boolean;
40
+ includeDeletes: boolean;
41
+ skipMissingPk: boolean;
42
+ pretty: boolean;
43
+ generateSql?: boolean;
44
+ generatePgTriggers?: boolean;
45
+ }
46
+ export type OptionalListInput = string[] | null;
47
+ export type GeneratorOptionInput = Partial<Omit<ResolvedGeneratorOptions, "excludeTables" | "schemaDiffExcludeTables" | "pgTriggersExcludeTables" | "ignoreColumns"> & {
48
+ excludeTables: OptionalListInput;
49
+ schemaDiffExcludeTables: OptionalListInput;
50
+ pgTriggersExcludeTables: OptionalListInput;
51
+ ignoreColumns: OptionalListInput;
52
+ }>;
53
+ /**
54
+ * Resolved apply options merged from CLI args and config.
55
+ */
56
+ export interface ResolvedApplyOptions {
57
+ destPgHost: string;
58
+ destPgPort: number | string;
59
+ destPgDatabase: string;
60
+ destPgUser: string;
61
+ destPgPassword: string;
62
+ destPgSsl: boolean | string;
63
+ input: string;
64
+ dryRun: boolean | string;
65
+ applyInserts: boolean | string;
66
+ applyUpdates: boolean | string;
67
+ applyDeletes: boolean | string;
68
+ conflictMode: "abort" | "skip" | "overwrite" | string;
69
+ insertMode: "strict" | "upsert" | string;
70
+ transaction: boolean | string;
71
+ verbose: boolean;
72
+ }
73
+ export interface RuntimeApplyOptions extends Omit<ResolvedApplyOptions, "destPgSsl" | "dryRun" | "applyInserts" | "applyUpdates" | "applyDeletes" | "conflictMode" | "insertMode" | "transaction"> {
74
+ destPgSsl: boolean;
75
+ dryRun: boolean;
76
+ applyInserts: boolean;
77
+ applyUpdates: boolean;
78
+ applyDeletes: boolean;
79
+ conflictMode: "abort" | "skip" | "overwrite";
80
+ insertMode: "strict" | "upsert";
81
+ transaction: boolean;
82
+ }
83
+ /**
84
+ * Merges generator CLI args on top of config values.
85
+ * CLI args take precedence over config values.
86
+ */
87
+ export declare function resolveGeneratorOptions(config: GeneratorConfig | undefined, cliArgs: GeneratorOptionInput): ResolvedGeneratorOptions;
88
+ /**
89
+ * Merges apply CLI args on top of config values.
90
+ * CLI args take precedence over config values.
91
+ */
92
+ export declare function resolveApplyOptions(config: ApplyConfig | undefined, cliArgs: Partial<ResolvedApplyOptions>): ResolvedApplyOptions;
93
+ export declare function resolveRuntimeGeneratorOptions(options: ResolvedGeneratorOptions): RuntimeGeneratorOptions;
94
+ export declare function resolveRuntimeApplyOptions(options: ResolvedApplyOptions): RuntimeApplyOptions;
95
+ //# sourceMappingURL=resolve-options.d.ts.map