@segment/action-destinations 3.419.0 → 3.420.1-staging-4888ea022.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/algolia-insights/algolia-insight-api.d.ts +1 -0
- package/dist/destinations/algolia-insights/conversionEvents/generated-types.d.ts +1 -0
- package/dist/destinations/algolia-insights/conversionEvents/index.js +11 -4
- package/dist/destinations/algolia-insights/conversionEvents/index.js.map +1 -1
- package/dist/destinations/algolia-insights/index.js +5 -2
- package/dist/destinations/algolia-insights/index.js.map +1 -1
- package/dist/destinations/algolia-insights/productClickedEvents/generated-types.d.ts +1 -0
- package/dist/destinations/algolia-insights/productClickedEvents/index.js +11 -4
- package/dist/destinations/algolia-insights/productClickedEvents/index.js.map +1 -1
- package/dist/destinations/algolia-insights/productListFilteredEvents/generated-types.d.ts +1 -0
- package/dist/destinations/algolia-insights/productListFilteredEvents/index.js +11 -4
- package/dist/destinations/algolia-insights/productListFilteredEvents/index.js.map +1 -1
- package/dist/destinations/algolia-insights/productListViewedEvents/generated-types.d.ts +15 -0
- package/dist/destinations/algolia-insights/productListViewedEvents/generated-types.js.map +1 -0
- package/dist/destinations/algolia-insights/productListViewedEvents/index.d.ts +5 -0
- package/dist/destinations/algolia-insights/productListViewedEvents/index.js +142 -0
- package/dist/destinations/algolia-insights/productListViewedEvents/index.js.map +1 -0
- package/dist/destinations/algolia-insights/productViewedEvents/generated-types.d.ts +1 -0
- package/dist/destinations/algolia-insights/productViewedEvents/index.js +14 -7
- package/dist/destinations/algolia-insights/productViewedEvents/index.js.map +1 -1
- package/dist/destinations/amazon-eventbridge/generated-types.d.ts +2 -4
- package/dist/destinations/amazon-eventbridge/index.js +4 -32
- package/dist/destinations/amazon-eventbridge/index.js.map +1 -1
- package/dist/destinations/amazon-eventbridge/send/constants.d.ts +26 -0
- package/dist/destinations/amazon-eventbridge/send/constants.js +27 -0
- package/dist/destinations/amazon-eventbridge/send/constants.js.map +1 -0
- package/dist/destinations/amazon-eventbridge/send/functions.d.ts +5 -0
- package/dist/destinations/amazon-eventbridge/send/functions.js +104 -0
- package/dist/destinations/amazon-eventbridge/send/functions.js.map +1 -0
- package/dist/destinations/amazon-eventbridge/send/generated-types.d.ts +11 -1
- package/dist/destinations/amazon-eventbridge/send/hooks.d.ts +8 -0
- package/dist/destinations/amazon-eventbridge/send/hooks.js +115 -0
- package/dist/destinations/amazon-eventbridge/send/hooks.js.map +1 -0
- package/dist/destinations/amazon-eventbridge/send/index.js +20 -25
- package/dist/destinations/amazon-eventbridge/send/index.js.map +1 -1
- package/dist/destinations/amazon-eventbridge/send/types.d.ts +27 -0
- package/dist/destinations/amazon-eventbridge/send/types.js +3 -0
- package/dist/destinations/amazon-eventbridge/send/types.js.map +1 -0
- package/dist/destinations/batch/constants.d.ts +3 -0
- package/dist/destinations/batch/constants.js +7 -0
- package/dist/destinations/batch/constants.js.map +1 -0
- package/dist/destinations/batch/index.js +2 -1
- package/dist/destinations/batch/index.js.map +1 -1
- package/dist/destinations/batch/updateProfile/index.js +5 -4
- package/dist/destinations/batch/updateProfile/index.js.map +1 -1
- package/dist/destinations/batch/updateProfile/type.d.ts +11 -0
- package/dist/destinations/batch/updateProfile/utils.d.ts +3 -1
- package/dist/destinations/batch/updateProfile/utils.js +37 -1
- package/dist/destinations/batch/updateProfile/utils.js.map +1 -1
- package/dist/destinations/kafka/index.js +1 -1
- package/dist/destinations/kafka/index.js.map +1 -1
- package/dist/destinations/kafka/send/generated-types.d.ts +2 -0
- package/dist/destinations/kafka/send/index.js +18 -2
- package/dist/destinations/kafka/send/index.js.map +1 -1
- package/dist/destinations/kafka/utils.d.ts +2 -3
- package/dist/destinations/kafka/utils.js +87 -24
- package/dist/destinations/kafka/utils.js.map +1 -1
- package/dist/destinations/klaviyo/functions.d.ts +3 -3
- package/dist/destinations/klaviyo/functions.js +42 -21
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +5 -3
- package/dist/destinations/klaviyo/types.js.map +1 -1
- package/dist/destinations/klaviyo/upsertProfile/index.js +25 -27
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/stackadapt/index.js +1 -1
- package/dist/destinations/stackadapt/index.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js +3 -3
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/forwardProfile/functions.js +2 -2
- package/dist/destinations/stackadapt-audiences/forwardProfile/functions.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/functions.d.ts +1 -0
- package/dist/destinations/stackadapt-audiences/functions.js +8 -2
- package/dist/destinations/stackadapt-audiences/functions.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/index.js +9 -0
- package/dist/destinations/the-trade-desk-crm/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/destinations/amazon-eventbridge/functions.d.ts +0 -3
- package/dist/destinations/amazon-eventbridge/functions.js +0 -53
- package/dist/destinations/amazon-eventbridge/functions.js.map +0 -1
- package/dist/destinations/amazon-eventbridge/functionsv2.d.ts +0 -4
- package/dist/destinations/amazon-eventbridge/functionsv2.js +0 -68
- package/dist/destinations/amazon-eventbridge/functionsv2.js.map +0 -1
- package/dist/destinations/amazon-eventbridge/sendV2/generated-types.d.ts +0 -11
- package/dist/destinations/amazon-eventbridge/sendV2/generated-types.js.map +0 -1
- package/dist/destinations/amazon-eventbridge/sendV2/index.d.ts +0 -5
- package/dist/destinations/amazon-eventbridge/sendV2/index.js +0 -90
- package/dist/destinations/amazon-eventbridge/sendV2/index.js.map +0 -1
- package/dist/destinations/batch/updateProfile/constants.d.ts +0 -2
- package/dist/destinations/batch/updateProfile/constants.js +0 -6
- package/dist/destinations/batch/updateProfile/constants.js.map +0 -1
- /package/dist/destinations/{amazon-eventbridge/sendV2 → algolia-insights/productListViewedEvents}/generated-types.js +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EBNotErrors = exports.EBRetryableErrors = exports.EBNotRetryableErrors = exports.SEGMENT_PARTNER_NAME = void 0;
|
|
4
|
+
exports.SEGMENT_PARTNER_NAME = 'aws.partner/segment.com';
|
|
5
|
+
exports.EBNotRetryableErrors = {
|
|
6
|
+
LimitExceededException: 'NON_RETRYABLE',
|
|
7
|
+
OperationDisabledException: 'NON_RETRYABLE',
|
|
8
|
+
AccessDeniedException: 'NON_RETRYABLE',
|
|
9
|
+
NotAuthorized: 'NON_RETRYABLE',
|
|
10
|
+
IncompleteSignature: 'NON_RETRYABLE',
|
|
11
|
+
InvalidAction: 'NON_RETRYABLE',
|
|
12
|
+
InvalidClientTokenId: 'NON_RETRYABLE',
|
|
13
|
+
OptInRequired: 'NON_RETRYABLE',
|
|
14
|
+
RequestExpired: 'NON_RETRYABLE',
|
|
15
|
+
ValidationError: 'NON_RETRYABLE'
|
|
16
|
+
};
|
|
17
|
+
exports.EBRetryableErrors = {
|
|
18
|
+
ConcurrentModificationException: 'RETRYABLE',
|
|
19
|
+
InternalException: 'RETRYABLE',
|
|
20
|
+
InternalFailure: 'RETRYABLE',
|
|
21
|
+
ThrottlingException: 'RETRYABLE',
|
|
22
|
+
ServiceUnavailable: 'RETRYABLE'
|
|
23
|
+
};
|
|
24
|
+
exports.EBNotErrors = {
|
|
25
|
+
ResourceAlreadyExistsException: 'NOT_AN_ERROR'
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-eventbridge/send/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,yBAAyB,CAAA;AAEhD,QAAA,oBAAoB,GAAG;IAClC,sBAAsB,EAAE,eAAe;IACvC,0BAA0B,EAAE,eAAe;IAC3C,qBAAqB,EAAE,eAAe;IACtC,aAAa,EAAE,eAAe;IAC9B,mBAAmB,EAAE,eAAe;IACpC,aAAa,EAAE,eAAe;IAC9B,oBAAoB,EAAE,eAAe;IACrC,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,eAAe;IAC/B,eAAe,EAAE,eAAe;CACxB,CAAA;AAEG,QAAA,iBAAiB,GAAG;IAC/B,+BAA+B,EAAE,WAAW;IAC5C,iBAAiB,EAAE,WAAW;IAC9B,eAAe,EAAE,WAAW;IAC5B,mBAAmB,EAAE,WAAW;IAChC,kBAAkB,EAAE,WAAW;CACvB,CAAA;AAEG,QAAA,WAAW,GAAG;IACzB,8BAA8B,EAAE,cAAc;CACtC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Payload } from './generated-types';
|
|
2
|
+
import { Settings } from '../generated-types';
|
|
3
|
+
import { MultiStatusResponse } from '@segment/actions-core';
|
|
4
|
+
import { HookOutputs } from './types';
|
|
5
|
+
export declare function send(payloads: Payload[], settings: Settings, hookOutputs?: HookOutputs): Promise<MultiStatusResponse>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.send = send;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const client_eventbridge_1 = require("@aws-sdk/client-eventbridge");
|
|
7
|
+
async function send(payloads, settings, hookOutputs) {
|
|
8
|
+
const sourceId = getSourceId(payloads, hookOutputs);
|
|
9
|
+
const { region } = settings;
|
|
10
|
+
const client = new client_eventbridge_1.EventBridgeClient({ region });
|
|
11
|
+
const commandJSON = createCommandJSON(payloads, sourceId);
|
|
12
|
+
const command = new client_eventbridge_1.PutPartnerEventsCommand(commandJSON);
|
|
13
|
+
let response;
|
|
14
|
+
try {
|
|
15
|
+
response = await client.send(command);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throwError(error, `client.send`);
|
|
19
|
+
}
|
|
20
|
+
return buildMultiStatusResponse(response, payloads);
|
|
21
|
+
}
|
|
22
|
+
function getSourceId(payloads, hookOutputs) {
|
|
23
|
+
const payloadSourceId = payloads[0].sourceId;
|
|
24
|
+
const hookSourceId = hookOutputs?.onMappingSave?.sourceId ?? hookOutputs?.retlOnMappingSave?.sourceId;
|
|
25
|
+
if (!payloadSourceId) {
|
|
26
|
+
throw new actions_core_1.PayloadValidationError('Source ID is required. Source ID not found in payload. It should be present at $.context.protocols.sourceId or $.projectId in the payload.');
|
|
27
|
+
}
|
|
28
|
+
if (!hookSourceId) {
|
|
29
|
+
throw new actions_core_1.PayloadValidationError('Source ID is required. Source ID not found in hook outputs.');
|
|
30
|
+
}
|
|
31
|
+
if (hookSourceId !== payloadSourceId) {
|
|
32
|
+
throw new actions_core_1.PayloadValidationError('Mismatch between payload and hook source ID values.');
|
|
33
|
+
}
|
|
34
|
+
return payloadSourceId;
|
|
35
|
+
}
|
|
36
|
+
function buildMultiStatusResponse(response, payloads) {
|
|
37
|
+
const entries = response.Entries ?? [];
|
|
38
|
+
const multiStatusResponse = new actions_core_1.MultiStatusResponse();
|
|
39
|
+
console.log('Entries' + entries);
|
|
40
|
+
payloads.forEach((event, index) => {
|
|
41
|
+
const entry = entries[index] ?? {};
|
|
42
|
+
if (entry.ErrorCode || entry.ErrorMessage) {
|
|
43
|
+
multiStatusResponse.setErrorResponseAtIndex(index, {
|
|
44
|
+
status: 400,
|
|
45
|
+
errormessage: entry.ErrorMessage ?? 'Unknown Error',
|
|
46
|
+
sent: JSON.stringify(event),
|
|
47
|
+
body: JSON.stringify(entry)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
multiStatusResponse.setSuccessResponseAtIndex(index, {
|
|
52
|
+
status: 200,
|
|
53
|
+
body: 'Event sent successfully',
|
|
54
|
+
sent: JSON.stringify(event)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return multiStatusResponse;
|
|
59
|
+
}
|
|
60
|
+
function createCommandJSON(payloads, sourceId) {
|
|
61
|
+
return {
|
|
62
|
+
Entries: payloads.map((event) => ({
|
|
63
|
+
Source: `${constants_1.SEGMENT_PARTNER_NAME}/${sourceId}`,
|
|
64
|
+
DetailType: event.detailType,
|
|
65
|
+
Detail: JSON.stringify(event.data),
|
|
66
|
+
Resources: Array.isArray(event.resources)
|
|
67
|
+
? event.resources
|
|
68
|
+
: typeof event.resources === 'string'
|
|
69
|
+
? [event.resources]
|
|
70
|
+
: [],
|
|
71
|
+
Time: event.time ? new Date(event.time) : new Date()
|
|
72
|
+
}))
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function isRetryableError(error) {
|
|
76
|
+
if (typeof error === 'object' && error !== null && 'name' in error) {
|
|
77
|
+
const err = error;
|
|
78
|
+
return !(err.name in constants_1.EBRetryableErrors);
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
function isNotRetryableError(error) {
|
|
83
|
+
if (typeof error === 'object' && error !== null && 'name' in error) {
|
|
84
|
+
const err = error;
|
|
85
|
+
return !(err.name in constants_1.EBNotRetryableErrors);
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
function throwError(error, context) {
|
|
90
|
+
if (isRetryableError(error)) {
|
|
91
|
+
const err = error;
|
|
92
|
+
const message = err.message ?? 'No error message returned';
|
|
93
|
+
throw new actions_core_1.RetryableError(`Retryable error ${err.name} in ${context}. Message: ${message}`);
|
|
94
|
+
}
|
|
95
|
+
else if (isNotRetryableError(error)) {
|
|
96
|
+
const err = error;
|
|
97
|
+
const message = err.message ?? 'No error message returned';
|
|
98
|
+
throw new actions_core_1.IntegrationError(`Non-retryable error ${err.name} in ${context}. Message: ${message}`, err.name, 400);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new actions_core_1.IntegrationError(`Unknown error in ${context}: ${JSON.stringify(error)}`, 'UnknownError', 400);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-eventbridge/send/functions.ts"],"names":[],"mappings":";;AAYA,oBAwBC;AAlCD,wDAAqH;AACrH,2CAA2F;AAC3F,oEAKoC;AAG7B,KAAK,UAAU,IAAI,CACxB,QAAmB,EACnB,QAAkB,EAClB,WAAyB;IAEzB,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;IAEnD,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAA;IAE3B,MAAM,MAAM,GAAG,IAAI,sCAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAEhD,MAAM,WAAW,GAAG,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzD,MAAM,OAAO,GAAG,IAAI,4CAAuB,CAAC,WAAW,CAAC,CAAA;IAExD,IAAI,QAAuC,CAAA;IAE3C,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACrD,CAAC;AAED,SAAS,WAAW,CAAC,QAAmB,EAAE,WAAyB;IACjE,MAAM,eAAe,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;IAC5C,MAAM,YAAY,GAAG,WAAW,EAAE,aAAa,EAAE,QAAQ,IAAI,WAAW,EAAE,iBAAiB,EAAE,QAAQ,CAAA;IAErG,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,qCAAsB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AO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAc,EAAE,OAAe;IACjD,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,KAA2C,CAAA;QACvD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,2BAA2B,CAAA;QAC1D,MAAM,IAAI,6BAAc,CAAC,mBAAmB,GAAG,CAAC,IAAI,OAAO,OAAO,cAAc,OAAO,EAAE,CAAC,CAAA;IAC5F,CAAC;SAAM,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,KAA2C,CAAA;QACvD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,2BAA2B,CAAA;QAC1D,MAAM,IAAI,+BAAgB,CAAC,uBAAuB,GAAG,CAAC,IAAI,OAAO,OAAO,cAAc,OAAO,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACjH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,+BAAgB,CAAC,oBAAoB,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,CAAA;IAC1G,CAAC;AACH,CAAC"}
|
|
@@ -4,8 +4,18 @@ export interface Payload {
|
|
|
4
4
|
};
|
|
5
5
|
detailType: string;
|
|
6
6
|
sourceId: string;
|
|
7
|
-
resources?: string;
|
|
7
|
+
resources?: string[];
|
|
8
8
|
time?: string;
|
|
9
9
|
enable_batching: boolean;
|
|
10
10
|
batch_size?: number;
|
|
11
11
|
}
|
|
12
|
+
export interface RetlOnMappingSaveInputs {
|
|
13
|
+
}
|
|
14
|
+
export interface RetlOnMappingSaveOutputs {
|
|
15
|
+
sourceId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface OnMappingSaveInputs {
|
|
18
|
+
}
|
|
19
|
+
export interface OnMappingSaveOutputs {
|
|
20
|
+
sourceId: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionHookDefinition } from '@segment/actions-core/destination-kit';
|
|
2
|
+
import { HookError, HookSuccess } from './types';
|
|
3
|
+
import { EventBridgeClient } from '@aws-sdk/client-eventbridge';
|
|
4
|
+
import { Settings } from '../generated-types';
|
|
5
|
+
import type { OnMappingSaveInputs, OnMappingSaveOutputs, Payload } from './generated-types';
|
|
6
|
+
export declare const ensureSourceIdHook: ActionHookDefinition<Settings, Payload, any, OnMappingSaveInputs, OnMappingSaveOutputs>;
|
|
7
|
+
export declare function ensurePartnerSource(client: EventBridgeClient, awsAccountId: string, sourceId: string): Promise<HookSuccess | HookError>;
|
|
8
|
+
export declare function getFullSourceName(sourceId: string): string;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureSourceIdHook = void 0;
|
|
4
|
+
exports.ensurePartnerSource = ensurePartnerSource;
|
|
5
|
+
exports.getFullSourceName = getFullSourceName;
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const constants_2 = require("./constants");
|
|
8
|
+
const client_eventbridge_1 = require("@aws-sdk/client-eventbridge");
|
|
9
|
+
exports.ensureSourceIdHook = {
|
|
10
|
+
label: 'EnsureSourceId',
|
|
11
|
+
description: 'Connect to an existing data extension or create a new one in Salesforce Marketing Cloud.',
|
|
12
|
+
inputFields: {},
|
|
13
|
+
performHook: async (_, { settings, subscriptionMetadata }) => {
|
|
14
|
+
const validation = validate(settings, subscriptionMetadata);
|
|
15
|
+
if ('error' in validation) {
|
|
16
|
+
return validation;
|
|
17
|
+
}
|
|
18
|
+
const { sourceId, region, accountId } = validation;
|
|
19
|
+
const client = new client_eventbridge_1.EventBridgeClient({ region });
|
|
20
|
+
return await ensurePartnerSource(client, accountId, sourceId);
|
|
21
|
+
},
|
|
22
|
+
outputTypes: {
|
|
23
|
+
sourceId: {
|
|
24
|
+
label: 'Source ID',
|
|
25
|
+
description: 'The identifier for the source.',
|
|
26
|
+
type: 'string',
|
|
27
|
+
required: true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function validate(settings, subscriptionMetadata) {
|
|
32
|
+
const sourceId = subscriptionMetadata?.sourceId;
|
|
33
|
+
const { region, accountId } = settings;
|
|
34
|
+
if (typeof sourceId !== 'string' || !sourceId) {
|
|
35
|
+
return { error: { message: 'Source ID required', code: 'ERROR' } };
|
|
36
|
+
}
|
|
37
|
+
if (typeof region !== 'string' || !region) {
|
|
38
|
+
return {
|
|
39
|
+
error: {
|
|
40
|
+
message: "Hook call to ensure Source ID failed. Region required. Ensure 'AWS Region' Settings field is populated.",
|
|
41
|
+
code: 'ERROR'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (typeof accountId !== 'string' || !accountId) {
|
|
46
|
+
return {
|
|
47
|
+
error: {
|
|
48
|
+
message: "Hook call to ensure Source ID failed. Account ID required. Ensure 'AWS Account ID' Settings field is populated.",
|
|
49
|
+
code: 'ERROR'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return { sourceId, region, accountId };
|
|
54
|
+
}
|
|
55
|
+
async function ensurePartnerSource(client, awsAccountId, sourceId) {
|
|
56
|
+
let hookResponse = await findSource(client, sourceId);
|
|
57
|
+
if (hookResponse === undefined) {
|
|
58
|
+
hookResponse = await createSource(client, awsAccountId, sourceId);
|
|
59
|
+
}
|
|
60
|
+
return hookResponse;
|
|
61
|
+
}
|
|
62
|
+
async function findSource(client, sourceId) {
|
|
63
|
+
try {
|
|
64
|
+
const command = new client_eventbridge_1.ListPartnerEventSourcesCommand({ NamePrefix: getFullSourceName(sourceId) });
|
|
65
|
+
const response = await client.send(command);
|
|
66
|
+
return (response.PartnerEventSources?.length ?? 0) > 0
|
|
67
|
+
? {
|
|
68
|
+
successMessage: 'SourceId found',
|
|
69
|
+
savedData: {
|
|
70
|
+
sourceId
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
: undefined;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return returnError(error, 'findSource');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function createSource(client, accountId, sourceId) {
|
|
80
|
+
const fullSourceName = getFullSourceName(sourceId);
|
|
81
|
+
const command = new client_eventbridge_1.CreatePartnerEventSourceCommand({ Account: accountId, Name: fullSourceName });
|
|
82
|
+
try {
|
|
83
|
+
await client.send(command);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (isAnError(error)) {
|
|
87
|
+
return returnError(error, `createSource(${fullSourceName})`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
successMessage: 'SourceId created',
|
|
92
|
+
savedData: {
|
|
93
|
+
sourceId
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function getFullSourceName(sourceId) {
|
|
98
|
+
return `${constants_1.SEGMENT_PARTNER_NAME}/${sourceId}`;
|
|
99
|
+
}
|
|
100
|
+
function isAnError(error) {
|
|
101
|
+
if (typeof error === 'object' && error !== null && 'name' in error) {
|
|
102
|
+
const err = error;
|
|
103
|
+
return !(err.name in constants_2.EBNotErrors);
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function returnError(error, context) {
|
|
108
|
+
return {
|
|
109
|
+
error: {
|
|
110
|
+
message: `Hook error: ${context}: ${JSON.stringify(error)}`,
|
|
111
|
+
code: 'ERROR'
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-eventbridge/send/hooks.ts"],"names":[],"mappings":";;;AA6EA,kDAYC;AAyCD,8CA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|
-
const
|
|
3
|
+
const functions_1 = require("./functions");
|
|
4
|
+
const hooks_1 = require("./hooks");
|
|
5
5
|
const action = {
|
|
6
6
|
title: 'Send',
|
|
7
|
-
description: 'Send
|
|
7
|
+
description: 'Send event data to Amazon EventBridge.',
|
|
8
8
|
fields: {
|
|
9
9
|
data: {
|
|
10
10
|
label: 'Detail',
|
|
@@ -15,8 +15,7 @@ const action = {
|
|
|
15
15
|
},
|
|
16
16
|
detailType: {
|
|
17
17
|
label: 'Detail Type',
|
|
18
|
-
description: `Detail Type of the event. Used to determine what fields to expect in the event Detail.
|
|
19
|
-
Value cannot be longer than 128 characters.`,
|
|
18
|
+
description: `Detail Type of the event. Used to determine what fields to expect in the event Detail. Value cannot be longer than 128 characters.`,
|
|
20
19
|
type: 'string',
|
|
21
20
|
maximum: 128,
|
|
22
21
|
default: { '@path': '$.type' },
|
|
@@ -38,23 +37,16 @@ const action = {
|
|
|
38
37
|
},
|
|
39
38
|
resources: {
|
|
40
39
|
label: 'Resources',
|
|
41
|
-
description: `AWS resources, identified by Amazon Resource Name (ARN),
|
|
42
|
-
which the event primarily concerns. Any number,
|
|
43
|
-
including zero, may be present.`,
|
|
40
|
+
description: `AWS resources, identified by Amazon Resource Name (ARN), which the event primarily concerns. Any number, including zero, may be present.`,
|
|
44
41
|
type: 'string',
|
|
45
|
-
|
|
46
|
-
'@if': {
|
|
47
|
-
exists: { '@path': '$.userId' },
|
|
48
|
-
then: { '@path': '$.userId' },
|
|
49
|
-
else: { '@path': '$.anonymousId' }
|
|
50
|
-
}
|
|
51
|
-
},
|
|
42
|
+
multiple: true,
|
|
52
43
|
required: false
|
|
53
44
|
},
|
|
54
45
|
time: {
|
|
55
46
|
label: 'Time',
|
|
56
|
-
description: 'The timestamp the event occurred.',
|
|
47
|
+
description: 'The timestamp the event occurred. Accepts a date in ISO 8601 format.',
|
|
57
48
|
type: 'string',
|
|
49
|
+
format: 'date-time',
|
|
58
50
|
default: { '@path': '$.timestamp' },
|
|
59
51
|
required: false
|
|
60
52
|
},
|
|
@@ -78,16 +70,19 @@ const action = {
|
|
|
78
70
|
maximum: 20
|
|
79
71
|
}
|
|
80
72
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (features?.['amazon-eventbridge-v2']) {
|
|
88
|
-
return (0, functionsv2_1.send)(payload, settings);
|
|
73
|
+
hooks: {
|
|
74
|
+
retlOnMappingSave: {
|
|
75
|
+
...hooks_1.ensureSourceIdHook
|
|
76
|
+
},
|
|
77
|
+
onMappingSave: {
|
|
78
|
+
...hooks_1.ensureSourceIdHook
|
|
89
79
|
}
|
|
90
|
-
|
|
80
|
+
},
|
|
81
|
+
perform: (_, { payload, settings, hookOutputs }) => {
|
|
82
|
+
return (0, functions_1.send)([payload], settings, hookOutputs);
|
|
83
|
+
},
|
|
84
|
+
performBatch: (_, { payload, settings, hookOutputs }) => {
|
|
85
|
+
return (0, functions_1.send)(payload, settings, hookOutputs);
|
|
91
86
|
}
|
|
92
87
|
};
|
|
93
88
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-eventbridge/send/index.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-eventbridge/send/index.ts"],"names":[],"mappings":";;AAGA,2CAAkC;AAClC,mCAA4C;AAE5C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,wCAAwC;IACrD,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,+CAA+C;YAC5D,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YAC1B,QAAQ,EAAE,IAAI;SACf;QACD,UAAU,EAAE;YACV,KAAK,EAAE,aAAa;Y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,KAAK,EAAE;QACL,iBAAiB,EAAE;YACjB,GAAG,0BAAkB;SACtB;QACD,aAAa,EAAE;YACb,GAAG,0BAAkB;SACtB;KACF;IACD,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE;QACjD,OAAO,IAAA,gBAAI,EAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;IAC/C,CAAC;IACD,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE;QACtD,OAAO,IAAA,gBAAI,EAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;IAC7C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OnMappingSaveOutputs, RetlOnMappingSaveOutputs } from './generated-types';
|
|
2
|
+
export interface PutPartnerEventsCommandJSON {
|
|
3
|
+
Entries: Array<EntryItem>;
|
|
4
|
+
}
|
|
5
|
+
export interface EntryItem {
|
|
6
|
+
Time: Date;
|
|
7
|
+
Source: string;
|
|
8
|
+
Resources: string[];
|
|
9
|
+
DetailType: string;
|
|
10
|
+
Detail: string;
|
|
11
|
+
}
|
|
12
|
+
export interface HookError {
|
|
13
|
+
error: {
|
|
14
|
+
message: string;
|
|
15
|
+
code: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface HookSuccess {
|
|
19
|
+
successMessage: string;
|
|
20
|
+
savedData: {
|
|
21
|
+
sourceId: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface HookOutputs {
|
|
25
|
+
onMappingSave?: OnMappingSaveOutputs;
|
|
26
|
+
retlOnMappingSave?: RetlOnMappingSaveOutputs;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-eventbridge/send/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_VERSION = exports.MAX_BATCH_SIZE = exports.MAX_ATTRIBUTES_SIZE = void 0;
|
|
4
|
+
exports.MAX_ATTRIBUTES_SIZE = 50;
|
|
5
|
+
exports.MAX_BATCH_SIZE = 200;
|
|
6
|
+
exports.API_VERSION = 2.6;
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/batch/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,EAAE,CAAA;AACxB,QAAA,cAAc,GAAG,GAAG,CAAA;AACpB,QAAA,WAAW,GAAG,GAAG,CAAA"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const actions_core_1 = require("@segment/actions-core");
|
|
7
7
|
const updateProfile_1 = __importDefault(require("./updateProfile"));
|
|
8
|
+
const constants_1 = require("./constants");
|
|
8
9
|
const destination = {
|
|
9
10
|
name: 'Batch (Actions)',
|
|
10
11
|
slug: 'actions-batch',
|
|
@@ -26,7 +27,7 @@ const destination = {
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
testAuthentication: async (request) => {
|
|
29
|
-
return await request(
|
|
30
|
+
return await request(`https://api.batch.com/${constants_1.API_VERSION}/profiles/update`, {
|
|
30
31
|
method: 'POST',
|
|
31
32
|
body: JSON.stringify([
|
|
32
33
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/batch/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA4E;AAE5E,oEAA2C;
|
|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4BAAa,EAAC,uBAAa,CAAC,MAAM,CAAC;YAC5C,IAAI,EAAE,WAAW;SAClB;KACF;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constants_1 = require("
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const action = {
|
|
6
6
|
title: 'Update User Profile',
|
|
@@ -27,7 +27,7 @@ const action = {
|
|
|
27
27
|
},
|
|
28
28
|
enable_batching: {
|
|
29
29
|
label: 'Enable Batching',
|
|
30
|
-
description:
|
|
30
|
+
description: `If enabled, the action will send multiple profiles in a single request. The maximum number of profiles in a single request is ${constants_1.MAX_BATCH_SIZE}.`,
|
|
31
31
|
type: 'boolean',
|
|
32
32
|
default: true,
|
|
33
33
|
unsafe_hidden: true
|
|
@@ -42,7 +42,7 @@ const action = {
|
|
|
42
42
|
},
|
|
43
43
|
profileAttributes: {
|
|
44
44
|
label: 'Profile attributes',
|
|
45
|
-
description:
|
|
45
|
+
description: `Attributes for the user profile. Batch can accept up to ${constants_1.MAX_ATTRIBUTES_SIZE} attributes per user.`,
|
|
46
46
|
type: 'object',
|
|
47
47
|
additionalProperties: true,
|
|
48
48
|
properties: {
|
|
@@ -160,10 +160,11 @@ const action = {
|
|
|
160
160
|
};
|
|
161
161
|
async function send(request, payload) {
|
|
162
162
|
const json = payload.map(utils_1.mapPayload);
|
|
163
|
-
|
|
163
|
+
const response = await request(`https://api.batch.com/${constants_1.API_VERSION}/profiles/update`, {
|
|
164
164
|
method: 'post',
|
|
165
165
|
json
|
|
166
166
|
});
|
|
167
|
+
return (0, utils_1.handleMultiStatusResponse)(response.data, payload, json);
|
|
167
168
|
}
|
|
168
169
|
exports.default = action;
|
|
169
170
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/batch/updateProfile/index.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/batch/updateProfile/index.ts"],"names":[],"mappings":";;AAGA,4CAA+E;AAC/E,mCAA+D;AAG/D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE,kEAAkE;IAC/E,mBAAmB,EAAE,qCAAqC;IAC1D,MAAM,EAAE;QACN,WAAW,EAAE;YACX,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,kBAAkB;YAC/B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE,IAAI;YAC1B,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,KAAK,EAAE,SAAS;oBAChB,WAAW,EAAE,+BAA+B;oBAC5C,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,OAAO,EAAE;gBACP,SAAS,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;aACnC;SACF;QACD,eAAe,EAAE;YACf,KAAK,EAAE,iBAAiB;YACxB,WAAW,EACX,iIAAiI,0BAAc,GAAG;YAClJ,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;YACb,aAAa,EAAE,IAAI;SACpB;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,wDAAwD;YACrE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,0BAAc;YACvB,QAAQ,EAAE,IAAI;YACd,aAAa,EAAE,IAAI;SACpB;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,2DAA2D,+BAAmB,uBAAuB;YAClH,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,IAAI;YAC1B,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,KAAK,EAAE,UAAU;oBACjB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B,WAAW,EAAE,+CAA+C;YAC5D,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;YACD,oBAAoB,EAAE,IAAI;SAC3B;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IACjC,CAAC;IACD,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/B,CAAC;CACF,CAAA;AAED,KAAK,UAAU,IAAI,CAAC,OAAsB,EAAE,OAAkB;IAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAU,CAAC,CAAA;IACpC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAA0B,yBAAyB,uBAAW,kBAAkB,EAAE;QAC9G,MAAM,EAAE,MAAM;QACd,IAAI;KACL,CAAC,CAAA;IAEF,OAAO,IAAA,iCAAyB,EAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;AAChE,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -29,3 +29,14 @@ export type EventObject = {
|
|
|
29
29
|
export interface EventAttributes {
|
|
30
30
|
[key: string]: string | number | boolean | null | undefined | string[] | EventObject | EventObject[];
|
|
31
31
|
}
|
|
32
|
+
export interface MultiStatusResponseJSON {
|
|
33
|
+
code: "SUCCESS" | "SUCCESS_WITH_PARTIAL_ERRORS";
|
|
34
|
+
errors: [
|
|
35
|
+
{
|
|
36
|
+
category: string;
|
|
37
|
+
bulk_index: number;
|
|
38
|
+
reason: string;
|
|
39
|
+
attribute?: string;
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Payload } from './generated-types';
|
|
2
|
-
import { Identifiers, ProfileAttributes, BatchJSON, EventAttributes } from './type';
|
|
2
|
+
import { Identifiers, ProfileAttributes, BatchJSON, EventAttributes, MultiStatusResponseJSON } from './type';
|
|
3
|
+
import { MultiStatusResponse } from '@segment/actions-core';
|
|
3
4
|
export declare function mapPayload(payload: Payload): BatchJSON;
|
|
4
5
|
export declare function formatAttributes(attributes: Record<string, unknown>, allowObjects: true): EventAttributes;
|
|
5
6
|
export declare function formatAttributes(attributes: Record<string, unknown>, allowObjects?: false): ProfileAttributes;
|
|
6
7
|
export declare function formatIdentifiers(identifiers: Payload['identifiers']): Identifiers;
|
|
8
|
+
export declare function handleMultiStatusResponse(response: MultiStatusResponseJSON, payloads: Payload[], json: BatchJSON[]): MultiStatusResponse;
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mapPayload = mapPayload;
|
|
4
4
|
exports.formatAttributes = formatAttributes;
|
|
5
5
|
exports.formatIdentifiers = formatIdentifiers;
|
|
6
|
-
|
|
6
|
+
exports.handleMultiStatusResponse = handleMultiStatusResponse;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
7
9
|
function mapPayload(payload) {
|
|
8
10
|
const { profileAttributes: { language, email_address, phone_number, email_marketing, sms_marketing, region, timezone, ...customAttributes } = {}, identifiers, eventName, eventAttributes } = payload;
|
|
9
11
|
const nativeProfileAttributes = {
|
|
@@ -71,6 +73,40 @@ function formatIdentifiers(identifiers) {
|
|
|
71
73
|
};
|
|
72
74
|
return cleanedIdentifiers;
|
|
73
75
|
}
|
|
76
|
+
function handleMultiStatusResponse(response, payloads, json) {
|
|
77
|
+
const msResponse = new actions_core_1.MultiStatusResponse();
|
|
78
|
+
if (response.code === 'SUCCESS_WITH_PARTIAL_ERRORS') {
|
|
79
|
+
payloads.forEach((payload, index) => {
|
|
80
|
+
const matchingError = response.errors.find((error) => error.bulk_index === index);
|
|
81
|
+
if (matchingError) {
|
|
82
|
+
msResponse.setErrorResponseAtIndex(index, {
|
|
83
|
+
status: 400,
|
|
84
|
+
errormessage: matchingError.reason,
|
|
85
|
+
sent: payload,
|
|
86
|
+
body: JSON.stringify(json[index])
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
msResponse.setSuccessResponseAtIndex(index, {
|
|
91
|
+
status: 202,
|
|
92
|
+
sent: payload,
|
|
93
|
+
body: JSON.stringify(json[index])
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return msResponse;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
payloads.forEach((payload, index) => {
|
|
101
|
+
msResponse.setSuccessResponseAtIndex(index, {
|
|
102
|
+
status: 202,
|
|
103
|
+
sent: payload,
|
|
104
|
+
body: JSON.stringify(json[index])
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
return msResponse;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
74
110
|
function formatEventName(eventName) {
|
|
75
111
|
if (!eventName)
|
|
76
112
|
return undefined;
|