@mhubcloud/tms_core 3.4.2 → 3.4.4

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.
package/dist/index.js CHANGED
@@ -431,19 +431,13 @@ async function defaultPublisher(azureFunctionContext, serviceBusMessage, source,
431
431
  if (result.status === "rejected") {
432
432
  if (result.reason instanceof Error) {
433
433
  const formattedError = formatError(result.reason);
434
- logException(
435
- azureFunctionContext.log,
436
- new Error(formattedError.message)
437
- );
434
+ logException(new Error(formattedError.message));
438
435
  throw formattedError;
439
436
  } else {
440
437
  const formattedError = formatError(
441
438
  typeof result.reason === "object" ? JSON.stringify(result.reason) : result.reason
442
439
  );
443
- logException(
444
- azureFunctionContext.log,
445
- new Error(formattedError.message)
446
- );
440
+ logException(new Error(formattedError.message));
447
441
  throw formattedError;
448
442
  }
449
443
  }
@@ -481,7 +475,6 @@ async function processMessage(message, log2, platformPublisher, trigger) {
481
475
  publishedAny = true;
482
476
  } else {
483
477
  logException(
484
- log2,
485
478
  new Error(
486
479
  `The message has not been published. Source: ${platformPublisher.source}`
487
480
  )
@@ -490,7 +483,6 @@ async function processMessage(message, log2, platformPublisher, trigger) {
490
483
  }
491
484
  if (!publishedAny) {
492
485
  logException(
493
- log2,
494
486
  new Error(
495
487
  "The message has not been published to any publisher configuration"
496
488
  )
@@ -899,7 +891,7 @@ var publisher = {
899
891
  Facebook: facebook,
900
892
  // eslint-disable-next-line @typescript-eslint/naming-convention
901
893
  CJ: cj,
902
- // eslint-disable-next-line @typescript-eslint/naming-convention
894
+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unnecessary-type-assertion
903
895
  GoogleAds: googleAds,
904
896
  // eslint-disable-next-line @typescript-eslint/naming-convention
905
897
  GoogleAnalytics4: googleAnalytics4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhubcloud/tms_core",
3
- "version": "3.4.2",
3
+ "version": "3.4.4",
4
4
  "description": "Core function for mHub Cloud TMS publishers",
5
5
  "homepage": "https://mhubcloud.com/",
6
6
  "license": "Apache 2.0",
package/src/broker.ts CHANGED
@@ -104,6 +104,8 @@ function matchEvent(event: EventInfo, publisherEvent: string | PublisherEvent) {
104
104
  if (!paramMatch) {
105
105
  return false;
106
106
  }
107
+ } else if (publisherEventParam && !eventParam) {
108
+ return false;
107
109
  } else {
108
110
  throw new Error('Unexpected formatting in publisher configuration');
109
111
  }
@@ -1,46 +0,0 @@
1
- const { TableClient } = require("@azure/data-tables");
2
- const utils = require("../lib/utils");
3
- const SOURCE = "f_TableStorage";
4
-
5
- module.exports = {
6
- /**
7
- * Processed data coming from EventHub to data for further processing
8
- * @param {Object} data The data coming from EventHub
9
- * @returns {Object} Data for further processing
10
- */
11
- parse: function parse(data, context) {
12
- //ConsumerBase.cs:ConsumeOneEventAsync
13
- data.enqueuedAt = context.test ? 1600000000000 : Date.now();
14
- return data;
15
- },
16
-
17
- /**
18
- * Publishes data to TableStorage
19
- * https://www.npmjs.com/package/@azure/data-tables
20
- * @param {{id: string, access_token: string}} config Publisher configuration
21
- * @param {Object} data Data in publisher-friendly format to be published
22
- * @param {string} event for which is it triggered
23
- */
24
- publish: async function publish(config, data, event) {
25
- data = utils.removeUndefined(data);
26
-
27
- const client = new TableClient(config.connectionString, config.tableName);
28
-
29
- await client.createEntity(data);
30
-
31
- console.log(`TableStorage - ${event} - sent`);
32
- },
33
-
34
- /**
35
- * Validates an object against given schema
36
- * @param {Object} data An object to validate.
37
- * @param {string} schema Name of the schema. That's name of a file with `.schema.json` extension in `customizable/schemas` subfolder of current publisher folder
38
- * @returns {boolean} Validation result, true if successful, false if unsuccessfull (in which case more info is written to console)
39
- */
40
- validate: function validate(data, schema) {
41
- if (!schema) throw new Error("Schema parameters not provided");
42
- if (schema.indexOf("/") >= 0) throw new Error("Schema must be provided as schema name, not schema path");
43
- //More validation done by utils.validate
44
- return utils.validate(data, SOURCE, schema);
45
- }
46
- };