@genesislcap/foundation-comms 14.199.2-alpha-0c81553.0 → 14.199.2

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