@onecx/integration-interface 9.0.0-rc.11 → 9.0.0-rc.13

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/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // libs/integration-interface/src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AiContextGatherer: () => AiContextGatherer,
33
34
  ConfigurationTopic: () => ConfigurationTopic,
34
35
  CurrentLocationTopic: () => CurrentLocationTopic,
35
36
  CurrentMfeTopic: () => CurrentMfeTopic,
@@ -463,6 +464,80 @@ var Topic = class extends TopicPublisher {
463
464
  // libs/accelerator/src/lib/topic/mocks/fake-topic.ts
464
465
  var import_rxjs2 = require("rxjs");
465
466
 
467
+ // libs/accelerator/src/lib/utils/gatherer.ts
468
+ var Gatherer = class _Gatherer {
469
+ logger;
470
+ static id = 0;
471
+ topic;
472
+ ownIds = /* @__PURE__ */ new Set();
473
+ topicSub = null;
474
+ topicName;
475
+ constructor(name, version, callback) {
476
+ this.topicName = name;
477
+ this.logger = createLogger(`Gatherer:${name}`);
478
+ this.logger.debug(`Gatherer ${name}: ${version} created`);
479
+ this.topic = new Topic(name, version, false);
480
+ this.topicSub = this.topic.subscribe((m) => {
481
+ if (!this.isOwnerOfRequest(m) && topicTabId["@onecx/accelerator"].gatherer.promises) {
482
+ this.logReceivedIfDebug(name, version, m);
483
+ if (!topicTabId["@onecx/accelerator"].gatherer.promises[m.id]) {
484
+ this.logger.warn("Expected an array of promises to gather for id ", m.id, " but the id was not present");
485
+ return;
486
+ }
487
+ let resolve;
488
+ topicTabId["@onecx/accelerator"].gatherer.promises[m.id].push(
489
+ new Promise((r) => {
490
+ resolve = r;
491
+ })
492
+ );
493
+ callback(m.request).then((response) => {
494
+ resolve(response);
495
+ this.logAnsweredIfDebug(name, version, m, response);
496
+ });
497
+ }
498
+ });
499
+ }
500
+ destroy() {
501
+ this.logger.debug(`Gatherer ${this.topic.name}: ${this.topic.version} destroyed`);
502
+ this.topicSub?.unsubscribe();
503
+ this.topic.destroy();
504
+ for (const id of this.ownIds) {
505
+ if (topicTabId["@onecx/accelerator"].gatherer.promises?.[id]) {
506
+ delete topicTabId["@onecx/accelerator"].gatherer.promises[id];
507
+ }
508
+ }
509
+ }
510
+ async gather(request) {
511
+ if (!topicTabId["@onecx/accelerator"].gatherer?.promises) {
512
+ throw new Error("Gatherer is not initialized");
513
+ }
514
+ const id = _Gatherer.id++;
515
+ this.ownIds.add(id);
516
+ topicTabId["@onecx/accelerator"].gatherer.promises[id] = [];
517
+ const message = { id, request };
518
+ await this.topic.publish(message);
519
+ const promises = topicTabId["@onecx/accelerator"].gatherer.promises[id];
520
+ delete topicTabId["@onecx/accelerator"].gatherer.promises[id];
521
+ this.ownIds.delete(id);
522
+ return Promise.all(promises).then((v) => {
523
+ this.logger.debug("Finished gathering responses", v);
524
+ return v;
525
+ });
526
+ }
527
+ logReceivedIfDebug(name, version, m) {
528
+ this.logger.debug("Gatherer " + name + ": " + version + " received request " + m.request);
529
+ }
530
+ logAnsweredIfDebug(name, version, m, response) {
531
+ this.logger.debug(
532
+ "Gatherer " + name + ": " + version + " answered request " + m.request + " with response",
533
+ response
534
+ );
535
+ }
536
+ isOwnerOfRequest(m) {
537
+ return this.ownIds.has(m.id);
538
+ }
539
+ };
540
+
466
541
  // libs/integration-interface/src/lib/topics/current-mfe/v1/current-mfe.topic.ts
467
542
  var CurrentMfeTopic = class extends Topic {
468
543
  constructor() {
@@ -1361,3 +1436,10 @@ var NotificationService = class {
1361
1436
  this.notificationTopic.destroy();
1362
1437
  }
1363
1438
  };
1439
+
1440
+ // libs/integration-interface/src/lib/gatherers/ai-context/v1/ai-context.gatherer.ts
1441
+ var AiContextGatherer = class extends Gatherer {
1442
+ constructor(callback) {
1443
+ super("aiContext", 1, callback);
1444
+ }
1445
+ };
package/dist/index.mjs CHANGED
@@ -372,6 +372,80 @@ var Topic = class extends TopicPublisher {
372
372
  // libs/accelerator/src/lib/topic/mocks/fake-topic.ts
373
373
  import { BehaviorSubject as BehaviorSubject2, ReplaySubject } from "rxjs";
374
374
 
375
+ // libs/accelerator/src/lib/utils/gatherer.ts
376
+ var Gatherer = class _Gatherer {
377
+ logger;
378
+ static id = 0;
379
+ topic;
380
+ ownIds = /* @__PURE__ */ new Set();
381
+ topicSub = null;
382
+ topicName;
383
+ constructor(name, version, callback) {
384
+ this.topicName = name;
385
+ this.logger = createLogger(`Gatherer:${name}`);
386
+ this.logger.debug(`Gatherer ${name}: ${version} created`);
387
+ this.topic = new Topic(name, version, false);
388
+ this.topicSub = this.topic.subscribe((m) => {
389
+ if (!this.isOwnerOfRequest(m) && topicTabId["@onecx/accelerator"].gatherer.promises) {
390
+ this.logReceivedIfDebug(name, version, m);
391
+ if (!topicTabId["@onecx/accelerator"].gatherer.promises[m.id]) {
392
+ this.logger.warn("Expected an array of promises to gather for id ", m.id, " but the id was not present");
393
+ return;
394
+ }
395
+ let resolve;
396
+ topicTabId["@onecx/accelerator"].gatherer.promises[m.id].push(
397
+ new Promise((r) => {
398
+ resolve = r;
399
+ })
400
+ );
401
+ callback(m.request).then((response) => {
402
+ resolve(response);
403
+ this.logAnsweredIfDebug(name, version, m, response);
404
+ });
405
+ }
406
+ });
407
+ }
408
+ destroy() {
409
+ this.logger.debug(`Gatherer ${this.topic.name}: ${this.topic.version} destroyed`);
410
+ this.topicSub?.unsubscribe();
411
+ this.topic.destroy();
412
+ for (const id of this.ownIds) {
413
+ if (topicTabId["@onecx/accelerator"].gatherer.promises?.[id]) {
414
+ delete topicTabId["@onecx/accelerator"].gatherer.promises[id];
415
+ }
416
+ }
417
+ }
418
+ async gather(request) {
419
+ if (!topicTabId["@onecx/accelerator"].gatherer?.promises) {
420
+ throw new Error("Gatherer is not initialized");
421
+ }
422
+ const id = _Gatherer.id++;
423
+ this.ownIds.add(id);
424
+ topicTabId["@onecx/accelerator"].gatherer.promises[id] = [];
425
+ const message = { id, request };
426
+ await this.topic.publish(message);
427
+ const promises = topicTabId["@onecx/accelerator"].gatherer.promises[id];
428
+ delete topicTabId["@onecx/accelerator"].gatherer.promises[id];
429
+ this.ownIds.delete(id);
430
+ return Promise.all(promises).then((v) => {
431
+ this.logger.debug("Finished gathering responses", v);
432
+ return v;
433
+ });
434
+ }
435
+ logReceivedIfDebug(name, version, m) {
436
+ this.logger.debug("Gatherer " + name + ": " + version + " received request " + m.request);
437
+ }
438
+ logAnsweredIfDebug(name, version, m, response) {
439
+ this.logger.debug(
440
+ "Gatherer " + name + ": " + version + " answered request " + m.request + " with response",
441
+ response
442
+ );
443
+ }
444
+ isOwnerOfRequest(m) {
445
+ return this.ownIds.has(m.id);
446
+ }
447
+ };
448
+
375
449
  // libs/integration-interface/src/lib/topics/current-mfe/v1/current-mfe.topic.ts
376
450
  var CurrentMfeTopic = class extends Topic {
377
451
  constructor() {
@@ -1270,7 +1344,15 @@ var NotificationService = class {
1270
1344
  this.notificationTopic.destroy();
1271
1345
  }
1272
1346
  };
1347
+
1348
+ // libs/integration-interface/src/lib/gatherers/ai-context/v1/ai-context.gatherer.ts
1349
+ var AiContextGatherer = class extends Gatherer {
1350
+ constructor(callback) {
1351
+ super("aiContext", 1, callback);
1352
+ }
1353
+ };
1273
1354
  export {
1355
+ AiContextGatherer,
1274
1356
  ConfigurationTopic,
1275
1357
  CurrentLocationTopic,
1276
1358
  CurrentMfeTopic,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onecx/integration-interface",
3
- "version": "9.0.0-rc.11",
3
+ "version": "9.0.0-rc.13",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "peerDependencies": {
10
10
  "rxjs": "^7.8.1",
11
- "@onecx/accelerator": "^9.0.0-rc.11"
11
+ "@onecx/accelerator": "^9.0.0-rc.13"
12
12
  },
13
13
  "type": "module",
14
14
  "dependencies": {
package/src/index.d.ts CHANGED
@@ -59,3 +59,5 @@ export * from './lib/utils/portal-message.utils';
59
59
  export * from './lib/topics/notification/v1/notification.model';
60
60
  export * from './lib/topics/notification/v1/notification.topic';
61
61
  export * from './lib/services/notification.service';
62
+ export * from './lib/gatherers/ai-context/v1/ai-context.model';
63
+ export * from './lib/gatherers/ai-context/v1/ai-context.gatherer';
package/src/index.js CHANGED
@@ -59,4 +59,6 @@ export * from './lib/utils/portal-message.utils';
59
59
  export * from './lib/topics/notification/v1/notification.model';
60
60
  export * from './lib/topics/notification/v1/notification.topic';
61
61
  export * from './lib/services/notification.service';
62
+ export * from './lib/gatherers/ai-context/v1/ai-context.model';
63
+ export * from './lib/gatherers/ai-context/v1/ai-context.gatherer';
62
64
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/integration-interface/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAA;AAC7D,cAAc,4CAA4C,CAAA;AAC1D,cAAc,iDAAiD,CAAA;AAC/D,cAAc,8CAA8C,CAAA;AAE5D,cAAc,iDAAiD,CAAA;AAE/D,cAAc,qDAAqD,CAAA;AAEnE,cAAc,mDAAmD,CAAA;AACjE,cAAc,2CAA2C,CAAA;AACzD,cAAc,oDAAoD,CAAA;AAElE,cAAc,iDAAiD,CAAA;AAC/D,cAAc,iDAAiD,CAAA;AAE/D,cAAc,mDAAmD,CAAA;AAEjE,cAAc,2DAA2D,CAAA;AACzE,cAAc,iEAAiE,CAAA;AAC/E,cAAc,mDAAmD,CAAA;AACjE,cAAc,+CAA+C,CAAA;AAC7D,cAAc,kDAAkD,CAAA;AAEhE,cAAc,wDAAwD,CAAA;AAEtE,cAAc,uCAAuC,CAAA;AACrD,cAAc,uCAAuC,CAAA;AAErD,cAAc,0DAA0D,CAAA;AACxE,cAAc,gEAAgE,CAAA;AAC9E,cAAc,8CAA8C,CA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CAAA;AAE/E,cAAc,4CAA4C,CAAA;AAE1D,cAAc,qCAAqC,CAAA;AACnD,cAAc,oCAAoC,CAAA;AAClD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,kCAAkC,CAAA;AAEhD,cAAc,iDAAiD,CAAA;AAC/D,cAAc,iDAAiD,CAAA;AAC/D,cAAc,qCAAqC,CAAA;AAEnD,cAAc,gDAAgD,CAAA;AAC9D,cAAc,mDAAmD,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { Gatherer } from "@onecx/accelerator";
2
+ import type { AiContextRequest, AiContextResponse } from "./ai-context.model";
3
+ /**
4
+ * This class can be used to provide a context for AI-specific features.
5
+ * It allows gathering information about all applications, products, and contexts in which the AI is being used.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ *
10
+ * // add a gatherer to the constructor of the page component that should provide AI context information
11
+ * // in ngOnDestroy, call the gatherer.destroy() method to clean up resources
12
+ *
13
+ * const aiContextGatherer = new AiContextGatherer(async (request) => {
14
+ * // decide if your app whats to contribute to the AI context or not
15
+ * // if you do not want to contribute, return null
16
+ * // if you want to contribute, return an AiContextResponse object
17
+ * });
18
+ * ```
19
+ */
20
+ export declare class AiContextGatherer extends Gatherer<AiContextRequest, AiContextResponse | null> {
21
+ constructor(callback: (request: AiContextRequest) => Promise<AiContextResponse | null>);
22
+ }
@@ -0,0 +1,24 @@
1
+ import { Gatherer } from "@onecx/accelerator";
2
+ /**
3
+ * This class can be used to provide a context for AI-specific features.
4
+ * It allows gathering information about all applications, products, and contexts in which the AI is being used.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ *
9
+ * // add a gatherer to the constructor of the page component that should provide AI context information
10
+ * // in ngOnDestroy, call the gatherer.destroy() method to clean up resources
11
+ *
12
+ * const aiContextGatherer = new AiContextGatherer(async (request) => {
13
+ * // decide if your app whats to contribute to the AI context or not
14
+ * // if you do not want to contribute, return null
15
+ * // if you want to contribute, return an AiContextResponse object
16
+ * });
17
+ * ```
18
+ */
19
+ export class AiContextGatherer extends Gatherer {
20
+ constructor(callback) {
21
+ super("aiContext", 1, callback);
22
+ }
23
+ }
24
+ //# sourceMappingURL=ai-context.gatherer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-context.gatherer.js","sourceRoot":"","sources":["../../../../../../../../libs/integration-interface/src/lib/gatherers/ai-context/v1/ai-context.gatherer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAI7C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,iBAAkB,SAAQ,QAAoD;IAEvF,YAAY,QAA0E;QAClF,KAAK,CAAC,WAAW,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;IACnC,CAAC;CACJ"}
@@ -0,0 +1,11 @@
1
+ export interface AiContextRequest {
2
+ agent: {
3
+ name: string;
4
+ };
5
+ }
6
+ export interface AiContextResponse {
7
+ productName: string;
8
+ appId: string;
9
+ appPath: string;
10
+ context: string;
11
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ai-context.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-context.model.js","sourceRoot":"","sources":["../../../../../../../../libs/integration-interface/src/lib/gatherers/ai-context/v1/ai-context.model.ts"],"names":[],"mappings":""}
package/src/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const LIB_NAME = "@onecx/integration-interface";
2
- export declare const LIB_VERSION = "9.0.0-rc.11";
2
+ export declare const LIB_VERSION = "9.0.0-rc.13";
package/src/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export const LIB_NAME = '@onecx/integration-interface';
2
- export const LIB_VERSION = '9.0.0-rc.11';
2
+ export const LIB_VERSION = '9.0.0-rc.13';
3
3
  //# sourceMappingURL=version.js.map