@t1mmen/srtd 0.0.0-next-20251227000343

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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +363 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +50 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/apply.d.ts +2 -0
  7. package/dist/commands/apply.js +105 -0
  8. package/dist/commands/apply.js.map +1 -0
  9. package/dist/commands/build.d.ts +2 -0
  10. package/dist/commands/build.js +134 -0
  11. package/dist/commands/build.js.map +1 -0
  12. package/dist/commands/clear.d.ts +2 -0
  13. package/dist/commands/clear.js +161 -0
  14. package/dist/commands/clear.js.map +1 -0
  15. package/dist/commands/init.d.ts +2 -0
  16. package/dist/commands/init.js +91 -0
  17. package/dist/commands/init.js.map +1 -0
  18. package/dist/commands/menu.d.ts +4 -0
  19. package/dist/commands/menu.js +76 -0
  20. package/dist/commands/menu.js.map +1 -0
  21. package/dist/commands/promote.d.ts +2 -0
  22. package/dist/commands/promote.js +181 -0
  23. package/dist/commands/promote.js.map +1 -0
  24. package/dist/commands/register.d.ts +2 -0
  25. package/dist/commands/register.js +192 -0
  26. package/dist/commands/register.js.map +1 -0
  27. package/dist/commands/watch.d.ts +14 -0
  28. package/dist/commands/watch.js +190 -0
  29. package/dist/commands/watch.js.map +1 -0
  30. package/dist/constants.d.ts +1 -0
  31. package/dist/constants.js +2 -0
  32. package/dist/constants.js.map +1 -0
  33. package/dist/services/DatabaseService.d.ts +113 -0
  34. package/dist/services/DatabaseService.js +343 -0
  35. package/dist/services/DatabaseService.js.map +1 -0
  36. package/dist/services/FileSystemService.d.ts +100 -0
  37. package/dist/services/FileSystemService.js +237 -0
  38. package/dist/services/FileSystemService.js.map +1 -0
  39. package/dist/services/MigrationBuilder.d.ts +106 -0
  40. package/dist/services/MigrationBuilder.js +193 -0
  41. package/dist/services/MigrationBuilder.js.map +1 -0
  42. package/dist/services/Orchestrator.d.ts +155 -0
  43. package/dist/services/Orchestrator.js +622 -0
  44. package/dist/services/Orchestrator.js.map +1 -0
  45. package/dist/services/StateService.d.ts +169 -0
  46. package/dist/services/StateService.js +463 -0
  47. package/dist/services/StateService.js.map +1 -0
  48. package/dist/types.d.ts +48 -0
  49. package/dist/types.js +2 -0
  50. package/dist/types.js.map +1 -0
  51. package/dist/ui/badge.d.ts +14 -0
  52. package/dist/ui/badge.js +28 -0
  53. package/dist/ui/badge.js.map +1 -0
  54. package/dist/ui/branding.d.ts +9 -0
  55. package/dist/ui/branding.js +35 -0
  56. package/dist/ui/branding.js.map +1 -0
  57. package/dist/ui/index.d.ts +4 -0
  58. package/dist/ui/index.js +5 -0
  59. package/dist/ui/index.js.map +1 -0
  60. package/dist/ui/results.d.ts +10 -0
  61. package/dist/ui/results.js +62 -0
  62. package/dist/ui/results.js.map +1 -0
  63. package/dist/ui/spinner.d.ts +5 -0
  64. package/dist/ui/spinner.js +8 -0
  65. package/dist/ui/spinner.js.map +1 -0
  66. package/dist/utils/config.d.ts +12 -0
  67. package/dist/utils/config.js +67 -0
  68. package/dist/utils/config.js.map +1 -0
  69. package/dist/utils/createEmptyBuildLog.d.ts +1 -0
  70. package/dist/utils/createEmptyBuildLog.js +10 -0
  71. package/dist/utils/createEmptyBuildLog.js.map +1 -0
  72. package/dist/utils/ensureDirectories.d.ts +4 -0
  73. package/dist/utils/ensureDirectories.js +23 -0
  74. package/dist/utils/ensureDirectories.js.map +1 -0
  75. package/dist/utils/fileExists.d.ts +1 -0
  76. package/dist/utils/fileExists.js +11 -0
  77. package/dist/utils/fileExists.js.map +1 -0
  78. package/dist/utils/findProjectRoot.d.ts +1 -0
  79. package/dist/utils/findProjectRoot.js +25 -0
  80. package/dist/utils/findProjectRoot.js.map +1 -0
  81. package/dist/utils/getErrorMessage.d.ts +9 -0
  82. package/dist/utils/getErrorMessage.js +14 -0
  83. package/dist/utils/getErrorMessage.js.map +1 -0
  84. package/dist/utils/getNextTimestamp.d.ts +2 -0
  85. package/dist/utils/getNextTimestamp.js +12 -0
  86. package/dist/utils/getNextTimestamp.js.map +1 -0
  87. package/dist/utils/isWipTemplate.d.ts +1 -0
  88. package/dist/utils/isWipTemplate.js +6 -0
  89. package/dist/utils/isWipTemplate.js.map +1 -0
  90. package/dist/utils/logger.d.ts +9 -0
  91. package/dist/utils/logger.js +12 -0
  92. package/dist/utils/logger.js.map +1 -0
  93. package/dist/utils/safeCreate.d.ts +1 -0
  94. package/dist/utils/safeCreate.js +16 -0
  95. package/dist/utils/safeCreate.js.map +1 -0
  96. package/package.json +106 -0
@@ -0,0 +1,622 @@
1
+ /**
2
+ * Orchestrator Service - Central coordinator for unidirectional data flow
3
+ * Manages coordination between FileSystemService, StateService, DatabaseService, and MigrationBuilder
4
+ * Implements the flow: FileSystem Event → Orchestrator → StateService (check) → Action → StateService (update)
5
+ */
6
+ import EventEmitter from 'node:events';
7
+ import path from 'node:path';
8
+ import { isWipTemplate } from '../utils/isWipTemplate.js';
9
+ import { DatabaseService } from './DatabaseService.js';
10
+ import { FileSystemService } from './FileSystemService.js';
11
+ import { MigrationBuilder } from './MigrationBuilder.js';
12
+ import { StateService } from './StateService.js';
13
+ export class Orchestrator extends EventEmitter {
14
+ fileSystemService;
15
+ stateService;
16
+ databaseService;
17
+ migrationBuilder;
18
+ config;
19
+ processQueue = new Set();
20
+ pendingRecheck = new Set(); // Templates that changed during processing
21
+ processingTemplate = null;
22
+ processing = false;
23
+ watching = false;
24
+ constructor(config) {
25
+ super();
26
+ this.config = config;
27
+ }
28
+ /**
29
+ * Initialize the orchestrator and all services
30
+ */
31
+ async initialize() {
32
+ // Initialize services (StateService loads and owns build logs)
33
+ await this.initializeServices();
34
+ // Set up event listeners
35
+ this.setupEventListeners();
36
+ }
37
+ /**
38
+ * Initialize all coordinated services
39
+ */
40
+ async initializeServices() {
41
+ // Initialize FileSystemService
42
+ this.fileSystemService = new FileSystemService({
43
+ baseDir: this.config.baseDir,
44
+ templateDir: this.config.cliConfig.templateDir,
45
+ filter: this.config.cliConfig.filter,
46
+ migrationDir: this.config.cliConfig.migrationDir,
47
+ watchOptions: {
48
+ ignoreInitial: false,
49
+ stabilityThreshold: 200,
50
+ pollInterval: 100,
51
+ },
52
+ });
53
+ // Initialize StateService with build log paths from config
54
+ this.stateService = new StateService({
55
+ baseDir: this.config.baseDir,
56
+ buildLogPath: path.join(this.config.baseDir, this.config.cliConfig.buildLog),
57
+ localBuildLogPath: path.join(this.config.baseDir, this.config.cliConfig.localBuildLog),
58
+ autoSave: true,
59
+ });
60
+ await this.stateService.initialize();
61
+ // Initialize DatabaseService
62
+ this.databaseService = new DatabaseService({
63
+ connectionString: this.config.cliConfig.pgConnection,
64
+ maxConnections: 10,
65
+ idleTimeoutMillis: 30000,
66
+ connectionTimeoutMillis: 10000,
67
+ maxRetries: 3,
68
+ retryDelayMs: 1000,
69
+ });
70
+ // Initialize MigrationBuilder
71
+ this.migrationBuilder = MigrationBuilder.fromConfig(this.config.cliConfig, this.config.baseDir);
72
+ }
73
+ /**
74
+ * Set up event listeners for service coordination
75
+ */
76
+ setupEventListeners() {
77
+ // FileSystemService events - Core unidirectional flow entry point
78
+ this.fileSystemService.on('template:changed', (event) => {
79
+ void this.handleFileSystemEvent('changed', event.path);
80
+ });
81
+ this.fileSystemService.on('template:added', (event) => {
82
+ void this.handleFileSystemEvent('added', event.path);
83
+ });
84
+ this.fileSystemService.on('error', (error) => {
85
+ this.log(`File system error: ${error.message}`, 'error');
86
+ });
87
+ // StateService events - For monitoring state transitions
88
+ this.stateService.on('state:transition', event => {
89
+ this.log(`Template state transition: ${event.templatePath} ${event.fromState} -> ${event.toState}`, 'info');
90
+ });
91
+ this.stateService.on('error', (error) => {
92
+ this.log(`State service error: ${error.message}`, 'error');
93
+ });
94
+ // DatabaseService events - For monitoring database operations
95
+ this.databaseService.on('connection:established', () => {
96
+ this.log('Database connection established', 'info');
97
+ });
98
+ this.databaseService.on('connection:lost', error => {
99
+ this.log(`Database connection lost: ${error.message}`, 'warn');
100
+ });
101
+ this.databaseService.on('error', (error) => {
102
+ this.log(`Database service error: ${error.message}`, 'error');
103
+ });
104
+ }
105
+ /**
106
+ * Handle FileSystem events - Entry point for unidirectional flow
107
+ * Uses queue + pendingRecheck to prevent race conditions from rapid file changes
108
+ */
109
+ async handleFileSystemEvent(_eventType, templatePath) {
110
+ if (!this.watching)
111
+ return;
112
+ if (this.processQueue.has(templatePath)) {
113
+ // Already in queue, nothing to do
114
+ return;
115
+ }
116
+ if (this.processingTemplate === templatePath) {
117
+ // Template changed while being processed - mark for recheck
118
+ this.pendingRecheck.add(templatePath);
119
+ }
120
+ else {
121
+ // Add to processing queue
122
+ this.processQueue.add(templatePath);
123
+ }
124
+ // Start processing if not already processing
125
+ if (!this.processing) {
126
+ this.processing = true;
127
+ await this.processNextTemplate();
128
+ }
129
+ }
130
+ /**
131
+ * Process the next template in the queue
132
+ */
133
+ async processNextTemplate() {
134
+ if (this.processQueue.size === 0) {
135
+ this.processing = false;
136
+ return;
137
+ }
138
+ const templatePath = this.processQueue.values().next().value;
139
+ if (!templatePath) {
140
+ this.processing = false;
141
+ return;
142
+ }
143
+ this.processQueue.delete(templatePath);
144
+ this.processingTemplate = templatePath;
145
+ try {
146
+ // Unidirectional flow: Orchestrator → StateService (check) → Action → StateService (update)
147
+ await this.processTemplate(templatePath, false);
148
+ }
149
+ finally {
150
+ // Check if template changed during processing - if so, requeue it
151
+ if (this.pendingRecheck.has(templatePath)) {
152
+ this.pendingRecheck.delete(templatePath);
153
+ this.processQueue.add(templatePath);
154
+ }
155
+ this.processingTemplate = null;
156
+ await this.processNextTemplate();
157
+ }
158
+ }
159
+ /**
160
+ * Process a single template through the unidirectional flow
161
+ */
162
+ async processTemplate(templatePath, force = false) {
163
+ try {
164
+ // Step 1: Check if file exists
165
+ const exists = await this.fileSystemService.fileExists(templatePath);
166
+ if (!exists) {
167
+ const templateName = path.basename(templatePath, '.sql');
168
+ this.log(`Template file not found: ${templatePath}`, 'warn');
169
+ return {
170
+ errors: [],
171
+ applied: [],
172
+ skipped: [templateName],
173
+ built: [],
174
+ };
175
+ }
176
+ // Step 2: Read template file
177
+ const templateFile = await this.fileSystemService.readTemplate(templatePath);
178
+ // Step 3: StateService (check) - Unidirectional flow checkpoint
179
+ const stateInfo = this.stateService.getTemplateStatus(templatePath);
180
+ const needsProcessing = force || this.stateService.hasTemplateChanged(templatePath, templateFile.hash);
181
+ if (!needsProcessing) {
182
+ return {
183
+ errors: [],
184
+ applied: [],
185
+ skipped: [templateFile.name],
186
+ built: [],
187
+ };
188
+ }
189
+ // Step 4: Update StateService with change detection
190
+ if (!stateInfo || this.stateService.hasTemplateChanged(templatePath, templateFile.hash)) {
191
+ await this.stateService.markAsChanged(templatePath, templateFile.hash);
192
+ }
193
+ // Step 5: Get current template status for event emission
194
+ const template = await this.getTemplateStatus(templatePath);
195
+ this.emit('templateChanged', template);
196
+ // Step 6: Action - Apply template to database
197
+ const result = await this.executeApplyTemplate(templatePath);
198
+ // Step 7: Handle result and emit events
199
+ if (result.errors.length > 0) {
200
+ const error = result.errors[0];
201
+ const formattedError = typeof error === 'string' ? error : error?.error;
202
+ this.emit('templateError', { template, error: formattedError });
203
+ }
204
+ else {
205
+ const updatedTemplate = await this.getTemplateStatus(templatePath);
206
+ this.emit('templateApplied', updatedTemplate);
207
+ }
208
+ return result;
209
+ }
210
+ catch (error) {
211
+ const errorMessage = error instanceof Error ? error.message : String(error);
212
+ this.log(`Error processing template ${templatePath}: ${errorMessage}`, 'error');
213
+ // Create safe template object for error event
214
+ const templateName = path.basename(templatePath, '.sql');
215
+ const safeTemplate = {
216
+ name: templateName,
217
+ path: templatePath,
218
+ currentHash: '',
219
+ migrationHash: null,
220
+ buildState: {},
221
+ wip: false,
222
+ };
223
+ this.emit('templateError', {
224
+ template: safeTemplate,
225
+ error: errorMessage,
226
+ });
227
+ return {
228
+ errors: [
229
+ {
230
+ file: templatePath,
231
+ error: errorMessage,
232
+ templateName,
233
+ },
234
+ ],
235
+ applied: [],
236
+ skipped: [],
237
+ built: [],
238
+ };
239
+ }
240
+ }
241
+ /**
242
+ * Get template status by coordinating between services
243
+ */
244
+ async getTemplateStatus(templatePath) {
245
+ const templateFile = await this.fileSystemService.readTemplate(templatePath);
246
+ // Get build state from StateService (single source of truth)
247
+ const buildState = this.stateService.getTemplateBuildState(templatePath) || {};
248
+ return {
249
+ name: templateFile.name,
250
+ path: templatePath,
251
+ currentHash: templateFile.hash,
252
+ migrationHash: null,
253
+ buildState,
254
+ wip: await isWipTemplate(templatePath, this.config.baseDir),
255
+ };
256
+ }
257
+ /**
258
+ * Execute apply operation for a template
259
+ */
260
+ async executeApplyTemplate(templatePath) {
261
+ const template = await this.getTemplateStatus(templatePath);
262
+ const templateFile = await this.fileSystemService.readTemplate(templatePath);
263
+ const content = templateFile.content;
264
+ try {
265
+ const result = await this.databaseService.executeMigration(content, template.name, this.config.silent);
266
+ if (result === true) {
267
+ // StateService (update) - Single source of truth for build logs
268
+ await this.stateService.markAsApplied(templatePath, templateFile.hash);
269
+ return { errors: [], applied: [template.name], skipped: [], built: [] };
270
+ }
271
+ // On error, update StateService (single source of truth)
272
+ await this.stateService.markAsError(templatePath, result.error, 'apply');
273
+ return { errors: [result], applied: [], skipped: [], built: [] };
274
+ }
275
+ catch (error) {
276
+ const errorMessage = error instanceof Error ? error.message : String(error);
277
+ throw new Error(errorMessage);
278
+ }
279
+ }
280
+ /**
281
+ * Command handler: Apply templates to database
282
+ */
283
+ async apply(options = {}) {
284
+ const templates = options.templatePaths || (await this.fileSystemService.findTemplates());
285
+ const result = { errors: [], applied: [], built: [], skipped: [] };
286
+ this.log('\\n');
287
+ const action = options.force ? 'Force applying' : 'Applying';
288
+ this.log(`${action} changed templates to local database...`, 'success');
289
+ for (const templatePath of templates) {
290
+ try {
291
+ const processResult = await this.processTemplate(templatePath, options.force);
292
+ result.errors.push(...(processResult.errors || []));
293
+ result.applied.push(...(processResult.applied || []));
294
+ result.skipped.push(...(processResult.skipped || []));
295
+ }
296
+ catch (error) {
297
+ result.errors.push({
298
+ file: templatePath,
299
+ templateName: templatePath,
300
+ error: error instanceof Error ? error.message : 'Unknown error',
301
+ });
302
+ }
303
+ }
304
+ // Emit operation complete event
305
+ this.emit('operationComplete', result);
306
+ // Log results
307
+ if (result.applied.length === 0 && result.errors.length === 0) {
308
+ this.log('No changes to apply', 'skip');
309
+ }
310
+ else if (result.errors.length > 0) {
311
+ this.log(`${result.errors.length} template(s) failed to apply`, 'error');
312
+ for (const err of result.errors) {
313
+ this.log(`${err.file}: ${err.error}`, 'error');
314
+ }
315
+ }
316
+ else {
317
+ this.log(`Applied ${result.applied.length} template(s)`, 'success');
318
+ }
319
+ return result;
320
+ }
321
+ /**
322
+ * Command handler: Build migration files from templates
323
+ */
324
+ async build(options = {}) {
325
+ const templates = options.templatePaths || (await this.fileSystemService.findTemplates());
326
+ this.log('\\n');
327
+ if (options.bundle) {
328
+ return await this.executeBundledBuild(templates, options);
329
+ }
330
+ return await this.executeIndividualBuilds(templates, options);
331
+ }
332
+ /**
333
+ * Execute bundled migration build
334
+ */
335
+ async executeBundledBuild(templatePaths, options) {
336
+ const result = { errors: [], applied: [], built: [], skipped: [] };
337
+ const templates = [];
338
+ // Collect templates for bundle
339
+ for (const templatePath of templatePaths) {
340
+ const isWip = await isWipTemplate(templatePath, this.config.baseDir);
341
+ if (isWip) {
342
+ const template = await this.getTemplateStatus(templatePath);
343
+ this.log(`Skipping WIP template: ${template.name}`, 'skip');
344
+ result.skipped.push(template.name);
345
+ continue;
346
+ }
347
+ const templateFile = await this.fileSystemService.readTemplate(templatePath);
348
+ const stateInfo = this.stateService.getTemplateStatus(templatePath);
349
+ if (!options.force && stateInfo?.lastBuiltHash === templateFile.hash) {
350
+ const template = await this.getTemplateStatus(templatePath);
351
+ this.log(`Skipping unchanged template: ${template.name}`, 'skip');
352
+ result.skipped.push(template.name);
353
+ continue;
354
+ }
355
+ // Get lastMigrationFile from StateService (single source of truth)
356
+ const buildState = this.stateService.getTemplateBuildState(templatePath);
357
+ templates.push({
358
+ name: templateFile.name,
359
+ templatePath: templateFile.path,
360
+ relativePath: templateFile.relativePath,
361
+ content: templateFile.content,
362
+ hash: templateFile.hash,
363
+ lastBuildAt: buildState?.lastMigrationFile,
364
+ });
365
+ result.built.push(templateFile.name);
366
+ }
367
+ try {
368
+ // Generate bundled migration using MigrationBuilder
369
+ // Use StateService's build log reference (read-only)
370
+ const buildLog = this.stateService.getBuildLogForMigration();
371
+ const { result: migrationResult } = await this.migrationBuilder.generateAndWriteBundledMigration(templates, buildLog, {
372
+ wrapInTransaction: this.config.cliConfig.wrapInTransaction,
373
+ });
374
+ // Update state for all included templates (StateService handles build log updates)
375
+ for (const template of templates) {
376
+ await this.stateService.markAsBuilt(template.templatePath, template.hash, migrationResult.fileName);
377
+ }
378
+ this.log(`Generated bundled migration file: ${migrationResult.fileName}`, 'success');
379
+ }
380
+ catch (error) {
381
+ const errorMessage = error instanceof Error ? error.message : String(error);
382
+ this.log(`Failed to write bundled migration file: ${errorMessage}`, 'error');
383
+ result.errors.push({
384
+ file: 'bundle',
385
+ templateName: 'bundle',
386
+ error: errorMessage,
387
+ });
388
+ }
389
+ this.emit('operationComplete', result);
390
+ return result;
391
+ }
392
+ /**
393
+ * Execute individual migration builds
394
+ */
395
+ async executeIndividualBuilds(templatePaths, options) {
396
+ const result = { errors: [], applied: [], built: [], skipped: [] };
397
+ this.log('Building migration files from templates...', 'success');
398
+ for (const templatePath of templatePaths) {
399
+ try {
400
+ const isWip = await isWipTemplate(templatePath, this.config.baseDir);
401
+ if (isWip) {
402
+ const template = await this.getTemplateStatus(templatePath);
403
+ this.log(`Skipping WIP template: ${template.name}`, 'skip');
404
+ result.skipped.push(template.name);
405
+ continue;
406
+ }
407
+ const templateFile = await this.fileSystemService.readTemplate(templatePath);
408
+ const template = await this.getTemplateStatus(templatePath);
409
+ const stateInfo = this.stateService.getTemplateStatus(templatePath);
410
+ if (options.force || stateInfo?.lastBuiltHash !== templateFile.hash) {
411
+ await this.executeBuildTemplate(templatePath);
412
+ result.built.push(template.name);
413
+ }
414
+ else {
415
+ result.skipped.push(template.name);
416
+ }
417
+ }
418
+ catch (error) {
419
+ const errorMessage = error instanceof Error ? error.message : String(error);
420
+ const templateName = path.basename(templatePath, '.sql');
421
+ result.errors.push({
422
+ file: templatePath,
423
+ templateName,
424
+ error: errorMessage,
425
+ });
426
+ }
427
+ }
428
+ // Log results
429
+ if (result.built.length > 0) {
430
+ this.log(`Generated ${result.built.length} migration file(s)`, 'success');
431
+ }
432
+ else if (result.skipped.length > 0) {
433
+ this.log('No new changes to build', 'skip');
434
+ }
435
+ this.emit('operationComplete', result);
436
+ return result;
437
+ }
438
+ /**
439
+ * Build a single template migration file
440
+ */
441
+ async executeBuildTemplate(templatePath) {
442
+ const template = await this.getTemplateStatus(templatePath);
443
+ const templateFile = await this.fileSystemService.readTemplate(templatePath);
444
+ // Get lastMigrationFile from StateService (single source of truth)
445
+ const buildState = this.stateService.getTemplateBuildState(templatePath);
446
+ const templateMetadata = {
447
+ name: templateFile.name,
448
+ templatePath: templateFile.path,
449
+ relativePath: templateFile.relativePath,
450
+ content: templateFile.content,
451
+ hash: templateFile.hash,
452
+ lastBuildAt: buildState?.lastMigrationFile,
453
+ };
454
+ try {
455
+ // Generate migration using MigrationBuilder
456
+ // Use StateService's build log reference (read-only)
457
+ const buildLog = this.stateService.getBuildLogForMigration();
458
+ const { result: migrationResult } = await this.migrationBuilder.generateAndWriteMigration(templateMetadata, buildLog, {
459
+ wrapInTransaction: this.config.cliConfig.wrapInTransaction,
460
+ });
461
+ // Update StateService (single source of truth - handles build log updates)
462
+ await this.stateService.markAsBuilt(templatePath, templateFile.hash, migrationResult.fileName);
463
+ this.emit('templateBuilt', template);
464
+ }
465
+ catch (error) {
466
+ const errorMessage = error instanceof Error ? error.message : String(error);
467
+ // Update StateService with error (single source of truth)
468
+ await this.stateService.markAsError(templatePath, errorMessage, 'build');
469
+ this.emit('templateError', { template, error: errorMessage });
470
+ throw error;
471
+ }
472
+ }
473
+ /**
474
+ * Command handler: Start watching for template changes
475
+ */
476
+ async watch(options = {}) {
477
+ this.watching = true;
478
+ if (!options.silent) {
479
+ this.log('Starting template watching...', 'info');
480
+ }
481
+ // Start FileSystemService watching
482
+ await this.fileSystemService.watchTemplates();
483
+ // Process initial templates if requested
484
+ if (options.initialProcess) {
485
+ const templates = await this.fileSystemService.findTemplates();
486
+ for (const templatePath of templates) {
487
+ void this.handleFileSystemEvent('changed', templatePath);
488
+ }
489
+ }
490
+ return {
491
+ close: async () => {
492
+ this.watching = false;
493
+ await this.fileSystemService.stopWatching();
494
+ if (!options.silent) {
495
+ this.log('Stopped template watching', 'info');
496
+ }
497
+ },
498
+ };
499
+ }
500
+ /**
501
+ * Find all templates using FileSystemService
502
+ */
503
+ async findTemplates() {
504
+ return this.fileSystemService.findTemplates();
505
+ }
506
+ /**
507
+ * Get template status for external consumers
508
+ */
509
+ async getTemplateStatusExternal(templatePath) {
510
+ return this.getTemplateStatus(templatePath);
511
+ }
512
+ /**
513
+ * Register a template in the build log without building it
514
+ * Used when importing existing migrations that should be tracked
515
+ */
516
+ async registerTemplate(templatePath) {
517
+ // Validate template exists
518
+ const exists = await this.fileSystemService.fileExists(templatePath);
519
+ if (!exists) {
520
+ throw new Error(`Template not found: ${templatePath}`);
521
+ }
522
+ // Validate template is in the correct directory
523
+ const templateDir = path.resolve(this.config.baseDir, this.config.cliConfig.templateDir);
524
+ const resolvedPath = path.resolve(templatePath);
525
+ if (!resolvedPath.startsWith(templateDir)) {
526
+ throw new Error(`Template must be in configured templateDir: ${this.config.cliConfig.templateDir}/*`);
527
+ }
528
+ // Read template and compute hash
529
+ const templateFile = await this.fileSystemService.readTemplate(templatePath);
530
+ // Register via StateService (single source of truth)
531
+ // Using markAsBuilt with undefined migration file to indicate registration without build
532
+ await this.stateService.markAsBuilt(templatePath, templateFile.hash, undefined);
533
+ }
534
+ /**
535
+ * Promote a WIP template by renaming it and updating build logs
536
+ * @returns The new path after promotion
537
+ */
538
+ async promoteTemplate(templatePath) {
539
+ // Validate template exists
540
+ const exists = await this.fileSystemService.fileExists(templatePath);
541
+ if (!exists) {
542
+ throw new Error(`Template not found: ${templatePath}`);
543
+ }
544
+ // Check if it's a WIP template
545
+ const isWip = await isWipTemplate(templatePath, this.config.baseDir);
546
+ if (!isWip) {
547
+ throw new Error(`Template is not a WIP template: ${path.basename(templatePath)}`);
548
+ }
549
+ // Calculate new path (remove WIP indicator)
550
+ const newPath = templatePath.replace(this.config.cliConfig.wipIndicator, '');
551
+ // Rename file via FileSystemService
552
+ await this.fileSystemService.renameFile(templatePath, newPath);
553
+ // Update build logs via StateService (single source of truth)
554
+ await this.stateService.renameTemplate(templatePath, newPath);
555
+ return newPath;
556
+ }
557
+ /**
558
+ * Clear build logs via StateService (single source of truth)
559
+ * @param type - 'local' clears local only, 'shared' clears shared only, 'both' clears all
560
+ */
561
+ async clearBuildLogs(type) {
562
+ await this.stateService.clearBuildLogs(type);
563
+ }
564
+ /**
565
+ * Logging utility
566
+ */
567
+ log(msg, logLevel = 'info') {
568
+ if (this.config.silent)
569
+ return;
570
+ // Simple logging for now - can be enhanced with proper logger
571
+ const prefix = {
572
+ info: '[INFO]',
573
+ warn: '[WARN]',
574
+ error: '[ERROR]',
575
+ success: '[SUCCESS]',
576
+ skip: '[SKIP]',
577
+ }[logLevel];
578
+ console.log(`${prefix} ${msg}`);
579
+ }
580
+ /**
581
+ * Dispose of all services and clean up (async version for proper cleanup)
582
+ */
583
+ async dispose() {
584
+ this.watching = false;
585
+ this.processing = false;
586
+ this.processQueue.clear();
587
+ this.pendingRecheck.clear();
588
+ // Wait for all services to dispose, even if some fail
589
+ await Promise.allSettled([
590
+ this.fileSystemService?.dispose(),
591
+ this.stateService?.dispose(),
592
+ this.databaseService?.dispose(),
593
+ ]);
594
+ this.removeAllListeners();
595
+ }
596
+ /**
597
+ * Async dispose for await using statement - ensures cleanup completes
598
+ */
599
+ async [Symbol.asyncDispose]() {
600
+ await this.dispose();
601
+ }
602
+ /**
603
+ * Synchronous dispose for using statement - schedules async cleanup
604
+ * Note: For proper cleanup, prefer await using with Symbol.asyncDispose
605
+ */
606
+ [Symbol.dispose]() {
607
+ void this.dispose();
608
+ }
609
+ /**
610
+ * Create orchestrator from CLI configuration
611
+ */
612
+ static async create(baseDir, cliConfig, options = {}) {
613
+ const orchestrator = new Orchestrator({
614
+ baseDir,
615
+ cliConfig,
616
+ silent: options.silent,
617
+ });
618
+ await orchestrator.initialize();
619
+ return orchestrator;
620
+ }
621
+ }
622
+ //# sourceMappingURL=Orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Orchestrator.js","sourceRoot":"","sources":["../../src/services/Orchestrator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAqCjD,MAAM,OAAO,YAAa,SAAQ,YAAY;IACpC,iBAAiB,CAAqB;IACtC,YAAY,CAAgB;IAC5B,eAAe,CAAmB;IAClC,gBAAgB,CAAoB;IAEpC,MAAM,CAAqB;IAE3B,YAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;IACtC,cAAc,GAAgB,IAAI,GAAG,EAAE,CAAC,CAAC,2CAA2C;IACpF,kBAAkB,GAAkB,IAAI,CAAC;IACzC,UAAU,GAAG,KAAK,CAAC;IACnB,QAAQ,GAAG,KAAK,CAAC;IAEzB,YAAY,MAA0B;QACpC,KAAK,EAAE,C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