@scopieflows/app-salesforce-marketing-cloud 0.1.9 → 0.2.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/package.json +1 -1
- package/src/index.js +5 -105
- package/src/index.js.map +1 -1
- package/src/lib/common/index.js +2 -25
- package/src/lib/common/index.js.map +1 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -23,15 +23,15 @@ const start_automation_1 = require("./lib/actions/start-automation");
|
|
|
23
23
|
const pause_automation_1 = require("./lib/actions/pause-automation");
|
|
24
24
|
const get_automation_status_1 = require("./lib/actions/get-automation-status");
|
|
25
25
|
exports.sfmcAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
26
|
-
description: `Connect your Salesforce Marketing Cloud account.
|
|
26
|
+
description: `Connect your Salesforce Marketing Cloud account using the **Client Credentials** flow.
|
|
27
27
|
|
|
28
28
|
1. In SFMC go to **Setup > Apps > Installed Packages**
|
|
29
29
|
2. Click **New** and create a package
|
|
30
|
-
3. Click **Add Component > API Integration**
|
|
30
|
+
3. Click **Add Component > API Integration** and choose **Server-to-Server**
|
|
31
31
|
4. Select the scopes your actions need (at minimum: **Data Extensions Read/Write**, **Journeys Read/Execute**)
|
|
32
32
|
5. Copy the **Client ID**, **Client Secret**, and **Auth Base URI** from the package details`,
|
|
33
33
|
required: true,
|
|
34
|
-
grantType: shared_1.
|
|
34
|
+
grantType: shared_1.OAuth2GrantType.CLIENT_CREDENTIALS,
|
|
35
35
|
props: {
|
|
36
36
|
authBaseUri: pieces_framework_1.Property.ShortText({
|
|
37
37
|
displayName: 'Auth Base URI',
|
|
@@ -39,109 +39,9 @@ exports.sfmcAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
|
39
39
|
required: true,
|
|
40
40
|
}),
|
|
41
41
|
},
|
|
42
|
-
authUrl: '
|
|
42
|
+
authUrl: '',
|
|
43
43
|
tokenUrl: '{authBaseUri}/v2/token',
|
|
44
|
-
scope: [
|
|
45
|
-
'offline',
|
|
46
|
-
'email_read',
|
|
47
|
-
'email_write',
|
|
48
|
-
'email_send',
|
|
49
|
-
'ott_chat_messaging_read',
|
|
50
|
-
'ott_chat_messaging_send',
|
|
51
|
-
'push_read',
|
|
52
|
-
'push_write',
|
|
53
|
-
'push_send',
|
|
54
|
-
'sms_read',
|
|
55
|
-
'sms_write',
|
|
56
|
-
'sms_send',
|
|
57
|
-
'social_read',
|
|
58
|
-
'social_write',
|
|
59
|
-
'social_publish',
|
|
60
|
-
'social_post',
|
|
61
|
-
'web_read',
|
|
62
|
-
'web_write',
|
|
63
|
-
'web_publish',
|
|
64
|
-
'documents_and_images_read',
|
|
65
|
-
'documents_and_images_write',
|
|
66
|
-
'saved_content_read',
|
|
67
|
-
'saved_content_write',
|
|
68
|
-
'automations_read',
|
|
69
|
-
'automations_write',
|
|
70
|
-
'automations_execute',
|
|
71
|
-
'journeys_read',
|
|
72
|
-
'journeys_write',
|
|
73
|
-
'journeys_execute',
|
|
74
|
-
'journeys_aspr',
|
|
75
|
-
'journeys_delete',
|
|
76
|
-
'audiences_read',
|
|
77
|
-
'audiences_write',
|
|
78
|
-
'contact_bu_mapping_create',
|
|
79
|
-
'contact_bu_mapping_view',
|
|
80
|
-
'contact_bu_mapping_update',
|
|
81
|
-
'contact_bu_mapping_delete',
|
|
82
|
-
'list_and_subscribers_read',
|
|
83
|
-
'list_and_subscribers_write',
|
|
84
|
-
'market_audience_create',
|
|
85
|
-
'market_audience_view',
|
|
86
|
-
'market_audience_update',
|
|
87
|
-
'market_audience_delete',
|
|
88
|
-
'market_audience_member_create',
|
|
89
|
-
'market_audience_member_view',
|
|
90
|
-
'market_audience_member_update',
|
|
91
|
-
'market_audience_member_delete',
|
|
92
|
-
'marketing_cloud_connect_read',
|
|
93
|
-
'marketing_cloud_connect_write',
|
|
94
|
-
'marketing_cloud_connect_send',
|
|
95
|
-
'data_extensions_read',
|
|
96
|
-
'data_extensions_write',
|
|
97
|
-
'file_locations_read',
|
|
98
|
-
'file_locations_write',
|
|
99
|
-
'tracking_events_read',
|
|
100
|
-
'tracking_events_write',
|
|
101
|
-
'key_manage_view',
|
|
102
|
-
'key_manage_rotate',
|
|
103
|
-
'key_manage_revoke',
|
|
104
|
-
'dfu_configure',
|
|
105
|
-
'event_notification_callback_read',
|
|
106
|
-
'event_notification_callback_create',
|
|
107
|
-
'event_notification_callback_update',
|
|
108
|
-
'event_notification_callback_delete',
|
|
109
|
-
'event_notification_subscription_read',
|
|
110
|
-
'event_notification_subscription_create',
|
|
111
|
-
'event_notification_subscription_update',
|
|
112
|
-
'event_notification_subscription_delete',
|
|
113
|
-
'approvals_read',
|
|
114
|
-
'approvals_write',
|
|
115
|
-
'calendar_read',
|
|
116
|
-
'calendar_write',
|
|
117
|
-
'campaign_read',
|
|
118
|
-
'campaign_write',
|
|
119
|
-
'tags_read',
|
|
120
|
-
'tags_write',
|
|
121
|
-
'workflows_read',
|
|
122
|
-
'workflows_write',
|
|
123
|
-
'deep_linking_asset_read',
|
|
124
|
-
'deep_linking_asset_write',
|
|
125
|
-
'deep_linking_asset_delete',
|
|
126
|
-
'deep_linking_settings_read',
|
|
127
|
-
'deep_linking_settings_write',
|
|
128
|
-
'accounts_read',
|
|
129
|
-
'accounts_write',
|
|
130
|
-
'e360_analytics_provisioning_view',
|
|
131
|
-
'e360_analytics_provisioning_update',
|
|
132
|
-
'e360_analytics_provisioning_delete',
|
|
133
|
-
'ott_channels_read',
|
|
134
|
-
'ott_channels_write',
|
|
135
|
-
'package_manager_package',
|
|
136
|
-
'package_manager_deploy',
|
|
137
|
-
'users_read',
|
|
138
|
-
'users_write',
|
|
139
|
-
'http_headers_view',
|
|
140
|
-
'http_headers_update',
|
|
141
|
-
'webhooks_read',
|
|
142
|
-
'webhooks_write',
|
|
143
|
-
],
|
|
144
|
-
prompt: 'omit',
|
|
44
|
+
scope: [],
|
|
145
45
|
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
146
46
|
var _b;
|
|
147
47
|
try {
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAKuC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAKuC;AACvC,gDAAqE;AACrE,8DAKoC;AACpC,uFAAiF;AACjF,mFAA6E;AAC7E,uFAAiF;AACjF,+EAA0E;AAC1E,+EAA0E;AAC1E,+EAA0E;AAC1E,yEAAoE;AACpE,iEAA6D;AAC7D,qEAAiE;AACjE,+DAA2D;AAC3D,6EAAwE;AACxE,qFAAgF;AAChF,qEAAgE;AAChE,+EAA0E;AAC1E,qEAAiE;AACjE,qEAAiE;AACjE,+EAA0E;AAE7D,QAAA,QAAQ,GAAG,4BAAS,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE;;;;;;6FAM+E;IAC5F,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,wBAAe,CAAC,kBAAkB;IAC7C,KAAK,EAAE;QACN,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,eAAe;YAC5B,WAAW,EACV,0LAA0L;YAC3L,QAAQ,EAAE,IAAI;SACd,CAAC;KACF;IACD,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,wBAAwB;IAClC,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;;QACxB,IAAI,CAAC;YACJ,MAAM,SAAS,GAAG,IAA2B,CAAC;YAC9C,MAAM,eAAe,GAAG,MAAA,SAAS,CAAC,IAAI,0CAAG,mBAAmB,CAEhD,CAAC;YACb,IAAI,CAAC,eAAe,EAAE,CAAC;gBACtB,OAAO;oBACN,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,qGAAqG;iBAC5G,CAAC;YACH,CAAC;YAC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kB;QAClB,iDAAsB;QACtB,iCAAc;QACd,2CAAmB;QACnB,kCAAe;QACf,kCAAe;QACf,2CAAmB;QACnB,IAAA,yCAAyB,EAAC;YACzB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;;gBACjB,MAAM,eAAe,GAAG,MAAC,IAA4B,CAAC,IAAI,0CACzD,mBAAmB,CACG,CAAC;gBACxB,OAAO,eAAe;oBACrB,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;oBACpC,CAAC,CAAC,EAAE,CAAC;YACP,CAAC;YACD,IAAI,EAAE,gBAAQ;YACd,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC7B,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;iBACrE,CAAC,CAAA;cAAA;SACF,CAAC;KACF;IACD,QAAQ,EAAE,EAAE;CACZ,CAAC,CAAC"}
|
package/src/lib/common/index.js
CHANGED
|
@@ -19,33 +19,15 @@ function mapSfmcError(error) {
|
|
|
19
19
|
if (message.includes('invalid_client') || message.includes('Unauthorized')) {
|
|
20
20
|
throw new Error('Authentication failed. Check your Client ID, Client Secret, and that the connected app has the required package scopes.');
|
|
21
21
|
}
|
|
22
|
-
if (message.includes('redirect_uri')) {
|
|
23
|
-
throw new Error('Redirect URI mismatch. The redirect URI configured in your SFMC connected app must exactly match the one used by ScopieFlows (no trailing slash differences).');
|
|
24
|
-
}
|
|
25
22
|
throw new Error(`SFMC API error: ${message}`);
|
|
26
23
|
}
|
|
27
24
|
function sfmcApiCall(_a) {
|
|
28
25
|
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, method, path, body, queryParams, }) {
|
|
29
|
-
var _b, _c, _d;
|
|
30
26
|
const baseUrl = getRestInstanceUrl(auth);
|
|
31
|
-
const fullUrl = `${baseUrl}${path}`;
|
|
32
|
-
console.log('[SFMC DEBUG] === Request ===');
|
|
33
|
-
console.log('[SFMC DEBUG] Method:', method);
|
|
34
|
-
console.log('[SFMC DEBUG] URL:', fullUrl);
|
|
35
|
-
console.log('[SFMC DEBUG] Base URL (rest_instance_url):', baseUrl);
|
|
36
|
-
console.log('[SFMC DEBUG] Token (first 30 chars):', ((_b = auth.access_token) === null || _b === void 0 ? void 0 : _b.substring(0, 30)) + '...');
|
|
37
|
-
console.log('[SFMC DEBUG] Token length:', (_c = auth.access_token) === null || _c === void 0 ? void 0 : _c.length);
|
|
38
|
-
console.log('[SFMC DEBUG] Grant type:', auth['grant_type']);
|
|
39
|
-
console.log('[SFMC DEBUG] Auth data keys:', JSON.stringify(Object.keys((_d = auth.data) !== null && _d !== void 0 ? _d : {})));
|
|
40
|
-
console.log('[SFMC DEBUG] Scope:', auth['scope']);
|
|
41
|
-
if (queryParams)
|
|
42
|
-
console.log('[SFMC DEBUG] Query params:', JSON.stringify(queryParams));
|
|
43
|
-
if (body)
|
|
44
|
-
console.log('[SFMC DEBUG] Body:', JSON.stringify(body));
|
|
45
27
|
try {
|
|
46
|
-
|
|
28
|
+
return yield pieces_common_1.httpClient.sendRequest({
|
|
47
29
|
method,
|
|
48
|
-
url:
|
|
30
|
+
url: `${baseUrl}${path}`,
|
|
49
31
|
authentication: {
|
|
50
32
|
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
51
33
|
token: auth.access_token,
|
|
@@ -53,13 +35,8 @@ function sfmcApiCall(_a) {
|
|
|
53
35
|
queryParams,
|
|
54
36
|
body,
|
|
55
37
|
});
|
|
56
|
-
console.log('[SFMC DEBUG] === Response ===');
|
|
57
|
-
console.log('[SFMC DEBUG] Status:', response.status);
|
|
58
|
-
return response;
|
|
59
38
|
}
|
|
60
39
|
catch (error) {
|
|
61
|
-
console.log('[SFMC DEBUG] === Error ===');
|
|
62
|
-
console.log('[SFMC DEBUG] Error:', error instanceof Error ? error.message : String(error));
|
|
63
40
|
mapSfmcError(error);
|
|
64
41
|
}
|
|
65
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":";;AAmCA,kCA4BC;;AA/DD,8DAMoC;AAGpC,SAAS,kBAAkB,CAAC,IAAyB;;IACpD,MAAM,eAAe,GAAG,MAAA,IAAI,CAAC,IAAI,0CAAG,mBAAmB,CAAuB,CAAC;IAC/E,IAAI,CAAC,eAAe,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACd,2IAA2I,CAC3I,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IACnC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEvE,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CACd,gIAAgI,CAChI,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CACd,yHAAyH,CACzH,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAsB,WAAW;iEAA4B,EAC5D,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,WAAW,GAOX;QACA,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC;YACJ,OAAO,MAAM,0BAAU,CAAC,WA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