@genesislcap/foundation-comms 14.200.1-alpha-eb310c6.0 → 14.200.1-alpha-599cb19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/dist/dts/connect/connect.d.ts +3 -4
  2. package/dist/dts/connect/connect.d.ts.map +1 -1
  3. package/dist/dts/connect/message.d.ts +5 -14
  4. package/dist/dts/connect/message.d.ts.map +1 -1
  5. package/dist/dts/datasource/datasource.d.ts +16 -21
  6. package/dist/dts/datasource/datasource.d.ts.map +1 -1
  7. package/dist/dts/datasource/datasource.types.d.ts +17 -37
  8. package/dist/dts/datasource/datasource.types.d.ts.map +1 -1
  9. package/dist/dts/metadata/metadata.types.d.ts +1 -23
  10. package/dist/dts/metadata/metadata.types.d.ts.map +1 -1
  11. package/dist/dts/testing/mocks/datasource/datasource.d.ts +2 -4
  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 +1 -2
  15. package/dist/esm/datasource/datasource.js +32 -63
  16. package/dist/esm/metadata/metadata.utils.js +1 -2
  17. package/dist/esm/testing/mocks/datasource/datasource.js +2 -14
  18. package/dist/foundation-comms.api.json +93 -510
  19. package/dist/foundation-comms.d.ts +44 -105
  20. package/docs/api/foundation-comms.connect.getmorerows.md +2 -3
  21. package/docs/api/foundation-comms.connect.md +1 -1
  22. package/docs/api/{foundation-comms.datasource.startstream.md → foundation-comms.datasource.deinit.md} +9 -5
  23. package/docs/api/foundation-comms.datasource.destroy.md +1 -5
  24. package/docs/api/foundation-comms.datasource.init.md +1 -2
  25. package/docs/api/foundation-comms.datasource.md +4 -4
  26. package/docs/api/foundation-comms.datasource.snapshot.md +3 -3
  27. package/docs/api/foundation-comms.datasource.snapshotfiltered.md +2 -2
  28. package/docs/api/foundation-comms.datasource.validresourcename.md +0 -5
  29. package/docs/api/foundation-comms.datasourcemetadata.md +0 -1
  30. package/docs/api/foundation-comms.datasourceoptions.criteria.md +0 -5
  31. package/docs/api/foundation-comms.datasourceoptions.disablepolling.md +0 -5
  32. package/docs/api/foundation-comms.datasourceoptions.fields.md +0 -5
  33. package/docs/api/foundation-comms.datasourceoptions.maxrows.md +0 -5
  34. package/docs/api/foundation-comms.datasourceoptions.maxview.md +0 -5
  35. package/docs/api/foundation-comms.datasourceoptions.md +0 -2
  36. package/docs/api/foundation-comms.datasourceoptions.movingview.md +0 -5
  37. package/docs/api/foundation-comms.datasourceoptions.orderby.md +0 -5
  38. package/docs/api/foundation-comms.datasourceoptions.request.md +0 -5
  39. package/docs/api/foundation-comms.datasourceoptions.reverse.md +0 -5
  40. package/docs/api/foundation-comms.defaultconnect.getmorerows.md +1 -2
  41. package/docs/api/foundation-comms.defaultconnect.md +1 -1
  42. package/docs/api/{foundation-comms.defaultdatasource.startstream.md → foundation-comms.defaultdatasource.deinit.md} +4 -4
  43. package/docs/api/foundation-comms.defaultdatasource.destroy.md +1 -5
  44. package/docs/api/foundation-comms.defaultdatasource.init.md +1 -2
  45. package/docs/api/foundation-comms.defaultdatasource.md +4 -6
  46. package/docs/api/foundation-comms.defaultdatasource.snapshot.md +1 -8
  47. package/docs/api/foundation-comms.defaultmessagebuilder.createmorerowsmessage.md +2 -3
  48. package/docs/api/foundation-comms.defaultmessagebuilder.md +1 -1
  49. package/docs/api/foundation-comms.md +0 -2
  50. package/docs/api/foundation-comms.messagebuilder.createmorerowsmessage.md +3 -4
  51. package/docs/api/foundation-comms.messagebuilder.createrequestmessage.md +2 -2
  52. package/docs/api/foundation-comms.messagebuilder.md +1 -1
  53. package/docs/api/foundation-comms.messagedetails.morerows.md +0 -1
  54. package/docs/api/foundation-comms.metadata.md +2 -5
  55. package/docs/api/foundation-comms.metadatadetail.md +0 -3
  56. package/docs/api/foundation-comms.requestparams.md +1 -3
  57. package/docs/api/foundation-comms.requestserverresult.md +0 -5
  58. package/docs/api-report.md +17 -59
  59. package/package.json +13 -13
  60. package/docs/api/foundation-comms.datasourcemetadata.customrequestfields.md +0 -11
  61. package/docs/api/foundation-comms.datasourceoptions.requestautosetup.md +0 -18
  62. package/docs/api/foundation-comms.datasourceoptions.viewnumber.md +0 -18
  63. package/docs/api/foundation-comms.defaultdatasource.customrequestfields.md +0 -12
  64. package/docs/api/foundation-comms.defaultdatasource.startstreamrequired.md +0 -12
  65. package/docs/api/foundation-comms.replydetail.md +0 -21
  66. 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, startStream = this.startStreamRequired) {
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 && startStream) {
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 ? `was successful.` : 'has failed.'}`);
82
+ logger.debug(`${resourceName} datasource initialization ${this.initialized ? `success` : 'failed'}`);
87
83
  this.reportStatus();
88
84
  return this.initialized;
89
85
  });
90
86
  }
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() {
87
+ deinit() {
100
88
  var _a;
101
- logger.debug('Datasource.destroy', (_a = this.options) === null || _a === void 0 ? void 0 : _a.resourceName);
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
- this.stream = undefined;
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(overrideParams) {
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, Object.assign(Object.assign({}, this.params), overrideParams));
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
- CRITERIA_MATCH: DETAILS.CRITERIA_MATCH,
155
- MAX_ROWS: DETAILS.MAX_ROWS,
156
- VIEW_NUMBER: DETAILS.VIEW_NUMBER,
157
- },
158
- REQUEST,
143
+ DETAILS,
144
+ REQUEST: requestFields,
159
145
  };
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));
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 || ((_a = metadata.REPLY) === null || _a === void 0 ? void 0 : _a.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
- return Promise.resolve(null);
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);