chkit 0.1.0-beta.5

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 (114) hide show
  1. package/README.md +43 -0
  2. package/dist/bin/chkit.d.ts +3 -0
  3. package/dist/bin/chkit.d.ts.map +1 -0
  4. package/dist/bin/chkit.js +337 -0
  5. package/dist/bin/chkit.js.map +1 -0
  6. package/dist/bin/commands/check.d.ts +2 -0
  7. package/dist/bin/commands/check.d.ts.map +1 -0
  8. package/dist/bin/commands/check.js +123 -0
  9. package/dist/bin/commands/check.js.map +1 -0
  10. package/dist/bin/commands/codegen.d.ts +2 -0
  11. package/dist/bin/commands/codegen.d.ts.map +1 -0
  12. package/dist/bin/commands/codegen.js +25 -0
  13. package/dist/bin/commands/codegen.js.map +1 -0
  14. package/dist/bin/commands/drift.d.ts +22 -0
  15. package/dist/bin/commands/drift.d.ts.map +1 -0
  16. package/dist/bin/commands/drift.js +170 -0
  17. package/dist/bin/commands/drift.js.map +1 -0
  18. package/dist/bin/commands/generate/output.d.ts +8 -0
  19. package/dist/bin/commands/generate/output.d.ts.map +1 -0
  20. package/dist/bin/commands/generate/output.js +58 -0
  21. package/dist/bin/commands/generate/output.js.map +1 -0
  22. package/dist/bin/commands/generate/plan-pipeline.d.ts +7 -0
  23. package/dist/bin/commands/generate/plan-pipeline.d.ts.map +1 -0
  24. package/dist/bin/commands/generate/plan-pipeline.js +139 -0
  25. package/dist/bin/commands/generate/plan-pipeline.js.map +1 -0
  26. package/dist/bin/commands/generate/rename-mappings.d.ts +29 -0
  27. package/dist/bin/commands/generate/rename-mappings.d.ts.map +1 -0
  28. package/dist/bin/commands/generate/rename-mappings.js +207 -0
  29. package/dist/bin/commands/generate/rename-mappings.js.map +1 -0
  30. package/dist/bin/commands/generate.d.ts +2 -0
  31. package/dist/bin/commands/generate.d.ts.map +1 -0
  32. package/dist/bin/commands/generate.js +137 -0
  33. package/dist/bin/commands/generate.js.map +1 -0
  34. package/dist/bin/commands/init.d.ts +2 -0
  35. package/dist/bin/commands/init.d.ts.map +1 -0
  36. package/dist/bin/commands/init.js +12 -0
  37. package/dist/bin/commands/init.js.map +1 -0
  38. package/dist/bin/commands/migrate.d.ts +2 -0
  39. package/dist/bin/commands/migrate.d.ts.map +1 -0
  40. package/dist/bin/commands/migrate.js +262 -0
  41. package/dist/bin/commands/migrate.js.map +1 -0
  42. package/dist/bin/commands/plugin-like.d.ts +38 -0
  43. package/dist/bin/commands/plugin-like.d.ts.map +1 -0
  44. package/dist/bin/commands/plugin-like.js +101 -0
  45. package/dist/bin/commands/plugin-like.js.map +1 -0
  46. package/dist/bin/commands/plugin.d.ts +2 -0
  47. package/dist/bin/commands/plugin.d.ts.map +1 -0
  48. package/dist/bin/commands/plugin.js +92 -0
  49. package/dist/bin/commands/plugin.js.map +1 -0
  50. package/dist/bin/commands/pull.d.ts +2 -0
  51. package/dist/bin/commands/pull.d.ts.map +1 -0
  52. package/dist/bin/commands/pull.js +25 -0
  53. package/dist/bin/commands/pull.js.map +1 -0
  54. package/dist/bin/commands/status.d.ts +2 -0
  55. package/dist/bin/commands/status.d.ts.map +1 -0
  56. package/dist/bin/commands/status.js +42 -0
  57. package/dist/bin/commands/status.js.map +1 -0
  58. package/dist/bin/commands/typegen.d.ts +2 -0
  59. package/dist/bin/commands/typegen.d.ts.map +1 -0
  60. package/dist/bin/commands/typegen.js +25 -0
  61. package/dist/bin/commands/typegen.js.map +1 -0
  62. package/dist/bin/config.d.ts +26 -0
  63. package/dist/bin/config.d.ts.map +1 -0
  64. package/dist/bin/config.js +59 -0
  65. package/dist/bin/config.js.map +1 -0
  66. package/dist/bin/json-output.d.ts +8 -0
  67. package/dist/bin/json-output.d.ts.map +1 -0
  68. package/dist/bin/json-output.js +21 -0
  69. package/dist/bin/json-output.js.map +1 -0
  70. package/dist/bin/lib.d.ts +7 -0
  71. package/dist/bin/lib.d.ts.map +1 -0
  72. package/dist/bin/lib.js +7 -0
  73. package/dist/bin/lib.js.map +1 -0
  74. package/dist/bin/migration-store.d.ts +24 -0
  75. package/dist/bin/migration-store.d.ts.map +1 -0
  76. package/dist/bin/migration-store.js +96 -0
  77. package/dist/bin/migration-store.js.map +1 -0
  78. package/dist/bin/plugin-runtime.d.ts +37 -0
  79. package/dist/bin/plugin-runtime.d.ts.map +1 -0
  80. package/dist/bin/plugin-runtime.js +264 -0
  81. package/dist/bin/plugin-runtime.js.map +1 -0
  82. package/dist/bin/safety-markers.d.ts +24 -0
  83. package/dist/bin/safety-markers.d.ts.map +1 -0
  84. package/dist/bin/safety-markers.js +94 -0
  85. package/dist/bin/safety-markers.js.map +1 -0
  86. package/dist/bin/schema-loader.d.ts +3 -0
  87. package/dist/bin/schema-loader.d.ts.map +1 -0
  88. package/dist/bin/schema-loader.js +6 -0
  89. package/dist/bin/schema-loader.js.map +1 -0
  90. package/dist/bin/table-scope.d.ts +39 -0
  91. package/dist/bin/table-scope.d.ts.map +1 -0
  92. package/dist/bin/table-scope.js +167 -0
  93. package/dist/bin/table-scope.js.map +1 -0
  94. package/dist/bin/version.d.ts +2 -0
  95. package/dist/bin/version.d.ts.map +1 -0
  96. package/dist/bin/version.js +2 -0
  97. package/dist/bin/version.js.map +1 -0
  98. package/dist/drift-diff.d.ts +8 -0
  99. package/dist/drift-diff.d.ts.map +1 -0
  100. package/dist/drift-diff.js +46 -0
  101. package/dist/drift-diff.js.map +1 -0
  102. package/dist/drift.d.ts +65 -0
  103. package/dist/drift.d.ts.map +1 -0
  104. package/dist/drift.js +209 -0
  105. package/dist/drift.js.map +1 -0
  106. package/dist/index.d.ts +2 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +2 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/plugins.d.ts +103 -0
  111. package/dist/plugins.d.ts.map +1 -0
  112. package/dist/plugins.js +10 -0
  113. package/dist/plugins.js.map +1 -0
  114. package/package.json +28 -0
@@ -0,0 +1,262 @@
1
+ import { mkdir, readFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import process from 'node:process';
4
+ import { createInterface } from 'node:readline/promises';
5
+ import { createClickHouseExecutor } from '@chkit/clickhouse';
6
+ import { CLI_VERSION } from '../version.js';
7
+ import { getCommandContext, hasFlag, parseArg } from '../config.js';
8
+ import { emitJson } from '../json-output.js';
9
+ import { checksumSQL, findChecksumMismatches, listMigrations, readJournal, readSnapshot, writeJournal, } from '../migration-store.js';
10
+ import { loadPluginRuntime } from '../plugin-runtime.js';
11
+ import { collectDestructiveOperationMarkers, extractExecutableStatements, extractMigrationOperationSummaries, migrationContainsDangerOperation, } from '../safety-markers.js';
12
+ import { databaseKeyFromOperationKey, resolveTableScope, tableKeyFromOperationKey, tableKeysFromDefinitions } from '../table-scope.js';
13
+ function isBackgroundOrCI() {
14
+ return process.env.CI === '1' || process.env.CI === 'true' || !process.stdin.isTTY || !process.stdout.isTTY;
15
+ }
16
+ function printDestructiveOperationDetails(markers) {
17
+ console.log('Destructive operations detected:');
18
+ for (const [index, marker] of markers.entries()) {
19
+ console.log(`${index + 1}. ${marker.migration}`);
20
+ console.log(` operation: ${marker.type}`);
21
+ console.log(` key: ${marker.key}`);
22
+ console.log(` warning: ${marker.warningCode}`);
23
+ console.log(` reason: ${marker.reason}`);
24
+ console.log(` impact: ${marker.impact}`);
25
+ console.log(` recommendation: ${marker.recommendation}`);
26
+ }
27
+ }
28
+ async function confirmDestructiveExecution(markers) {
29
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
30
+ try {
31
+ printDestructiveOperationDetails(markers);
32
+ console.log('');
33
+ console.log('Type "yes" to continue. Any other input cancels.');
34
+ const response = await rl.question('Apply destructive operations? [no/yes]: ');
35
+ return response.trim().toLowerCase() === 'yes';
36
+ }
37
+ finally {
38
+ rl.close();
39
+ }
40
+ }
41
+ async function filterPendingByScope(migrationsDir, pending, selectedTables) {
42
+ const selectedDatabases = new Set([...selectedTables].map((table) => table.split('.')[0] ?? ''));
43
+ const inScope = [];
44
+ for (const file of pending) {
45
+ const sql = await readFile(join(migrationsDir, file), 'utf8');
46
+ const operations = extractMigrationOperationSummaries(sql);
47
+ const matches = operations.some((operation) => {
48
+ const tableKey = tableKeyFromOperationKey(operation.key);
49
+ if (tableKey)
50
+ return selectedTables.has(tableKey);
51
+ const database = databaseKeyFromOperationKey(operation.key);
52
+ if (database)
53
+ return selectedDatabases.has(database);
54
+ return false;
55
+ });
56
+ if (matches)
57
+ inScope.push(file);
58
+ }
59
+ return inScope;
60
+ }
61
+ export async function cmdMigrate(args) {
62
+ const executeRequested = hasFlag('--apply', args) || hasFlag('--execute', args);
63
+ const allowDestructive = hasFlag('--allow-destructive', args);
64
+ const tableSelector = parseArg('--table', args);
65
+ const { config, configPath, dirs, jsonMode } = await getCommandContext(args);
66
+ const { migrationsDir, metaDir } = dirs;
67
+ const snapshot = await readSnapshot(metaDir);
68
+ const tableScope = resolveTableScope(tableSelector, tableKeysFromDefinitions(snapshot?.definitions ?? []));
69
+ const pluginRuntime = await loadPluginRuntime({
70
+ config,
71
+ configPath,
72
+ cliVersion: CLI_VERSION,
73
+ });
74
+ await pluginRuntime.runOnConfigLoaded({
75
+ command: 'migrate',
76
+ config,
77
+ configPath,
78
+ tableScope,
79
+ });
80
+ await mkdir(migrationsDir, { recursive: true });
81
+ const files = await listMigrations(migrationsDir);
82
+ const journal = await readJournal(metaDir);
83
+ const appliedNames = new Set(journal.applied.map((entry) => entry.name));
84
+ const pendingAll = files.filter((f) => !appliedNames.has(f));
85
+ const checksumMismatches = await findChecksumMismatches(migrationsDir, journal);
86
+ if (checksumMismatches.length > 0) {
87
+ if (jsonMode) {
88
+ emitJson('migrate', {
89
+ mode: executeRequested ? 'execute' : 'plan',
90
+ scope: tableScope,
91
+ error: 'Checksum mismatch detected on applied migrations',
92
+ checksumMismatches,
93
+ });
94
+ process.exitCode = 1;
95
+ return;
96
+ }
97
+ throw new Error(`Checksum mismatch detected on applied migrations: ${checksumMismatches
98
+ .map((item) => item.name)
99
+ .join(', ')}`);
100
+ }
101
+ if (tableScope.enabled && tableScope.matchCount === 0) {
102
+ if (jsonMode) {
103
+ emitJson('migrate', {
104
+ mode: executeRequested ? 'execute' : 'plan',
105
+ scope: tableScope,
106
+ pending: [],
107
+ applied: [],
108
+ warning: `No tables matched selector "${tableScope.selector ?? ''}".`,
109
+ });
110
+ }
111
+ else {
112
+ console.log(`No tables matched selector "${tableScope.selector ?? ''}". No migrations selected.`);
113
+ }
114
+ return;
115
+ }
116
+ const pending = tableScope.enabled
117
+ ? await filterPendingByScope(migrationsDir, pendingAll, new Set(tableScope.matchedTables))
118
+ : pendingAll;
119
+ if (pending.length === 0) {
120
+ if (jsonMode) {
121
+ emitJson('migrate', {
122
+ mode: executeRequested ? 'execute' : 'plan',
123
+ scope: tableScope,
124
+ pending: [],
125
+ applied: [],
126
+ });
127
+ }
128
+ else {
129
+ console.log('No pending migrations.');
130
+ }
131
+ return;
132
+ }
133
+ const planned = {
134
+ mode: executeRequested ? 'execute' : 'plan',
135
+ scope: tableScope,
136
+ pending,
137
+ };
138
+ if (jsonMode && !executeRequested) {
139
+ emitJson('migrate', planned);
140
+ return;
141
+ }
142
+ if (!jsonMode) {
143
+ if (tableScope.enabled) {
144
+ console.log(`Table scope: ${tableScope.selector ?? ''} (${tableScope.matchCount} matched)`);
145
+ for (const table of tableScope.matchedTables)
146
+ console.log(`- ${table}`);
147
+ }
148
+ console.log(`Pending migrations: ${pending.length}`);
149
+ for (const file of pending)
150
+ console.log(`- ${file}`);
151
+ }
152
+ let shouldExecute = executeRequested;
153
+ if (!shouldExecute) {
154
+ if (isBackgroundOrCI() || jsonMode) {
155
+ if (!jsonMode) {
156
+ console.log('\nPlan only. Re-run with --apply to apply and journal these migrations.');
157
+ }
158
+ return;
159
+ }
160
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
161
+ try {
162
+ console.log('');
163
+ console.log('Type "yes" to continue. Any other input cancels.');
164
+ const response = await rl.question('Apply pending migrations now? [no/yes]: ');
165
+ shouldExecute = response.trim().toLowerCase() === 'yes';
166
+ }
167
+ finally {
168
+ rl.close();
169
+ }
170
+ if (!shouldExecute) {
171
+ console.log('Migration apply cancelled by user.');
172
+ return;
173
+ }
174
+ }
175
+ const destructiveMigrations = [];
176
+ const destructiveOperations = [];
177
+ for (const file of pending) {
178
+ const sql = await readFile(join(migrationsDir, file), 'utf8');
179
+ if (migrationContainsDangerOperation(sql)) {
180
+ destructiveMigrations.push(file);
181
+ destructiveOperations.push(...collectDestructiveOperationMarkers(file, sql));
182
+ }
183
+ }
184
+ let destructiveAllowed = allowDestructive || config.safety?.allowDestructive === true;
185
+ if (destructiveMigrations.length > 0 && !destructiveAllowed) {
186
+ const error = 'Blocked destructive migration execution. Re-run with --allow-destructive or set safety.allowDestructive=true after review.';
187
+ if (jsonMode) {
188
+ emitJson('migrate', {
189
+ mode: 'execute',
190
+ scope: tableScope,
191
+ error,
192
+ destructiveMigrations,
193
+ destructiveOperations,
194
+ });
195
+ process.exitCode = 3;
196
+ return;
197
+ }
198
+ if (isBackgroundOrCI()) {
199
+ printDestructiveOperationDetails(destructiveOperations);
200
+ throw new Error(`${error}\nDestructive migrations: ${destructiveMigrations.join(', ')}\n` +
201
+ 'Non-interactive run detected. Pass --allow-destructive to proceed.');
202
+ }
203
+ const confirmed = await confirmDestructiveExecution(destructiveOperations);
204
+ if (!confirmed) {
205
+ throw new Error(`Destructive migration cancelled by user.\nDestructive migrations: ${destructiveMigrations.join(', ')}`);
206
+ }
207
+ destructiveAllowed = true;
208
+ }
209
+ if (destructiveMigrations.length > 0 && !destructiveAllowed) {
210
+ throw new Error('Blocked destructive migration execution.');
211
+ }
212
+ if (!config.clickhouse) {
213
+ throw new Error('clickhouse config is required for --apply');
214
+ }
215
+ const db = createClickHouseExecutor(config.clickhouse);
216
+ const appliedNow = [];
217
+ for (const file of pending) {
218
+ const fullPath = join(migrationsDir, file);
219
+ const sql = await readFile(fullPath, 'utf8');
220
+ const parsedStatements = extractExecutableStatements(sql);
221
+ const statements = await pluginRuntime.runOnBeforeApply({
222
+ command: 'migrate',
223
+ config,
224
+ tableScope,
225
+ migration: file,
226
+ sql,
227
+ statements: parsedStatements,
228
+ });
229
+ for (const statement of statements) {
230
+ await db.execute(statement);
231
+ }
232
+ const entry = {
233
+ name: file,
234
+ appliedAt: new Date().toISOString(),
235
+ checksum: checksumSQL(sql),
236
+ };
237
+ journal.applied.push(entry);
238
+ appliedNow.push(entry);
239
+ await writeJournal(metaDir, journal);
240
+ await pluginRuntime.runOnAfterApply({
241
+ command: 'migrate',
242
+ config,
243
+ tableScope,
244
+ migration: file,
245
+ statements,
246
+ appliedAt: entry.appliedAt,
247
+ });
248
+ if (!jsonMode)
249
+ console.log(`Applied: ${file}`);
250
+ }
251
+ if (jsonMode) {
252
+ emitJson('migrate', {
253
+ mode: 'execute',
254
+ scope: tableScope,
255
+ applied: appliedNow,
256
+ journalFile: join(metaDir, 'journal.json'),
257
+ });
258
+ return;
259
+ }
260
+ console.log(`\nJournal updated: ${join(metaDir, 'journal.json')}`);
261
+ }
262
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../src/bin/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,c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IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,QAAQ,EAAE,WAAW,CAAC,GAAG,CAAC;SAC3B,CAAA;QACD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC3B,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACtB,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACpC,MAAM,aAAa,CAAC,eAAe,CAAC;YAClC,OAAO,EAAE,SAAS;YAClB,MAAM;YACN,UAAU;YACV,SAAS,EAAE,IAAI;YACf,UAAU;YACV,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ;YAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,SAAS,EAAE;YAClB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,UAAU;YACnB,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC;SAC3C,CAAC,CAAA;QACF,OAAM;IACR,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC,CAAA;AACpE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { getCommandContext } from '../config.js';
2
+ import { type PluginRuntime } from '../plugin-runtime.js';
3
+ import { type TableScope } from '../table-scope.js';
4
+ export interface PluginLikeContext {
5
+ config: Awaited<ReturnType<typeof getCommandContext>>['config'];
6
+ configPath: string;
7
+ jsonMode: boolean;
8
+ runtime: PluginRuntime;
9
+ commandArgs: string[];
10
+ tableScope: TableScope;
11
+ }
12
+ interface BuildPluginLikeContextInput {
13
+ args: string[];
14
+ command: 'plugin' | 'codegen' | 'pull';
15
+ handleInvalidPluginOptions?: boolean;
16
+ }
17
+ interface MissingPluginArgs {
18
+ pluginName: string;
19
+ availablePlugins: string[];
20
+ }
21
+ interface MissingCommandArgs {
22
+ pluginName: string;
23
+ commandName: string;
24
+ availableCommands: string[];
25
+ }
26
+ interface RunPluginLikeCommandInput {
27
+ context: PluginLikeContext;
28
+ pluginName: string;
29
+ commandName: string;
30
+ commandArgs: string[];
31
+ missingPluginMessage?: (args: MissingPluginArgs) => string;
32
+ missingCommandMessage?: (args: MissingCommandArgs) => string;
33
+ }
34
+ export declare function stripGlobalFlags(args: string[]): string[];
35
+ export declare function buildPluginLikeContext(input: BuildPluginLikeContextInput): Promise<PluginLikeContext | null>;
36
+ export declare function runPluginLikeCommand(input: RunPluginLikeCommandInput): Promise<void>;
37
+ export {};
38
+ //# sourceMappingURL=plugin-like.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-like.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/plugin-like.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAA;AAG1D,OAAO,EAAE,KAAK,aAAa,EAAqB,MAAM,sBAAsB,CAAA;AAC5E,OAAO,EAA+C,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGhG,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC/D,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,aAAa,CAAA;IACtB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,UAAU,2BAA2B;IACnC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAA;IACtC,0BAA0B,CAAC,EAAE,OAAO,CAAA;CACrC;AAED,UAAU,iBAAiB;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED,UAAU,kBAAkB;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,iBAAiB,EAAE,MAAM,EAAE,CAAA;CAC5B;AAED,UAAU,yBAAyB;IACjC,OAAO,EAAE,iBAAiB,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,MAAM,CAAA;IAC1D,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,MAAM,CAAA;CAC7D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAiBzD;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAqCnC;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6C1F"}
@@ -0,0 +1,101 @@
1
+ import process from 'node:process';
2
+ import { getCommandContext, parseArg } from '../config.js';
3
+ import { loadSchemaDefinitions } from '../lib.js';
4
+ import { printOutput } from '../json-output.js';
5
+ import { loadPluginRuntime } from '../plugin-runtime.js';
6
+ import { resolveTableScope, tableKeysFromDefinitions } from '../table-scope.js';
7
+ import { CLI_VERSION } from '../version.js';
8
+ export function stripGlobalFlags(args) {
9
+ const tokens = [];
10
+ for (let i = 0; i < args.length; i += 1) {
11
+ const value = args[i];
12
+ if (!value)
13
+ continue;
14
+ if (value === '--json')
15
+ continue;
16
+ if (value === '--config') {
17
+ i += 1;
18
+ continue;
19
+ }
20
+ if (value === '--table') {
21
+ i += 1;
22
+ continue;
23
+ }
24
+ tokens.push(value);
25
+ }
26
+ return tokens;
27
+ }
28
+ export async function buildPluginLikeContext(input) {
29
+ const commandArgs = stripGlobalFlags(input.args);
30
+ const { config, configPath, jsonMode } = await getCommandContext(input.args);
31
+ const selector = parseArg('--table', input.args);
32
+ const definitions = await loadSchemaDefinitions(config.schema);
33
+ const tableScope = resolveTableScope(selector, tableKeysFromDefinitions(definitions));
34
+ const runtime = await loadPluginRuntime({
35
+ config,
36
+ configPath,
37
+ cliVersion: CLI_VERSION,
38
+ });
39
+ try {
40
+ await runtime.runOnConfigLoaded({
41
+ command: input.command,
42
+ config,
43
+ configPath,
44
+ tableScope,
45
+ });
46
+ }
47
+ catch (error) {
48
+ const message = error instanceof Error ? error.message : String(error);
49
+ if (input.handleInvalidPluginOptions && message.includes('Invalid plugin option')) {
50
+ printOutput({ ok: false, error: message }, jsonMode);
51
+ process.exitCode = 2;
52
+ return null;
53
+ }
54
+ throw error;
55
+ }
56
+ return {
57
+ config,
58
+ configPath,
59
+ jsonMode,
60
+ runtime,
61
+ commandArgs,
62
+ tableScope,
63
+ };
64
+ }
65
+ export async function runPluginLikeCommand(input) {
66
+ const selectedPlugin = input.context.runtime.plugins.find((entry) => entry.plugin.manifest.name === input.pluginName);
67
+ if (!selectedPlugin) {
68
+ const availablePlugins = input.context.runtime.plugins
69
+ .map((entry) => entry.plugin.manifest.name)
70
+ .sort();
71
+ if (input.missingPluginMessage) {
72
+ throw new Error(input.missingPluginMessage({ pluginName: input.pluginName, availablePlugins }));
73
+ }
74
+ throw new Error(`Unknown plugin "${input.pluginName}". Available: ${availablePlugins.length > 0 ? availablePlugins.join(', ') : '(none)'}.`);
75
+ }
76
+ const foundCommand = input.context.runtime.getCommand(input.pluginName, input.commandName);
77
+ if (!foundCommand) {
78
+ const availableCommands = (selectedPlugin.plugin.commands ?? []).map((command) => command.name).sort();
79
+ if (input.missingCommandMessage) {
80
+ throw new Error(input.missingCommandMessage({
81
+ pluginName: input.pluginName,
82
+ commandName: input.commandName,
83
+ availableCommands,
84
+ }));
85
+ }
86
+ throw new Error(`Unknown command "${input.commandName}" for plugin "${input.pluginName}". Available: ${availableCommands.length > 0 ? availableCommands.join(', ') : '(none)'}.`);
87
+ }
88
+ const exitCode = await input.context.runtime.runPluginCommand(input.pluginName, input.commandName, {
89
+ config: input.context.config,
90
+ configPath: input.context.configPath,
91
+ jsonMode: input.context.jsonMode,
92
+ tableScope: input.context.tableScope,
93
+ args: input.commandArgs,
94
+ print(value) {
95
+ printOutput(value, input.context.jsonMode);
96
+ },
97
+ });
98
+ if (exitCode !== 0)
99
+ process.exitCode = exitCode;
100
+ }
101
+ //# sourceMappingURL=plugin-like.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-like.js","sourceRoot":"","sources":["../../../src/bin/commands/plugin-like.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAsB,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAmB,MAAM,mBAAmB,CAAA;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAqC3C,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACrB,IAAI,CAAC,KAAK;YAAE,SAAQ;QACpB,IAAI,KAAK,KAAK,QAAQ;YAAE,SAAQ;QAChC,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;YACzB,C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AAQ,KAAK,CAAC;QAAE,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;AACjD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function cmdPlugin(args: string[]): Promise<void>;
2
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/plugin.ts"],"names":[],"mappings":"AAeA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8F7D"}
@@ -0,0 +1,92 @@
1
+ import { emitJson } from '../json-output.js';
2
+ import { buildPluginLikeContext, runPluginLikeCommand } from './plugin-like.js';
3
+ function parsePluginInvocation(commandArgs) {
4
+ return {
5
+ pluginName: commandArgs[0],
6
+ commandName: commandArgs[1],
7
+ commandArgs: commandArgs.slice(2),
8
+ };
9
+ }
10
+ export async function cmdPlugin(args) {
11
+ const context = await buildPluginLikeContext({
12
+ args,
13
+ command: 'plugin',
14
+ });
15
+ if (!context)
16
+ return;
17
+ const parsed = parsePluginInvocation(context.commandArgs);
18
+ if (context.runtime.plugins.length === 0) {
19
+ if (context.jsonMode) {
20
+ emitJson('plugin', {
21
+ error: 'No plugins configured. Add entries to config.plugins first.',
22
+ plugins: [],
23
+ });
24
+ process.exitCode = 1;
25
+ return;
26
+ }
27
+ throw new Error('No plugins configured. Add entries to config.plugins first.');
28
+ }
29
+ if (!parsed.pluginName) {
30
+ const payload = {
31
+ plugins: context.runtime.plugins.map((entry) => ({
32
+ name: entry.plugin.manifest.name,
33
+ version: entry.plugin.manifest.version ?? null,
34
+ commands: (entry.plugin.commands ?? []).map((command) => ({
35
+ name: command.name,
36
+ description: command.description ?? '',
37
+ })),
38
+ })),
39
+ };
40
+ if (context.jsonMode) {
41
+ emitJson('plugin', payload);
42
+ return;
43
+ }
44
+ console.log('Configured plugins:');
45
+ for (const plugin of payload.plugins) {
46
+ console.log(`- ${plugin.name}${plugin.version ? ` (v${plugin.version})` : ''}`);
47
+ if (plugin.commands.length === 0) {
48
+ console.log(' (no commands)');
49
+ continue;
50
+ }
51
+ for (const command of plugin.commands) {
52
+ console.log(` - ${command.name}${command.description ? `: ${command.description}` : ''}`);
53
+ }
54
+ }
55
+ return;
56
+ }
57
+ const selectedPlugin = context.runtime.plugins.find((entry) => entry.plugin.manifest.name === parsed.pluginName);
58
+ if (!selectedPlugin) {
59
+ const known = context.runtime.plugins.map((entry) => entry.plugin.manifest.name).sort();
60
+ throw new Error(`Unknown plugin "${parsed.pluginName}". Available: ${known.length > 0 ? known.join(', ') : '(none)'}.`);
61
+ }
62
+ if (!parsed.commandName) {
63
+ const commands = (selectedPlugin.plugin.commands ?? []).map((command) => ({
64
+ name: command.name,
65
+ description: command.description ?? '',
66
+ }));
67
+ const payload = {
68
+ plugin: selectedPlugin.plugin.manifest.name,
69
+ commands,
70
+ };
71
+ if (context.jsonMode) {
72
+ emitJson('plugin', payload);
73
+ return;
74
+ }
75
+ if (commands.length === 0) {
76
+ console.log(`Plugin "${selectedPlugin.plugin.manifest.name}" has no registered commands.`);
77
+ return;
78
+ }
79
+ console.log(`Plugin commands for "${selectedPlugin.plugin.manifest.name}":`);
80
+ for (const command of commands) {
81
+ console.log(`- ${command.name}${command.description ? `: ${command.description}` : ''}`);
82
+ }
83
+ return;
84
+ }
85
+ await runPluginLikeCommand({
86
+ context,
87
+ pluginName: parsed.pluginName,
88
+ commandName: parsed.commandName,
89
+ commandArgs: parsed.commandArgs,
90
+ });
91
+ }
92
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/bin/commands/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE/E,SAAS,qBAAqB,CAAC,WAAqB;IAKlD,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,CAAC,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAC1F,CAAC;QACD,OAAM;IACR,CAAC;IAED,MAAM,oBAAoB,CAAC;QACzB,OAAO;QACP,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function cmdPull(args: string[]): Promise<void>;
2
+ //# sourceMappingURL=pull.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/pull.ts"],"names":[],"mappings":"AAEA,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB3D"}
@@ -0,0 +1,25 @@
1
+ import { buildPluginLikeContext, runPluginLikeCommand } from './plugin-like.js';
2
+ export async function cmdPull(args) {
3
+ const context = await buildPluginLikeContext({
4
+ args,
5
+ command: 'pull',
6
+ handleInvalidPluginOptions: true,
7
+ });
8
+ if (!context)
9
+ return;
10
+ const pluginName = 'pull';
11
+ const commandName = 'schema';
12
+ await runPluginLikeCommand({
13
+ context,
14
+ pluginName,
15
+ commandName,
16
+ commandArgs: context.commandArgs,
17
+ missingPluginMessage() {
18
+ return 'Pull plugin is not configured. Add a plugin with manifest.name "pull" to config.plugins.';
19
+ },
20
+ missingCommandMessage({ availableCommands }) {
21
+ return `Pull plugin is configured but does not expose command "${commandName}". Available: ${availableCommands.length > 0 ? availableCommands.join(', ') : '(none)'}.`;
22
+ },
23
+ });
24
+ }
25
+ //# sourceMappingURL=pull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../src/bin/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE/E,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAc;IAC1C,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC;QAC3C,IAAI;QACJ,OAAO,EAAE,MAAM;QACf,0BAA0B,EAAE,IAAI;KACjC,CAAC,CAAA;IACF,IAAI,CAAC,OAAO;QAAE,OAAM;IAEpB,MAAM,UAAU,GAAG,MAAM,CAAA;IACzB,MAAM,WAAW,GAAG,QAAQ,CAAA;IAC5B,MAAM,oBAAoB,CAAC;QACzB,OAAO;QACP,UAAU;QACV,WAAW;QACX,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,oBAAoB;YAClB,OAAO,0FAA0F,CAAA;QACnG,CAAC;QACD,qBAAqB,CAAC,EAAE,iBAAiB,EAAE;YACzC,OAAO,0DAA0D,WAAW,iBAAiB,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAA;QACxK,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function cmdStatus(args: string[]): Promise<void>;
2
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/status.ts"],"names":[],"mappings":"AAMA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuC7D"}
@@ -0,0 +1,42 @@
1
+ import { mkdir } from 'node:fs/promises';
2
+ import { getCommandContext } from '../config.js';
3
+ import { emitJson } from '../json-output.js';
4
+ import { findChecksumMismatches, listMigrations, readJournal } from '../migration-store.js';
5
+ export async function cmdStatus(args) {
6
+ const { dirs, jsonMode } = await getCommandContext(args);
7
+ const { migrationsDir, metaDir } = dirs;
8
+ await mkdir(migrationsDir, { recursive: true });
9
+ const files = await listMigrations(migrationsDir);
10
+ const journal = await readJournal(metaDir);
11
+ const appliedNames = new Set(journal.applied.map((entry) => entry.name));
12
+ const pending = files.filter((f) => !appliedNames.has(f));
13
+ const checksumMismatches = await findChecksumMismatches(migrationsDir, journal);
14
+ const payload = {
15
+ migrationsDir,
16
+ total: files.length,
17
+ applied: journal.applied.length,
18
+ pending: pending.length,
19
+ pendingMigrations: pending,
20
+ checksumMismatchCount: checksumMismatches.length,
21
+ checksumMismatches,
22
+ };
23
+ if (jsonMode) {
24
+ emitJson('status', payload);
25
+ return;
26
+ }
27
+ console.log(`Migrations directory: ${migrationsDir}`);
28
+ console.log(`Total migrations: ${files.length}`);
29
+ console.log(`Applied: ${journal.applied.length}`);
30
+ console.log(`Pending: ${pending.length}`);
31
+ if (pending.length > 0) {
32
+ console.log('\nPending migrations:');
33
+ for (const item of pending)
34
+ console.log(`- ${item}`);
35
+ }
36
+ if (checksumMismatches.length > 0) {
37
+ console.log('\nChecksum mismatches on applied migrations:');
38
+ for (const item of checksumMismatches)
39
+ console.log(`- ${item.name}`);
40
+ }
41
+ }
42
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/bin/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAE3F,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAc;IAC5C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAA;IACxD,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAEvC,MAAM,K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CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;QACpC,KAAK,MAAM,IAAI,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAA;QAC3D,KAAK,MAAM,IAAI,IAAI,kBAAkB;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IACtE,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function cmdTypegen(args: string[]): Promise<void>;
2
+ //# sourceMappingURL=typegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typegen.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/typegen.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB9D"}