@kwirthmagnify/kwirth-provider-http-pull-push 0.1.1 → 0.1.3
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/back.js +61 -1
- package/front.js +2 -2
- package/package.json +1 -1
package/back.js
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// kwirth-back-globals:express
|
|
34
|
+
var require_express = __commonJS({
|
|
35
|
+
"kwirth-back-globals:express"(exports2, module2) {
|
|
36
|
+
module2.exports = global.__kwirth_back__.express;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
30
40
|
// src/back/index.ts
|
|
31
41
|
var index_exports = {};
|
|
32
42
|
__export(index_exports, {
|
|
@@ -34,7 +44,7 @@ __export(index_exports, {
|
|
|
34
44
|
default: () => index_default
|
|
35
45
|
});
|
|
36
46
|
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var import_express = __toESM(
|
|
47
|
+
var import_express = __toESM(require_express(), 1);
|
|
38
48
|
|
|
39
49
|
// src/common/HttpPullPush.ts
|
|
40
50
|
var TEST_PREVIEW_CHARS = 1500;
|
|
@@ -468,6 +478,56 @@ Gotchas:
|
|
|
468
478
|
this.configs = new Map(configs.map((c) => [c.name, c]));
|
|
469
479
|
this.reconcile();
|
|
470
480
|
};
|
|
481
|
+
/*
|
|
482
|
+
── Portabilidad de configuracion (IExtension) ──────────────────────────────────────────────
|
|
483
|
+
|
|
484
|
+
Las conexiones SON la configuracion de este provider: nombres, urls, intervalos, cabeceras y
|
|
485
|
+
credenciales. No guarda nada mas —lo que sondea no se persiste, se emite—, asi que aqui no hay
|
|
486
|
+
que separar configuracion de datos: viaja todo.
|
|
487
|
+
|
|
488
|
+
Lo que si hay que separar son las CREDENCIALES, y el store ya las tiene partidas en dos
|
|
489
|
+
almacenes; aqui solo hay que vaciarlas cuando no se piden. Se vacian, no se omiten: quien
|
|
490
|
+
importe tiene que poder ver que esa conexion necesita una contraseña.
|
|
491
|
+
*/
|
|
492
|
+
this.exportConfig = async (options) => {
|
|
493
|
+
const configs = this.getConfigs();
|
|
494
|
+
if (options.includeCredentials) return { configs };
|
|
495
|
+
return {
|
|
496
|
+
configs: configs.map((c) => ({
|
|
497
|
+
...c,
|
|
498
|
+
...c.auth ? { auth: {
|
|
499
|
+
...c.auth,
|
|
500
|
+
...c.auth.password !== void 0 ? { password: "" } : {},
|
|
501
|
+
...c.auth.token !== void 0 ? { token: "" } : {},
|
|
502
|
+
...c.auth.headerValue !== void 0 ? { headerValue: "" } : {}
|
|
503
|
+
} } : {}
|
|
504
|
+
}))
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
this.importConfig = async (data) => {
|
|
508
|
+
const warnings = [];
|
|
509
|
+
const entrantes = data?.configs;
|
|
510
|
+
if (!Array.isArray(entrantes)) return { applied: 0, skipped: 0, warnings: ["no configs array in the imported data"] };
|
|
511
|
+
const errores = validateConfigs(entrantes);
|
|
512
|
+
if (errores.length > 0) return { applied: 0, skipped: entrantes.length, warnings: errores };
|
|
513
|
+
const conservarSecretos = (entrante) => {
|
|
514
|
+
const actual = this.configs.get(entrante.name);
|
|
515
|
+
if (!entrante.auth) return entrante;
|
|
516
|
+
const heredar = (campo) => {
|
|
517
|
+
const valor = entrante.auth?.[campo];
|
|
518
|
+
if (valor) return { [campo]: valor };
|
|
519
|
+
const previo = actual?.auth?.[campo];
|
|
520
|
+
if (previo) return { [campo]: previo };
|
|
521
|
+
if (valor === "") warnings.push(`connection '${entrante.name}' needs its ${campo} to be set`);
|
|
522
|
+
return {};
|
|
523
|
+
};
|
|
524
|
+
return { ...entrante, auth: { ...entrante.auth, ...heredar("password"), ...heredar("token"), ...heredar("headerValue") } };
|
|
525
|
+
};
|
|
526
|
+
const resultado = new Map(this.configs);
|
|
527
|
+
for (const entrante of entrantes) resultado.set(entrante.name, conservarSecretos(entrante));
|
|
528
|
+
await this.applyConfigs([...resultado.values()]);
|
|
529
|
+
return { applied: entrantes.length, skipped: 0, warnings };
|
|
530
|
+
};
|
|
471
531
|
this.getConfigs = () => [...this.configs.values()];
|
|
472
532
|
// Solo los nombres: alimenta el contador de la tarjeta en el gestor de extensiones.
|
|
473
533
|
this.getConfigNames = () => [...this.configs.keys()];
|
package/front.js
CHANGED
|
@@ -569,7 +569,7 @@
|
|
|
569
569
|
import_material3.Button,
|
|
570
570
|
{
|
|
571
571
|
size: "small",
|
|
572
|
-
startIcon: /* @__PURE__ */ import_react3.default.createElement(import_icons_material3.
|
|
572
|
+
startIcon: /* @__PURE__ */ import_react3.default.createElement(import_icons_material3.Download, null),
|
|
573
573
|
disabled: configs.length === 0,
|
|
574
574
|
onClick: () => {
|
|
575
575
|
setExportSelected(new Set(configs.map((c) => c.name)));
|
|
@@ -578,7 +578,7 @@
|
|
|
578
578
|
}
|
|
579
579
|
},
|
|
580
580
|
"Export"
|
|
581
|
-
))), /* @__PURE__ */ import_react3.default.createElement(import_material3.Tooltip, { title: "Import connections from JSON" }, /* @__PURE__ */ import_react3.default.createElement(import_material3.Button, { size: "small", startIcon: /* @__PURE__ */ import_react3.default.createElement(import_icons_material3.
|
|
581
|
+
))), /* @__PURE__ */ import_react3.default.createElement(import_material3.Tooltip, { title: "Import connections from JSON" }, /* @__PURE__ */ import_react3.default.createElement(import_material3.Button, { size: "small", startIcon: /* @__PURE__ */ import_react3.default.createElement(import_icons_material3.Upload, null), onClick: () => importFileRef.current?.click() }, "Import"))), /* @__PURE__ */ import_react3.default.createElement(import_material3.Button, { onClick: onClose, disabled: saving }, "Close"))), /* @__PURE__ */ import_react3.default.createElement(import_material3.Dialog, { open: exportOpen, maxWidth: false, sx: { "& .MuiDialog-paper": { width: "480px" } } }, /* @__PURE__ */ import_react3.default.createElement(import_material3.DialogTitle, null, "Export connections"), /* @__PURE__ */ import_react3.default.createElement(import_material3.DialogContent, { sx: { pt: "16px !important" } }, /* @__PURE__ */ import_react3.default.createElement(import_material3.Stack, { spacing: 1 }, /* @__PURE__ */ import_react3.default.createElement(
|
|
582
582
|
import_material3.FormControlLabel,
|
|
583
583
|
{
|
|
584
584
|
label: "Select all",
|
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.
|
|
10
|
+
"version": "0.1.3",
|
|
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,
|