@adobe/acc-js-sdk 1.1.51 → 1.1.53

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.
@@ -2,6 +2,23 @@
2
2
  layout: page
3
3
  title: Change Log
4
4
  ---
5
+ <section class="changelog"><h1>Version 1.1.53</h1>
6
+ <h2>2024/09/06</h2>
7
+ <li>
8
+ Fixed JSON/XML serialization when there is both an attribute and an element with the same name
9
+ </li>
10
+ </section>
11
+
12
+ <section class="changelog"><h1>Version 1.1.52</h1>
13
+ <h2>2024/09/04</h2>
14
+ <li>
15
+ Updated dependencies to fix vulnerabilities reported by npm
16
+ </li>
17
+ <li>
18
+ Report upload error correctly when file upload fails
19
+ </li>
20
+ </section>
21
+
5
22
  <section class="changelog"><h1>Version 1.1.51</h1>
6
23
  <h2>2024/08/15</h2>
7
24
  <li>
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.51",
3
+ "version": "1.1.53",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.51",
9
+ "version": "1.1.53",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "axios": "^1.2.1",
@@ -3668,11 +3668,12 @@
3668
3668
  "license": "MIT"
3669
3669
  },
3670
3670
  "node_modules/micromatch": {
3671
- "version": "4.0.5",
3671
+ "version": "4.0.8",
3672
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
3673
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
3672
3674
  "dev": true,
3673
- "license": "MIT",
3674
3675
  "dependencies": {
3675
- "braces": "^3.0.2",
3676
+ "braces": "^3.0.3",
3676
3677
  "picomatch": "^2.3.1"
3677
3678
  },
3678
3679
  "engines": {
@@ -7152,10 +7153,12 @@
7152
7153
  "dev": true
7153
7154
  },
7154
7155
  "micromatch": {
7155
- "version": "4.0.5",
7156
+ "version": "4.0.8",
7157
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
7158
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
7156
7159
  "dev": true,
7157
7160
  "requires": {
7158
- "braces": "^3.0.2",
7161
+ "braces": "^3.0.3",
7159
7162
  "picomatch": "^2.3.1"
7160
7163
  }
7161
7164
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.51",
3
+ "version": "1.1.53",
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/client.js CHANGED
@@ -629,22 +629,37 @@ const fileUploader = (client) => {
629
629
  size: file.size,
630
630
  };
631
631
  if (action === "publishIfNeeded") {
632
- const counter = await client.NLWS.xtkCounter.increaseValue({name: 'xtkResource'});
633
- const fileRes= {
634
- internalName: 'RES' + counter,
635
- md5: data[0].md5,
636
- label: data[0].fileName,
637
- fileName: data[0].fileName,
638
- originalName: data[0].fileName,
639
- useMd5AsFilename: '1',
640
- storageType: 5,
641
- xtkschema: 'xtk:fileRes'
642
-
632
+ try {
633
+ const counter =
634
+ await client.NLWS.xtkCounter.increaseValue(
635
+ { name: 'xtkResource' }
636
+ );
637
+ const fileRes = {
638
+ internalName: 'RES' + counter,
639
+ md5: data[0].md5,
640
+ label: data[0].fileName,
641
+ fileName: data[0].fileName,
642
+ originalName: data[0].fileName,
643
+ useMd5AsFilename: '1',
644
+ storageType: 5,
645
+ xtkschema: 'xtk:fileRes',
643
646
  };
644
647
  await client.NLWS.xtkSession.write(fileRes);
645
- await client.NLWS.xtkFileRes.create(fileRes).publishIfNeeded();
646
- const url = await client.NLWS.xtkFileRes.create(fileRes).getURL();
648
+ await client.NLWS.xtkFileRes
649
+ .create(fileRes)
650
+ .publishIfNeeded();
651
+ const url = await client.NLWS.xtkFileRes
652
+ .create(fileRes)
653
+ .getURL();
647
654
  result.url = url;
655
+ } catch (ex) {
656
+ reject(
657
+ CampaignException.FILE_UPLOAD_FAILED(
658
+ file.name,
659
+ ex
660
+ )
661
+ );
662
+ }
648
663
  }
649
664
  resolve(result);
650
665
  }
package/src/domUtil.js CHANGED
@@ -314,7 +314,7 @@ class DomUtil {
314
314
  var attFirstIndex = 1;
315
315
 
316
316
  if (flavor == "SimpleJson") {
317
- if ((t == "string" || t == "number" || t == "boolean") && att[0] != '$') {
317
+ if ((t == "string" || t == "number" || t == "boolean") && att[0] != '$' && att[0] != '@') {
318
318
  isAtt = true;
319
319
  attFirstIndex = 0;
320
320
  }
@@ -4061,6 +4061,67 @@ describe('ACC Client', function () {
4061
4061
  expect(found).toBe(true);
4062
4062
  });
4063
4063
 
4064
+ it("Should throw error when 'publishIfNeeded' action rejected", async () => {
4065
+ // Create a mock client and logon
4066
+ const client = await Mock.makeClient();
4067
+ client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
4068
+ await client.NLWS.xtkSession.logon();
4069
+
4070
+ // Mock the upload protocol
4071
+ // - the upload.jsp (which returns the content of an iframe and JS to eval)
4072
+ // - call to xtk:counter#IncreaseValue (first, retrieve the schema xtk:counter then call the function)
4073
+ // - call to xtk:session#Write
4074
+ // - call to xtk:fileRes#PublishIfNeeded
4075
+ // - call to xtk:fileRes#GetURL
4076
+
4077
+ client._transport.mockReturnValueOnce(
4078
+ Promise.resolve(`Ok
4079
+ <html xmlns="http://www.w3.org/1999/xhtml">
4080
+ <head>
4081
+ <script type="text/javascript">if(window.parent&&window.parent.document.controller&&"function"==typeof window.parent.document.controller.uploadFileCallBack){var aFilesInfo=new Array;aFilesInfo.push({paramName:"file",fileName:"test.txt",newFileName:"d8e8fca2dc0f896fd7cb4cb0031ba249.txt",md5:"d8e8fca2dc0f896fd7cb4cb0031ba249"}),window.parent.document.controller.uploadFileCallBack(aFilesInfo)}</script>
4082
+ </head>
4083
+ <body></body>
4084
+ </html>`)
4085
+ ); // upload.jsp
4086
+
4087
+ client._transport.mockReturnValueOnce(
4088
+ Promise.resolve(Mock.GET_XTK_COUNTER_RESPONSE)
4089
+ ); // GetEntityIfMoreRecentResponse - counter
4090
+ client._transport.mockReturnValueOnce(
4091
+ Mock.INCREASE_VALUE_RESPONSE
4092
+ ); // xtk:counter#IncreaseValue
4093
+
4094
+ client._transport.mockReturnValueOnce(
4095
+ Mock.GET_XTK_SESSION_SCHEMA_RESPONSE
4096
+ ); // GetEntityIfMoreRecentResponse - session
4097
+ client._transport.mockReturnValueOnce(
4098
+ Mock.FILE_RES_WRITE_RESPONSE
4099
+ ); // xtk:session#Write
4100
+
4101
+ client._transport.mockReturnValueOnce(
4102
+ Promise.resolve(Mock.GET_FILERES_QUERY_SCHEMA_RESPONSE)
4103
+ ); // GetEntityIfMoreRecentResponse - fileRes
4104
+ client._transport.mockReturnValueOnce(
4105
+ Promise.reject(`Some error occured`)
4106
+ ); // xtk:fileRes#PublishIfNeeded
4107
+
4108
+ client._transport.mockReturnValueOnce(
4109
+ Promise.resolve(Mock.GET_URL_RESPONSE)
4110
+ ); // xtk:fileRes#GetURL
4111
+
4112
+ await client.fileUploader
4113
+ .upload({
4114
+ type: "text/html",
4115
+ size: 12345,
4116
+ name: "abcd.txt",
4117
+ })
4118
+ .catch((ex) => {
4119
+ expect(ex.message).toMatch(
4120
+ "500 - Error 16384: SDK-000013 \"Failed to upload file abcd.txt. 500 - Error calling method 'xtk:fileRes#PublishIfNeeded': Some error occured"
4121
+ );
4122
+ });
4123
+ });
4124
+
4064
4125
  it("Should support 'none' action", async () => {
4065
4126
  // Create a mock client and logon
4066
4127
  const client = await Mock.makeClient();
@@ -156,6 +156,8 @@ describe('DomUtil', function() {
156
156
  assert.strictEqual(fromJSON({ "a": [ ] }), '<root/>');
157
157
  assert.strictEqual(fromJSON({ "a": null }), '<root/>');
158
158
  assert.strictEqual(fromJSON({ "a": undefined }), '<root/>');
159
+ assert.strictEqual(fromJSON({ "@a":2, "@b":"zz", "@c": true }), '<root a="2" b="zz" c="true"/>');
160
+ assert.strictEqual(fromJSON({ "a":{ x:3 }, "@a": 2 }), '<root a="2"><a x="3"/></root>');
159
161
  });
160
162
 
161
163
  it("Should support attributes named 'length'", () => {
@@ -192,6 +194,8 @@ describe('DomUtil', function() {
192
194
  assert.strictEqual(fromJSON({ "a": [ ] }), '<root/>');
193
195
  assert.strictEqual(fromJSON({ "a": null }), '<root/>');
194
196
  assert.strictEqual(fromJSON({ "a": undefined }), '<root/>');
197
+ assert.strictEqual(fromJSON({ "@a":2, "@b":"zz", "@c": true }), '<root a="2" b="zz" c="true"/>');
198
+ assert.strictEqual(fromJSON({ "a":{ x:3 }, "@a": 2 }), '<root a="2"><a x="3"/></root>');
195
199
  });
196
200
  });
197
201