@segment/action-destinations 3.177.1-webhookaudiencestemp.11 → 3.178.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/acoustic/Utility/eventprocessing.js +10 -1
- package/dist/destinations/acoustic/Utility/eventprocessing.js.map +1 -1
- package/dist/destinations/acoustic/Utility/tablemaintutilities.js +17 -34
- package/dist/destinations/acoustic/Utility/tablemaintutilities.js.map +1 -1
- package/dist/destinations/acoustic/generated-types.d.ts +1 -0
- package/dist/destinations/acoustic/index.js +18 -8
- package/dist/destinations/acoustic/index.js.map +1 -1
- package/dist/destinations/acoustic/receiveEvents/index.js +3 -3
- package/dist/destinations/acoustic/receiveEvents/index.js.map +1 -1
- package/dist/destinations/devrev/createRevUser/generated-types.d.ts +8 -0
- package/dist/destinations/devrev/createRevUser/generated-types.js.map +1 -0
- package/dist/destinations/devrev/createRevUser/index.d.ts +5 -0
- package/dist/destinations/devrev/createRevUser/index.js +171 -0
- package/dist/destinations/devrev/createRevUser/index.js.map +1 -0
- package/dist/destinations/devrev/createWork/generated-types.d.ts +9 -0
- package/dist/destinations/devrev/createWork/generated-types.js +3 -0
- package/dist/destinations/devrev/createWork/generated-types.js.map +1 -0
- package/dist/destinations/devrev/createWork/index.d.ts +5 -0
- package/dist/destinations/devrev/createWork/index.js +146 -0
- package/dist/destinations/devrev/createWork/index.js.map +1 -0
- package/dist/destinations/devrev/generated-types.d.ts +4 -0
- package/dist/destinations/devrev/generated-types.js +3 -0
- package/dist/destinations/devrev/generated-types.js.map +1 -0
- package/dist/destinations/devrev/index.js +47 -0
- package/dist/destinations/devrev/index.js.map +1 -0
- package/dist/destinations/devrev/mocks/index.d.ts +144 -0
- package/dist/destinations/devrev/mocks/index.js +145 -0
- package/dist/destinations/devrev/mocks/index.js.map +1 -0
- package/dist/destinations/devrev/utils/constants.d.ts +15 -0
- package/dist/destinations/devrev/utils/constants.js +19 -0
- package/dist/destinations/devrev/utils/constants.js.map +1 -0
- package/dist/destinations/devrev/utils/helpers.d.ts +14 -0
- package/dist/destinations/devrev/utils/helpers.js +56 -0
- package/dist/destinations/devrev/utils/helpers.js.map +1 -0
- package/dist/destinations/devrev/utils/index.d.ts +3 -0
- package/dist/destinations/devrev/utils/index.js +16 -0
- package/dist/destinations/devrev/utils/index.js.map +1 -0
- package/dist/destinations/devrev/utils/types.d.ts +105 -0
- package/dist/destinations/{webhook-audiences/send.types.js → devrev/utils/types.js} +1 -1
- package/dist/destinations/devrev/utils/types.js.map +1 -0
- package/dist/destinations/hubspot/api/index.d.ts +16 -0
- package/dist/destinations/hubspot/api/index.js +55 -0
- package/dist/destinations/hubspot/api/index.js.map +1 -0
- package/dist/destinations/hubspot/errors.d.ts +2 -0
- package/dist/destinations/hubspot/errors.js +3 -1
- package/dist/destinations/hubspot/errors.js.map +1 -1
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +2 -2
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -1
- package/dist/destinations/hubspot/upsertCompany/index.js +13 -68
- package/dist/destinations/hubspot/upsertCompany/index.js.map +1 -1
- package/dist/destinations/hubspot/upsertContact/index.js +2 -2
- package/dist/destinations/hubspot/upsertContact/index.js.map +1 -1
- package/dist/destinations/hubspot/upsertCustomObjectRecord/generated-types.d.ts +4 -0
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js +47 -8
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js.map +1 -1
- package/dist/destinations/hubspot/utils.d.ts +47 -0
- package/dist/destinations/hubspot/utils.js +43 -0
- package/dist/destinations/hubspot/utils.js.map +1 -0
- package/dist/destinations/index.js +1 -1
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/voucherify/upsertCustomer/generated-types.d.ts +13 -13
- package/dist/destinations/voucherify/upsertCustomer/index.js +18 -5
- package/dist/destinations/voucherify/upsertCustomer/index.js.map +1 -1
- package/dist/destinations/webhook/__test__/webhook.test.d.ts +1 -2
- package/dist/destinations/webhook/__test__/webhook.test.js +120 -125
- package/dist/destinations/webhook/__test__/webhook.test.js.map +1 -1
- package/package.json +2 -2
- package/dist/destinations/hubspot/helperFunctions.d.ts +0 -7
- package/dist/destinations/hubspot/helperFunctions.js +0 -27
- package/dist/destinations/hubspot/helperFunctions.js.map +0 -1
- package/dist/destinations/webhook-audiences/__test__/index.test.d.ts +0 -1
- package/dist/destinations/webhook-audiences/__test__/index.test.js +0 -44
- package/dist/destinations/webhook-audiences/__test__/index.test.js.map +0 -1
- package/dist/destinations/webhook-audiences/generated-types.d.ts +0 -5
- package/dist/destinations/webhook-audiences/generated-types.js.map +0 -1
- package/dist/destinations/webhook-audiences/index.js +0 -99
- package/dist/destinations/webhook-audiences/index.js.map +0 -1
- package/dist/destinations/webhook-audiences/send.types.d.ts +0 -11
- package/dist/destinations/webhook-audiences/send.types.js.map +0 -1
- /package/dist/destinations/{webhook-audiences → devrev/createRevUser}/generated-types.js +0 -0
- /package/dist/destinations/{webhook-audiences → devrev}/index.d.ts +0 -0
|
@@ -15,6 +15,7 @@ const action = {
|
|
|
15
15
|
},
|
|
16
16
|
name: {
|
|
17
17
|
label: 'Name',
|
|
18
|
+
allowNull: true,
|
|
18
19
|
description: 'First name and last name of the [customer](https://docs.voucherify.io/reference/customer-object).',
|
|
19
20
|
type: 'string',
|
|
20
21
|
default: {
|
|
@@ -23,6 +24,7 @@ const action = {
|
|
|
23
24
|
},
|
|
24
25
|
first_name: {
|
|
25
26
|
label: 'First Name',
|
|
27
|
+
allowNull: true,
|
|
26
28
|
description: 'First name of the [customer](https://docs.voucherify.io/reference/customer-object). It will be merged with `last_name` to create the `name` field.',
|
|
27
29
|
type: 'string',
|
|
28
30
|
default: {
|
|
@@ -31,6 +33,7 @@ const action = {
|
|
|
31
33
|
},
|
|
32
34
|
last_name: {
|
|
33
35
|
label: 'Last Name',
|
|
36
|
+
allowNull: true,
|
|
34
37
|
description: 'Last name of the [customer](https://docs.voucherify.io/reference/customer-object). It will be merged with `first_name` to create the `name` field.',
|
|
35
38
|
type: 'string',
|
|
36
39
|
default: {
|
|
@@ -39,6 +42,7 @@ const action = {
|
|
|
39
42
|
},
|
|
40
43
|
description: {
|
|
41
44
|
label: 'Description',
|
|
45
|
+
allowNull: true,
|
|
42
46
|
description: 'An arbitrary string that you can attach to a [customer](https://docs.voucherify.io/reference/customer-object) object.',
|
|
43
47
|
type: 'string',
|
|
44
48
|
default: {
|
|
@@ -47,6 +51,7 @@ const action = {
|
|
|
47
51
|
},
|
|
48
52
|
email: {
|
|
49
53
|
label: 'Email Address',
|
|
54
|
+
allowNull: true,
|
|
50
55
|
description: 'The email that identifies the [customer](https://docs.voucherify.io/reference/the-customer-object) in Voucherify.',
|
|
51
56
|
type: 'string',
|
|
52
57
|
default: {
|
|
@@ -55,6 +60,7 @@ const action = {
|
|
|
55
60
|
},
|
|
56
61
|
phone: {
|
|
57
62
|
label: 'Phone',
|
|
63
|
+
allowNull: true,
|
|
58
64
|
description: 'Phone number of the [customer](https://docs.voucherify.io/reference/the-customer-object).',
|
|
59
65
|
type: 'string',
|
|
60
66
|
default: {
|
|
@@ -63,6 +69,7 @@ const action = {
|
|
|
63
69
|
},
|
|
64
70
|
birthdate: {
|
|
65
71
|
label: 'Birthdate',
|
|
72
|
+
allowNull: true,
|
|
66
73
|
description: 'Birthdate of the [customer](https://docs.voucherify.io/reference/the-customer-object). You can pass data here in `date` or `datetime` format (ISO 8601).',
|
|
67
74
|
type: 'string',
|
|
68
75
|
default: {
|
|
@@ -76,23 +83,28 @@ const action = {
|
|
|
76
83
|
properties: {
|
|
77
84
|
city: {
|
|
78
85
|
label: 'City',
|
|
79
|
-
type: 'string'
|
|
86
|
+
type: 'string',
|
|
87
|
+
allowNull: true
|
|
80
88
|
},
|
|
81
89
|
state: {
|
|
82
90
|
label: 'State',
|
|
83
|
-
type: 'string'
|
|
91
|
+
type: 'string',
|
|
92
|
+
allowNull: true
|
|
84
93
|
},
|
|
85
94
|
postal_code: {
|
|
86
95
|
label: 'Postal Code',
|
|
87
|
-
type: 'string'
|
|
96
|
+
type: 'string',
|
|
97
|
+
allowNull: true
|
|
88
98
|
},
|
|
89
99
|
street: {
|
|
90
100
|
label: 'Street',
|
|
91
|
-
type: 'string'
|
|
101
|
+
type: 'string',
|
|
102
|
+
allowNull: true
|
|
92
103
|
},
|
|
93
104
|
country: {
|
|
94
105
|
label: 'Country',
|
|
95
|
-
type: 'string'
|
|
106
|
+
type: 'string',
|
|
107
|
+
allowNull: true
|
|
96
108
|
}
|
|
97
109
|
},
|
|
98
110
|
default: {
|
|
@@ -107,6 +119,7 @@ const action = {
|
|
|
107
119
|
label: 'Metadata',
|
|
108
120
|
description: 'A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format.',
|
|
109
121
|
type: 'object',
|
|
122
|
+
allowNull: true,
|
|
110
123
|
default: {
|
|
111
124
|
'@path': '$.traits.metadata'
|
|
112
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/voucherify/upsertCustomer/index.ts"],"names":[],"mappings":";;AAEA,kDAA0D;AAG1D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,kBAAkB;IACzB,WAAW,EACT,6KAA6K;IAC/K,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EACT,0HAA0H;YAC5H,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;SACjC;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,mGAAmG;YAChH,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,eAAe;aACzB;SACF;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EACT,oJAAoJ;YACtJ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,qBAAqB;aAC/B;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EACT,oJAAoJ;YACtJ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,oBAAoB;aAC9B;SACF;QACD,WAAW,EAAE;YACX,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,uHAAuH;YACzH,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,sBAAsB;aAChC;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE,eAAe;YACtB,WAAW,EACT,mHAAmH;YACrH,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,gBAAgB;aAC1B;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,2FAA2F;YACxG,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,gBAAgB;aAC1B;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EACT,0JAA0J;YAC5J,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,oBAAoB;aAC9B;SACF;QACD,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,sFAAsF;YACnG,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/voucherify/upsertCustomer/index.ts"],"names":[],"mappings":";;AAEA,kDAA0D;AAG1D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,kBAAkB;IACzB,WAAW,EACT,6KAA6K;IAC/K,mBAAmB,EAAE,mBAAmB;IACxC,M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,YAAY;YACnB,WAAW,EACT,sHAAsH;YACxH,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,QAAQ;aAClB;SACF;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,MAAM,oBAAoB,GAAG,uCAAwB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QAC3E,OAAO,OAAO,CAAC,oBAAoB,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const baseWebhookTests: (def: DestinationDefinition<any>) => void;
|
|
1
|
+
export {};
|
|
@@ -3,140 +3,135 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.baseWebhookTests = void 0;
|
|
7
6
|
const nock_1 = __importDefault(require("nock"));
|
|
8
7
|
const actions_core_1 = require("@segment/actions-core");
|
|
9
8
|
const index_1 = __importDefault(require("../index"));
|
|
10
9
|
const crypto_1 = require("crypto");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
describe(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
useDefaultMappings: true
|
|
27
|
-
});
|
|
28
|
-
expect(responses.length).toBe(1);
|
|
29
|
-
expect(responses[0].status).toBe(200);
|
|
10
|
+
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
11
|
+
describe('Webhook', () => {
|
|
12
|
+
describe('send', () => {
|
|
13
|
+
it('should work with default mapping', async () => {
|
|
14
|
+
const url = 'https://example.com';
|
|
15
|
+
const event = actions_core_1.createTestEvent();
|
|
16
|
+
nock_1.default(url)
|
|
17
|
+
.post('/', event)
|
|
18
|
+
.reply(200);
|
|
19
|
+
const responses = await testDestination.testAction('send', {
|
|
20
|
+
event,
|
|
21
|
+
mapping: {
|
|
22
|
+
url
|
|
23
|
+
},
|
|
24
|
+
useDefaultMappings: true
|
|
30
25
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
26
|
+
expect(responses.length).toBe(1);
|
|
27
|
+
expect(responses[0].status).toBe(200);
|
|
28
|
+
});
|
|
29
|
+
it('supports customizations', async () => {
|
|
30
|
+
const url = 'https://example.build';
|
|
31
|
+
const event = actions_core_1.createTestEvent();
|
|
32
|
+
const headerField = 'Custom-Header';
|
|
33
|
+
const headerValue = 'Custom-Value';
|
|
34
|
+
const data = { cool: true };
|
|
35
|
+
nock_1.default(url).put('/', data).matchHeader(headerField, headerValue).reply(200);
|
|
36
|
+
const responses = await testDestination.testAction('send', {
|
|
37
|
+
event,
|
|
38
|
+
mapping: {
|
|
39
|
+
url,
|
|
40
|
+
method: 'PUT',
|
|
41
|
+
headers: { [headerField]: headerValue },
|
|
42
|
+
data
|
|
43
|
+
}
|
|
49
44
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
nock_1.default(url)
|
|
58
|
-
.post('/', payload)
|
|
59
|
-
.reply(async function (_uri, body) {
|
|
60
|
-
const bodyString = JSON.stringify(body);
|
|
61
|
-
const expectSignature = this.req.headers['x-signature'][0];
|
|
62
|
-
const actualSignature = crypto_1.createHmac('sha1', sharedSecret).update(bodyString).digest('hex');
|
|
63
|
-
if (expectSignature.length !== actualSignature.length ||
|
|
64
|
-
!crypto_1.timingSafeEqual(Buffer.from(actualSignature, 'hex'), Buffer.from(expectSignature, 'hex'))) {
|
|
65
|
-
return [400, 'Invalid signature'];
|
|
66
|
-
}
|
|
67
|
-
return [200, 'OK'];
|
|
68
|
-
});
|
|
69
|
-
const responses = await testDestination.testAction('send', {
|
|
70
|
-
event,
|
|
71
|
-
mapping: {
|
|
72
|
-
url,
|
|
73
|
-
data: { '@path': '$.properties' }
|
|
74
|
-
},
|
|
75
|
-
settings: { sharedSecret },
|
|
76
|
-
useDefaultMappings: true
|
|
77
|
-
});
|
|
78
|
-
expect(responses.length).toBe(1);
|
|
79
|
-
expect(responses[0].status).toBe(200);
|
|
45
|
+
expect(responses.length).toBe(1);
|
|
46
|
+
expect(responses[0].status).toBe(200);
|
|
47
|
+
});
|
|
48
|
+
it('supports request signing', async () => {
|
|
49
|
+
const url = 'https://example.com';
|
|
50
|
+
const event = actions_core_1.createTestEvent({
|
|
51
|
+
properties: { cool: true }
|
|
80
52
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
nock_1.default(url)
|
|
95
|
-
.post('/', payload)
|
|
96
|
-
.reply(async function (_uri, body) {
|
|
97
|
-
const expectSignature = this.req.headers['x-signature'][0];
|
|
98
|
-
const actualSignature = crypto_1.createHmac('sha1', sharedSecret).update(JSON.stringify(body[0])).digest('hex');
|
|
99
|
-
if (expectSignature.length !== actualSignature.length ||
|
|
100
|
-
!crypto_1.timingSafeEqual(Buffer.from(actualSignature, 'hex'), Buffer.from(expectSignature, 'hex'))) {
|
|
101
|
-
return [400, 'Invalid signature123'];
|
|
102
|
-
}
|
|
103
|
-
return [200, 'OK'];
|
|
104
|
-
});
|
|
105
|
-
const responses = await testDestination.testBatchAction('send', {
|
|
106
|
-
events,
|
|
107
|
-
mapping: {
|
|
108
|
-
url,
|
|
109
|
-
data: { '@path': '$.properties' }
|
|
110
|
-
},
|
|
111
|
-
settings: { sharedSecret },
|
|
112
|
-
useDefaultMappings: true
|
|
113
|
-
});
|
|
114
|
-
expect(responses.length).toBe(1);
|
|
115
|
-
expect(responses[0].status).toBe(200);
|
|
53
|
+
const payload = JSON.stringify(event.properties);
|
|
54
|
+
const sharedSecret = 'abc123';
|
|
55
|
+
nock_1.default(url)
|
|
56
|
+
.post('/', payload)
|
|
57
|
+
.reply(async function (_uri, body) {
|
|
58
|
+
const bodyString = JSON.stringify(body);
|
|
59
|
+
const expectSignature = this.req.headers['x-signature'][0];
|
|
60
|
+
const actualSignature = crypto_1.createHmac('sha1', sharedSecret).update(bodyString).digest('hex');
|
|
61
|
+
if (expectSignature.length !== actualSignature.length ||
|
|
62
|
+
!crypto_1.timingSafeEqual(Buffer.from(actualSignature, 'hex'), Buffer.from(expectSignature, 'hex'))) {
|
|
63
|
+
return [400, 'Invalid signature'];
|
|
64
|
+
}
|
|
65
|
+
return [200, 'OK'];
|
|
116
66
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.matchHeader(headerField, headerValue)
|
|
126
|
-
.replyWithError('TypeError: هيثم is not a legal HTTP header value');
|
|
127
|
-
await expect(testDestination.testAction('send', {
|
|
128
|
-
event,
|
|
129
|
-
mapping: {
|
|
130
|
-
url,
|
|
131
|
-
method: 'PUT',
|
|
132
|
-
headers: { [headerField]: headerValue },
|
|
133
|
-
data
|
|
134
|
-
}
|
|
135
|
-
})).rejects.toThrow(actions_core_1.PayloadValidationError);
|
|
67
|
+
const responses = await testDestination.testAction('send', {
|
|
68
|
+
event,
|
|
69
|
+
mapping: {
|
|
70
|
+
url,
|
|
71
|
+
data: { '@path': '$.properties' }
|
|
72
|
+
},
|
|
73
|
+
settings: { sharedSecret },
|
|
74
|
+
useDefaultMappings: true
|
|
136
75
|
});
|
|
76
|
+
expect(responses.length).toBe(1);
|
|
77
|
+
expect(responses[0].status).toBe(200);
|
|
78
|
+
});
|
|
79
|
+
it('supports request signing with batched events', async () => {
|
|
80
|
+
const url = 'https://example.com';
|
|
81
|
+
const events = [
|
|
82
|
+
actions_core_1.createTestEvent({
|
|
83
|
+
properties: { cool: false }
|
|
84
|
+
}),
|
|
85
|
+
actions_core_1.createTestEvent({
|
|
86
|
+
properties: { cool: true }
|
|
87
|
+
})
|
|
88
|
+
];
|
|
89
|
+
const payload = JSON.stringify(events.map(({ properties }) => properties));
|
|
90
|
+
console.log(payload);
|
|
91
|
+
const sharedSecret = 'abc123';
|
|
92
|
+
nock_1.default(url)
|
|
93
|
+
.post('/', payload)
|
|
94
|
+
.reply(async function (_uri, body) {
|
|
95
|
+
const expectSignature = this.req.headers['x-signature'][0];
|
|
96
|
+
const actualSignature = crypto_1.createHmac('sha1', sharedSecret).update(JSON.stringify(body[0])).digest('hex');
|
|
97
|
+
if (expectSignature.length !== actualSignature.length ||
|
|
98
|
+
!crypto_1.timingSafeEqual(Buffer.from(actualSignature, 'hex'), Buffer.from(expectSignature, 'hex'))) {
|
|
99
|
+
return [400, 'Invalid signature123'];
|
|
100
|
+
}
|
|
101
|
+
return [200, 'OK'];
|
|
102
|
+
});
|
|
103
|
+
const responses = await testDestination.testBatchAction('send', {
|
|
104
|
+
events,
|
|
105
|
+
mapping: {
|
|
106
|
+
url,
|
|
107
|
+
data: { '@path': '$.properties' }
|
|
108
|
+
},
|
|
109
|
+
settings: { sharedSecret },
|
|
110
|
+
useDefaultMappings: true
|
|
111
|
+
});
|
|
112
|
+
expect(responses.length).toBe(1);
|
|
113
|
+
expect(responses[0].status).toBe(200);
|
|
114
|
+
});
|
|
115
|
+
it('should throw an error when header value is invalid', async () => {
|
|
116
|
+
const url = 'https://example.build';
|
|
117
|
+
const event = actions_core_1.createTestEvent();
|
|
118
|
+
const headerField = 'Custom-Header';
|
|
119
|
+
const headerValue = 'هيثم';
|
|
120
|
+
const data = { cool: true };
|
|
121
|
+
nock_1.default(url)
|
|
122
|
+
.put('/', data)
|
|
123
|
+
.matchHeader(headerField, headerValue)
|
|
124
|
+
.replyWithError('TypeError: هيثم is not a legal HTTP header value');
|
|
125
|
+
await expect(testDestination.testAction('send', {
|
|
126
|
+
event,
|
|
127
|
+
mapping: {
|
|
128
|
+
url,
|
|
129
|
+
method: 'PUT',
|
|
130
|
+
headers: { [headerField]: headerValue },
|
|
131
|
+
data
|
|
132
|
+
}
|
|
133
|
+
})).rejects.toThrow(actions_core_1.PayloadValidationError);
|
|
137
134
|
});
|
|
138
135
|
});
|
|
139
|
-
};
|
|
140
|
-
exports.baseWebhookTests = baseWebhookTests;
|
|
141
|
-
exports.baseWebhookTests(index_1.default);
|
|
136
|
+
});
|
|
142
137
|
//# sourceMappingURL=webhook.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAAsG;AACtG,qDAA8B;AAC9B,mCAAoD;AAGpD,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAO,CAAC,CAAA;AAEtD,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,GAAG,GAAG,qBAAqB,CAAA;YACjC,MAAM,KAAK,GAAG,8BAAe,E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,kDAAkD,CAAC,CAAA;YAErE,MAAM,MAAM,CACV,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBACjC,KAAK;gBACL,OAAO,EAAE;oBACP,GAAG;oBACH,MAAM,EAAE,KAAK;oBACb,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE;oBACvC,IAAI;iBACL;aACF,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CAAC,qCAAsB,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,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.178.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"__tests__/__helpers__/"
|
|
77
77
|
]
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "2abde6b72f8a5b52175389968ce1b8e15e79af3b"
|
|
80
80
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenObject = void 0;
|
|
4
|
-
function flattenObject(obj) {
|
|
5
|
-
if (typeof obj === 'undefined' || obj === null)
|
|
6
|
-
return obj;
|
|
7
|
-
const flattened = {};
|
|
8
|
-
Object.keys(obj).forEach((key) => {
|
|
9
|
-
if (typeof obj[key] === 'undefined' || obj[key] == null || !Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (obj[key] instanceof Array) {
|
|
13
|
-
flattened[key] = obj[key]
|
|
14
|
-
.map((item) => (typeof item === 'object' ? JSON.stringify(item) : item))
|
|
15
|
-
.join(';');
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (typeof obj[key] === 'object') {
|
|
19
|
-
flattened[key] = JSON.stringify(obj[key]);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
flattened[key] = obj[key];
|
|
23
|
-
});
|
|
24
|
-
return flattened;
|
|
25
|
-
}
|
|
26
|
-
exports.flattenObject = flattenObject;
|
|
27
|
-
//# sourceMappingURL=helperFunctions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helperFunctions.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/helperFunctions.ts"],"names":[],"mappings":";;;AAKA,SAAgB,aAAa,CAAC,GAAe;IAC3C,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAA;IAE1D,MAAM,SAAS,GAAe,EAAE,CAAA;IAEhC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QAGvC,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,WAAW,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;YAC1G,OAAM;SACP;QAGD,IAAI,GAAG,CAAC,GAAG,CAAC,YAAY,KAAK,EAAE;YAC7B,SAAS,CAAC,GAAG,CAAC,GAAI,GAAG,CAAC,GAAG,CAAoB;iBAC1C,GAAG,CAAC,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;iBAChF,IAAI,CAAC,GAAG,CAAC,CAAA;YACZ,OAAM;SACP;QAGD,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YAChC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;YACzC,OAAM;SACP;QAED,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEF,OAAO,SAAS,CAAA;AAClB,CAAC;AA9BD,sCA8BC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
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 index_1 = __importDefault(require("../index"));
|
|
7
|
-
const webhook_test_1 = require("../../webhook/__test__/webhook.test");
|
|
8
|
-
const nock_1 = __importDefault(require("nock"));
|
|
9
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
10
|
-
webhook_test_1.baseWebhookTests(index_1.default);
|
|
11
|
-
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
12
|
-
describe('Webhook Audience Tests', () => {
|
|
13
|
-
it('creates an audience', async () => {
|
|
14
|
-
const fakeUrl = 'http://segmentfake.xyz';
|
|
15
|
-
const exampleRequest = {
|
|
16
|
-
audienceName: 'My Cool Audience'
|
|
17
|
-
};
|
|
18
|
-
const exampleResponse = {
|
|
19
|
-
externalId: 'abc123xyz'
|
|
20
|
-
};
|
|
21
|
-
nock_1.default(fakeUrl).post('/', exampleRequest).reply(200, exampleResponse);
|
|
22
|
-
const expectedResponse = await testDestination.createAudience({
|
|
23
|
-
audienceName: 'My Cool Audience',
|
|
24
|
-
settings: { createAudienceUrl: fakeUrl }
|
|
25
|
-
});
|
|
26
|
-
expect(expectedResponse).toStrictEqual(exampleResponse);
|
|
27
|
-
});
|
|
28
|
-
it('gets an audience', async () => {
|
|
29
|
-
const fakeUrl = 'http://segmentfake.xyz';
|
|
30
|
-
const exampleRequest = {
|
|
31
|
-
externalId: 'abc123xyz'
|
|
32
|
-
};
|
|
33
|
-
const exampleResponse = {
|
|
34
|
-
externalId: 'abc123xyz'
|
|
35
|
-
};
|
|
36
|
-
nock_1.default(fakeUrl).post('/', exampleRequest).reply(200, exampleResponse);
|
|
37
|
-
const expectedResponse = await testDestination.getAudience({
|
|
38
|
-
externalId: 'abc123xyz',
|
|
39
|
-
settings: { getAudienceUrl: fakeUrl }
|
|
40
|
-
});
|
|
41
|
-
expect(expectedResponse).toStrictEqual(exampleResponse);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=index.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook-audiences/__test__/index.test.ts"],"names":[],"mappings":";;;;;AAAA,qDAAsC;AACtC,sEAAsE;AACtE,gDAAuB;AACvB,wDAA6D;AAE7D,+BAAgB,CAAC,eAAe,CAAC,CAAA;AAEjC,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAe,CAAC,CAAA;AAC9D,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,OAAO,GAAG,wBAAwB,CAAA;QACxC,MAAM,cAAc,GAAG;YACrB,YAAY,EAAE,kBAAkB;SACjC,CAAA;QACD,MAAM,eAAe,GAAG;YACtB,UAAU,EAAE,WAAW;SACxB,CAAA;QACD,cAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;QAEnE,MAAM,gBAAgB,GAAG,MAAM,eAAe,CAAC,cAAc,CAAC;YAC5D,YAAY,EAAE,kBAAkB;YAChC,QAAQ,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE;SACzC,CAAC,CAAA;QAEF,MAAM,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAChC,MAAM,OAAO,GAAG,wBAAwB,CAAA;QACxC,MAAM,cAAc,GAAG;YACrB,UAAU,EAAE,WAAW;SACxB,CAAA;QACD,MAAM,eAAe,GAAG;YACtB,UAAU,EAAE,WAAW;SACxB,CAAA;QACD,cAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;QAEnE,MAAM,gBAAgB,GAAG,MAAM,eAAe,CAAC,WAAW,CAAC;YACzD,UAAU,EAAE,WAAW;YACvB,QAAQ,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE;SACtC,CAAC,CAAA;QAEF,MAAM,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/webhook-audiences/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,99 +0,0 @@
|
|
|
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 send_1 = __importDefault(require("../webhook/send"));
|
|
7
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
-
const crypto_1 = require("crypto");
|
|
9
|
-
const externalIdKey = 'externalId';
|
|
10
|
-
const audienceNameKey = 'audienceName';
|
|
11
|
-
const destination = {
|
|
12
|
-
name: 'Webhook Audiences',
|
|
13
|
-
slug: 'actions-webhook-audiences',
|
|
14
|
-
mode: 'cloud',
|
|
15
|
-
authentication: {
|
|
16
|
-
scheme: 'custom',
|
|
17
|
-
fields: {
|
|
18
|
-
sharedSecret: {
|
|
19
|
-
type: 'string',
|
|
20
|
-
label: 'Shared Secret',
|
|
21
|
-
description: 'If set, Segment will sign requests with an HMAC in the "X-Signature" request header. The HMAC is a hex-encoded SHA1 hash generated using this shared secret and the request body.'
|
|
22
|
-
},
|
|
23
|
-
createAudienceUrl: {
|
|
24
|
-
type: 'string',
|
|
25
|
-
label: 'URL to send requests to create an audience',
|
|
26
|
-
description: `If set, Segment will send a POST request with the ${audienceNameKey} in the JSON to the provided URL to create the audience. The expected JSON response must have "${externalIdKey}".`
|
|
27
|
-
},
|
|
28
|
-
getAudienceUrl: {
|
|
29
|
-
type: 'string',
|
|
30
|
-
label: 'URL to send requests to get an audience',
|
|
31
|
-
description: `If set, Segment will send a POST request with the ${externalIdKey} in the JSON to the provided URL to get the audience. The expected JSON response must have "${externalIdKey}".`
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
audienceSettings: {
|
|
36
|
-
mode: {
|
|
37
|
-
type: 'synced',
|
|
38
|
-
full_audience_sync: false
|
|
39
|
-
},
|
|
40
|
-
async getAudience(request, getAudienceInput) {
|
|
41
|
-
const getAudienceUrl = getAudienceInput.settings.getAudienceUrl;
|
|
42
|
-
if (!getAudienceUrl) {
|
|
43
|
-
throw new actions_core_1.IntegrationError('Missing get audience url value', 'MISSING_REQUIRED_FIELD', 400);
|
|
44
|
-
}
|
|
45
|
-
const response = await request(getAudienceUrl, {
|
|
46
|
-
method: 'POST',
|
|
47
|
-
json: {
|
|
48
|
-
[externalIdKey]: getAudienceInput.externalId
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const jsonOutput = await response.json();
|
|
52
|
-
if (!jsonOutput[externalIdKey]) {
|
|
53
|
-
throw new actions_core_1.IntegrationError('Invalid response from get audience request', 'INVALID_RESPONSE', 400);
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
externalId: jsonOutput[externalIdKey]
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
async createAudience(request, createAudienceInput) {
|
|
60
|
-
const audienceName = createAudienceInput.audienceName;
|
|
61
|
-
if (audienceName?.length == 0) {
|
|
62
|
-
throw new actions_core_1.IntegrationError('Missing audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
63
|
-
}
|
|
64
|
-
const createAudienceUrl = createAudienceInput.settings.createAudienceUrl;
|
|
65
|
-
if (!createAudienceUrl) {
|
|
66
|
-
throw new actions_core_1.IntegrationError('Missing create audience url value', 'MISSING_REQUIRED_FIELD', 400);
|
|
67
|
-
}
|
|
68
|
-
const response = await request(createAudienceUrl, {
|
|
69
|
-
method: 'POST',
|
|
70
|
-
json: {
|
|
71
|
-
audienceName
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
const jsonOutput = await response.json();
|
|
75
|
-
if (!jsonOutput[externalIdKey]) {
|
|
76
|
-
throw new actions_core_1.IntegrationError('Invalid response from create audience request', 'INVALID_RESPONSE', 400);
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
externalId: jsonOutput[externalIdKey]
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
extendRequest: ({ settings, payload }) => {
|
|
84
|
-
if (!payload) {
|
|
85
|
-
return {};
|
|
86
|
-
}
|
|
87
|
-
const payloadData = payload.length ? payload[0]['data'] : payload['data'];
|
|
88
|
-
if (settings.sharedSecret && payloadData) {
|
|
89
|
-
const digest = crypto_1.createHmac('sha1', settings.sharedSecret).update(JSON.stringify(payloadData), 'utf8').digest('hex');
|
|
90
|
-
return { headers: { 'X-Signature': digest } };
|
|
91
|
-
}
|
|
92
|
-
return {};
|
|
93
|
-
},
|
|
94
|
-
actions: {
|
|
95
|
-
send: send_1.default
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
exports.default = destination;
|
|
99
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/webhook-audiences/index.ts"],"names":[],"mappings":";;;;;AAGA,2DAAkC;AAClC,wDAAwD;AACxD,mCAAmC;AAEnC,MAAM,aAAa,GAAG,YAAY,CAAA;AAClC,MAAM,eAAe,GAAG,cAAc,CAAA;AAEtC,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE,OAAO;IACb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,eAAe;gBACtB,WAAW,EACT,mLAAmL;aACtL;YACD,iBAAiB,EAAE;gBACjB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,4CAA4C;gBACnD,WAAW,EAAE,qDAAqD,eAAe,kGAAkG,aAAa,IAAI;aACrM;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,yCAAyC;gBAChD,WAAW,EAAE,qDAAqD,aAAa,+FAA+F,aAAa,IAAI;aAChM;SACF;KACF;IACD,gBAAgB,EAAE;QAChB,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,kBAAkB,EAAE,KAAK;SAC1B;QACD,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,gBAAgB;YACzC,MAAM,cAAc,GAAG,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAA;YAC/D,IAAI,CAAC,cAAc,EAAE;gBACnB,MAAM,IAAI,+BAAgB,CAAC,gCAAgC,EAAE,wBAAwB,EAAE,GAAG,CAAC,CAAA;aAC5F;YAED,MAAM,QAAQ,GA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