@adobe/acc-js-sdk 1.1.14 → 1.1.16

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.
@@ -144,17 +144,19 @@ describe('DomUtil', function() {
144
144
  return DomUtil.toXMLString(xml);
145
145
  }
146
146
 
147
- assert.strictEqual(fromJSON({}), '<root/>');
148
- assert.strictEqual(fromJSON({ "a":2, "b":"zz", "c": true }), '<root a="2" b="zz" c="true"/>');
149
- assert.strictEqual(fromJSON({ "a":{ x:3 } }), '<root><a x="3"/></root>');
150
- assert.strictEqual(fromJSON({ "$": "Hello" }), '<root>Hello</root>');
151
- assert.strictEqual(fromJSON({ "$a": "Hello" }), '<root><a>Hello</a></root>');
152
- assert.strictEqual(fromJSON({ a: { "$": "Hello" } }), '<root><a>Hello</a></root>');
153
- assert.strictEqual(fromJSON({ a: "World", "$a": "Hello" }), '<root a="World"><a>Hello</a></root>');
154
- assert.strictEqual(fromJSON({ "a": [ { "i":1 }, { "i": 2 } ] }), '<root><a i="1"/><a i="2"/></root>');
155
- assert.strictEqual(fromJSON({ "a": [ ] }), '<root/>');
156
- assert.strictEqual(fromJSON({ "a": null }), '<root/>');
157
- assert.strictEqual(fromJSON({ "a": undefined }), '<root/>');
147
+ it("Should convert from JSON to XML", () => {
148
+ assert.strictEqual(fromJSON({}), '<root/>');
149
+ assert.strictEqual(fromJSON({ "a":2, "b":"zz", "c": true }), '<root a="2" b="zz" c="true"/>');
150
+ assert.strictEqual(fromJSON({ "a":{ x:3 } }), '<root><a x="3"/></root>');
151
+ assert.strictEqual(fromJSON({ "$": "Hello" }), '<root>Hello</root>');
152
+ assert.strictEqual(fromJSON({ "$a": "Hello" }), '<root><a>Hello</a></root>');
153
+ assert.strictEqual(fromJSON({ a: { "$": "Hello" } }), '<root><a>Hello</a></root>');
154
+ assert.strictEqual(fromJSON({ a: "World", "$a": "Hello" }), '<root a="World"><a>Hello</a></root>');
155
+ assert.strictEqual(fromJSON({ "a": [ { "i":1 }, { "i": 2 } ] }), '<root><a i="1"/><a i="2"/></root>');
156
+ assert.strictEqual(fromJSON({ "a": [ ] }), '<root/>');
157
+ assert.strictEqual(fromJSON({ "a": null }), '<root/>');
158
+ assert.strictEqual(fromJSON({ "a": undefined }), '<root/>');
159
+ });
158
160
  });
159
161
 
160
162
  describe('fromJSON (default)', function() {
@@ -164,17 +166,37 @@ describe('DomUtil', function() {
164
166
  return DomUtil.toXMLString(xml);
165
167
  }
166
168
 
167
- assert.strictEqual(fromJSON({}), '<root/>');
168
- assert.strictEqual(fromJSON({ "a":2, "b":"zz", "c": true }), '<root a="2" b="zz" c="true"/>');
169
- assert.strictEqual(fromJSON({ "a":{ x:3 } }), '<root><a x="3"/></root>');
170
- assert.strictEqual(fromJSON({ "$": "Hello" }), '<root>Hello</root>');
171
- assert.strictEqual(fromJSON({ "$a": "Hello" }), '<root><a>Hello</a></root>');
172
- assert.strictEqual(fromJSON({ a: { "$": "Hello" } }), '<root><a>Hello</a></root>');
173
- assert.strictEqual(fromJSON({ a: "World", "$a": "Hello" }), '<root a="World"><a>Hello</a></root>');
174
- assert.strictEqual(fromJSON({ "a": [ { "i":1 }, { "i": 2 } ] }), '<root><a i="1"/><a i="2"/></root>');
175
- assert.strictEqual(fromJSON({ "a": [ ] }), '<root/>');
176
- assert.strictEqual(fromJSON({ "a": null }), '<root/>');
177
- assert.strictEqual(fromJSON({ "a": undefined }), '<root/>');
169
+ it("Should convert from JSON to XML", () => {
170
+ assert.strictEqual(fromJSON({}), '<root/>');
171
+ assert.strictEqual(fromJSON({ "a":2, "b":"zz", "c": true }), '<root a="2" b="zz" c="true"/>');
172
+ assert.strictEqual(fromJSON({ "a":{ x:3 } }), '<root><a x="3"/></root>');
173
+ assert.strictEqual(fromJSON({ "$": "Hello" }), '<root>Hello</root>');
174
+ assert.strictEqual(fromJSON({ "$a": "Hello" }), '<root><a>Hello</a></root>');
175
+ assert.strictEqual(fromJSON({ a: { "$": "Hello" } }), '<root><a>Hello</a></root>');
176
+ assert.strictEqual(fromJSON({ a: "World", "$a": "Hello" }), '<root a="World"><a>Hello</a></root>');
177
+ assert.strictEqual(fromJSON({ "a": [ { "i":1 }, { "i": 2 } ] }), '<root><a i="1"/><a i="2"/></root>');
178
+ assert.strictEqual(fromJSON({ "a": [ ] }), '<root/>');
179
+ assert.strictEqual(fromJSON({ "a": null }), '<root/>');
180
+ assert.strictEqual(fromJSON({ "a": undefined }), '<root/>');
181
+ });
182
+ });
183
+
184
+ describe('fromJSON (advanced)', function() {
185
+ function fromJSON(json) {
186
+ var xml = DomUtil.fromJSON("root", json);
187
+ return DomUtil.toXMLString(xml);
188
+ }
189
+
190
+ it("Should handle fixes made in version 1.1.3", () => {
191
+ expect(fromJSON({ $: "Hello" })).toBe("<root>Hello</root>");
192
+ expect(fromJSON({ "$delivery": "Hello" })).toBe("<root><delivery>Hello</delivery></root>");
193
+ expect(fromJSON({ "delivery": { $: "Hello" } })).toBe("<root><delivery>Hello</delivery></root>");
194
+ //expect(fromJSON({ "$delivery": "World", "delivery": { $: "Hello" } })).toBe("<root><delivery>Hello</delivery></root>");
195
+ expect(fromJSON({delivery: { "transaction": "0", "$": "0" }})).toBe('<root><delivery transaction="0">0</delivery></root>');
196
+ expect(fromJSON({delivery: { "$": "Hello", child: { name: "world" } }})).toBe('<root><delivery>Hello<child name="world"/></delivery></root>');
197
+ expect(fromJSON({delivery: { "$": "Hello", child: { name: "world" } }})).toBe('<root><delivery>Hello<child name="world"/></delivery></root>');
198
+ expect(fromJSON({ delivery: { $: "HelloWorld", child:{} } })).toBe('<root><delivery>HelloWorld<child/></delivery></root>');
199
+ });
178
200
  });
179
201
 
180
202
  describe('toJSON (SimpleJson)', function() {
@@ -185,20 +207,21 @@ describe('DomUtil', function() {
185
207
  return json;
186
208
  }
187
209
 
188
- assert.deepStrictEqual(toJSON('<root/>'), {});
189
- assert.deepStrictEqual(toJSON('<root a="1"/>'), { a:"1" });
190
- assert.deepStrictEqual(toJSON('<root a="1" b="2"/>'), { a:"1", b:"2" });
191
- assert.deepStrictEqual(toJSON('<root><a/></root>'), { a:{} });
192
- assert.deepStrictEqual(toJSON('<root><a/><a/></root>'), { a:[{},{}] });
210
+ it("Should convert XML to SimpleJSON", () => {
211
+ assert.deepStrictEqual(toJSON('<root/>'), {});
212
+ assert.deepStrictEqual(toJSON('<root a="1"/>'), { a:"1" });
213
+ assert.deepStrictEqual(toJSON('<root a="1" b="2"/>'), { a:"1", b:"2" });
214
+ assert.deepStrictEqual(toJSON('<root><a/></root>'), { a:{} });
215
+ assert.deepStrictEqual(toJSON('<root><a/><a/></root>'), { a:[{},{}] });
216
+ });
193
217
  });
194
218
 
195
219
  describe('fromJSON (invalid flavor)', function() {
196
- try {
197
- DomUtil.fromJSON("root", {}, "InvalidFlavor");
198
- assert.fail("Should have failed");
199
- } catch(ex) {
200
- assert.ok(true);
201
- }
220
+ it("Should fail", () => {
221
+ expect(() => {
222
+ DomUtil.fromJSON("root", {}, "InvalidFlavor");
223
+ }).toThrow();
224
+ });
202
225
  });
203
226
 
204
227
  describe('toJson (errors)', function() {
@@ -217,6 +240,233 @@ describe('DomUtil', function() {
217
240
 
218
241
  });
219
242
 
243
+ describe('toJson (SimpleJson, advanced)', function() {
244
+ function toJSON(xml) {
245
+ xml = DomUtil.parse(xml);
246
+ var json = DomUtil.toJSON(xml, "SimpleJson");
247
+ return json;
248
+ }
249
+
250
+ it("Should handle elements containing both text and other elements", () => {
251
+ expect(toJSON('<root>Hello</root>')).toEqual({ $: "Hello" });
252
+ expect(toJSON('<ctx><delivery>Hello</delivery></ctx>')).toEqual({ "$delivery": "Hello" });
253
+ expect(toJSON('<delivery transaction="0">0</delivery>')).toEqual({ "transaction": "0", "$": "0" });
254
+ expect(toJSON('<ctx><delivery transaction="0">0</delivery></ctx>')).toEqual({delivery: { "transaction": "0", "$": "0" }});
255
+ expect(toJSON('<ctx><delivery>Hello<child name="world"/></delivery></ctx>')).toEqual({delivery: { "$": "Hello", child: { name: "world" } }});
256
+ expect(toJSON('<ctx><delivery><child name="world"/>Hello</delivery></ctx>')).toEqual({delivery: { "$": "Hello", child: { name: "world" } }});
257
+ expect(toJSON('<root><delivery>Hello<child/>World</delivery></root>')).toEqual({ delivery: { $: "HelloWorld", child:{} } });
258
+ });
259
+
260
+ describe("Should handle insignificant whitespaces", () => {
261
+ it("Should not remove whitespace for element which does not have any children", () => {
262
+ expect(toJSON('<root><delivery> \nHello </delivery></root>')).toEqual({ $delivery: " \nHello " });
263
+ });
264
+ it("Should remove whitespace for root element even if it does not have any children. Because in SimpleJson we consider that root always has children", () => {
265
+ expect(toJSON('<root>\n</root>')).toEqual({ });
266
+ expect(toJSON('<root> \nHello </root>')).toEqual({ $: "Hello" });
267
+ expect(toJSON('<root> \nHello <delivery/></root>')).toEqual({ $: "Hello", delivery: {} });
268
+ expect(toJSON('<root> \nHello<delivery/> </root>')).toEqual({ $: "Hello", delivery: {} });
269
+ });
270
+ it("Should never remove whitespace in the middle of text", () => {
271
+ expect(toJSON('<root>Hello World</root>')).toEqual({ $: "Hello World" });
272
+ expect(toJSON('<root><delivery>Hello World</delivery></root>')).toEqual({ $delivery: "Hello World" });
273
+ expect(toJSON('<root><delivery> Hello World </delivery></root>')).toEqual({ $delivery: " Hello World " });
274
+ expect(toJSON('<root><delivery> Hello <child/>World </delivery></root>')).toEqual({ delivery: { $: "HelloWorld", child:{} } });
275
+ expect(toJSON('<root><delivery> Hello Cruel W<child/>orld </delivery></root>')).toEqual({ delivery: { $: "Hello Cruel World", child:{} } });
276
+ });
277
+
278
+ it("Should remove insignificant spaces", () => {
279
+ expect(toJSON('<ctx>\n <delivery>\n <target x="2"/>\n </delivery>\n</ctx>')).toEqual({delivery: { target: { x:"2"} }});
280
+ });
281
+
282
+ it("Should handle collections", () => {
283
+ expect(toJSON('<test-collection>\n <test a="1"></test>\n</test-collection>')).toEqual({test: [ { a:"1" }] });
284
+ expect(toJSON('<test-collection>\n <test a="1"></test>\n <test a="2"></test>\n</test-collection>')).toEqual({test: [ { a:"1" }, { a:"2" }] });
285
+ });
286
+
287
+ it("Should handle collections of text elements", () => {
288
+ expect(toJSON('<test-collection>\n <test>One</test>\n</test-collection>')).toEqual({test: [ { $:"One" }] });
289
+ expect(toJSON('<test-collection>\n <test>One</test>\n <test>Two</test>\n</test-collection>')).toEqual({test: [ { $:"One" }, { $:"Two" }] });
290
+ expect(toJSON('<array>\n <test>One</test>\n <test>Two</test>\n</array>')).toEqual({test: [ { $:"One" }, { $:"Two" }] });
291
+ });
292
+
293
+ it("Should never remove whitespaces of CDATA nodes", () => {
294
+ expect(toJSON('<root><![CDATA[]]></root>')).toEqual({});
295
+ expect(toJSON('<root><![CDATA[ Hello\tWorld\n ]]></root>')).toEqual({ $: " Hello\tWorld\n "});
296
+ expect(toJSON('<root><![CDATA[ Hello\t]]><![CDATA[World\n ]]></root>')).toEqual({ $: " Hello\tWorld\n "});
297
+ });
298
+
299
+ it("Should not handle whitespaces if element containing text has only attributes", () => {
300
+ // Whitespaces are always removed for the root node
301
+ expect(toJSON('<delivery transaction="0"> Hello World </delivery>')).toEqual({ "transaction": "0", "$": "Hello World" });
302
+ // But not for child nodes
303
+ expect(toJSON('<root><delivery transaction="0"> Hello World </delivery></root>')).toEqual({ delivery: { "transaction": "0", "$": " Hello World " } });
304
+ });
305
+ });
306
+
307
+ describe("Real payloads", () => {
308
+ it("Should convert report data payload", () => {
309
+ const xml = `<ctx lang="en" date="2022-11-18T08:04:06Z" _target="web" webApp-id="1583" _context="selection" _reportContext="deliverySending" _schema="nms:delivery" _hasFilter="false" _selection="12133" _folderModel="nmsDelivery" _folderLinkId="@folder-id" _folderLink="folder" activityHist="@r2rp0BOIZulQ3PcAaXVCr+9of9KxMPqM4MWmTTydhh4/qMVzTGmcRevNzHnoPS0WHvHKH084KIWom6NaVlzR1vCXv47bq3m/dfT3j7MQDSyDwb0rPU/4rD08CeDN3xqR6GazBmh+Lmz+ugo85WCwAaCDUYEJtG/EcqCOO0G+PRtjHlrNOhSrDSxanl4pxonQ4DhDTejA5VjSopu7pvV8U32e5k+fFuk/vvaOMHUP2Zk+VNuMnEytIExnbstFDepeSRDEMuIgmHWuENglhtcdfH3suIcibmqFyBF6Xupcqp2LlicJFFkXHXuM2LgUC7BTGsqMsN4HhNSs6NzW8ZhMPA==">
310
+ <userInfo datakitInDatabase="true" homeDir="" instanceLocale="en-US" locale="en-US" login="internal" loginCS="Internal account" loginId="0" noConsoleCnx="false" orgUnitId="0" theme="" timezone="Europe/Paris" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:xtk:session" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
311
+ <timezone current="Europe/Paris" changed="false"/>
312
+ <_contextFilter>
313
+ <where>
314
+ <condition enabledIf="$(@_context) = 'selection' and $(@_hasFilter) = false" expr="@id = $noescaping(@_selection)"/>
315
+ <condition enabledIf="$(@_context) = 'selection' and $(@_hasFilter) and $(@_locationName) != 'descriptiveAnalysis'" expr="@id" setOperator="IN" subQuery="$(whereCond)"/>
316
+ </where>
317
+ </_contextFilter>
318
+ <activityHistory>
319
+ <activity name="page" type="page"/>
320
+ <activity name="query2" type="query"/>
321
+ <activity name="script2" type="script"/>
322
+ <activity name="query" type="query"/>
323
+ <activity name="start" type="start"/>
324
+ </activityHistory>
325
+ <data>
326
+ <query>
327
+ <delivery amount="0" article="0" contactDate="" error="0" estimatedRecipientOpen="0" estimatedTotalRecipientOpen="0" forward="0" label="" mirrorPage="0" newQuarantine="0" optOut="0" personClick="0" recipientClick="0" reject="0" success="0" toDeliver="0" totalRecipientClick="0" totalTarget="0" totalWebPage="0" transaction="0">0</delivery>
328
+ </query>
329
+ </data>
330
+ <vars>
331
+ <operator>0</operator>
332
+ </vars>
333
+ <title>Delivery:</title>
334
+ <query2/>
335
+ <chart_page_123722795831>
336
+ <data>&lt;data/&gt;</data>
337
+ <config>&lt;graphConfig accumulate="false" autoScale="true" autoStretch="true" computePercent="false" displayEmptySamples="false" filledOpacity="50" innerPieRadius="0" perspective="true" renderType="pie" reverseSeries="false" reverseStacking="false" showLabels="0" sortMode="2" zoomOnWheel="true"&gt;&lt;onclick action="url" enabledWhenHistory="false" target="_blank"/&gt;&lt;legend layout="right" visible="true"/&gt;&lt;series aggregate="sum" label="" renderGroup="layered" xpath="/dlvExclusion" xpathIndex="@label" xpathValue="@count"/&gt;&lt;/graphConfig&gt;</config>
338
+ </chart_page_123722795831>
339
+ </ctx>`;
340
+ expect(toJSON(xml)).toEqual(
341
+ {
342
+ userInfo: {
343
+ datakitInDatabase: "true",
344
+ homeDir: "",
345
+ instanceLocale: "en-US",
346
+ locale: "en-US",
347
+ login: "internal",
348
+ loginCS: "Internal account",
349
+ loginId: "0",
350
+ noConsoleCnx: "false",
351
+ orgUnitId: "0",
352
+ theme: "",
353
+ timezone: "Europe/Paris",
354
+ "xmlns:SOAP-ENV": "http://schemas.xmlsoap.org/soap/envelope/",
355
+ "xmlns:ns": "urn:xtk:session",
356
+ "xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
357
+ "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
358
+ },
359
+ timezone: {
360
+ current: "Europe/Paris",
361
+ changed: "false",
362
+ },
363
+ _contextFilter: {
364
+ where: {
365
+ condition: [
366
+ {
367
+ enabledIf: "$(@_context) = 'selection' and $(@_hasFilter) = false",
368
+ expr: "@id = $noescaping(@_selection)",
369
+ },
370
+ {
371
+ enabledIf: "$(@_context) = 'selection' and $(@_hasFilter) and $(@_locationName) != 'descriptiveAnalysis'",
372
+ expr: "@id",
373
+ setOperator: "IN",
374
+ subQuery: "$(whereCond)",
375
+ },
376
+ ],
377
+ },
378
+ },
379
+ activityHistory: {
380
+ activity: [
381
+ {
382
+ name: "page",
383
+ type: "page",
384
+ },
385
+ {
386
+ name: "query2",
387
+ type: "query",
388
+ },
389
+ {
390
+ name: "script2",
391
+ type: "script",
392
+ },
393
+ {
394
+ name: "query",
395
+ type: "query",
396
+ },
397
+ {
398
+ name: "start",
399
+ type: "start",
400
+ },
401
+ ],
402
+ },
403
+ data: {
404
+ query: {
405
+ delivery: {
406
+ $: "0",
407
+ amount: "0",
408
+ article: "0",
409
+ contactDate: "",
410
+ error: "0",
411
+ estimatedRecipientOpen: "0",
412
+ estimatedTotalRecipientOpen: "0",
413
+ forward: "0",
414
+ label: "",
415
+ mirrorPage: "0",
416
+ newQuarantine: "0",
417
+ optOut: "0",
418
+ personClick: "0",
419
+ recipientClick: "0",
420
+ reject: "0",
421
+ success: "0",
422
+ toDeliver: "0",
423
+ totalRecipientClick: "0",
424
+ totalTarget: "0",
425
+ totalWebPage: "0",
426
+ transaction: "0",
427
+ },
428
+ },
429
+ },
430
+ vars: {
431
+ $operator: "0",
432
+ },
433
+ $title: "Delivery:",
434
+ query2: {
435
+ },
436
+ chart_page_123722795831: {
437
+ $data: "<data/>",
438
+ $config: "<graphConfig accumulate=\"false\" autoScale=\"true\" autoStretch=\"true\" computePercent=\"false\" displayEmptySamples=\"false\" filledOpacity=\"50\" innerPieRadius=\"0\" perspective=\"true\" renderType=\"pie\" reverseSeries=\"false\" reverseStacking=\"false\" showLabels=\"0\" sortMode=\"2\" zoomOnWheel=\"true\"><onclick action=\"url\" enabledWhenHistory=\"false\" target=\"_blank\"/><legend layout=\"right\" visible=\"true\"/><series aggregate=\"sum\" label=\"\" renderGroup=\"layered\" xpath=\"/dlvExclusion\" xpathIndex=\"@label\" xpathValue=\"@count\"/></graphConfig>",
439
+ },
440
+ lang: "en",
441
+ date: "2022-11-18T08:04:06Z",
442
+ _target: "web",
443
+ "webApp-id": "1583",
444
+ _context: "selection",
445
+ _reportContext: "deliverySending",
446
+ _schema: "nms:delivery",
447
+ _hasFilter: "false",
448
+ _selection: "12133",
449
+ _folderModel: "nmsDelivery",
450
+ _folderLinkId: "@folder-id",
451
+ _folderLink: "folder",
452
+ activityHist: "@r2rp0BOIZulQ3PcAaXVCr+9of9KxMPqM4MWmTTydhh4/qMVzTGmcRevNzHnoPS0WHvHKH084KIWom6NaVlzR1vCXv47bq3m/dfT3j7MQDSyDwb0rPU/4rD08CeDN3xqR6GazBmh+Lmz+ugo85WCwAaCDUYEJtG/EcqCOO0G+PRtjHlrNOhSrDSxanl4pxonQ4DhDTejA5VjSopu7pvV8U32e5k+fFuk/vvaOMHUP2Zk+VNuMnEytIExnbstFDepeSRDEMuIgmHWuENglhtcdfH3suIcibmqFyBF6Xupcqp2LlicJFFkXHXuM2LgUC7BTGsqMsN4HhNSs6NzW8ZhMPA==",
453
+ }
454
+ );
455
+ });
456
+ });
457
+
458
+ it("Should support attribute and element with same name", () => {
459
+ expect(toJSON('<ctx lang="en" timezone="Europe/Paris"><timezone current="Europe/Paris" changed="false"/></ctx>')).toEqual({
460
+ lang: "en",
461
+ "@timezone": "Europe/Paris",
462
+ "timezone": {
463
+ current: "Europe/Paris",
464
+ changed: "false",
465
+ }
466
+ });
467
+ });
468
+
469
+ });
220
470
 
221
471
  describe('toXMLString', function() {
222
472
 
@@ -46,9 +46,9 @@ describe('escaping', function() {
46
46
  });
47
47
  })
48
48
 
49
- describe('Tagged template litteral', function() {
49
+ describe('Tagged template literal', function() {
50
50
 
51
- it("Should escape in template litteral", () => {
51
+ it("Should escape in template literal", () => {
52
52
  expect(sdk.escapeXtk`Hello world`).toBe("Hello world");
53
53
  expect(sdk.escapeXtk`Hello 'world'`).toBe("Hello 'world'"); // only variables are escaped
54
54
 
@@ -77,7 +77,7 @@ describe('escaping', function() {
77
77
  expect(sdk.escapeXtk`@name=${"Rock 'n' Roll"}`).toBe("@name='Rock \\'n\\' Roll'");
78
78
  });
79
79
 
80
- describe('QueryDef & template litteral', () => {
80
+ describe('QueryDef & template literal', () => {
81
81
 
82
82
  })
83
83
 
package/test/mock.js CHANGED
@@ -285,7 +285,114 @@ const GET_XTK_SESSION_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
285
285
  </pdomDoc>
286
286
  </GetEntityIfMoreRecentResponse>
287
287
  </SOAP-ENV:Body>
288
- </SOAP-ENV:Envelope>`)
288
+ </SOAP-ENV:Envelope>`);
289
+
290
+ const GET_XTK_JOB_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
291
+ <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/'>
292
+ <SOAP-ENV:Body>
293
+ <GetEntityIfMoreRecentResponse xmlns='urn:wpp:default' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
294
+ <pdomDoc xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
295
+ <schema implements="xtk:jobInterface" name="job" namespace="xtk" xtkschema="xtk:schema">
296
+ <interface async="true" label="Job interface" name="jobInterface">
297
+ <method const="true" name="Execute">
298
+ <parameters>
299
+ <param inout="in" name="methodName" type="string"/>
300
+ <param inout="out" name="id" type="string"/>
301
+ </parameters>
302
+ </method>
303
+ <method const="true" name="Submit">
304
+ <parameters>
305
+ <param inout="in" name="methodName" type="string"/>
306
+ <param inout="out" name="id" type="string"/>
307
+ </parameters>
308
+ </method>
309
+ <method const="true" name="SubmitSoapCall">
310
+ <parameters>
311
+ <param inout="in" name="soapCall" type="DOMElement"/>
312
+ <param inout="out" name="id" type="string"/>
313
+ </parameters>
314
+ </method>
315
+ <method name="SubmitFromModel" static="true">
316
+ <parameters>
317
+ <param inout="in" name="schema" type="string"/>
318
+ <param inout="in" name="where" type="string"/>
319
+ <param inout="in" name="methodName" type="string"/>
320
+ <param inout="in" name="diff" type="DOMElement"/>
321
+ <param inout="in" name="async" type="boolean"/>
322
+ <param inout="out" name="jobId" type="long"/>
323
+ </parameters>
324
+ </method>
325
+ <method name="Cancel" static="true">
326
+ <parameters>
327
+ <param inout="in" name="id" type="string"/>
328
+ </parameters>
329
+ </method>
330
+ <method name="WaitJobCancelled" static="true">
331
+ <parameters>
332
+ <param inout="in" name="id" type="string"/>
333
+ <param desc="Maximum wait (in seconds)" inout="in" name="timeout" type="long"/>
334
+ </parameters>
335
+ </method>
336
+ <method name="Pause" static="true">
337
+ <parameters>
338
+ <param inout="in" name="id" type="string"/>
339
+ </parameters>
340
+ </method>
341
+ <method name="CheckIfJobInProcess" static="true">
342
+ <parameters>
343
+ <param inout="in" name="pid" type="long"/>
344
+ <param name="hostName" type="string"/>
345
+ <param inout="out" name="result" type="boolean"/>
346
+ </parameters>
347
+ </method>
348
+ <method name="GetJobsInProcess" static="true">
349
+ <parameters>
350
+ <param desc="Returned document" inout="out" name="jobInfo" type="DOMDocument"/>
351
+ </parameters>
352
+ </method>
353
+ <method name="GetStatus" static="true">
354
+ <parameters>
355
+ <param inout="in" name="id" type="string"/>
356
+ <param inout="in" name="lastLogId" type="long"/>
357
+ <param inout="in" name="maxLogCount" type="long"/>
358
+ <param enum="xtk:jobLog:logType" inout="out" name="status" type="short"/>
359
+ <param inout="out" name="returnLogs" type="DOMElement"/>
360
+ <param inout="out" name="properties" type="DOMElement"/>
361
+ </parameters>
362
+ </method>
363
+ <method name="GetResult" static="true">
364
+ <parameters>
365
+ <param inout="in" name="id" type="string"/>
366
+ <param inout="out" name="response" type="string"/>
367
+ </parameters>
368
+ </method>
369
+ <method name="HasWarning" static="true">
370
+ <parameters>
371
+ <param inout="in" name="id" type="string"/>
372
+ <param inout="out" name="hasWarning" type="boolean"/>
373
+ </parameters>
374
+ </method>
375
+ <method name="FilesExist" static="true">
376
+ <parameters>
377
+ <param inout="in" name="files" type="DOMDocument"/>
378
+ <param inout="out" name="exist" type="DOMDocument"/>
379
+ </parameters>
380
+ </method>
381
+ <method name="GetServerDiskSpace" static="true">
382
+ <parameters>
383
+ <param inout="out" name="serverDiskSpace" type="int64"/>
384
+ </parameters>
385
+ </method>
386
+ </interface>
387
+
388
+ <element autopk="true" name="job">
389
+ <attribute name="id" sqlname="iJobId" type="long"/>
390
+ </element>
391
+ </schema>
392
+ </pdomDoc>
393
+ </GetEntityIfMoreRecentResponse>
394
+ </SOAP-ENV:Body>
395
+ </SOAP-ENV:Envelope>`);
289
396
 
290
397
  const GET_DATABASEID_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
291
398
  <SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
@@ -873,6 +980,7 @@ exports.Mock = {
873
980
  LOGON_RESPONSE_NO_SECURITYTOKEN: LOGON_RESPONSE_NO_SECURITYTOKEN,
874
981
  LOGOFF_RESPONSE: LOGOFF_RESPONSE,
875
982
  GET_XTK_SESSION_SCHEMA_RESPONSE: GET_XTK_SESSION_SCHEMA_RESPONSE,
983
+ GET_XTK_JOB_SCHEMA_RESPONSE: GET_XTK_JOB_SCHEMA_RESPONSE,
876
984
  GET_DATABASEID_RESPONSE: GET_DATABASEID_RESPONSE,
877
985
  GET_OPTION_NOTFOUND_RESPONSE: GET_OPTION_NOTFOUND_RESPONSE,
878
986
  GET_OPTION_MISSING_DATA_RESPONSE: GET_OPTION_MISSING_DATA_RESPONSE,
package/test/util.test.js CHANGED
@@ -17,8 +17,8 @@ governing permissions and limitations under the License.
17
17
  *
18
18
  *********************************************************************************/
19
19
 
20
- const { Util, ArrayMap } = require('../src/util.js');
21
- const { SafeStorage, Cache } = require('../src/cache.js');
20
+ const { Util, ArrayMap } = require('../src/util.js');
21
+ const { SafeStorage, Cache } = require('../src/cache.js');
22
22
 
23
23
 
24
24
  describe('Util', function() {
@@ -37,6 +37,15 @@ describe('Util', function() {
37
37
  expect(Util.isArray([ 1 ])).toBe(true);
38
38
  });
39
39
 
40
+ describe("util.schemaIdFromNamespace", () => {
41
+ it("Should should extract schema id for simple namespaces", () => {
42
+ expect(Util.schemaIdFromNamespace("")).toBe("");
43
+ expect(Util.schemaIdFromNamespace("nmsRecipient")).toBe("nms:recipient");
44
+ expect(Util.schemaIdFromNamespace("000Recipient")).toBe("000:recipient");
45
+ expect(Util.schemaIdFromNamespace("Recipient")).toBe(":recipient");
46
+ });
47
+ });
48
+
40
49
  describe("Util.trim", () => {
41
50
  it("Should remove trailing spaces", () => {
42
51
  expect(Util.trim("Hello \n \r \t ")).toBe("Hello");
@@ -102,7 +111,6 @@ describe('Util', function() {
102
111
  })
103
112
  })
104
113
 
105
-
106
114
  describe("Safe storage", () => {
107
115
  it("Should support undefined delegate", () => {
108
116
  const storage = new SafeStorage();