@adobe/acc-js-sdk 1.1.28 → 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 +15 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/application.js +39 -19
- package/src/client.js +15 -10
- package/src/util.js +4 -3
- package/test/application.test.js +37 -0
package/docs/changeLog.html
CHANGED
|
@@ -3,6 +3,21 @@ 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
|
+
|
|
14
|
+
<section class="changelog"><h1>Version 1.1.29</h1>
|
|
15
|
+
<h2>2023/06/15</h2>
|
|
16
|
+
<li>
|
|
17
|
+
Passing pushdown options to observability layer
|
|
18
|
+
</li>
|
|
19
|
+
</section>
|
|
20
|
+
|
|
6
21
|
<section class="changelog"><h1>Version 1.1.28</h1>
|
|
7
22
|
<h2>2023/06/09</h2>
|
|
8
23
|
<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/client.js
CHANGED
|
@@ -911,7 +911,7 @@ class Client {
|
|
|
911
911
|
this._observers.map((observer) => callback(observer));
|
|
912
912
|
}
|
|
913
913
|
|
|
914
|
-
_trackEvent(eventName, parentEvent, payload) {
|
|
914
|
+
_trackEvent(eventName, parentEvent, payload, pushDownOptions) {
|
|
915
915
|
try {
|
|
916
916
|
if (payload && payload.name === 'CampaignException') {
|
|
917
917
|
payload = {
|
|
@@ -933,6 +933,9 @@ class Client {
|
|
|
933
933
|
payload: payload,
|
|
934
934
|
timestamp: now,
|
|
935
935
|
};
|
|
936
|
+
if (pushDownOptions) {
|
|
937
|
+
event.pushDownOptions = pushDownOptions;
|
|
938
|
+
}
|
|
936
939
|
if (parentEvent) event.parentEventId = parentEvent.eventId;
|
|
937
940
|
this._notifyObservers((observer) => observer.event && observer.event(event, parentEvent));
|
|
938
941
|
|
|
@@ -1046,6 +1049,7 @@ class Client {
|
|
|
1046
1049
|
if (this._traceAPICalls) {
|
|
1047
1050
|
console.log(`RETRY SOAP//request ${safeCallData}`);
|
|
1048
1051
|
}
|
|
1052
|
+
const pushDownOptions = soapCall._pushDownOptions;
|
|
1049
1053
|
const event = this._trackEvent('SOAP//request', undefined, {
|
|
1050
1054
|
urn: soapCall.urn,
|
|
1051
1055
|
methodName: soapCall.methodName,
|
|
@@ -1053,16 +1057,16 @@ class Client {
|
|
|
1053
1057
|
retry: true,
|
|
1054
1058
|
retryCount: soapCall._retryCount,
|
|
1055
1059
|
safeCallData: safeCallData,
|
|
1056
|
-
});
|
|
1060
|
+
}, pushDownOptions);
|
|
1057
1061
|
try {
|
|
1058
1062
|
await soapCall.execute();
|
|
1059
1063
|
const safeCallResponse = Util.trim(soapCall.response);
|
|
1060
1064
|
if (this._traceAPICalls) {
|
|
1061
1065
|
console.log(`SOAP//response ${safeCallResponse}`);
|
|
1062
1066
|
}
|
|
1063
|
-
this._trackEvent('SOAP//response', event, { safeCallResponse: safeCallResponse });
|
|
1067
|
+
this._trackEvent('SOAP//response', event, { safeCallResponse: safeCallResponse }, pushDownOptions);
|
|
1064
1068
|
} catch(error) {
|
|
1065
|
-
this._trackEvent('SOAP//failure', event, error);
|
|
1069
|
+
this._trackEvent('SOAP//failure', event, error, pushDownOptions);
|
|
1066
1070
|
throw error;
|
|
1067
1071
|
}
|
|
1068
1072
|
return;
|
|
@@ -1314,6 +1318,7 @@ class Client {
|
|
|
1314
1318
|
console.log(`SOAP//request ${safeCallData}`);
|
|
1315
1319
|
that._notifyObservers((observer) => observer.onSOAPCall && observer.onSOAPCall(soapCall, safeCallData) );
|
|
1316
1320
|
|
|
1321
|
+
const pushDownOptions = soapCall._pushDownOptions;
|
|
1317
1322
|
const event = this._trackEvent('SOAP//request', undefined, {
|
|
1318
1323
|
urn: soapCall.urn,
|
|
1319
1324
|
methodName: soapCall.methodName,
|
|
@@ -1321,21 +1326,21 @@ class Client {
|
|
|
1321
1326
|
retry: false,
|
|
1322
1327
|
retryCount: soapCall._retryCount,
|
|
1323
1328
|
safeCallData: safeCallData,
|
|
1324
|
-
});
|
|
1329
|
+
}, pushDownOptions);
|
|
1325
1330
|
return soapCall.execute()
|
|
1326
1331
|
.then(() => {
|
|
1327
1332
|
const safeCallResponse = Util.trim(soapCall.response);
|
|
1328
1333
|
if (that._traceAPICalls)
|
|
1329
1334
|
console.log(`SOAP//response ${safeCallResponse}`);
|
|
1330
1335
|
that._notifyObservers((observer) => observer.onSOAPCallSuccess && observer.onSOAPCallSuccess(soapCall, safeCallResponse) );
|
|
1331
|
-
this._trackEvent('SOAP//response', event, { safeCallResponse: safeCallResponse });
|
|
1336
|
+
this._trackEvent('SOAP//response', event, { safeCallResponse: safeCallResponse }, pushDownOptions);
|
|
1332
1337
|
return Promise.resolve();
|
|
1333
1338
|
})
|
|
1334
1339
|
.catch((ex) => {
|
|
1335
1340
|
if (that._traceAPICalls)
|
|
1336
1341
|
console.log(`SOAP//failure ${ex.toString()}`);
|
|
1337
1342
|
that._notifyObservers((observer) => observer.onSOAPCallFailure && observer.onSOAPCallFailure(soapCall, ex) );
|
|
1338
|
-
this._trackEvent('SOAP//failure', event, ex);
|
|
1343
|
+
this._trackEvent('SOAP//failure', event, ex, pushDownOptions);
|
|
1339
1344
|
// Call session expiration callback in case of 401
|
|
1340
1345
|
if (ex.statusCode == 401 && that._refreshClient && soapCall.retry) {
|
|
1341
1346
|
return this._retrySoapCall(soapCall);
|
|
@@ -1680,7 +1685,7 @@ class Client {
|
|
|
1680
1685
|
* @private
|
|
1681
1686
|
* @deprecated since version 1.0.0
|
|
1682
1687
|
*/
|
|
1683
|
-
|
|
1688
|
+
async _getSecretKeyCipher() {
|
|
1684
1689
|
var that = this;
|
|
1685
1690
|
if (this._secretKeyCipher) return this._secretKeyCipher;
|
|
1686
1691
|
return that.getOption("XtkSecretKey").then(function(secretKey) {
|
|
@@ -1701,7 +1706,7 @@ class Client {
|
|
|
1701
1706
|
* @param {boolean} internal indicates an "internal" call, i.e. a call performed by the SDK itself rather than the user of the SDK. For instance, the SDK will dynamically load schemas to find method definitions
|
|
1702
1707
|
* @return {XML.XtkObject} A DOM or JSON representation of the entity, or null if the entity is not found
|
|
1703
1708
|
*/
|
|
1704
|
-
|
|
1709
|
+
async getEntityIfMoreRecent(entityType, fullName, representation, internal) {
|
|
1705
1710
|
const soapCall = this._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true, internal, this._connectionParameters._options.extraHttpHeaders);
|
|
1706
1711
|
const inputParams = [
|
|
1707
1712
|
{ name: "pk", type: "string", value: entityType + "|" + fullName },
|
|
@@ -2080,7 +2085,7 @@ class Client {
|
|
|
2080
2085
|
const result = this._toRepresentation(xml, representation);
|
|
2081
2086
|
return result;
|
|
2082
2087
|
} catch(ex) {
|
|
2083
|
-
|
|
2088
|
+
throw CampaignException.REPORT_FETCH_FAILED(callContext.reportName, ex);
|
|
2084
2089
|
}
|
|
2085
2090
|
}
|
|
2086
2091
|
|
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", () => {
|