@adobe/acc-js-sdk 1.1.29 → 1.1.30
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 +8 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/application.js +39 -19
- package/src/util.js +4 -3
- package/test/application.test.js +37 -0
package/docs/changeLog.html
CHANGED
|
@@ -3,6 +3,14 @@ layout: page
|
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
<section class="changelog"><h1>Version 1.1.30</h1>
|
|
7
|
+
<h2>2023/06/19</h2>
|
|
8
|
+
<li>
|
|
9
|
+
Fixed an issue causing errors when parsing some specific enumerations such as xtk:dataTransfer:decimalCount which
|
|
10
|
+
contain enumeration values without "value" attributes and whose "name" attribute contains stringified numbers.
|
|
11
|
+
</li>
|
|
12
|
+
</section>
|
|
13
|
+
|
|
6
14
|
<section class="changelog"><h1>Version 1.1.29</h1>
|
|
7
15
|
<h2>2023/06/15</h2>
|
|
8
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.30",
|
|
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.30",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.2.1",
|
package/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -1021,7 +1021,12 @@ function XtkEnumerationValue(xml, baseType, parentTranslationId) {
|
|
|
1021
1021
|
* @type {string}
|
|
1022
1022
|
*/
|
|
1023
1023
|
this.applicableIf = EntityAccessor.getAttributeAsString(xml, "applicableIf");
|
|
1024
|
-
|
|
1024
|
+
let stringValue = EntityAccessor.getAttributeAsString(xml, "value");
|
|
1025
|
+
if (stringValue == "" && XtkCaster.isNumericType(baseType)) {
|
|
1026
|
+
// Some enumerations (ex: xtk:dataTransfer:decimalCount) are of numeric type but do
|
|
1027
|
+
// not have a "value" defined. In this case, we try to cas the name as the value
|
|
1028
|
+
stringValue = this.name;
|
|
1029
|
+
}
|
|
1025
1030
|
/**
|
|
1026
1031
|
* The enumeration value, casted according to the enumeration type
|
|
1027
1032
|
* @type {*}
|
|
@@ -1082,31 +1087,46 @@ class XtkEnumeration {
|
|
|
1082
1087
|
* The enumerations values
|
|
1083
1088
|
* @type {Utils.ArrayMap<Campaign.XtkEnumerationValue>}
|
|
1084
1089
|
*/
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1090
|
+
this.values = new ArrayMap();
|
|
1091
|
+
|
|
1092
|
+
var defaultValue = EntityAccessor.getAttributeAsString(xml, "default");
|
|
1093
|
+
this._localizationId = `${schemaId}__${this.name}`.replace(':','__');
|
|
1094
|
+
|
|
1095
|
+
// Determine if the enumeration can support both access by name and by index.
|
|
1096
|
+
// Some enumerations, such as xtk:dataTransfer:decimalCount are ambiguous since
|
|
1097
|
+
// they have names which are string reprensentation of their values (ex: name="0").
|
|
1098
|
+
// In this case enumValue[0] may mean either the first enumeration value (index 0)
|
|
1099
|
+
// or the enumeration value with value "0" which happens to be the second
|
|
1100
|
+
let supportsIndexing = true;
|
|
1101
|
+
const values = [];
|
|
1102
|
+
for (var child of EntityAccessor.getChildElements(xml, "value")) {
|
|
1103
|
+
const e = new XtkEnumerationValue(child, this.baseType, this._localizationId);
|
|
1104
|
+
values.push(e);
|
|
1105
|
+
const numericName = +e.name;
|
|
1106
|
+
if (numericName === numericName) {
|
|
1107
|
+
// Name is a number
|
|
1108
|
+
supportsIndexing = false;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1089
1111
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1112
|
+
for (const e of values) {
|
|
1113
|
+
this.values._push(e.name, e, !supportsIndexing);
|
|
1114
|
+
if (e.image != "") this.hasImage = true;
|
|
1115
|
+
const stringValue = e.name;
|
|
1116
|
+
if (defaultValue == stringValue)
|
|
1117
|
+
this.default = e;
|
|
1118
|
+
}
|
|
1098
1119
|
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1120
|
+
this.labelLocalizationId = this._localizationId + "__@label";
|
|
1121
|
+
this.descriptionLocalizationId = this._localizationId + "__@desc";
|
|
1122
|
+
propagateImplicitValues(this, true);
|
|
1102
1123
|
|
|
1103
1124
|
/**
|
|
1104
1125
|
* The system enumeration name, without the schema id prefix
|
|
1105
1126
|
* @type {string}
|
|
1106
1127
|
*/
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1128
|
+
this.shortName = this.name;
|
|
1129
|
+
this.name = `${schemaId}:${this.shortName}`;
|
|
1110
1130
|
}
|
|
1111
1131
|
}
|
|
1112
1132
|
|
package/src/util.js
CHANGED
|
@@ -194,14 +194,15 @@ class ArrayMap {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
_push(key, value) {
|
|
197
|
+
_push(key, value, withoutIndexing) {
|
|
198
198
|
let isNumKey = false;
|
|
199
199
|
if (key) {
|
|
200
200
|
// reserved keyworkds
|
|
201
201
|
const isReserved = key === "_items" || key === "length" || key === "_push" || key === "forEach" || key === "map" || key === "_map" || key === "get" || key === "find" || key === "flatMap" || key === "filter";
|
|
202
202
|
|
|
203
203
|
// already a child with the name => there's a problem with the schema
|
|
204
|
-
if (!isReserved && this[key])
|
|
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`);
|
|
205
206
|
|
|
206
207
|
// Set key as a enumerable property, so that elements can be accessed by key,
|
|
207
208
|
// but also iterated on with a for ... in loop
|
|
@@ -218,7 +219,7 @@ class ArrayMap {
|
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
if (!isNumKey) {
|
|
222
|
+
if (!withoutIndexing && !isNumKey) {
|
|
222
223
|
// Set the index property so that items can be accessed by array index.
|
|
223
224
|
// However, make it non-enumerable to make sure indexes do not show up in a for .. in loop
|
|
224
225
|
Object.defineProperty(this, this._items.length, {
|
package/test/application.test.js
CHANGED
|
@@ -700,6 +700,43 @@ describe('Application', () => {
|
|
|
700
700
|
expect(enumeration).toBeFalsy();
|
|
701
701
|
});
|
|
702
702
|
});
|
|
703
|
+
|
|
704
|
+
it("Should support numeric enumeration with implicit value", async () => {
|
|
705
|
+
// Example in xtk:dataTransfer:decimalCount
|
|
706
|
+
const client = await Mock.makeClient();
|
|
707
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
708
|
+
await client.NLWS.xtkSession.logon();
|
|
709
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
710
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:wpp:default' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
711
|
+
<SOAP-ENV:Body>
|
|
712
|
+
<GetEntityIfMoreRecentResponse xmlns='urn:wpp:default' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
713
|
+
<pdomDoc xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
714
|
+
<schema name="dataTransfer" namespace="xtk" xtkschema="xtk:schema">
|
|
715
|
+
<enumeration name="decimalCount" basetype="short">
|
|
716
|
+
<value value="-1" name="all" label="All"/>
|
|
717
|
+
<value name="0"/>
|
|
718
|
+
<value name="1"/>
|
|
719
|
+
<value name="2"/>
|
|
720
|
+
<value name="3"/>
|
|
721
|
+
<value name="4"/>
|
|
722
|
+
<value name="5"/>
|
|
723
|
+
<value name="6"/>
|
|
724
|
+
<value name="7"/>
|
|
725
|
+
<value name="8"/>
|
|
726
|
+
<value name="9"/>
|
|
727
|
+
</enumeration>
|
|
728
|
+
</schema>
|
|
729
|
+
</pdomDoc>
|
|
730
|
+
</GetEntityIfMoreRecentResponse>
|
|
731
|
+
</SOAP-ENV:Body>
|
|
732
|
+
</SOAP-ENV:Envelope>`));
|
|
733
|
+
const enumeration = await client.application.getSysEnum("decimalCount", "xtk:dataTransfer");
|
|
734
|
+
expect(enumeration.label).toBe("DecimalCount");
|
|
735
|
+
const values = enumeration.values;
|
|
736
|
+
expect(values["all"].value).toBe(-1)
|
|
737
|
+
expect(values["0"].value).toBe(0)
|
|
738
|
+
expect(values["1"].value).toBe(1)
|
|
739
|
+
});
|
|
703
740
|
});
|
|
704
741
|
|
|
705
742
|
describe("Keys", () => {
|