@teamvibe/poller 0.1.62 → 0.1.64

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.
@@ -26,20 +26,25 @@ export async function postMaintenanceReports(brainPath, channelId) {
26
26
  return;
27
27
  logger.info(`[MaintenanceReporter] Found ${jsonFiles.length} JSON report(s) in ${reportsDir}`);
28
28
  const postedFiles = [];
29
+ const removedFiles = [];
29
30
  for (const file of jsonFiles) {
30
31
  const filePath = join(reportsDir, file);
31
32
  try {
32
33
  const content = await readFile(filePath, 'utf-8');
33
34
  const report = JSON.parse(content);
34
35
  if (!report.operationType) {
35
- logger.warn(`[MaintenanceReporter] Skipping ${file}: missing operationType`);
36
- emitError('maintenance', `Skipping report ${file}: missing operationType`, { severity: 'warn' });
36
+ logger.warn(`[MaintenanceReporter] Removing invalid report ${file}: missing operationType`);
37
+ emitError('maintenance', `Removing invalid report ${file}: missing operationType`, { severity: 'warn' });
38
+ await unlink(filePath).catch(() => { });
39
+ removedFiles.push(`reports/${file}`);
37
40
  continue;
38
41
  }
39
42
  const eventType = OPERATION_TO_EVENT_TYPE[report.operationType];
40
43
  if (!eventType) {
41
- logger.warn(`[MaintenanceReporter] Skipping ${file}: unknown operationType "${report.operationType}"`);
42
- emitError('maintenance', `Skipping report ${file}: unknown operationType "${report.operationType}"`, { severity: 'warn' });
44
+ logger.warn(`[MaintenanceReporter] Removing report ${file}: unknown operationType "${report.operationType}"`);
45
+ emitError('maintenance', `Removing report ${file}: unknown operationType "${report.operationType}"`, { severity: 'warn' });
46
+ await unlink(filePath).catch(() => { });
47
+ removedFiles.push(`reports/${file}`);
43
48
  continue;
44
49
  }
45
50
  const payload = {
@@ -71,12 +76,13 @@ export async function postMaintenanceReports(brainPath, channelId) {
71
76
  emitError('maintenance', `Error processing report ${file}: ${err instanceof Error ? err.message : String(err)}`, { severity: 'warn', channelId });
72
77
  }
73
78
  }
74
- // Remove posted JSON reports from git so they don't resurrect on next pull
75
- if (postedFiles.length > 0) {
79
+ // Remove posted/invalid JSON reports from git so they don't resurrect on next pull
80
+ const allRemovedFromGit = [...postedFiles, ...removedFiles];
81
+ if (allRemovedFromGit.length > 0) {
76
82
  try {
77
- await execFileAsync('git', ['rm', '--cached', '--ignore-unmatch', ...postedFiles], { cwd: brainPath });
78
- await execFileAsync('git', ['commit', '-m', 'chore: remove posted maintenance reports'], { cwd: brainPath });
79
- logger.info(`[MaintenanceReporter] Committed removal of ${postedFiles.length} posted report(s) from git`);
83
+ await execFileAsync('git', ['rm', '--cached', '--ignore-unmatch', ...allRemovedFromGit], { cwd: brainPath });
84
+ await execFileAsync('git', ['commit', '-m', 'chore: remove processed maintenance reports'], { cwd: brainPath });
85
+ logger.info(`[MaintenanceReporter] Committed removal of ${allRemovedFromGit.length} report(s) from git`);
80
86
  }
81
87
  catch (err) {
82
88
  logger.debug(`[MaintenanceReporter] Could not git-rm reports (may not be a git repo): ${err instanceof Error ? err.message : err}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamvibe/poller",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {