@segment/action-destinations 3.400.0 → 3.401.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.
- package/dist/destinations/braze/index.js +3 -1
- package/dist/destinations/braze/index.js.map +1 -1
- package/dist/destinations/braze/triggerCampaign/functions/dynamic-field-functions.d.ts +7 -0
- package/dist/destinations/braze/triggerCampaign/functions/dynamic-field-functions.js +54 -0
- package/dist/destinations/braze/triggerCampaign/functions/dynamic-field-functions.js.map +1 -0
- package/dist/destinations/braze/triggerCampaign/generated-types.d.ts +33 -0
- package/dist/destinations/braze/triggerCampaign/generated-types.js +3 -0
- package/dist/destinations/braze/triggerCampaign/generated-types.js.map +1 -0
- package/dist/destinations/braze/triggerCampaign/index.d.ts +5 -0
- package/dist/destinations/braze/triggerCampaign/index.js +235 -0
- package/dist/destinations/braze/triggerCampaign/index.js.map +1 -0
- package/package.json +4 -4
|
@@ -14,6 +14,7 @@ const updateUserProfile_1 = __importDefault(require("./updateUserProfile"));
|
|
|
14
14
|
const trackEvent2_1 = __importDefault(require("./trackEvent2"));
|
|
15
15
|
const trackPurchase2_1 = __importDefault(require("./trackPurchase2"));
|
|
16
16
|
const updateUserProfile2_1 = __importDefault(require("./updateUserProfile2"));
|
|
17
|
+
const triggerCampaign_1 = __importDefault(require("./triggerCampaign"));
|
|
17
18
|
const destination = {
|
|
18
19
|
name: 'Braze Cloud Mode (Actions)',
|
|
19
20
|
slug: 'actions-braze-cloud',
|
|
@@ -85,7 +86,8 @@ const destination = {
|
|
|
85
86
|
trackEvent2: trackEvent2_1.default,
|
|
86
87
|
trackPurchase2: trackPurchase2_1.default,
|
|
87
88
|
updateUserProfile2: updateUserProfile2_1.default,
|
|
88
|
-
createAlias2: createAlias2_1.default
|
|
89
|
+
createAlias2: createAlias2_1.default,
|
|
90
|
+
triggerCampaign: triggerCampaign_1.default
|
|
89
91
|
},
|
|
90
92
|
presets: [
|
|
91
93
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/braze/index.ts"],"names":[],"mappings":";;;;;AAEA,wDAA8E;AAC9E,gEAAuC;AACvC,kEAAyC;AACzC,kEAAyC;AACzC,oEAA2C;AAC3C,8DAAqC;AACrC,oEAA2C;AAC3C,4EAAmD;AACnD,gEAAuC;AACvC,sEAA6C;AAC7C,8EAAqD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/braze/index.ts"],"names":[],"mappings":";;;;;AAEA,wDAA8E;AAC9E,gEAAuC;AACvC,kEAAyC;AACzC,kEAAyC;AACzC,oEAA2C;AAC3C,8DAAqC;AACrC,oEAA2C;AAC3C,4EAAmD;AACnD,gEAAuC;AACvC,sEAA6C;AAC7C,8EAAqD;AACrD,wEAA+C;AAE/C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,gDAAgD;IAC7D,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,yDAAyD;gBACtE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,IAAI;aACf;YACD,MAAM,EAAE;gBACN,KAAK,EAAE,QAAQ;gBACf,WAAW,EACT,+IAA+I;gBACjJ,IAAI,EAAE,QAAQ;aACf;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,eAAe;gBACtB,WAAW,EAAE,gGAAgG;gBAC7G,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,wCAAwC,EAAE,KAAK,EAAE,+BAA+B,EAAE;oBAC3F,EAAE,KAAK,EAAE,wCAAwC,EAAE,KAAK,EAAE,+BAA+B,EAAE;oBAC3F,EAAE,KAAK,EAAE,wC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@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestClient, DynamicFieldResponse } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../../generated-types';
|
|
3
|
+
export declare const dynamicFields: {
|
|
4
|
+
campaign_id: (request: RequestClient, { settings }: {
|
|
5
|
+
settings: Settings;
|
|
6
|
+
}) => Promise<DynamicFieldResponse>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamicFields = void 0;
|
|
4
|
+
exports.dynamicFields = {
|
|
5
|
+
campaign_id: async (request, { settings }) => {
|
|
6
|
+
try {
|
|
7
|
+
const allCampaigns = [];
|
|
8
|
+
let page = 0;
|
|
9
|
+
while (true) {
|
|
10
|
+
const response = await request(`${settings.endpoint}/campaigns/list`, {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
skipResponseCloning: true,
|
|
13
|
+
searchParams: {
|
|
14
|
+
page: page.toString()
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const data = response.data;
|
|
18
|
+
if (!data.campaigns || !Array.isArray(data.campaigns) || data.campaigns.length === 0) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
if (data.campaigns) {
|
|
22
|
+
allCampaigns.push(...data.campaigns);
|
|
23
|
+
}
|
|
24
|
+
page++;
|
|
25
|
+
}
|
|
26
|
+
if (allCampaigns.length === 0) {
|
|
27
|
+
return {
|
|
28
|
+
choices: [],
|
|
29
|
+
error: {
|
|
30
|
+
message: 'No campaigns found in your Braze account',
|
|
31
|
+
code: '404'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const campaigns = allCampaigns.map((campaign) => ({
|
|
36
|
+
label: campaign.name,
|
|
37
|
+
value: campaign.id
|
|
38
|
+
}));
|
|
39
|
+
return {
|
|
40
|
+
choices: campaigns
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
choices: [],
|
|
46
|
+
error: {
|
|
47
|
+
message: error.message || 'Failed to fetch campaigns from Braze API',
|
|
48
|
+
code: error.status || '500'
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=dynamic-field-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-field-functions.js","sourceRoot":"","sources":["../../../../../src/destinations/braze/triggerCampaign/functions/dynamic-field-functions.ts"],"names":[],"mappings":";;;AAca,QAAA,aAAa,GAAG;IAC3B,WAAW,EAAE,KAAK,EAAE,OAAsB,EAAE,EAAE,QAAQ,EAA0B,EAAiC,EAAE;QACjH,IAAI;YACF,MAAM,YAAY,GAAe,EAAE,CAAA;YACnC,IAAI,IAAI,GAAG,CAAC,CAAA;YAGZ,OAAO,IAAI,EAAE;gBACX,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,iBAAiB,EAAE;oBACpE,MAAM,EAAE,KAAK;oBACb,mBAAmB,EAAE,IAAI;oBACzB,YAAY,EAAE;wBACZ,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;qBACtB;iBACF,CAAC,CAAA;gBACF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAwB,CAAA;gBAE9C,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;oBACpF,MAAK;iBACN;gBAGD,IAAI,IAAI,CAAC,SAAS,EAAE;oBAClB,YAAY,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;iBACrC;gBAGD,IAAI,EAAE,CAAA;aACP;YAED,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC7B,OAAO;oBACL,OAAO,EAAE,EAAE;oBACX,KAAK,EAAE;wBACL,OAAO,EAAE,0CAA0C;wBACnD,IAAI,EAAE,KAAK;qBACZ;iBACF,CAAA;aACF;YAGD,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAChD,KAAK,EAAE,QAAQ,CAAC,IAAI;gBACpB,KAAK,EAAE,QAAQ,CAAC,EAAE;aACnB,CAAC,CAAC,CAAA;YAEH,OAAO;gBACL,OAAO,EAAE,SAAS;aACnB,CAAA;SACF;QAAC,OAAO,KAAU,EAAE;YACnB,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,KAAK,EAAE;oBACL,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,0CAA0C;oBACpE,IAAI,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK;iBAC5B;aACF,CAAA;SACF;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
campaign_id: string;
|
|
3
|
+
send_id?: string;
|
|
4
|
+
trigger_properties?: {
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
broadcast?: boolean;
|
|
8
|
+
attachments?: {
|
|
9
|
+
file_name: string;
|
|
10
|
+
url: string;
|
|
11
|
+
}[];
|
|
12
|
+
recipients?: {
|
|
13
|
+
external_user_id?: string;
|
|
14
|
+
user_alias?: {
|
|
15
|
+
[k: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
email?: string;
|
|
18
|
+
trigger_properties?: {
|
|
19
|
+
[k: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
send_to_existing_only?: boolean;
|
|
22
|
+
attributes?: {
|
|
23
|
+
[k: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
}[];
|
|
26
|
+
prioritization?: {
|
|
27
|
+
first_priority?: string;
|
|
28
|
+
second_priority?: string;
|
|
29
|
+
};
|
|
30
|
+
audience?: {
|
|
31
|
+
[k: string]: unknown;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/braze/triggerCampaign/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const dynamic_field_functions_1 = require("./functions/dynamic-field-functions");
|
|
5
|
+
const prioritizationChoices = [
|
|
6
|
+
{ label: 'Identified', value: 'identified' },
|
|
7
|
+
{ label: 'Unidentified', value: 'unidentified' },
|
|
8
|
+
{ label: 'Most recently updated', value: 'most_recently_updated' },
|
|
9
|
+
{ label: 'Least recently updated', value: 'least_recently_updated' }
|
|
10
|
+
];
|
|
11
|
+
const action = {
|
|
12
|
+
title: 'Trigger Campaign',
|
|
13
|
+
description: 'Trigger a Braze Campaign via API-triggered delivery',
|
|
14
|
+
defaultSubscription: 'type = "track"',
|
|
15
|
+
dynamicFields: {
|
|
16
|
+
...dynamic_field_functions_1.dynamicFields
|
|
17
|
+
},
|
|
18
|
+
fields: {
|
|
19
|
+
campaign_id: {
|
|
20
|
+
label: 'Campaign ID',
|
|
21
|
+
description: 'The ID of the Braze campaign to trigger. The campaign must be an API-triggered campaign created in Braze.',
|
|
22
|
+
type: 'string',
|
|
23
|
+
required: true,
|
|
24
|
+
dynamic: true
|
|
25
|
+
},
|
|
26
|
+
send_id: {
|
|
27
|
+
label: 'Send ID',
|
|
28
|
+
description: 'Optional string to identify the send. This can be used for send level analytics, or to cancel a send.',
|
|
29
|
+
type: 'string'
|
|
30
|
+
},
|
|
31
|
+
trigger_properties: {
|
|
32
|
+
label: 'Trigger Properties',
|
|
33
|
+
description: 'Optional data that will be used to personalize the campaign message. Personalization key-value pairs that will apply to all users in this request.',
|
|
34
|
+
type: 'object',
|
|
35
|
+
default: {
|
|
36
|
+
'@path': '$.properties'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
broadcast: {
|
|
40
|
+
label: 'Broadcast',
|
|
41
|
+
description: 'If set to true, and if the audience is not provided, the campaign will be sent to all the users in the segment targeted by the campaign. It can not be used with "recipients".',
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
required: {
|
|
44
|
+
match: 'all',
|
|
45
|
+
conditions: [
|
|
46
|
+
{
|
|
47
|
+
fieldKey: 'recipients',
|
|
48
|
+
operator: 'is',
|
|
49
|
+
value: undefined
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
fieldKey: 'audience',
|
|
53
|
+
operator: 'is',
|
|
54
|
+
value: undefined
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
depends_on: {
|
|
59
|
+
match: 'all',
|
|
60
|
+
conditions: [
|
|
61
|
+
{
|
|
62
|
+
fieldKey: 'recipients',
|
|
63
|
+
operator: 'is',
|
|
64
|
+
value: undefined
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
attachments: {
|
|
70
|
+
label: 'Attachments',
|
|
71
|
+
description: 'Attachments to send along with the campaign. Limited to 2MB per file.',
|
|
72
|
+
type: 'object',
|
|
73
|
+
multiple: true,
|
|
74
|
+
properties: {
|
|
75
|
+
file_name: {
|
|
76
|
+
label: 'File Name',
|
|
77
|
+
description: 'The name of the file to be attached.',
|
|
78
|
+
type: 'string',
|
|
79
|
+
required: true
|
|
80
|
+
},
|
|
81
|
+
url: {
|
|
82
|
+
label: 'URL',
|
|
83
|
+
description: 'The URL of the file to be attached.',
|
|
84
|
+
type: 'string',
|
|
85
|
+
required: true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
defaultObjectUI: 'arrayeditor'
|
|
89
|
+
},
|
|
90
|
+
recipients: {
|
|
91
|
+
label: 'Recipients',
|
|
92
|
+
description: 'An array of user identifiers to send the campaign to. It can not be used with "broadcast".',
|
|
93
|
+
type: 'object',
|
|
94
|
+
multiple: true,
|
|
95
|
+
depends_on: {
|
|
96
|
+
match: 'all',
|
|
97
|
+
conditions: [
|
|
98
|
+
{
|
|
99
|
+
fieldKey: 'broadcast',
|
|
100
|
+
operator: 'is_not',
|
|
101
|
+
value: true
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
properties: {
|
|
106
|
+
external_user_id: {
|
|
107
|
+
label: 'External User ID',
|
|
108
|
+
description: 'External identifier of user to receive message.',
|
|
109
|
+
type: 'string',
|
|
110
|
+
default: {
|
|
111
|
+
'@path': '$.userId'
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
user_alias: {
|
|
115
|
+
label: 'User Alias',
|
|
116
|
+
description: 'User alias object to identify the user.',
|
|
117
|
+
type: 'object'
|
|
118
|
+
},
|
|
119
|
+
email: {
|
|
120
|
+
label: 'Email',
|
|
121
|
+
description: 'Email address of user to receive message.',
|
|
122
|
+
type: 'string',
|
|
123
|
+
default: {
|
|
124
|
+
'@path': '$.traits.email'
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
trigger_properties: {
|
|
128
|
+
label: 'User Trigger Properties',
|
|
129
|
+
description: 'Properties that will override the default trigger_properties for a specific user.',
|
|
130
|
+
type: 'object'
|
|
131
|
+
},
|
|
132
|
+
send_to_existing_only: {
|
|
133
|
+
label: 'Send to Existing Only',
|
|
134
|
+
description: "Defaults to true, can't be used with user aliases; if set to false, an attributes object must also be included.",
|
|
135
|
+
type: 'boolean'
|
|
136
|
+
},
|
|
137
|
+
attributes: {
|
|
138
|
+
label: 'User Attributes',
|
|
139
|
+
description: 'Fields in the attributes object will create or update an attribute of that name with the given value on the specified user profile before the message is sent and existing values will be overwritten.',
|
|
140
|
+
type: 'object'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
prioritization: {
|
|
145
|
+
label: 'Prioritization',
|
|
146
|
+
description: 'Prioritization settings; required when using email in recipients. This prioritization will be applied to all recipients.',
|
|
147
|
+
type: 'object',
|
|
148
|
+
properties: {
|
|
149
|
+
first_priority: {
|
|
150
|
+
label: 'First Priority',
|
|
151
|
+
description: 'First priority in the prioritization sequence',
|
|
152
|
+
type: 'string',
|
|
153
|
+
choices: prioritizationChoices
|
|
154
|
+
},
|
|
155
|
+
second_priority: {
|
|
156
|
+
label: 'Second Priority',
|
|
157
|
+
description: 'Second priority in the prioritization sequence',
|
|
158
|
+
type: 'string',
|
|
159
|
+
choices: prioritizationChoices
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
depends_on: {
|
|
163
|
+
match: 'all',
|
|
164
|
+
conditions: [
|
|
165
|
+
{
|
|
166
|
+
fieldKey: 'broadcast',
|
|
167
|
+
operator: 'is_not',
|
|
168
|
+
value: true
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
audience: {
|
|
174
|
+
label: 'Audience',
|
|
175
|
+
description: 'A standard audience object to specify the users to send the campaign to. Including "audience" will only send to users in the audience',
|
|
176
|
+
type: 'object',
|
|
177
|
+
depends_on: {
|
|
178
|
+
match: 'all',
|
|
179
|
+
conditions: [
|
|
180
|
+
{
|
|
181
|
+
fieldKey: 'recipients',
|
|
182
|
+
operator: 'is',
|
|
183
|
+
value: undefined
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
fieldKey: 'broadcast',
|
|
187
|
+
operator: 'is',
|
|
188
|
+
value: true
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
perform: async (request, { settings, payload }) => {
|
|
195
|
+
if (!payload.broadcast && (!payload.recipients || payload.recipients.length === 0)) {
|
|
196
|
+
throw new actions_core_1.PayloadValidationError('Either "broadcast" must be true or "recipients" list must be provided.');
|
|
197
|
+
}
|
|
198
|
+
if (payload.broadcast && payload.recipients && payload.recipients.length > 0) {
|
|
199
|
+
throw new actions_core_1.PayloadValidationError('When "broadcast" is true, "recipients" list cannot be included.');
|
|
200
|
+
}
|
|
201
|
+
if (payload.recipients?.length && payload.prioritization) {
|
|
202
|
+
const prioritizationArray = [];
|
|
203
|
+
if (payload.prioritization?.first_priority) {
|
|
204
|
+
prioritizationArray.push(payload.prioritization.first_priority);
|
|
205
|
+
}
|
|
206
|
+
if (payload.prioritization?.second_priority) {
|
|
207
|
+
prioritizationArray.push(payload.prioritization.second_priority);
|
|
208
|
+
}
|
|
209
|
+
if (prioritizationArray.length > 0) {
|
|
210
|
+
payload.recipients = payload.recipients.map((recipient) => ({
|
|
211
|
+
...recipient,
|
|
212
|
+
prioritization: prioritizationArray
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
delete payload.prioritization;
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
return await request(`${settings.endpoint}/campaigns/trigger/send`, {
|
|
219
|
+
method: 'post',
|
|
220
|
+
json: payload
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
if (error instanceof actions_core_1.HTTPError && error.response) {
|
|
225
|
+
const responseContent = error.response;
|
|
226
|
+
if (responseContent.data?.message) {
|
|
227
|
+
throw new actions_core_1.APIError(responseContent.data.message, error.response.status);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
exports.default = action;
|
|
235
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/braze/triggerCampaign/index.ts"],"names":[],"mappings":";;AACA,wDAAqG;AAGrG,iFAAmE;AAEnE,MAAM,qBAAqB,GAAG;IAC5B,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,KAAK,EAAE,c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AAE;gBAChD,MAAM,eAAe,GAAG,KAAK,CAAC,QAAkD,CAAA;gBAChF,IAAI,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE;oBACjC,MAAM,IAAI,uBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;iBACxE;aACF;YACD,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
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.
|
|
4
|
+
"version": "3.401.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@aws-sdk/client-s3": "^3.600.0",
|
|
46
46
|
"@bufbuild/protobuf": "^2.2.3",
|
|
47
47
|
"@segment/a1-notation": "^2.1.4",
|
|
48
|
-
"@segment/actions-core": "^3.
|
|
49
|
-
"@segment/actions-shared": "^1.
|
|
48
|
+
"@segment/actions-core": "^3.156.0",
|
|
49
|
+
"@segment/actions-shared": "^1.137.0",
|
|
50
50
|
"@types/node": "^22.13.1",
|
|
51
51
|
"ajv-formats": "^2.1.1",
|
|
52
52
|
"aws4": "^1.12.0",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"__tests__/__helpers__/"
|
|
91
91
|
]
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "6888f4e178bb0a1d6c42e564c45651c83d2fdfa3"
|
|
94
94
|
}
|