@kwirthmagnify/kwirth-provider-http-pull-push 0.1.5 → 0.1.6

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 (2) hide show
  1. package/back.js +18 -6
  2. package/package.json +1 -1
package/back.js CHANGED
@@ -322,6 +322,18 @@ var Poller = class {
322
322
  // src/back/index.ts
323
323
  var HttpPullPushProvider = class {
324
324
  constructor(_clusterInfo, _kwirthData, storage, fetcher = httpFetcher) {
325
+ /*
326
+ Starts writing to the console — what it did before — and the core replaces it as soon as the
327
+ provider is built. With an older core nobody calls setLogger and everything stays as it was.
328
+ */
329
+ this.log = {
330
+ info: (message) => console.log(`[http-pull-push] ${message}`),
331
+ warning: (message) => console.warn(`[http-pull-push] ${message}`),
332
+ error: (message) => console.error(`[http-pull-push] ${message}`)
333
+ };
334
+ this.setLogger = (logger) => {
335
+ this.log = logger;
336
+ };
325
337
  this.id = "http-pull-push";
326
338
  this.providesRouter = false;
327
339
  this.router = void 0;
@@ -349,9 +361,9 @@ var HttpPullPushProvider = class {
349
361
  try {
350
362
  const configs = await this.store.load();
351
363
  this.configs = new Map(configs.map((c) => [c.name, c]));
352
- console.log(`[http-pull-push] ${this.configs.size} connection(s) loaded`);
364
+ this.log.info(`${this.configs.size} connection(s) loaded`);
353
365
  } catch (err) {
354
- console.error(`[http-pull-push] Could not load connections: ${err}`);
366
+ this.log.error(`Could not load connections: ${err}`);
355
367
  }
356
368
  this.started = true;
357
369
  this.reconcile();
@@ -428,7 +440,7 @@ Gotchas:
428
440
  await this.applyConfigs(incoming);
429
441
  res.status(200).json({ ok: true });
430
442
  } catch (err) {
431
- console.error(`[http-pull-push] Error saving connections: ${err}`);
443
+ this.log.error(`Error saving connections: ${err}`);
432
444
  res.status(500).json({ errors: [String(err)] });
433
445
  }
434
446
  });
@@ -437,7 +449,7 @@ Gotchas:
437
449
  const result = await this.testConnection(req.body);
438
450
  res.status(200).json(result);
439
451
  } catch (err) {
440
- console.error(`[http-pull-push] Error testing connection: ${err}`);
452
+ this.log.error(`Error testing connection: ${err}`);
441
453
  res.status(500).json({ ok: false, durationMs: 0, error: String(err) });
442
454
  }
443
455
  });
@@ -591,7 +603,7 @@ Gotchas:
591
603
  this.deliveries++;
592
604
  subscriber.processProviderEvent(this.id, event);
593
605
  } catch (err) {
594
- console.error(`[http-pull-push] Subscriber failed processing '${event.config}': ${err}`);
606
+ this.log.error(`Subscriber failed processing '${event.config}': ${err}`);
595
607
  }
596
608
  }
597
609
  };
@@ -603,7 +615,7 @@ Gotchas:
603
615
  this.warnUnknown = (data) => {
604
616
  if (!data?.configs) return;
605
617
  for (const name of data.configs) {
606
- if (!this.configs.has(name)) console.log(`[http-pull-push] Subscription to unknown connection '${name}' \u2014 ignored`);
618
+ if (!this.configs.has(name)) this.log.warning(`Subscription to unknown connection '${name}' \u2014 ignored`);
607
619
  }
608
620
  };
609
621
  this.store = new ConfigStore(storage);
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "id": "http-pull-push",
8
8
  "name": "@kwirthmagnify/kwirth-provider-http-pull-push",
9
9
  "displayName": "HTTP Pull-Push Provider",
10
- "version": "0.1.5",
10
+ "version": "0.1.6",
11
11
  "description": "HTTP polling provider for Kwirth — pulls remote HTTP endpoints on a schedule and pushes each result to the subscribed channels",
12
12
  "website": "https://kwirthmagnify.dev",
13
13
  "requiresRestart": true,