@adobe/acc-js-sdk 1.1.61 → 1.1.62
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/docs/connectionParameters.html +5 -0
- package/package-lock.json +3585 -2091
- package/package.json +1 -1
- package/src/client.js +15 -10
- package/test/client.test.js +34 -4
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -309,6 +309,7 @@ class Credentials {
|
|
|
309
309
|
* @property {number} timeout - Can be set to change the HTTP call timeout. Value is passed in ms.
|
|
310
310
|
* @property {string} cacheRootKey - "default" or "none" - determine the prefix to use for the keys in the caches of schemas, options, etc.
|
|
311
311
|
* @property {string} instanceKey - an optional value to override the instance key which is used for the caches of schemas, options, etc.
|
|
312
|
+
* @property {boolean} enableRequestIdHeader - an optional value to enable the request ID header for SOAP API calls
|
|
312
313
|
* @memberOf Campaign
|
|
313
314
|
*/
|
|
314
315
|
|
|
@@ -1178,17 +1179,21 @@ class Client {
|
|
|
1178
1179
|
* parameters should be set
|
|
1179
1180
|
*/
|
|
1180
1181
|
_prepareSoapCall(urn, method, isStatic, internal, extraHttpHeaders, pushDownOptions) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1182
|
+
|
|
1183
|
+
// Send request ID header if enableRequestIdHeader flag is set to true
|
|
1184
|
+
const enableRequestIdHeader = this._connectionParameters._options &&
|
|
1185
|
+
this._connectionParameters._options.enableRequestIdHeader;
|
|
1186
|
+
let updatedExtraHttpHeaders = extraHttpHeaders;
|
|
1187
|
+
if (enableRequestIdHeader) {
|
|
1188
|
+
try {
|
|
1189
|
+
const requestId = Util.getUUID();
|
|
1190
|
+
updatedExtraHttpHeaders = Object.assign({}, extraHttpHeaders, {
|
|
1189
1191
|
"x-request-id": requestId,
|
|
1190
|
-
})
|
|
1191
|
-
|
|
1192
|
+
});
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
console.error("Failed to generate request ID", error);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1192
1197
|
const soapCall = new SoapMethodCall(this._transport, urn, method,
|
|
1193
1198
|
this._sessionToken, this._securityToken,
|
|
1194
1199
|
this._getUserAgentString(),
|
package/test/client.test.js
CHANGED
|
@@ -3447,8 +3447,8 @@ describe('ACC Client', function () {
|
|
|
3447
3447
|
});
|
|
3448
3448
|
});
|
|
3449
3449
|
|
|
3450
|
-
it("Should add x-request-id header to
|
|
3451
|
-
const client = await Mock.makeClient();
|
|
3450
|
+
it("Should add x-request-id header to SOAP call when enableRequestIdHeader is true", async () => {
|
|
3451
|
+
const client = await Mock.makeClient({ enableRequestIdHeader: true });
|
|
3452
3452
|
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3453
3453
|
await client.NLWS.xtkSession.logon();
|
|
3454
3454
|
|
|
@@ -3480,7 +3480,37 @@ describe('ACC Client', function () {
|
|
|
3480
3480
|
});
|
|
3481
3481
|
|
|
3482
3482
|
it("Should call SOAP call on request ID generation failure", async () => {
|
|
3483
|
-
const client = await Mock.makeClient();
|
|
3483
|
+
const client = await Mock.makeClient({enableRequestIdHeader: true});
|
|
3484
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3485
|
+
await client.NLWS.xtkSession.logon();
|
|
3486
|
+
|
|
3487
|
+
const mockGetUUID = jest.spyOn(Util, 'getUUID').mockImplementation(() => { throw new Error('UUID error'); });
|
|
3488
|
+
|
|
3489
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
3490
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
3491
|
+
const queryDef = {
|
|
3492
|
+
"schema": "nms:extAccount",
|
|
3493
|
+
"operation": "select",
|
|
3494
|
+
"select": {
|
|
3495
|
+
"node": [{ "expr": "@id" }]
|
|
3496
|
+
}
|
|
3497
|
+
};
|
|
3498
|
+
|
|
3499
|
+
const query = client.NLWS.xtkQueryDef.create(queryDef);
|
|
3500
|
+
|
|
3501
|
+
const headers = await collectHeaders(client, async() => {
|
|
3502
|
+
await query.executeQuery();
|
|
3503
|
+
});
|
|
3504
|
+
|
|
3505
|
+
expect(headers["x-request-id"]).toBeUndefined();
|
|
3506
|
+
|
|
3507
|
+
// Restore the mock
|
|
3508
|
+
mockGetUUID.mockRestore();
|
|
3509
|
+
});
|
|
3510
|
+
|
|
3511
|
+
|
|
3512
|
+
it("Should not add x-request-id header to SOAP call when enableRequestIdHeader is false", async () => {
|
|
3513
|
+
const client = await Mock.makeClient({ enableRequestIdHeader: false });
|
|
3484
3514
|
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3485
3515
|
await client.NLWS.xtkSession.logon();
|
|
3486
3516
|
|
|
@@ -4415,7 +4445,7 @@ describe('ACC Client', function () {
|
|
|
4415
4445
|
type: "text/html",
|
|
4416
4446
|
size: 12345,
|
|
4417
4447
|
}, undefined, 'PREFIX');
|
|
4418
|
-
expect(Util.getUUID).toHaveBeenCalledTimes(
|
|
4448
|
+
expect(Util.getUUID).toHaveBeenCalledTimes(1);
|
|
4419
4449
|
});
|
|
4420
4450
|
}); // "File uploader - on browser"
|
|
4421
4451
|
}); // 'upload'
|