@adobe/acc-js-sdk 1.0.8 → 1.1.1
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/CHANGELOG.md +23 -1
- package/MIGRATION.md +160 -0
- package/README.md +139 -14
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/application.js +347 -141
- package/src/client.js +6 -1
- package/src/index.js +1 -1
- package/src/soap.js +5 -2
- package/src/util.js +144 -0
- package/src/xtkCaster.js +17 -2
- package/test/application.test.js +1492 -117
- package/test/client.test.js +3 -3
- package/test/soap.test.js +53 -2
- package/test/util.test.js +167 -1
package/test/client.test.js
CHANGED
|
@@ -2283,15 +2283,15 @@ describe('ACC Client', function () {
|
|
|
2283
2283
|
it("Should ignore protocol for local storage root key", async () => {
|
|
2284
2284
|
var connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("http://acc-sdk:8080", "admin", "admin", {});
|
|
2285
2285
|
var client = await sdk.init(connectionParameters);
|
|
2286
|
-
expect(client._optionCache._storage._rootKey).toBe("acc.js.sdk.1.
|
|
2286
|
+
expect(client._optionCache._storage._rootKey).toBe("acc.js.sdk.1.1.1.acc-sdk:8080.cache.OptionCache$");
|
|
2287
2287
|
|
|
2288
2288
|
connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("https://acc-sdk:8080", "admin", "admin", {});
|
|
2289
2289
|
client = await sdk.init(connectionParameters);
|
|
2290
|
-
expect(client._optionCache._storage._rootKey).toBe("acc.js.sdk.1.
|
|
2290
|
+
expect(client._optionCache._storage._rootKey).toBe("acc.js.sdk.1.1.1.acc-sdk:8080.cache.OptionCache$");
|
|
2291
2291
|
|
|
2292
2292
|
connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("acc-sdk:8080", "admin", "admin", {});
|
|
2293
2293
|
client = await sdk.init(connectionParameters);
|
|
2294
|
-
expect(client._optionCache._storage._rootKey).toBe("acc.js.sdk.1.
|
|
2294
|
+
expect(client._optionCache._storage._rootKey).toBe("acc.js.sdk.1.1.1.acc-sdk:8080.cache.OptionCache$");
|
|
2295
2295
|
})
|
|
2296
2296
|
|
|
2297
2297
|
it("Should support no storage", async () => {
|
package/test/soap.test.js
CHANGED
|
@@ -21,11 +21,12 @@ const { SoapMethodCall } = require('../src/soap.js');
|
|
|
21
21
|
const { CampaignException, makeCampaignException } = require('../src/campaign.js');
|
|
22
22
|
const { DomUtil } = require('../src/domUtil.js');
|
|
23
23
|
const assert = require('assert');
|
|
24
|
+
const sdk = require('../src/index.js');
|
|
24
25
|
|
|
25
26
|
const URL = "https://soap-test/nl/jsp/soaprouter.jsp";
|
|
26
27
|
|
|
27
|
-
function makeSoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString) {
|
|
28
|
-
const call = new SoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString);
|
|
28
|
+
function makeSoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString, optionalCharset) {
|
|
29
|
+
const call = new SoapMethodCall(transport, urn, methodName, sessionToken, securityToken, userAgentString, optionalCharset);
|
|
29
30
|
return call;
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -682,6 +683,56 @@ describe('SOAP', function() {
|
|
|
682
683
|
});
|
|
683
684
|
})
|
|
684
685
|
});
|
|
686
|
+
|
|
687
|
+
describe("Charset encoding", function() {
|
|
688
|
+
|
|
689
|
+
it("Should support no encoding", function() {
|
|
690
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty");
|
|
691
|
+
const request = call._createHTTPRequest(URL);
|
|
692
|
+
assert.equal(request.url, URL);
|
|
693
|
+
assert.equal(request.headers["Content-type"], "application/soap+xml");
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
it("Should support UTF-8 encoding", function() {
|
|
697
|
+
const call = makeSoapMethodCall(undefined, "xtk:session", "Empty", undefined, undefined, undefined, "UTF-8");
|
|
698
|
+
const request = call._createHTTPRequest(URL);
|
|
699
|
+
assert.equal(request.url, URL);
|
|
700
|
+
assert.equal(request.headers["Content-type"], "application/soap+xml;charset=UTF-8");
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
it("Default encoding should be UTF-8", async () => {
|
|
704
|
+
const connectionParameters = sdk.ConnectionParameters.ofSessionToken("http://acc-sdk:8080", "mc/");
|
|
705
|
+
const client = await sdk.init(connectionParameters);
|
|
706
|
+
client._transport = jest.fn();
|
|
707
|
+
expect(client._connectionParameters._options.charset).toBe('UTF-8');
|
|
708
|
+
const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
|
|
709
|
+
expect (soapCall._charset).toBe('UTF-8');
|
|
710
|
+
const request = soapCall._createHTTPRequest(URL);
|
|
711
|
+
assert.equal(request.headers["Content-type"], "application/soap+xml;charset=UTF-8");
|
|
712
|
+
})
|
|
713
|
+
|
|
714
|
+
it("Default support forcing an empty encoding", async () => {
|
|
715
|
+
const connectionParameters = sdk.ConnectionParameters.ofSessionToken("http://acc-sdk:8080", "mc/", { charset: "" });
|
|
716
|
+
const client = await sdk.init(connectionParameters);
|
|
717
|
+
client._transport = jest.fn();
|
|
718
|
+
expect(client._connectionParameters._options.charset).toBe('');
|
|
719
|
+
const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
|
|
720
|
+
expect (soapCall._charset).toBe('');
|
|
721
|
+
const request = soapCall._createHTTPRequest(URL);
|
|
722
|
+
assert.equal(request.headers["Content-type"], "application/soap+xml");
|
|
723
|
+
})
|
|
724
|
+
|
|
725
|
+
it("Default support forcing an ISO charset", async () => {
|
|
726
|
+
const connectionParameters = sdk.ConnectionParameters.ofSessionToken("http://acc-sdk:8080", "mc/", { charset: "ISO-8859-1" });
|
|
727
|
+
const client = await sdk.init(connectionParameters);
|
|
728
|
+
client._transport = jest.fn();
|
|
729
|
+
expect(client._connectionParameters._options.charset).toBe('ISO-8859-1');
|
|
730
|
+
const soapCall = client._prepareSoapCall("xtk:persist", "GetEntityIfMoreRecent", true);
|
|
731
|
+
expect (soapCall._charset).toBe('ISO-8859-1');
|
|
732
|
+
const request = soapCall._createHTTPRequest(URL);
|
|
733
|
+
assert.equal(request.headers["Content-type"], "application/soap+xml;charset=ISO-8859-1");
|
|
734
|
+
})
|
|
735
|
+
});
|
|
685
736
|
|
|
686
737
|
});
|
|
687
738
|
|
package/test/util.test.js
CHANGED
|
@@ -17,7 +17,7 @@ governing permissions and limitations under the License.
|
|
|
17
17
|
*
|
|
18
18
|
*********************************************************************************/
|
|
19
19
|
|
|
20
|
-
const { Util } = require('../src/util.js');
|
|
20
|
+
const { Util, ArrayMap } = require('../src/util.js');
|
|
21
21
|
const { SafeStorage, Cache } = require('../src/cache.js');
|
|
22
22
|
|
|
23
23
|
|
|
@@ -232,4 +232,170 @@ describe('Util', function() {
|
|
|
232
232
|
expect(cache._cache["Hello"].value).toBe("World");
|
|
233
233
|
})
|
|
234
234
|
|
|
235
|
+
describe("ArrayMap", () => {
|
|
236
|
+
|
|
237
|
+
it("Should support access by keys", () => {
|
|
238
|
+
const am = new ArrayMap();
|
|
239
|
+
am._push("hello", "Hello");
|
|
240
|
+
am._push("world", "World");
|
|
241
|
+
expect(am["hello"]).toBe("Hello");
|
|
242
|
+
expect(am["world"]).toBe("World");
|
|
243
|
+
expect(am.get("hello")).toBe("Hello");
|
|
244
|
+
expect(am.get("world")).toBe("World");
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("Should support access by index", () => {
|
|
248
|
+
const am = new ArrayMap();
|
|
249
|
+
am._push("hello", "Hello");
|
|
250
|
+
am._push("world", "World");
|
|
251
|
+
expect(am[0]).toBe("Hello");
|
|
252
|
+
expect(am[1]).toBe("World");
|
|
253
|
+
expect(am.get(0)).toBe("Hello");
|
|
254
|
+
expect(am.get(1)).toBe("World");
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("Should support length attribute", () => {
|
|
258
|
+
const am = new ArrayMap();
|
|
259
|
+
am._push("hello", "Hello");
|
|
260
|
+
am._push("world", "World");
|
|
261
|
+
expect(am.length).toBe(2);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("Should support iterators (for...of)", () => {
|
|
265
|
+
const am = new ArrayMap();
|
|
266
|
+
am._push("hello", "Hello");
|
|
267
|
+
am._push("world", "World");
|
|
268
|
+
let cat = "";
|
|
269
|
+
for (const s of am) cat = cat + s;
|
|
270
|
+
expect(cat).toBe("HelloWorld");
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("Should support map()", () => {
|
|
274
|
+
const am = new ArrayMap();
|
|
275
|
+
am._push("hello", "Hello");
|
|
276
|
+
am._push("world", "World");
|
|
277
|
+
const cat = am.map(s => s).join(',');
|
|
278
|
+
expect(cat).toBe("Hello,World");
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it("Should support flatMap()", () => {
|
|
282
|
+
const am = new ArrayMap();
|
|
283
|
+
am._push("hello", "Hello");
|
|
284
|
+
am._push("world", ["Adobe", "World"]);
|
|
285
|
+
const cat = am.flatMap(s => s).join(',');
|
|
286
|
+
expect(cat).toBe("Hello,Adobe,World");
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("Should support find()", () => {
|
|
290
|
+
const am = new ArrayMap();
|
|
291
|
+
am._push("hello", "Hello");
|
|
292
|
+
am._push("world", "World");
|
|
293
|
+
const world = am.find(s => s === 'World');
|
|
294
|
+
expect(world).toBe("World");
|
|
295
|
+
const notFound = am.find(s => s === 'NotFound');
|
|
296
|
+
expect(notFound).toBe(undefined);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it("Should support filter()", () => {
|
|
300
|
+
const am = new ArrayMap();
|
|
301
|
+
am._push("hello", "Hello");
|
|
302
|
+
am._push("world", "World");
|
|
303
|
+
const all = am.filter(s => true);
|
|
304
|
+
expect(all).toMatchObject([ "Hello", "World" ]);
|
|
305
|
+
const none = am.filter(s => false);
|
|
306
|
+
expect(none).toMatchObject([ ]);
|
|
307
|
+
const world = am.filter(s => s === 'World');
|
|
308
|
+
expect(world).toMatchObject([ "World" ]);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("Should support forEach", () => {
|
|
312
|
+
const am = new ArrayMap();
|
|
313
|
+
am._push("hello", "Hello");
|
|
314
|
+
am._push("world", "World");
|
|
315
|
+
let cat = "";
|
|
316
|
+
am.forEach(s => cat = cat + s);
|
|
317
|
+
expect(cat).toBe("HelloWorld");
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it("Should support forEach as a key", () => {
|
|
321
|
+
const am = new ArrayMap();
|
|
322
|
+
am._push("forEach", "Hello");
|
|
323
|
+
const cat = am.map(s => s).join(',');
|
|
324
|
+
expect(cat).toBe("Hello");
|
|
325
|
+
expect(typeof am.forEach).toBe('function');
|
|
326
|
+
expect(am["forEach"]).not.toBe("Hello"); // forEach is a function
|
|
327
|
+
expect(am.get("forEach")).toBe("Hello");
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it("Should support for...in", () => {
|
|
331
|
+
const am = new ArrayMap();
|
|
332
|
+
am._push("hello", "Hello");
|
|
333
|
+
am._push("world", "World");
|
|
334
|
+
let cat = "";
|
|
335
|
+
for (const s in am) cat = cat + s;
|
|
336
|
+
expect(cat).toBe("helloworld");
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it("Should not support for...in when there's a property named 'forEach'", () => {
|
|
340
|
+
const am = new ArrayMap();
|
|
341
|
+
am._push("hello", "Hello");
|
|
342
|
+
am._push("forEach", "World");
|
|
343
|
+
let cat = "";
|
|
344
|
+
for (const s in am) cat = cat + s;
|
|
345
|
+
expect(cat).toBe("hello");
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("Should support enumerations whose key is a number", () => {
|
|
349
|
+
// For instance the "addressQuality" enumeration
|
|
350
|
+
const am = new ArrayMap();
|
|
351
|
+
am._push("0", { name:"0", value:0 });
|
|
352
|
+
am._push("1", { name:"1", value:1 });
|
|
353
|
+
am._push("2", { name:"2", value:2 });
|
|
354
|
+
let cat = "";
|
|
355
|
+
for (const k in am) cat = cat + am.get(k).name;
|
|
356
|
+
expect(cat).toBe("012");
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it("Should not support adding the same key twice", () => {
|
|
360
|
+
const am = new ArrayMap();
|
|
361
|
+
am._push("hello", "Hello");
|
|
362
|
+
expect(() => { am._push("hello", "World"); }).toThrow("Failed to add element 'hello' to ArrayMap. There's already an item with the same name");
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it("Should support missing names", () => {
|
|
366
|
+
const am = new ArrayMap();
|
|
367
|
+
am._push("", { name:"0", value:0 });
|
|
368
|
+
am._push(undefined, { name:"1", value:1 });
|
|
369
|
+
am._push(null, { name:"2", value:2 });
|
|
370
|
+
expect(am.length).toBe(3);
|
|
371
|
+
expect(am[0].name).toBe("0");
|
|
372
|
+
expect(am[1].name).toBe("1");
|
|
373
|
+
expect(am[2].name).toBe("2");
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it("Should handle compatibility", () => {
|
|
377
|
+
const am = new ArrayMap();
|
|
378
|
+
am._push("perfect", { name:"perfect", value:0 });
|
|
379
|
+
am._push("notPerfect", { name:"notPerfect", value:1 });
|
|
380
|
+
am._push("error", { name:"error", value:2 });
|
|
381
|
+
// length
|
|
382
|
+
expect(am.length).toBe(3);
|
|
383
|
+
// Access by name
|
|
384
|
+
expect(am.perfect).toMatchObject({ name:"perfect", value:0 });
|
|
385
|
+
expect(am.notPerfect).toMatchObject({ name:"notPerfect", value:1 });
|
|
386
|
+
expect(am.error).toMatchObject({ name:"error", value:2 });
|
|
387
|
+
expect(am.notFound).toBeUndefined();
|
|
388
|
+
// for .. in loop
|
|
389
|
+
const list = [];
|
|
390
|
+
for (const p in am) list.push(p);
|
|
391
|
+
expect(list).toMatchObject([ "perfect", "notPerfect", "error" ]);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
describe("Is Browser", () => {
|
|
396
|
+
it("Should not be a browser", () => {
|
|
397
|
+
expect(Util.isBrowser()).toBe(false);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
235
400
|
});
|
|
401
|
+
|