@adobe/acc-js-sdk 1.1.42 → 1.1.44

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.
@@ -291,6 +291,8 @@ const root = await node.linkTarget();
291
291
  <tr><td><b>belongsTo</b></td><td>For attribute and elements, indicates the schema id in which they were defined. Since version 1.1.10 of the SDK</td></tr>
292
292
  <tr><td><b>default</b></td><td>Default value if any. Can be an array for collections. Since version 1.1.24 of the SDK</td></tr>
293
293
  <tr><td><b>translatedDefault</b></td><td>Default value if any. Since version 1.1.24 of the SDK</td></tr>
294
+ <tr><td><b>ordered</b></td><td>If children are ordered</td></tr>
295
+ <tr><td><b>doesNotSupportDiff</b></td><td>If returning the whole node when comparing difference</td></tr>
294
296
  </tbody>
295
297
  </table>
296
298
 
@@ -2,6 +2,23 @@
2
2
  layout: page
3
3
  title: Change Log
4
4
  ---
5
+ <section class="changelog"><h1>Version 1.1.44</h1>
6
+ <h2>2024/01/02</h2>
7
+ <li>
8
+ Add the "ordered" and "doesNotSupportDiff" attributes to the nodes in the application object
9
+ </li>
10
+ </section>
11
+
12
+
13
+ <section class="changelog"><h1>Version 1.1.43</h1>
14
+ <h2>2023/12/21</h2>
15
+ <li>
16
+ Do not throw an error in case of duplicate enumeration value. Use the last one instead. This introduces a small behavior change
17
+ because this was causing an exception before.
18
+ </li>
19
+ </section>
20
+
21
+
5
22
  <section class="changelog"><h1>Version 1.1.42</h1>
6
23
  <h2>2023/12/20</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.42",
3
+ "version": "1.1.44",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.42",
9
+ "version": "1.1.44",
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.42",
3
+ "version": "1.1.44",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
@@ -386,6 +386,12 @@ class XtkSchemaNode {
386
386
  */
387
387
  this.unbound = EntityAccessor.getAttributeAsBoolean(xml, "unbound");
388
388
 
389
+ /**
390
+ * If children are ordered
391
+ * @type {boolean}
392
+ */
393
+ this.ordered = EntityAccessor.getAttributeAsBoolean(xml, "ordered");
394
+
389
395
  /**
390
396
  * The expression controlling the visibility of the current node
391
397
  * @type {string}
@@ -410,6 +416,12 @@ class XtkSchemaNode {
410
416
  */
411
417
  this.isAdvanced = EntityAccessor.getAttributeAsBoolean(xml, "advanced");
412
418
 
419
+ /**
420
+ * if returning the whole node when camparing difference
421
+ * @type {boolean}
422
+ */
423
+ this.doesNotSupportDiff = EntityAccessor.getAttributeAsBoolean(xml, "doesNotSupportDiff");
424
+
413
425
  /**
414
426
  * Children of the node. This is a object whose key are the names of the children nodes (without the "@"
415
427
  * character for attributes)
package/src/util.js CHANGED
@@ -196,13 +196,17 @@ class ArrayMap {
196
196
 
197
197
  _push(key, value, withoutIndexing) {
198
198
  let isNumKey = false;
199
+ let updateIndex = -1;
200
+
199
201
  if (key) {
200
202
  // reserved keyworkds
201
203
  const isReserved = key === "_items" || key === "length" || key === "_push" || key === "forEach" || key === "map" || key === "_map" || key === "get" || key === "find" || key === "flatMap" || key === "filter";
202
204
 
203
205
  // already a child with the name => there's a problem with the schema
204
- if (!isReserved && this[key])
205
- throw new Error(`Failed to add element '${key}' to ArrayMap. There's already an item with the same name`);
206
+ // it seems the current behavior is to replace the existing item with the new one
207
+ if (!isReserved && this[key]) {
208
+ updateIndex = this._items.indexOf(this[key]);
209
+ }
206
210
 
207
211
  // Set key as a enumerable property, so that elements can be accessed by key,
208
212
  // but also iterated on with a for ... in loop
@@ -222,14 +226,19 @@ class ArrayMap {
222
226
  if (!withoutIndexing && !isNumKey) {
223
227
  // Set the index property so that items can be accessed by array index.
224
228
  // However, make it non-enumerable to make sure indexes do not show up in a for .. in loop
225
- Object.defineProperty(this, this._items.length, {
229
+ const numKey = updateIndex == -1 ? this._items.length : updateIndex;
230
+ Object.defineProperty(this, numKey, {
226
231
  value: value,
227
232
  writable: false,
228
233
  enumerable: false,
234
+ configurable: true, // Allow to redefine the property later in case there's a duplicate key
229
235
  });
230
236
  }
231
237
  // Add to array and set length
232
- this._items.push(value);
238
+ if (updateIndex == -1)
239
+ this._items.push(value);
240
+ else
241
+ this._items[updateIndex] = value;
233
242
  this.length = this._items.length;
234
243
  }
235
244
 
@@ -45,13 +45,37 @@ describe('Application', () => {
45
45
  });
46
46
 
47
47
  it("Duplicate root nodes", () => {
48
- expect(() => {
49
- var xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
50
- <element name='recipient' label='Recipients'/>
51
- <element name='recipient' label='Recipients2'/>
52
- </schema>`);
53
- newSchema(xml);
54
- }).toThrow("Failed to add element 'recipient' to ArrayMap. There's already an item with the same name");
48
+ var xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
49
+ <element name='recipient' label='Recipients'/>
50
+ <element name='recipient' label='Recipients2'/>
51
+ </schema>`);
52
+ var schema = newSchema(xml);
53
+ var root = schema.root;
54
+ expect(root).toBeTruthy();
55
+ expect(root.name).toBe("recipient");
56
+ expect(root.label).toBe("Recipients2");
57
+ });
58
+
59
+ it("Duplicate enumeration value", () => {
60
+ const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
61
+ <enumeration basetype="string" name="AKA">
62
+ <value name="PC" value="1"/>
63
+ <value name="CL2" value="2"/>
64
+ <value name="CL3" value="3"/>
65
+ <value name="Null" value="4"/>
66
+ <value name="Null" value="NULL"/>
67
+ </enumeration>
68
+ <element name='recipient' label='Recipients'/>
69
+ </schema>`);
70
+ const schema = newSchema(xml);
71
+ const enumerations = schema.enumerations;
72
+ const enumeration = enumerations.AKA.values;
73
+ expect(enumeration.length).toBe(4);
74
+ expect(enumeration[0].name).toBe("PC");
75
+ expect(enumeration[1].name).toBe("CL2");
76
+ expect(enumeration[2].name).toBe("CL3");
77
+ expect(enumeration[3].name).toBe("Null");
78
+ expect(enumeration[3].value).toBe("NULL");
55
79
  });
56
80
 
57
81
  it("Should find root node", () => {
package/test/util.test.js CHANGED
@@ -371,10 +371,26 @@ describe('Util', function() {
371
371
  expect(cat).toBe("012");
372
372
  });
373
373
 
374
- it("Should not support adding the same key twice", () => {
374
+ it("Should support adding the same key twice. The last value overwrites", () => {
375
375
  const am = new ArrayMap();
376
376
  am._push("hello", "Hello");
377
- expect(() => { am._push("hello", "World"); }).toThrow("Failed to add element 'hello' to ArrayMap. There's already an item with the same name");
377
+ expect(am.length).toBe(1);
378
+ am._push("hello", "World");
379
+ expect(am.length).toBe(1);
380
+ expect(am.get(0)).toBe("World");
381
+ });
382
+
383
+ it("Should support adding the same key twice. The last value overwrites in the middle of the array", () => {
384
+ const am = new ArrayMap();
385
+ am._push("hello", "Hello");
386
+ am._push("cruel", "Cruel");
387
+ am._push("world", "World");
388
+ expect(am.length).toBe(3);
389
+ am._push("cruel", "*cruel*");
390
+ expect(am.length).toBe(3);
391
+ expect(am.get(0)).toBe("Hello");
392
+ expect(am.get(1)).toBe("*cruel*");
393
+ expect(am.get(2)).toBe("World");
378
394
  });
379
395
 
380
396
  it("Should support missing names", () => {