@genesislcap/foundation-comms 14.187.1-alpha-3406925.0 → 14.187.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. package/dist/dts/connect/connect.d.ts +6 -11
  2. package/dist/dts/connect/connect.d.ts.map +1 -1
  3. package/dist/dts/connect/http.connect.d.ts +2 -2
  4. package/dist/dts/connect/http.connect.d.ts.map +1 -1
  5. package/dist/dts/connect/message.d.ts +0 -11
  6. package/dist/dts/connect/message.d.ts.map +1 -1
  7. package/dist/dts/connect/socket.d.ts +2 -6
  8. package/dist/dts/connect/socket.d.ts.map +1 -1
  9. package/dist/dts/datasource/datasource.d.ts +19 -49
  10. package/dist/dts/datasource/datasource.d.ts.map +1 -1
  11. package/dist/dts/datasource/datasource.types.d.ts +22 -14
  12. package/dist/dts/datasource/datasource.types.d.ts.map +1 -1
  13. package/dist/dts/datasource/entityDatasource.d.ts +8 -5
  14. package/dist/dts/datasource/entityDatasource.d.ts.map +1 -1
  15. package/dist/dts/datasource/index.d.ts +0 -2
  16. package/dist/dts/datasource/index.d.ts.map +1 -1
  17. package/dist/dts/index.d.ts +0 -1
  18. package/dist/dts/index.d.ts.map +1 -1
  19. package/dist/dts/testing/mocks/auth/auth.d.ts +0 -3
  20. package/dist/dts/testing/mocks/auth/auth.d.ts.map +1 -1
  21. package/dist/dts/testing/mocks/connect/connect.d.ts +2 -3
  22. package/dist/dts/testing/mocks/connect/connect.d.ts.map +1 -1
  23. package/dist/dts/testing/mocks/connect/socket.d.ts +0 -1
  24. package/dist/dts/testing/mocks/connect/socket.d.ts.map +1 -1
  25. package/dist/dts/testing/mocks/datasource/datasource.d.ts +4 -22
  26. package/dist/dts/testing/mocks/datasource/datasource.d.ts.map +1 -1
  27. package/dist/dts/testing/mocks/index.d.ts +0 -1
  28. package/dist/dts/testing/mocks/index.d.ts.map +1 -1
  29. package/dist/esm/connect/connect.js +15 -12
  30. package/dist/esm/connect/http.connect.js +3 -5
  31. package/dist/esm/connect/message.js +0 -2
  32. package/dist/esm/connect/socket.js +6 -19
  33. package/dist/esm/datasource/datasource.js +58 -133
  34. package/dist/esm/datasource/datasource.types.js +18 -2
  35. package/dist/esm/datasource/entityDatasource.js +0 -6
  36. package/dist/esm/datasource/index.js +0 -2
  37. package/dist/esm/index.js +0 -1
  38. package/dist/esm/testing/mocks/auth/auth.js +0 -10
  39. package/dist/esm/testing/mocks/connect/connect.js +2 -9
  40. package/dist/esm/testing/mocks/connect/socket.js +0 -2
  41. package/dist/esm/testing/mocks/datasource/datasource.js +0 -59
  42. package/dist/esm/testing/mocks/index.js +0 -1
  43. package/dist/foundation-comms.api.json +6042 -10797
  44. package/dist/foundation-comms.d.ts +37 -696
  45. package/docs/api/foundation-comms.connect.connect.md +2 -2
  46. package/docs/api/foundation-comms.connect.getavailableresources.md +2 -2
  47. package/docs/api/foundation-comms.connect.md +0 -1
  48. package/docs/api/{foundation-comms.datasource.status.md → foundation-comms.datasource.fieldmetadata.md} +4 -3
  49. package/docs/api/foundation-comms.datasource.init.md +2 -2
  50. package/docs/api/foundation-comms.datasource.md +2 -3
  51. package/docs/api/foundation-comms.datasourceconfig.md +1 -2
  52. package/docs/api/foundation-comms.defaultconnect.connect.md +2 -2
  53. package/docs/api/foundation-comms.defaultconnect.getavailableresources.md +2 -2
  54. package/docs/api/foundation-comms.defaultconnect.md +0 -1
  55. package/docs/api/foundation-comms.defaultdatasource._constructor_.md +2 -3
  56. package/docs/api/{foundation-comms.defaultdatasource.fetchmetadatarequired.md → foundation-comms.defaultdatasource._stream.md} +3 -4
  57. package/docs/api/foundation-comms.defaultdatasource.availableindexes.md +1 -2
  58. package/docs/api/foundation-comms.defaultdatasource.fieldmetadata.md +0 -1
  59. package/docs/api/foundation-comms.defaultdatasource.initialized.md +1 -3
  60. package/docs/api/foundation-comms.defaultdatasource.md +7 -10
  61. package/docs/api/foundation-comms.defaultdatasource.originalfielddef.md +1 -2
  62. package/docs/api/foundation-comms.defaultdatasource.requestfields.md +1 -2
  63. package/docs/api/foundation-comms.defaultdatasource.stream.md +1 -1
  64. package/docs/api/foundation-comms.defaultdatasource.validresourcename.md +0 -5
  65. package/docs/api/foundation-comms.defaultdatasourceconfig.md +1 -1
  66. package/docs/api/foundation-comms.defaulthttpconnect.getavailableresources.md +2 -2
  67. package/docs/api/foundation-comms.defaultsocket._constructor_.md +1 -2
  68. package/docs/api/foundation-comms.defaultsocket.connect.md +2 -2
  69. package/docs/api/foundation-comms.defaultsocket.md +1 -3
  70. package/docs/api/foundation-comms.eventmessagetype.md +0 -2
  71. package/docs/api/foundation-comms.md +2 -19
  72. package/docs/api/foundation-comms.socket.md +0 -6
  73. package/docs/api-report.md +25 -550
  74. package/package.json +12 -13
  75. package/dist/dts/datasource/datasource.config.d.ts +0 -44
  76. package/dist/dts/datasource/datasource.config.d.ts.map +0 -1
  77. package/dist/dts/datasource/datasource.mixins.d.ts +0 -367
  78. package/dist/dts/datasource/datasource.mixins.d.ts.map +0 -1
  79. package/dist/dts/resources/genesis/config.d.ts +0 -81
  80. package/dist/dts/resources/genesis/config.d.ts.map +0 -1
  81. package/dist/dts/resources/genesis/genesis.d.ts +0 -69
  82. package/dist/dts/resources/genesis/genesis.d.ts.map +0 -1
  83. package/dist/dts/resources/genesis/index.d.ts +0 -4
  84. package/dist/dts/resources/genesis/index.d.ts.map +0 -1
  85. package/dist/dts/resources/genesis/types.d.ts +0 -19
  86. package/dist/dts/resources/genesis/types.d.ts.map +0 -1
  87. package/dist/dts/resources/index.d.ts +0 -2
  88. package/dist/dts/resources/index.d.ts.map +0 -1
  89. package/dist/dts/testing/mocks/resources/genesis/genesis.d.ts +0 -16
  90. package/dist/dts/testing/mocks/resources/genesis/genesis.d.ts.map +0 -1
  91. package/dist/dts/testing/mocks/resources/genesis/index.d.ts +0 -2
  92. package/dist/dts/testing/mocks/resources/genesis/index.d.ts.map +0 -1
  93. package/dist/dts/testing/mocks/resources/index.d.ts +0 -2
  94. package/dist/dts/testing/mocks/resources/index.d.ts.map +0 -1
  95. package/dist/esm/datasource/datasource.config.js +0 -41
  96. package/dist/esm/datasource/datasource.mixins.js +0 -86
  97. package/dist/esm/resources/genesis/config.js +0 -51
  98. package/dist/esm/resources/genesis/genesis.js +0 -114
  99. package/dist/esm/resources/genesis/index.js +0 -3
  100. package/dist/esm/resources/genesis/types.js +0 -4
  101. package/dist/esm/resources/index.js +0 -1
  102. package/dist/esm/testing/mocks/resources/genesis/genesis.js +0 -25
  103. package/dist/esm/testing/mocks/resources/genesis/index.js +0 -1
  104. package/dist/esm/testing/mocks/resources/index.js +0 -1
  105. package/docs/api/foundation-comms.connect.host.md +0 -11
  106. package/docs/api/foundation-comms.datasourceconfig.eventemitter.md +0 -18
  107. package/docs/api/foundation-comms.datasourceeventhandler.md +0 -353
  108. package/docs/api/foundation-comms.datasourcemetadata.availableindexes.md +0 -11
  109. package/docs/api/foundation-comms.datasourcemetadata.fetchmetadatarequired.md +0 -11
  110. package/docs/api/foundation-comms.datasourcemetadata.fieldmetadata.md +0 -11
  111. package/docs/api/foundation-comms.datasourcemetadata.md +0 -24
  112. package/docs/api/foundation-comms.datasourcemetadata.originalfielddef.md +0 -11
  113. package/docs/api/foundation-comms.datasourcemetadata.requestfields.md +0 -11
  114. package/docs/api/foundation-comms.datasourcestatus.md +0 -21
  115. package/docs/api/foundation-comms.datasourcestatuschanged.md +0 -13
  116. package/docs/api/foundation-comms.datasourcestatuschangedevent.md +0 -15
  117. package/docs/api/foundation-comms.defaultconnect.host.md +0 -11
  118. package/docs/api/foundation-comms.defaultdatasource.fetchandapplymetadata.md +0 -22
  119. package/docs/api/foundation-comms.defaultdatasource.resources.md +0 -11
  120. package/docs/api/foundation-comms.defaultdatasource.status.md +0 -12
  121. package/docs/api/foundation-comms.defaultgenesisresources._constructor_.md +0 -21
  122. package/docs/api/foundation-comms.defaultgenesisresources.config.md +0 -11
  123. package/docs/api/foundation-comms.defaultgenesisresources.connect.md +0 -11
  124. package/docs/api/foundation-comms.defaultgenesisresources.destroy.md +0 -17
  125. package/docs/api/foundation-comms.defaultgenesisresources.getresources.md +0 -15
  126. package/docs/api/foundation-comms.defaultgenesisresources.getresourcetypefor.md +0 -24
  127. package/docs/api/foundation-comms.defaultgenesisresources.isvalidresource.md +0 -24
  128. package/docs/api/foundation-comms.defaultgenesisresources.md +0 -40
  129. package/docs/api/foundation-comms.defaultgenesisresources.postloadedmessage.md +0 -15
  130. package/docs/api/foundation-comms.defaultgenesisresources.resources.md +0 -11
  131. package/docs/api/foundation-comms.defaultgenesisresources.resourcespromise.md +0 -11
  132. package/docs/api/foundation-comms.defaultgenesisresourcesconfig.md +0 -13
  133. package/docs/api/foundation-comms.defaultsocket.config.md +0 -11
  134. package/docs/api/foundation-comms.defaultsocket.host.md +0 -11
  135. package/docs/api/foundation-comms.genesisresources.destroy.md +0 -13
  136. package/docs/api/foundation-comms.genesisresources.getresourcetypefor.md +0 -13
  137. package/docs/api/foundation-comms.genesisresources.isvalidresource.md +0 -13
  138. package/docs/api/foundation-comms.genesisresources.md +0 -26
  139. package/docs/api/foundation-comms.genesisresourceschannel.md +0 -33
  140. package/docs/api/foundation-comms.genesisresourceschannelid.md +0 -12
  141. package/docs/api/foundation-comms.genesisresourcesconfig.md +0 -21
  142. package/docs/api/foundation-comms.genesisresourcesconfig.throwwhenunavailable.md +0 -13
  143. package/docs/api/foundation-comms.genesisresourcesconfig.throwwhenunknown.md +0 -13
  144. package/docs/api/foundation-comms.genesisresourcesevents.md +0 -17
  145. package/docs/api/foundation-comms.genesisresourcesmock.destroy.md +0 -15
  146. package/docs/api/foundation-comms.genesisresourcesmock.getresourcetypefor.md +0 -24
  147. package/docs/api/foundation-comms.genesisresourcesmock.isvalidresource.md +0 -24
  148. package/docs/api/foundation-comms.genesisresourcesmock.md +0 -30
  149. package/docs/api/foundation-comms.genesisresourcesmock.nextisvalidresourceresponse.md +0 -11
  150. package/docs/api/foundation-comms.genesisresourcesmock.nextresourcetypeforresponse.md +0 -11
  151. package/docs/api/foundation-comms.genesisresourcesmock.resources.md +0 -11
  152. package/docs/api/foundation-comms.getgenesisresources.md +0 -30
  153. package/docs/api/foundation-comms.getgenesisresourceschannel.md +0 -39
  154. package/docs/api/foundation-comms.resourceitem.md +0 -15
  155. package/docs/api/foundation-comms.resourcesmessage.md +0 -18
  156. package/docs/api/foundation-comms.socket.host.md +0 -11
@@ -1,2 +0,0 @@
1
- export * from './genesis';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -1,16 +0,0 @@
1
- import { ResourceType } from '../../../../datasource';
2
- import type { GenesisResources, ResourceItem } from '../../../../resources';
3
- /**
4
- * @public
5
- */
6
- export declare class GenesisResourcesMock implements GenesisResources {
7
- resources: ResourceItem[];
8
- nextIsValidResourceResponse: boolean;
9
- nextResourceTypeForResponse: ResourceType;
10
- /** {@inheritDoc GenesisResources.isValidResource} */
11
- isValidResource(resourceName: string): Promise<boolean>;
12
- /** {@inheritDoc GenesisResources.getResourceTypeFor} */
13
- getResourceTypeFor(resourceName: string): Promise<ResourceType>;
14
- destroy(): void;
15
- }
16
- //# sourceMappingURL=genesis.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"genesis.d.ts","sourceRoot":"","sources":["../../../../../../src/testing/mocks/resources/genesis/genesis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE5E;;GAEG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D,SAAS,EAAE,YAAY,EAAE,CAAM;IAC/B,2BAA2B,EAAE,OAAO,CAAQ;IAC5C,2BAA2B,EAAE,YAAY,CAA2B;IAEpE,qDAAqD;IAC/C,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7D,wDAAwD;IAClD,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAIrE,OAAO;CACR"}
@@ -1,2 +0,0 @@
1
- export * from './genesis';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/testing/mocks/resources/genesis/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './genesis';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/testing/mocks/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -1,41 +0,0 @@
1
- import { DI } from '@microsoft/fast-foundation';
2
- import { criteriaFiltersToFields } from './criteriaFiltersToFields';
3
- import { dataServerResultFilter } from './dataServerResultFilter';
4
- /**
5
- * Default values for a DatasourceConfig
6
- * @public
7
- */
8
- export class DatasourceDefaults {
9
- }
10
- DatasourceDefaults.MAX_ROWS_250 = 250;
11
- DatasourceDefaults.MAX_VIEW_1000 = 1000;
12
- DatasourceDefaults.REQ_REP_POLLING_INTERVAL_MS = 10000;
13
- DatasourceDefaults.DATASERVER_ROW_ID = 'ROW_REF';
14
- DatasourceDefaults.REQUEST_SERVER_ROW_ID = 'RECORD_ID';
15
- /**
16
- * Default DatasourceConfig DI implementation.
17
- * @public
18
- */
19
- export const defaultDatasourceConfig = {
20
- options: {
21
- criteria: '',
22
- isSnapshot: false,
23
- maxRows: DatasourceDefaults.MAX_ROWS_250,
24
- maxView: DatasourceDefaults.MAX_VIEW_1000,
25
- pollingInterval: DatasourceDefaults.REQ_REP_POLLING_INTERVAL_MS,
26
- movingView: false,
27
- orderBy: '',
28
- resourceName: '',
29
- reverse: false,
30
- },
31
- criteriaToFields: criteriaFiltersToFields,
32
- dataServerResultFilter: dataServerResultFilter,
33
- };
34
- /**
35
- * DatasourceConfig DI key.
36
- *
37
- * @internal
38
- * @privateRemarks
39
- * Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
40
- */
41
- export const DatasourceConfig = DI.createInterface((x) => x.instance(defaultDatasourceConfig));
@@ -1,86 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { observable } from '@microsoft/fast-element';
3
- import { logger } from '../utils';
4
- import { DatasourceStatusChanged, } from './datasource.types';
5
- /**
6
- * Datasource event handler mixin for target classes that use or are interested in datasource status changes.
7
- *
8
- * @remarks
9
- * Classes that use the mixin are not required to own the datasource itself, there may be several interested parties.
10
- *
11
- * @example
12
- * ```ts
13
- * import { DatasourceEventHandler, DatasourceStatus } from '@genesislcap/foundation-comms';
14
- * ...
15
- * class MyComponent extends DatasourceEventHandler(FASTElement) {
16
- * resourceName: string = 'some-resource';
17
- * ...
18
- * datasourceStatusChanged(prev: DatasourceStatus, next: DatasourceStatus) {
19
- * // Respond to changes in the target datasource.
20
- * }
21
- * }
22
- * ```
23
- *
24
- * @privateRemarks
25
- * Unfortunately our datasource ui components do not share a common baseclass. Given datasource ui components contain a
26
- * Datasource and currently await their `init`, usage is more for example at this point, ie. how could we allow interested
27
- * parties to monitor and respond to changes, given they will exist at different levels of DOM hierarchy etc. Datasource
28
- * itself is also transient DI injectable, so each interested party would not have access to the same instance, nor would
29
- * we necessarily want to expose that via the event to prevent them operating on it to cause unwanted side effects.
30
- *
31
- * @param Target - The class to mix the event handler with.
32
- *
33
- * @public
34
- */
35
- export const DatasourceEventHandler = (Target) => {
36
- // @ts-ignore
37
- class Mixin extends Target {
38
- constructor() {
39
- super();
40
- if (!this.hasOwnProperty('onDatasourceStatusChanged')) {
41
- this.onDatasourceStatusChanged = (event) => {
42
- var _a;
43
- if (!this.resourceName) {
44
- logger.warn(`Target classes must have a resourceName property to use the DatasourceEventHandler mixin.`);
45
- }
46
- const next = event.detail;
47
- if (next.name === this.resourceName) {
48
- const prev = (_a = this.datasourceStatus) !== null && _a !== void 0 ? _a : {
49
- isInitialized: false,
50
- hasMetadata: false,
51
- };
52
- const hasChanged = prev.isInitialized !== next.isInitialized ||
53
- (next.metadataRequired && prev.hasMetadata !== next.hasMetadata);
54
- if (hasChanged) {
55
- this.datasourceStatus = next;
56
- }
57
- }
58
- };
59
- }
60
- }
61
- /**
62
- * @remarks
63
- * Override this method to respond to changes in the target datasource.
64
- */
65
- datasourceStatusChanged(prev, next) {
66
- logger.debug('Target classes should override the datasourceStatusChanged method of the DatasourceEventHandler mixin to respond to changes in the target datasource.');
67
- }
68
- connectedCallback() {
69
- super.connectedCallback();
70
- document.addEventListener(DatasourceStatusChanged, this.onDatasourceStatusChanged, {
71
- passive: true,
72
- capture: true,
73
- });
74
- }
75
- disconnectedCallback() {
76
- super.disconnectedCallback();
77
- document.removeEventListener(DatasourceStatusChanged, this.onDatasourceStatusChanged, {
78
- capture: true,
79
- });
80
- }
81
- }
82
- __decorate([
83
- observable
84
- ], Mixin.prototype, "datasourceStatus", void 0);
85
- return Mixin;
86
- };
@@ -1,51 +0,0 @@
1
- import { registerTypedBroadcastChannel, } from '@genesislcap/foundation-broadcast-channel';
2
- import { DI } from '@microsoft/fast-foundation';
3
- import { GenesisResourcesChannelId } from './types';
4
- /**
5
- * Default GenesisResourcesConfig implementation.
6
- * @public
7
- */
8
- export const defaultGenesisResourcesConfig = {
9
- throwWhenUnavailable: true,
10
- throwWhenUnknown: false,
11
- };
12
- /**
13
- * GenesisResourcesConfig DI key.
14
- * @internal
15
- * @privateRemarks
16
- * Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
17
- */
18
- export const GenesisResourcesConfig = DI.createInterface((x) => x.instance(defaultGenesisResourcesConfig));
19
- /**
20
- * GenesisResourcesChannel DI key.
21
- * @internal
22
- * @privateRemarks
23
- * Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
24
- */
25
- export const GenesisResourcesChannel = registerTypedBroadcastChannel(GenesisResourcesChannelId);
26
- /**
27
- * Gets GenesisResourcesChannel from the DI container.
28
- *
29
- * @remarks
30
- * A utility method for host applications that are not using decorators or the DI container.
31
- *
32
- * @example
33
- * ```ts
34
- * import { getGenesisResourcesChannel } from '@genesislcap/foundation-comms';
35
- * ...
36
- * const channel = getGenesisResourcesChannel();
37
- * ...
38
- * channel.onmessage = (e) => {
39
- * if (channel.isMessageType('resources-loaded', e)) {
40
- * logger.debug('resources-loaded', e.data.detail);
41
- * return;
42
- * }
43
- * }
44
- * ...
45
- * channel.close();
46
- * ```
47
- * @public
48
- */
49
- export function getGenesisResourcesChannel() {
50
- return DI.getOrCreateDOMContainer().get(GenesisResourcesChannel);
51
- }
@@ -1,114 +0,0 @@
1
- import { __awaiter, __decorate, __param } from "tslib";
2
- import { DI } from '@microsoft/fast-foundation';
3
- import { Connect } from '../../connect';
4
- import { logger } from '../../utils';
5
- import { GenesisResourcesConfig, getGenesisResourcesChannel } from './config';
6
- /**
7
- * Default GenesisResources implementation.
8
- * @public
9
- */
10
- let DefaultGenesisResources = class DefaultGenesisResources {
11
- constructor(connect, config) {
12
- this.connect = connect;
13
- this.config = config;
14
- }
15
- /** {@inheritDoc GenesisResources.isValidResource} */
16
- isValidResource(resourceName) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- resourceName = resourceName === null || resourceName === void 0 ? void 0 : resourceName.trim();
19
- if (!resourceName) {
20
- return false;
21
- }
22
- yield this.getResources();
23
- const resourceItem = this.resources.find((item) => item.RESOURCE_NAME === resourceName);
24
- return !!resourceItem;
25
- });
26
- }
27
- /** {@inheritDoc GenesisResources.getResourceTypeFor} */
28
- getResourceTypeFor(resourceName) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- yield this.getResources();
31
- const resourceItem = this.resources.find((item) => item.RESOURCE_NAME === resourceName);
32
- if (resourceItem) {
33
- return resourceItem.RESOURCE_TYPE;
34
- }
35
- const message = `${resourceName} resource does not exist.`;
36
- logger.error(message);
37
- if (this.config.throwWhenUnknown) {
38
- throw new Error(message);
39
- }
40
- });
41
- }
42
- /** {@inheritDoc GenesisResources.destroy} */
43
- destroy() {
44
- this.resources = undefined;
45
- this.resourcesPromise = undefined;
46
- }
47
- getResources() {
48
- var _a;
49
- return __awaiter(this, void 0, void 0, function* () {
50
- if (!this.resourcesPromise) {
51
- /**
52
- * Await a resources request
53
- */
54
- this.resourcesPromise = this.connect.getAvailableResources();
55
- const data = yield this.resourcesPromise;
56
- this.resources = data === null || data === void 0 ? void 0 : data.RESOURCES;
57
- if (!((_a = this.resources) === null || _a === void 0 ? void 0 : _a.length)) {
58
- const message = `Genesis resources unavailable.`;
59
- logger.error(message);
60
- if (this.config.throwWhenUnavailable) {
61
- throw new Error(message);
62
- }
63
- }
64
- this.postLoadedMessage();
65
- this.resourcesPromise = undefined;
66
- }
67
- else {
68
- /**
69
- * Await the in-progress resources request
70
- */
71
- yield this.resourcesPromise;
72
- }
73
- });
74
- }
75
- postLoadedMessage() {
76
- /**
77
- * Normally we'd inject channels into components and call their `channel.close()` api on `disconnectedCallback`.
78
- * However, in shared long-lived service instances like this, channels may lead to tests failing to exit as they are
79
- * not garbage collected by default. Creating and destroying the channel on on-demand poses less risk.
80
- */
81
- const channel = getGenesisResourcesChannel();
82
- channel.postMessage('resources-loaded', this.resources);
83
- channel.close();
84
- }
85
- };
86
- DefaultGenesisResources = __decorate([
87
- __param(0, Connect),
88
- __param(1, GenesisResourcesConfig)
89
- ], DefaultGenesisResources);
90
- export { DefaultGenesisResources };
91
- /**
92
- * GenesisResources DI key.
93
- * @internal
94
- * @privateRemarks
95
- * Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
96
- */
97
- export const GenesisResources = DI.createInterface((x) => x.singleton(DefaultGenesisResources));
98
- /**
99
- * Gets GenesisResources from the DI container.
100
- *
101
- * @remarks
102
- * A utility method for host applications that are not using decorators or the DI container.
103
- *
104
- * @example
105
- * ```ts
106
- * import { getGenesisResources } from '@genesislcap/foundation-comms';
107
- * ...
108
- * const genesisResources = getGenesisResources();
109
- * ```
110
- * @public
111
- */
112
- export function getGenesisResources() {
113
- return DI.getOrCreateDOMContainer().get(GenesisResources);
114
- }
@@ -1,3 +0,0 @@
1
- export * from './config';
2
- export * from './genesis';
3
- export * from './types';
@@ -1,4 +0,0 @@
1
- /**
2
- * @public
3
- */
4
- export const GenesisResourcesChannelId = 'genesis-resources';
@@ -1 +0,0 @@
1
- export * from './genesis';
@@ -1,25 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { ResourceType } from '../../../../datasource';
3
- /**
4
- * @public
5
- */
6
- export class GenesisResourcesMock {
7
- constructor() {
8
- this.resources = [];
9
- this.nextIsValidResourceResponse = true;
10
- this.nextResourceTypeForResponse = ResourceType.DATASERVER;
11
- }
12
- /** {@inheritDoc GenesisResources.isValidResource} */
13
- isValidResource(resourceName) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- return this.nextIsValidResourceResponse;
16
- });
17
- }
18
- /** {@inheritDoc GenesisResources.getResourceTypeFor} */
19
- getResourceTypeFor(resourceName) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- return this.nextResourceTypeForResponse;
22
- });
23
- }
24
- destroy() { }
25
- }
@@ -1 +0,0 @@
1
- export * from './genesis';
@@ -1 +0,0 @@
1
- export * from './genesis';
@@ -1,11 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@genesislcap/foundation-comms](./foundation-comms.md) &gt; [Connect](./foundation-comms.connect.md) &gt; [host](./foundation-comms.connect.host.md)
4
-
5
- ## Connect.host property
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- host: string;
11
- ```
@@ -1,18 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@genesislcap/foundation-comms](./foundation-comms.md) &gt; [DatasourceConfig](./foundation-comms.datasourceconfig.md) &gt; [eventEmitter](./foundation-comms.datasourceconfig.eventemitter.md)
4
-
5
- ## DatasourceConfig.eventEmitter property
6
-
7
- The element to emit events from.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- eventEmitter?: HTMLElement;
13
- ```
14
-
15
- ## Remarks
16
-
17
- If omitted the document is used.
18
-