@genesislcap/foundation-comms 14.200.1-alpha-eb310c6.0 → 14.200.1-alpha-e974201.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/dts/connect/connect.d.ts +3 -4
- package/dist/dts/connect/connect.d.ts.map +1 -1
- package/dist/dts/connect/message.d.ts +5 -14
- package/dist/dts/connect/message.d.ts.map +1 -1
- package/dist/dts/datasource/datasource.d.ts +16 -21
- package/dist/dts/datasource/datasource.d.ts.map +1 -1
- package/dist/dts/datasource/datasource.types.d.ts +17 -37
- package/dist/dts/datasource/datasource.types.d.ts.map +1 -1
- package/dist/dts/metadata/metadata.types.d.ts +1 -23
- package/dist/dts/metadata/metadata.types.d.ts.map +1 -1
- package/dist/dts/testing/mocks/datasource/datasource.d.ts +2 -4
- package/dist/dts/testing/mocks/datasource/datasource.d.ts.map +1 -1
- package/dist/esm/connect/connect.js +2 -2
- package/dist/esm/connect/message.js +1 -2
- package/dist/esm/datasource/datasource.js +32 -63
- package/dist/esm/metadata/metadata.utils.js +1 -2
- package/dist/esm/testing/mocks/datasource/datasource.js +2 -14
- package/dist/foundation-comms.api.json +93 -510
- package/dist/foundation-comms.d.ts +44 -105
- package/docs/api/foundation-comms.connect.getmorerows.md +2 -3
- package/docs/api/foundation-comms.connect.md +1 -1
- package/docs/api/{foundation-comms.datasource.startstream.md → foundation-comms.datasource.deinit.md} +9 -5
- package/docs/api/foundation-comms.datasource.destroy.md +1 -5
- package/docs/api/foundation-comms.datasource.init.md +1 -2
- package/docs/api/foundation-comms.datasource.md +4 -4
- package/docs/api/foundation-comms.datasource.snapshot.md +3 -3
- package/docs/api/foundation-comms.datasource.snapshotfiltered.md +2 -2
- package/docs/api/foundation-comms.datasource.validresourcename.md +0 -5
- package/docs/api/foundation-comms.datasourcemetadata.md +0 -1
- package/docs/api/foundation-comms.datasourceoptions.criteria.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.disablepolling.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.fields.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.maxrows.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.maxview.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.md +0 -2
- package/docs/api/foundation-comms.datasourceoptions.movingview.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.orderby.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.request.md +0 -5
- package/docs/api/foundation-comms.datasourceoptions.reverse.md +0 -5
- package/docs/api/foundation-comms.defaultconnect.getmorerows.md +1 -2
- package/docs/api/foundation-comms.defaultconnect.md +1 -1
- package/docs/api/{foundation-comms.defaultdatasource.startstream.md → foundation-comms.defaultdatasource.deinit.md} +4 -4
- package/docs/api/foundation-comms.defaultdatasource.destroy.md +1 -5
- package/docs/api/foundation-comms.defaultdatasource.init.md +1 -2
- package/docs/api/foundation-comms.defaultdatasource.md +4 -6
- package/docs/api/foundation-comms.defaultdatasource.snapshot.md +1 -8
- package/docs/api/foundation-comms.defaultmessagebuilder.createmorerowsmessage.md +2 -3
- package/docs/api/foundation-comms.defaultmessagebuilder.md +1 -1
- package/docs/api/foundation-comms.md +0 -2
- package/docs/api/foundation-comms.messagebuilder.createmorerowsmessage.md +3 -4
- package/docs/api/foundation-comms.messagebuilder.createrequestmessage.md +2 -2
- package/docs/api/foundation-comms.messagebuilder.md +1 -1
- package/docs/api/foundation-comms.messagedetails.morerows.md +0 -1
- package/docs/api/foundation-comms.metadata.md +2 -5
- package/docs/api/foundation-comms.metadatadetail.md +0 -3
- package/docs/api/foundation-comms.requestparams.md +1 -3
- package/docs/api/foundation-comms.requestserverresult.md +0 -5
- package/docs/api-report.md +17 -59
- package/package.json +13 -13
- package/docs/api/foundation-comms.datasourcemetadata.customrequestfields.md +0 -11
- package/docs/api/foundation-comms.datasourceoptions.requestautosetup.md +0 -18
- package/docs/api/foundation-comms.datasourceoptions.viewnumber.md +0 -18
- package/docs/api/foundation-comms.defaultdatasource.customrequestfields.md +0 -12
- package/docs/api/foundation-comms.defaultdatasource.startstreamrequired.md +0 -12
- package/docs/api/foundation-comms.replydetail.md +0 -21
- package/docs/api/foundation-comms.requestdetailsparam.md +0 -15
@@ -27,16 +27,12 @@ let DefaultDatasource = class DefaultDatasource {
|
|
27
27
|
this.config = config;
|
28
28
|
/** {@inheritDoc DatasourceMetadata.fetchMetadataRequired} */
|
29
29
|
this.fetchMetadataRequired = true;
|
30
|
-
/** {@inheritDoc DatasourceMetadata.startStream} */
|
31
|
-
this.startStreamRequired = true;
|
32
30
|
/** {@inheritDoc DatasourceMetadata.originalFieldDef} */
|
33
31
|
this.originalFieldDef = [];
|
34
32
|
/** {@inheritDoc DatasourceMetadata.fieldMetadata} */
|
35
33
|
this.fieldMetadata = [];
|
36
34
|
/** {@inheritDoc DatasourceMetadata.requestFields} */
|
37
35
|
this.requestFields = [];
|
38
|
-
/** {@inheritDoc DatasourceMetadata.customRequestFields} */
|
39
|
-
this.customRequestFields = [];
|
40
36
|
/** {@inheritDoc DatasourceMetadata.availableIndexes} */
|
41
37
|
this.availableIndexes = [];
|
42
38
|
this.readOnly = true;
|
@@ -53,7 +49,7 @@ let DefaultDatasource = class DefaultDatasource {
|
|
53
49
|
// additional checks? regex? or maybe we can ask the server if it's a valid resource in the future
|
54
50
|
return true;
|
55
51
|
}
|
56
|
-
init(options, fetchMeta = this.fetchMetadataRequired
|
52
|
+
init(options, fetchMeta = this.fetchMetadataRequired) {
|
57
53
|
return __awaiter(this, void 0, void 0, function* () {
|
58
54
|
this.fetchMetadataRequired = fetchMeta;
|
59
55
|
this.options = Object.assign(Object.assign({}, this.config.options), options);
|
@@ -77,28 +73,20 @@ let DefaultDatasource = class DefaultDatasource {
|
|
77
73
|
return false;
|
78
74
|
}
|
79
75
|
logger.debug(`Initializing ${resourceName} datasource from ${this.connect.host}`);
|
80
|
-
if (!this.options.isSnapshot
|
76
|
+
if (!this.options.isSnapshot) {
|
81
77
|
this.stream = yield this.createStream();
|
82
78
|
}
|
83
79
|
if (this.fetchMetadataRequired) {
|
84
80
|
yield this.fetchAndApplyMetadata(this.options.resourceName);
|
85
81
|
}
|
86
|
-
logger.debug(`${resourceName} datasource initialization ${this.initialized ? `
|
82
|
+
logger.debug(`${resourceName} datasource initialization ${this.initialized ? `success` : 'failed'}`);
|
87
83
|
this.reportStatus();
|
88
84
|
return this.initialized;
|
89
85
|
});
|
90
86
|
}
|
91
|
-
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
93
|
-
if (!this.options.isSnapshot && this.stream === undefined) {
|
94
|
-
this.stream = yield this.createStream();
|
95
|
-
}
|
96
|
-
});
|
97
|
-
}
|
98
|
-
/** {@inheritDoc Datasource.destroy} */
|
99
|
-
destroy() {
|
87
|
+
deinit() {
|
100
88
|
var _a;
|
101
|
-
logger.debug('Datasource.
|
89
|
+
logger.debug('Datasource.deinit', (_a = this.options) === null || _a === void 0 ? void 0 : _a.resourceName);
|
102
90
|
this.status = undefined;
|
103
91
|
this.fetchMetadataRequired = undefined;
|
104
92
|
this.options = {};
|
@@ -107,67 +95,55 @@ let DefaultDatasource = class DefaultDatasource {
|
|
107
95
|
this.originalFieldDef = [];
|
108
96
|
this.fieldMetadata = [];
|
109
97
|
this.requestFields = [];
|
110
|
-
|
98
|
+
}
|
99
|
+
/** {@inheritDoc Datasource.destroy} */
|
100
|
+
destroy() {
|
101
|
+
var _a;
|
102
|
+
logger.debug('Datasource.destroy', (_a = this.options) === null || _a === void 0 ? void 0 : _a.resourceName);
|
103
|
+
this.deinit();
|
104
|
+
delete this.stream;
|
105
|
+
this.status = undefined;
|
111
106
|
}
|
112
107
|
get params() {
|
113
108
|
var _a;
|
114
|
-
let ORDER_BY;
|
115
|
-
if (this.options.orderBy) {
|
116
|
-
if (((_a = this.availableIndexes) === null || _a === void 0 ? void 0 : _a.findIndex((i) => i.NAME === this.options.orderBy)) > -1) {
|
117
|
-
ORDER_BY = this.options.orderBy;
|
118
|
-
}
|
119
|
-
else {
|
120
|
-
const validIndexes = this.availableIndexes.map((index) => index.NAME);
|
121
|
-
logger.warn('Specified [orderBy] index is not valid and will not be used. See https://learn.genesis.global/docs/database/data-types/index-entities/ - Available indexes:', validIndexes);
|
122
|
-
}
|
123
|
-
}
|
124
109
|
const params = {
|
125
|
-
// Common between DATASERVER and REQUEST_SERVER (REQ-REP)
|
126
110
|
CRITERIA_MATCH: this.options.criteria,
|
127
|
-
MAX_ROWS: this.options.maxRows,
|
128
|
-
VIEW_NUMBER: this.options.viewNumber,
|
129
|
-
// DATASERVER only
|
130
111
|
FIELDS: this.options.fields,
|
112
|
+
MAX_ROWS: this.options.maxRows,
|
131
113
|
MAX_VIEW: this.options.maxView,
|
132
114
|
MOVING_VIEW: this.options.movingView,
|
133
|
-
ORDER_BY,
|
134
|
-
REVERSE: this.options.reverse,
|
135
|
-
// REQUEST_SERVER only
|
136
|
-
DISABLE_POLLING: this.options.disablePolling,
|
137
115
|
POLLING_INTERVAL: this.options.pollingInterval,
|
116
|
+
DISABLE_POLLING: this.options.disablePolling,
|
138
117
|
REQUEST: this.options.request,
|
118
|
+
REVERSE: this.options.reverse,
|
139
119
|
};
|
120
|
+
if (this.options.orderBy) {
|
121
|
+
if (((_a = this.availableIndexes) === null || _a === void 0 ? void 0 : _a.findIndex((i) => i.NAME === this.options.orderBy)) > -1) {
|
122
|
+
params.ORDER_BY = this.options.orderBy;
|
123
|
+
}
|
124
|
+
else {
|
125
|
+
const validIndexes = this.availableIndexes.map((index) => index.NAME);
|
126
|
+
logger.warn('Specified [orderBy] index is not valid and will not be used. See https://learn.genesis.global/docs/database/data-types/index-entities/ - Available indexes:', validIndexes);
|
127
|
+
}
|
128
|
+
}
|
140
129
|
logger.debug('Getting configured params:', params);
|
141
130
|
return params;
|
142
131
|
}
|
143
|
-
snapshot(
|
132
|
+
snapshot() {
|
144
133
|
var _a;
|
145
134
|
return __awaiter(this, void 0, void 0, function* () {
|
146
135
|
logger.debug(`Requesting snapshot for ${this.options.resourceName} (${this.resourceType}).`);
|
147
136
|
switch (this.resourceType) {
|
148
137
|
case ResourceType.DATASERVER:
|
149
|
-
return this.connect.snapshot(this.options.resourceName,
|
138
|
+
return this.connect.snapshot(this.options.resourceName, this.params);
|
150
139
|
case ResourceType.REQUEST_SERVER: {
|
151
|
-
const _b = this.params, { REQUEST } = _b, DETAILS = __rest(_b, ["REQUEST"]);
|
140
|
+
const _b = this.params, { REQUEST, CRITERIA_MATCH } = _b, DETAILS = __rest(_b, ["REQUEST", "CRITERIA_MATCH"]);
|
141
|
+
const requestFields = Object.assign(Object.assign(Object.assign({}, Object.fromEntries(this.requestFields.map((rf) => [rf.NAME, '*']))), this.params.REQUEST), (((_a = this === null || this === void 0 ? void 0 : this.options) === null || _a === void 0 ? void 0 : _a.criteria) ? this.config.criteriaToFields(this.options.criteria) : {}));
|
152
142
|
const reqParams = {
|
153
|
-
DETAILS
|
154
|
-
|
155
|
-
MAX_ROWS: DETAILS.MAX_ROWS,
|
156
|
-
VIEW_NUMBER: DETAILS.VIEW_NUMBER,
|
157
|
-
},
|
158
|
-
REQUEST,
|
143
|
+
DETAILS,
|
144
|
+
REQUEST: requestFields,
|
159
145
|
};
|
160
|
-
|
161
|
-
if (this.options.requestAutoSetup) {
|
162
|
-
reqParams.REQUEST = Object.assign(Object.assign({}, Object.fromEntries(this.requestFields.map((rf) => [rf.NAME, '*']))), (((_a = this === null || this === void 0 ? void 0 : this.options) === null || _a === void 0 ? void 0 : _a.criteria)
|
163
|
-
? this.config.criteriaToFields(this.options.criteria)
|
164
|
-
: {}));
|
165
|
-
}
|
166
|
-
else {
|
167
|
-
reqParams.REQUEST = {};
|
168
|
-
}
|
169
|
-
}
|
170
|
-
return this.connect.request(this.options.resourceName, Object.assign(Object.assign({}, reqParams), overrideParams));
|
146
|
+
return this.connect.request(this.options.resourceName, reqParams);
|
171
147
|
}
|
172
148
|
default:
|
173
149
|
throw new Error(`Snapshot not supported for selected resource type: ${this.resourceType}`);
|
@@ -227,7 +203,6 @@ let DefaultDatasource = class DefaultDatasource {
|
|
227
203
|
this.originalFieldDef = extractFieldDefinitions(meta);
|
228
204
|
this.fieldMetadata = toFieldMetadata(this.originalFieldDef);
|
229
205
|
this.requestFields = meta.REQUEST_FIELD || [];
|
230
|
-
this.customRequestFields = meta.FIELD || [];
|
231
206
|
this.fetchMetadataRequired = false;
|
232
207
|
}
|
233
208
|
this.status = this.normaliseStatus({
|
@@ -283,9 +258,6 @@ __decorate([
|
|
283
258
|
__decorate([
|
284
259
|
observable
|
285
260
|
], DefaultDatasource.prototype, "fetchMetadataRequired", void 0);
|
286
|
-
__decorate([
|
287
|
-
observable
|
288
|
-
], DefaultDatasource.prototype, "startStreamRequired", void 0);
|
289
261
|
__decorate([
|
290
262
|
observable
|
291
263
|
], DefaultDatasource.prototype, "originalFieldDef", void 0);
|
@@ -295,9 +267,6 @@ __decorate([
|
|
295
267
|
__decorate([
|
296
268
|
observable
|
297
269
|
], DefaultDatasource.prototype, "requestFields", void 0);
|
298
|
-
__decorate([
|
299
|
-
observable
|
300
|
-
], DefaultDatasource.prototype, "customRequestFields", void 0);
|
301
270
|
__decorate([
|
302
271
|
observable
|
303
272
|
], DefaultDatasource.prototype, "availableIndexes", void 0);
|
@@ -36,13 +36,12 @@ export const toFieldMetadata = (fieldDef) => {
|
|
36
36
|
* @returns An array of metadata detail.
|
37
37
|
*/
|
38
38
|
export const extractFieldDefinitions = (metadata) => {
|
39
|
-
var _a;
|
40
39
|
const type = metadata === null || metadata === void 0 ? void 0 : metadata.TYPE;
|
41
40
|
if (type === ResourceType.DATASERVER) {
|
42
41
|
return metadata.FIELD || [];
|
43
42
|
}
|
44
43
|
if (type === ResourceType.REQUEST_SERVER) {
|
45
|
-
return metadata.REPLY_FIELD ||
|
44
|
+
return metadata.REPLY_FIELD || [];
|
46
45
|
}
|
47
46
|
throw new Error(`Unsupported resource type: ${type}`);
|
48
47
|
};
|
@@ -12,15 +12,11 @@ export class DatasourceMock {
|
|
12
12
|
this.originalFieldDef = [];
|
13
13
|
this.fieldMetadata = [];
|
14
14
|
this.requestFields = [];
|
15
|
-
this.customRequestFields = [];
|
16
15
|
this.availableIndexes = [];
|
17
16
|
}
|
18
17
|
init(options, fetchMeta) {
|
19
18
|
return Promise.resolve(this.initialized);
|
20
19
|
}
|
21
|
-
startStream() {
|
22
|
-
return Promise.resolve();
|
23
|
-
}
|
24
20
|
/**
|
25
21
|
* Convenience method to avoid you having to prime connect etc.
|
26
22
|
* @param meta - The metadata to set.
|
@@ -31,7 +27,6 @@ export class DatasourceMock {
|
|
31
27
|
this.originalFieldDef = extractFieldDefinitions(meta);
|
32
28
|
this.fieldMetadata = toFieldMetadata(this.originalFieldDef);
|
33
29
|
this.requestFields = meta.REQUEST_FIELD || [];
|
34
|
-
this.customRequestFields = meta.FIELD || [];
|
35
30
|
this.fetchMetadataRequired = false;
|
36
31
|
}
|
37
32
|
unsetMedata() {
|
@@ -63,12 +58,8 @@ export class DatasourceMock {
|
|
63
58
|
getMetadata(resourceName) {
|
64
59
|
return Promise.resolve(this.fieldMetadata);
|
65
60
|
}
|
66
|
-
snapshot(params) {
|
67
|
-
|
68
|
-
}
|
69
|
-
snapshotFiltered(rowId) {
|
70
|
-
return Promise.resolve(null);
|
71
|
-
}
|
61
|
+
snapshot(params) { }
|
62
|
+
snapshotFiltered(rowId) { }
|
72
63
|
updateData(data) {
|
73
64
|
return Promise.resolve();
|
74
65
|
}
|
@@ -108,9 +99,6 @@ __decorate([
|
|
108
99
|
__decorate([
|
109
100
|
observable
|
110
101
|
], DatasourceMock.prototype, "requestFields", void 0);
|
111
|
-
__decorate([
|
112
|
-
observable
|
113
|
-
], DatasourceMock.prototype, "customRequestFields", void 0);
|
114
102
|
__decorate([
|
115
103
|
observable
|
116
104
|
], DatasourceMock.prototype, "availableIndexes", void 0);
|