@adobe/acc-js-sdk 1.1.42 → 1.1.43
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/changeLog.html +9 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/util.js +13 -4
- package/test/application.test.js +31 -7
- package/test/util.test.js +18 -2
package/docs/changeLog.html
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
layout: page
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
|
+
<section class="changelog"><h1>Version 1.1.43</h1>
|
|
6
|
+
<h2>2023/12/21</h2>
|
|
7
|
+
<li>
|
|
8
|
+
Do not throw an error in case of duplicate enumeration value. Use the last one instead. This introduces a small behavior change
|
|
9
|
+
because this was causing an exception before.
|
|
10
|
+
</li>
|
|
11
|
+
</section>
|
|
12
|
+
|
|
13
|
+
|
|
5
14
|
<section class="changelog"><h1>Version 1.1.42</h1>
|
|
6
15
|
<h2>2023/12/20</h2>
|
|
7
16
|
<li>
|
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.43",
|
|
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.43",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.2.1",
|
package/package.json
CHANGED
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
|
-
|
|
205
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
package/test/application.test.js
CHANGED
|
@@ -45,13 +45,37 @@ describe('Application', () => {
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it("Duplicate root nodes", () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
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(
|
|
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", () => {
|