@ceon-oy/monitor-sdk 1.5.5 → 1.5.7

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.
package/dist/index.d.mts CHANGED
@@ -189,6 +189,18 @@ interface SdkHealthResultsResponse {
189
189
  total: number;
190
190
  };
191
191
  }
192
+ interface ProjectSettings {
193
+ name: string;
194
+ vulnerabilityScanIntervalHours: number;
195
+ scanRequestedAt: string | null;
196
+ techScanRequestedAt: string | null;
197
+ metricsEnabled?: boolean;
198
+ metricsIntervalSeconds?: number;
199
+ metricsDiskPaths?: string[];
200
+ metricsCpuThreshold?: number;
201
+ metricsRamThreshold?: number;
202
+ metricsDiskThreshold?: number;
203
+ }
192
204
 
193
205
  declare class MonitorClient {
194
206
  private apiKey;
@@ -291,18 +303,16 @@ declare class MonitorClient {
291
303
  * Fetch project settings from the monitoring server.
292
304
  * Returns configuration including vulnerability scan interval and scan request timestamps.
293
305
  */
294
- fetchProjectSettings(): Promise<{
295
- name: string;
296
- vulnerabilityScanIntervalHours: number;
297
- scanRequestedAt: string | null;
298
- techScanRequestedAt: string | null;
299
- metricsEnabled?: boolean;
300
- metricsIntervalSeconds?: number;
301
- metricsDiskPaths?: string[];
302
- metricsCpuThreshold?: number;
303
- metricsRamThreshold?: number;
304
- metricsDiskThreshold?: number;
305
- } | null>;
306
+ fetchProjectSettings(): Promise<ProjectSettings | null>;
307
+ /**
308
+ * Fetch project settings, retrying a couple of times on failure before giving up.
309
+ * A single transient failure here (a slow DNS lookup, a brief server hiccup at
310
+ * boot) used to permanently disable auto-audit for the process's entire
311
+ * lifetime, since this call only ever ran once at startup. Retrying a few
312
+ * seconds apart absorbs that kind of one-off blip instead of needing a full
313
+ * process restart to recover.
314
+ */
315
+ private fetchProjectSettingsWithRetry;
306
316
  /**
307
317
  * Setup automatic vulnerability scanning based on server-configured interval.
308
318
  * Fetches settings from server and sets up recurring scans.
package/dist/index.d.ts CHANGED
@@ -189,6 +189,18 @@ interface SdkHealthResultsResponse {
189
189
  total: number;
190
190
  };
191
191
  }
192
+ interface ProjectSettings {
193
+ name: string;
194
+ vulnerabilityScanIntervalHours: number;
195
+ scanRequestedAt: string | null;
196
+ techScanRequestedAt: string | null;
197
+ metricsEnabled?: boolean;
198
+ metricsIntervalSeconds?: number;
199
+ metricsDiskPaths?: string[];
200
+ metricsCpuThreshold?: number;
201
+ metricsRamThreshold?: number;
202
+ metricsDiskThreshold?: number;
203
+ }
192
204
 
193
205
  declare class MonitorClient {
194
206
  private apiKey;
@@ -291,18 +303,16 @@ declare class MonitorClient {
291
303
  * Fetch project settings from the monitoring server.
292
304
  * Returns configuration including vulnerability scan interval and scan request timestamps.
293
305
  */
294
- fetchProjectSettings(): Promise<{
295
- name: string;
296
- vulnerabilityScanIntervalHours: number;
297
- scanRequestedAt: string | null;
298
- techScanRequestedAt: string | null;
299
- metricsEnabled?: boolean;
300
- metricsIntervalSeconds?: number;
301
- metricsDiskPaths?: string[];
302
- metricsCpuThreshold?: number;
303
- metricsRamThreshold?: number;
304
- metricsDiskThreshold?: number;
305
- } | null>;
306
+ fetchProjectSettings(): Promise<ProjectSettings | null>;
307
+ /**
308
+ * Fetch project settings, retrying a couple of times on failure before giving up.
309
+ * A single transient failure here (a slow DNS lookup, a brief server hiccup at
310
+ * boot) used to permanently disable auto-audit for the process's entire
311
+ * lifetime, since this call only ever ran once at startup. Retrying a few
312
+ * seconds apart absorbs that kind of one-off blip instead of needing a full
313
+ * process restart to recover.
314
+ */
315
+ private fetchProjectSettingsWithRetry;
306
316
  /**
307
317
  * Setup automatic vulnerability scanning based on server-configured interval.
308
318
  * Fetches settings from server and sets up recurring scans.
package/dist/index.js CHANGED
@@ -58,6 +58,10 @@ var CONFIG_LIMITS = {
58
58
  // real npm audit run on Cloud Run (slow registry egress) exceeded, silently returning null
59
59
  SETTINGS_POLL_INTERVAL_MS: 5 * 60 * 1e3,
60
60
  // 5 minutes
61
+ SETUP_SETTINGS_MAX_ATTEMPTS: 3,
62
+ // retry a transient failure fetching settings at startup
63
+ SETUP_SETTINGS_RETRY_DELAY_MS: 5e3,
64
+ // before falling back to the periodic poll to self-heal
61
65
  REGISTRY_TIMEOUT_MS: 5e3,
62
66
  // 5 seconds (default)
63
67
  MAX_REGISTRY_TIMEOUT_MS: 3e4,
@@ -490,15 +494,46 @@ var MonitorClient = class {
490
494
  return null;
491
495
  }
492
496
  }
497
+ /**
498
+ * Fetch project settings, retrying a couple of times on failure before giving up.
499
+ * A single transient failure here (a slow DNS lookup, a brief server hiccup at
500
+ * boot) used to permanently disable auto-audit for the process's entire
501
+ * lifetime, since this call only ever ran once at startup. Retrying a few
502
+ * seconds apart absorbs that kind of one-off blip instead of needing a full
503
+ * process restart to recover.
504
+ */
505
+ async fetchProjectSettingsWithRetry() {
506
+ for (let attempt = 1; attempt <= CONFIG_LIMITS.SETUP_SETTINGS_MAX_ATTEMPTS; attempt++) {
507
+ const settings = await this.fetchProjectSettings();
508
+ if (settings) {
509
+ return settings;
510
+ }
511
+ if (attempt < CONFIG_LIMITS.SETUP_SETTINGS_MAX_ATTEMPTS) {
512
+ console.warn(
513
+ `[MonitorClient] Fetching project settings failed (attempt ${attempt}/${CONFIG_LIMITS.SETUP_SETTINGS_MAX_ATTEMPTS}), retrying...`
514
+ );
515
+ await new Promise((resolve) => setTimeout(resolve, CONFIG_LIMITS.SETUP_SETTINGS_RETRY_DELAY_MS));
516
+ }
517
+ }
518
+ return null;
519
+ }
493
520
  /**
494
521
  * Setup automatic vulnerability scanning based on server-configured interval.
495
522
  * Fetches settings from server and sets up recurring scans.
496
523
  * Also sets up polling for on-demand scan requests from the server.
497
524
  */
498
525
  async setupAutoAudit() {
499
- const settings = await this.fetchProjectSettings();
526
+ const settings = await this.fetchProjectSettingsWithRetry();
527
+ console.log("[MonitorClient] Polling for scan requests enabled (every 5 minutes)");
528
+ this.settingsPollingTimer = setInterval(() => {
529
+ this.checkForScanRequest().catch((err) => {
530
+ this.reportError("SETTINGS_POLL", "Scan request check failed", err);
531
+ });
532
+ }, CONFIG_LIMITS.SETTINGS_POLL_INTERVAL_MS);
500
533
  if (!settings) {
501
- console.warn("[MonitorClient] Could not fetch project settings, auto audit disabled");
534
+ const message = "Could not fetch project settings after retrying at startup; will keep retrying every 5 minutes";
535
+ console.warn(`[MonitorClient] ${message}`);
536
+ this.reportError("AUDIT_SETUP", message);
502
537
  return;
503
538
  }
504
539
  if (settings.scanRequestedAt) {
@@ -516,12 +551,6 @@ var MonitorClient = class {
516
551
  await this.runScanAndTrackTime();
517
552
  this.setAuditInterval(intervalHours);
518
553
  }
519
- console.log("[MonitorClient] Polling for scan requests enabled (every 5 minutes)");
520
- this.settingsPollingTimer = setInterval(() => {
521
- this.checkForScanRequest().catch((err) => {
522
- this.reportError("SETTINGS_POLL", "Scan request check failed", err);
523
- });
524
- }, CONFIG_LIMITS.SETTINGS_POLL_INTERVAL_MS);
525
554
  }
526
555
  /**
527
556
  * (Re)configure the recurring audit timer for the given interval, replacing
package/dist/index.mjs CHANGED
@@ -22,6 +22,10 @@ var CONFIG_LIMITS = {
22
22
  // real npm audit run on Cloud Run (slow registry egress) exceeded, silently returning null
23
23
  SETTINGS_POLL_INTERVAL_MS: 5 * 60 * 1e3,
24
24
  // 5 minutes
25
+ SETUP_SETTINGS_MAX_ATTEMPTS: 3,
26
+ // retry a transient failure fetching settings at startup
27
+ SETUP_SETTINGS_RETRY_DELAY_MS: 5e3,
28
+ // before falling back to the periodic poll to self-heal
25
29
  REGISTRY_TIMEOUT_MS: 5e3,
26
30
  // 5 seconds (default)
27
31
  MAX_REGISTRY_TIMEOUT_MS: 3e4,
@@ -454,15 +458,46 @@ var MonitorClient = class {
454
458
  return null;
455
459
  }
456
460
  }
461
+ /**
462
+ * Fetch project settings, retrying a couple of times on failure before giving up.
463
+ * A single transient failure here (a slow DNS lookup, a brief server hiccup at
464
+ * boot) used to permanently disable auto-audit for the process's entire
465
+ * lifetime, since this call only ever ran once at startup. Retrying a few
466
+ * seconds apart absorbs that kind of one-off blip instead of needing a full
467
+ * process restart to recover.
468
+ */
469
+ async fetchProjectSettingsWithRetry() {
470
+ for (let attempt = 1; attempt <= CONFIG_LIMITS.SETUP_SETTINGS_MAX_ATTEMPTS; attempt++) {
471
+ const settings = await this.fetchProjectSettings();
472
+ if (settings) {
473
+ return settings;
474
+ }
475
+ if (attempt < CONFIG_LIMITS.SETUP_SETTINGS_MAX_ATTEMPTS) {
476
+ console.warn(
477
+ `[MonitorClient] Fetching project settings failed (attempt ${attempt}/${CONFIG_LIMITS.SETUP_SETTINGS_MAX_ATTEMPTS}), retrying...`
478
+ );
479
+ await new Promise((resolve) => setTimeout(resolve, CONFIG_LIMITS.SETUP_SETTINGS_RETRY_DELAY_MS));
480
+ }
481
+ }
482
+ return null;
483
+ }
457
484
  /**
458
485
  * Setup automatic vulnerability scanning based on server-configured interval.
459
486
  * Fetches settings from server and sets up recurring scans.
460
487
  * Also sets up polling for on-demand scan requests from the server.
461
488
  */
462
489
  async setupAutoAudit() {
463
- const settings = await this.fetchProjectSettings();
490
+ const settings = await this.fetchProjectSettingsWithRetry();
491
+ console.log("[MonitorClient] Polling for scan requests enabled (every 5 minutes)");
492
+ this.settingsPollingTimer = setInterval(() => {
493
+ this.checkForScanRequest().catch((err) => {
494
+ this.reportError("SETTINGS_POLL", "Scan request check failed", err);
495
+ });
496
+ }, CONFIG_LIMITS.SETTINGS_POLL_INTERVAL_MS);
464
497
  if (!settings) {
465
- console.warn("[MonitorClient] Could not fetch project settings, auto audit disabled");
498
+ const message = "Could not fetch project settings after retrying at startup; will keep retrying every 5 minutes";
499
+ console.warn(`[MonitorClient] ${message}`);
500
+ this.reportError("AUDIT_SETUP", message);
466
501
  return;
467
502
  }
468
503
  if (settings.scanRequestedAt) {
@@ -480,12 +515,6 @@ var MonitorClient = class {
480
515
  await this.runScanAndTrackTime();
481
516
  this.setAuditInterval(intervalHours);
482
517
  }
483
- console.log("[MonitorClient] Polling for scan requests enabled (every 5 minutes)");
484
- this.settingsPollingTimer = setInterval(() => {
485
- this.checkForScanRequest().catch((err) => {
486
- this.reportError("SETTINGS_POLL", "Scan request check failed", err);
487
- });
488
- }, CONFIG_LIMITS.SETTINGS_POLL_INTERVAL_MS);
489
518
  }
490
519
  /**
491
520
  * (Re)configure the recurring audit timer for the given interval, replacing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceon-oy/monitor-sdk",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "Client SDK for Ceon Monitor - Error tracking, health monitoring, security events, and vulnerability scanning",
5
5
  "author": "Ceon",
6
6
  "license": "MIT",