@ceon-oy/monitor-sdk 1.0.16 → 1.1.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.
package/README.md CHANGED
@@ -102,6 +102,8 @@ interface MonitorClientConfig {
102
102
  path: string; // Directory path (e.g., '.', '../client')
103
103
  environment: string; // Environment label (e.g., 'server', 'client')
104
104
  }[];
105
+ auditTimeoutMs?: number; // Timeout for npm audit command (default: 60000, max: 300000)
106
+ registryTimeoutMs?: number; // Timeout for npm registry requests (default: 5000, max: 30000)
105
107
  }
106
108
  ```
107
109
 
package/dist/index.d.mts CHANGED
@@ -47,6 +47,8 @@ interface MonitorClientConfig {
47
47
  versionCheckEnabled?: boolean;
48
48
  /** Timeout for npm audit command in ms (default: 60000, max: 300000) */
49
49
  auditTimeoutMs?: number;
50
+ /** Timeout for npm registry requests in ms (default: 5000, max: 30000) */
51
+ registryTimeoutMs?: number;
50
52
  }
51
53
  interface TechnologyItem {
52
54
  name: string;
@@ -185,6 +187,7 @@ declare class MonitorClient {
185
187
  private lastKnownTechScanRequestedAt;
186
188
  private versionCheckEnabled;
187
189
  private auditTimeoutMs;
190
+ private registryTimeoutMs;
188
191
  constructor(config: MonitorClientConfig);
189
192
  /**
190
193
  * Security: Validate and sanitize metadata to prevent oversized payloads
package/dist/index.d.ts CHANGED
@@ -47,6 +47,8 @@ interface MonitorClientConfig {
47
47
  versionCheckEnabled?: boolean;
48
48
  /** Timeout for npm audit command in ms (default: 60000, max: 300000) */
49
49
  auditTimeoutMs?: number;
50
+ /** Timeout for npm registry requests in ms (default: 5000, max: 30000) */
51
+ registryTimeoutMs?: number;
50
52
  }
51
53
  interface TechnologyItem {
52
54
  name: string;
@@ -185,6 +187,7 @@ declare class MonitorClient {
185
187
  private lastKnownTechScanRequestedAt;
186
188
  private versionCheckEnabled;
187
189
  private auditTimeoutMs;
190
+ private registryTimeoutMs;
188
191
  constructor(config: MonitorClientConfig);
189
192
  /**
190
193
  * Security: Validate and sanitize metadata to prevent oversized payloads
package/dist/index.js CHANGED
@@ -53,8 +53,12 @@ var CONFIG_LIMITS = {
53
53
  // 60 seconds (default)
54
54
  MAX_AUDIT_TIMEOUT_MS: 3e5,
55
55
  // 5 minutes (max configurable)
56
- SETTINGS_POLL_INTERVAL_MS: 5 * 60 * 1e3
56
+ SETTINGS_POLL_INTERVAL_MS: 5 * 60 * 1e3,
57
57
  // 5 minutes
58
+ REGISTRY_TIMEOUT_MS: 5e3,
59
+ // 5 seconds (default)
60
+ MAX_REGISTRY_TIMEOUT_MS: 3e4
61
+ // 30 seconds (max configurable)
58
62
  };
59
63
  var MonitorClient = class {
60
64
  constructor(config) {
@@ -121,6 +125,7 @@ var MonitorClient = class {
121
125
  this.includeDevDependencies = config.includeDevDependencies ?? false;
122
126
  this.versionCheckEnabled = config.versionCheckEnabled ?? true;
123
127
  this.auditTimeoutMs = Math.min(CONFIG_LIMITS.MAX_AUDIT_TIMEOUT_MS, Math.max(1e3, config.auditTimeoutMs || CONFIG_LIMITS.AUDIT_TIMEOUT_MS));
128
+ this.registryTimeoutMs = Math.min(CONFIG_LIMITS.MAX_REGISTRY_TIMEOUT_MS, Math.max(1e3, config.registryTimeoutMs || CONFIG_LIMITS.REGISTRY_TIMEOUT_MS));
124
129
  this.startFlushTimer();
125
130
  if (this.trackDependencies) {
126
131
  this.syncDependencies().catch((err) => {
@@ -443,12 +448,14 @@ var MonitorClient = class {
443
448
  if (technologies.length === 0) continue;
444
449
  const enrichedTechnologies = await this.enrichWithLatestVersions(technologies);
445
450
  await this.sendTechnologiesWithEnvironment(enrichedTechnologies, source.environment);
451
+ console.log(`[MonitorClient] Technology sync completed for ${source.environment}`);
446
452
  }
447
453
  } else {
448
454
  const technologies = await this.readPackageJson();
449
455
  if (technologies.length === 0) return;
450
456
  const enrichedTechnologies = await this.enrichWithLatestVersions(technologies);
451
457
  await this.sendTechnologies(enrichedTechnologies);
458
+ console.log(`[MonitorClient] Technology sync completed for ${this.environment}`);
452
459
  }
453
460
  } catch (err) {
454
461
  console.error("[MonitorClient] Failed to sync dependencies:", err);
@@ -466,6 +473,8 @@ var MonitorClient = class {
466
473
  console.log(`[MonitorClient] Fetching latest versions for ${technologies.length} packages...`);
467
474
  const packageNames = technologies.map((t) => t.name);
468
475
  const latestVersions = await this.fetchLatestVersions(packageNames);
476
+ const foundCount = [...latestVersions.values()].filter((v) => v !== null).length;
477
+ console.log(`[MonitorClient] Fetched latest versions: ${foundCount}/${technologies.length} packages`);
469
478
  return technologies.map((tech) => ({
470
479
  ...tech,
471
480
  latestVersion: latestVersions.get(tech.name) || void 0
@@ -550,7 +559,7 @@ var MonitorClient = class {
550
559
  const encodedName = encodeURIComponent(packageName).replace("%40", "@");
551
560
  const response = await fetch(`https://registry.npmjs.org/${encodedName}`, {
552
561
  headers: { "Accept": "application/json" },
553
- signal: AbortSignal.timeout(5e3)
562
+ signal: AbortSignal.timeout(this.registryTimeoutMs)
554
563
  });
555
564
  if (!response.ok) return null;
556
565
  const data = await response.json();
package/dist/index.mjs CHANGED
@@ -17,8 +17,12 @@ var CONFIG_LIMITS = {
17
17
  // 60 seconds (default)
18
18
  MAX_AUDIT_TIMEOUT_MS: 3e5,
19
19
  // 5 minutes (max configurable)
20
- SETTINGS_POLL_INTERVAL_MS: 5 * 60 * 1e3
20
+ SETTINGS_POLL_INTERVAL_MS: 5 * 60 * 1e3,
21
21
  // 5 minutes
22
+ REGISTRY_TIMEOUT_MS: 5e3,
23
+ // 5 seconds (default)
24
+ MAX_REGISTRY_TIMEOUT_MS: 3e4
25
+ // 30 seconds (max configurable)
22
26
  };
23
27
  var MonitorClient = class {
24
28
  constructor(config) {
@@ -85,6 +89,7 @@ var MonitorClient = class {
85
89
  this.includeDevDependencies = config.includeDevDependencies ?? false;
86
90
  this.versionCheckEnabled = config.versionCheckEnabled ?? true;
87
91
  this.auditTimeoutMs = Math.min(CONFIG_LIMITS.MAX_AUDIT_TIMEOUT_MS, Math.max(1e3, config.auditTimeoutMs || CONFIG_LIMITS.AUDIT_TIMEOUT_MS));
92
+ this.registryTimeoutMs = Math.min(CONFIG_LIMITS.MAX_REGISTRY_TIMEOUT_MS, Math.max(1e3, config.registryTimeoutMs || CONFIG_LIMITS.REGISTRY_TIMEOUT_MS));
88
93
  this.startFlushTimer();
89
94
  if (this.trackDependencies) {
90
95
  this.syncDependencies().catch((err) => {
@@ -407,12 +412,14 @@ var MonitorClient = class {
407
412
  if (technologies.length === 0) continue;
408
413
  const enrichedTechnologies = await this.enrichWithLatestVersions(technologies);
409
414
  await this.sendTechnologiesWithEnvironment(enrichedTechnologies, source.environment);
415
+ console.log(`[MonitorClient] Technology sync completed for ${source.environment}`);
410
416
  }
411
417
  } else {
412
418
  const technologies = await this.readPackageJson();
413
419
  if (technologies.length === 0) return;
414
420
  const enrichedTechnologies = await this.enrichWithLatestVersions(technologies);
415
421
  await this.sendTechnologies(enrichedTechnologies);
422
+ console.log(`[MonitorClient] Technology sync completed for ${this.environment}`);
416
423
  }
417
424
  } catch (err) {
418
425
  console.error("[MonitorClient] Failed to sync dependencies:", err);
@@ -430,6 +437,8 @@ var MonitorClient = class {
430
437
  console.log(`[MonitorClient] Fetching latest versions for ${technologies.length} packages...`);
431
438
  const packageNames = technologies.map((t) => t.name);
432
439
  const latestVersions = await this.fetchLatestVersions(packageNames);
440
+ const foundCount = [...latestVersions.values()].filter((v) => v !== null).length;
441
+ console.log(`[MonitorClient] Fetched latest versions: ${foundCount}/${technologies.length} packages`);
433
442
  return technologies.map((tech) => ({
434
443
  ...tech,
435
444
  latestVersion: latestVersions.get(tech.name) || void 0
@@ -514,7 +523,7 @@ var MonitorClient = class {
514
523
  const encodedName = encodeURIComponent(packageName).replace("%40", "@");
515
524
  const response = await fetch(`https://registry.npmjs.org/${encodedName}`, {
516
525
  headers: { "Accept": "application/json" },
517
- signal: AbortSignal.timeout(5e3)
526
+ signal: AbortSignal.timeout(this.registryTimeoutMs)
518
527
  });
519
528
  if (!response.ok) return null;
520
529
  const data = await response.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceon-oy/monitor-sdk",
3
- "version": "1.0.16",
3
+ "version": "1.1.0",
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",
@@ -34,12 +34,15 @@
34
34
  "scripts": {
35
35
  "build": "tsup src/index.ts --format cjs,esm --dts",
36
36
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
37
+ "test": "vitest run",
38
+ "test:watch": "vitest",
37
39
  "prepublishOnly": "npm run build"
38
40
  },
39
41
  "devDependencies": {
40
42
  "@types/node": "^24.10.2",
41
43
  "tsup": "^8.3.5",
42
- "typescript": "^5.7.2"
44
+ "typescript": "^5.7.2",
45
+ "vitest": "^4.0.18"
43
46
  },
44
47
  "files": [
45
48
  "dist"