@adobe/acc-js-sdk 1.1.45 → 1.1.47

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.
@@ -2,6 +2,25 @@
2
2
  layout: page
3
3
  title: Change Log
4
4
  ---
5
+ <section class="changelog"><h1>Version 1.1.47</h1>
6
+ <h2>2024/04/23</h2>
7
+ <li>
8
+ Issue 105 (https://github.com/adobe/acc-js-sdk/issues/105). Fix XML name of parameters in workflow functions. The name is expected to be 'variables' and not 'parameters'.
9
+ Methods StartWithParameters, PostEvent, SimulateWithParameters, SpawnWithParameters, and SpawnWithParametersEx are included.
10
+ </li>
11
+ </section>
12
+
13
+
14
+ <section class="changelog"><h1>Version 1.1.46</h1>
15
+ <h2>2024/03/19</h2>
16
+ <li>
17
+ Method nms:extAccount#TestAccount could not be called because it has parameters which are both input and output (inout="inout") and this was not supported by the SDK
18
+ </li>
19
+ <li>
20
+ Update follow-redirects 3rd party to fix a potential vulnerability
21
+ </li>
22
+ </section>
23
+
5
24
  <section class="changelog"><h1>Version 1.1.45</h1>
6
25
  <h2>2024/01/15</h2>
7
26
  <li>
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.45",
9
+ "version": "1.1.47",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "axios": "^1.2.1",
@@ -2219,9 +2219,9 @@
2219
2219
  "license": "ISC"
2220
2220
  },
2221
2221
  "node_modules/follow-redirects": {
2222
- "version": "1.15.5",
2223
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
2224
- "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
2222
+ "version": "1.15.6",
2223
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
2224
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
2225
2225
  "funding": [
2226
2226
  {
2227
2227
  "type": "individual",
@@ -6186,9 +6186,9 @@
6186
6186
  "dev": true
6187
6187
  },
6188
6188
  "follow-redirects": {
6189
- "version": "1.15.5",
6190
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
6191
- "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw=="
6189
+ "version": "1.15.6",
6190
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
6191
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA=="
6192
6192
  },
6193
6193
  "form-data": {
6194
6194
  "version": "4.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
@@ -0,0 +1,40 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ const utils = require("./utils.js");
13
+
14
+ /* Basic samples illustrating how to manage workflows
15
+ */
16
+
17
+ ( async () => {
18
+
19
+ await utils.sample({
20
+ title: "Activate a workflow via a signal",
21
+ labels: [ "xtk:workflow", "Basics", "Workflow", "Signal" ],
22
+ description: `The PostEvent method activats a signal activity of a workflow`,
23
+ code: async() => {
24
+ return await utils.logon(async (client, NLWS) => {
25
+ console.log("This sample will post an event to a signal activity of a workflow.");
26
+
27
+ const workflowIdOrName = "WKF20";
28
+ const activityName = "signal";
29
+ const transitionName = "";
30
+ const variables = { hello: "world" };
31
+ const complete = false;
32
+ await NLWS.xtkWorkflow.postEvent(workflowIdOrName, activityName, transitionName, variables, complete);
33
+
34
+ });
35
+ }
36
+ });
37
+
38
+
39
+ })();
40
+
package/src/client.js CHANGED
@@ -1197,7 +1197,9 @@ class Client {
1197
1197
  // Hack for workflow API. The C++ code checks that the name of the XML element is <variables>. When
1198
1198
  // using xml representation at the SDK level, it's ok since the SDK caller will set that. But this does
1199
1199
  // not work when using "BadgerFish" representation where we do not know the root element name.
1200
- if (entitySchemaId == "xtk:workflow" && methodName == "StartWithParameters" && paramName == "parameters")
1200
+ if (entitySchemaId == "xtk:workflow" && paramName == "parameters" && (
1201
+ methodName == "StartWithParameters" || methodName == "PostEvent" || methodName == "SimulateWithParameters" ||
1202
+ methodName == "SpawnWithParameters" || methodName == "SpawnWithParametersEx") )
1201
1203
  docName = "variables";
1202
1204
  if (entitySchemaId == "nms:rtEvent" && methodName == "PushEvent")
1203
1205
  docName = "rtEvent";
@@ -2043,7 +2045,9 @@ class Client {
2043
2045
  const inout = DomUtil.getAttributeAsString(param, "inout");
2044
2046
  const type = DomUtil.getAttributeAsString(param, "type");
2045
2047
  const paramName = DomUtil.getAttributeAsString(param, "name");
2046
- if (!inout || inout=="in") {
2048
+ const isIn = !inout || inout=="in" || inout=="inout";
2049
+ const isOut = inout=="out" || inout=="inout";
2050
+ if (isIn) {
2047
2051
  let paramValue = parametersIsArray ? parameters[paramIndex] : parameters;
2048
2052
  const inputParam = {
2049
2053
  name: paramName,
@@ -2053,13 +2057,13 @@ class Client {
2053
2057
  inputParams.push(inputParam);
2054
2058
  paramIndex = paramIndex + 1;
2055
2059
  }
2056
- else if (inout=="out") {
2060
+ if (isOut) {
2057
2061
  outputParams.push({
2058
2062
  name: paramName,
2059
2063
  type: type,
2060
2064
  });
2061
2065
  }
2062
- else {
2066
+ if( !isIn && !isOut) {
2063
2067
  throw CampaignException.BAD_PARAMETER("inout", inout, `Parameter '${paramName}' of schema '${entitySchemaId}' is not correctly defined as an input or output parameter`);
2064
2068
  }
2065
2069
  param = DomUtil.getNextSiblingElement(param, "param");
@@ -1061,26 +1061,44 @@ describe('ACC Client', function () {
1061
1061
  await client.NLWS.xtkSession.logon();
1062
1062
 
1063
1063
  client._transport.mockReturnValueOnce(Mock.GET_XTK_WORKFLOW_SCHEMA_RESPONSE);
1064
- client._transport.mockImplementationOnce(options => {
1065
- const doc = DomUtil.parse(options.data);
1066
- const body = DomUtil.findElement(doc.documentElement, "SOAP-ENV:Body");
1067
- const method = DomUtil.getFirstChildElement(body);
1068
- const parameters = DomUtil.findElement(method, "parameters");
1069
- const variables = DomUtil.getFirstChildElement(parameters, "variables");
1070
- if (!variables)
1071
- throw new Error("Did not find 'variables' node");
1072
- if (variables.getAttribute("hello") != "world")
1073
- throw new Error("Did not find 'hello' variable");
1074
1064
 
1075
- return Promise.resolve(`<?xml version='1.0'?>
1076
- <SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:workflow' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
1077
- <SOAP-ENV:Body>
1078
- <StartWithParametersResponse xmlns='urn:xtk:workflow' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
1079
- </StartWithParametersResponse>
1080
- </SOAP-ENV:Body>
1081
- </SOAP-ENV:Envelope>`);
1082
- });
1083
- await client.NLWS.xtkWorkflow.startWithParameters(4900, { "hello": "world" });
1065
+ const mockImpl = (methodName) => {
1066
+ client._transport.mockImplementationOnce(options => {
1067
+ const doc = DomUtil.parse(options.data);
1068
+ const body = DomUtil.findElement(doc.documentElement, "SOAP-ENV:Body");
1069
+ const method = DomUtil.getFirstChildElement(body);
1070
+ const parameters = DomUtil.findElement(method, "parameters");
1071
+ const variables = DomUtil.getFirstChildElement(parameters, "variables");
1072
+ if (!variables)
1073
+ throw new Error("Did not find 'variables' node");
1074
+ if (variables.getAttribute("hello") != "world")
1075
+ throw new Error("Did not find 'hello' variable");
1076
+
1077
+ const tagName = methodName + "Response";
1078
+ return Promise.resolve(`<?xml version='1.0'?>
1079
+ <SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:workflow' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
1080
+ <SOAP-ENV:Body>
1081
+ <${tagName} xmlns='urn:xtk:workflow' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
1082
+ </${tagName}>
1083
+ </SOAP-ENV:Body>
1084
+ </SOAP-ENV:Envelope>`);
1085
+ });
1086
+ };
1087
+
1088
+ const variables = { "hello": "world" };
1089
+
1090
+ mockImpl("StartWithParameters");
1091
+ await client.NLWS.xtkWorkflow.startWithParameters(4900, variables);
1092
+ mockImpl("SimulateWithParameters");
1093
+ await client.NLWS.xtkWorkflow.simulateWithParameters(4900, variables);
1094
+ mockImpl("PostEvent");
1095
+ await client.NLWS.xtkWorkflow.postEvent("WFK123", "signal", "", variables, false);
1096
+
1097
+ // return parameter instanceId has been removed from the mock method definition to simplify the unit test
1098
+ mockImpl("SpawnWithParameters");
1099
+ await client.NLWS.xtkWorkflow.spawnWithParameters(4900, variables);
1100
+ mockImpl("SpawnWithParametersEx");
1101
+ await client.NLWS.xtkWorkflow.spawnWithParametersEx(4900, true, variables);
1084
1102
 
1085
1103
  client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
1086
1104
  await client.NLWS.xtkSession.logoff();
@@ -4351,4 +4369,33 @@ describe('ACC Client', function () {
4351
4369
  expect(result[1].serverInfo.buildNumber).toBe("9219");
4352
4370
  });
4353
4371
  });
4372
+
4373
+ describe("Test inout parameter", () => {
4374
+ it("Call testAccount with inout parameter", async () => {
4375
+ const client = await Mock.makeClient();
4376
+ client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
4377
+ await client.NLWS.xtkSession.logon();
4378
+
4379
+ client._transport.mockReturnValueOnce(Mock.GET_NMS_EXTACCOUNT_SCHEMA_WITH_METHODS_RESPONSE);
4380
+
4381
+ client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
4382
+ <SOAP-ENV:Envelope
4383
+ xmlns:xsd='http://www.w3.org/2001/XMLSchema'
4384
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
4385
+ xmlns:ns='urn:nms:extAccount'
4386
+ xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
4387
+ <SOAP-ENV:Body>
4388
+ <TestAccountResponse
4389
+ xmlns='urn:nms:extAccount' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
4390
+ <pstrServer xsi:type='xsd:string'>localhost</pstrServer>
4391
+ <pstrDbmsVer xsi:type='xsd:string'>Database server version 'PostgreSQL 12.2, compiled by Visual C++ build 1914, 64-bit'.</pstrDbmsVer>
4392
+ <pstrWarehouse xsi:type='xsd:string'></pstrWarehouse>
4393
+ <pstrTestDuration xsi:type='xsd:string'>Test connection took: 0 ms</pstrTestDuration>
4394
+ </TestAccountResponse>
4395
+ </SOAP-ENV:Body>
4396
+ </SOAP-ENV:Envelope>`));
4397
+
4398
+ const result = await client.NLWS.nmsExtAccount.testAccount(7, true, "PostgreSQL:localhost", "postgres", "password", "NChar=0;unicodeData=1;timezone=_server_;dbSchema=public;fileMethod=uploadFile;filePath=", "pg2", 0);
4399
+ });
4400
+ });
4354
4401
  });
package/test/mock.js CHANGED
@@ -567,6 +567,50 @@ const GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?
567
567
  </SOAP-ENV:Body>
568
568
  </SOAP-ENV:Envelope>`);
569
569
 
570
+ const GET_NMS_EXTACCOUNT_SCHEMA_WITH_METHODS_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
571
+ <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/'>
572
+ <SOAP-ENV:Body>
573
+ <GetEntityIfMoreRecentResponse xmlns='urn:wpp:default' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
574
+ <pdomDoc xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
575
+ <schema name="extAccount" namespace="nms" xtkschema="xtk:schema">
576
+ <enumeration basetype="byte" default="delivery" name="type">
577
+ <value name="bounces" value="0"/>
578
+ <value name="hdfs" value="17"/>
579
+ </enumeration>
580
+ <enumeration basetype="byte" default="none" name="encryptionType">
581
+ <value name="none" value="0"/>
582
+ <value name="ssl" value="1"/>
583
+ </enumeration>
584
+ <element name="extAccount"></element>
585
+ <methods>
586
+ <method name="TestAccount" static="true">
587
+ <help>Performs a connection test</help>
588
+ <parameters>
589
+ <param name="type" type="byte" desc="Account type"/>
590
+ <param name="active" type="boolean" desc="Is account active"/>
591
+ <param name="server" type="string" desc="Server address" inout="inout"/>
592
+ <param name="account" type="string" desc="Name (or login) of account"/>
593
+ <param name="password" type="string" desc="Password associated with account"/>
594
+ <param name="port" type="string" desc="Server port"/>
595
+ <param name="options" type="string" desc="Connection options"/>
596
+ <param name="name" type="string" desc="Account name" optional="true"/>
597
+ <param name="oauth" type="boolean" desc="OAUth 2.0 activation"/>
598
+ <param name="azureTenant" type="string" desc="Azure tenant" optional="true"/>
599
+ <param name="clientId" type="string" desc="Azure client Id" optional="true"/>
600
+ <param name="clientSecret" type="string" desc="Azure client secret" optional="true"/>
601
+ <param name="redirectUrl" type="string" desc="Azure redirect url" optional="true"/>
602
+ <param name="dbmsVer" type="string" desc="DBMS Version" inout="out" optional="true"/>
603
+ <param name="warehouse" type="string" desc="Warehouse name" inout="out" optional="true"/>
604
+ <param name="testDuration" type="string" desc="Formatted string displaying connection time in ms" inout="out" optional="true"/>
605
+ </parameters>
606
+ </method>
607
+ </methods>
608
+ </schema>
609
+ </pdomDoc>
610
+ </GetEntityIfMoreRecentResponse>
611
+ </SOAP-ENV:Body>
612
+ </SOAP-ENV:Envelope>`);
613
+
570
614
  const GET_XTK_IMPL_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
571
615
  <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/'>
572
616
  <SOAP-ENV:Body>
@@ -698,6 +742,34 @@ const GET_XTK_WORKFLOW_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
698
742
  <param name="parameters" type="DOMElement" inout="in"></param>
699
743
  </parameters>
700
744
  </method>
745
+ <method name="SimulateWithParameters" static="true">
746
+ <parameters>
747
+ <param name="workflowId" type="string" inout="in" />
748
+ <param name="parameters" type="DOMElement" inout="in"></param>
749
+ </parameters>
750
+ </method>
751
+ <method name="PostEvent" static="true">
752
+ <parameters>
753
+ <param name="workflowId" type="string" inout="in"/>
754
+ <param name="activity" type="string" inout="in"/>
755
+ <param name="transition" type="string" inout="in"/>
756
+ <param name="parameters" type="DOMElement" inout="in"/>
757
+ <param name="complete" type="boolean" inout="in"/>
758
+ </parameters>
759
+ </method>
760
+ <method name="SpawnWithParameters" static="true">
761
+ <parameters>
762
+ <param name="workflowId" type="string" inout="in" />
763
+ <param name="parameters" type="DOMElement" inout="in"></param>
764
+ </parameters>
765
+ </method>
766
+ <method name="SpawnWithParametersEx" static="true">
767
+ <parameters>
768
+ <param name="workflowId" type="string" inout="in" />
769
+ <param name="simulation" type="boolean" inout="in"/>
770
+ <param name="parameters" type="DOMElement" inout="in"></param>
771
+ </parameters>
772
+ </method>
701
773
  </methods>
702
774
  </schema>
703
775
  </pdomDoc>
@@ -1061,6 +1133,7 @@ exports.Mock = {
1061
1133
  GET_LOGON_MID_RESPONSE: GET_LOGON_MID_RESPONSE,
1062
1134
  GET_TSTCNX_RESPONSE: GET_TSTCNX_RESPONSE,
1063
1135
  GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE: GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE,
1136
+ GET_NMS_EXTACCOUNT_SCHEMA_WITH_METHODS_RESPONSE: GET_NMS_EXTACCOUNT_SCHEMA_WITH_METHODS_RESPONSE,
1064
1137
  GET_XTK_ALL_SCHEMA_RESPONSE: GET_XTK_ALL_SCHEMA_RESPONSE,
1065
1138
  GET_XTK_IMPL_SCHEMA_RESPONSE: GET_XTK_IMPL_SCHEMA_RESPONSE,
1066
1139
  GET_XTK_ALL_TYPES_RESPONSE: GET_XTK_ALL_TYPES_RESPONSE,