feed-common 1.43.1 → 1.45.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,29 @@
1
- import {
2
- ServerSideEvent,
3
- ServerSideProgressEvent,
4
- ServerSideScheduleEvent,
5
- SubscriptionPlan,
6
- } from '../types/company.types.js';
7
- import { ShopifyRecurringCharge } from '../types/shopify.types.js';
1
+ import { ServerSideEvent, ServerSideProgressEvent, ServerSideScheduleEvent } from '../types/company.types.js';
8
2
 
9
- export function isServerSideProgressEvent (
10
- event: ServerSideEvent
11
- ): event is ServerSideProgressEvent {
12
- return event.type === 'progress';
3
+ export function isServerSideProgressEvent(event: ServerSideEvent): event is ServerSideProgressEvent {
4
+ return event.type === 'progress';
13
5
  }
14
6
 
15
- export function isServerSideScheduleEvent (
16
- event: ServerSideEvent
17
- ): event is ServerSideScheduleEvent {
18
- return event.type === 'schedule';
7
+ export function isServerSideScheduleEvent(event: ServerSideEvent): event is ServerSideScheduleEvent {
8
+ return event.type === 'schedule';
19
9
  }
20
10
 
21
- export function makeSubscriptionCode (plan: SubscriptionPlan) {
22
- return `${plan.code}${plan.level}`;
11
+ export function makeSubscriptionCode(plan: { code: string; level: number }) {
12
+ return `${plan.code}${plan.level}`;
23
13
  }
24
14
 
25
- export function makeSubscriptionName (plan: SubscriptionPlan) {
15
+ export function makeSubscriptionName(plan: { code: string; level: number }) {
26
16
  return makeSubscriptionCode(plan);
27
17
  }
28
18
 
29
- export function extractSubscriptionCode (subscription: ShopifyRecurringCharge) {
19
+ export function extractSubscriptionCode(subscription: { name: string | null }): string | null {
30
20
  return subscription.name?.match(/^G\d+/i)?.[0] ?? null;
31
21
  }
32
22
 
33
- export function parseSubscriptionName (name: string | null): {
23
+ export function parseSubscriptionName(name: string | null): {
34
24
  code: string | null;
35
25
  level: string | null;
36
26
  } {
37
27
  const match = name?.match(/^G(\d+)/);
38
28
  return { code: 'G', level: match ? match[1] : null };
39
29
  }
40
-
@@ -6,6 +6,7 @@ import { facebookFeedTemplate } from './facebook.template.js';
6
6
  import { XmlFeedTemplateType } from '../../types/profile.types.js';
7
7
  import { googleFeedTemplate } from './google.template.js';
8
8
  import { tiktokFeedTemplate } from './tiktok.template.js';
9
+ import { microsoftTemplate } from './microsoft.template.js';
9
10
 
10
11
  export const hasMacro = (v: string) => /{{[^}]+}}/.test(v);
11
12
  export const removeMacro = (v: string) => v.replaceAll(/{{[^}]+}}/g, '');
@@ -88,6 +89,8 @@ export function getTemplate(type: XMLFeedType): XmlFeedTemplateType {
88
89
  return googleFeedTemplate;
89
90
  case XMLFeedType.TikTok:
90
91
  return tiktokFeedTemplate;
92
+ case XMLFeedType.Microsoft:
93
+ return microsoftTemplate;
91
94
  default:
92
95
  throw new Error(`Invalid feed type: ${type}`);
93
96
  }