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