@activepieces/piece-kustomer 0.0.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/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@activepieces/piece-kustomer",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "tslib": "2.6.2",
9
+ "@activepieces/pieces-common": "0.12.1",
10
+ "@activepieces/pieces-framework": "0.27.1",
11
+ "@activepieces/shared": "0.58.3"
12
+ },
13
+ "scripts": {
14
+ "build": "tsc -p tsconfig.lib.json && cp package.json dist/",
15
+ "lint": "eslint 'src/**/*.ts'"
16
+ }
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const kustomer: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kustomer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const shared_1 = require("@activepieces/shared");
8
+ const create_conversation_1 = require("./lib/actions/create-conversation");
9
+ const create_customer_1 = require("./lib/actions/create-customer");
10
+ const get_customer_1 = require("./lib/actions/get-customer");
11
+ const get_custom_objects_1 = require("./lib/actions/get-custom-objects");
12
+ const update_conversation_1 = require("./lib/actions/update-conversation");
13
+ const auth_1 = require("./lib/common/auth");
14
+ const client_1 = require("./lib/common/client");
15
+ exports.kustomer = (0, pieces_framework_1.createPiece)({
16
+ displayName: 'Kustomer',
17
+ description: 'Create and manage Kustomer customers, conversations, and custom objects.',
18
+ minimumSupportedRelease: '0.36.1',
19
+ logoUrl: 'https://cdn.activepieces.com/pieces/kustomer.png',
20
+ categories: [shared_1.PieceCategory.CUSTOMER_SUPPORT],
21
+ authors: ['veri5ied', 'sanket-a11y'],
22
+ auth: auth_1.kustomerAuth,
23
+ actions: [
24
+ create_customer_1.createCustomerAction,
25
+ create_conversation_1.createConversationAction,
26
+ update_conversation_1.updateConversationAction,
27
+ get_customer_1.getCustomerAction,
28
+ get_custom_objects_1.getCustomObjectsAction,
29
+ (0, pieces_common_1.createCustomApiCallAction)({
30
+ auth: auth_1.kustomerAuth,
31
+ baseUrl: () => client_1.KUSTOMER_API_BASE_URL,
32
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
33
+ const apiKey = auth.secret_text;
34
+ return client_1.kustomerClient.createAuthHeaders({
35
+ apiKey,
36
+ });
37
+ }),
38
+ }),
39
+ ],
40
+ triggers: [],
41
+ });
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAA6D;AAC7D,iDAAqD;AAErD,2EAA6E;AAC7E,mEAAqE;AACrE,6DAA+D;AAC/D,yEAA0E;AAC1E,2EAA6E;AAC7E,4CAAiD;AACjD,gDAA4E;AAE/D,QAAA,QAAQ,GAAG,IAAA,8BAAW,EAAC;IAClC,WAAW,EAAE,UAAU;IACvB,WAAW,EACT,0EAA0E;IAC5E,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,kDAAkD;IAC3D,UAAU,EAAE,CAAC,sBAAa,CAAC,gBAAgB,CAAC;IAC5C,OAAO,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC;IACpC,IAAI,EAAE,mBAAY;IAClB,OAAO,EAAE;QACP,sCAAoB;QACpB,8CAAwB;QACxB,8CAAwB;QACxB,gCAAiB;QACjB,2CAAsB;QACtB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,mBAAY;YAClB,OAAO,EAAE,GAAG,EAAE,CAAC,8BAAqB;YACpC,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,WAAqB,CAAC;gBAC1C,OAAO,uBAAc,CAAC,iBAAiB,CAAC;oBACtC,MAAM;iBACP,CAAC,CAAC;YACL,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const createConversationAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ customer: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ status: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
5
+ priority: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
6
+ direction: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
7
+ externalId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ replyChannel: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ }>;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConversationAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const client_1 = require("../common/client");
8
+ exports.createConversationAction = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.kustomerAuth,
10
+ name: 'create-conversation',
11
+ displayName: 'Create Conversation',
12
+ description: 'Creates a new conversation in Kustomer.',
13
+ props: {
14
+ customer: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Customer ID',
16
+ description: 'The Kustomer ID of the customer this conversation belongs to. You can get this from the "Get Customer" action or from the URL when viewing a customer in Kustomer.',
17
+ required: true,
18
+ }),
19
+ name: pieces_framework_1.Property.ShortText({
20
+ displayName: 'Conversation Name',
21
+ description: 'A short subject or title for the conversation (max 256 characters).',
22
+ required: false,
23
+ }),
24
+ status: pieces_framework_1.Property.StaticDropdown({
25
+ displayName: 'Status',
26
+ description: 'The initial status of the conversation.',
27
+ required: false,
28
+ defaultValue: 'open',
29
+ options: {
30
+ options: [
31
+ { label: 'Open', value: 'open' },
32
+ { label: 'Done', value: 'done' },
33
+ ],
34
+ },
35
+ }),
36
+ priority: pieces_framework_1.Property.StaticDropdown({
37
+ displayName: 'Priority',
38
+ description: 'Conversation priority from 1 (lowest) to 5 (highest).',
39
+ required: false,
40
+ options: {
41
+ options: [
42
+ { label: '1 — Lowest', value: 1 },
43
+ { label: '2 — Low', value: 2 },
44
+ { label: '3 — Medium', value: 3 },
45
+ { label: '4 — High', value: 4 },
46
+ { label: '5 — Highest', value: 5 },
47
+ ],
48
+ },
49
+ }),
50
+ direction: pieces_framework_1.Property.StaticDropdown({
51
+ displayName: 'Direction',
52
+ description: '"Inbound" means the customer initiated the conversation; "Outbound" means your team initiated it.',
53
+ required: false,
54
+ options: {
55
+ options: [
56
+ { label: 'Inbound', value: 'in' },
57
+ { label: 'Outbound', value: 'out' },
58
+ ],
59
+ },
60
+ }),
61
+ externalId: pieces_framework_1.Property.ShortText({
62
+ displayName: 'External ID',
63
+ description: 'A unique identifier from your own system to link this conversation (max 256 characters).',
64
+ required: false,
65
+ }),
66
+ replyChannel: pieces_framework_1.Property.ShortText({
67
+ displayName: 'Reply Channel',
68
+ description: 'The channel used to reply in this conversation (e.g. "email", "chat"). Leave empty to use the workspace default.',
69
+ required: false,
70
+ }),
71
+ },
72
+ run(context) {
73
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
+ const apiKey = context.auth.secret_text;
75
+ const props = context.propsValue;
76
+ const conversation = {
77
+ customer: props.customer,
78
+ };
79
+ if (props.name)
80
+ conversation['name'] = props.name;
81
+ if (props.status)
82
+ conversation['status'] = props.status;
83
+ if (props.priority !== null && props.priority !== undefined)
84
+ conversation['priority'] = props.priority;
85
+ if (props.direction)
86
+ conversation['direction'] = props.direction;
87
+ if (props.externalId)
88
+ conversation['externalId'] = props.externalId;
89
+ if (props.replyChannel)
90
+ conversation['replyChannel'] = props.replyChannel;
91
+ const response = yield client_1.kustomerClient.createConversation({
92
+ apiKey,
93
+ conversation,
94
+ });
95
+ return response;
96
+ });
97
+ },
98
+ });
99
+ //# sourceMappingURL=create-conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-conversation.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-conversation.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,yCAA8C;AAC9C,6CAAkD;AAIrC,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACnD,IAAI,EAAE,mBAAY;IAClB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,aAAa;YAC1B,WAAW,EACT,oKAAoK;YACtK,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,mBAAmB;YAChC,WAAW,EACT,qEAAqE;YACvE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC9B,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oBAChC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;iBACjC;aACF;SACF,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAChC,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,KAAK;YACf,OAAO,EA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I,KAAK,CAAC,MAAM;gBAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;YACxD,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;gBACzD,YAAY,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;YAC5C,IAAI,KAAK,CAAC,SAAS;gBAAE,YAAY,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;YACjE,IAAI,KAAK,CAAC,UAAU;gBAAE,YAAY,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC;YACpE,IAAI,KAAK,CAAC,YAAY;gBAAE,YAAY,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;YAE1E,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,kBAAkB,CAAC;gBACvD,MAAM;gBACN,YAAY;aACb,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const createCustomerAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
3
+ email: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ phone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ company: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ externalId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
+ username: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ locale: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ timeZone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
+ gender: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
11
+ birthdayAt: import("@activepieces/pieces-framework").ShortTextProperty<false>;
12
+ signedUpAt: import("@activepieces/pieces-framework").ShortTextProperty<false>;
13
+ avatarUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
+ }>;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCustomerAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const client_1 = require("../common/client");
8
+ exports.createCustomerAction = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.kustomerAuth,
10
+ name: 'create-customer',
11
+ displayName: 'Create Customer',
12
+ description: 'Creates a new customer record in Kustomer.',
13
+ props: {
14
+ name: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Full Name',
16
+ description: 'The customer\'s full name (e.g. "Jane Doe").',
17
+ required: false,
18
+ }),
19
+ email: pieces_framework_1.Property.ShortText({
20
+ displayName: 'Email Address',
21
+ description: 'Primary email address of the customer.',
22
+ required: false,
23
+ }),
24
+ phone: pieces_framework_1.Property.ShortText({
25
+ displayName: 'Phone Number',
26
+ description: 'Primary phone number in E.164 format (e.g. "+14155551234").',
27
+ required: false,
28
+ }),
29
+ company: pieces_framework_1.Property.ShortText({
30
+ displayName: 'Company',
31
+ description: 'Name of the company the customer belongs to.',
32
+ required: false,
33
+ }),
34
+ externalId: pieces_framework_1.Property.ShortText({
35
+ displayName: 'External ID',
36
+ description: 'Unique identifier from your own system (e.g. your CRM or database ID). Used to link this Kustomer record back to your data.',
37
+ required: false,
38
+ }),
39
+ username: pieces_framework_1.Property.ShortText({
40
+ displayName: 'Username',
41
+ description: "The customer's username in your system.",
42
+ required: false,
43
+ }),
44
+ locale: pieces_framework_1.Property.ShortText({
45
+ displayName: 'Locale',
46
+ description: 'Language/locale code for the customer (e.g. "en_US", "fr_FR", "de_DE").',
47
+ required: false,
48
+ }),
49
+ timeZone: pieces_framework_1.Property.ShortText({
50
+ displayName: 'Time Zone',
51
+ description: 'IANA timezone identifier (e.g. "America/New_York", "Europe/London", "Asia/Tokyo").',
52
+ required: false,
53
+ }),
54
+ gender: pieces_framework_1.Property.StaticDropdown({
55
+ displayName: 'Gender',
56
+ description: "The customer's gender.",
57
+ required: false,
58
+ options: {
59
+ options: [
60
+ { label: 'Male', value: 'm' },
61
+ { label: 'Female', value: 'f' },
62
+ ],
63
+ },
64
+ }),
65
+ birthdayAt: pieces_framework_1.Property.ShortText({
66
+ displayName: 'Birthday',
67
+ description: 'Customer\'s birth date in ISO 8601 format (e.g. "1990-06-15T00:00:00.000Z").',
68
+ required: false,
69
+ }),
70
+ signedUpAt: pieces_framework_1.Property.ShortText({
71
+ displayName: 'Signed Up At',
72
+ description: 'When the customer registered, in ISO 8601 format (e.g. "2024-01-15T10:30:00.000Z").',
73
+ required: false,
74
+ }),
75
+ avatarUrl: pieces_framework_1.Property.ShortText({
76
+ displayName: 'Avatar URL',
77
+ description: "URL of the customer's profile image.",
78
+ required: false,
79
+ }),
80
+ },
81
+ run(context) {
82
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
83
+ const apiKey = context.auth.secret_text;
84
+ const props = context.propsValue;
85
+ const customer = {};
86
+ if (props.name)
87
+ customer['name'] = props.name;
88
+ if (props.company)
89
+ customer['company'] = props.company;
90
+ if (props.externalId)
91
+ customer['externalId'] = props.externalId;
92
+ if (props.username)
93
+ customer['username'] = props.username;
94
+ if (props.locale)
95
+ customer['locale'] = props.locale;
96
+ if (props.timeZone)
97
+ customer['timeZone'] = props.timeZone;
98
+ if (props.gender)
99
+ customer['gender'] = props.gender;
100
+ if (props.birthdayAt)
101
+ customer['birthdayAt'] = props.birthdayAt;
102
+ if (props.signedUpAt)
103
+ customer['signedUpAt'] = props.signedUpAt;
104
+ if (props.avatarUrl)
105
+ customer['avatarUrl'] = props.avatarUrl;
106
+ if (props.email)
107
+ customer['emails'] = [{ email: props.email }];
108
+ if (props.phone)
109
+ customer['phones'] = [{ phone: props.phone }];
110
+ const response = yield client_1.kustomerClient.createCustomer({ apiKey, customer });
111
+ return response;
112
+ });
113
+ },
114
+ });
115
+ //# sourceMappingURL=create-customer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-customer.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-customer.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,yCAA8C;AAC9C,6CAAkD;AAIrC,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,mBAAY;IAClB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,4CAA4C;IACzD,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,8CAA8C;YAC3D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,wCAAwC;YACrD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,cAAc;YAC3B,WAAW,EACT,6DAA6D;YAC/D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,8CAA8C;YAC3D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,WAAW,EACT,6HAA6H;YAC/H,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,QAAQ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declare const getCustomObjectsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ klassName: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ fromDate: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ }>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomObjectsAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const client_1 = require("../common/client");
8
+ exports.getCustomObjectsAction = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.kustomerAuth,
10
+ name: 'get-custom-objects',
11
+ displayName: 'Get Custom Objects',
12
+ description: 'Retrieves all custom objects (KObjects) for a given class in Kustomer.',
13
+ props: {
14
+ klassName: pieces_framework_1.Property.ShortText({
15
+ displayName: 'KObject Class Name',
16
+ description: 'The API name of the custom object class to fetch (e.g. "order", "ticket"). You can find this in Kustomer under Settings > Custom Objects — it is the lowercase identifier, not the display label.',
17
+ required: true,
18
+ }),
19
+ fromDate: pieces_framework_1.Property.ShortText({
20
+ displayName: 'From Date',
21
+ description: 'Only return objects created or updated on or after this date. Use ISO 8601 format (e.g. "2024-01-15T00:00:00.000Z"). Leave empty to return all objects.',
22
+ required: false,
23
+ }),
24
+ },
25
+ run(context) {
26
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
27
+ const apiKey = context.auth.secret_text;
28
+ const { klassName, fromDate } = context.propsValue;
29
+ const response = yield client_1.kustomerClient.getCustomObjects(Object.assign({ apiKey,
30
+ klassName }, (fromDate ? { fromDate } : {})));
31
+ return response;
32
+ });
33
+ },
34
+ });
35
+ //# sourceMappingURL=get-custom-objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-custom-objects.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-custom-objects.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,yCAA8C;AAC9C,6CAAkD;AAGrC,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IACjD,IAAI,EAAE,mBAAY;IAClB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EACT,wEAAwE;IAC1E,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,oBAAoB;YACjC,WAAW,EACT,mMAAmM;YACrM,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,WAAW,EACT,yJAAyJ;YAC3J,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,WAAqB,CAAC;YAClD,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEnD,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,gBAAgB,iBACpD,MAAM;gBACN,SAAS,IACN,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACjC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const getCustomerAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ customerId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ }>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomerAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const client_1 = require("../common/client");
8
+ const utils_1 = require("../common/utils");
9
+ exports.getCustomerAction = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.kustomerAuth,
11
+ name: 'get-customer',
12
+ displayName: 'Get Customer',
13
+ description: 'Gets a customer by ID from Kustomer.',
14
+ props: {
15
+ customerId: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Customer ID',
17
+ description: 'The Kustomer customer ID.',
18
+ required: true,
19
+ }),
20
+ },
21
+ run(context) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ const apiKey = context.auth.secret_text;
24
+ const customerId = utils_1.kustomerUtils.parseRequiredString({
25
+ value: context.propsValue.customerId,
26
+ fieldName: 'Customer ID',
27
+ });
28
+ return client_1.kustomerClient.getCustomer({
29
+ apiKey,
30
+ customerId,
31
+ });
32
+ });
33
+ },
34
+ });
35
+ //# sourceMappingURL=get-customer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-customer.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-customer.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,yCAA8C;AAC9C,6CAAkD;AAClD,2CAAgD;AAEnC,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,mBAAY;IAClB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,2BAA2B;YACxC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC,WAAqB,CAAC;YACjD,MAAM,UAAU,GAAG,qBAAa,CAAC,mBAAmB,CAAC;gBACnD,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU;gBACpC,SAAS,EAAE,aAAa;aACzB,CAAC,CAAC;YAEH,OAAO,uBAAc,CAAC,WAAW,CAAC;gBAChC,MAAM;gBACN,UAAU;aACX,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const updateConversationAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ conversationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ status: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
4
+ priority: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
5
+ name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ direction: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
7
+ replyChannel: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ }>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateConversationAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const client_1 = require("../common/client");
8
+ exports.updateConversationAction = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.kustomerAuth,
10
+ name: 'update-conversation',
11
+ displayName: 'Update Conversation',
12
+ description: 'Updates an existing conversation in Kustomer.',
13
+ props: {
14
+ conversationId: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Conversation ID',
16
+ description: 'The Kustomer ID of the conversation to update. You can get this from the "Create Conversation" action output or from the URL when viewing a conversation in Kustomer.',
17
+ required: true,
18
+ }),
19
+ status: pieces_framework_1.Property.StaticDropdown({
20
+ displayName: 'Status',
21
+ description: 'Change the status of the conversation.',
22
+ required: false,
23
+ options: {
24
+ options: [
25
+ { label: 'Open', value: 'open' },
26
+ { label: 'Done', value: 'done' },
27
+ { label: 'Snoozed', value: 'snoozed' },
28
+ ],
29
+ },
30
+ }),
31
+ priority: pieces_framework_1.Property.StaticDropdown({
32
+ displayName: 'Priority',
33
+ description: 'Conversation priority from 1 (lowest) to 5 (highest).',
34
+ required: false,
35
+ options: {
36
+ options: [
37
+ { label: '1 — Lowest', value: 1 },
38
+ { label: '2 — Low', value: 2 },
39
+ { label: '3 — Medium', value: 3 },
40
+ { label: '4 — High', value: 4 },
41
+ { label: '5 — Highest', value: 5 },
42
+ ],
43
+ },
44
+ }),
45
+ name: pieces_framework_1.Property.ShortText({
46
+ displayName: 'Conversation Name',
47
+ description: 'Update the subject or title of the conversation.',
48
+ required: false,
49
+ }),
50
+ direction: pieces_framework_1.Property.StaticDropdown({
51
+ displayName: 'Direction',
52
+ description: '"Inbound" means the customer initiated the conversation; "Outbound" means your team initiated it.',
53
+ required: false,
54
+ options: {
55
+ options: [
56
+ { label: 'Inbound', value: 'in' },
57
+ { label: 'Outbound', value: 'out' },
58
+ ],
59
+ },
60
+ }),
61
+ replyChannel: pieces_framework_1.Property.ShortText({
62
+ displayName: 'Reply Channel',
63
+ description: 'The channel used to reply in this conversation (e.g. "email", "chat").',
64
+ required: false,
65
+ }),
66
+ },
67
+ run(context) {
68
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
69
+ const apiKey = context.auth.secret_text;
70
+ const props = context.propsValue;
71
+ const updates = {};
72
+ if (props.status)
73
+ updates['status'] = props.status;
74
+ if (props.priority !== null && props.priority !== undefined)
75
+ updates['priority'] = props.priority;
76
+ if (props.name !== null && props.name !== undefined)
77
+ updates['name'] = props.name;
78
+ if (props.direction)
79
+ updates['direction'] = props.direction;
80
+ if (props.replyChannel !== null && props.replyChannel !== undefined)
81
+ updates['replyChannel'] = props.replyChannel;
82
+ const response = yield client_1.kustomerClient.updateConversation({
83
+ apiKey,
84
+ conversationId: props.conversationId,
85
+ updates,
86
+ });
87
+ return response;
88
+ });
89
+ },
90
+ });
91
+ //# sourceMappingURL=update-conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-conversation.js","sourceRoot":"","sources":["../../../../src/lib/actions/update-conversation.ts"],"names":[],"mappings":";;;;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AAC,YAAY,KAAK,SAAS;gBACjE,OAAO,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;YAE/C,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,kBAAkB,CAAC;gBACvD,MAAM;gBACN,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const kustomerAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kustomerAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const shared_1 = require("@activepieces/shared");
7
+ const client_1 = require("./client");
8
+ exports.kustomerAuth = pieces_framework_1.PieceAuth.SecretText({
9
+ displayName: 'API Token',
10
+ description: `Authenticate using a Kustomer API token.
11
+
12
+ Paste a private Kustomer API token with access to customers, conversations, and KObjects.`,
13
+ required: true,
14
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
15
+ const apiKey = auth;
16
+ if (!apiKey) {
17
+ return {
18
+ valid: false,
19
+ error: 'Invalid API token.',
20
+ };
21
+ }
22
+ const { error } = yield (0, shared_1.tryCatch)(() => client_1.kustomerClient.validateAuth({
23
+ apiKey,
24
+ }));
25
+ if (error) {
26
+ return {
27
+ valid: false,
28
+ error: 'Invalid API token or missing Kustomer permissions.',
29
+ };
30
+ }
31
+ return {
32
+ valid: true,
33
+ };
34
+ }),
35
+ });
36
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAA2D;AAC3D,iDAAgD;AAChD,qCAA0C;AAE7B,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE;;0FAE2E;IACxF,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,MAAM,MAAM,GAAG,IAAc,CAAC;QAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,oBAAoB;aAC5B,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,iBAAQ,EAAC,GAAG,EAAE,CACpC,uBAAc,CAAC,YAAY,CAAC;YAC1B,MAAM;SACP,CAAC,CACH,CAAC;QAEF,IAAI,KAAK,EAAE,CAAC;YACV,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,oDAAoD;aAC5D,CAAC;QACJ,CAAC;QAED,OAAO;YACL,KAAK,EAAE,IAAI;SACZ,CAAC;IACJ,CAAC,CAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { KustomerJsonObject, KustomerJsonValue } from './types';
2
+ declare function validateAuth({ apiKey, }: {
3
+ apiKey: string;
4
+ }): Promise<void>;
5
+ declare function createCustomer({ apiKey, customer, }: {
6
+ apiKey: string;
7
+ customer: KustomerJsonObject;
8
+ }): Promise<KustomerJsonValue>;
9
+ declare function createConversation({ apiKey, conversation, }: {
10
+ apiKey: string;
11
+ conversation: KustomerJsonObject;
12
+ }): Promise<KustomerJsonValue>;
13
+ declare function updateConversation({ apiKey, conversationId, updates, }: {
14
+ apiKey: string;
15
+ conversationId: string;
16
+ updates: KustomerJsonObject;
17
+ }): Promise<KustomerJsonValue>;
18
+ declare function getCustomer({ apiKey, customerId, }: {
19
+ apiKey: string;
20
+ customerId: string;
21
+ }): Promise<KustomerJsonValue>;
22
+ declare function getCustomObjects({ apiKey, klassName, fromDate, }: {
23
+ apiKey: string;
24
+ klassName: string;
25
+ fromDate?: string;
26
+ }): Promise<KustomerJsonValue>;
27
+ declare function createAuthHeaders({ apiKey, }: {
28
+ apiKey: string;
29
+ }): Record<string, string>;
30
+ export declare const kustomerClient: {
31
+ validateAuth: typeof validateAuth;
32
+ createCustomer: typeof createCustomer;
33
+ createConversation: typeof createConversation;
34
+ updateConversation: typeof updateConversation;
35
+ getCustomer: typeof getCustomer;
36
+ getCustomObjects: typeof getCustomObjects;
37
+ createAuthHeaders: typeof createAuthHeaders;
38
+ };
39
+ export declare const KUSTOMER_API_BASE_URL = "https://api.kustomerapp.com/v1";
40
+ export {};
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KUSTOMER_API_BASE_URL = exports.kustomerClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ function validateAuth(_a) {
7
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, }) {
8
+ yield sendRequest({
9
+ apiKey,
10
+ method: pieces_common_1.HttpMethod.GET,
11
+ path: '/customers',
12
+ });
13
+ });
14
+ }
15
+ function createCustomer(_a) {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, customer, }) {
17
+ return sendRequest({
18
+ apiKey,
19
+ method: pieces_common_1.HttpMethod.POST,
20
+ path: '/customers',
21
+ body: customer,
22
+ });
23
+ });
24
+ }
25
+ function createConversation(_a) {
26
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, conversation, }) {
27
+ return sendRequest({
28
+ apiKey,
29
+ method: pieces_common_1.HttpMethod.POST,
30
+ path: '/conversations',
31
+ body: conversation,
32
+ });
33
+ });
34
+ }
35
+ function updateConversation(_a) {
36
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, conversationId, updates, }) {
37
+ return sendRequest({
38
+ apiKey,
39
+ method: pieces_common_1.HttpMethod.PUT,
40
+ path: `/conversations/${encodeURIComponent(conversationId)}`,
41
+ body: updates,
42
+ });
43
+ });
44
+ }
45
+ function getCustomer(_a) {
46
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, customerId, }) {
47
+ return sendRequest({
48
+ apiKey,
49
+ method: pieces_common_1.HttpMethod.GET,
50
+ path: `/customers/${encodeURIComponent(customerId)}`,
51
+ });
52
+ });
53
+ }
54
+ function getCustomObjects(_a) {
55
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, klassName, fromDate, }) {
56
+ return sendRequest(Object.assign({ apiKey, method: pieces_common_1.HttpMethod.GET, path: `/kobjects/${encodeURIComponent(klassName)}` }, (fromDate ? { queryParams: { fromDate } } : {})));
57
+ });
58
+ }
59
+ function createAuthHeaders({ apiKey, }) {
60
+ return {
61
+ Authorization: `Bearer ${apiKey}`,
62
+ Accept: 'application/json',
63
+ 'Content-Type': 'application/json',
64
+ };
65
+ }
66
+ function sendRequest(_a) {
67
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, method, path, body, queryParams, }) {
68
+ const request = Object.assign(Object.assign({ method, url: `${exports.KUSTOMER_API_BASE_URL}${path}`, headers: createAuthHeaders({
69
+ apiKey,
70
+ }) }, (body ? { body } : {})), (queryParams ? { queryParams } : {}));
71
+ const response = yield pieces_common_1.httpClient.sendRequest(request);
72
+ return response.body;
73
+ });
74
+ }
75
+ exports.kustomerClient = {
76
+ validateAuth,
77
+ createCustomer,
78
+ createConversation,
79
+ updateConversation,
80
+ getCustomer,
81
+ getCustomObjects,
82
+ createAuthHeaders,
83
+ };
84
+ exports.KUSTOMER_API_BASE_URL = 'https://api.kustomerapp.com/v1';
85
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;;;AAAA,+DAIqC;AAQrC,SAAe,YAAY;iEAAC,EAC1B,MAAM,GAGP;QACC,MAAM,WAAW,CAAC;YAChB,MAAM;Y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,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAClD,CAAC;IACL,CAAC;CAAA;AAED,SAAS,iBAAiB,CAAC,EACzB,MAAM,GAGP;IACC,OAAO;QACL,aAAa,EAAE,UAAU,MAAM,EAAE;QACjC,MAAM,EAAE,kBAAkB;QAC1B,cAAc,EAAE,kBAAkB;KACnC,CAAC;AACJ,CAAC;AAED,SAAe,WAAW;iEAAC,EACzB,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,WAAW,GAOZ;QACC,MAAM,OAAO,iCACX,MAAM,EACN,GAAG,EAAE,GAAG,6BAAqB,GAAG,IAAI,EAAE,EACtC,OAAO,EAAE,iBAAiB,CAAC;gBACzB,MAAM;aACP,CAAC,IACC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACtB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACxC,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAoB,OAAO,CAAC,CAAC;QAE1E,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CAAA;AAEY,QAAA,cAAc,GAAG;IAC5B,YAAY;IACZ,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,WAAW;IACX,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAEW,QAAA,qBAAqB,GAAG,gCAAgC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type KustomerJsonPrimitive = string | number | boolean | null;
2
+ export type KustomerJsonValue = KustomerJsonPrimitive | KustomerJsonObject | KustomerJsonValue[];
3
+ export type KustomerJsonObject = {
4
+ [key: string]: KustomerJsonValue;
5
+ };
6
+ export type KustomerQueryParams = Record<string, string>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/common/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { KustomerJsonObject } from './types';
2
+ declare function parseRequiredString({ value, fieldName, }: {
3
+ value: unknown;
4
+ fieldName: string;
5
+ }): string;
6
+ declare function parseJsonObject({ value, fieldName, }: {
7
+ value: unknown;
8
+ fieldName: string;
9
+ }): KustomerJsonObject;
10
+ export declare const kustomerUtils: {
11
+ parseRequiredString: typeof parseRequiredString;
12
+ parseJsonObject: typeof parseJsonObject;
13
+ };
14
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kustomerUtils = void 0;
4
+ function parseRequiredString({ value, fieldName, }) {
5
+ if (typeof value !== 'string' || value.trim().length === 0) {
6
+ throw new Error(`${fieldName} is required.`);
7
+ }
8
+ return value.trim();
9
+ }
10
+ function parseJsonObject({ value, fieldName, }) {
11
+ if (!isKustomerJsonObject(value)) {
12
+ throw new Error(`${fieldName} must be a JSON object.`);
13
+ }
14
+ return value;
15
+ }
16
+ function isKustomerJsonObject(value) {
17
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
18
+ return false;
19
+ }
20
+ return Object.values(value).every(isKustomerJsonValue);
21
+ }
22
+ function isKustomerJsonValue(value) {
23
+ if (typeof value === 'string' ||
24
+ typeof value === 'number' ||
25
+ typeof value === 'boolean' ||
26
+ value === null) {
27
+ return true;
28
+ }
29
+ if (Array.isArray(value)) {
30
+ return value.every(isKustomerJsonValue);
31
+ }
32
+ return isKustomerJsonObject(value);
33
+ }
34
+ exports.kustomerUtils = {
35
+ parseRequiredString,
36
+ parseJsonObject,
37
+ };
38
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/lib/common/utils.ts"],"names":[],"mappings":";;;AAEA,SAA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