@adobe/acc-js-sdk 1.1.11 → 1.1.13

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/compile.js CHANGED
@@ -41,6 +41,7 @@ var resources = [
41
41
  { name: "./crypto.js" },
42
42
  { name: "./application.js" },
43
43
  { name: "./testUtil.js" },
44
+ { file: "../node_modules/qs-stringify/index.js", name: "qs-stringify" },
44
45
  { name: "./client.js" },
45
46
  { name: "./index.js" },
46
47
  ];
@@ -62,6 +62,8 @@
62
62
  link: midSourcing.html
63
63
  - name: Message Center
64
64
  link: messageCenter.html
65
+ - name: Reports Data API
66
+ link: reportData.html
65
67
  - name: --
66
68
  - name: Advanced Topics
67
69
  children:
@@ -38,6 +38,7 @@ title: The Application Object
38
38
  <tr><td><b>login</b></td><td>the login name of the operator</td></tr>
39
39
  <tr><td><b>computeString</b></td><td>A human readable name for the operator</td></tr>
40
40
  <tr><td><b>timezone</b></td><td>The timezone of the operator</td></tr>
41
+ <tr><td><b>instanceLocale</b></td><td>The locale of the instance</td></tr>
41
42
  <tr><td><b>rights</b></td><td>An array of strings describing the rights of the operators</td></tr>
42
43
  </tbody>
43
44
  </table>
@@ -263,7 +264,7 @@ const root = await node.linkTarget();
263
264
  <tr><td><b>isNotNull</b></td><td>Returns a boolean which indicates whether or not the current node can take the null value into account.</td></tr>
264
265
  <tr><td><b>isRequired</b></td><td>Returns a boolean which indicates whether or not the value of the current node is mandatory.</td></tr>
265
266
  <tr><td><b>isRoot</b></td><td>Indicates if the node is the root node of a schema, i.e. the first child of the schema node, whose name matches the schema name</td></tr>
266
- <tr><td><b>isSQL</b></td><td>Returns a boolean which indicates whether the current node is mapped in SQL.</td></tr>
267
+ <tr><td><b>isSQL</b></td><td>Returns a boolean which indicates whether the current node is mapped in SQL. There are some inconsistencies in ACC schemas, and sometimes attributes may be defined as both sql and xml (for example: nms:delivery/properties/seedProcessed). Such nodes with have both isSql=true and isMappedAsXml=true</td></tr>
267
268
  <tr><td><b>isTemporaryTable</b></td><td>Returns a boolean indicating whether the table is a temporary table. The table will not be created during database creation.</td></tr>
268
269
  <tr><td><b>unbound</b></td><td>Returns a boolean which indicates whether the current node has an unlimited number of children of the same type.</td></tr>
269
270
  <tr><td><b>joins</b></td><td>Element of type "link" has an array of XtkJoin. See <b>joinNodes</b> method.</td></tr>
@@ -2,6 +2,21 @@
2
2
  layout: page
3
3
  title: Change Log
4
4
  ---
5
+ <section class="changelog"><h1>Version 1.1.13</h1>
6
+ <h2>2022/11/24</h2>
7
+
8
+ <li>Fix a bug with file upload API: API call payload was not passed with the right property. The transport interface uses the "data" property and not the "body" property</li>
9
+ <li>Add "getReportData" API to fetch the data use to create a particular report</li>
10
+ <li>Add unit test to check that schema nodes mapped as both xml and sql are properly handled (as SQL)</li>
11
+ </section>
12
+
13
+ <section class="changelog"><h1>Version 1.1.12</h1>
14
+ <h2>2022/11/16</h2>
15
+
16
+ <li>Fix an issue with localization ids: do not generate localization ids for empty labels or descriptions</li>
17
+ <li>Add the instanceLocale attribute in the CurrentLogin object. This attribute returns the instance locale</li>
18
+ </section>
19
+
5
20
  <section class="changelog"><h1>Version 1.1.11</h1>
6
21
  <h2>2022/11/09</h2>
7
22
 
@@ -0,0 +1,92 @@
1
+ ---
2
+ layout: page
3
+ title: Reports Data API
4
+ ---
5
+
6
+ <p>Campaign provides an API to fetch reports data. Just like all APIs in the SDK, it's been wrapped into a function and will return a XML or JSON object based on the requested representation</p>
7
+
8
+ <p>Function Definition</p>
9
+ <pre class="code">
10
+ client.getReportData = (callContext: any, representation: string) : Promise<any>
11
+ </pre>
12
+ <p>callContext</p>
13
+ <pre class="code">
14
+ {
15
+ reportName: string(Report Name),
16
+ context: string("selection"|"global"),
17
+ schema: string(entity type to be used for selection),
18
+ selection: string(Comma separated list of entity IDs),
19
+ formData: any
20
+ }
21
+ </pre>
22
+
23
+ <p>Usage</p>
24
+ <pre class="code">
25
+ const report = await client.getReportData({
26
+ reportName: "throughput",
27
+ context: "selection",
28
+ schema: "nms:delivery",
29
+ selection: "12133"
30
+ });
31
+ console.log(JSON.stringify(report));
32
+ </pre>
33
+ <p>Usage with multiple entities</p>
34
+ <pre class="code">
35
+ const report = await client.getReportData({
36
+ reportName: "throughput",
37
+ context: "selection",
38
+ schema: "nms:delivery",
39
+ selection: "12133,12134"
40
+ });
41
+ console.log(JSON.stringify(report));
42
+ </pre>
43
+ <p>Usage with form data</p>
44
+ <pre class="code">
45
+ const report = await client.getReportData({
46
+ reportName: "throughput",
47
+ context: "selection",
48
+ schema: "nms:delivery",
49
+ selection: "12133",
50
+ formData: {
51
+ vars_opens: 1,
52
+ userAction: "next",
53
+ ctx: {
54
+ _context: 'selection',
55
+ _reportContext: 'throughput',
56
+ _hasFilter: 'false',
57
+ _selectionCount: '1',
58
+ _selection: '12133',
59
+ vars: {
60
+ '$period': '21600',
61
+ '$trunc': '600',
62
+ '$valueScaleFactor': '6',
63
+ '$dateStepType': 'minute',
64
+ '$dateStepFactor': '10'
65
+ },
66
+ data: {
67
+ deliveryStat: { deliveryStat: [Array] },
68
+ bandwidth: { deliveryStat: [Object] }
69
+ }
70
+ }
71
+ }
72
+ });
73
+ console.log(JSON.stringify(report));
74
+ </pre>
75
+
76
+ <p>A given representation can be forced</p>
77
+ <pre class="code">
78
+ const xmlReport = await client.getReportData({
79
+ reportName: "throughput",
80
+ context: "selection",
81
+ schema: "nms:delivery",
82
+ selection: "12133"
83
+ }, "xml");
84
+ const jsonReport = await client.getReportData({
85
+ reportName: "throughput",
86
+ context: "selection",
87
+ schema: "nms:delivery",
88
+ selection: "12133"
89
+ }, "SimpleJson");
90
+ </pre>
91
+
92
+
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -3362,6 +3362,11 @@
3362
3362
  "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
3363
3363
  "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
3364
3364
  },
3365
+ "qs-stringify": {
3366
+ "version": "1.2.1",
3367
+ "resolved": "https://registry.npmjs.org/qs-stringify/-/qs-stringify-1.2.1.tgz",
3368
+ "integrity": "sha512-2N5xGLGZUxpgAYq1fD1LmBSCbxQVsXYt5JU0nU3FuPWO8PlCnKNFQwXkZgyB6mrTdg7IbexX4wxIR403dJw9pw=="
3369
+ },
3365
3370
  "react-is": {
3366
3371
  "version": "17.0.2",
3367
3372
  "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
@@ -11,7 +11,8 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "axios": "^0.25.0",
14
- "jsdom": "^19.0.0"
14
+ "jsdom": "^19.0.0",
15
+ "qs-stringify": "^1.2.1"
15
16
  },
16
17
  "devDependencies": {
17
18
  "docdash": "^1.2.0",
@@ -669,10 +669,14 @@ class XtkSchemaNode {
669
669
  this._localizationId = this._localizationId + "__e____" + this.name;
670
670
  }
671
671
  }
672
- this.labelLocalizationId = this._localizationId + "__@label";
673
- this.descriptionLocalizationId = this._localizationId + "__@desc";
674
- if (!this.parent) {
675
- this.labelSingularLocalizationId = this._localizationId + "__@labelSingular";
672
+ if (this.label) {
673
+ this.labelLocalizationId = this._localizationId + "__@label";
674
+ }
675
+ if (this.description) {
676
+ this.descriptionLocalizationId = this._localizationId + "__@desc";
677
+ }
678
+ if (!this.parent && this.labelSingular) {
679
+ this.labelSingularLocalizationId = this._localizationId + "__@labelSingular";
676
680
  }
677
681
  }
678
682
 
@@ -1219,7 +1223,13 @@ class CurrentLogin {
1219
1223
  * @type {string}
1220
1224
  */
1221
1225
  this.timezone = EntityAccessor.getAttributeAsString(userInfo, "timezone");
1222
-
1226
+
1227
+ /**
1228
+ * The instance locale
1229
+ * @type { string }
1230
+ */
1231
+ this.instanceLocale = EntityAccessor.getAttributeAsString(userInfo, "instanceLocale");
1232
+
1223
1233
  /**
1224
1234
  * The llist of operator rights
1225
1235
  * @type {string[]}
package/src/campaign.js CHANGED
@@ -39,6 +39,8 @@ const { Util } = require("./util.js");
39
39
  static DECRYPT_ERROR(details) { return new CampaignException(undefined, 400, 16384, `SDK-000011 "Cannot decrypt password: password marker is missing`, details); }
40
40
  static SESSION_EXPIRED() { return new CampaignException(undefined, 401, 16384, `SDK-000012 "Session has expired or is invalid. Please reconnect.`); }
41
41
  static FILE_UPLOAD_FAILED(name, details) { return new CampaignException(undefined, 500, 16384, `SDK-000013 "Failed to upload file ${name}`, details); }
42
+ static REPORT_FETCH_FAILED(name, details) { return new CampaignException(undefined, 500, 16384, `SDK-000014 Failed to fetch report ${name}`, details); }
43
+ static FEATURE_NOT_SUPPORTED(name) { return new CampaignException(undefined, 500, 16384, `SDK-000015 ${name} feature is not supported by the ACC instance`); }
42
44
 
43
45
 
44
46
  /**
package/src/client.js CHANGED
@@ -36,6 +36,7 @@ const request = require('./transport.js').request;
36
36
  const Application = require('./application.js').Application;
37
37
  const EntityAccessor = require('./entityAccessor.js').EntityAccessor;
38
38
  const { Util } = require('./util.js');
39
+ const qsStringify = require('qs-stringify');
39
40
 
40
41
  /**
41
42
  * @namespace Campaign
@@ -54,6 +55,9 @@ const { Util } = require('./util.js');
54
55
  *
55
56
  * @typedef {Object} Observer
56
57
  * @memberOf Campaign
58
+ *
59
+ * @typedef {Object} ReportContext
60
+ * @memberOf Campaign
57
61
  */
58
62
 
59
63
 
@@ -548,7 +552,7 @@ const fileUploader = (client) => {
548
552
  processData: false,
549
553
  credentials: 'include',
550
554
  method: 'POST',
551
- body: data,
555
+ data: data,
552
556
  headers: {
553
557
  'x-security-token': client._securityToken,
554
558
  'Cookie': '__sessiontoken=' + client._sessionToken,
@@ -1764,6 +1768,46 @@ class Client {
1764
1768
  return result;
1765
1769
  }
1766
1770
 
1771
+ /**
1772
+ * This is the exposed/public method to request context data for a specific report.
1773
+ * @param {*} callContext: {reportName: string, schema: string, context: string, selection: string, formData: any}
1774
+ * @param {string} representation the expected representation ('xml', 'BadgerFish', or 'SimpleJson'). If not set, will use the current representation
1775
+ *
1776
+ * @returns {Campaign.ReportContext} an object containing the context data for a specific report
1777
+ */
1778
+ async getReportData(callContext, representation) {
1779
+ try {
1780
+ if(callContext.formData && callContext.formData.ctx) {
1781
+ var xmlCtx = this._fromRepresentation('ctx', callContext.formData.ctx);
1782
+ callContext.formData.ctx = DomUtil.toXMLString(xmlCtx);
1783
+ }
1784
+ const selectionCount = callContext.selection.split(',').length;
1785
+
1786
+ const request = {
1787
+ url: `${this._connectionParameters._endpoint}/report/${callContext.reportName}?${encodeURI(`_noRender=true&_schema=${callContext.schema}&_context=${callContext.context}&_selection=${callContext.selection}`)}&_selectionCount=${selectionCount}`,
1788
+ headers: {
1789
+ 'X-Security-Token': this._securityToken,
1790
+ 'Cookie': '__sessiontoken=' + this._sessionToken,
1791
+ 'Content-Type': 'application/x-www-form-urlencoded'
1792
+ },
1793
+ method: 'POST',
1794
+ credentials: 'include',
1795
+ data : qsStringify(callContext.formData)
1796
+ };
1797
+
1798
+ for (let h in this._connectionParameters._options.extraHttpHeaders)
1799
+ request.headers[h] = this._connectionParameters._options.extraHttpHeaders[h];
1800
+ const body = await this._makeHttpCall(request);
1801
+ if(!body.startsWith("<ctx"))
1802
+ throw CampaignException.FEATURE_NOT_SUPPORTED("Reports Data");
1803
+ const xml = DomUtil.parse(body);
1804
+ const result = this._toRepresentation(xml, representation);
1805
+ return result;
1806
+ } catch(ex) {
1807
+ throw CampaignException.REPORT_FETCH_FAILED(callContext.reportName, ex);
1808
+ }
1809
+ }
1810
+
1767
1811
  /**
1768
1812
  * Ping a Message Center Campaign server (/nl/jsp/mcPing.jsp).
1769
1813
  * Assumes Message Center is installed
@@ -1973,6 +1973,28 @@ describe('Application', () => {
1973
1973
  expect(node.isSQL).toBe(false);
1974
1974
  });
1975
1975
 
1976
+ it("Should have isSQL even if it also has isXML", async () => {
1977
+ const xml = DomUtil.parse(`<schema namespace='nms' name='delivery' mappingType="sql">
1978
+ <element name='delivery' sqltable="NmsDelivery">
1979
+ <element name='properties'>
1980
+ <attribute name="midAccountUsedName" type="string" xml="true"/>
1981
+ <attribute name="seedProcessed" sqlname="iSeedProcessed" type="long" xml="true"/>
1982
+ </element>
1983
+ </element>
1984
+ </schema>`);
1985
+ const schema = newSchema(xml);
1986
+ const properties = await schema.root.findNode("properties");
1987
+ expect(properties.isSQL).toBe(false);
1988
+ // xml only node is not sql
1989
+ const midAccountUsedName = await properties.findNode("@midAccountUsedName");
1990
+ expect(midAccountUsedName.isSQL).toBe(false);
1991
+ expect(midAccountUsedName.isMappedAsXML).toBe(true);
1992
+ // node may be both xml and sql. If that's the case, it's considered sql
1993
+ const seedProcessed = await properties.findNode("@seedProcessed");
1994
+ expect(seedProcessed.isSQL).toBe(true);
1995
+ expect(seedProcessed.isMappedAsXML).toBe(true);
1996
+ });
1997
+
1976
1998
  it("Should be memo and memo data" , async () => {
1977
1999
  const xml = DomUtil.parse(`<schema namespace='nms' name='recipient' label="Recipients" labelSingular="Recipient">
1978
2000
  <element name='recipient' sqltable="NmsRecipient">
@@ -2061,29 +2083,42 @@ describe('Application', () => {
2061
2083
  });
2062
2084
 
2063
2085
  describe("Translation ids", () => {
2064
- it("schema should have a correct label localization id", () => {
2086
+ it("schema should not have label localization id when label does not exist", () => {
2065
2087
  const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2066
2088
  const schema = newSchema(xml);
2089
+ expect(schema.labelLocalizationId).toBeUndefined();
2090
+ expect(schema.descriptionLocalizationId).toBeUndefined();
2091
+ });
2092
+
2093
+ it("schema should have a correct label localization id", () => {
2094
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient' label='Recipients' desc='Recipient table(profiles)'><element name='recipient' label='Recipients'/></schema>");
2095
+ const schema = newSchema(xml);
2067
2096
  expect(schema.labelLocalizationId).toBe('nms__recipient__@label');
2068
2097
  expect(schema.descriptionLocalizationId).toBe('nms__recipient__@desc');
2069
2098
  });
2070
2099
 
2071
2100
  it("schema should have a correct singular label localization id", () => {
2072
- const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2101
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient' labelSingular='Recipient'><element name='recipient' label='Recipients'/></schema>");
2073
2102
  const schema = newSchema(xml);
2074
2103
  expect(schema.labelSingularLocalizationId).toBe('nms__recipient__@labelSingular');
2075
2104
  });
2076
2105
 
2077
- it("root node should have a correct label localization id", () => {
2106
+ it("schema should not have singular label localization id when singular label does not exist", () => {
2078
2107
  const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2079
2108
  const schema = newSchema(xml);
2109
+ expect(schema.labelSingularLocalizationId).toBeUndefined();
2110
+ });
2111
+
2112
+ it("root node should have a correct label localization id", () => {
2113
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients' desc='Recipients'/></schema>");
2114
+ const schema = newSchema(xml);
2080
2115
  const root = schema.root;
2081
2116
  expect(root.labelLocalizationId).toBe('nms__recipient__e____recipient__@label');
2082
2117
  expect(root.descriptionLocalizationId).toBe('nms__recipient__e____recipient__@desc');
2083
2118
  });
2084
2119
 
2085
2120
  it("child node should have a correct label localization id", () => {
2086
- const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='lib' label='library'/><element name='recipient' label='Recipients'/></schema>");
2121
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='lib' label='library' desc='library'/><element name='recipient' label='Recipients'/></schema>");
2087
2122
  const schema = newSchema(xml);
2088
2123
  const lib = schema.children["lib"];
2089
2124
  expect(lib.labelLocalizationId).toBe('nms__recipient__e____lib__@label');
@@ -2093,7 +2128,7 @@ describe('Application', () => {
2093
2128
  it("attribute should have a correct label localization id", () => {
2094
2129
  const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
2095
2130
  <element name='recipient' label='Recipients'>
2096
- <attribute name='email' type='string' label='email' length='3'/>
2131
+ <attribute name='email' type='string' label='email' desc='email' length='3'/>
2097
2132
  </element>
2098
2133
  </schema>`);
2099
2134
  const schema = newSchema(xml);
@@ -2141,13 +2176,15 @@ describe('Application', () => {
2141
2176
  loginCS: "Alex",
2142
2177
  timezone: "Europe/Paris",
2143
2178
  "login-right": [
2144
- ]
2179
+ ],
2180
+ instanceLocale: "en"
2145
2181
  })
2146
2182
  expect(op.login).toBe("alex");
2147
2183
  expect(op.id).toBe(12);
2148
2184
  expect(op.computeString).toBe("Alex");
2149
2185
  expect(op.timezone).toBe("Europe/Paris");
2150
2186
  expect(op.rights).toEqual([]);
2187
+ expect(op.instanceLocale).toBe("en");
2151
2188
  })
2152
2189
 
2153
2190
  it("Should support missing 'login-right' node", () => {
@@ -3224,6 +3224,17 @@ describe('ACC Client', function () {
3224
3224
  type: 'text/html',
3225
3225
  size: 12345
3226
3226
  })
3227
+ expect(client._transport).toHaveBeenNthCalledWith(2,
3228
+ expect.objectContaining({
3229
+ data: expect.anything(),
3230
+ url: expect.any(String),
3231
+ method: 'POST',
3232
+ processData: false,
3233
+ credentials: 'include',
3234
+ headers: expect.anything(),
3235
+ })
3236
+ );
3237
+
3227
3238
  expect(result).toMatchObject({
3228
3239
  md5: "d8e8fca2dc0f896fd7cb4cb0031ba249",
3229
3240
  name: "test.txt",
@@ -3467,4 +3478,66 @@ describe('ACC Client', function () {
3467
3478
  });
3468
3479
  });
3469
3480
 
3481
+ describe("getReport API", () => {
3482
+ it("Should call report API", async () => {
3483
+ const client = await Mock.makeClient();
3484
+ client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
3485
+ await client.NLWS.xtkSession.logon();
3486
+
3487
+ client._transport.mockReturnValueOnce(Mock.REPORT_RESPONSE);
3488
+ const report = await client.getReportData({
3489
+ reportName: "throughput",
3490
+ context: "selection",
3491
+ selection: "12133",
3492
+ schema: "nms:delivery",
3493
+ formData: {ctx: {}}
3494
+ });
3495
+ expect(report._reportContext).toBe("throughput");
3496
+ expect(report._selection).toBe("12133");
3497
+ expect(report.vars.$period).toBe("604800");
3498
+ expect(report.delivery.scheduling.contactDate).toBe("2021-12-07 17:13:39.507Z");
3499
+ expect(report.data.bandwidth.deliveryStat.size).toBe("1.34");
3500
+ expect(report.userInfo).toBeDefined();
3501
+ expect(report.activityHistory).toBeDefined();
3502
+
3503
+ client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
3504
+ await client.NLWS.xtkSession.logoff();
3505
+ });
3506
+
3507
+ it("Should fail to get report data, if API is not supported", async () => {
3508
+ const client = await Mock.makeClient();
3509
+ client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
3510
+ await client.NLWS.xtkSession.logon();
3511
+
3512
+ client._transport.mockReturnValueOnce("Invalid response");
3513
+ await expect(client.getReportData({
3514
+ reportName: "throughput",
3515
+ context: "selection",
3516
+ selection: "12133",
3517
+ schema: "nms:delivery"
3518
+ })).rejects.toMatchObject({ statusCode:500, message:"500 - Error 16384: SDK-000014 Failed to fetch report throughput. 500 - Error 16384: SDK-000015 Reports Data feature is not supported by the ACC instance" });
3519
+
3520
+ client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
3521
+ await client.NLWS.xtkSession.logoff();
3522
+ });
3523
+
3524
+ it("Should fail to call getReport API", async () => {
3525
+ const client = await Mock.makeClient();
3526
+ client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
3527
+ await client.NLWS.xtkSession.logon();
3528
+ client.traceAPICalls(true);
3529
+
3530
+ client._transport.mockRejectedValueOnce(new HttpError(500, "Error rc=-57"));
3531
+ await expect(client.getReportData({
3532
+ reportName: "throughput",
3533
+ context: "selection",
3534
+ selection: "12133",
3535
+ schema: "nms:delivery"
3536
+ })).rejects.toMatchObject({ statusCode:500, message:"500 - Error 16384: SDK-000014 Failed to fetch report throughput. 500 - Error calling method '/report/throughput?_noRender=true&_schema=nms:delivery&_context=selection&_selection=12133&_selectionCount=1': Error rc=-57" });
3537
+
3538
+ client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
3539
+ await client.NLWS.xtkSession.logoff();
3540
+ });
3541
+ });
3542
+
3470
3543
  });
package/test/mock.js CHANGED
@@ -70,6 +70,39 @@ const PING = Promise.resolve("OK\n2021-08-27 15:43:48.862Z\n");
70
70
  const MC_PING = Promise.resolve("Ok\n2021-08-27 15:48:07.893Z\n7/400 pending events");
71
71
  const MC_PING_ERROR = Promise.resolve("Error\nThe queue is full (7/400)");
72
72
 
73
+ const REPORT_RESPONSE = Promise.resolve(`<ctx lang="en" date="2022-11-09T06:10:27Z" _target="web" alt_period="604800" statsCount="1" webApp-id="1569" _context="selection" _reportContext="throughput" _hasFilter="false" _selectionCount="1" _selection="12133" _schema="nms:delivery" _folderModel="nmsDelivery" _folderLinkId="@folder-id" _folderLink="folder" activityHist="xxx">
74
+ <userInfo datakitInDatabase="true" homeDir="" instanceLocale="en-US" locale="en-US" login="admin" loginCS="Administrator (admin)" loginId="1059" noConsoleCnx="false" orgUnitId="0" theme="" timezone="Asia/Kolkata" 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">
75
+ <login-group id="1060"/>
76
+ <login-right right="admin"/>
77
+ </userInfo>
78
+ <vars>
79
+ <period>604800</period>
80
+ <trunc>3600</trunc>
81
+ <valueScaleFactor>1</valueScaleFactor>
82
+ <dateStepType>hour</dateStepType>
83
+ <dateStepFactor>1</dateStepFactor>
84
+ </vars>
85
+ <activityHistory>
86
+ <activity name="page" type="page"/>
87
+ <activity name="script" type="script"/>
88
+ <activity name="query2" type="query"/>
89
+ <activity name="test" type="test"/>
90
+ </activityHistory>
91
+ <delivery label="Email delivery">
92
+ <scheduling contactDate="2021-12-07 17:13:39.507Z"/>
93
+ </delivery>
94
+ <title>Delivery: Email delivery</title>
95
+ <data>
96
+ <deliveryStat>
97
+ <deliveryStat date="2021-12-07 17:30:00.000Z" count="1" series="Success"/>
98
+ <deliveryStat date="2021-12-07 17:30:00.000Z" count="0" series="Errors"/>
99
+ </deliveryStat>
100
+ <bandwidth>
101
+ <deliveryStat date="2021-12-07 17:30:00.000Z" size="1.34"/>
102
+ </bandwidth>
103
+ </data>
104
+ </ctx>`);
105
+
73
106
  const LOGON_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
74
107
  <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/'>
75
108
  <SOAP-ENV:Body>
@@ -828,6 +861,7 @@ exports.Mock = {
828
861
  PING: PING,
829
862
  MC_PING: MC_PING,
830
863
  MC_PING_ERROR: MC_PING_ERROR,
864
+ REPORT_RESPONSE: REPORT_RESPONSE,
831
865
  LOGON_RESPONSE: LOGON_RESPONSE,
832
866
  BEARER_LOGON_RESPONSE: BEARER_LOGON_RESPONSE,
833
867
  LOGON_RESPONSE_NO_SESSIONTOKEN: LOGON_RESPONSE_NO_SESSIONTOKEN,