heimdall-api-platform 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/clients/http-client.js +1 -0
  2. package/dist/commons-cache.js +1 -0
  3. package/dist/commons-const.js +1 -0
  4. package/dist/commons-elasticsearch.js +1 -0
  5. package/dist/commons-errors.js +1 -0
  6. package/dist/commons-opensearch.js +1 -0
  7. package/dist/commons-splunk.js +1 -0
  8. package/dist/commons-util.js +1 -0
  9. package/dist/default-routes-docs.js +1 -0
  10. package/dist/default-routes-pos.js +1 -0
  11. package/dist/default-routes-pre.js +1 -0
  12. package/dist/environment.js +1 -0
  13. package/dist/factory/api-gateway.js +1 -0
  14. package/dist/factory/client-factory.js +1 -0
  15. package/dist/factory/function-factory.js +1 -0
  16. package/dist/factory/operation-flow-factory.js +1 -0
  17. package/dist/factory/server-factory.js +1 -0
  18. package/dist/factory/transformation-function-factory.js +1 -0
  19. package/dist/handle-route.js +1 -0
  20. package/dist/index.js +2 -0
  21. package/dist/jwt-util.js +1 -0
  22. package/dist/license/license-service.js +1 -0
  23. package/dist/models/base-context.js +1 -0
  24. package/dist/models/elastic-index-data.js +1 -0
  25. package/dist/models/flow-context.js +1 -0
  26. package/dist/models/flow-indexed.js +1 -0
  27. package/dist/models/operation-function-indexed.js +1 -0
  28. package/dist/models/operation-function-transformation-indexed.js +1 -0
  29. package/dist/models/operation-http-indexed.js +1 -0
  30. package/dist/models/operation-mock-indexed.js +1 -0
  31. package/dist/models/route-context.js +1 -0
  32. package/dist/models/security-route.js +1 -0
  33. package/dist/models/service-context.js +1 -0
  34. package/dist/models/service-group.js +1 -0
  35. package/dist/models/service-route.js +1 -0
  36. package/dist/models/splunk-data.js +1 -0
  37. package/dist/operations/abstract-operation.js +1 -0
  38. package/dist/operations/function.js +1 -0
  39. package/dist/operations/http.js +1 -0
  40. package/dist/operations/mock.js +1 -0
  41. package/dist/operations/monitor-check.js +1 -0
  42. package/dist/orchestration-flow.js +1 -0
  43. package/dist/router.js +1 -0
  44. package/dist/security-validation.js +1 -0
  45. package/dist/services/server.js +1 -0
  46. package/dist/services/template-monitorcheck-route.js +1 -0
  47. package/package.json +5 -5
  48. package/lib/clients/http-client.js +0 -296
  49. package/lib/commons-cache.js +0 -185
  50. package/lib/commons-const.js +0 -203
  51. package/lib/commons-elasticsearch.js +0 -49
  52. package/lib/commons-errors.js +0 -278
  53. package/lib/commons-opensearch.js +0 -37
  54. package/lib/commons-splunk.js +0 -105
  55. package/lib/commons-util.js +0 -669
  56. package/lib/default-routes-docs.js +0 -141
  57. package/lib/default-routes-pos.js +0 -111
  58. package/lib/default-routes-pre.js +0 -151
  59. package/lib/environment.js +0 -81
  60. package/lib/factory/api-gateway.js +0 -12
  61. package/lib/factory/client-factory.js +0 -41
  62. package/lib/factory/function-factory.js +0 -40
  63. package/lib/factory/operation-flow-factory.js +0 -64
  64. package/lib/factory/server-factory.js +0 -15
  65. package/lib/factory/transformation-function-factory.js +0 -47
  66. package/lib/handle-route.js +0 -472
  67. package/lib/index.js +0 -50
  68. package/lib/jwt-util.js +0 -38
  69. package/lib/license/license-service.js +0 -27
  70. package/lib/models/base-context.js +0 -77
  71. package/lib/models/elastic-index-data.js +0 -76
  72. package/lib/models/flow-context.js +0 -58
  73. package/lib/models/flow-indexed.js +0 -62
  74. package/lib/models/operation-function-indexed.js +0 -22
  75. package/lib/models/operation-function-transformation-indexed.js +0 -23
  76. package/lib/models/operation-http-indexed.js +0 -38
  77. package/lib/models/operation-mock-indexed.js +0 -22
  78. package/lib/models/route-context.js +0 -69
  79. package/lib/models/security-route.js +0 -41
  80. package/lib/models/service-context.js +0 -65
  81. package/lib/models/service-group.js +0 -15
  82. package/lib/models/service-route.js +0 -23
  83. package/lib/models/splunk-data.js +0 -70
  84. package/lib/operations/abstract-operation.js +0 -73
  85. package/lib/operations/function.js +0 -143
  86. package/lib/operations/http.js +0 -286
  87. package/lib/operations/mock.js +0 -34
  88. package/lib/operations/monitor-check.js +0 -151
  89. package/lib/orchestration-flow.js +0 -323
  90. package/lib/public/redoc.html +0 -152
  91. package/lib/public/swagger.html +0 -143
  92. package/lib/router.js +0 -29
  93. package/lib/security-validation.js +0 -46
  94. package/lib/services/server.js +0 -211
  95. package/lib/services/template-monitorcheck-route.js +0 -61
@@ -1,669 +0,0 @@
1
- "use strict";
2
- const { createLogger, format, transports } = require("winston");
3
- const { combine, timestamp, label, printf, colorize } = format;
4
- const os = require("os");
5
- const axios = require("axios");
6
-
7
- let publicIp = "Fetching..."; // Placeholder until we fetch the actual public IP
8
-
9
- // Fetch the public IP asynchronously
10
- (async function fetchPublicIp() {
11
- try {
12
- const response = await axios.get("https://api.ipify.org?format=json");
13
- publicIp = response.data.ip;
14
- } catch (error) {
15
- console.error("Error fetching public IP:", error.message);
16
- publicIp = "Unavailable"; // Fallback if the fetch fails
17
- }
18
- })();
19
-
20
- // Helper function to get local IP address
21
- function getLocalIp() {
22
- const interfaces = os.networkInterfaces();
23
- for (const interfaceName in interfaces) {
24
- const iface = interfaces[interfaceName];
25
- for (const alias of iface) {
26
- if (alias.family === "IPv4" && !alias.internal) {
27
- return alias.address; // Return the first non-internal IPv4 address
28
- }
29
- }
30
- }
31
- return "127.0.0.1"; // Default fallback to localhost
32
- }
33
-
34
- const localIp = getLocalIp();
35
-
36
- const loggingFormat = printf(({ level, message, label, timestamp }) => {
37
- return `dateTime=${timestamp} appName=${label} env=${process.env.NODE_ENV} machine=${os.hostname()} ip=${localIp} publicIp=${publicIp} os=${process.platform} level=${level} ${message}`;
38
- });
39
-
40
- const _ = require("underscore");
41
- const environment = require("./environment");
42
- const hash = require("object-hash");
43
- const crypto = require("crypto");
44
-
45
- var Util = function () { };
46
-
47
- const Colors = {
48
- info: "\x1b[36m",
49
- error: "\x1b[31m",
50
- warn: "\x1b[33m",
51
- verbose: "\x1b[43m",
52
- end: "\x1b[0m",
53
- };
54
-
55
- Util.config = {
56
- logger: environment.application.logger,
57
- applicationName: environment.application.appName || "NO NAME",
58
- machineHostName: os.hostname(),
59
- env: process.env.NODE_ENV,
60
- os: process.platform,
61
- stringify: {
62
- // If > 0 will truncate string values at this length
63
- truncationLength: 0,
64
-
65
- // Same list as com.vcmais.commons.utils.ToStringBuilder.EXCLUDE_FIELD_NAMES (commons-util project)
66
- // Case INsensitive. Can be a RegEx pattern (for example (new)?Password would match "password" and "newPassword")
67
- exclusions: [
68
- "accessKeyId",
69
- "secretAccessKey",
70
- "cpf",
71
- "pin",
72
- "password",
73
- "newPassword",
74
- "confirmPassword",
75
- "cvv",
76
- "cardKey",
77
- "encKey",
78
- "encPaymentData",
79
- "encryptionKey",
80
- "publicKey",
81
- "fingerprintKey",
82
- "accessToken",
83
- "file",
84
- "icon",
85
- "background",
86
- "photo",
87
- "Authorization",
88
- "cardNumber",
89
- "number",
90
- "pan",
91
- "taxId"
92
- ],
93
-
94
- // If this field have a value, use it instead of whatever came along any of the fields above.
95
- // For example: { password: "xpto" } --> { "password": "**********" } (in case excludedKeyValue have its default value)
96
- excludedKeyValue: "***",
97
- },
98
- };
99
-
100
- Util.getLogger = function () {
101
- if (typeof this.logger !== "undefined") {
102
- return this.logger;
103
- } else {
104
- return Util.configureLogger();
105
- }
106
- };
107
-
108
- function jsonToMap(options) {
109
- if (options !== null && options !== undefined) {
110
- var dataMap = new Map(Object.entries(options));
111
-
112
- var resultString = "";
113
-
114
- for (const key of dataMap.keys()) {
115
- resultString += key + "=" + dataMap.get(key) + " ";
116
- }
117
-
118
- return resultString;
119
- }
120
- }
121
-
122
- function _printLog(level, message, options) {
123
- let messageFinal = message;
124
-
125
- if (options !== null && options !== undefined) {
126
- messageFinal += " " + JSON.stringify(options || {}, null, 2) || "";
127
- }
128
-
129
- Util.getLogger().log(level, messageFinal);
130
- }
131
-
132
- Util.configureLogger = function () {
133
- this.logger = createLogger({
134
- format: combine(label({ label: Util.config.applicationName }), timestamp(), loggingFormat),
135
- transports: [
136
- new transports.Console({
137
- name: Util.config.logger.Console.name,
138
- format: format.splat(),
139
- level: Util.config.logger.Console.level || "info",
140
- }),
141
- ],
142
- defaultMeta: { service: Util.config.applicationName },
143
- });
144
-
145
- return this.logger;
146
- };
147
-
148
- Util.log = function () {
149
- var self = this;
150
-
151
- try {
152
- var message = Array.prototype.slice.call(arguments).join(" ");
153
- Util.info(message);
154
- } catch (error) {
155
- try {
156
- Util.getLogger().log(error === null ? "Error" : error.message || error, {
157
- env: self.config.env,
158
- machine: self.config.machineHostName,
159
- layer: self.config.applicationName,
160
- stackTrace: error !== null ? Util.getErrorStack(error) : null,
161
- });
162
- } catch (error) { }
163
- }
164
- };
165
-
166
- Util.getErrorStack = function (error) {
167
- var errorStack = error.stack || error.message || error;
168
-
169
- if (error.cause) {
170
- errorStack += "\n" + Util.getErrorStack(error.cause);
171
- }
172
-
173
- return errorStack;
174
- };
175
-
176
- Util.debug = function (message, options) {
177
- _printLog("debug", message, options);
178
- };
179
-
180
- Util.warning = function (message, options) {
181
- _printLog("warn", message, options);
182
- };
183
-
184
- Util.warn = function (message, options) {
185
- _printLog("warn", message, options);
186
- };
187
-
188
- Util.info = function (message, options) {
189
- _printLog("info", message, options);
190
- };
191
-
192
- Util.error = function (message, options) {
193
- _printLog("error", message, options);
194
- };
195
-
196
- Util.throwErrorIfItExists = function (error) {
197
- if (error) {
198
- //Executando o throw o Step pula pro próximo FLOW
199
- //Util.error(error);
200
- throw error;
201
- }
202
- };
203
-
204
- Util.encodeHexStringToBase64 = function (string) {
205
- return new Buffer(string, "hex").toString("base64");
206
- };
207
-
208
- Util.encodeBufferToBase64 = function (buffer) {
209
- return buffer.toString("base64");
210
- };
211
-
212
- Util.decodeBase64ToBuffer = function (string) {
213
- return new Buffer(string, "base64");
214
- };
215
-
216
- Util.decodeBase64ToHex = function (string) {
217
- return new Buffer(string, "base64").toString("hex");
218
- };
219
-
220
- Util.encodeBase64 = function (string) {
221
- return new Buffer(string).toString("base64");
222
- };
223
-
224
- Util.decodeBase64 = function (string) {
225
- return new Buffer(string, "base64").toString("ascii");
226
- };
227
-
228
- Util.format = function (str) {
229
- var args = [].slice.call(arguments, 1);
230
-
231
- return str.replace(/%s/g, function () {
232
- return args.shift();
233
- });
234
- };
235
-
236
- Util.extend = function (target) {
237
- var sources = [].slice.call(arguments, 1);
238
- sources.forEach(function (source) {
239
- for (var prop in source) {
240
- target[prop] = source[prop];
241
- }
242
- });
243
- return target;
244
- };
245
-
246
- Util.isJSONValid = function (str) {
247
- try {
248
- if (str instanceof Object) {
249
- return true;
250
- } else {
251
- JSON.parse(str);
252
- }
253
- } catch (e) {
254
- return false;
255
- }
256
- return true;
257
- };
258
-
259
- Util.stringify = function (objJSON) {
260
- if (Util.isJSONValid(objJSON)) {
261
- return JSON.stringify(objJSON);
262
- } else {
263
- return objJSON;
264
- }
265
- };
266
-
267
- Util.tryParseJSON = function (jsonData) {
268
- try {
269
- if (jsonData instanceof Object) {
270
- return jsonData;
271
- } else {
272
- return JSON.parse(jsonData);
273
- }
274
- } catch (e) {
275
- return jsonData;
276
- }
277
- };
278
-
279
- Util.parseJSON = function (jsonData) {
280
- try {
281
- if (jsonData instanceof Object) {
282
- return jsonData;
283
- } else {
284
- return JSON.parse(jsonData);
285
- }
286
- } catch (e) {
287
- return {
288
- success: false,
289
- message: e.message,
290
- jsonData: jsonData,
291
- };
292
- }
293
- };
294
-
295
- Util.toQueryString = function (obj) {
296
- return _.map(obj, function (v, k) {
297
- return encodeURIComponent(k) + "=" + encodeURIComponent(v);
298
- }).join("&");
299
- };
300
-
301
- Util.setValue = function (sourceObject, variableName, value) {
302
- var levels = variableName.split("."),
303
- sourceObjectClone = _.clone(sourceObject),
304
- newSourceObject = sourceObjectClone || {},
305
- source = newSourceObject;
306
-
307
- for (var i = 0; i < levels.length - 1; i++) {
308
- source = sourceObjectClone[levels[i]];
309
-
310
- if (!source) {
311
- sourceObjectClone[levels[i]] = {};
312
- source = sourceObjectClone[levels[i]];
313
- }
314
- }
315
-
316
- if (source[levels[levels.length - 1]]) {
317
- source[levels[levels.length - 1]] = _.extend(source[levels[levels.length - 1]], value);
318
- } else {
319
- source[levels[levels.length - 1]] = value;
320
- }
321
-
322
- return newSourceObject;
323
- };
324
-
325
- function isCreditCardNumber(value) {
326
- return !isNaN(parseFloat(value)) && isFinite(value) && (value || "").length == 16;
327
- }
328
-
329
- function maskCardNumber(cardNumber) {
330
- return cardNumber.replace(/^[\d-\s]+(?=\d{4})/, "************");
331
- }
332
-
333
- Util.obfuscationJSON = function (objJSON) {
334
- return Util.tryParseJSON(Util.stringifyInfo(objJSON));
335
- };
336
-
337
- Util.stringifyInfo = function (objJSON) {
338
- var cache = [];
339
- var self = this;
340
- var regex = new RegExp("^(" + self.config.stringify.exclusions.join("|") + ")$", "i");
341
-
342
- objJSON = Util.tryParseJSON(objJSON);
343
-
344
- return JSON.stringify(objJSON, function (key, value) {
345
- if (regex.test(key)) {
346
- if (self.config.stringify.excludedKeyValue) {
347
- if (isCreditCardNumber(value)) {
348
- value = maskCardNumber(value);
349
- } else {
350
- value = self.config.stringify.excludedKeyValue;
351
- }
352
- } else {
353
- return;
354
- }
355
- }
356
-
357
- if (value !== null && value !== undefined) {
358
- if (typeof value === "object") {
359
- if (cache.indexOf(value) !== -1) {
360
- // Circular reference found, discard key
361
- return;
362
- }
363
- // Store value in our collection
364
- cache.push(value);
365
- } else if (typeof value === "string" && self.config.stringify.truncationLength > 0) {
366
- return value.length > self.config.stringify.truncationLength
367
- ? value.substring(0, self.config.stringify.truncationLength) + "... [truncated]"
368
- : value;
369
- }
370
- }
371
-
372
- return value;
373
- });
374
- };
375
-
376
- Util.nonNull = function (object) {
377
- object = object || {};
378
- if (typeof object === "object") {
379
- return !(Object.keys(object).length === 0 && object.constructor === Object);
380
- } else {
381
- return object;
382
- }
383
- };
384
-
385
- Util.isNull = function (object) {
386
- return _.isNull(object);
387
- };
388
-
389
- Util.isEmpty = function (object) {
390
- return _.isEmpty(object);
391
- };
392
-
393
- Util.getEncryptionKey = function (context) {
394
- if (context.service.security) {
395
- return context.security.encryptionKey;
396
- } else {
397
- //GET ALL RESULT IN SERVICE.RESULT
398
- return context.service.result.encryptionKey;
399
- }
400
- };
401
-
402
- Util.getPublicKey = function (context) {
403
- if (context.service.security) {
404
- return context.security.publicKey;
405
- } else {
406
- return Util.decodeBase64(context.headers["x-device-public-key"]);
407
- }
408
- };
409
-
410
- Util.getDeviceDNA = function (context) {
411
- if (context.service.security) {
412
- return context.security.deviceDNA;
413
- } else {
414
- return context.service.result.device.dna;
415
- }
416
- };
417
-
418
- Util.generateKey = function (objectKey) {
419
- return hash(objectKey);
420
- };
421
-
422
- Util.generateQueryHash = function (query) {
423
-
424
- if (!query || typeof query !== 'object') return '';
425
-
426
- const ordered = Object.keys(query)
427
- .sort()
428
- .reduce((acc, key) => {
429
- acc[key] = query[key];
430
- return acc;
431
- }, {});
432
-
433
- const jsonString = JSON.stringify(ordered);
434
-
435
- return crypto.createHash("sha256").update(jsonString).digest("hex");
436
-
437
- };
438
-
439
- Util.shallowCopy = function (obj) {
440
- if (!obj) {
441
- return obj;
442
- }
443
- var copy = {};
444
- Object.keys(obj).forEach(function forEach(k) {
445
- copy[k] = obj[k];
446
- });
447
- return copy;
448
- };
449
-
450
- Util.formatJSON = function (req, res, body) {
451
- var data = body ? JSON.stringify(body) : "null";
452
- // Setting the content-length header is not a formatting feature and should
453
- // be separated into another module
454
- res.setHeader("Content-Length", Buffer.byteLength(data));
455
- return data;
456
- };
457
-
458
- Util.responseTimeInMillis = function (initialTime, endTime) {
459
- return (endTime || new Date()) - initialTime;
460
- };
461
-
462
- function parseDuration(duration) {
463
- let remain = duration;
464
-
465
- let days = Math.floor(remain / (1000 * 60 * 60 * 24));
466
- remain = remain % (1000 * 60 * 60 * 24);
467
-
468
- let hours = Math.floor(remain / (1000 * 60 * 60));
469
- remain = remain % (1000 * 60 * 60);
470
-
471
- let minutes = Math.floor(remain / (1000 * 60));
472
- remain = remain % (1000 * 60);
473
-
474
- let seconds = Math.floor(remain / 1000);
475
- remain = remain % 1000;
476
-
477
- let milliseconds = remain;
478
-
479
- return {
480
- days,
481
- hours,
482
- minutes,
483
- seconds,
484
- milliseconds,
485
- };
486
- }
487
-
488
- function formatTime(o, useMilli = false) {
489
- let parts = [];
490
-
491
- if (o.days) {
492
- let ret = o.days + " day";
493
- if (o.days !== 1) {
494
- ret += "s";
495
- }
496
- parts.push(ret);
497
- }
498
-
499
- if (o.hours) {
500
- let ret = o.hours + " hour";
501
- if (o.hours !== 1) {
502
- ret += "s";
503
- }
504
- parts.push(ret);
505
- }
506
- if (o.minutes) {
507
- let ret = o.minutes + " minute";
508
- if (o.minutes !== 1) {
509
- ret += "s";
510
- }
511
- parts.push(ret);
512
- }
513
-
514
- if (o.seconds) {
515
- let ret = o.seconds + " second";
516
- if (o.seconds !== 1) {
517
- ret += "s";
518
- }
519
- parts.push(ret);
520
- }
521
-
522
- if (useMilli && o.milliseconds) {
523
- let ret = o.milliseconds + " millisecond";
524
- if (o.milliseconds !== 1) {
525
- ret += "s";
526
- }
527
- parts.push(ret);
528
- }
529
-
530
- if (parts.length === 0) {
531
- return "instantly";
532
- } else {
533
- return parts.join(" ");
534
- }
535
- }
536
-
537
- Util.formatDuration = function (duration) {
538
- let time = parseDuration(duration);
539
- return formatTime(time, true);
540
- };
541
-
542
- Util.defaultDateISOString = function () {
543
- return new Date("1900-01-01T00:00:00.000Z").toISOString();
544
- };
545
-
546
- Util.parseCookies = (headers) => {
547
- var list = {},
548
- rc = headers.cookie;
549
-
550
- rc &&
551
- rc.split(";").forEach(function (cookie) {
552
- var parts = cookie.split("=");
553
- list[parts.shift().trim()] = decodeURI(parts.join("="));
554
- });
555
-
556
- return list;
557
- };
558
-
559
- Util.parseSetCookies = (headers) => {
560
- var list = {},
561
- rc = headers["set-cookie"];
562
-
563
- rc &&
564
- rc.map((item) => {
565
- item.split(";").map((cookie) => {
566
- var parts = cookie.split("=");
567
- list[parts.shift().trim()] = decodeURI(parts.join("="));
568
- });
569
- });
570
-
571
- return list;
572
- };
573
-
574
- Util.zeroPad = (number, places) => {
575
- var zero = places - number.toString().length + 1;
576
- return Array(+(zero > 0 && zero)).join("0") + number;
577
- };
578
-
579
- Util.underscore = () => {
580
- return _;
581
- };
582
-
583
- Util.checksum = (str, algorithm, encoding) => {
584
- return crypto
585
- .createHash(algorithm || "md5")
586
- .update(str, "utf8")
587
- .digest(encoding || "hex");
588
- };
589
-
590
- Util.formatNumberFlatToDecimal = (number, decimalSize = 2) => {
591
- try {
592
- let n = number.toString();
593
- let s = n.length;
594
- let d = decimalSize;
595
-
596
- return parseFloat(`${n.substring(0, s - d)}.${n.substring(s - d, s)}`) || 0.0;
597
- } catch (error) {
598
- Util.error("Error to format number flat to float", error);
599
- return 0.0;
600
- }
601
- };
602
-
603
- Util.compileTemplate = (data, template) => {
604
- let compiled = _.template(template);
605
- return compiled(data);
606
- };
607
-
608
- Util.isUrl = (url) => {
609
- if (!_.isString(url)) return false;
610
-
611
- if (url.toLowerCase().indexOf("localhost") != -1) return true;
612
-
613
- if (url.toLowerCase().startsWith("https://") || url.toLowerCase().startsWith("http://")) {
614
- return true;
615
- } else {
616
- return false;
617
- }
618
- };
619
-
620
- Util.getObjectCache = async (context, keyName, key) => {
621
- try {
622
- return await context.orchestrator.redisClient.get(keyName, key);
623
- } catch (error) {
624
- Util.error(`stage=error method=getObjectCache message=Error retrieving cache for key=${key}`, error);
625
- return {};
626
- }
627
- };
628
-
629
- Util.putObjectCache = async (context, keyName, key, data, ttl) => {
630
- try {
631
- await context.orchestrator.redisClient.put(keyName, key, data, ttl || 60 * 1); //1min Default
632
- Util.info(`stage=info method=putObjectCache message=Cache set successfully`, {
633
- keyName,
634
- key,
635
- ttl,
636
- });
637
- } catch (error) {
638
- Util.error(`stage=error method=putObjectCache message=Error setting cache for key=${key}`, error);
639
- }
640
- };
641
-
642
- Util.getObjectCacheByCacheName = async (context, cacheName) => {
643
- try {
644
- return await context.orchestrator.redisClient.getKeys(cacheName);
645
- } catch (error) {
646
- Util.error(`stage=error method=getObjectCacheByCacheName message=Error retrieving keys for cacheName=${cacheName}`, error);
647
- return [];
648
- }
649
- };
650
-
651
- Util.deleteObjectCache = async (context, keyName, key) => {
652
- try {
653
- await context.orchestrator.redisClient.delete(keyName, key);
654
- } catch (error) {
655
- Util.error(`stage=error method=deleteObjectCache message=Error deleting cache for key=${key}`, error);
656
- }
657
- };
658
-
659
- Util.substring = (string, maxLen) => {
660
- let stringSanitizer = string || "";
661
-
662
- if (stringSanitizer.length > 0 && stringSanitizer.length > maxLen) {
663
- return stringSanitizer.substring(0, maxLen);
664
- } else {
665
- return stringSanitizer;
666
- }
667
- };
668
-
669
- module.exports = Util;