@kwirthmagnify/kwirth-common-back 0.5.51 → 0.5.53

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.
@@ -1,4 +1,22 @@
1
1
  import { IExtensionExportOptions, IExtensionImportResult } from '@kwirthmagnify/kwirth-common';
2
+ /**
3
+ * What an extension writes its log with. The core builds it knowing who the extension is, so the
4
+ * line comes out identified — '[prov] [ERRO] [longhorn] ...' — and the extension only writes the
5
+ * message.
6
+ *
7
+ * It lives here, and not next to one family's contract, because the need is the same for all of
8
+ * them: before this, anything that was not a channel had only `console.log`, which comes out with no
9
+ * timestamp, no level and no component, and turns a failure into something that reads like a routine
10
+ * trace.
11
+ *
12
+ * Three levels and no more. An `info` nobody can filter out is what buries a log, and a failure that
13
+ * goes out as `info` is a failure nobody sees.
14
+ */
15
+ export interface IExtensionLogger {
16
+ info(message: unknown): void;
17
+ warning(message: unknown): void;
18
+ error(message: unknown): void;
19
+ }
2
20
  export interface IExtension {
3
21
  exportConfig?(options: IExtensionExportOptions): Promise<unknown>;
4
22
  importConfig?(config: unknown): Promise<IExtensionImportResult>;
@@ -1,5 +1,5 @@
1
1
  import { KwirthData, IConfigFieldDef } from '@kwirthmagnify/kwirth-common';
2
- import { IExtension } from './IExtension';
2
+ import { IExtension, IExtensionLogger } from './IExtension';
3
3
  /**
4
4
  * Minimal interface representing the channel side that providers interact with.
5
5
  * Providers only need to call processProviderEvent on their subscribers.
@@ -7,6 +7,38 @@ import { IExtension } from './IExtension';
7
7
  export interface IProviderSubscriber {
8
8
  processProviderEvent(providerId: string, obj: any): void;
9
9
  }
10
+ /**
11
+ * How a channel subscribes to a producer. The core hands one of these out already bound to the two
12
+ * ends — the producer and the channel asking for it — with 'clusterInfo.getProvider(id, this)'.
13
+ *
14
+ * It exists because a channel used to receive the provider OBJECT and call 'addSubscriber' on it,
15
+ * which meant the core could be bypassed without doing anything wrong, and therefore that its
16
+ * registry of who consumes what — the one the status graph is drawn from — was incomplete by
17
+ * construction. Going through the handle is what makes that registry true.
18
+ *
19
+ * ⚠️ The handle is NOT in the path of the data. It hands the provider the very same subscriber it
20
+ * was given, so events still travel straight from the producer to the consumer: no wrapper, no extra
21
+ * call, nothing per event. What runs is two functions per SUBSCRIPTION, which happens once when a tab
22
+ * opens. That is the whole reason it is shaped like this.
23
+ *
24
+ * One subscription per handle call, so a channel serving several instances subscribes once per
25
+ * instance with its own subscriber, and each one is unsubscribed on its own. The edge in the graph
26
+ * survives until the last of them is gone.
27
+ */
28
+ export interface IProviderHandle {
29
+ /** Who produces: a provider ('events') or a pluvider ('plugin:agora'). */
30
+ readonly id: string;
31
+ /**
32
+ * Returns whatever the producer returned — normally a promise. It is handed back instead of
33
+ * swallowed because a provider that fails while taking a subscriber on board leaves an unhandled
34
+ * rejection, and that takes the whole core down. A consumer that wants to survive third-party
35
+ * providers wraps this in Promise.resolve().catch(); one that does not care ignores it.
36
+ */
37
+ subscribe(subscriber: IProviderSubscriber, data?: any): unknown;
38
+ /** Changes what this subscriber wants. Providers may not implement it; then nothing happens. */
39
+ updateSubscription(subscriber: IProviderSubscriber, data?: any): unknown;
40
+ unsubscribe(subscriber: IProviderSubscriber): unknown;
41
+ }
10
42
  /**
11
43
  * Persistencia que el core inyecta al provider (mismo mecanismo que reciben los canales).
12
44
  * El booleano 'secret' decide el destino: true -> Secret de Kubernetes, false -> ConfigMap.
@@ -86,6 +118,12 @@ export interface IProviderStats {
86
118
  /** Errores al entregar, con el mismo criterio: acumulado y barato. */
87
119
  errors?: number;
88
120
  }
121
+ /**
122
+ * What a provider writes its log with. It is the common extension logger — the need turned out to be
123
+ * the same for senders, so it lives in IExtension. Kept as a name of its own because it is already
124
+ * published and providers compile against it.
125
+ */
126
+ export type IProviderLogger = IExtensionLogger;
89
127
  /**
90
128
  * Interface that all provider plugins must implement.
91
129
  * Use 'any' for clusterInfo to avoid pulling in kubernetes/docker dependencies.
@@ -135,6 +173,20 @@ export interface IProvider extends IExtension {
135
173
  * estructuras aqui convierte una consulta en trabajo para todos.
136
174
  */
137
175
  getStats?(): IProviderStats;
176
+ /**
177
+ * The core hands the provider a logger that already knows who it is, right after building it.
178
+ *
179
+ * OPTIONAL, like everything in this block: a provider that does not implement it keeps writing
180
+ * wherever it was writing, and an older core that never calls it leaves the provider on its own
181
+ * fallback. Neither side needs the other to be up to date.
182
+ *
183
+ * Why it exists: channels get a 'backChannelObject' to log with, providers got nothing, so the
184
+ * only thing left to them was 'console.log'. That comes out with no timestamp, no level and no
185
+ * component — an error from a provider looks exactly like an informational line, and nothing can
186
+ * be filtered. With this, a provider's line reads '[provider] [ERROR] [longhorn] ...' and the
187
+ * provider does not even have to write its own id: the core puts it there.
188
+ */
189
+ setLogger?(logger: IProviderLogger): void;
138
190
  startProvider(): Promise<void>;
139
191
  stopProvider(): Promise<void>;
140
192
  router: any;
package/dist/ISender.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ISenderMessage, ISenderConfig, ISenderAccess, ISenderStoredConfig, ISenderResult, TConfigFieldType, IConfigFieldDef, IExtensionNodeMeta } from '@kwirthmagnify/kwirth-common';
2
- import { IExtension } from './IExtension';
2
+ import { IExtension, IExtensionLogger } from './IExtension';
3
3
  export { ISenderMessage, ISenderConfig, ISenderAccess, ISenderStoredConfig, ISenderResult };
4
4
  /** @deprecated usa TConfigFieldType, comun a todas las extensiones. */
5
5
  export type SenderFieldType = TConfigFieldType;
@@ -17,6 +17,18 @@ export interface ISender extends IExtension {
17
17
  getConfigSchema?(): ISenderFieldDef[];
18
18
  getNodeMeta?(): ISenderNodeMeta;
19
19
  send(configName: string, message: ISenderMessage): Promise<ISenderResult | void>;
20
+ /**
21
+ * The core hands the sender a logger that already knows who it is, as soon as it builds it.
22
+ *
23
+ * OPTIONAL and read defensively, like the rest: a sender that does not implement it keeps writing
24
+ * wherever it was writing, and an older core that never calls it leaves the sender on its own
25
+ * fallback.
26
+ *
27
+ * ⚠️ This is for what the sender says ABOUT ITSELF — a delivery that failed, a configuration it
28
+ * could not read. It is not the place for what it delivers: a sender's job is to put a message
29
+ * somewhere, and that somewhere is decided by its configuration, not by this.
30
+ */
31
+ setLogger?(logger: IExtensionLogger): void;
20
32
  sendBatch?(configName: string, messages: ISenderMessage[]): Promise<ISenderResult | void>;
21
33
  fetchStatus?(configName: string, externalId: string): Promise<string | undefined>;
22
34
  evalFilter?(configName: string, message: ISenderMessage, forward: () => Promise<void>): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwirthmagnify/kwirth-common-back",
3
- "version": "0.5.51",
3
+ "version": "0.5.53",
4
4
  "description": "Backend interfaces for building Kwirth provider and channel plugins",
5
5
  "scripts": {
6
6
  "build": "tsc",