@adobe/acc-js-sdk 1.1.47 → 1.1.49
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/docs/_data/navigation.yml +2 -0
- package/docs/changeLog.html +26 -1
- package/docs/download.html +25 -0
- package/docs/xtkJob.html +9 -0
- package/package-lock.json +31 -16
- package/package.json +1 -1
- package/src/campaign.js +1 -2
- package/src/client.js +60 -1
- package/src/xtkJob.js +8 -4
- package/test/client.test.js +799 -419
- package/test/mock.js +3 -0
- package/test/xtkJob.test.js +75 -10
package/docs/changeLog.html
CHANGED
|
@@ -2,10 +2,35 @@
|
|
|
2
2
|
layout: page
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
|
+
<section class="changelog"><h1>Version 1.1.49</h1>
|
|
6
|
+
<h2>2024/07/97</h2>
|
|
7
|
+
<li>
|
|
8
|
+
<a href="https://github.com/adobe/acc-js-sdk/pull/109">Issue 109</a>. Extra HTTP headers were not passed in all API calls.
|
|
9
|
+
</li>
|
|
10
|
+
<li>
|
|
11
|
+
Updated dependencies to fix vulnerabilities.
|
|
12
|
+
</li>
|
|
13
|
+
</section>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<section class="changelog"><h1>Version 1.1.48</h1>
|
|
17
|
+
<h2>2024/06/11</h2>
|
|
18
|
+
<li>
|
|
19
|
+
<a href="https://github.com/adobe/acc-js-sdk/issues/106">Issue 106</a>. Add support for file download.
|
|
20
|
+
</li>
|
|
21
|
+
<li>
|
|
22
|
+
<a href="https://github.com/adobe/acc-js-sdk/issues/10"7>Issue 107</a>. Ability to create a job interface from a job id and get the job status from here.
|
|
23
|
+
</li>
|
|
24
|
+
<li>
|
|
25
|
+
Updated dependencies to fix <a href="https://github.com/advisories/GHSA-grv7-fg5c-xmjg">vulnerabilities</a>.
|
|
26
|
+
</li>
|
|
27
|
+
</section>
|
|
28
|
+
|
|
29
|
+
|
|
5
30
|
<section class="changelog"><h1>Version 1.1.47</h1>
|
|
6
31
|
<h2>2024/04/23</h2>
|
|
7
32
|
<li>
|
|
8
|
-
|
|
33
|
+
<a href="https://github.com/adobe/acc-js-sdk/issues/105">Issue 105</a>. Fix XML name of parameters in workflow functions. The name is expected to be 'variables' and not 'parameters'.
|
|
9
34
|
Methods StartWithParameters, PostEvent, SimulateWithParameters, SpawnWithParameters, and SpawnWithParametersEx are included.
|
|
10
35
|
</li>
|
|
11
36
|
</section>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Downloading files
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Files can be downloaded using the <b>client.fileUploader.download</b> method. In order to download a file from the Campaign server, you need the file md5 and extension which act as the file key. For example, the md5 of a file attachment in a delivry is available in the attachment/@md5 attribute.
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p>
|
|
11
|
+
In the following example, a CSV file is downloaded
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<pre class="code">
|
|
15
|
+
const responseFile = await client.fileUploader.download("d83d8b9a7504043644e1f2dd0a28bf7f", "csv", {
|
|
16
|
+
fileName: 'My Sample File.csv',
|
|
17
|
+
contentType: "txt/csv",
|
|
18
|
+
});
|
|
19
|
+
</pre>
|
|
20
|
+
|
|
21
|
+
<p>
|
|
22
|
+
The function returns a <a href="https://w3c.github.io/FileAPI/#file-section">File Blob</a>
|
|
23
|
+
<p>
|
|
24
|
+
|
|
25
|
+
<p class="warning">This function only works when using the SDK in the browser.</p>
|
package/docs/xtkJob.html
CHANGED
|
@@ -106,6 +106,15 @@ title: XTK Jobs (xkt:job, xkt:jobInterface)
|
|
|
106
106
|
</tbody>
|
|
107
107
|
</table>
|
|
108
108
|
|
|
109
|
+
<p>
|
|
110
|
+
You can get the status of a job, given a job id as follow
|
|
111
|
+
</p>
|
|
112
|
+
|
|
113
|
+
<pre class="code">
|
|
114
|
+
const jobId = 'ABC';
|
|
115
|
+
const job = new XtkJobInterface(client, { jobId });
|
|
116
|
+
const status = await job.getStatus(12, 500);
|
|
117
|
+
</pre>
|
|
109
118
|
|
|
110
119
|
<h1>Job Progress</h1>
|
|
111
120
|
<p>
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/acc-js-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.49",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@adobe/acc-js-sdk",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.49",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.2.1",
|
|
@@ -1437,11 +1437,12 @@
|
|
|
1437
1437
|
}
|
|
1438
1438
|
},
|
|
1439
1439
|
"node_modules/braces": {
|
|
1440
|
-
"version": "3.0.
|
|
1440
|
+
"version": "3.0.3",
|
|
1441
|
+
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
|
1442
|
+
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
|
1441
1443
|
"dev": true,
|
|
1442
|
-
"license": "MIT",
|
|
1443
1444
|
"dependencies": {
|
|
1444
|
-
"fill-range": "^7.
|
|
1445
|
+
"fill-range": "^7.1.1"
|
|
1445
1446
|
},
|
|
1446
1447
|
"engines": {
|
|
1447
1448
|
"node": ">=8"
|
|
@@ -2179,9 +2180,10 @@
|
|
|
2179
2180
|
}
|
|
2180
2181
|
},
|
|
2181
2182
|
"node_modules/fill-range": {
|
|
2182
|
-
"version": "7.
|
|
2183
|
+
"version": "7.1.1",
|
|
2184
|
+
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
|
2185
|
+
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
|
2183
2186
|
"dev": true,
|
|
2184
|
-
"license": "MIT",
|
|
2185
2187
|
"dependencies": {
|
|
2186
2188
|
"to-regex-range": "^5.0.1"
|
|
2187
2189
|
},
|
|
@@ -2557,8 +2559,9 @@
|
|
|
2557
2559
|
},
|
|
2558
2560
|
"node_modules/is-number": {
|
|
2559
2561
|
"version": "7.0.0",
|
|
2562
|
+
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
|
2563
|
+
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
|
2560
2564
|
"dev": true,
|
|
2561
|
-
"license": "MIT",
|
|
2562
2565
|
"engines": {
|
|
2563
2566
|
"node": ">=0.12.0"
|
|
2564
2567
|
}
|
|
@@ -4321,8 +4324,9 @@
|
|
|
4321
4324
|
},
|
|
4322
4325
|
"node_modules/to-regex-range": {
|
|
4323
4326
|
"version": "5.0.1",
|
|
4327
|
+
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
|
4328
|
+
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
|
4324
4329
|
"dev": true,
|
|
4325
|
-
"license": "MIT",
|
|
4326
4330
|
"dependencies": {
|
|
4327
4331
|
"is-number": "^7.0.0"
|
|
4328
4332
|
},
|
|
@@ -4583,14 +4587,15 @@
|
|
|
4583
4587
|
}
|
|
4584
4588
|
},
|
|
4585
4589
|
"node_modules/ws": {
|
|
4586
|
-
"version": "8.
|
|
4587
|
-
"
|
|
4590
|
+
"version": "8.18.0",
|
|
4591
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
|
|
4592
|
+
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
|
4588
4593
|
"engines": {
|
|
4589
4594
|
"node": ">=10.0.0"
|
|
4590
4595
|
},
|
|
4591
4596
|
"peerDependencies": {
|
|
4592
4597
|
"bufferutil": "^4.0.1",
|
|
4593
|
-
"utf-8-validate": "
|
|
4598
|
+
"utf-8-validate": ">=5.0.2"
|
|
4594
4599
|
},
|
|
4595
4600
|
"peerDependenciesMeta": {
|
|
4596
4601
|
"bufferutil": {
|
|
@@ -5687,10 +5692,12 @@
|
|
|
5687
5692
|
}
|
|
5688
5693
|
},
|
|
5689
5694
|
"braces": {
|
|
5690
|
-
"version": "3.0.
|
|
5695
|
+
"version": "3.0.3",
|
|
5696
|
+
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
|
5697
|
+
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
|
5691
5698
|
"dev": true,
|
|
5692
5699
|
"requires": {
|
|
5693
|
-
"fill-range": "^7.
|
|
5700
|
+
"fill-range": "^7.1.1"
|
|
5694
5701
|
}
|
|
5695
5702
|
},
|
|
5696
5703
|
"browserslist": {
|
|
@@ -6159,7 +6166,9 @@
|
|
|
6159
6166
|
}
|
|
6160
6167
|
},
|
|
6161
6168
|
"fill-range": {
|
|
6162
|
-
"version": "7.
|
|
6169
|
+
"version": "7.1.1",
|
|
6170
|
+
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
|
6171
|
+
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
|
6163
6172
|
"dev": true,
|
|
6164
6173
|
"requires": {
|
|
6165
6174
|
"to-regex-range": "^5.0.1"
|
|
@@ -6385,6 +6394,8 @@
|
|
|
6385
6394
|
},
|
|
6386
6395
|
"is-number": {
|
|
6387
6396
|
"version": "7.0.0",
|
|
6397
|
+
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
|
6398
|
+
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
|
6388
6399
|
"dev": true
|
|
6389
6400
|
},
|
|
6390
6401
|
"is-potential-custom-element-name": {
|
|
@@ -7543,6 +7554,8 @@
|
|
|
7543
7554
|
},
|
|
7544
7555
|
"to-regex-range": {
|
|
7545
7556
|
"version": "5.0.1",
|
|
7557
|
+
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
|
7558
|
+
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
|
7546
7559
|
"dev": true,
|
|
7547
7560
|
"requires": {
|
|
7548
7561
|
"is-number": "^7.0.0"
|
|
@@ -7704,7 +7717,9 @@
|
|
|
7704
7717
|
}
|
|
7705
7718
|
},
|
|
7706
7719
|
"ws": {
|
|
7707
|
-
"version": "8.
|
|
7720
|
+
"version": "8.18.0",
|
|
7721
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
|
|
7722
|
+
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
|
7708
7723
|
"requires": {}
|
|
7709
7724
|
},
|
|
7710
7725
|
"xml": {
|
package/package.json
CHANGED
package/src/campaign.js
CHANGED
|
@@ -43,7 +43,7 @@ const { Util } = require("./util.js");
|
|
|
43
43
|
static FEATURE_NOT_SUPPORTED(name) { return new CampaignException(undefined, 500, 16384, `SDK-000015 ${name} feature is not supported by the ACC instance`); }
|
|
44
44
|
static REQUEST_ABORTED( ) { return new CampaignException(undefined, 500, -53, `SDK-000016 Request was aborted by the client`); }
|
|
45
45
|
static AEM_ASSET_UPLOAD_FAILED(details, statusCode=500) { return new CampaignException(undefined, statusCode, 16384, `SDK-000017 Failed to upload AEM asset`, details); }
|
|
46
|
-
|
|
46
|
+
static FILE_DOWNLOAD_FAILED(name, details) { return new CampaignException(undefined, 500, 16384, `SDK-000018 "Failed to download file ${name}`, details); }
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Returns a short description of the exception
|
|
@@ -67,7 +67,6 @@ const { Util } = require("./util.js");
|
|
|
67
67
|
* @param {Error|string} cause an optional error object representing the cause of the exception
|
|
68
68
|
*/
|
|
69
69
|
constructor(call, statusCode, faultCode, faultString, detail, cause) {
|
|
70
|
-
|
|
71
70
|
// Provides a shorter and more friendly description of the call and method name
|
|
72
71
|
// depending on whether the exception is thrown by a SOAP or HTTP call
|
|
73
72
|
var methodCall;
|
package/src/client.js
CHANGED
|
@@ -595,6 +595,8 @@ const fileUploader = (client) => {
|
|
|
595
595
|
const data = new FormData();
|
|
596
596
|
data.append('file_noMd5', file);
|
|
597
597
|
const headers = client._getAuthHeaders(false);
|
|
598
|
+
for (let h in client._connectionParameters._options.extraHttpHeaders)
|
|
599
|
+
headers[h] = client._connectionParameters._options.extraHttpHeaders[h];
|
|
598
600
|
client._makeHttpCall({
|
|
599
601
|
url: `${client._connectionParameters._endpoint}/nl/jsp/uploadFile.jsp`,
|
|
600
602
|
processData: false,
|
|
@@ -680,7 +682,8 @@ const fileUploader = (client) => {
|
|
|
680
682
|
const jsonData = JSON.stringify({
|
|
681
683
|
'assetDownloadUrl': assetDownloadUrl
|
|
682
684
|
});
|
|
683
|
-
|
|
685
|
+
for (let h in client._connectionParameters._options.extraHttpHeaders)
|
|
686
|
+
headers[h] = client._connectionParameters._options.extraHttpHeaders[h];
|
|
684
687
|
var response = await client._makeHttpCall({
|
|
685
688
|
url: url,
|
|
686
689
|
method: 'POST',
|
|
@@ -702,7 +705,63 @@ const fileUploader = (client) => {
|
|
|
702
705
|
else
|
|
703
706
|
throw CampaignException.AEM_ASSET_UPLOAD_FAILED(ex, ex.statusCode);
|
|
704
707
|
}
|
|
708
|
+
},
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Exposed public method of the fileUploader api,
|
|
712
|
+
* specifically designed to download files from the 'upload' folder of the Campaign instance
|
|
713
|
+
* @param {string} md5 md5 of the file content
|
|
714
|
+
* @param {string} ext (original) file extension
|
|
715
|
+
* @param {Object | undefined} options
|
|
716
|
+
* @param {string} options.fileName to rename the name in save as dialog of web browser
|
|
717
|
+
* (force this dialog) must be in UTF-8
|
|
718
|
+
* @param {string} options.contentType change the content-type of the response (to help browser to
|
|
719
|
+
* handle this file) expl : image/png, text/plain;charset=ISO-8859-1
|
|
720
|
+
* @returns {Promise<File(string)>}
|
|
721
|
+
*/
|
|
722
|
+
download: async (md5, ext, options) => {
|
|
723
|
+
if (!md5 || typeof md5 !== 'string') {
|
|
724
|
+
throw CampaignException.BAD_PARAMETER(
|
|
725
|
+
"md5",
|
|
726
|
+
md5,
|
|
727
|
+
"'md5' is mandatory parameter with type as 'string' for download file."
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (!ext || typeof ext !== "string") {
|
|
732
|
+
throw CampaignException.BAD_PARAMETER(
|
|
733
|
+
"ext",
|
|
734
|
+
ext,
|
|
735
|
+
"'ext' is mandatory parameter with type as 'string' for download file."
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
try {
|
|
740
|
+
const fileName =
|
|
741
|
+
options && options.fileName ? options.fileName : md5;
|
|
742
|
+
const contentType =
|
|
743
|
+
options && options.contentType ? options.contentType : "";
|
|
744
|
+
|
|
745
|
+
let queryString = `md5=${encodeURIComponent(md5)}&ext=${encodeURIComponent(ext)}&fileName=${encodeURIComponent(fileName)}`;
|
|
746
|
+
|
|
747
|
+
if (contentType) {
|
|
748
|
+
queryString += `&contentType=${encodeURIComponent(contentType)}`;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
const headers = client._getAuthHeaders(false);
|
|
752
|
+
for (let h in client._connectionParameters._options.extraHttpHeaders)
|
|
753
|
+
headers[h] = client._connectionParameters._options.extraHttpHeaders[h];
|
|
754
|
+
const rawFileResponse = await client._makeHttpCall({
|
|
755
|
+
url: `${client._connectionParameters._endpoint}/nl/jsp/downloadFile.jsp?${queryString}`,
|
|
756
|
+
headers: headers,
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
return rawFileResponse;
|
|
760
|
+
} catch (ex) {
|
|
761
|
+
throw CampaignException.FILE_DOWNLOAD_FAILED(md5, ex);
|
|
762
|
+
}
|
|
705
763
|
}
|
|
764
|
+
|
|
706
765
|
};
|
|
707
766
|
};
|
|
708
767
|
|
package/src/xtkJob.js
CHANGED
|
@@ -32,6 +32,7 @@ const { XtkCaster } = require("./xtkCaster.js");
|
|
|
32
32
|
* @property {string} xtkschema - the method schema id. It can be ommited if the object has a xtkschema property
|
|
33
33
|
* @property {any} object - the object ("this") to call the method with, possibly null for static methods. Should implement the xtk:job interface
|
|
34
34
|
* @property {Array} args - the list of arguments to the SOAP call
|
|
35
|
+
* @property {(string|number)} [jobId] - the optional job id, which can be used for subsequent calls
|
|
35
36
|
* @memberOf Campaign
|
|
36
37
|
*/
|
|
37
38
|
|
|
@@ -77,10 +78,11 @@ class XtkJobInterface {
|
|
|
77
78
|
* @param {Campaign.XtkSoapCallSpec} soapCallSpec the definition of the SOAP call
|
|
78
79
|
*/
|
|
79
80
|
constructor(client, soapCallSpec) {
|
|
81
|
+
this._reset();
|
|
80
82
|
this._client = client;
|
|
81
83
|
this._soapCall = soapCallSpec;
|
|
82
84
|
this._maxLogCount = 100; // default fetch size
|
|
83
|
-
this.
|
|
85
|
+
this.jobId = soapCallSpec ? soapCallSpec.jobId : undefined;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
// Reset state before executing or submitting a job
|
|
@@ -110,7 +112,8 @@ class XtkJobInterface {
|
|
|
110
112
|
client: this._client,
|
|
111
113
|
object: this._soapCall.object,
|
|
112
114
|
schemaId: 'xtk:jobInterface',
|
|
113
|
-
entitySchemaId: entitySchemaId
|
|
115
|
+
entitySchemaId: entitySchemaId,
|
|
116
|
+
headers: this._client._connectionParameters._options.extraHttpHeaders
|
|
114
117
|
};
|
|
115
118
|
var jobId = await callContext.client._callMethod("Execute", callContext, [ methodName ]);
|
|
116
119
|
this.jobId = jobId;
|
|
@@ -133,7 +136,8 @@ class XtkJobInterface {
|
|
|
133
136
|
client: this._client,
|
|
134
137
|
object: this._soapCall.object,
|
|
135
138
|
schemaId: 'xtk:jobInterface',
|
|
136
|
-
entitySchemaId: entitySchemaId
|
|
139
|
+
entitySchemaId: entitySchemaId,
|
|
140
|
+
headers: this._client._connectionParameters._options.extraHttpHeaders
|
|
137
141
|
};
|
|
138
142
|
var jobId = await callContext.client._callMethod("Submit", callContext, [ this._soapCall.method ]);
|
|
139
143
|
this.jobId = jobId;
|
|
@@ -154,8 +158,8 @@ class XtkJobInterface {
|
|
|
154
158
|
object: this._soapCall.object,
|
|
155
159
|
schemaId: 'xtk:jobInterface',
|
|
156
160
|
entitySchemaId: entitySchemaId,
|
|
161
|
+
headers: this._client._connectionParameters._options.extraHttpHeaders
|
|
157
162
|
};
|
|
158
|
-
|
|
159
163
|
const methodName = this._soapCall.method;
|
|
160
164
|
var schema = await this._client.getSchema(entitySchemaId, "xml", true);
|
|
161
165
|
if (!schema)
|