@kwirthmagnify/kwirth-common-back 0.5.39 → 0.5.41

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.
@@ -0,0 +1,28 @@
1
+ export declare enum EConfigFieldType {
2
+ TEXT = "text",
3
+ NUMBER = "number",
4
+ BOOLEAN = "boolean",
5
+ PASSWORD = "password",
6
+ SELECT = "select",
7
+ JSON = "json"
8
+ }
9
+ export interface IConfigFieldDef {
10
+ /** Clave con la que el valor se guarda en la configuracion. */
11
+ name: string;
12
+ /** Etiqueta que ve el usuario en el formulario. */
13
+ label: string;
14
+ /** Ausente = EConfigFieldType.TEXT. */
15
+ type?: EConfigFieldType;
16
+ required?: boolean;
17
+ /** Valores admitidos cuando 'type' es SELECT. Ignorado en el resto. */
18
+ options?: string[];
19
+ /** Valor con el que se precarga el campo mientras no haya nada guardado. */
20
+ default?: string | number | boolean;
21
+ /** El campo es comun a TODAS las configuraciones de la extension, no propio de cada una. */
22
+ common?: boolean;
23
+ }
24
+ export interface IExtensionNodeMeta {
25
+ label: string;
26
+ icon?: string;
27
+ description?: string;
28
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*
3
+ Contrato COMUN de configuracion de extensiones.
4
+
5
+ Toda extension que publique un formulario de configuracion (senders, webhooks, conectores IdP,
6
+ logins y providers) describe sus campos con ESTE tipo. Antes cada familia tenia el suyo, casi
7
+ identico pero divergente: provider decia 'string' donde el resto decia 'text', solo el tenia
8
+ 'default', solo sender y webhook tenian 'common', y su definicion ni siquiera vivia aqui (estaba
9
+ dentro del core, en back/src/tools/ProviderManager.ts).
10
+
11
+ OJO: no confundir EConfigFieldType (el tipo de UN CAMPO del formulario) con EExtensionType (el
12
+ tipo de la extension: provider, sender, plugin...), que vive en kwirth-common y es lo que declara
13
+ el package.json del artefacto.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.EConfigFieldType = void 0;
17
+ /*
18
+ Tipo de un campo del formulario de configuracion.
19
+
20
+ Lo que hoy pinta el front para cada valor:
21
+ TEXT campo de texto. Es el comportamiento por defecto cuando 'type' se omite.
22
+ NUMBER campo numerico.
23
+ BOOLEAN switch. Los gestores de sender, webhook, idp y provider lo pintan; el de login no.
24
+ PASSWORD campo enmascarado con ojo de visibilidad.
25
+ SELECT desplegable alimentado por 'options'. Los gestores de sender, webhook y login lo
26
+ pintan; los de idp y provider no.
27
+ JSON area de texto libre para JSON. NINGUN gestor lo pinta todavia: hoy cae a campo de
28
+ texto. Declararlo es valido, pero no esperes editor estructurado.
29
+ */
30
+ var EConfigFieldType;
31
+ (function (EConfigFieldType) {
32
+ EConfigFieldType["TEXT"] = "text";
33
+ EConfigFieldType["NUMBER"] = "number";
34
+ EConfigFieldType["BOOLEAN"] = "boolean";
35
+ EConfigFieldType["PASSWORD"] = "password";
36
+ EConfigFieldType["SELECT"] = "select";
37
+ EConfigFieldType["JSON"] = "json";
38
+ })(EConfigFieldType || (exports.EConfigFieldType = EConfigFieldType = {}));
@@ -1,15 +1,11 @@
1
+ import { EConfigFieldType, IConfigFieldDef } from './IExtensionConfig';
1
2
  export declare enum EIdpConnectorKind {
2
3
  OIDC = "oidc",
3
4
  OAUTH2 = "oauth2"
4
5
  }
5
- export type IdpFieldType = 'text' | 'number' | 'boolean' | 'password';
6
- export interface IIdpConfigFieldDef {
7
- name: string;
8
- label: string;
9
- type?: IdpFieldType;
10
- required?: boolean;
11
- options?: string[];
12
- }
6
+ /** @deprecated usa EConfigFieldType, comun a todas las extensiones. */
7
+ export type IdpFieldType = EConfigFieldType;
8
+ export type IIdpConfigFieldDef = IConfigFieldDef;
13
9
  export interface IIdpIdentity {
14
10
  email: string;
15
11
  emailVerified: boolean;
package/dist/ILogin.d.ts CHANGED
@@ -1,8 +1,5 @@
1
- export type LoginFieldType = 'text' | 'number' | 'boolean' | 'password' | 'select';
2
- export interface ILoginFieldDef {
3
- name: string;
4
- label: string;
5
- type?: LoginFieldType;
6
- required?: boolean;
7
- options?: string[];
8
- }
1
+ import { EConfigFieldType, IConfigFieldDef } from './IExtensionConfig';
2
+ /** @deprecated usa EConfigFieldType, comun a todas las extensiones. */
3
+ export type LoginFieldType = EConfigFieldType;
4
+ /** Campo de configuracion de un login. Es el contrato comun IConfigFieldDef, sin nada propio. */
5
+ export type ILoginFieldDef = IConfigFieldDef;
@@ -1,4 +1,5 @@
1
1
  import { KwirthData } from '@kwirthmagnify/kwirth-common';
2
+ import { IConfigFieldDef } from './IExtensionConfig';
2
3
  /**
3
4
  * Minimal interface representing the channel side that providers interact with.
4
5
  * Providers only need to call processProviderEvent on their subscribers.
@@ -17,6 +18,38 @@ export interface IProviderStorage {
17
18
  writeStorageCommon(id: string, secret: boolean, data: any): Promise<void>;
18
19
  readStorageCommon(id: string, secret: boolean): Promise<any>;
19
20
  }
21
+ /**
22
+ * Un campo del payload de suscripcion, descrito para que un consumidor pueda pintar un formulario
23
+ * en vez de exigir JSON a mano. Solo tiene sentido declararlos cuando el payload es plano; si es
24
+ * anidado (p.ej. otel, con 'spaces'), basta con 'usage' y 'example'.
25
+ */
26
+ export interface IProviderSubscriptionField {
27
+ name: string;
28
+ type: 'string' | 'number' | 'boolean' | 'string[]';
29
+ required?: boolean;
30
+ description: string;
31
+ }
32
+ /**
33
+ * Ayuda que un provider publica sobre COMO SUSCRIBIRSE a el, es decir sobre el argumento 'data' de
34
+ * addSubscriber. No confundir con el 'schema' que un provider exporta desde su back.js, que
35
+ * describe la configuracion del propio provider (configure/configRouter).
36
+ *
37
+ * La consume provider-debug para explicarle al usuario que escribir, pero cualquier canal que
38
+ * ofrezca elegir provider puede usarla.
39
+ */
40
+ export interface IProviderSubscriptionHelp {
41
+ /** Como se usa, en prosa: que entrega, que hace falta para recibir algo, gotchas. */
42
+ usage: string;
43
+ /** Payload de ejemplo, listo para pasar tal cual a addSubscriber. */
44
+ example: Record<string, unknown>;
45
+ /** Descripcion campo a campo. Opcional: solo para payloads planos. */
46
+ fields?: IProviderSubscriptionField[];
47
+ }
48
+ /**
49
+ * Un campo de la configuracion del PROPIO provider (no de la suscripcion). Es el contrato comun
50
+ * IConfigFieldDef, el mismo que usan senders, webhooks, idps y logins.
51
+ */
52
+ export type IProviderFieldDef = IConfigFieldDef;
20
53
  /**
21
54
  * Interface that all provider plugins must implement.
22
55
  * Use 'any' for clusterInfo to avoid pulling in kubernetes/docker dependencies.
@@ -34,6 +67,28 @@ export interface IProvider {
34
67
  * de terceros que aun usen la config gestionada por el core.
35
68
  */
36
69
  configure?(config: Record<string, unknown>): void;
70
+ /**
71
+ * Ayuda de suscripcion. OPCIONAL: quien escriba un provider la añade si quiere. Sin ella el
72
+ * consumidor sigue funcionando, simplemente no tiene nada que enseñarle al usuario sobre que
73
+ * payload escribir.
74
+ */
75
+ getSubscriptionHelp?(): IProviderSubscriptionHelp;
76
+ /**
77
+ * Nombres de las configuraciones que el provider tiene definidas (equivalente a
78
+ * ISender.getConfigNames). OPCIONAL: solo tiene sentido en un provider que sea dueño de su
79
+ * configuracion. El gestor de extensiones lo usa para mostrar cuantas hay en la tarjeta, igual
80
+ * que hace con los senders. No expone valores, solo nombres.
81
+ */
82
+ getConfigNames?(): string[];
83
+ /**
84
+ * Schema de configuracion del propio provider, con el que kwirth pinta un formulario generico.
85
+ * Es la forma ESTANDAR de declararlo, la misma que ISender.getConfigSchema e IWebhook.
86
+ *
87
+ * Un provider al que nadie se suscribe y que no expone router NO se instancia nunca, asi que en
88
+ * ese caso no hay a quien preguntarselo: para esos, exporta ademas una constante 'schema' con el
89
+ * mismo array desde el back.js, que el core lee al instalar sin instanciar nada.
90
+ */
91
+ getConfigSchema?(): IProviderFieldDef[];
37
92
  startProvider(): Promise<void>;
38
93
  stopProvider(): Promise<void>;
39
94
  router: any;
package/dist/ISender.d.ts CHANGED
@@ -1,19 +1,12 @@
1
1
  import { ISenderMessage, ISenderConfig, ISenderAccess, ISenderStoredConfig, ISenderResult } from '@kwirthmagnify/kwirth-common';
2
+ import { EConfigFieldType, IConfigFieldDef, IExtensionNodeMeta } from './IExtensionConfig';
2
3
  export { ISenderMessage, ISenderConfig, ISenderAccess, ISenderStoredConfig, ISenderResult };
3
- export type SenderFieldType = 'text' | 'number' | 'boolean' | 'password' | 'select' | 'json';
4
- export interface ISenderFieldDef {
5
- name: string;
6
- label: string;
7
- type?: SenderFieldType;
8
- required?: boolean;
9
- options?: string[];
10
- common?: boolean;
11
- }
12
- export interface ISenderNodeMeta {
13
- label: string;
14
- icon?: string;
15
- description?: string;
16
- }
4
+ /** @deprecated usa EConfigFieldType, comun a todas las extensiones. */
5
+ export type SenderFieldType = EConfigFieldType;
6
+ /** Campo de configuracion de un sender. Es el contrato comun IConfigFieldDef, sin nada propio. */
7
+ export type ISenderFieldDef = IConfigFieldDef;
8
+ /** @deprecated usa IExtensionNodeMeta, comun a todas las extensiones. */
9
+ export type ISenderNodeMeta = IExtensionNodeMeta;
17
10
  export interface ISender {
18
11
  readonly id: string;
19
12
  readonly senderType?: 'filter' | 'output';
@@ -1,19 +1,12 @@
1
1
  import { IWebhookEvent, IWebhookConfig, IWebhookAccess, IWebhookConsumer, IWebhookStoredConfig } from '@kwirthmagnify/kwirth-common';
2
+ import { EConfigFieldType, IConfigFieldDef, IExtensionNodeMeta } from './IExtensionConfig';
2
3
  export { IWebhookEvent, IWebhookConfig, IWebhookAccess, IWebhookConsumer, IWebhookStoredConfig };
3
- export type WebhookFieldType = 'text' | 'number' | 'boolean' | 'password' | 'select' | 'json';
4
- export interface IWebhookFieldDef {
5
- name: string;
6
- label: string;
7
- type?: WebhookFieldType;
8
- required?: boolean;
9
- options?: string[];
10
- common?: boolean;
11
- }
12
- export interface IWebhookNodeMeta {
13
- label: string;
14
- icon?: string;
15
- description?: string;
16
- }
4
+ /** @deprecated usa EConfigFieldType, comun a todas las extensiones. */
5
+ export type WebhookFieldType = EConfigFieldType;
6
+ /** Campo de configuracion de un webhook. Es el contrato comun IConfigFieldDef, sin nada propio. */
7
+ export type IWebhookFieldDef = IConfigFieldDef;
8
+ /** @deprecated usa IExtensionNodeMeta, comun a todas las extensiones. */
9
+ export type IWebhookNodeMeta = IExtensionNodeMeta;
17
10
  export interface IWebhook {
18
11
  readonly id: string;
19
12
  verify(rawBody: Buffer, headers: Record<string, string | string[] | undefined>, config: IWebhookConfig): boolean;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './IExtensionConfig';
1
2
  export * from './IBackChannelObject';
2
3
  export * from './ILogin';
3
4
  export * from './IChannel';
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./IExtensionConfig"), exports);
17
18
  __exportStar(require("./IBackChannelObject"), exports);
18
19
  __exportStar(require("./ILogin"), exports);
19
20
  __exportStar(require("./IChannel"), exports);
package/dist/oauth2.js CHANGED
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.oauth2ConfigSchema = oauth2ConfigSchema;
4
4
  exports.oauth2BuildAuthorizationUrl = oauth2BuildAuthorizationUrl;
5
5
  exports.oauth2HandleCallback = oauth2HandleCallback;
6
+ const IExtensionConfig_1 = require("./IExtensionConfig");
6
7
  // esquema base de un IdP OAuth2 (el conector añade sus URLs si aplica; clientSecret 'password' → se enmascara)
7
8
  function oauth2ConfigSchema() {
8
9
  return [
9
- { name: 'clientId', label: 'Client ID', type: 'text', required: true },
10
- { name: 'clientSecret', label: 'Client Secret', type: 'password', required: true },
11
- { name: 'scopes', label: 'Scopes', type: 'text' }
10
+ { name: 'clientId', label: 'Client ID', type: IExtensionConfig_1.EConfigFieldType.TEXT, required: true },
11
+ { name: 'clientSecret', label: 'Client Secret', type: IExtensionConfig_1.EConfigFieldType.PASSWORD, required: true },
12
+ { name: 'scopes', label: 'Scopes', type: IExtensionConfig_1.EConfigFieldType.TEXT }
12
13
  ];
13
14
  }
14
15
  function oauth2BuildAuthorizationUrl(config, ctx, ep) {
package/dist/oidc.js CHANGED
@@ -4,6 +4,7 @@ exports.oidcConfigSchema = oidcConfigSchema;
4
4
  exports.oidcBuildAuthorizationUrl = oidcBuildAuthorizationUrl;
5
5
  exports.oidcHandleCallback = oidcHandleCallback;
6
6
  const openid_client_1 = require("openid-client");
7
+ const IExtensionConfig_1 = require("./IExtensionConfig");
7
8
  /*
8
9
  Lógica OIDC compartida por todos los conectores OIDC (Google, Keycloak, GitLab, Microsoft, ...).
9
10
  Vive en common-back y el back la expone como global (__kwirth_back__.kwirthCommonBack), de modo
@@ -15,10 +16,10 @@ const openid_client_1 = require("openid-client");
15
16
  // esquema de config estándar de un IdP OIDC (clientSecret es 'password' → se enmascara en la UI)
16
17
  function oidcConfigSchema() {
17
18
  return [
18
- { name: 'clientId', label: 'Client ID', type: 'text', required: true },
19
- { name: 'clientSecret', label: 'Client Secret', type: 'password', required: true },
20
- { name: 'scopes', label: 'Scopes', type: 'text' },
21
- { name: 'issuer', label: 'Issuer URL', type: 'text' }
19
+ { name: 'clientId', label: 'Client ID', type: IExtensionConfig_1.EConfigFieldType.TEXT, required: true },
20
+ { name: 'clientSecret', label: 'Client Secret', type: IExtensionConfig_1.EConfigFieldType.PASSWORD, required: true },
21
+ { name: 'scopes', label: 'Scopes', type: IExtensionConfig_1.EConfigFieldType.TEXT },
22
+ { name: 'issuer', label: 'Issuer URL', type: IExtensionConfig_1.EConfigFieldType.TEXT }
22
23
  ];
23
24
  }
24
25
  async function makeClient(config, redirectUri, defaultIssuer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwirthmagnify/kwirth-common-back",
3
- "version": "0.5.39",
3
+ "version": "0.5.41",
4
4
  "description": "Backend interfaces for building Kwirth provider and channel plugins",
5
5
  "scripts": {
6
6
  "build": "tsc",