@adobe/acc-js-sdk 1.1.47 → 1.1.48

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.
@@ -66,6 +66,8 @@
66
66
  link: reportData.html
67
67
  - name: AEM asset upload API
68
68
  link: uploadAemAsset.html
69
+ - name: Downloading files
70
+ link: download.html
69
71
  - name: --
70
72
  - name: Advanced Topics
71
73
  children:
@@ -2,10 +2,24 @@
2
2
  layout: page
3
3
  title: Change Log
4
4
  ---
5
+ <section class="changelog"><h1>Version 1.1.48</h1>
6
+ <h2>2024/06/11</h2>
7
+ <li>
8
+ <a href="https://github.com/adobe/acc-js-sdk/issues/106">Issue 106</a>. Add support for file download.
9
+ </li>
10
+ <li>
11
+ <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.
12
+ </li>
13
+ <li>
14
+ Updated dependencies to fix <a href="https://github.com/advisories/GHSA-grv7-fg5c-xmjg">vulnerabilities</a>.
15
+ </li>
16
+ </section>
17
+
18
+
5
19
  <section class="changelog"><h1>Version 1.1.47</h1>
6
20
  <h2>2024/04/23</h2>
7
21
  <li>
8
- Issue 105 (https://github.com/adobe/acc-js-sdk/issues/105). Fix XML name of parameters in workflow functions. The name is expected to be 'variables' and not 'parameters'.
22
+ <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
23
  Methods StartWithParameters, PostEvent, SimulateWithParameters, SpawnWithParameters, and SpawnWithParametersEx are included.
10
24
  </li>
11
25
  </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.47",
3
+ "version": "1.1.48",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.47",
9
+ "version": "1.1.48",
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.2",
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.0.1"
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.0.1",
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
  },
@@ -5687,10 +5691,12 @@
5687
5691
  }
5688
5692
  },
5689
5693
  "braces": {
5690
- "version": "3.0.2",
5694
+ "version": "3.0.3",
5695
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
5696
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
5691
5697
  "dev": true,
5692
5698
  "requires": {
5693
- "fill-range": "^7.0.1"
5699
+ "fill-range": "^7.1.1"
5694
5700
  }
5695
5701
  },
5696
5702
  "browserslist": {
@@ -6159,7 +6165,9 @@
6159
6165
  }
6160
6166
  },
6161
6167
  "fill-range": {
6162
- "version": "7.0.1",
6168
+ "version": "7.1.1",
6169
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
6170
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
6163
6171
  "dev": true,
6164
6172
  "requires": {
6165
6173
  "to-regex-range": "^5.0.1"
@@ -6385,6 +6393,8 @@
6385
6393
  },
6386
6394
  "is-number": {
6387
6395
  "version": "7.0.0",
6396
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
6397
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
6388
6398
  "dev": true
6389
6399
  },
6390
6400
  "is-potential-custom-element-name": {
@@ -7543,6 +7553,8 @@
7543
7553
  },
7544
7554
  "to-regex-range": {
7545
7555
  "version": "5.0.1",
7556
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
7557
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
7546
7558
  "dev": true,
7547
7559
  "requires": {
7548
7560
  "is-number": "^7.0.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.47",
3
+ "version": "1.1.48",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
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
@@ -702,7 +702,61 @@ const fileUploader = (client) => {
702
702
  else
703
703
  throw CampaignException.AEM_ASSET_UPLOAD_FAILED(ex, ex.statusCode);
704
704
  }
705
+ },
706
+
707
+ /**
708
+ * Exposed public method of the fileUploader api,
709
+ * specifically designed to download files from the 'upload' folder of the Campaign instance
710
+ * @param {string} md5 md5 of the file content
711
+ * @param {string} ext (original) file extension
712
+ * @param {Object | undefined} options
713
+ * @param {string} options.fileName to rename the name in save as dialog of web browser
714
+ * (force this dialog) must be in UTF-8
715
+ * @param {string} options.contentType change the content-type of the response (to help browser to
716
+ * handle this file) expl : image/png, text/plain;charset=ISO-8859-1
717
+ * @returns {Promise<File(string)>}
718
+ */
719
+ download: async (md5, ext, options) => {
720
+ if (!md5 || typeof md5 !== 'string') {
721
+ throw CampaignException.BAD_PARAMETER(
722
+ "md5",
723
+ md5,
724
+ "'md5' is mandatory parameter with type as 'string' for download file."
725
+ );
726
+ }
727
+
728
+ if (!ext || typeof ext !== "string") {
729
+ throw CampaignException.BAD_PARAMETER(
730
+ "ext",
731
+ ext,
732
+ "'ext' is mandatory parameter with type as 'string' for download file."
733
+ );
734
+ }
735
+
736
+ try {
737
+ const fileName =
738
+ options && options.fileName ? options.fileName : md5;
739
+ const contentType =
740
+ options && options.contentType ? options.contentType : "";
741
+
742
+ let queryString = `md5=${encodeURIComponent(md5)}&ext=${encodeURIComponent(ext)}&fileName=${encodeURIComponent(fileName)}`;
743
+
744
+ if (contentType) {
745
+ queryString += `&contentType=${encodeURIComponent(contentType)}`;
746
+ }
747
+
748
+ const headers = client._getAuthHeaders(false);
749
+ const rawFileResponse = await client._makeHttpCall({
750
+ url: `${client._connectionParameters._endpoint}/nl/jsp/downloadFile.jsp?${queryString}`,
751
+ headers: headers,
752
+ });
753
+
754
+ return rawFileResponse;
755
+ } catch (ex) {
756
+ throw CampaignException.FILE_DOWNLOAD_FAILED(md5, ex);
757
+ }
705
758
  }
759
+
706
760
  };
707
761
  };
708
762
 
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._reset();
85
+ this.jobId = soapCallSpec ? soapCallSpec.jobId : undefined;
84
86
  }
85
87
 
86
88
  // Reset state before executing or submitting a job