@segment/action-destinations 3.219.0-staging.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.
@@ -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/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,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"}
@@ -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"}
@@ -59,3 +59,11 @@ export interface EventData {
59
59
  };
60
60
  };
61
61
  }
62
+ export interface listData {
63
+ data: [
64
+ {
65
+ type: string;
66
+ id?: string;
67
+ }
68
+ ];
69
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@segment/action-destinations",
3
3
  "description": "Destination Actions engine and definitions.",
4
- "version": "3.219.0-staging.0",
4
+ "version": "3.220.0-staging.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/segmentio/action-destinations",