@segment/action-destinations 3.345.11-staging.0 → 3.345.12-staging.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/amazon-amc/function.d.ts +14 -0
- package/dist/destinations/amazon-amc/function.js +155 -0
- package/dist/destinations/amazon-amc/function.js.map +1 -0
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.d.ts +1 -1
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js +4 -88
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js.map +1 -1
- package/dist/destinations/amazon-amc/utils.d.ts +1 -0
- package/dist/destinations/amazon-amc/utils.js +2 -1
- package/dist/destinations/amazon-amc/utils.js.map +1 -1
- package/dist/destinations/braze/updateUserProfile/index.js +5 -1
- package/dist/destinations/braze/updateUserProfile/index.js.map +1 -1
- package/dist/destinations/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/klaviyo/removeProfile/index.js +1 -1
- package/dist/destinations/klaviyo/removeProfile/index.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js +1 -1
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js +1 -1
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.d.ts +2 -1
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js +36 -34
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/types.d.ts +1 -0
- package/dist/destinations/segment/properties.js +5 -4
- package/dist/destinations/segment/properties.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/constants.d.ts +2 -0
- package/dist/destinations/sendgrid-audiences/constants.js +3 -1
- package/dist/destinations/sendgrid-audiences/constants.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/index.d.ts +3 -1
- package/dist/destinations/sendgrid-audiences/index.js +45 -12
- package/dist/destinations/sendgrid-audiences/index.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/dynamic-fields.d.ts +2 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/dynamic-fields.js +16 -14
- package/dist/destinations/sendgrid-audiences/syncAudience/dynamic-fields.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/fields.js +76 -46
- package/dist/destinations/sendgrid-audiences/syncAudience/fields.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/generated-types.d.ts +14 -5
- package/dist/destinations/sendgrid-audiences/syncAudience/index.js +14 -4
- package/dist/destinations/sendgrid-audiences/syncAudience/index.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/utils.d.ts +4 -2
- package/dist/destinations/sendgrid-audiences/syncAudience/utils.js +206 -88
- package/dist/destinations/sendgrid-audiences/syncAudience/utils.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/types.d.ts +24 -0
- package/dist/destinations/twilio-messaging/sendMessage/constants.js +3 -1
- package/dist/destinations/twilio-messaging/sendMessage/constants.js.map +1 -1
- package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js +3 -4
- package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js.map +1 -1
- package/dist/destinations/twilio-messaging/sendMessage/fields.js +1 -1
- package/dist/destinations/twilio-messaging/sendMessage/fields.js.map +1 -1
- package/dist/destinations/twilio-messaging/sendMessage/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sfmc-operations.js","sourceRoot":"","sources":["../../../src/destinations/salesforce-marketing-cloud/sfmc-operations.ts"],"names":[],"mappings":";;;AAAA,wDAM8B;
|
|
1
|
+
{"version":3,"file":"sfmc-operations.js","sourceRoot":"","sources":["../../../src/destinations/salesforce-marketing-cloud/sfmc-operations.ts"],"names":[],"mappings":";;;AAAA,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CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;KACH;IACD,OAAO,mBAAmB,CAAA;AAC5B,CAAC;AAhDD,oEAgDC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_SEGMENT_ENDPOINT = exports.SEGMENT_ENDPOINTS = void 0;
|
|
4
|
+
const isProd = process.env.NODE_ENV === 'production';
|
|
4
5
|
exports.SEGMENT_ENDPOINTS = {
|
|
5
6
|
'us-west-2': {
|
|
6
7
|
label: 'North America',
|
|
7
|
-
url:
|
|
8
|
-
cdn:
|
|
8
|
+
url: `https://api.segment.${isProd ? 'io' : 'build'}/v1`,
|
|
9
|
+
cdn: `https://cdn.segment.${isProd ? 'com' : 'build'}/v1`
|
|
9
10
|
},
|
|
10
11
|
'eu-west-1': {
|
|
11
12
|
label: 'Europe',
|
|
12
|
-
url:
|
|
13
|
-
cdn:
|
|
13
|
+
url: `https://events.eu1.segmentapis.${isProd ? 'com' : 'build'}/v1`,
|
|
14
|
+
cdn: `https://cdn.segment.${isProd ? 'com' : 'build'}/v1`
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
exports.DEFAULT_SEGMENT_ENDPOINT = 'us-west-2';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/segment/properties.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/segment/properties.ts"],"names":[],"mappings":";;;AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AAQvC,QAAA,iBAAiB,GAAuC;IACnE,WAAW,EAAE;QACX,KAAK,EAAE,eAAe;QACtB,GAAG,EAAE,uBAAuB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK;QACxD,GAAG,EAAE,uBAAuB,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK;KAC1D;IACD,WAAW,EAAE;QACX,KAAK,EAAE,QAAQ;QACf,GAAG,EAAE,kCAAkC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK;QACpE,GAAG,EAAE,uBAAuB,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK;KAC1D;CACF,CAAA;AAEY,QAAA,wBAAwB,GAAG,WAAW,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const MAX_BATCH_SIZE = 100;
|
|
2
|
+
export declare const GET_LIST_URL = "https://api.sendgrid.com/v3/marketing/lists";
|
|
2
3
|
export declare const CREATE_LIST_URL = "https://api.sendgrid.com/v3/marketing/lists";
|
|
3
4
|
export declare const UPSERT_CONTACTS_URL = "https://api.sendgrid.com/v3/marketing/contacts";
|
|
4
5
|
export declare const REMOVE_CONTACTS_FROM_LIST_URL = "https://api.sendgrid.com/v3/marketing/lists/{list_id}/contacts?contact_ids={contact_ids}";
|
|
@@ -7,3 +8,4 @@ export declare const GET_CONTACT_BY_EMAIL_URL = "https://api.sendgrid.com/v3/mar
|
|
|
7
8
|
export declare const SEARCH_CONTACTS_URL = "https://api.sendgrid.com/v3/marketing/contacts/search";
|
|
8
9
|
export declare const MAX_CHUNK_SIZE_SEARCH = 50;
|
|
9
10
|
export declare const GET_CUSTOM_FIELDS_URL = "https://api.sendgrid.com/v3/marketing/field_definitions";
|
|
11
|
+
export declare const E164_REGEX: RegExp;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GET_CUSTOM_FIELDS_URL = exports.MAX_CHUNK_SIZE_SEARCH = exports.SEARCH_CONTACTS_URL = exports.GET_CONTACT_BY_EMAIL_URL = exports.MAX_CHUNK_SIZE_REMOVE = exports.REMOVE_CONTACTS_FROM_LIST_URL = exports.UPSERT_CONTACTS_URL = exports.CREATE_LIST_URL = exports.MAX_BATCH_SIZE = void 0;
|
|
3
|
+
exports.E164_REGEX = exports.GET_CUSTOM_FIELDS_URL = exports.MAX_CHUNK_SIZE_SEARCH = exports.SEARCH_CONTACTS_URL = exports.GET_CONTACT_BY_EMAIL_URL = exports.MAX_CHUNK_SIZE_REMOVE = exports.REMOVE_CONTACTS_FROM_LIST_URL = exports.UPSERT_CONTACTS_URL = exports.CREATE_LIST_URL = exports.GET_LIST_URL = exports.MAX_BATCH_SIZE = void 0;
|
|
4
4
|
exports.MAX_BATCH_SIZE = 100;
|
|
5
|
+
exports.GET_LIST_URL = 'https://api.sendgrid.com/v3/marketing/lists';
|
|
5
6
|
exports.CREATE_LIST_URL = 'https://api.sendgrid.com/v3/marketing/lists';
|
|
6
7
|
exports.UPSERT_CONTACTS_URL = 'https://api.sendgrid.com/v3/marketing/contacts';
|
|
7
8
|
exports.REMOVE_CONTACTS_FROM_LIST_URL = 'https://api.sendgrid.com/v3/marketing/lists/{list_id}/contacts?contact_ids={contact_ids}';
|
|
@@ -10,4 +11,5 @@ exports.GET_CONTACT_BY_EMAIL_URL = 'https://api.sendgrid.com/v3/marketing/contac
|
|
|
10
11
|
exports.SEARCH_CONTACTS_URL = 'https://api.sendgrid.com/v3/marketing/contacts/search';
|
|
11
12
|
exports.MAX_CHUNK_SIZE_SEARCH = 50;
|
|
12
13
|
exports.GET_CUSTOM_FIELDS_URL = 'https://api.sendgrid.com/v3/marketing/field_definitions';
|
|
14
|
+
exports.E164_REGEX = /^\+[1-9]\d{1,14}$/;
|
|
13
15
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/sendgrid-audiences/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,GAAG,CAAA;AAEpB,QAAA,eAAe,GAAG,6CAA6C,CAAA;AAE/D,QAAA,mBAAmB,GAAG,gDAAgD,CAAA;AAEtE,QAAA,6BAA6B,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/sendgrid-audiences/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,GAAG,CAAA;AAEpB,QAAA,YAAY,GAAG,6CAA6C,CAAA;AAE5D,QAAA,eAAe,GAAG,6CAA6C,CAAA;AAE/D,QAAA,mBAAmB,GAAG,gDAAgD,CAAA;AAEtE,QAAA,6BAA6B,GACxC,0FAA0F,CAAA;AAE/E,QAAA,qBAAqB,GAAG,GAAG,CAAA;AAE3B,QAAA,wBAAwB,GAAG,8DAA8D,CAAA;AAEzF,QAAA,mBAAmB,GAAG,uDAAuD,CAAA;AAE7E,QAAA,qBAAqB,GAAG,EAAE,CAAA;AAE1B,QAAA,qBAAqB,GAAG,yDAAyD,CAAA;AAEjF,QAAA,UAAU,GAAG,mBAAmB,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AudienceDestinationDefinition, RequestClient } from '@segment/actions-core';
|
|
2
2
|
import type { Settings, AudienceSettings } from './generated-types';
|
|
3
3
|
declare const destination: AudienceDestinationDefinition<Settings, AudienceSettings>;
|
|
4
|
+
export declare function getAudienceIdByName(request: RequestClient, name: string): Promise<string | undefined>;
|
|
5
|
+
export declare function getAudienceIdById(request: RequestClient, externalId: string): Promise<string | undefined>;
|
|
4
6
|
export default destination;
|
|
@@ -3,6 +3,8 @@ 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.getAudienceIdById = exports.getAudienceIdByName = void 0;
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
6
8
|
const syncAudience_1 = __importDefault(require("./syncAudience"));
|
|
7
9
|
const constants_1 = require("./constants");
|
|
8
10
|
const destination = {
|
|
@@ -46,25 +48,56 @@ const destination = {
|
|
|
46
48
|
full_audience_sync: false
|
|
47
49
|
},
|
|
48
50
|
async createAudience(request, createAudienceInput) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const name = createAudienceInput?.audienceSettings?.listName ?? createAudienceInput.audienceName;
|
|
52
|
+
const id = await getAudienceIdByName(request, name);
|
|
53
|
+
if (id) {
|
|
54
|
+
return { externalId: id };
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const response = await request(constants_1.CREATE_LIST_URL, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
throwHttpErrors: false,
|
|
60
|
+
json: {
|
|
61
|
+
name
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const json = await response.json();
|
|
65
|
+
return { externalId: json.id };
|
|
66
|
+
}
|
|
58
67
|
},
|
|
59
68
|
async getAudience(_, getAudienceInput) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
const id = await getAudienceIdById(_, getAudienceInput.externalId);
|
|
70
|
+
if (id) {
|
|
71
|
+
return {
|
|
72
|
+
externalId: getAudienceInput.externalId
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw new actions_core_1.IntegrationError(`Audience with externalId ${getAudienceInput.externalId} not found`, 'GET_AUDIENCE_ERROR', 404);
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
79
|
},
|
|
65
80
|
actions: {
|
|
66
81
|
syncAudience: syncAudience_1.default
|
|
67
82
|
}
|
|
68
83
|
};
|
|
84
|
+
async function getAudienceIdByName(request, name) {
|
|
85
|
+
const response = await request(constants_1.GET_LIST_URL, {
|
|
86
|
+
method: 'GET',
|
|
87
|
+
throwHttpErrors: false
|
|
88
|
+
});
|
|
89
|
+
const json = await response.json();
|
|
90
|
+
return json.result.find((list) => list.name === name)?.id ?? undefined;
|
|
91
|
+
}
|
|
92
|
+
exports.getAudienceIdByName = getAudienceIdByName;
|
|
93
|
+
async function getAudienceIdById(request, externalId) {
|
|
94
|
+
const response = await request(`${constants_1.GET_LIST_URL}/${externalId}`, {
|
|
95
|
+
method: 'GET',
|
|
96
|
+
throwHttpErrors: false
|
|
97
|
+
});
|
|
98
|
+
const json = await response.json();
|
|
99
|
+
return json.id === externalId ? externalId : undefined;
|
|
100
|
+
}
|
|
101
|
+
exports.getAudienceIdById = getAudienceIdById;
|
|
69
102
|
exports.default = destination;
|
|
70
103
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/sendgrid-audiences/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/sendgrid-audiences/index.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAsG;AAEtG,kEAAyC;AACzC,2CAA2D;AAG3D,MAAM,WAAW,GAA8D;IAC7E,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,iDAAiD;IAC9D,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,cAAc,EAAE;gBACd,KAAK,EAAE,SAAS;gBAChB,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,wCAAwC;gBACrD,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAI9B,OAAO,OAAO,CAAC,0CAA0C,CAAC,CAAA;QAC5D,CAAC;KACF;IACD,aAAa,CAAC,EAAE,QAAQ,EAAE;QACxB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,QAAQ,CAAC,cAAc,EAAE;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AAG,CACJ,CAAA;aACF;QACH,CAAC;KACF;IACD,OAAO,EAAE;QACP,YAAY,EAAZ,sBAAY;KACb;CACF,CAAA;AAEM,KAAK,UAAU,mBAAmB,CAAC,OAAsB,EAAE,IAAY;IAC5E,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,wBAAY,EAAE;QAC3C,MAAM,EAAE,KAAK;QACb,eAAe,EAAE,KAAK;KACvB,CAAC,CAAA;IACF,MAAM,IAAI,GAAiB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAChD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,EAAE,IAAI,SAAS,CAAA;AACxE,CAAC;AAPD,kDAOC;AAEM,KAAK,UAAU,iBAAiB,CAAC,OAAsB,EAAE,UAAkB;IAChF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,wBAAY,IAAI,UAAU,EAAE,EAAE;QAC9D,MAAM,EAAE,KAAK;QACb,eAAe,EAAE,KAAK;KACvB,CAAC,CAAA;IACF,MAAM,IAAI,GAAoB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACnD,OAAO,IAAI,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAA;AACxD,CAAC;AAPD,8CAOC;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RequestClient } from '@segment/actions-core';
|
|
2
2
|
import { DynamicFieldResponse } from '@segment/actions-core';
|
|
3
3
|
import { Payload } from './generated-types';
|
|
4
|
-
|
|
4
|
+
import type { FieldType } from '../types';
|
|
5
|
+
export declare function dynamicCustomFields(request: RequestClient, payload: Payload, fieldType: FieldType): Promise<DynamicFieldResponse>;
|
|
@@ -2,31 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dynamicCustomFields = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
|
-
|
|
5
|
+
function createErrorResponse(message, code) {
|
|
6
|
+
return {
|
|
7
|
+
choices: [],
|
|
8
|
+
error: { message: message ?? 'Unknown error', code: code ?? '404' }
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
async function dynamicCustomFields(request, payload, fieldType) {
|
|
6
12
|
try {
|
|
7
13
|
const response = await request(constants_1.GET_CUSTOM_FIELDS_URL, {
|
|
8
14
|
method: 'GET',
|
|
9
15
|
skipResponseCloning: true
|
|
10
16
|
});
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
17
|
+
const selected = new Set(Object.keys({ ...payload.custom_text_fields, ...payload.custom_number_fields, ...payload.custom_date_fields }));
|
|
18
|
+
const remainingFields = response.data.custom_fields.filter(field => field.field_type === fieldType).filter(field => !selected.has(field.name));
|
|
19
|
+
if (remainingFields.length === 0) {
|
|
20
|
+
return createErrorResponse(`No custom ${fieldType} fields available`);
|
|
21
|
+
}
|
|
14
22
|
return {
|
|
15
|
-
choices:
|
|
16
|
-
label:
|
|
17
|
-
value:
|
|
23
|
+
choices: remainingFields.map(field => ({
|
|
24
|
+
label: field.name,
|
|
25
|
+
value: field.name
|
|
18
26
|
}))
|
|
19
27
|
};
|
|
20
28
|
}
|
|
21
29
|
catch (err) {
|
|
22
30
|
const error = err;
|
|
23
|
-
return
|
|
24
|
-
choices: [],
|
|
25
|
-
error: {
|
|
26
|
-
message: error.response.data.errors.map((e) => e.message).join(';') ?? 'Unknown error: dynamicCustomFields',
|
|
27
|
-
code: String(error.response.status)
|
|
28
|
-
}
|
|
29
|
-
};
|
|
31
|
+
return createErrorResponse(error.response.data.errors.map((e) => e.message).join(';') ?? 'Unknown error: dynamicCustomFields', String(error.response.status));
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
exports.dynamicCustomFields = dynamicCustomFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-fields.js","sourceRoot":"","sources":["../../../../src/destinations/sendgrid-audiences/syncAudience/dynamic-fields.ts"],"names":[],"mappings":";;;AAGA,4CAAoD;
|
|
1
|
+
{"version":3,"file":"dynamic-fields.js","sourceRoot":"","sources":["../../../../src/destinations/sendgrid-audiences/syncAudience/dynamic-fields.ts"],"names":[],"mappings":";;;AAGA,4CAAoD;AAYpD,SAAS,mBAAmB,CAAC,OAAgB,EAAE,IAAa;IAC1D,OAAO;QACL,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,IAAI,EAAE,IAAI,IAAI,KAAK,EAAE;KACpE,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,mBAAmB,CAAC,OAAsB,EAAE,OAAgB,EAAE,SAAmB;IAoBnG,IAAI;QACF,MAAM,QAAQ,GAAiB,MAAM,OAAO,CAAC,iCAAqB,EAAE;YAClE,MAAM,EAAE,KAAK;YACb,mBAAmB,EAAE,IAAI;SAC1B,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,GAAG,OAAO,CAAC,kBAAkB,EAAE,GAAG,OAAO,CAAC,oBAAoB,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAA;QACvI,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAE9I,IAAG,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,OAAO,mBAAmB,CAAC,aAAa,SAAS,mBAAmB,CAAC,CAAA;SACtE;QAED,OAAO;YACL,OAAO,EAAE,eAAe,CAAC,GAAG,CAC1B,KAAK,CAAC,EAAE,CAAC,CAAC;gBACR,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,KAAK,EAAE,KAAK,CAAC,IAAI;aAClB,CAAC,CACH;SACF,CAAA;KAEF;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,KAAK,GAAG,GAAkB,CAAA;QAChC,OAAO,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAK,oCAAoC,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;KAC/J;AACH,CAAC;AA9CH,kDA8CG"}
|
|
@@ -48,50 +48,47 @@ exports.fields = {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
|
|
52
|
-
label: '
|
|
53
|
-
description: `
|
|
54
|
-
type: '
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
identifiers: {
|
|
52
|
+
label: 'Contact Identifiers',
|
|
53
|
+
description: `Identifiers for the Contact. At least one identifier must be provided.`,
|
|
54
|
+
type: 'object',
|
|
55
|
+
required: true,
|
|
56
|
+
defaultObjectUI: 'keyvalue:only',
|
|
57
|
+
additionalProperties: false,
|
|
58
|
+
properties: {
|
|
59
|
+
email: {
|
|
60
|
+
label: 'Email Address',
|
|
61
|
+
description: `The contact's email address.`,
|
|
62
|
+
type: 'string',
|
|
63
|
+
format: 'email',
|
|
64
|
+
required: false
|
|
65
|
+
},
|
|
66
|
+
anonymous_id: {
|
|
67
|
+
label: 'Anonymous ID',
|
|
68
|
+
description: `The contact's anonymous ID.`,
|
|
69
|
+
type: 'string',
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
72
|
+
external_id: {
|
|
73
|
+
label: 'External ID',
|
|
74
|
+
description: `The contact's external ID.`,
|
|
75
|
+
type: 'string',
|
|
76
|
+
required: false
|
|
77
|
+
},
|
|
78
|
+
phone_number_id: {
|
|
79
|
+
label: 'Phone Number ID',
|
|
80
|
+
description: `A Contact identifier in the form of a phone number in E.164 format.`,
|
|
81
|
+
type: 'string',
|
|
82
|
+
required: false
|
|
82
83
|
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
phone_number_id: {
|
|
86
|
-
label: 'Phone Number ID',
|
|
87
|
-
description: `The contact's primary phone number. Should include the country code e.g. +19876543213.`,
|
|
88
|
-
type: 'string',
|
|
89
|
-
required: false,
|
|
84
|
+
},
|
|
90
85
|
default: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
email: {
|
|
87
|
+
'@if': {
|
|
88
|
+
exists: { '@path': '$.traits.email' },
|
|
89
|
+
then: { '@path': '$.traits.email' },
|
|
90
|
+
else: { '@path': '$.properties.email' }
|
|
91
|
+
}
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
94
|
},
|
|
@@ -113,6 +110,11 @@ exports.fields = {
|
|
|
113
110
|
description: `The contact's last name.`,
|
|
114
111
|
type: 'string'
|
|
115
112
|
},
|
|
113
|
+
phone_number: {
|
|
114
|
+
label: 'Phone Number',
|
|
115
|
+
description: `The contact's phone number in E.164 format. This phone number is not treated as a Contact identifer (as the Phone Number ID is).`,
|
|
116
|
+
type: 'string'
|
|
117
|
+
},
|
|
116
118
|
address_line_1: {
|
|
117
119
|
label: 'Address Line 1',
|
|
118
120
|
description: `The contact's address line 1.`,
|
|
@@ -159,6 +161,13 @@ exports.fields = {
|
|
|
159
161
|
else: { '@path': '$.properties.last_name' }
|
|
160
162
|
}
|
|
161
163
|
},
|
|
164
|
+
phone_number: {
|
|
165
|
+
'@if': {
|
|
166
|
+
exists: { '@path': '$.traits.phone' },
|
|
167
|
+
then: { '@path': '$.traits.phone' },
|
|
168
|
+
else: { '@path': '$.properties.phone' }
|
|
169
|
+
}
|
|
170
|
+
},
|
|
162
171
|
address_line_1: {
|
|
163
172
|
'@if': {
|
|
164
173
|
exists: { '@path': '$.traits.street' },
|
|
@@ -203,14 +212,35 @@ exports.fields = {
|
|
|
203
212
|
}
|
|
204
213
|
}
|
|
205
214
|
},
|
|
206
|
-
|
|
207
|
-
label: 'Custom Fields',
|
|
208
|
-
description: `Custom Field values to be added to the Contact.
|
|
215
|
+
custom_text_fields: {
|
|
216
|
+
label: 'Custom Text Fields',
|
|
217
|
+
description: `Custom Text Field values to be added to the Contact. Values must be in in string format. The custom field must already exit in Sendgrid.`,
|
|
218
|
+
type: 'object',
|
|
219
|
+
required: false,
|
|
220
|
+
defaultObjectUI: 'keyvalue',
|
|
221
|
+
additionalProperties: true,
|
|
222
|
+
dynamic: true,
|
|
223
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment']
|
|
224
|
+
},
|
|
225
|
+
custom_number_fields: {
|
|
226
|
+
label: 'Custom Number Fields',
|
|
227
|
+
description: `Custom Number Field values to be added to the Contact. Values must be inumeric. The custom field must already exit in Sendgrid.`,
|
|
228
|
+
type: 'object',
|
|
229
|
+
required: false,
|
|
230
|
+
defaultObjectUI: 'keyvalue',
|
|
231
|
+
additionalProperties: true,
|
|
232
|
+
dynamic: true,
|
|
233
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment']
|
|
234
|
+
},
|
|
235
|
+
custom_date_fields: {
|
|
236
|
+
label: 'Custom Date Fields',
|
|
237
|
+
description: `Custom Date Field values to be added to the Contact. Values must be in ISO 8601 format. e.g. YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ. The custom field must already exit in Sendgrid.`,
|
|
209
238
|
type: 'object',
|
|
210
239
|
required: false,
|
|
211
240
|
defaultObjectUI: 'keyvalue',
|
|
212
241
|
additionalProperties: true,
|
|
213
|
-
dynamic: true
|
|
242
|
+
dynamic: true,
|
|
243
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment']
|
|
214
244
|
},
|
|
215
245
|
enable_batching: {
|
|
216
246
|
type: 'boolean',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../src/destinations/sendgrid-audiences/syncAudience/fields.ts"],"names":[],"mappings":";;;AACA,4CAA6C;AAEhC,QAAA,MAAM,GAA+B;IAChD,0BAA0B,EAAE;QAC1B,KAAK,EAAE,2BAA2B;QAClC,WAAW,EACT,qHAAqH;QACvH,IAAI,EAAE,QAAQ;QACd,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,OAAO,EAAE,sCAAsC;SAChD;QACD,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;KACpD;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,4EAA4E;QACzF,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE;YACP,OAAO,EAAE,yCAAyC;SACnD;KACF;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,QAAQ;QACd,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,OAAO,EAAE,oCAAoC;SAC9C;KACF;IACD,eAAe,EAAE;QACf,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,2FAA2F;QACxG,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;gBACnC,IAAI,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;gBACjC,IAAI,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;aAC9B;SACF;KACF;IACD,
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../src/destinations/sendgrid-audiences/syncAudience/fields.ts"],"names":[],"mappings":";;;AACA,4CAA6C;AAEhC,QAAA,MAAM,GAA+B;IAChD,0BAA0B,EAAE;QAC1B,KAAK,EAAE,2BAA2B;QAClC,WAAW,EACT,qHAAqH;QACvH,IAAI,EAAE,QAAQ;QACd,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,OAAO,EAAE,sCAAsC;SAChD;QACD,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;KACpD;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,4EAA4E;QACzF,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE;YACP,OAAO,EAAE,yCAAyC;SACnD;KACF;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,QAAQ;QACd,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,OAAO,EAAE,oCAAoC;SAC9C;KACF;IACD,eAAe,EAAE;QACf,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,2FAA2F;QACxG,IAAI,EAAE,QAAQ;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,IAAI;QACb,oBAAoB,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC;KACpF;IACD,eAAe,EAAE;QACf,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,6EAA6E;QAC1F,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACd;IACD,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,oEAAoE;QACjF,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,0BAAc;KACxB;CACF,CAAA"}
|
|
@@ -5,13 +5,16 @@ export interface Payload {
|
|
|
5
5
|
traits_or_props: {
|
|
6
6
|
[k: string]: unknown;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
identifiers: {
|
|
9
|
+
email?: string;
|
|
10
|
+
anonymous_id?: string;
|
|
11
|
+
external_id?: string;
|
|
12
|
+
phone_number_id?: string;
|
|
13
|
+
};
|
|
12
14
|
user_attributes?: {
|
|
13
15
|
first_name?: string;
|
|
14
16
|
last_name?: string;
|
|
17
|
+
phone_number?: string;
|
|
15
18
|
address_line_1?: string;
|
|
16
19
|
address_line_2?: string;
|
|
17
20
|
city?: string;
|
|
@@ -19,7 +22,13 @@ export interface Payload {
|
|
|
19
22
|
country?: string;
|
|
20
23
|
postal_code?: string;
|
|
21
24
|
};
|
|
22
|
-
|
|
25
|
+
custom_text_fields?: {
|
|
26
|
+
[k: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
custom_number_fields?: {
|
|
29
|
+
[k: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
custom_date_fields?: {
|
|
23
32
|
[k: string]: unknown;
|
|
24
33
|
};
|
|
25
34
|
enable_batching: boolean;
|
|
@@ -9,17 +9,27 @@ const action = {
|
|
|
9
9
|
defaultSubscription: 'type = "identify" or type = "track"',
|
|
10
10
|
fields: fields_1.fields,
|
|
11
11
|
dynamicFields: {
|
|
12
|
-
|
|
12
|
+
custom_text_fields: {
|
|
13
13
|
__keys__: async (request, { payload }) => {
|
|
14
|
-
return await dynamic_fields_1.dynamicCustomFields(request, payload);
|
|
14
|
+
return await dynamic_fields_1.dynamicCustomFields(request, payload, "Text");
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
custom_number_fields: {
|
|
18
|
+
__keys__: async (request, { payload }) => {
|
|
19
|
+
return await dynamic_fields_1.dynamicCustomFields(request, payload, "Number");
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
custom_date_fields: {
|
|
23
|
+
__keys__: async (request, { payload }) => {
|
|
24
|
+
return await dynamic_fields_1.dynamicCustomFields(request, payload, "Date");
|
|
15
25
|
}
|
|
16
26
|
}
|
|
17
27
|
},
|
|
18
28
|
perform: async (request, { payload }) => {
|
|
19
|
-
return await utils_1.send(request, [payload]);
|
|
29
|
+
return await utils_1.send(request, [payload], false);
|
|
20
30
|
},
|
|
21
31
|
performBatch: async (request, { payload }) => {
|
|
22
|
-
return await utils_1.send(request, payload);
|
|
32
|
+
return await utils_1.send(request, payload, true);
|
|
23
33
|
}
|
|
24
34
|
};
|
|
25
35
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/sendgrid-audiences/syncAudience/index.ts"],"names":[],"mappings":";;AAGA,mCAA8B;AAC9B,qCAAiC;AACjC,qDAAsD;AAEtD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,mDAAmD;IAChE,mBAAmB,EAAE,qCAAqC;IAC1D,MAAM,EAAN,eAAM;IACN,aAAa,EAAE;QACb,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/sendgrid-audiences/syncAudience/index.ts"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} from '@segment/actions-core';
|
|
2
2
|
import type { Payload } from './generated-types';
|
|
3
|
-
export declare function send(request: RequestClient, payload: Payload[]): Promise<
|
|
3
|
+
export declare function send(request: RequestClient, payload: Payload[], isBatch: boolean): Promise<MultiStatusResponse | undefined>;
|
|
4
|
+
export declare function validatePhone(phone: string): boolean;
|
|
5
|
+
export declare function toDateFormat(dateString: string): string | undefined;
|