@adobe/acc-js-sdk 1.1.35 → 1.1.37

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.
@@ -3,6 +3,20 @@ layout: page
3
3
  title: Change Log
4
4
  ---
5
5
 
6
+ <section class="changelog"><h1>Version 1.1.37</h1>
7
+ <h2>2023/08/07</h2>
8
+ <li>
9
+ Fix missing schema localisation for description id when description is empty in the source schema
10
+ </li>
11
+ </section>
12
+
13
+ <section class="changelog"><h1>Version 1.1.36</h1>
14
+ <h2>2023/07/28</h2>
15
+ <li>
16
+ Fixed the `uploadAemAsset` method when used from a browser, using fetch for HTTP requests.
17
+ </li>
18
+ </section>
19
+
6
20
  <section class="changelog"><h1>Version 1.1.35</h1>
7
21
  <h2>2023/07/25</h2>
8
22
  <li>
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.35",
9
+ "version": "1.1.37",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "axios": "^1.2.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
@@ -62,7 +62,10 @@ function propagateImplicitValues(xtkDesc, labelOnly) {
62
62
  // Force first letter as uppercase
63
63
  xtkDesc.label = xtkDesc.label.substring(0, 1).toUpperCase() + xtkDesc.label.substring(1);
64
64
  }
65
- if (!labelOnly && !xtkDesc.description) xtkDesc.description = xtkDesc.label;
65
+ if (!labelOnly && !xtkDesc.description) {
66
+ xtkDesc.description = xtkDesc.label;
67
+ xtkDesc.descriptionLocalizationId = xtkDesc.labelLocalizationId;
68
+ }
66
69
  }
67
70
 
68
71
  // ========================================================================================
package/src/client.js CHANGED
@@ -657,13 +657,22 @@ const fileUploader = (client) => {
657
657
  if(headers['Authorization'] === undefined || headers['Authorization'] === '' || headers['Authorization'] === 'null') {
658
658
  throw 'Bearer token is missing';
659
659
  }
660
+ // Serialize json data (required for fetch)
661
+ const jsonData = JSON.stringify({
662
+ 'assetDownloadUrl': assetDownloadUrl
663
+ });
660
664
 
661
- const response = await client._makeHttpCall({
665
+ var response = await client._makeHttpCall({
662
666
  url: url,
663
667
  method: 'POST',
664
- data: {assetDownloadUrl: assetDownloadUrl},
668
+ data: jsonData,
665
669
  headers: headers
666
670
  });
671
+
672
+ // response is returned as string when using fetch(in browser)
673
+ // & returned as json using axios(nodejs).
674
+ if(typeof response === 'string')
675
+ response = JSON.parse(response);
667
676
  if(response.publishedURL)
668
677
  return response;
669
678
  else
@@ -2400,7 +2400,15 @@ describe('Application', () => {
2400
2400
  expect(root.labelLocalizationId).toBe('nms__recipient__e____recipient__@label');
2401
2401
  expect(root.descriptionLocalizationId).toBe('nms__recipient__e____recipient__@desc');
2402
2402
  });
2403
-
2403
+
2404
+ it("root node should have the label localization id when label exist but description does not exist", () => {
2405
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients' /></schema>");
2406
+ const schema = newSchema(xml);
2407
+ const root = schema.root;
2408
+ expect(root.labelLocalizationId).toBe('nms__recipient__e____recipient__@label');
2409
+ expect(root.descriptionLocalizationId).toBe('nms__recipient__e____recipient__@label');
2410
+ });
2411
+
2404
2412
  it("child node should have a correct label localization id", () => {
2405
2413
  const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='lib' label='library' desc='library'/><element name='recipient' label='Recipients'/></schema>");
2406
2414
  const schema = newSchema(xml);
@@ -1756,11 +1756,11 @@ describe('ACC Client', function () {
1756
1756
  await client.NLWS.xtkSession.logon();
1757
1757
 
1758
1758
  const mockResponse = {
1759
- "publishedURL" : "http://trk-inst-xyz.campaign.adobe.com/res/trk-inst/409afb8798180a36591456e152b6c406.jpeg"
1759
+ "publishedURL" : "http://trk-inst-xyz.camp.adobe.com/res/trk-inst/409afb8798180a36591456e152b6c406.jpeg"
1760
1760
  };
1761
1761
  client._bearerToken = 'Bearer 1234567890';
1762
1762
  client._transport.mockReturnValueOnce(mockResponse);
1763
- const response = await client.fileUploader.uploadAemAsset("https://author-p74953-e183988-cmstg.adobeaemcloud.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download");
1763
+ const response = await client.fileUploader.uploadAemAsset("https://author-stg.aem.adobe.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download");
1764
1764
  expect(response).toBe(mockResponse);
1765
1765
 
1766
1766
  client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
@@ -1773,7 +1773,7 @@ describe('ACC Client', function () {
1773
1773
  client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
1774
1774
  await client.NLWS.xtkSession.logon();
1775
1775
 
1776
- await (client.fileUploader.uploadAemAsset("https://author-p74953-e183988-cmstg.adobeaemcloud.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download"))
1776
+ await (client.fileUploader.uploadAemAsset("https://author-stg.aem.adobe.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download"))
1777
1777
  .catch( e => { expect(e).toMatchObject(CampaignException.AEM_ASSET_UPLOAD_FAILED('Bearer token is missing'))});
1778
1778
 
1779
1779
  client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
@@ -1791,7 +1791,7 @@ describe('ACC Client', function () {
1791
1791
  client._transport.mockReturnValueOnce(mockResponse);
1792
1792
  client._bearerToken = 'Bearer 1234567890';
1793
1793
 
1794
- await (client.fileUploader.uploadAemAsset("https://author-p74953-e183988-cmstg.adobeaemcloud.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download"))
1794
+ await (client.fileUploader.uploadAemAsset("https://author-stg.aem.adobe.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download"))
1795
1795
  .catch( e => { console.log(e); expect(e).toMatchObject(CampaignException.AEM_ASSET_UPLOAD_FAILED('Publishing failed'))});
1796
1796
 
1797
1797
  client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
@@ -1814,13 +1814,32 @@ describe('ACC Client', function () {
1814
1814
  client._bearerToken = 'Bearer 1234567890';
1815
1815
 
1816
1816
  var ex = CampaignException.AEM_ASSET_UPLOAD_FAILED('The requested content does not exist', 400);
1817
- await (client.fileUploader.uploadAemAsset("https://author-p74953-e183988-cmstg.adobeaemcloud.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download"))
1817
+ await (client.fileUploader.uploadAemAsset("https://author-stg.aem.adobe.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download"))
1818
1818
  .catch( e => { console.log(e); expect(e).toMatchObject(ex)});
1819
1819
 
1820
1820
  client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
1821
1821
  await client.NLWS.xtkSession.logoff();
1822
1822
  });
1823
1823
 
1824
+ // Case 5: transport layer returns response as string instead of json when sdk
1825
+ // used as package inside browser(Fetch API is used in browser while axios in node).
1826
+ it("Should return correct response", async () => {
1827
+ const client = await Mock.makeClient();
1828
+ client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
1829
+ await client.NLWS.xtkSession.logon();
1830
+
1831
+ const mockResponse = {
1832
+ "publishedURL" : "http://trk-inst-xyz.camp.adobe.com/res/trk-inst/409afb8798180a36591456e152b6c406.jpeg"
1833
+ };
1834
+ const mockResponseString = JSON.stringify(mockResponse);
1835
+ client._bearerToken = 'Bearer 1234567890';
1836
+ client._transport.mockReturnValueOnce(mockResponseString);
1837
+ const response = await client.fileUploader.uploadAemAsset("https://author-stg.aem.adobe.com/adobe/repository/content/dam/projects/children-kids-group-eating-ice-cream-funny-party-72701973%20%281%29%20%2812%29%20%282%29%20%283%29.jpg;api=block_download");
1838
+ expect(response).toMatchObject(mockResponse);
1839
+
1840
+ client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
1841
+ await client.NLWS.xtkSession.logoff();
1842
+ });
1824
1843
  });
1825
1844
 
1826
1845