@adobe/acc-js-sdk 1.1.29 → 1.1.31
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 +16 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/application.js +39 -19
- package/src/client.js +5 -2
- package/src/util.js +4 -3
- package/test/application.test.js +37 -0
- package/test/client.test.js +43 -0
- package/test/mock.js +16 -0
package/docs/changeLog.html
CHANGED
|
@@ -3,6 +3,22 @@ layout: page
|
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
<section class="changelog"><h1>Version 1.1.31</h1>
|
|
7
|
+
<h2>2023/06/19</h2>
|
|
8
|
+
<li>
|
|
9
|
+
Fixed a caching issue: xtk:session method can be missing from the cache. This is a temporary fix. A better fix is needed to
|
|
10
|
+
properly handle consistency of the entity and method caches.
|
|
11
|
+
</li>
|
|
12
|
+
</section>
|
|
13
|
+
|
|
14
|
+
<section class="changelog"><h1>Version 1.1.30</h1>
|
|
15
|
+
<h2>2023/06/19</h2>
|
|
16
|
+
<li>
|
|
17
|
+
Fixed an issue causing errors when parsing some specific enumerations such as xtk:dataTransfer:decimalCount which
|
|
18
|
+
contain enumeration values without "value" attributes and whose "name" attribute contains stringified numbers.
|
|
19
|
+
</li>
|
|
20
|
+
</section>
|
|
21
|
+
|
|
6
22
|
<section class="changelog"><h1>Version 1.1.29</h1>
|
|
7
23
|
<h2>2023/06/15</h2>
|
|
8
24
|
<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.31",
|
|
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.31",
|
|
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/client.js
CHANGED
|
@@ -1787,8 +1787,11 @@ class Client {
|
|
|
1787
1787
|
if (entity) {
|
|
1788
1788
|
const impls = DomUtil.getAttributeAsString(entity, "implements");
|
|
1789
1789
|
if (impls === "xtk:persist" && schemaId !== "xtk:session" && schemaId !== "xtk:persist") {
|
|
1790
|
-
|
|
1791
|
-
|
|
1790
|
+
// Ensure xtk:persist is present by loading the xtk:session schema
|
|
1791
|
+
const xtkSession = await this.getSchema("xtk:session", "xml", true);
|
|
1792
|
+
// it is possible that methodCache content has not be loaded in memory
|
|
1793
|
+
// so we re-put the methods
|
|
1794
|
+
await this._methodCache.put(xtkSession);
|
|
1792
1795
|
}
|
|
1793
1796
|
await this._entityCache.put("xtk:schema", schemaId, entity);
|
|
1794
1797
|
await this._methodCache.put(entity);
|
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", () => {
|
package/test/client.test.js
CHANGED
|
@@ -965,6 +965,49 @@ describe('ACC Client', function () {
|
|
|
965
965
|
await client.NLWS.xtkSession.logoff();
|
|
966
966
|
});
|
|
967
967
|
|
|
968
|
+
it("Should always put in cache methods of schema to avoid a method is not found", async () => {
|
|
969
|
+
const client = await Mock.makeClient();
|
|
970
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
971
|
+
await client.NLWS.xtkSession.logon();
|
|
972
|
+
|
|
973
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
974
|
+
client._transport.mockReturnValueOnce(Mock.GET_USER_INFO_RESPONSE);
|
|
975
|
+
// call a method of xtk:session to have the schema xt:session in memory and in entityCache
|
|
976
|
+
await client.NLWS.xtkSession.getUserInfo();
|
|
977
|
+
|
|
978
|
+
// simulate expiration of methodCache only (entityCache not expired)
|
|
979
|
+
client._methodCache.clear();
|
|
980
|
+
|
|
981
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_IMPL_SCHEMA_RESPONSE);
|
|
982
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
983
|
+
await client.NLWS.xtkImpl.Duplicate();
|
|
984
|
+
|
|
985
|
+
client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
|
|
986
|
+
await client.NLWS.xtkSession.logoff();
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
it("Should always put in memory methods of schema to avoid a method is not found", async () => {
|
|
990
|
+
const client = await Mock.makeClient();
|
|
991
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
992
|
+
await client.NLWS.xtkSession.logon();
|
|
993
|
+
|
|
994
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
995
|
+
client._transport.mockReturnValueOnce(Mock.GET_USER_INFO_RESPONSE);
|
|
996
|
+
// call a method of xtk:session to have the schema xt:session in memory and in entityCache
|
|
997
|
+
await client.NLWS.xtkSession.getUserInfo();
|
|
998
|
+
|
|
999
|
+
// simulate empty cache method in memory
|
|
1000
|
+
client._methodCache._cache = {};
|
|
1001
|
+
|
|
1002
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_IMPL_SCHEMA_RESPONSE);
|
|
1003
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
1004
|
+
await client.NLWS.xtkImpl.Duplicate();
|
|
1005
|
+
|
|
1006
|
+
client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
|
|
1007
|
+
await client.NLWS.xtkSession.logoff();
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
|
|
968
1011
|
it("Should fail if method parameter inout attribute is not correct", async () => {
|
|
969
1012
|
const client = await Mock.makeClient();
|
|
970
1013
|
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
package/test/mock.js
CHANGED
|
@@ -219,6 +219,8 @@ const GET_XTK_SESSION_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
|
219
219
|
<interface name="persist">
|
|
220
220
|
<method name="NewInstance">
|
|
221
221
|
</method>
|
|
222
|
+
<method name="Duplicate" static="true">
|
|
223
|
+
</method>
|
|
222
224
|
<method name="Write" static="true">
|
|
223
225
|
<parameters>
|
|
224
226
|
<param name="doc" type="DOMDocument"/>
|
|
@@ -565,6 +567,19 @@ const GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?
|
|
|
565
567
|
</SOAP-ENV:Body>
|
|
566
568
|
</SOAP-ENV:Envelope>`);
|
|
567
569
|
|
|
570
|
+
const GET_XTK_IMPL_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
571
|
+
<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/'>
|
|
572
|
+
<SOAP-ENV:Body>
|
|
573
|
+
<GetEntityIfMoreRecentResponse xmlns='urn:wpp:default' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
574
|
+
<pdomDoc xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
575
|
+
<schema name="impl" namespace="xtk" xtkschema="xtk:schema" implements="xtk:persist">
|
|
576
|
+
<element name="one"></element>
|
|
577
|
+
</schema>
|
|
578
|
+
</pdomDoc>
|
|
579
|
+
</GetEntityIfMoreRecentResponse>
|
|
580
|
+
</SOAP-ENV:Body>
|
|
581
|
+
</SOAP-ENV:Envelope>`);
|
|
582
|
+
|
|
568
583
|
const GET_XTK_ALL_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
569
584
|
<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/'>
|
|
570
585
|
<SOAP-ENV:Body>
|
|
@@ -999,6 +1014,7 @@ exports.Mock = {
|
|
|
999
1014
|
GET_TSTCNX_RESPONSE: GET_TSTCNX_RESPONSE,
|
|
1000
1015
|
GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE: GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE,
|
|
1001
1016
|
GET_XTK_ALL_SCHEMA_RESPONSE: GET_XTK_ALL_SCHEMA_RESPONSE,
|
|
1017
|
+
GET_XTK_IMPL_SCHEMA_RESPONSE: GET_XTK_IMPL_SCHEMA_RESPONSE,
|
|
1002
1018
|
GET_XTK_ALL_TYPES_RESPONSE: GET_XTK_ALL_TYPES_RESPONSE,
|
|
1003
1019
|
GET_XTK_TYPE_UNSUPPORTED_TYPE_RESPONSE: GET_XTK_TYPE_UNSUPPORTED_TYPE_RESPONSE,
|
|
1004
1020
|
GET_USER_INFO_RESPONSE: GET_USER_INFO_RESPONSE,
|