@genesislcap/foundation-comms 14.199.1 → 14.199.2-alpha-6f7195d.0

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