@segment/action-destinations 3.402.0 → 3.404.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 (39) hide show
  1. package/dist/destinations/amazon-conversions-api/index.js +10 -0
  2. package/dist/destinations/amazon-conversions-api/index.js.map +1 -1
  3. package/dist/destinations/amazon-conversions-api/trackConversion/index.js +3 -2
  4. package/dist/destinations/amazon-conversions-api/trackConversion/index.js.map +1 -1
  5. package/dist/destinations/amazon-conversions-api/trackConversion/utils.d.ts +2 -1
  6. package/dist/destinations/amazon-conversions-api/trackConversion/utils.js +21 -7
  7. package/dist/destinations/amazon-conversions-api/trackConversion/utils.js.map +1 -1
  8. package/dist/destinations/braze/identifyUser2/generated-types.d.ts +6 -1
  9. package/dist/destinations/braze/identifyUser2/index.d.ts +11 -0
  10. package/dist/destinations/braze/identifyUser2/index.js +111 -13
  11. package/dist/destinations/braze/identifyUser2/index.js.map +1 -1
  12. package/dist/destinations/braze/index.js +2 -0
  13. package/dist/destinations/braze/index.js.map +1 -1
  14. package/dist/destinations/braze/upsertCatalogItem/generated-types.d.ts +22 -0
  15. package/dist/destinations/braze/upsertCatalogItem/generated-types.js +3 -0
  16. package/dist/destinations/braze/upsertCatalogItem/generated-types.js.map +1 -0
  17. package/dist/destinations/braze/upsertCatalogItem/index.d.ts +5 -0
  18. package/dist/destinations/braze/upsertCatalogItem/index.js +267 -0
  19. package/dist/destinations/braze/upsertCatalogItem/index.js.map +1 -0
  20. package/dist/destinations/braze/upsertCatalogItem/types.d.ts +29 -0
  21. package/dist/destinations/braze/upsertCatalogItem/types.js +3 -0
  22. package/dist/destinations/braze/upsertCatalogItem/types.js.map +1 -0
  23. package/dist/destinations/braze/upsertCatalogItem/utils.d.ts +16 -0
  24. package/dist/destinations/braze/upsertCatalogItem/utils.js +185 -0
  25. package/dist/destinations/braze/upsertCatalogItem/utils.js.map +1 -0
  26. package/dist/destinations/twilio-messaging/sendMessage/constants.d.ts +3 -3
  27. package/dist/destinations/twilio-messaging/sendMessage/constants.js +13 -7
  28. package/dist/destinations/twilio-messaging/sendMessage/constants.js.map +1 -1
  29. package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.d.ts +0 -1
  30. package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js +21 -73
  31. package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js.map +1 -1
  32. package/dist/destinations/twilio-messaging/sendMessage/fields.js +3 -53
  33. package/dist/destinations/twilio-messaging/sendMessage/fields.js.map +1 -1
  34. package/dist/destinations/twilio-messaging/sendMessage/generated-types.d.ts +0 -6
  35. package/dist/destinations/twilio-messaging/sendMessage/index.js +0 -5
  36. package/dist/destinations/twilio-messaging/sendMessage/index.js.map +1 -1
  37. package/dist/destinations/twilio-messaging/sendMessage/utils.js +35 -55
  38. package/dist/destinations/twilio-messaging/sendMessage/utils.js.map +1 -1
  39. package/package.json +2 -2
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const actions_core_1 = require("@segment/actions-core");
7
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
8
+ const utils_1 = require("./utils");
9
+ const UPSERT_OPERATION = {
10
+ match: 'all',
11
+ conditions: [{ type: 'field', fieldKey: '__segment_internal_sync_mode', operator: 'is', value: 'upsert' }]
12
+ };
13
+ const CREATE_OPERATION = {
14
+ match: 'all',
15
+ conditions: [{ fieldKey: 'operation', operator: 'is', value: 'create' }]
16
+ };
17
+ const SELECT_OPERATION = {
18
+ match: 'all',
19
+ conditions: [{ fieldKey: 'operation', operator: 'is', value: 'select' }]
20
+ };
21
+ const catalogHook = {
22
+ label: 'Select or Create a Catalog',
23
+ description: 'Select an existing catalog or create a new one in Braze.',
24
+ inputFields: {
25
+ operation: {
26
+ label: 'Operation',
27
+ description: 'Whether to select an existing catalog or create a new one in Braze.',
28
+ type: 'string',
29
+ disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
30
+ choices: [
31
+ { label: 'Create a new catalog', value: 'create' },
32
+ { label: 'Select an existing catalog', value: 'select' }
33
+ ],
34
+ required: true
35
+ },
36
+ selected_catalog_name: {
37
+ label: 'Catalog Name',
38
+ description: 'The unique name of the catalog.',
39
+ type: 'string',
40
+ required: SELECT_OPERATION,
41
+ disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
42
+ depends_on: SELECT_OPERATION,
43
+ dynamic: async (request, { settings }) => {
44
+ return (0, utils_1.getCatalogNames)(request, { settings });
45
+ }
46
+ },
47
+ created_catalog_name: {
48
+ label: 'Catalog Name',
49
+ description: 'The name of the catalog. Must be unique. Maximum 250 characters. Supported characters: letters, numbers, hyphens, and underscores.',
50
+ type: 'string',
51
+ required: CREATE_OPERATION,
52
+ depends_on: CREATE_OPERATION
53
+ },
54
+ description: {
55
+ label: 'Catalog Description',
56
+ description: 'The description of the catalog. Maximum 250 characters.',
57
+ type: 'string',
58
+ depends_on: CREATE_OPERATION
59
+ },
60
+ columns: {
61
+ label: 'Catalog Fields',
62
+ description: 'A list of fields to create in the catalog. Maximum 500 fields. ID field is added by default.',
63
+ type: 'object',
64
+ multiple: true,
65
+ defaultObjectUI: 'arrayeditor',
66
+ additionalProperties: true,
67
+ required: CREATE_OPERATION,
68
+ depends_on: CREATE_OPERATION,
69
+ properties: {
70
+ name: {
71
+ label: 'Field Name',
72
+ description: 'The name of the field. Maximum 250 characters. Supported characters: letters, numbers, hyphens, and underscores.',
73
+ type: 'string',
74
+ required: true
75
+ },
76
+ type: {
77
+ label: 'Field Type',
78
+ description: 'The data type of the field.',
79
+ type: 'string',
80
+ required: true,
81
+ choices: ['string', 'number', 'time', 'boolean', 'object', 'array']
82
+ }
83
+ }
84
+ }
85
+ },
86
+ performHook: async (request, { settings, hookInputs }) => {
87
+ if (hookInputs?.operation === 'select') {
88
+ return {
89
+ successMessage: 'Catalog selected successfully',
90
+ savedData: {
91
+ catalog_name: hookInputs?.selected_catalog_name ?? ''
92
+ }
93
+ };
94
+ }
95
+ return await (0, utils_1.createCatalog)(request, settings.endpoint, hookInputs);
96
+ },
97
+ outputTypes: {
98
+ catalog_name: {
99
+ label: 'Catalog Name',
100
+ description: 'The name of the catalog.',
101
+ type: 'string',
102
+ required: true
103
+ }
104
+ }
105
+ };
106
+ const action = {
107
+ title: 'Upsert Catalog Item',
108
+ description: 'Upserts or deletes items in a catalog',
109
+ syncMode: {
110
+ description: 'Define how the records from your destination will be synced.',
111
+ label: 'How to sync records',
112
+ default: 'upsert',
113
+ choices: [
114
+ { label: 'Upsert Catalog Item', value: 'upsert' },
115
+ { label: 'Delete Catalog Item', value: 'delete' }
116
+ ]
117
+ },
118
+ fields: {
119
+ item: {
120
+ label: 'Catalog item to upsert',
121
+ description: 'The item to upsert in the catalog. The item object should contain fields that exist in the catalog. The item object should not contain the id field.',
122
+ type: 'object',
123
+ required: UPSERT_OPERATION,
124
+ depends_on: UPSERT_OPERATION,
125
+ defaultObjectUI: 'keyvalue:only',
126
+ dynamic: true
127
+ },
128
+ item_id: {
129
+ label: 'Item ID',
130
+ description: 'The unique identifier for the item. Maximum 250 characters. Supported characters: letters, numbers, hyphens, and underscores.',
131
+ type: 'string',
132
+ required: true,
133
+ maximum: 250,
134
+ minimum: 1
135
+ },
136
+ enable_batching: {
137
+ type: 'boolean',
138
+ label: 'Batch Data to Braze?',
139
+ description: 'If true, Segment will batch events before sending to Braze.',
140
+ default: true
141
+ },
142
+ batch_size: {
143
+ type: 'number',
144
+ label: 'Batch Size',
145
+ description: 'If batching is enabled, this is the number of events to include in each batch. Maximum 50 events per batch.',
146
+ minimum: 1,
147
+ maximum: 50,
148
+ default: 50,
149
+ unsafe_hidden: true
150
+ }
151
+ },
152
+ hooks: {
153
+ onMappingSave: { ...catalogHook }
154
+ },
155
+ dynamicFields: {
156
+ item: {
157
+ __keys__: async (request, { settings, payload }) => {
158
+ return await (0, utils_1.getItemKeys)(request, settings, payload);
159
+ }
160
+ }
161
+ },
162
+ perform: async (request, { settings, payload, syncMode, hookOutputs }) => {
163
+ const catalog_name = hookOutputs?.onMappingSave?.outputs?.catalog_name;
164
+ const { item_id = '' } = payload;
165
+ const { item = {} } = payload;
166
+ if (!(0, utils_1.isValidItemId)(item_id)) {
167
+ throw new actions_core_1.IntegrationError(`Invalid ID Format`, actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED, 400);
168
+ }
169
+ if (syncMode === 'upsert') {
170
+ if ((0, actions_core_1.isObject)(item) && (0, isEmpty_1.default)(item)) {
171
+ throw new actions_core_1.IntegrationError('Item is required', actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED, 400);
172
+ }
173
+ }
174
+ try {
175
+ return await request(`${settings.endpoint}/catalogs/${catalog_name}/items/${item_id}`, {
176
+ method: syncMode === 'upsert' ? 'PUT' : 'DELETE',
177
+ headers: {
178
+ 'Content-Type': 'application/json'
179
+ },
180
+ json: {
181
+ items: [item]
182
+ }
183
+ });
184
+ }
185
+ catch (error) {
186
+ if (error?.response?.data?.errors?.[0]?.id === 'item-not-found' &&
187
+ syncMode === 'delete') {
188
+ return {
189
+ status: 200,
190
+ message: 'Could not find item'
191
+ };
192
+ }
193
+ else {
194
+ throw new actions_core_1.IntegrationError(`${error?.response?.data?.errors?.[0]?.message}`, `Error ${syncMode}ing item`, error?.response?.status ?? 500);
195
+ }
196
+ }
197
+ },
198
+ performBatch: async (request, { settings, payload, syncMode, hookOutputs }) => {
199
+ const catalog_name = hookOutputs?.onMappingSave?.outputs?.catalog_name;
200
+ const multiStatusResponse = new actions_core_1.MultiStatusResponse();
201
+ const validPayloadMap = new Map();
202
+ const items = [];
203
+ for (let batchIndex = 0; batchIndex < payload.length; batchIndex++) {
204
+ const { item_id = '', item = {} } = payload[batchIndex];
205
+ if (validPayloadMap.has(item_id)) {
206
+ multiStatusResponse.setErrorResponseAtIndex(batchIndex, {
207
+ status: 400,
208
+ errortype: actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED,
209
+ errormessage: 'Every item in the batch must have a unique item_id'
210
+ });
211
+ continue;
212
+ }
213
+ let body = {};
214
+ if (!(0, utils_1.isValidItemId)(item_id)) {
215
+ multiStatusResponse.setErrorResponseAtIndex(batchIndex, {
216
+ status: 400,
217
+ errortype: actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED,
218
+ errormessage: 'Invalid ID Format'
219
+ });
220
+ continue;
221
+ }
222
+ if (syncMode === 'upsert') {
223
+ if ((0, actions_core_1.isObject)(item) && (0, isEmpty_1.default)(item)) {
224
+ multiStatusResponse.setErrorResponseAtIndex(batchIndex, {
225
+ status: 400,
226
+ errortype: actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED,
227
+ errormessage: 'Item is required'
228
+ });
229
+ continue;
230
+ }
231
+ body = {
232
+ ...item
233
+ };
234
+ }
235
+ body.id = item_id;
236
+ items.push(body);
237
+ validPayloadMap.set(item_id, batchIndex);
238
+ }
239
+ if (items.length === 0) {
240
+ return multiStatusResponse;
241
+ }
242
+ try {
243
+ const response = await request(`${settings.endpoint}/catalogs/${catalog_name}/items/`, {
244
+ method: syncMode === 'upsert' ? 'PUT' : 'DELETE',
245
+ headers: {
246
+ 'Content-Type': 'application/json'
247
+ },
248
+ json: {
249
+ items
250
+ }
251
+ });
252
+ validPayloadMap.forEach((index, id) => {
253
+ multiStatusResponse.setSuccessResponseAtIndex(index, {
254
+ status: 200,
255
+ sent: { ...payload[index]?.item, id },
256
+ body: response?.data
257
+ });
258
+ });
259
+ }
260
+ catch (error) {
261
+ (0, utils_1.processMultiStatusErrorResponse)(error?.response?.data, multiStatusResponse, validPayloadMap, payload);
262
+ }
263
+ return multiStatusResponse;
264
+ }
265
+ };
266
+ exports.default = action;
267
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dest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AAA;SAC3B;QAED,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,aAAa,YAAY,SAAS,EAAE;gBACrF,MAAM,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;gBAChD,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE;oBACJ,KAAK;iBACN;aACF,CAAC,CAAA;YAEF,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;gBACpC,mBAAmB,CAAC,yBAAyB,CAAC,KAAK,EAAE;oBACnD,MAAM,EAAE,GAAG;oBACX,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,EAAoB;oBACvD,IAAI,EAAE,QAAQ,EAAE,IAAsB;iBACvC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;SACH;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,uCAA+B,EAC7B,KAAK,EAAE,QAAQ,EAAE,IAAsC,EACvD,mBAAmB,EACnB,eAAe,EACf,OAAO,CACR,CAAA;SACF;QAED,OAAO,mBAAmB,CAAA;IAC5B,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { JSONLikeObject } from '@segment/actions-core/json-object';
2
+ export interface CatalogSchema {
3
+ description?: string;
4
+ fields?: {
5
+ name: string;
6
+ token: string;
7
+ type: 'string' | 'number' | 'time' | 'boolean';
8
+ }[];
9
+ name: string;
10
+ num_items?: Number;
11
+ storage_size?: Number;
12
+ updated_at?: string;
13
+ selections_size?: Number;
14
+ source?: Number;
15
+ selections: unknown[];
16
+ }
17
+ export interface ListCatalogsResponse {
18
+ catalogs?: CatalogSchema[];
19
+ message?: string;
20
+ }
21
+ export interface UpsertCatalogItemErrorResponse {
22
+ message?: string;
23
+ errors: {
24
+ id?: string;
25
+ message?: string;
26
+ parameters?: string[];
27
+ parameter_values?: string[] | JSONLikeObject[];
28
+ }[];
29
+ }
@@ -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/destinations/braze/upsertCatalogItem/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { RequestClient } from '@segment/actions-core/create-request-client';
2
+ import { UpsertCatalogItemErrorResponse } from './types';
3
+ import { ActionHookResponse, MultiStatusResponse } from '@segment/actions-core/destination-kit/action';
4
+ import { OnMappingSaveInputs, Payload } from './generated-types';
5
+ import { DynamicFieldResponse } from '@segment/actions-core/index';
6
+ import { Settings } from '../generated-types';
7
+ export declare function getCatalogMetas(request: RequestClient, endpoint: string): Promise<import("./types").CatalogSchema[] | undefined>;
8
+ export declare function createCatalog(request: RequestClient, endpoint: string, hookInputs?: OnMappingSaveInputs): Promise<ActionHookResponse<{
9
+ catalog_name: string;
10
+ }>>;
11
+ export declare function isValidItemId(item_id: string): boolean;
12
+ export declare function processMultiStatusErrorResponse(response: UpsertCatalogItemErrorResponse, multiStatusResponse: MultiStatusResponse, validPayloadMap: Map<string, number>, payload: Payload[]): void;
13
+ export declare function getCatalogNames(request: RequestClient, { settings }: {
14
+ settings: Settings;
15
+ }): Promise<DynamicFieldResponse>;
16
+ export declare function getItemKeys(request: RequestClient, settings: Settings, payload: Payload): Promise<DynamicFieldResponse>;
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getItemKeys = exports.getCatalogNames = exports.processMultiStatusErrorResponse = exports.isValidItemId = exports.createCatalog = exports.getCatalogMetas = void 0;
4
+ async function getCatalogMetas(request, endpoint) {
5
+ const response = await request(`${endpoint}/catalogs`, {
6
+ method: 'get'
7
+ });
8
+ return response?.data?.catalogs;
9
+ }
10
+ exports.getCatalogMetas = getCatalogMetas;
11
+ async function createCatalog(request, endpoint, hookInputs) {
12
+ const { created_catalog_name = '', description = '', columns = [] } = hookInputs ?? {};
13
+ const fields = [{ name: 'id', type: 'string' }].concat(columns
14
+ ?.filter((column) => column.name !== 'id')
15
+ .map((column) => ({
16
+ name: column?.name,
17
+ type: column?.type
18
+ })));
19
+ const body = {
20
+ catalogs: [
21
+ {
22
+ name: created_catalog_name,
23
+ description,
24
+ fields
25
+ }
26
+ ]
27
+ };
28
+ try {
29
+ await request(`${endpoint}/catalogs`, {
30
+ method: 'POST',
31
+ headers: {
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ json: body
35
+ });
36
+ return {
37
+ successMessage: 'Catalog created successfully',
38
+ savedData: {
39
+ catalog_name: created_catalog_name
40
+ }
41
+ };
42
+ }
43
+ catch (error) {
44
+ return {
45
+ error: {
46
+ message: (error?.response?.data).errors?.[0]?.message ?? 'Unknown Error',
47
+ code: 'ERROR'
48
+ }
49
+ };
50
+ }
51
+ }
52
+ exports.createCatalog = createCatalog;
53
+ function isValidItemId(item_id) {
54
+ return /^[a-zA-Z0-9_-]+$/.test(item_id);
55
+ }
56
+ exports.isValidItemId = isValidItemId;
57
+ function processMultiStatusErrorResponse(response, multiStatusResponse, validPayloadMap, payload) {
58
+ const { errors = [] } = response ?? {};
59
+ let isValidCatalog = true;
60
+ errors?.forEach((error) => {
61
+ const isObject = Array.isArray(error?.parameters) && error.parameters.length > 1;
62
+ if (error?.id !== 'catalog-not-found') {
63
+ error.parameter_values?.forEach((parameter_value) => {
64
+ const itemId = isObject ? parameter_value?.['id'] : parameter_value;
65
+ if (validPayloadMap.has(itemId)) {
66
+ const index = validPayloadMap.get(itemId);
67
+ multiStatusResponse.setErrorResponseAtIndex(index, {
68
+ status: 400,
69
+ errortype: 'PAYLOAD_VALIDATION_FAILED',
70
+ errormessage: error.message || 'Unknown error',
71
+ sent: { ...payload[index]?.item, id: itemId },
72
+ body: error
73
+ });
74
+ validPayloadMap.delete(itemId);
75
+ }
76
+ });
77
+ }
78
+ else {
79
+ isValidCatalog = false;
80
+ }
81
+ });
82
+ if (!isValidCatalog) {
83
+ validPayloadMap.forEach((index, itemId) => {
84
+ multiStatusResponse.setErrorResponseAtIndex(index, {
85
+ status: 404,
86
+ errortype: 'NOT_FOUND',
87
+ errormessage: `Catalog not found. Please create a catalog first.`,
88
+ sent: { ...payload[index]?.item, id: itemId },
89
+ body: JSON.stringify(errors)
90
+ });
91
+ });
92
+ return;
93
+ }
94
+ if (validPayloadMap.size > 0) {
95
+ validPayloadMap.forEach((index, itemId) => {
96
+ multiStatusResponse.setErrorResponseAtIndex(index, {
97
+ status: 500,
98
+ errortype: 'RETRYABLE_ERROR',
99
+ errormessage: `Item with ID ${itemId} could not be processed due to invalid catalog items in the batch request.`,
100
+ sent: { ...payload[index]?.item, id: itemId },
101
+ body: JSON.stringify(errors)
102
+ });
103
+ });
104
+ }
105
+ }
106
+ exports.processMultiStatusErrorResponse = processMultiStatusErrorResponse;
107
+ async function getCatalogNames(request, { settings }) {
108
+ let choices = [];
109
+ try {
110
+ const catalogs = await getCatalogMetas(request, settings.endpoint);
111
+ if (catalogs?.length) {
112
+ choices = catalogs.map((catalog) => ({
113
+ label: catalog.name,
114
+ value: catalog.name,
115
+ type: 'string',
116
+ description: catalog?.description
117
+ }));
118
+ return {
119
+ choices
120
+ };
121
+ }
122
+ return {
123
+ choices,
124
+ error: {
125
+ message: 'No catalogs found. Please create a catalog first.',
126
+ code: '404'
127
+ }
128
+ };
129
+ }
130
+ catch (err) {
131
+ return {
132
+ choices,
133
+ error: {
134
+ message: 'Unknown error. Please try again later',
135
+ code: '500'
136
+ }
137
+ };
138
+ }
139
+ }
140
+ exports.getCatalogNames = getCatalogNames;
141
+ async function getItemKeys(request, settings, payload) {
142
+ const catalog_name = payload?.onMappingSave?.outputs?.catalog_name ?? '';
143
+ try {
144
+ const catalogs = await getCatalogMetas(request, settings.endpoint);
145
+ if (!catalogs?.length) {
146
+ return {
147
+ choices: [],
148
+ error: {
149
+ message: 'No catalogs found. Please create a catalog first.',
150
+ code: '404'
151
+ }
152
+ };
153
+ }
154
+ const catalog = catalogs?.find((catalog) => catalog.name === catalog_name);
155
+ if (catalog && Array.isArray(catalog.fields)) {
156
+ const choices = catalog.fields
157
+ .map((field) => ({
158
+ label: field.name,
159
+ value: field.name
160
+ }))
161
+ .filter((field) => field.value !== 'id');
162
+ return {
163
+ choices
164
+ };
165
+ }
166
+ return {
167
+ choices: [],
168
+ error: {
169
+ message: `Catalog "${catalog_name}" not found or has no fields.`,
170
+ code: '404'
171
+ }
172
+ };
173
+ }
174
+ catch (error) {
175
+ return {
176
+ choices: [],
177
+ error: {
178
+ message: error,
179
+ code: '500'
180
+ }
181
+ };
182
+ }
183
+ }
184
+ exports.getItemKeys = getItemKeys;
185
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/destinations/braze/upsertCatalogItem/utils.ts"],"names":[],"mappings":";;;AASO,KAAK,UAAU,eAAe,CAAC,OAAsB,EAAE,QAAgB;IAC5E,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAuB,GAAG,QAAQ,WAAW,EAAE;QAC3E,MAAM,EAAE,KAAK;KACd,CAAC,CAAA;IAEF,OAAO,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAA;AACjC,CAAC;AAND,0CAMC;AAEM,KAAK,UAAU,aAAa,CACjC,OAAsB,EACtB,QAAgB,EAChB,UAAgC;IAEhC,MAAM,EAAE,oBAAoB,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;IAEtF,MAAM,MAAM,GAAqC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CACtF,OAAO;QACL,EAAE,MAAM,CAAC,CAAC,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F,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO;YACL,OAAO,EAAE,EAAE;YACX,KAAK,EAAE;gBACL,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,KAAK;aACZ;SACF,CAAA;KACF;AACH,CAAC;AA/CD,kCA+CC"}
@@ -19,6 +19,7 @@ export declare const CHANNELS: {
19
19
  readonly MMS: "MMS";
20
20
  readonly WHATSAPP: "Whatsapp";
21
21
  readonly MESSENGER: "Messenger";
22
+ readonly RCS: "RCS";
22
23
  };
23
24
  export declare const PREDEFINED_CONTENT_TYPES: PredefinedContentTypes;
24
25
  export declare const INLINE_CONTENT_TYPES: {
@@ -26,7 +27,7 @@ export declare const INLINE_CONTENT_TYPES: {
26
27
  friendly_name: string;
27
28
  name: undefined;
28
29
  supports_media: boolean;
29
- supported_channels: ("SMS" | "MMS" | "Whatsapp" | "Messenger")[];
30
+ supported_channels: ("SMS" | "MMS" | "Whatsapp" | "Messenger" | "RCS")[];
30
31
  };
31
32
  };
32
33
  export declare const ALL_CONTENT_TYPES: {
@@ -34,10 +35,9 @@ export declare const ALL_CONTENT_TYPES: {
34
35
  friendly_name: string;
35
36
  name: undefined;
36
37
  supports_media: boolean;
37
- supported_channels: ("SMS" | "MMS" | "Whatsapp" | "Messenger")[];
38
+ supported_channels: ("SMS" | "MMS" | "Whatsapp" | "Messenger" | "RCS")[];
38
39
  };
39
40
  };
40
- export declare const CONTENT_TYPE_FRIENDLY_NAMES_SUPPORTING_MEDIA: string[];
41
41
  export declare const SENDER_TYPE: {
42
42
  PHONE_NUMBER: string;
43
43
  MESSENGER_SENDER_ID: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SENDER_TYPE = exports.CONTENT_TYPE_FRIENDLY_NAMES_SUPPORTING_MEDIA = exports.ALL_CONTENT_TYPES = exports.INLINE_CONTENT_TYPES = exports.PREDEFINED_CONTENT_TYPES = exports.CHANNELS = exports.GET_CONTENT_VARIABLES_URL = exports.GET_CONTENT_URL = exports.GET_ALL_CONTENTS_URL = exports.GET_MESSAGING_SERVICE_SIDS_URL = exports.GET_INCOMING_SHORT_CODES_URL = exports.GET_INCOMING_PHONE_NUMBERS_URL = exports.CONTENT_SID_REGEX = exports.MESSAGING_SERVICE_SID_REGEX = exports.TWILIO_SHORT_CODE_REGEX = exports.E164_REGEX = exports.TOKEN_REGEX = exports.FIELD_REGEX = exports.SEND_SMS_URL = exports.ACCOUNT_SID_TOKEN = exports.CONTENT_SID_TOKEN = void 0;
3
+ exports.SENDER_TYPE = exports.ALL_CONTENT_TYPES = exports.INLINE_CONTENT_TYPES = exports.PREDEFINED_CONTENT_TYPES = exports.CHANNELS = exports.GET_CONTENT_VARIABLES_URL = exports.GET_CONTENT_URL = exports.GET_ALL_CONTENTS_URL = exports.GET_MESSAGING_SERVICE_SIDS_URL = exports.GET_INCOMING_SHORT_CODES_URL = exports.GET_INCOMING_PHONE_NUMBERS_URL = exports.CONTENT_SID_REGEX = exports.MESSAGING_SERVICE_SID_REGEX = exports.TWILIO_SHORT_CODE_REGEX = exports.E164_REGEX = exports.TOKEN_REGEX = exports.FIELD_REGEX = exports.SEND_SMS_URL = exports.ACCOUNT_SID_TOKEN = exports.CONTENT_SID_TOKEN = void 0;
4
4
  exports.CONTENT_SID_TOKEN = '{accountSid}';
5
5
  exports.ACCOUNT_SID_TOKEN = '{accountSid}';
6
6
  exports.SEND_SMS_URL = `https://api.twilio.com/2010-04-01/Accounts/${exports.ACCOUNT_SID_TOKEN}/Messages.json`;
@@ -20,20 +20,21 @@ exports.CHANNELS = {
20
20
  SMS: 'SMS',
21
21
  MMS: 'MMS',
22
22
  WHATSAPP: 'Whatsapp',
23
- MESSENGER: 'Messenger'
23
+ MESSENGER: 'Messenger',
24
+ RCS: 'RCS'
24
25
  };
25
26
  exports.PREDEFINED_CONTENT_TYPES = {
26
27
  TEXT: {
27
28
  friendly_name: 'Text',
28
29
  name: 'twilio/text',
29
30
  supports_media: false,
30
- supported_channels: [exports.CHANNELS.SMS, exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER]
31
+ supported_channels: [exports.CHANNELS.SMS, exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER, exports.CHANNELS.RCS]
31
32
  },
32
33
  MEDIA: {
33
34
  friendly_name: 'Media',
34
35
  name: 'twilio/media',
35
36
  supports_media: true,
36
- supported_channels: [exports.CHANNELS.MMS, exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER]
37
+ supported_channels: [exports.CHANNELS.MMS, exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER, exports.CHANNELS.RCS]
37
38
  },
38
39
  QUICK_REPLY: {
39
40
  friendly_name: 'Quick Reply',
@@ -57,7 +58,7 @@ exports.PREDEFINED_CONTENT_TYPES = {
57
58
  friendly_name: 'Card',
58
59
  name: 'twilio/card',
59
60
  supports_media: true,
60
- supported_channels: [exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER]
61
+ supported_channels: [exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER, exports.CHANNELS.RCS]
61
62
  },
62
63
  WHATSAPP_CARD: {
63
64
  friendly_name: 'WhatsApp Card',
@@ -76,6 +77,12 @@ exports.PREDEFINED_CONTENT_TYPES = {
76
77
  name: 'twilio/catalog',
77
78
  supports_media: false,
78
79
  supported_channels: [exports.CHANNELS.WHATSAPP]
80
+ },
81
+ CAROUSEL: {
82
+ friendly_name: 'Carousel',
83
+ name: 'twilio/catalog',
84
+ supports_media: false,
85
+ supported_channels: [exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER, exports.CHANNELS.RCS]
79
86
  }
80
87
  };
81
88
  exports.INLINE_CONTENT_TYPES = {
@@ -83,14 +90,13 @@ exports.INLINE_CONTENT_TYPES = {
83
90
  friendly_name: 'Inline',
84
91
  name: undefined,
85
92
  supports_media: true,
86
- supported_channels: [exports.CHANNELS.SMS, exports.CHANNELS.MMS, exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER]
93
+ supported_channels: [exports.CHANNELS.SMS, exports.CHANNELS.MMS, exports.CHANNELS.WHATSAPP, exports.CHANNELS.MESSENGER, exports.CHANNELS.RCS]
87
94
  }
88
95
  };
89
96
  exports.ALL_CONTENT_TYPES = {
90
97
  ...exports.PREDEFINED_CONTENT_TYPES,
91
98
  ...exports.INLINE_CONTENT_TYPES
92
99
  };
93
- exports.CONTENT_TYPE_FRIENDLY_NAMES_SUPPORTING_MEDIA = Object.values(exports.ALL_CONTENT_TYPES).filter((t) => t.supports_media).map((t) => t.friendly_name);
94
100
  exports.SENDER_TYPE = {
95
101
  PHONE_NUMBER: 'Phone number',
96
102
  MESSENGER_SENDER_ID: 'Messenger Sender ID',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,iBAAiB,GAAG,cAAc,CAAA;AAElC,QAAA,iBAAiB,GAAG,cAAc,CAAA;AAElC,QAAA,YAAY,GAAG,8CAA8C,yBAAiB,gBAAgB,CAAA;AAE9F,QAAA,WAAW,GAAG,WAAW,CAAA;AAEzB,QAAA,WAAW,GAAG,YAAY,CAAA;AAE1B,QAAA,UAAU,GAAG,mBAAmB,CAAA;AAEhC,QAAA,uBAAuB,GAAG,gBAAgB,CAAA;AAE1C,QAAA,2BAA2B,GAAG,qBAAqB,CAAA;AAEnD,QAAA,iBAAiB,GAAG,qBAAqB,CAAA;AAEzC,QAAA,8BAA8B,GAAG,8CAA8C,yBAAiB,0CAA0C,CAAA;AAE1I,QAAA,4BAA4B,GAAG,8CAA8C,yBAAiB,oCAAoC,CAAA;AAElI,QAAA,8BAA8B,GAAG,wDAAwD,CAAA;AAEzF,QAAA,oBAAoB,GAAG,qDAAqD,CAAA;AAE5E,QAAA,eAAe,GAAG,yCAAyC,yBAAiB,EAAE,CAAA;AAE9E,QAAA,yBAAyB,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AAS;QACxB,IAAI,EAAE,gBAAgB;QACtB,cAAc,EAAE,KAAK;QACrB,kBAAkB,EAAE,CAAC,gBAAQ,CAAC,QAAQ,CAAC;KACxC;IACD,QAAQ,EAAE;QACR,aAAa,EAAE,UAAU;QACzB,IAAI,EAAE,gBAAgB;QACtB,cAAc,EAAE,KAAK;QACrB,kBAAkB,EAAE,CAAC,gBAAQ,CAAC,QAAQ,EAAE,gBAAQ,CAAC,SAAS,EAAE,gBAAQ,CAAC,GAAG,CAAC;KAC1E;CACF,CAAA;AAEY,QAAA,oBAAoB,GAAG;IAClC,MAAM,EAAE;QACN,aAAa,EAAE,QAAQ;QACvB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,IAAI;QACpB,kBAAkB,EAAE,CAAC,gBAAQ,CAAC,GAAG,EAAE,gBAAQ,CAAC,GAAG,EAAE,gBAAQ,CAAC,QAAQ,EAAE,gBAAQ,CAAC,SAAS,EAAE,gBAAQ,CAAC,GAAG,CAAC;KACtG;CACF,CAAA;AAEY,QAAA,iBAAiB,GAAG;IAC/B,GAAG,gCAAwB;IAC3B,GAAG,4BAAoB;CACxB,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,YAAY,EAAE,cAAc;IAC5B,mBAAmB,EAAE,qBAAqB;IAC1C,iBAAiB,EAAE,mBAAmB;CACvC,CAAA"}
@@ -7,5 +7,4 @@ export declare function dynamicFromPhoneNumber(request: RequestClient, payload:
7
7
  export declare function dynamicMessagingServiceSid(request: RequestClient, settings: Settings): Promise<DynamicFieldResponse>;
8
8
  export declare function dynamicContentTemplateType(payload: Payload): Promise<DynamicFieldResponse>;
9
9
  export declare function dynamicContentSid(request: RequestClient, payload: Payload): Promise<DynamicFieldResponse>;
10
- export declare function dynamicMediaUrls(request: RequestClient, payload: Payload): Promise<DynamicFieldResponse>;
11
10
  export declare function dynamicContentVariables(request: RequestClient, payload: Payload): Promise<DynamicFieldResponse>;