@mhubcloud/tms_core 3.1.2 → 3.1.3-beta.1

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
@@ -301,7 +301,7 @@ async function processMessage(message, log3, platformPublisher, source, trigger)
301
301
  eventPublisher.config,
302
302
  platformPublisher,
303
303
  {
304
- message: `event`,
304
+ message: `mhub/platformSent`,
305
305
  severity: 1,
306
306
  properties: {
307
307
  publisher: platformPublisher.source ? platformPublisher.source : source,
@@ -425,7 +425,7 @@ var cj = {
425
425
 
426
426
  // src/publishers/facebook.ts
427
427
  var facebook = {
428
- source: "Faceboook",
428
+ source: "Facebook",
429
429
  /**
430
430
  *Publishes data to Facebook
431
431
  * @param log Azure Function context.log
@@ -555,6 +555,36 @@ var piano = {
555
555
  }
556
556
  };
557
557
 
558
+ // src/publishers/tablestorage.ts
559
+ var tableStorage = {
560
+ source: "f_TableStorage",
561
+ async publish(log3, config, data, event) {
562
+ if (config.SASToken && config.tableName) {
563
+ data = removeUndefined(data);
564
+ const requestOptions = {
565
+ method: "POST",
566
+ headers: {
567
+ // eslint-disable-next-line @typescript-eslint/naming-convention
568
+ "User-Agent": "mHub Cloud"
569
+ },
570
+ body: JSON.stringify(data)
571
+ };
572
+ const baseUrl = `https://${config.account}.table.core.windows.net/${config.tableName}`;
573
+ const query = config.SASToken;
574
+ await handlePlatformRequest({
575
+ source: this.source,
576
+ baseUrl,
577
+ requestOptions,
578
+ query,
579
+ event,
580
+ logger: log3
581
+ });
582
+ } else {
583
+ throw new Error("Invalid config for platform " + this.source);
584
+ }
585
+ }
586
+ };
587
+
558
588
  // src/publishers/universalAnalytics.ts
559
589
  var universalAnalytics = {
560
590
  source: "UniversalAnalytics",
@@ -633,7 +663,9 @@ var publisher = {
633
663
  // eslint-disable-next-line @typescript-eslint/naming-convention
634
664
  Piano: piano,
635
665
  // eslint-disable-next-line @typescript-eslint/naming-convention
636
- AffiliatePort: affiliatePort
666
+ AffiliatePort: affiliatePort,
667
+ // eslint-disable-next-line @typescript-eslint/naming-convention
668
+ TableStorage: tableStorage
637
669
  };
638
670
  // Annotate the CommonJS export names for ESM import in node:
639
671
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhubcloud/tms_core",
3
- "version": "3.1.2",
3
+ "version": "3.1.3-beta.1",
4
4
  "description": "Core function for mHub Cloud TMS publishers",
5
5
  "homepage": "https://mhubcloud.com/",
6
6
  "license": "Apache 2.0",
@@ -45,7 +45,11 @@ export async function defaultPublisher(
45
45
  azureFunctionContext.log,
46
46
  new Error(result.reason as Error['message']),
47
47
  );
48
- throw new Error(result.reason as Error['message']);
48
+ throw new Error(
49
+ typeof result.reason === 'object'
50
+ ? JSON.stringify(result.reason)
51
+ : (result.reason as Error['message']),
52
+ );
49
53
  }
50
54
  }
51
55
  }
@@ -93,7 +97,7 @@ async function processMessage(
93
97
  eventPublisher.config,
94
98
  platformPublisher,
95
99
  {
96
- message: `event`,
100
+ message: `Event dispatched to platform`,
97
101
  severity: 1,
98
102
  properties: {
99
103
  publisher: platformPublisher.source
@@ -5,7 +5,7 @@ import {
5
5
  } from '../types/PlatformPublisher';
6
6
 
7
7
  export const facebook: PlatformPublisher = {
8
- source: 'Faceboook',
8
+ source: 'Facebook',
9
9
  /**
10
10
  *Publishes data to Facebook
11
11
  * @param log Azure Function context.log
@@ -290,7 +290,7 @@ interface HandleRequestParams {
290
290
  query?: string;
291
291
  event: EventToLog;
292
292
  logger: Logger;
293
- handlePlatformResponse: boolean;
293
+ handlePlatformResponse?: boolean;
294
294
  }
295
295
 
296
296
  /**