@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.
- package/dist/dts/connect/connect.d.ts +6 -11
- package/dist/dts/connect/connect.d.ts.map +1 -1
- package/dist/dts/connect/http.connect.d.ts +2 -2
- package/dist/dts/connect/http.connect.d.ts.map +1 -1
- package/dist/dts/connect/message.d.ts +0 -11
- package/dist/dts/connect/message.d.ts.map +1 -1
- package/dist/dts/connect/socket.d.ts +2 -6
- package/dist/dts/connect/socket.d.ts.map +1 -1
- package/dist/dts/datasource/datasource.d.ts +19 -49
- package/dist/dts/datasource/datasource.d.ts.map +1 -1
- package/dist/dts/datasource/datasource.types.d.ts +22 -14
- package/dist/dts/datasource/datasource.types.d.ts.map +1 -1
- package/dist/dts/datasource/entityDatasource.d.ts +8 -5
- package/dist/dts/datasource/entityDatasource.d.ts.map +1 -1
- package/dist/dts/datasource/index.d.ts +0 -2
- package/dist/dts/datasource/index.d.ts.map +1 -1
- package/dist/dts/index.d.ts +0 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/testing/mocks/auth/auth.d.ts +0 -3
- package/dist/dts/testing/mocks/auth/auth.d.ts.map +1 -1
- package/dist/dts/testing/mocks/connect/connect.d.ts +2 -3
- package/dist/dts/testing/mocks/connect/connect.d.ts.map +1 -1
- package/dist/dts/testing/mocks/connect/socket.d.ts +0 -1
- package/dist/dts/testing/mocks/connect/socket.d.ts.map +1 -1
- package/dist/dts/testing/mocks/datasource/datasource.d.ts +4 -22
- package/dist/dts/testing/mocks/datasource/datasource.d.ts.map +1 -1
- package/dist/dts/testing/mocks/index.d.ts +0 -1
- package/dist/dts/testing/mocks/index.d.ts.map +1 -1
- package/dist/esm/connect/connect.js +15 -12
- package/dist/esm/connect/http.connect.js +3 -5
- package/dist/esm/connect/message.js +0 -2
- package/dist/esm/connect/socket.js +6 -19
- package/dist/esm/datasource/datasource.js +58 -133
- package/dist/esm/datasource/datasource.types.js +18 -2
- package/dist/esm/datasource/entityDatasource.js +0 -6
- package/dist/esm/datasource/index.js +0 -2
- package/dist/esm/index.js +0 -1
- package/dist/esm/testing/mocks/auth/auth.js +0 -10
- package/dist/esm/testing/mocks/connect/connect.js +2 -9
- package/dist/esm/testing/mocks/connect/socket.js +0 -2
- package/dist/esm/testing/mocks/datasource/datasource.js +0 -59
- package/dist/esm/testing/mocks/index.js +0 -1
- package/dist/foundation-comms.api.json +6042 -10797
- package/dist/foundation-comms.d.ts +37 -696
- package/docs/api/foundation-comms.connect.connect.md +2 -2
- package/docs/api/foundation-comms.connect.getavailableresources.md +2 -2
- package/docs/api/foundation-comms.connect.md +0 -1
- package/docs/api/{foundation-comms.datasource.status.md → foundation-comms.datasource.fieldmetadata.md} +4 -3
- package/docs/api/foundation-comms.datasource.init.md +2 -2
- package/docs/api/foundation-comms.datasource.md +2 -3
- package/docs/api/foundation-comms.datasourceconfig.md +1 -2
- package/docs/api/foundation-comms.defaultconnect.connect.md +2 -2
- package/docs/api/foundation-comms.defaultconnect.getavailableresources.md +2 -2
- package/docs/api/foundation-comms.defaultconnect.md +0 -1
- package/docs/api/foundation-comms.defaultdatasource._constructor_.md +2 -3
- package/docs/api/{foundation-comms.defaultdatasource.fetchmetadatarequired.md → foundation-comms.defaultdatasource._stream.md} +3 -4
- package/docs/api/foundation-comms.defaultdatasource.availableindexes.md +1 -2
- package/docs/api/foundation-comms.defaultdatasource.fieldmetadata.md +0 -1
- package/docs/api/foundation-comms.defaultdatasource.initialized.md +1 -3
- package/docs/api/foundation-comms.defaultdatasource.md +7 -10
- package/docs/api/foundation-comms.defaultdatasource.originalfielddef.md +1 -2
- package/docs/api/foundation-comms.defaultdatasource.requestfields.md +1 -2
- package/docs/api/foundation-comms.defaultdatasource.stream.md +1 -1
- package/docs/api/foundation-comms.defaultdatasource.validresourcename.md +0 -5
- package/docs/api/foundation-comms.defaultdatasourceconfig.md +1 -1
- package/docs/api/foundation-comms.defaulthttpconnect.getavailableresources.md +2 -2
- package/docs/api/foundation-comms.defaultsocket._constructor_.md +1 -2
- package/docs/api/foundation-comms.defaultsocket.connect.md +2 -2
- package/docs/api/foundation-comms.defaultsocket.md +1 -3
- package/docs/api/foundation-comms.eventmessagetype.md +0 -2
- package/docs/api/foundation-comms.md +2 -19
- package/docs/api/foundation-comms.socket.md +0 -6
- package/docs/api-report.md +25 -550
- package/package.json +12 -13
- package/dist/dts/datasource/datasource.config.d.ts +0 -44
- package/dist/dts/datasource/datasource.config.d.ts.map +0 -1
- package/dist/dts/datasource/datasource.mixins.d.ts +0 -367
- package/dist/dts/datasource/datasource.mixins.d.ts.map +0 -1
- package/dist/dts/resources/genesis/config.d.ts +0 -81
- package/dist/dts/resources/genesis/config.d.ts.map +0 -1
- package/dist/dts/resources/genesis/genesis.d.ts +0 -69
- package/dist/dts/resources/genesis/genesis.d.ts.map +0 -1
- package/dist/dts/resources/genesis/index.d.ts +0 -4
- package/dist/dts/resources/genesis/index.d.ts.map +0 -1
- package/dist/dts/resources/genesis/types.d.ts +0 -19
- package/dist/dts/resources/genesis/types.d.ts.map +0 -1
- package/dist/dts/resources/index.d.ts +0 -2
- package/dist/dts/resources/index.d.ts.map +0 -1
- package/dist/dts/testing/mocks/resources/genesis/genesis.d.ts +0 -16
- package/dist/dts/testing/mocks/resources/genesis/genesis.d.ts.map +0 -1
- package/dist/dts/testing/mocks/resources/genesis/index.d.ts +0 -2
- package/dist/dts/testing/mocks/resources/genesis/index.d.ts.map +0 -1
- package/dist/dts/testing/mocks/resources/index.d.ts +0 -2
- package/dist/dts/testing/mocks/resources/index.d.ts.map +0 -1
- package/dist/esm/datasource/datasource.config.js +0 -41
- package/dist/esm/datasource/datasource.mixins.js +0 -86
- package/dist/esm/resources/genesis/config.js +0 -51
- package/dist/esm/resources/genesis/genesis.js +0 -114
- package/dist/esm/resources/genesis/index.js +0 -3
- package/dist/esm/resources/genesis/types.js +0 -4
- package/dist/esm/resources/index.js +0 -1
- package/dist/esm/testing/mocks/resources/genesis/genesis.js +0 -25
- package/dist/esm/testing/mocks/resources/genesis/index.js +0 -1
- package/dist/esm/testing/mocks/resources/index.js +0 -1
- package/docs/api/foundation-comms.connect.host.md +0 -11
- package/docs/api/foundation-comms.datasourceconfig.eventemitter.md +0 -18
- package/docs/api/foundation-comms.datasourceeventhandler.md +0 -353
- package/docs/api/foundation-comms.datasourcemetadata.availableindexes.md +0 -11
- package/docs/api/foundation-comms.datasourcemetadata.fetchmetadatarequired.md +0 -11
- package/docs/api/foundation-comms.datasourcemetadata.fieldmetadata.md +0 -11
- package/docs/api/foundation-comms.datasourcemetadata.md +0 -24
- package/docs/api/foundation-comms.datasourcemetadata.originalfielddef.md +0 -11
- package/docs/api/foundation-comms.datasourcemetadata.requestfields.md +0 -11
- package/docs/api/foundation-comms.datasourcestatus.md +0 -21
- package/docs/api/foundation-comms.datasourcestatuschanged.md +0 -13
- package/docs/api/foundation-comms.datasourcestatuschangedevent.md +0 -15
- package/docs/api/foundation-comms.defaultconnect.host.md +0 -11
- package/docs/api/foundation-comms.defaultdatasource.fetchandapplymetadata.md +0 -22
- package/docs/api/foundation-comms.defaultdatasource.resources.md +0 -11
- package/docs/api/foundation-comms.defaultdatasource.status.md +0 -12
- package/docs/api/foundation-comms.defaultgenesisresources._constructor_.md +0 -21
- package/docs/api/foundation-comms.defaultgenesisresources.config.md +0 -11
- package/docs/api/foundation-comms.defaultgenesisresources.connect.md +0 -11
- package/docs/api/foundation-comms.defaultgenesisresources.destroy.md +0 -17
- package/docs/api/foundation-comms.defaultgenesisresources.getresources.md +0 -15
- package/docs/api/foundation-comms.defaultgenesisresources.getresourcetypefor.md +0 -24
- package/docs/api/foundation-comms.defaultgenesisresources.isvalidresource.md +0 -24
- package/docs/api/foundation-comms.defaultgenesisresources.md +0 -40
- package/docs/api/foundation-comms.defaultgenesisresources.postloadedmessage.md +0 -15
- package/docs/api/foundation-comms.defaultgenesisresources.resources.md +0 -11
- package/docs/api/foundation-comms.defaultgenesisresources.resourcespromise.md +0 -11
- package/docs/api/foundation-comms.defaultgenesisresourcesconfig.md +0 -13
- package/docs/api/foundation-comms.defaultsocket.config.md +0 -11
- package/docs/api/foundation-comms.defaultsocket.host.md +0 -11
- package/docs/api/foundation-comms.genesisresources.destroy.md +0 -13
- package/docs/api/foundation-comms.genesisresources.getresourcetypefor.md +0 -13
- package/docs/api/foundation-comms.genesisresources.isvalidresource.md +0 -13
- package/docs/api/foundation-comms.genesisresources.md +0 -26
- package/docs/api/foundation-comms.genesisresourceschannel.md +0 -33
- package/docs/api/foundation-comms.genesisresourceschannelid.md +0 -12
- package/docs/api/foundation-comms.genesisresourcesconfig.md +0 -21
- package/docs/api/foundation-comms.genesisresourcesconfig.throwwhenunavailable.md +0 -13
- package/docs/api/foundation-comms.genesisresourcesconfig.throwwhenunknown.md +0 -13
- package/docs/api/foundation-comms.genesisresourcesevents.md +0 -17
- package/docs/api/foundation-comms.genesisresourcesmock.destroy.md +0 -15
- package/docs/api/foundation-comms.genesisresourcesmock.getresourcetypefor.md +0 -24
- package/docs/api/foundation-comms.genesisresourcesmock.isvalidresource.md +0 -24
- package/docs/api/foundation-comms.genesisresourcesmock.md +0 -30
- package/docs/api/foundation-comms.genesisresourcesmock.nextisvalidresourceresponse.md +0 -11
- package/docs/api/foundation-comms.genesisresourcesmock.nextresourcetypeforresponse.md +0 -11
- package/docs/api/foundation-comms.genesisresourcesmock.resources.md +0 -11
- package/docs/api/foundation-comms.getgenesisresources.md +0 -30
- package/docs/api/foundation-comms.getgenesisresourceschannel.md +0 -39
- package/docs/api/foundation-comms.resourceitem.md +0 -15
- package/docs/api/foundation-comms.resourcesmessage.md +0 -18
- package/docs/api/foundation-comms.socket.host.md +0 -11
@@ -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 +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 +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 +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) > [@genesislcap/foundation-comms](./foundation-comms.md) > [Connect](./foundation-comms.connect.md) > [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) > [@genesislcap/foundation-comms](./foundation-comms.md) > [DatasourceConfig](./foundation-comms.datasourceconfig.md) > [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
|
-
|