@antcde/connect-ts 0.4.17-rc.9b29378 → 0.4.17-rc.c0e281b

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 (43) hide show
  1. package/README.md +98 -0
  2. package/build/AntConnect.d.ts.map +1 -1
  3. package/build/AntConnect.js +8 -6
  4. package/build/AntHttpClient.js +24 -49
  5. package/build/comms/client.d.ts +4 -1
  6. package/build/comms/client.d.ts.map +1 -1
  7. package/build/comms/client.js +10 -23
  8. package/build/comms/host.d.ts +4 -1
  9. package/build/comms/host.d.ts.map +1 -1
  10. package/build/comms/host.js +25 -27
  11. package/build/comms/recordServiceCalls.js +6 -15
  12. package/build/comms/signal.d.ts +40 -1
  13. package/build/comms/signal.d.ts.map +1 -1
  14. package/build/comms/signal.js +5 -3
  15. package/build/comms/utils.js +6 -15
  16. package/build/index.d.ts +3 -3
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +1 -1
  19. package/build/services/AppService.d.ts +58 -0
  20. package/build/services/AppService.d.ts.map +1 -1
  21. package/build/services/DmsService.js +5 -5
  22. package/build/services/LabelService.js +6 -1
  23. package/build/services/RecordService.js +7 -3
  24. package/build/services/ReleaseService.js +1 -1
  25. package/build/services/SbsService.js +8 -2
  26. package/build/services/ScriptsService.d.ts.map +1 -1
  27. package/build/services/ScriptsService.js +4 -3
  28. package/build/services/TableService.d.ts +5 -2
  29. package/build/services/TableService.d.ts.map +1 -1
  30. package/build/services/TableService.js +10 -2
  31. package/build/services/TaskQueryService.js +1 -1
  32. package/build/services/TaskService.d.ts +4 -4
  33. package/build/services/TaskService.d.ts.map +1 -1
  34. package/build/services/TaskService.js +2 -2
  35. package/build/services/TaskServiceQueries.d.ts +3 -3
  36. package/build/services/TaskServiceQueries.d.ts.map +1 -1
  37. package/build/services/TokenService.js +5 -15
  38. package/build/services/WorkflowService.d.ts +5 -3
  39. package/build/services/WorkflowService.d.ts.map +1 -1
  40. package/build/services/WorkflowService.js +21 -20
  41. package/package.json +12 -10
  42. package/schemas/app-config.schema.json +165 -0
  43. package/build/tsconfig.esm.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -566,6 +566,104 @@ const query = qs.stringify(params, {
566
566
 
567
567
  ---
568
568
 
569
+ ## App Manifest (`app-config.json`)
570
+
571
+ Every ANT app can ship an `app-config.json` in its distribution bundle. The OS and App Store read this file to discover what the app declares about itself: its version, tagline, tables, and signal topics.
572
+
573
+ ### Schema validation
574
+
575
+ A JSON Schema is published with this package at `schemas/app-config.schema.json`. Point the `$schema` key at it for editor autocompletion, hover docs, and validation:
576
+
577
+ ```json
578
+ {
579
+ "$schema": "node_modules/@antcde/connect-ts/schemas/app-config.schema.json",
580
+ "version": "1.0.0",
581
+ "tagline": "My App",
582
+ "tables": [],
583
+ "signals": {
584
+ "topics": {}
585
+ }
586
+ }
587
+ ```
588
+
589
+ ### Sending the manifest to the OS
590
+
591
+ Apps can send their manifest to the OS during the comms handshake. This makes tables and topics visible in the OS context menu without an extra API call, and works across CORS boundaries (e.g. remote OS + local dev server).
592
+
593
+ ```typescript
594
+ import { useCommsClient } from '@antcde/vue-utils'
595
+ import manifest from '../app-config.json'
596
+
597
+ const comms = useCommsClient(connect, undefined, manifest)
598
+ ```
599
+
600
+ The OS receives the manifest via the handshake ACK and exposes it on the comms host. Any app that passes a manifest will appear in the OS context menu with its declared tables and topics.
601
+
602
+ ### Tables
603
+
604
+ Tables are created in the project when the app is installed. Each entry declares a table name and its columns:
605
+
606
+ ```json
607
+ {
608
+ "tables": [
609
+ {
610
+ "name": "MY_APP_ITEMS",
611
+ "master_table": true,
612
+ "columns": [
613
+ { "name": "title", "type": "text", "required": true },
614
+ { "name": "status", "type": "dropdown", "options_value": ["draft", "active"] }
615
+ ]
616
+ }
617
+ ]
618
+ }
619
+ ```
620
+
621
+ Column types: `integer`, `text`, `text-field`, `boolean`, `date`, `link`, `email`, `dropdown`, `document`, `float`, `sbscode`, `table`.
622
+
623
+ ### Topic declarations
624
+
625
+ Topics enable generic pub/sub between apps via Echo whisper channels. Each key under `signals.topics` is a topic name (must match `[A-Za-z0-9_-]`):
626
+
627
+ ```json
628
+ {
629
+ "signals": {
630
+ "topics": {
631
+ "cursor-positions": {
632
+ "scope": "project",
633
+ "description": "Live cursor positions shared between editors",
634
+ "direction": ["send", "receive"],
635
+ "schema": { "type": "object" }
636
+ }
637
+ }
638
+ }
639
+ }
640
+ ```
641
+
642
+ | Field | Required | Description |
643
+ |-------------|----------|--------------------------------------------------------|
644
+ | `scope` | no | `"project"` (default) or `"license"` |
645
+ | `description` | no | Human-readable summary shown in the App Store |
646
+ | `direction` | no | Array of `"send"` and/or `"receive"`. Defaults to `["receive"]` |
647
+ | `schema` | no | JSON Schema describing the payload shape |
648
+
649
+ ### Sending and receiving topics
650
+
651
+ ```typescript
652
+ // publish
653
+ signal.send({ topic: { name: 'cursor-positions', data: { x: 10, y: 20 } } })
654
+
655
+ // subscribe
656
+ signal.receive((s) => {
657
+ if (s.topic?.name === 'cursor-positions') {
658
+ handleCursor(s.topic.data)
659
+ }
660
+ })
661
+ ```
662
+
663
+ The OS handles fan-out: when an app publishes a topic signal, the OS redistributes it to all other loaded apps and whispers it on the scoped Echo channel so apps in other browser tabs receive it too.
664
+
665
+ ---
666
+
569
667
  ## Resource Signals
570
668
 
571
669
  Arbitrary resource signals let apps send and receive domain-specific events (e.g., `cat`, `homeowner`, `invoice`) without modifying the core `ChangeSignal` types. Signals are distributed locally across split-screen apps and can optionally be backed by WebSocket (Echo) for backend-driven events.
@@ -1 +1 @@
1
- {"version":3,"file":"AntConnect.d.ts","sourceRoot":"","sources":["../src/AntConnect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,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AgB,sBAAsB,CAAC,UAAU,EAAE,aAAa,GAAG,iBAAiB,CAsBnF;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,EAAE,YAAY,CAAC,CAAA;AAEjH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,CAAC,CAAA;AAE1F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,CAAC,GAAG,iBAAiB,EAAE,EAAE,UAAU,CAAC,GAAG,UAAU,CAE1F;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAU7E"}
@@ -72,9 +72,9 @@ export function newAntConnect(httpClient) {
72
72
  export function newCommunityAntConnect(httpClient) {
73
73
  const antConnect = newAntConnect(httpClient);
74
74
  const pick = (service, calls) => {
75
- return !calls.length
75
+ return !calls?.length
76
76
  ? { [service]: antConnect[service] }
77
- : (calls !== null && calls !== void 0 ? calls : []).reduce((connect, call) => Object.assign(connect, { [service]: { [call]: antConnect[service][call] } }), {});
77
+ : (calls ?? []).reduce((connect, call) => Object.assign(connect, { [service]: { [call]: antConnect[service][call] } }), {});
78
78
  };
79
79
  return Object.assign(pick('projects', ['getProjects', 'getProject', 'createProject', 'updateProject', 'addProjectToFavorites', 'deleteProject', 'getProjectImage']), pick('tables', ['getTables', 'createTable', 'getTable', 'updateTable', 'deleteTable', 'clearTable', 'queryTables']), pick('columns', ['getColumns', 'createColumn', 'getColumn', 'updateColumn', 'deleteColumn']), pick('records', ['createRecord', 'deleteRecord', 'importRecords', 'updateRecord', 'getRecordHistory', 'getRecordDocument']), // relations are not available?
80
80
  pick('sbs', ['allSbs', 'createSbs', 'updateSbs', 'deleteSbs']), pick('tasks'));
@@ -83,11 +83,13 @@ export function newAntConnectChain(input) {
83
83
  return newChain(input);
84
84
  }
85
85
  export function newChain(input) {
86
- return new Proxy(input[input.length - 1], {
86
+ return new Proxy(input.at(-1), {
87
87
  get(target, key) {
88
- return typeof target[key] === 'object'
89
- ? newChain(input.map(e => e[key]).filter(e => typeof e === 'object'))
90
- : input.map(e => e[key]).find(e => typeof e !== 'undefined');
88
+ const t = target;
89
+ const items = input;
90
+ return typeof t[key] === 'object'
91
+ ? newChain(items.map(e => e[key]).filter(e => typeof e === 'object'))
92
+ : items.map(e => e[key]).find(e => typeof e !== 'undefined');
91
93
  },
92
94
  });
93
95
  }
@@ -1,17 +1,8 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import axios from 'axios';
11
2
  export function newAntHttpClient({ baseUrl, apiUrl, scope, token }) {
12
- const httpClient = new AntHttpClient(baseUrl !== null && baseUrl !== void 0 ? baseUrl : 'https://api.alpha.antcde.io', apiUrl !== null && apiUrl !== void 0 ? apiUrl : '/api/2.0', scope);
3
+ const httpClient = new AntHttpClient(baseUrl ?? 'https://api.alpha.antcde.io', apiUrl ?? '/api/2.0', scope);
13
4
  if (token) {
14
- httpClient.getInterceptorsManager().request.use(config => Object.assign({}, config, { headers: Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${token}` }) }));
5
+ httpClient.getInterceptorsManager().request.use(config => Object.assign({}, config, { headers: { ...config.headers, Authorization: `Bearer ${token}` } }));
15
6
  }
16
7
  return httpClient;
17
8
  }
@@ -19,7 +10,7 @@ export class AntHttpClient {
19
10
  constructor(baseUrl, apiUrl, scope = new AbortController()) {
20
11
  this.baseUrl = baseUrl;
21
12
  this.scope = scope;
22
- this.http = axios.create(Object.assign({ baseURL: baseUrl + apiUrl }, scope));
13
+ this.http = axios.create({ baseURL: baseUrl + apiUrl, ...scope });
23
14
  this.http.defaults.headers.common.Accept = 'application/json';
24
15
  }
25
16
  getInterceptorsManager() {
@@ -28,51 +19,35 @@ export class AntHttpClient {
28
19
  getBaseUrl() {
29
20
  return this.baseUrl;
30
21
  }
31
- download(url, config) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return this.http.get(url, Object.assign(Object.assign({}, config), this.scope));
34
- });
22
+ async download(url, config) {
23
+ return this.http.get(url, { ...config, ...this.scope });
35
24
  }
36
- downloadFile(url, config) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- return this.http
39
- .get(url, Object.assign(Object.assign(Object.assign({}, this.scope), config), { responseType: 'blob' }))
40
- .then(r => r.data);
41
- });
25
+ async downloadFile(url, config) {
26
+ return this.http
27
+ .get(url, { ...this.scope, ...config, responseType: 'blob' })
28
+ .then(r => r.data);
42
29
  }
43
30
  // FIXME: Not see any value to save interceptors on our side instead of give client possibility
44
31
  // to use axios flows by default.
45
- get(url, config) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- return this.http.get(url, Object.assign(Object.assign({}, this.scope), config)).then(r => r.data);
48
- });
32
+ async get(url, config) {
33
+ return this.http.get(url, { ...this.scope, ...config }).then(r => r.data);
49
34
  }
50
- post(url, data, config) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- return this.http.post(url, data, Object.assign(Object.assign({}, this.scope), config)).then(r => r.data);
53
- });
35
+ async post(url, data, config) {
36
+ return this.http.post(url, data, { ...this.scope, ...config }).then(r => r.data);
54
37
  }
55
- put(url, data, config) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- return this.http.put(url, data, Object.assign(Object.assign({}, this.scope), config)).then(r => r.data);
58
- });
38
+ async put(url, data, config) {
39
+ return this.http.put(url, data, { ...this.scope, ...config }).then(r => r.data);
59
40
  }
60
- delete(url, config) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- return this.http.delete(url, Object.assign(Object.assign({}, this.scope), config)).then(r => r.data);
63
- });
41
+ async delete(url, config) {
42
+ return this.http.delete(url, { ...this.scope, ...config }).then(r => r.data);
64
43
  }
65
- patch(url, data, config) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- return this.http.patch(url, data, Object.assign(Object.assign({}, this.scope), config)).then(r => r.data);
68
- });
44
+ async patch(url, data, config) {
45
+ return this.http.patch(url, data, { ...this.scope, ...config }).then(r => r.data);
69
46
  }
70
- authenticate(userData, client_id, client_secret) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- return this.http
73
- .post('/oauth/token', Object.assign(Object.assign({}, userData), { client_id, client_secret, grant_type: 'password' }), Object.assign({ baseURL: this.baseUrl }, this.scope))
74
- .then(e => e.data);
75
- });
47
+ async authenticate(userData, client_id, client_secret) {
48
+ return this.http
49
+ .post('/oauth/token', { ...userData, client_id, client_secret, grant_type: 'password' }, { baseURL: this.baseUrl, ...this.scope })
50
+ .then(e => e.data);
76
51
  }
77
52
  params(values, prefix) {
78
53
  const encode = encodeURIComponent;
@@ -80,7 +55,7 @@ export class AntHttpClient {
80
55
  return values
81
56
  .map((v, k) => isComplex(v)
82
57
  ? this.params(v, prefix ? `${prefix}[${k}]` : `[${k}]`)
83
- : `${encode(`${prefix !== null && prefix !== void 0 ? prefix : ''}[${k}]`)}=${encode(v)}`)
58
+ : `${encode(`${prefix ?? ''}[${k}]`)}=${encode(v)}`)
84
59
  .join('&');
85
60
  }
86
61
  else {
@@ -1,13 +1,16 @@
1
1
  import type { AxiosRequestConfig } from 'axios';
2
2
  import type { Observable } from 'rxjs';
3
+ import type { AppManifest } from "../services/AppService";
3
4
  import type { Context, Notepad, Notifications, Toolbar } from './models';
4
5
  import type { SignalReceiver, SignalSender } from './signal';
5
6
  import type { Scope } from './utils';
6
7
  import type { AntConnect } from "../AntConnect";
7
8
  import { Subscription } from 'rxjs';
8
- interface ClientParams {
9
+ export interface ClientParams {
9
10
  parent: Window;
10
11
  connect?: AntConnect;
12
+ /** Optional app manifest (app-config.json) sent to the host during handshake. */
13
+ manifest?: AppManifest;
11
14
  }
12
15
  interface Box {
13
16
  clientIdChanges: Observable<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/comms/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,KAAK,EAAgB,KAAK,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAoB;AAE9C,OAAO,EAYL,YAAY,EAIb,MAAM,MAAM,CAAA;AAKb,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB;AAED,UAAU,GAAG;IACX,eAAe,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IACnC,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,KAAK,iBAAiB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AACvE,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,IAAI,C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,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,KAAK,IAAI,CAAA;QACpE,GAAG,EAAE,MAAM,OAAO,CAAA;KACnB,CAAA;IACD,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG;QAC7B,GAAG,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;QAC1B,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KACtC,CAAA;IACD,MAAM,EAAE,YAAY,GAAG,cAAc,CAAA;IACrC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;CACtF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAgE3D;AA4ED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,GAAG,GAAG,OAAO,CAe3E;AAED,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,iBAevE"}
@@ -1,19 +1,9 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { send } from 'post-robot';
11
2
  import { BehaviorSubject, combineLatest, concatMap, filter, first, firstValueFrom, identity, map, merge, share, shareReplay, Subscription, switchMap, take, tap, } from 'rxjs';
12
3
  import { notificationTypes } from './models';
13
4
  import { newSignaler } from './signal';
14
5
  import { clone, newId, newScope, takeUntilClosed } from './utils';
15
6
  export function newCommsClient(params) {
16
- var _a;
17
7
  const scope = newScope();
18
8
  // Two initialization paths:
19
9
  // 1. Initial load: Host sends 'ant/comms/init' with clientId + context after iframe @load
@@ -21,7 +11,7 @@ export function newCommsClient(params) {
21
11
  const initData = new BehaviorSubject(null);
22
12
  // Send ready message for HMR recovery (host's listener is scoped to our window)
23
13
  // For initial load, this will timeout (expected) because host's listener isn't set up until @load
24
- send(params.parent, 'ant/comms/ready', {}, { fireAndForget: false })
14
+ send(params.parent, 'ant/comms/ready', { manifest: params.manifest }, { fireAndForget: false })
25
15
  .then((response) => {
26
16
  const { clientId, context } = response.data;
27
17
  initData.next({ clientId, context });
@@ -38,11 +28,10 @@ export function newCommsClient(params) {
38
28
  // marks connectionInitialized and starts sending messages.
39
29
  scope
40
30
  .once('ant/comms/init', (message) => {
41
- var _a;
42
31
  if (!initData.value) {
43
- initData.next({ clientId: message.data.clientId, context: (_a = message.data.context) !== null && _a !== void 0 ? _a : {} });
32
+ initData.next({ clientId: message.data.clientId, context: message.data.context ?? {} });
44
33
  }
45
- return Promise.resolve(); // Return value becomes ACK
34
+ return Promise.resolve({ manifest: params.manifest }); // Return value becomes ACK
46
35
  })
47
36
  .subscribe();
48
37
  const clientIdChanges = initData.asObservable().pipe(filter((data) => data !== null), map(data => data.clientId), shareReplay(1));
@@ -56,7 +45,7 @@ export function newCommsClient(params) {
56
45
  return Object.assign(scope, {
57
46
  notepad: newNotepad(box),
58
47
  notifications: newNotifications(box),
59
- connect: (_a = params.connect) !== null && _a !== void 0 ? _a : newAntConnectFacade(box),
48
+ connect: params.connect ?? newAntConnectFacade(box),
60
49
  context: newContextObservableWithInitial(box, initialContext),
61
50
  toolbar: handleToolbarChanges(box),
62
51
  appState: handleAppStateChanges(box),
@@ -94,24 +83,23 @@ function handleToolbarChanges({ scope, parent, clientIdChanges }) {
94
83
  // which would tear down and recreate listeners on every toolbar change
95
84
  clientIdChanges
96
85
  .pipe(switchMap(clientId => merge(scope.on(`ant/${clientId}/toolbar/click`).pipe(tap(({ data }) => {
97
- var _a, _b;
98
- (_b = (_a = toolbar.value.menu[data.index]) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
86
+ toolbar.value.menu[data.index]?.onClick?.();
99
87
  })), scope.on(`ant/${clientId}/toolbar/search`).pipe(tap(({ data }) => {
100
- set(t => (Object.assign(Object.assign({}, t), { search: Object.assign(Object.assign({}, t.search), { input: data.value }) })));
88
+ set(t => ({ ...t, search: { ...t.search, input: data.value ?? '' } }));
101
89
  })))), takeUntilClosed(scope))
102
90
  .subscribe();
103
91
  return Object.assign(toolbar.asObservable().pipe(takeUntilClosed(scope)), { set, get: () => toolbar.value });
104
92
  }
105
93
  export function newNotepad({ scope, parent, clientIdChanges }) {
106
- const post = (name, data) => __awaiter(this, void 0, void 0, function* () {
94
+ const post = async (name, data) => {
107
95
  clientIdChanges
108
96
  .pipe(concatMap(clientId => scope.send(parent, `ant/${clientId}/notepad`, { name, data })))
109
97
  .subscribe();
110
- });
98
+ };
111
99
  return {
112
100
  show: tab => post('show/tab', { tab }),
113
101
  showTask: (task, select) => post(`show/task`, { task, select }),
114
- hide: () => post(`hide`, undefined),
102
+ hide: () => post(`hide`, {}),
115
103
  selectSbs: item => post(`sbs/select`, { item }),
116
104
  };
117
105
  }
@@ -166,7 +154,6 @@ function getSignal({ clientIdChanges, scope, parent }) {
166
154
  }
167
155
  function getRequest({ clientIdChanges, scope }) {
168
156
  return (request, controller) => {
169
- var _a;
170
157
  const id = newId();
171
158
  const subscription = new Subscription();
172
159
  const result = new Promise((next, error) => {
@@ -177,7 +164,7 @@ function getRequest({ clientIdChanges, scope }) {
177
164
  subscription.add(clientIdChanges
178
165
  .pipe(take(1), switchMap(clientId => scope.send(parent, `ant/${clientId}/request`, { id, request })), takeUntilClosed(scope))
179
166
  .subscribe());
180
- (_a = controller === null || controller === void 0 ? void 0 : controller.signal) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', () => subscription.unsubscribe());
167
+ controller?.signal?.addEventListener('abort', () => subscription.unsubscribe());
181
168
  scope.add(subscription);
182
169
  return result;
183
170
  };
@@ -1,9 +1,10 @@
1
1
  import type { Observable, Subject, SubscriptionLike } from 'rxjs';
2
+ import type { AppManifest } from "../services/AppService";
2
3
  import type { Context, Notepad, Notification, Toolbar } from './models';
3
4
  import type { Change, ChangeSignal, Signal, SignalReceiver, SignalSender } from './signal';
4
5
  import type { Scope } from './utils';
5
6
  import type { AntConnect } from "../AntConnect";
6
- import { BehaviorSubject, Subscription } from 'rxjs';
7
+ import { BehaviorSubject, ReplaySubject, Subscription } from 'rxjs';
7
8
  export type SignalObserverFactory = (type: keyof ChangeSignal | (string & {}), id: string | undefined | null, actions: Change[], callback: (...signal: Signal[]) => void, scope?: ('project' | 'license')[]) => () => void;
8
9
  export interface HostParams {
9
10
  windowChanges: Observable<Window>;
@@ -19,6 +20,7 @@ export interface Box {
19
20
  clientId: string;
20
21
  scope: Scope;
21
22
  connectionInitialized: Subject<void>;
23
+ manifestSubject: ReplaySubject<AppManifest | null>;
22
24
  }
23
25
  export interface Host extends SubscriptionLike {
24
26
  toolbar: Observable<Toolbar> & {
@@ -28,6 +30,7 @@ export interface Host extends SubscriptionLike {
28
30
  };
29
31
  };
30
32
  isConnectionInitialized: Observable<boolean>;
33
+ manifest: Observable<AppManifest | null>;
31
34
  signal: SignalReceiver & SignalSender;
32
35
  appState: {
33
36
  changes: Observable<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/comms/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACvE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E,CAAA;IAC3G,uBAAuB,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC5C,QAAQ,EAAE,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACxC,MAAM,EAAE,cAAc,GAAG,YAAY,CAAA;IACrC,QAAQ,EAAE;QACR,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QAC3B,GAAG,EAAE,MAAM,MAAM,CAAA;QACjB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;KAC7B,CAAA;IACD,KAAK,EAAE,YAAY,CAAA;CACpB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAwCrD;AAqED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA"}
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { on, send } from 'post-robot';
11
2
  import { BehaviorSubject, combineLatest, concatMap, delay, distinctUntilChanged, filter, firstValueFrom, from, identity, map, of, ReplaySubject, retry, share, startWith, Subscription, switchMap, take, tap, } from 'rxjs';
12
3
  import { fromArrayLike } from 'rxjs/internal/observable/innerFrom';
@@ -17,7 +8,8 @@ export function newCommsHost(params) {
17
8
  const scope = newScope();
18
9
  const clientId = newId();
19
10
  const connectionInitialized = new ReplaySubject(1);
20
- const box = { scope, params, clientId, connectionInitialized };
11
+ const manifestSubject = new ReplaySubject(1);
12
+ const box = { scope, params, clientId, connectionInitialized, manifestSubject };
21
13
  const toolbar = handleToolbarChanges(box);
22
14
  const appState = handleAppStateChanges(box);
23
15
  handleInit(box);
@@ -40,10 +32,11 @@ export function newCommsHost(params) {
40
32
  isConnectionInitialized: connectionInitialized
41
33
  .asObservable()
42
34
  .pipe(map(() => true), startWith(false), takeUntilClosed(scope)),
35
+ manifest: manifestSubject.asObservable().pipe(takeUntilClosed(scope)),
43
36
  scope: newScope(scope),
44
37
  });
45
38
  }
46
- function handleInit({ scope, params, clientId, connectionInitialized }) {
39
+ function handleInit({ scope, params, clientId, connectionInitialized, manifestSubject }) {
47
40
  // Init message includes context so client has it immediately (no delay waiting for separate context message)
48
41
  // The client uses a handler in scope.once, ensuring initData.next() runs BEFORE the ACK is sent.
49
42
  // This means all RxJS subscriptions (which set up listeners) have processed before we get here.
@@ -51,7 +44,10 @@ function handleInit({ scope, params, clientId, connectionInitialized }) {
51
44
  .pipe(switchMap(window => send(window, 'ant/comms/init', { clientId, context: params.contextChanges.value }, { fireAndForget: false })), retry({
52
45
  delay: (error, attempt) => of(error).pipe(delay(500), tap(error => console.info('retrying connection initialization', { attempt, error }))),
53
46
  }), tap(() => console.info('connection initialized')), takeUntilClosed(scope))
54
- .subscribe(() => connectionInitialized.next(undefined));
47
+ .subscribe((response) => {
48
+ manifestSubject.next(response.data?.manifest ?? null);
49
+ connectionInitialized.next(undefined);
50
+ });
55
51
  }
56
52
  /**
57
53
  * Client-initiated connection handler for HMR recovery.
@@ -63,26 +59,27 @@ function handleInit({ scope, params, clientId, connectionInitialized }) {
63
59
  * Note: For initial load, handleInit provides context with the init message.
64
60
  * This handler is specifically for HMR where client JS restarts but iframe doesn't reload.
65
61
  */
66
- function handleReady({ scope, params, clientId, connectionInitialized }) {
62
+ function handleReady({ scope, params, clientId, connectionInitialized, manifestSubject }) {
67
63
  // Wait for window reference (from @load event), then set up HMR recovery listener
68
64
  // The listener is scoped to our specific iframe window
69
65
  params.windowChanges.pipe(filter(Boolean), take(1), takeUntilClosed(scope)).subscribe((iframeWindow) => {
70
- const canceller = on('ant/comms/ready', { window: iframeWindow }, () => __awaiter(this, void 0, void 0, function* () {
66
+ const canceller = on('ant/comms/ready', { window: iframeWindow }, async (event) => {
71
67
  console.info('ready message received (client-initiated, HMR recovery)');
68
+ manifestSubject.next(event.data?.manifest ?? null);
72
69
  // Small delay to ensure client's RxJS subscriptions have processed after receiving response
73
70
  setTimeout(() => connectionInitialized.next(undefined), 50);
74
71
  return { clientId, context: params.contextChanges.value };
75
- }));
72
+ });
76
73
  scope.add({ unsubscribe: () => canceller.cancel() });
77
74
  });
78
75
  }
79
76
  function handleNotificationChanges({ scope, params, clientId }) {
80
77
  scope
81
- .resolve(on(`ant/${clientId}/notifications`, (_a) => __awaiter(this, [_a], void 0, function* ({ data }) {
78
+ .resolve(on(`ant/${clientId}/notifications`, async ({ data }) => {
82
79
  const notification = data;
83
80
  params.addNotification(notification);
84
81
  return notification;
85
- })))
82
+ }))
86
83
  .catch(identity); // consume the cancellation error
87
84
  }
88
85
  const defaultConnectCall = ({ params }, { service, name, args }) => params.connect[service][name](...args);
@@ -101,8 +98,11 @@ function handleRequestChanges(box) {
101
98
  .on(`ant/${clientId}/request`)
102
99
  .pipe(concatMap(({ data, source }) => {
103
100
  const { id, request } = data;
104
- const http = box.params.connect.httpClient.http;
105
- const config = Object.assign(Object.assign({}, request), { baseURL: box.params.connect.httpClient.baseUrl });
101
+ const { httpClient } = box.params.connect;
102
+ if (!httpClient)
103
+ return from(Promise.reject(new Error('No httpClient configured on AntConnect')));
104
+ const http = httpClient.http;
105
+ const config = { ...request, baseURL: httpClient.baseUrl };
106
106
  const promise = http.request(config);
107
107
  return from(promise).pipe(concatMap(response => scope.send(source, `ant/${clientId}/request`, { id, response: response.data })));
108
108
  }), takeUntilClosed(scope))
@@ -110,7 +110,7 @@ function handleRequestChanges(box) {
110
110
  }
111
111
  function handleNotepadChanges({ scope, params, clientId }) {
112
112
  scope
113
- .resolve(on(`ant/${clientId}/notepad`, (e) => __awaiter(this, void 0, void 0, function* () {
113
+ .resolve(on(`ant/${clientId}/notepad`, async (e) => {
114
114
  const { name, data } = e.data;
115
115
  switch (name) {
116
116
  case 'hide':
@@ -122,7 +122,7 @@ function handleNotepadChanges({ scope, params, clientId }) {
122
122
  case 'sbs/select':
123
123
  return params.notepad.selectSbs(data.item);
124
124
  }
125
- })))
125
+ }))
126
126
  .catch(identity); // consume the cancellation error
127
127
  }
128
128
  function handleContextChanges({ params, clientId, scope, connectionInitialized }) {
@@ -156,11 +156,10 @@ function handleToolbarChanges({ scope, clientId, connectionInitialized, params }
156
156
  });
157
157
  }
158
158
  function handleAppStateChanges({ scope, params, clientId, connectionInitialized }) {
159
- var _a;
160
- const appState = new BehaviorSubject({ timestamp: 0, state: (_a = params.appState) !== null && _a !== void 0 ? _a : '' });
159
+ const appState = new BehaviorSubject({ timestamp: 0, state: params.appState ?? '' });
161
160
  scope
162
161
  .on(`ant/${clientId}/state`)
163
- .subscribe(({ data }) => { var _a; return data.timestamp > ((_a = appState.value) === null || _a === void 0 ? void 0 : _a.timestamp) && appState.next(data); });
162
+ .subscribe(({ data }) => data.timestamp > appState.value?.timestamp && appState.next(data));
164
163
  scope
165
164
  .on(`ant/${clientId}/state/get`, () => appState.value)
166
165
  .subscribe();
@@ -178,14 +177,13 @@ function installSignalObservers(signal, { scope, params }) {
178
177
  const observers = {};
179
178
  const subscription = new Subscription();
180
179
  const unsubscribe = signal.receive((s) => {
181
- var _a;
182
180
  if (s.observe && !subscription.closed) {
183
181
  const { actions, id, random, type, scope: observeScope } = s.observe;
184
- const unobserve = params.newSignalObserver(type, id, actions !== null && actions !== void 0 ? actions : [...changes], signal.send, observeScope);
182
+ const unobserve = params.newSignalObserver(type, id, actions ?? [...changes], signal.send, observeScope);
185
183
  Object.assign(observers, { [random]: unobserve });
186
184
  }
187
185
  else if (s.unobserve) {
188
- (_a = observers[s.unobserve.random]) === null || _a === void 0 ? void 0 : _a.call(observers);
186
+ observers[s.unobserve.random]?.();
189
187
  delete observers[s.unobserve.random];
190
188
  }
191
189
  });
@@ -1,19 +1,10 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { firstValueFrom } from 'rxjs';
11
2
  export const recordServiceCalls = [
12
- ifRecordsService('createRecord', (call_1, box_1, _a) => __awaiter(void 0, [call_1, box_1, _a], void 0, function* (call, box, { args }) { return call(args[0], args[1], args[2] || (yield getSelectedTask(box))); })),
13
- ifRecordsService('importRecords', (call_1, box_1, _a) => __awaiter(void 0, [call_1, box_1, _a], void 0, function* (call, box, { args }) { return call(args[0], args[1], args[2] || (yield getSelectedTask(box))); })),
14
- ifRecordsService('updateRecord', (call_1, box_1, _a) => __awaiter(void 0, [call_1, box_1, _a], void 0, function* (call, box, { args }) { return call(args[0], args[1], args[2], args[3] || (yield getSelectedTask(box))); })),
15
- ifRecordsService('deleteRecord', (call_1, box_1, _a) => __awaiter(void 0, [call_1, box_1, _a], void 0, function* (call, box, { args }) { return call(args[0], args[1] || (yield getSelectedTask(box))); })),
16
- ifRecordsService('deleteRecords', (call_1, box_1, _a) => __awaiter(void 0, [call_1, box_1, _a], void 0, function* (call, box, { args }) { return call(args[0], args[1], args[2], args[3] || (yield getSelectedTask(box))); })),
3
+ ifRecordsService('createRecord', async (call, box, { args }) => call(args[0], args[1], args[2] || await getSelectedTask(box))),
4
+ ifRecordsService('importRecords', async (call, box, { args }) => call(args[0], args[1], args[2] || await getSelectedTask(box))),
5
+ ifRecordsService('updateRecord', async (call, box, { args }) => call(args[0], args[1], args[2], args[3] || await getSelectedTask(box))),
6
+ ifRecordsService('deleteRecord', async (call, box, { args }) => call(args[0], args[1] || await getSelectedTask(box))),
7
+ ifRecordsService('deleteRecords', async (call, box, { args }) => call(args[0], args[1], args[2], args[3] || await getSelectedTask(box))),
17
8
  ];
18
9
  /**
19
10
  * If an api call from RecordService needs to be called, the callback will be triggered. Otherwise the next on will be ran.
@@ -27,5 +18,5 @@ function ifRecordsService(key, fn) {
27
18
  : next();
28
19
  }
29
20
  function getSelectedTask(box) {
30
- return firstValueFrom(box.params.contextChanges).then(e => { var _a; return (_a = e.selectedTask) === null || _a === void 0 ? void 0 : _a.id; });
21
+ return firstValueFrom(box.params.contextChanges).then(e => e.selectedTask?.id);
31
22
  }