@segment/action-destinations 3.219.0 → 3.220.0-staging.0

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 (144) hide show
  1. package/dist/destinations/airship/utilities.js +2 -2
  2. package/dist/destinations/airship/utilities.js.map +1 -1
  3. package/dist/destinations/braze/updateUserProfile/index.js +1 -6
  4. package/dist/destinations/braze/updateUserProfile/index.js.map +1 -1
  5. package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.d.ts +1 -0
  6. package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js +8 -1
  7. package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js.map +1 -1
  8. package/dist/destinations/engage/twilio/utils/PhoneMessageSender.d.ts +0 -1
  9. package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js +2 -2
  10. package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js.map +1 -1
  11. package/dist/destinations/fullstory/identifyUserV2/generated-types.d.ts +1 -1
  12. package/dist/destinations/fullstory/identifyUserV2/index.js +1 -1
  13. package/dist/destinations/fullstory/identifyUserV2/index.js.map +1 -1
  14. package/dist/destinations/fullstory/index.js +1 -1
  15. package/dist/destinations/fullstory/index.js.map +1 -1
  16. package/dist/destinations/fullstory/request-params.d.ts +2 -2
  17. package/dist/destinations/fullstory/request-params.js +6 -6
  18. package/dist/destinations/fullstory/request-params.js.map +1 -1
  19. package/dist/destinations/fullstory/trackEventV2/generated-types.d.ts +1 -1
  20. package/dist/destinations/fullstory/trackEventV2/index.js +1 -1
  21. package/dist/destinations/fullstory/trackEventV2/index.js.map +1 -1
  22. package/dist/destinations/hyperengage/commonFields.d.ts +3 -0
  23. package/dist/destinations/hyperengage/commonFields.js +165 -0
  24. package/dist/destinations/hyperengage/commonFields.js.map +1 -0
  25. package/dist/destinations/hyperengage/generated-types.d.ts +4 -0
  26. package/dist/destinations/{liveramp-audiences/audienceEnteredSFTP.types.js → hyperengage/generated-types.js} +1 -1
  27. package/dist/destinations/hyperengage/generated-types.js.map +1 -0
  28. package/dist/destinations/hyperengage/group/generated-types.d.ts +35 -0
  29. package/dist/destinations/hyperengage/group/generated-types.js +3 -0
  30. package/dist/destinations/hyperengage/group/generated-types.js.map +1 -0
  31. package/dist/destinations/hyperengage/group/index.d.ts +5 -0
  32. package/dist/destinations/hyperengage/group/index.js +81 -0
  33. package/dist/destinations/hyperengage/group/index.js.map +1 -0
  34. package/dist/destinations/hyperengage/identify/generated-types.d.ts +36 -0
  35. package/dist/destinations/hyperengage/identify/generated-types.js +3 -0
  36. package/dist/destinations/hyperengage/identify/generated-types.js.map +1 -0
  37. package/dist/destinations/hyperengage/identify/index.d.ts +5 -0
  38. package/dist/destinations/hyperengage/identify/index.js +110 -0
  39. package/dist/destinations/hyperengage/identify/index.js.map +1 -0
  40. package/dist/destinations/hyperengage/index.d.ts +4 -0
  41. package/dist/destinations/hyperengage/index.js +72 -0
  42. package/dist/destinations/hyperengage/index.js.map +1 -0
  43. package/dist/destinations/hyperengage/track/generated-types.d.ts +32 -0
  44. package/dist/destinations/hyperengage/track/generated-types.js +3 -0
  45. package/dist/destinations/hyperengage/track/generated-types.js.map +1 -0
  46. package/dist/destinations/hyperengage/track/index.d.ts +5 -0
  47. package/dist/destinations/hyperengage/track/index.js +54 -0
  48. package/dist/destinations/hyperengage/track/index.js.map +1 -0
  49. package/dist/destinations/hyperengage/validateInput.d.ts +2 -0
  50. package/dist/destinations/hyperengage/validateInput.js +90 -0
  51. package/dist/destinations/hyperengage/validateInput.js.map +1 -0
  52. package/dist/destinations/index.js +3 -0
  53. package/dist/destinations/index.js.map +1 -1
  54. package/dist/destinations/klaviyo/addProfileToList/generated-types.d.ts +4 -0
  55. package/dist/destinations/klaviyo/addProfileToList/generated-types.js +3 -0
  56. package/dist/destinations/klaviyo/addProfileToList/generated-types.js.map +1 -0
  57. package/dist/destinations/klaviyo/addProfileToList/index.d.ts +5 -0
  58. package/dist/destinations/klaviyo/addProfileToList/index.js +53 -0
  59. package/dist/destinations/klaviyo/addProfileToList/index.js.map +1 -0
  60. package/dist/destinations/klaviyo/config.d.ts +1 -0
  61. package/dist/destinations/klaviyo/config.js +5 -0
  62. package/dist/destinations/klaviyo/config.js.map +1 -0
  63. package/dist/destinations/klaviyo/functions.d.ts +2 -0
  64. package/dist/destinations/klaviyo/functions.js +35 -0
  65. package/dist/destinations/klaviyo/functions.js.map +1 -0
  66. package/dist/destinations/klaviyo/index.js +9 -5
  67. package/dist/destinations/klaviyo/index.js.map +1 -1
  68. package/dist/destinations/klaviyo/orderCompleted/generated-types.d.ts +22 -0
  69. package/dist/destinations/klaviyo/orderCompleted/generated-types.js +3 -0
  70. package/dist/destinations/klaviyo/orderCompleted/generated-types.js.map +1 -0
  71. package/dist/destinations/klaviyo/orderCompleted/index.d.ts +5 -0
  72. package/dist/destinations/klaviyo/orderCompleted/index.js +152 -0
  73. package/dist/destinations/klaviyo/orderCompleted/index.js.map +1 -0
  74. package/dist/destinations/klaviyo/removeProfileToList/generated-types.d.ts +4 -0
  75. package/dist/destinations/klaviyo/removeProfileToList/generated-types.js +3 -0
  76. package/dist/destinations/klaviyo/removeProfileToList/generated-types.js.map +1 -0
  77. package/dist/destinations/klaviyo/removeProfileToList/index.d.ts +5 -0
  78. package/dist/destinations/klaviyo/removeProfileToList/index.js +53 -0
  79. package/dist/destinations/klaviyo/removeProfileToList/index.js.map +1 -0
  80. package/dist/destinations/klaviyo/trackEvent/generated-types.d.ts +16 -0
  81. package/dist/destinations/klaviyo/trackEvent/generated-types.js +3 -0
  82. package/dist/destinations/klaviyo/trackEvent/generated-types.js.map +1 -0
  83. package/dist/destinations/klaviyo/trackEvent/index.d.ts +5 -0
  84. package/dist/destinations/klaviyo/trackEvent/index.js +118 -0
  85. package/dist/destinations/klaviyo/trackEvent/index.js.map +1 -0
  86. package/dist/destinations/klaviyo/types.d.ts +69 -0
  87. package/dist/destinations/klaviyo/types.js +8 -0
  88. package/dist/destinations/klaviyo/types.js.map +1 -0
  89. package/dist/destinations/klaviyo/upsertProfile/generated-types.d.ts +21 -1
  90. package/dist/destinations/klaviyo/upsertProfile/index.js +150 -5
  91. package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
  92. package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js +1 -1
  93. package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js.map +1 -1
  94. package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js +1 -1
  95. package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js.map +1 -1
  96. package/dist/destinations/pinterest-conversions/pinterest-capi-custom-data.js +1 -1
  97. package/dist/destinations/pinterest-conversions/pinterest-capi-custom-data.js.map +1 -1
  98. package/dist/destinations/pinterest-conversions/reportConversionEvent/generated-types.d.ts +1 -1
  99. package/dist/destinations/snap-conversions-api/_tests_/index.test.js.map +1 -1
  100. package/dist/destinations/the-trade-desk-crm/functions.js +1 -7
  101. package/dist/destinations/the-trade-desk-crm/functions.js.map +1 -1
  102. package/dist/destinations/the-trade-desk-crm/index.js +1 -1
  103. package/dist/destinations/yahoo-audiences/constants.d.ts +2 -0
  104. package/dist/destinations/yahoo-audiences/constants.js +6 -0
  105. package/dist/destinations/yahoo-audiences/constants.js.map +1 -0
  106. package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.d.ts +4 -0
  107. package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js +3 -0
  108. package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js.map +1 -0
  109. package/dist/destinations/yahoo-audiences/createCustomerNode/index.d.ts +5 -0
  110. package/dist/destinations/yahoo-audiences/createCustomerNode/index.js +33 -0
  111. package/dist/destinations/yahoo-audiences/createCustomerNode/index.js.map +1 -0
  112. package/dist/destinations/yahoo-audiences/createSegment/generated-types.d.ts +6 -0
  113. package/dist/destinations/yahoo-audiences/createSegment/generated-types.js +3 -0
  114. package/dist/destinations/yahoo-audiences/createSegment/generated-types.js.map +1 -0
  115. package/dist/destinations/yahoo-audiences/createSegment/index.d.ts +5 -0
  116. package/dist/destinations/yahoo-audiences/createSegment/index.js +45 -0
  117. package/dist/destinations/yahoo-audiences/createSegment/index.js.map +1 -0
  118. package/dist/destinations/yahoo-audiences/generated-types.d.ts +12 -0
  119. package/dist/destinations/yahoo-audiences/generated-types.js +3 -0
  120. package/dist/destinations/yahoo-audiences/generated-types.js.map +1 -0
  121. package/dist/destinations/yahoo-audiences/index.d.ts +4 -0
  122. package/dist/destinations/yahoo-audiences/index.js +145 -0
  123. package/dist/destinations/yahoo-audiences/index.js.map +1 -0
  124. package/dist/destinations/yahoo-audiences/types.d.ts +25 -0
  125. package/dist/destinations/yahoo-audiences/types.js +3 -0
  126. package/dist/destinations/yahoo-audiences/types.js.map +1 -0
  127. package/dist/destinations/yahoo-audiences/updateSegment/generated-types.d.ts +17 -0
  128. package/dist/destinations/yahoo-audiences/updateSegment/generated-types.js +3 -0
  129. package/dist/destinations/yahoo-audiences/updateSegment/generated-types.js.map +1 -0
  130. package/dist/destinations/yahoo-audiences/updateSegment/index.d.ts +5 -0
  131. package/dist/destinations/yahoo-audiences/updateSegment/index.js +168 -0
  132. package/dist/destinations/yahoo-audiences/updateSegment/index.js.map +1 -0
  133. package/dist/destinations/yahoo-audiences/utils-rt.d.ts +10 -0
  134. package/dist/destinations/yahoo-audiences/utils-rt.js +95 -0
  135. package/dist/destinations/yahoo-audiences/utils-rt.js.map +1 -0
  136. package/dist/destinations/yahoo-audiences/utils-tax.d.ts +10 -0
  137. package/dist/destinations/yahoo-audiences/utils-tax.js +67 -0
  138. package/dist/destinations/yahoo-audiences/utils-tax.js.map +1 -0
  139. package/dist/destinations/yahoo-audiences/utils.d.ts +4 -0
  140. package/dist/destinations/yahoo-audiences/utils.js +30 -0
  141. package/dist/destinations/yahoo-audiences/utils.js.map +1 -0
  142. package/package.json +2 -2
  143. package/dist/destinations/liveramp-audiences/audienceEnteredSFTP.types.d.ts +0 -16
  144. package/dist/destinations/liveramp-audiences/audienceEnteredSFTP.types.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/addProfileToList/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const config_1 = require("../config");
5
+ const functions_1 = require("../functions");
6
+ const action = {
7
+ title: 'Add To List',
8
+ description: 'Add to list',
9
+ fields: {
10
+ profile_id: {
11
+ label: 'Profile Id',
12
+ description: 'Profile Id of User',
13
+ type: 'string'
14
+ },
15
+ list_id: {
16
+ label: 'List Id',
17
+ description: `'Insert the ID of the default list that you'd like to subscribe users to when you call .identify().'`,
18
+ type: 'string',
19
+ dynamic: true
20
+ }
21
+ },
22
+ dynamicFields: {
23
+ list_id: async (request, { settings }) => {
24
+ return functions_1.getListIdDynamicData(request, settings);
25
+ }
26
+ },
27
+ perform: async (request, { payload }) => {
28
+ try {
29
+ const { profile_id, list_id } = payload;
30
+ if (!list_id) {
31
+ throw new actions_core_1.IntegrationError("Insert the ID of the default list that you'd like to subscribe users", 'Missing required fields', 400);
32
+ }
33
+ const listData = {
34
+ data: [
35
+ {
36
+ type: 'profile',
37
+ id: profile_id
38
+ }
39
+ ]
40
+ };
41
+ const list = await request(`${config_1.API_URL}/lists/${list_id}/relationships/profiles/`, {
42
+ method: 'POST',
43
+ json: listData
44
+ });
45
+ return list;
46
+ }
47
+ catch (error) {
48
+ throw new Error('An error occurred while processing the request');
49
+ }
50
+ }
51
+ };
52
+ exports.default = action;
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/addProfileToList/index.ts"],"names":[],"mappings":";;AAAA,wDAAgG;AAGhG,sCAAmC;AAEnC,4CAAmD;AAEnD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,oBAAoB;YACjC,IAAI,EAAE,QAAQ;SACf;QACD,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,sGAAsG;YACnH,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI;SACd;KACF;IACD,aAAa,EAAE;QACb,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAiC,EAAE;YACtE,OAAO,gCAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAChD,CAAC;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACtC,IAAI;YACF,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;YACvC,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,IAAI,+BAAgB,CACxB,sEAAsE,EACtE,yBAAyB,EACzB,GAAG,CACJ,CAAA;aACF;YACD,MAAM,QAAQ,GAAa;gBACzB,IAAI,EAAE;oBACJ;wBACE,IAAI,EAAE,SAAS;wBACf,EAAE,EAAE,UAAU;qBACf;iBACF;aACF,CAAA;YACD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,gBAAO,UAAU,OAAO,0BAA0B,EAAE;gBAChF,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,QAAQ;aACf,CAAC,CAAA;YACF,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;SAClE;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const API_URL = "https://a.klaviyo.com/api";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.API_URL = void 0;
4
+ exports.API_URL = 'https://a.klaviyo.com/api';
5
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,2BAA2B,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { RequestClient, DynamicFieldResponse } from '@segment/actions-core';
2
+ export declare function getListIdDynamicData(request: RequestClient, settings: any): Promise<DynamicFieldResponse>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getListIdDynamicData = void 0;
4
+ const config_1 = require("./config");
5
+ async function getListIdDynamicData(request, settings) {
6
+ try {
7
+ const result = await request(`${config_1.API_URL}/lists/`, {
8
+ method: 'get',
9
+ headers: {
10
+ Authorization: `Klaviyo-API-Key ${settings.api_key}`,
11
+ Accept: 'application/json',
12
+ revision: new Date().toISOString().slice(0, 10)
13
+ },
14
+ skipResponseCloning: true
15
+ });
16
+ const choices = JSON.parse(result.content).data.map((list) => {
17
+ return { value: list.id, label: list.attributes.name };
18
+ });
19
+ return {
20
+ choices
21
+ };
22
+ }
23
+ catch (err) {
24
+ return {
25
+ choices: [],
26
+ nextPage: '',
27
+ error: {
28
+ message: err.message ?? 'Unknown error',
29
+ code: err.status + '' ?? 'Unknown error'
30
+ }
31
+ };
32
+ }
33
+ }
34
+ exports.getListIdDynamicData = getListIdDynamicData;
35
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/functions.ts"],"names":[],"mappings":";;;AACA,qCAAkC;AAE3B,KAAK,UAAU,oBAAoB,CAAC,OAAsB,EAAE,QAAa;IAC9E,IAAI;QACF,MAAM,MAAM,GAAQ,MAAM,OAAO,CAAC,GAAG,gBAAO,SAAS,EAAE;YACrD,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,aAAa,EAAE,mBAAmB,QAAQ,CAAC,OAAO,EAAE;gBACpD,MAAM,EAAE,kBAAkB;gBAC1B,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;aAChD;YACD,mBAAmB,EAAE,IAAI;SAC1B,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAkD,EAAE,EAAE;YACzG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QACxD,CAAC,CAAC,CAAA;QACF,OAAO;YACL,OAAO;SACR,CAAA;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO;YACL,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE;gBACL,OAAO,EAAG,GAAgB,CAAC,OAAO,IAAI,eAAe;gBACrD,IAAI,EAAG,GAAgB,CAAC,MAAM,GAAG,EAAE,IAAI,eAAe;aACvD;SACF,CAAA;KACF;AACH,CAAC;AA3BD,oDA2BC"}
@@ -4,7 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const upsertProfile_1 = __importDefault(require("./upsertProfile"));
7
- const API_URL = 'https://a.klaviyo.com/api';
7
+ const config_1 = require("./config");
8
+ const trackEvent_1 = __importDefault(require("./trackEvent"));
9
+ const orderCompleted_1 = __importDefault(require("./orderCompleted"));
8
10
  const destination = {
9
11
  name: 'Klaviyo (Actions)',
10
12
  slug: 'actions-klaviyo',
@@ -20,13 +22,13 @@ const destination = {
20
22
  }
21
23
  },
22
24
  testAuthentication: (request) => {
23
- return request(`${API_URL}/accounts/`, {
25
+ return request(`${config_1.API_URL}/accounts/`, {
24
26
  method: 'get'
25
27
  });
26
28
  }
27
29
  },
28
30
  onDelete: async (request, { payload }) => {
29
- return request(`${API_URL}/data-privacy-deletion-jobs/`, {
31
+ return request(`${config_1.API_URL}/data-privacy-deletion-jobs/`, {
30
32
  method: 'post',
31
33
  json: {
32
34
  data: {
@@ -48,12 +50,14 @@ const destination = {
48
50
  headers: {
49
51
  Authorization: `Klaviyo-API-Key ${settings.api_key}`,
50
52
  Accept: 'application/json',
51
- revision: new Date().toISOString().slice(0, 10)
53
+ revision: '2023-09-15'
52
54
  }
53
55
  };
54
56
  },
55
57
  actions: {
56
- upsertProfile: upsertProfile_1.default
58
+ upsertProfile: upsertProfile_1.default,
59
+ trackEvent: trackEvent_1.default,
60
+ orderCompleted: orderCompleted_1.default
57
61
  }
58
62
  };
59
63
  exports.default = destination;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAGA,oEAA2C;AAE3C,MAAM,OAAO,GAAG,2BAA2B,CAAA;AAE3C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,wGAAwG;gBACrH,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,GAAG,OAAO,YAAY,EAAE;gBACrC,MAAM,EAAE,KAAK;aACd,CAAC,CAAA;QACJ,CAAC;KACF;IAED,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,OAAO,OAAO,CAAC,GAAG,OAAO,8BAA8B,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,2BAA2B;oBACjC,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;gCACf,EAAE,EAAE,OAAO,CAAC,MAAM;6BACnB;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAC,EAAE,QAAQ,EAAE;QACxB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,mBAAmB,QAAQ,CAAC,OAAO,EAAE;gBACpD,MAAM,EAAE,kBAAkB;gBAC1B,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;aAChD;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;KACd;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAGA,oEAA2C;AAC3C,qCAAkC;AAElC,8DAAqC;AAErC,sEAA6C;AAE7C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,wGAAwG;gBACrH,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,GAAG,gBAAO,YAAY,EAAE;gBACrC,MAAM,EAAE,KAAK;aACd,CAAC,CAAA;QACJ,CAAC;KACF;IAED,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,OAAO,OAAO,CAAC,GAAG,gBAAO,8BAA8B,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,2BAA2B;oBACjC,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;gCACf,EAAE,EAAE,OAAO,CAAC,MAAM;6BACnB;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAC,EAAE,QAAQ,EAAE;QACxB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,mBAAmB,QAAQ,CAAC,OAAO,EAAE;gBACpD,MAAM,EAAE,kBAAkB;gBAC1B,QAAQ,EAAE,YAAY;aACvB;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;QACb,UAAU,EAAV,oBAAU;QACV,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1,22 @@
1
+ export interface Payload {
2
+ profile: {
3
+ email?: string;
4
+ phone_number?: string;
5
+ other_properties?: {
6
+ [k: string]: unknown;
7
+ };
8
+ };
9
+ metric_name: string;
10
+ properties: {
11
+ [k: string]: unknown;
12
+ };
13
+ time?: string | number;
14
+ value?: number;
15
+ unique_id?: string;
16
+ products?: {
17
+ value?: number;
18
+ properties?: {
19
+ [k: string]: unknown;
20
+ };
21
+ }[];
22
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/orderCompleted/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const config_1 = require("../config");
5
+ const createEventData = (payload) => ({
6
+ data: {
7
+ type: 'event',
8
+ attributes: {
9
+ properties: { ...payload.properties },
10
+ time: payload.time,
11
+ value: payload.value,
12
+ metric: {
13
+ data: {
14
+ type: 'metric',
15
+ attributes: {
16
+ name: 'Order Completed'
17
+ }
18
+ }
19
+ },
20
+ profile: {
21
+ data: {
22
+ type: 'profile',
23
+ attributes: {
24
+ ...payload.profile
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ });
31
+ const sendProductRequests = async (payload, eventData, request) => {
32
+ if (payload.products && Array.isArray(payload.products)) {
33
+ const productPromises = payload?.products?.map((product) => {
34
+ eventData.data.attributes.properties = product.properties;
35
+ eventData.data.attributes.value = product.value;
36
+ eventData.data.attributes.metric.data.attributes.name = 'Ordered Product';
37
+ return request(`${config_1.API_URL}/events/`, {
38
+ method: 'POST',
39
+ json: eventData
40
+ });
41
+ });
42
+ await Promise.all(productPromises);
43
+ }
44
+ };
45
+ const action = {
46
+ title: 'Order Completed',
47
+ description: 'Order Completed Event action tracks users Order Completed events and associate it with their profile.',
48
+ defaultSubscription: 'type = "track"',
49
+ fields: {
50
+ profile: {
51
+ label: 'Profile',
52
+ description: `Properties of the profile that triggered this event.`,
53
+ type: 'object',
54
+ properties: {
55
+ email: {
56
+ label: 'Email',
57
+ type: 'string'
58
+ },
59
+ phone_number: {
60
+ label: 'Phone Number',
61
+ type: 'string'
62
+ },
63
+ other_properties: {
64
+ label: 'Other Properties',
65
+ type: 'object'
66
+ }
67
+ },
68
+ required: true
69
+ },
70
+ metric_name: {
71
+ label: 'Metric Name',
72
+ description: 'Name of the event. Must be less than 128 characters.',
73
+ type: 'string',
74
+ default: {
75
+ '@path': '$.event'
76
+ },
77
+ required: true
78
+ },
79
+ properties: {
80
+ description: `Properties of this event.`,
81
+ label: 'Properties',
82
+ type: 'object',
83
+ default: {
84
+ '@path': '$.properties'
85
+ },
86
+ required: true
87
+ },
88
+ time: {
89
+ label: 'Time',
90
+ description: `When this event occurred. By default, the time the request was received will be used.
91
+ The time is truncated to the second. The time must be after the year 2000 and can only
92
+ be up to 1 year in the future.
93
+ `,
94
+ type: 'datetime',
95
+ default: {
96
+ '@path': '$.timestamp'
97
+ }
98
+ },
99
+ value: {
100
+ label: 'Value',
101
+ description: 'A numeric value to associate with this event. For example, the dollar amount of a purchase.',
102
+ type: 'number'
103
+ },
104
+ unique_id: {
105
+ label: 'Unique ID',
106
+ description: `A unique identifier for an event. If the unique_id is repeated for the same
107
+ profile and metric, only the first processed event will be recorded. If this is not
108
+ present, this will use the time to the second. Using the default, this limits only one
109
+ event per profile per second.
110
+ `,
111
+ type: 'string',
112
+ default: {
113
+ '@path': '$.event'
114
+ }
115
+ },
116
+ products: {
117
+ label: 'Products',
118
+ description: 'List of products purchased in the order.',
119
+ multiple: true,
120
+ type: 'object',
121
+ properties: {
122
+ value: {
123
+ label: 'Value',
124
+ description: 'A numeric value to associate with this event. For example, the dollar amount of a purchase.',
125
+ type: 'number'
126
+ },
127
+ properties: {
128
+ description: `Properties of this event.`,
129
+ label: 'Properties',
130
+ type: 'object'
131
+ }
132
+ }
133
+ }
134
+ },
135
+ perform: async (request, { payload }) => {
136
+ const { email, phone_number } = payload.profile;
137
+ if (!email && !phone_number) {
138
+ throw new actions_core_1.IntegrationError('One of Phone Number or Email is required.', 'Missing required fields', 400);
139
+ }
140
+ const eventData = createEventData(payload);
141
+ const event = await request(`${config_1.API_URL}/events/`, {
142
+ method: 'POST',
143
+ json: eventData
144
+ });
145
+ if (event.status == 202 && Array.isArray(payload.products)) {
146
+ await sendProductRequests(payload, eventData, request);
147
+ }
148
+ return event;
149
+ }
150
+ };
151
+ exports.default = action;
152
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/orderCompleted/index.ts"],"names":[],"mappings":";;AAGA,wDAAuE;AACvE,sCAAmC;AAGnC,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC;IAC7C,IAAI,EAAE;QACJ,IAAI,EAAE,OAAO;QACb,UAAU,EAAE;YACV,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE;YACrC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,iBAAiB;qBACxB;iBACF;aACF;YACD,OAAO,EAAE;gBACP,IAAI,EAAE;oBACJ,IAAI,EAAE,SAAS;oBACf,UAAU,EAAE;wBACV,GAAG,OAAO,CAAC,OAAO;qBACnB;iBACF;aACF;SACF;KACF;CACF,CAAC,CAAA;AAEF,MAAM,mBAAmB,GAAG,KAAK,EAAE,OAAgB,EAAE,SAAoB,EAAE,OAAsB,EAAE,EAAE;IACnG,IAAI,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACvD,MAAM,eAAe,GAAG,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACzD,SAAS,CAAC,IAAI,CAA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AS;SAChB,CAAC,CAAA;QAEF,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC1D,MAAM,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;SACvD;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,4 @@
1
+ export interface Payload {
2
+ profile_id?: string;
3
+ list_id?: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/removeProfileToList/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const config_1 = require("../config");
5
+ const functions_1 = require("../functions");
6
+ const action = {
7
+ title: 'Remove profile from list',
8
+ description: 'Remove profile from list',
9
+ fields: {
10
+ profile_id: {
11
+ label: 'Profile Id',
12
+ description: 'Profile Id of User',
13
+ type: 'string'
14
+ },
15
+ list_id: {
16
+ label: 'List Id',
17
+ description: `'Insert the ID of the default list that you'd like to subscribe users to when you call .identify().'`,
18
+ type: 'string',
19
+ dynamic: true
20
+ }
21
+ },
22
+ dynamicFields: {
23
+ list_id: async (request, { settings }) => {
24
+ return functions_1.getListIdDynamicData(request, settings);
25
+ }
26
+ },
27
+ perform: async (request, { payload }) => {
28
+ const { profile_id, list_id } = payload;
29
+ if (!list_id) {
30
+ throw new actions_core_1.IntegrationError("Insert the ID of the default list that you'd like to subscribe users", 'Missing required fields', 400);
31
+ }
32
+ try {
33
+ const listData = {
34
+ data: [
35
+ {
36
+ type: 'profile',
37
+ id: profile_id
38
+ }
39
+ ]
40
+ };
41
+ const list = await request(`${config_1.API_URL}/lists/${list_id}/relationships/profiles/`, {
42
+ method: 'DELETE',
43
+ json: listData
44
+ });
45
+ return list;
46
+ }
47
+ catch (error) {
48
+ throw new Error('An error occurred while processing the request');
49
+ }
50
+ }
51
+ };
52
+ exports.default = action;
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/removeProfileToList/index.ts"],"names":[],"mappings":";;AAAA,wDAAgG;AAIhG,sCAAmC;AAEnC,4CAAmD;AAEnD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,0BAA0B;IACjC,WAAW,EAAE,0BAA0B;IACvC,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,oBAAoB;YACjC,IAAI,EAAE,QAAQ;SACf;QACD,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,sGAAsG;YACnH,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI;SACd;KACF;IACD,aAAa,EAAE;QACb,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAiC,EAAE;YACtE,OAAO,gCAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAChD,CAAC;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACtC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QAEvC,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,+BAAgB,CACxB,sEAAsE,EACtE,yBAAyB,EACzB,GAAG,CACJ,CAAA;SACF;QACD,IAAI;YACF,MAAM,QAAQ,GAAa;gBACzB,IAAI,EAAE;oBACJ;wBACE,IAAI,EAAE,SAAS;wBACf,EAAE,EAAE,UAAU;qBACf;iBACF;aACF,CAAA;YACD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,gBAAO,UAAU,OAAO,0BAA0B,EAAE;gBAChF,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,QAAQ;aACf,CAAC,CAAA;YACF,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;SAClE;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,16 @@
1
+ export interface Payload {
2
+ profile: {
3
+ email?: string | null;
4
+ phone_number?: string | null;
5
+ other_properties?: {
6
+ [k: string]: unknown;
7
+ } | null;
8
+ };
9
+ metric_name: string;
10
+ properties: {
11
+ [k: string]: unknown;
12
+ };
13
+ time?: string | number;
14
+ value?: number;
15
+ unique_id?: string;
16
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/trackEvent/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const config_1 = require("../config");
5
+ const action = {
6
+ title: 'Track Event',
7
+ description: 'Track user events and associate it with their profile.',
8
+ defaultSubscription: 'type = "track"',
9
+ fields: {
10
+ profile: {
11
+ label: 'Profile',
12
+ description: `Properties of the profile that triggered this event.`,
13
+ type: 'object',
14
+ properties: {
15
+ email: {
16
+ label: 'Email',
17
+ type: 'string',
18
+ allowNull: true
19
+ },
20
+ phone_number: {
21
+ label: 'Phone Number',
22
+ type: 'string',
23
+ allowNull: true
24
+ },
25
+ other_properties: {
26
+ label: 'Other Properties',
27
+ type: 'object',
28
+ allowNull: true
29
+ }
30
+ },
31
+ required: true
32
+ },
33
+ metric_name: {
34
+ label: 'Metric Name',
35
+ description: 'Name of the event. Must be less than 128 characters.',
36
+ type: 'string',
37
+ default: {
38
+ '@path': '$.event'
39
+ },
40
+ required: true
41
+ },
42
+ properties: {
43
+ description: `Properties of this event.`,
44
+ label: 'Properties',
45
+ type: 'object',
46
+ default: {
47
+ '@path': '$.properties'
48
+ },
49
+ required: true
50
+ },
51
+ time: {
52
+ label: 'Time',
53
+ description: `When this event occurred. By default, the time the request was received will be used.
54
+ The time is truncated to the second. The time must be after the year 2000 and can only
55
+ be up to 1 year in the future.
56
+ `,
57
+ type: 'datetime',
58
+ default: {
59
+ '@path': '$.timestamp'
60
+ }
61
+ },
62
+ value: {
63
+ label: 'Value',
64
+ description: 'A numeric value to associate with this event. For example, the dollar amount of a purchase.',
65
+ type: 'number'
66
+ },
67
+ unique_id: {
68
+ label: 'Unique ID',
69
+ description: `A unique identifier for an event. If the unique_id is repeated for the same
70
+ profile and metric, only the first processed event will be recorded. If this is not
71
+ present, this will use the time to the second. Using the default, this limits only one
72
+ event per profile per second.
73
+ `,
74
+ type: 'string',
75
+ default: {
76
+ '@path': '$.event'
77
+ }
78
+ }
79
+ },
80
+ perform: (request, { payload }) => {
81
+ const { email, phone_number } = payload.profile;
82
+ if (!email && !phone_number) {
83
+ throw new actions_core_1.IntegrationError('One of Phone Number or Email is required.', 'Missing required fields', 400);
84
+ }
85
+ const eventData = {
86
+ data: {
87
+ type: 'event',
88
+ attributes: {
89
+ properties: { ...payload.properties },
90
+ time: payload.time,
91
+ value: payload.value,
92
+ metric: {
93
+ data: {
94
+ type: 'metric',
95
+ attributes: {
96
+ name: payload.metric_name
97
+ }
98
+ }
99
+ },
100
+ profile: {
101
+ data: {
102
+ type: 'profile',
103
+ attributes: {
104
+ ...payload.profile
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ };
111
+ return request(`${config_1.API_URL}/events/`, {
112
+ method: 'POST',
113
+ json: eventData
114
+ });
115
+ }
116
+ };
117
+ exports.default = action;
118
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/trackEvent/index.ts"],"names":[],"mappings":";;AAIA,wDAAwD;AACxD,sCAAmC;AAEnC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,wDAAwD;IACrE,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,sDAAsD;YACnE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,KAAK,EAAE,OAAO;oBACd,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,IAAI;iBAChB;gBACD,YAAY,EAAE;oBACZ,KAAK,EAAE,cAAc;oBACrB,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,IAAI;iBAChB;gBACD,gBAAgB,EAAE;oBAChB,KAAK,EAAE,kBAAkB;oBACzB,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,IAAI;iBAChB;aACF;YACD,QAAQ,EAAE,IAAI;SACf;QACD,WAAW,EAAE;YACX,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,sDAAsD;YACnE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;YACD,QAAQ,EAAE,IAAI;SACf;QACD,UAAU,EAAE;YACV,WAAW,EAAE,2BAA2B;YAC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