@adobe/acc-js-sdk 1.1.1 → 1.1.4
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/.github/workflows/npm-publish.yml +1 -1
- package/CHANGELOG.md +29 -0
- package/README.md +198 -22
- package/compile.js +1 -1
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/samples/011 - basics - packages.js +60 -0
- package/samples/utils.js +3 -1
- package/src/application.js +11 -4
- package/src/client.js +156 -71
- package/src/index.js +3 -1
- package/src/soap.js +44 -18
- package/src/testUtil.js +2 -2
- package/src/transport.js +17 -2
- package/test/application.test.js +11 -0
- package/test/client.hasPackage.test.js +6 -6
- package/test/client.test.js +467 -4
- package/test/soap.test.js +76 -28
- package/.vscode/launch.json +0 -22
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
node-version: 10.0.0
|
|
17
17
|
- name: Publish if version has been updated
|
|
18
18
|
#uses: pascalgn/npm-publish-action@06e0830ea83eea10ed4a62654eeaedafb8bf50fc
|
|
19
|
-
uses: mkiki/npm-publish-action@
|
|
19
|
+
uses: mkiki/npm-publish-action@52879298d00c0a02781e1f02c9e917e01cff1bc7
|
|
20
20
|
with: # All of theses inputs are optional
|
|
21
21
|
tag_name: "v%s"
|
|
22
22
|
tag_message: "v%s"
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,35 @@ This is a node.js SDK for Campaign API. It exposes the Campaign API exactly like
|
|
|
5
5
|
|
|
6
6
|
# Changelog
|
|
7
7
|
|
|
8
|
+
## Version 1.1.4
|
|
9
|
+
_2022/06/xx_
|
|
10
|
+
|
|
11
|
+
* Added `application.version` which returns the server version in the format major.minor.servicePack (ex: 8.2.10)
|
|
12
|
+
* Added the ability to push down parameters to the SOAP and transport layers. See the pushDown section of the readme file.
|
|
13
|
+
* The pushDown mechanism can be used to simply overwrite the request timeout, either globally or at the method level
|
|
14
|
+
* Publicly export the HttpError class so that custom transports can be written more safely. A failure during transport should return an HttpError object
|
|
15
|
+
* By default, the SOAP method name is now added in the URLs for better troubleshooting
|
|
16
|
+
|
|
17
|
+
## Version 1.1.3
|
|
18
|
+
_2022/05/30_
|
|
19
|
+
|
|
20
|
+
* Fix a bug in client.hasPackage which was returning an incorrect result when passed a single parameter (it would always return false). Fixed the corresponding unit test too.
|
|
21
|
+
* Fix a bug causing API calls having a input parameter of type "int" to fail. Usually the type is described as "long", but sometimes "int" is used instead, such as, for instance, in the nms:extAccount#UpdateMCSynchWkf method.
|
|
22
|
+
* When using XML representations and DOMDocument method parameter type, the SDK expects to be passed an actual DOM document. Now it supports being passed a DOM element too. This is a common case when using the nms:delivery#createFromModel API followed by a xtk:session#Write API call.
|
|
23
|
+
* Avoid the error 'Cannot transform entity to xml because no XML root name was given' by using SOAP method parameter name as the default for XML document root when no other root is available
|
|
24
|
+
* Document how to set the password of an external account
|
|
25
|
+
* By default, SDK will send additional HTTP headers to help troubleshooting and usage tracking
|
|
26
|
+
* Add the ability to pass extra HTTP headers to API calls, either globally (to all HTTP headers), or locally, i.e. for a specific method
|
|
27
|
+
* Remove .vscode folder from the sources
|
|
28
|
+
* Example for xtkBuilder.installPackage API
|
|
29
|
+
* For APIs which have parameters of type DOMElement and which are called using XML, support passing either a DOMElement or a DOMDocument
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Version 1.1.2
|
|
33
|
+
_2022/03/22_
|
|
34
|
+
|
|
35
|
+
* Add support for choosing the representation (XML or JSON) at the method level using NLWS.xml or NLWS.json.
|
|
36
|
+
|
|
8
37
|
## Version 1.1.1
|
|
9
38
|
_2022/03/10_
|
|
10
39
|
|
package/README.md
CHANGED
|
@@ -130,7 +130,11 @@ noStorage|false|De-activate using of local storage
|
|
|
130
130
|
storage|localStorage|Overrides the local storage for caches
|
|
131
131
|
refreshClient|undefined|Async callback to run when the session token is expired
|
|
132
132
|
charset|UTF-8|The charset encoding used for http requests. In version 1.1.1 and above, the default will be UTF-8. It's possible to override (including setting an empty character set) with this option.
|
|
133
|
-
|
|
133
|
+
extraHttpHeaders|[string]:string|An optional dictionary (key/value pairs) of extra HTTP headers to pass to all API calls.
|
|
134
|
+
clientApp|string|An optional string describing the name and version of the SDK client application. It will be passed to the server in the ACC-SDK-Client-App HTTP header
|
|
135
|
+
noSDKHeaders|boolean|Can be set to disable passing ACC-SDK-* HTTP headers to the server
|
|
136
|
+
noMethodInURL|boolean|Can be set to true to remove the method name from the URL
|
|
137
|
+
timeout|number|Can be used to set the APIs call timeout (in ms)
|
|
134
138
|
```js
|
|
135
139
|
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
136
140
|
"https://myInstance.campaign.adobe.com",
|
|
@@ -187,8 +191,8 @@ If you want to use the SDK client-side in a web page returned by Campaign, you c
|
|
|
187
191
|
For this scenario, the `ofSecurityToken` function can be used. Pass it a security token (usually available as document.__securitytoken), and the SDK will let the browser handle the session token (cookie) for you.
|
|
188
192
|
|
|
189
193
|
```html
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
<script src="acc-sdk.js"></script>
|
|
195
|
+
<script>
|
|
192
196
|
(async () => {
|
|
193
197
|
try {
|
|
194
198
|
const sdk = document.accSDK;
|
|
@@ -202,8 +206,8 @@ For this scenario, the `ofSecurityToken` function can be used. Pass it a securit
|
|
|
202
206
|
console.error(ex);
|
|
203
207
|
}
|
|
204
208
|
})();
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
</script>
|
|
210
|
+
</body>
|
|
207
211
|
</html>
|
|
208
212
|
```
|
|
209
213
|
|
|
@@ -304,12 +308,22 @@ const queryDef = {
|
|
|
304
308
|
};
|
|
305
309
|
```
|
|
306
310
|
|
|
311
|
+
## Method-level representation
|
|
312
|
+
|
|
313
|
+
The client object is created with a default representation which is used for all API calls in the context of this client. Since version 1.1.2, it is also possible to set the representation at the method level, i.e. use a particular representation for a particular API call.
|
|
314
|
+
|
|
315
|
+
* `client.NLWS`: use the default representation set at the client level
|
|
316
|
+
* `client.NLWS.xml`: use the XML reresentation
|
|
317
|
+
* `client.NLWS.json`: use the SimpleJson representation
|
|
318
|
+
|
|
319
|
+
|
|
307
320
|
## SimpleJson format
|
|
308
321
|
The Simple JSON format works like this:
|
|
309
322
|
|
|
310
323
|
The XML root element tag is determined by the SDK as it's generating the XML, usually from the current schema name.
|
|
311
324
|
|
|
312
|
-
* XML: `<root
|
|
325
|
+
* XML: `<root/>
|
|
326
|
+
`
|
|
313
327
|
* JSON: `{}`
|
|
314
328
|
|
|
315
329
|
XML attributes are mapped to JSON attributes with the same name, whose litteral value can be a string, number, or boolean. There's no "@" sign in the JSON attribute name.
|
|
@@ -324,7 +338,7 @@ XML elements are mapped to JSON objects
|
|
|
324
338
|
* XML: `<root><item id=1/></root>`
|
|
325
339
|
* JSON: `{ item: { id:1 } }`
|
|
326
340
|
|
|
327
|
-
If the parent element tag ends with `-
|
|
341
|
+
If the parent element tag ends with `-collection` children are always an array, even if there are no children, or if there is just one child. The rationale is that XML/JSON conversion is ambigous : XML can have multiple elements with the same tag and when there's only one such element, it's not possible to determine if it should be represented as a JSON object or JSON array unless we have additional metadata.
|
|
328
342
|
|
|
329
343
|
* XML: `<root-collection><item id=1/></root>`
|
|
330
344
|
* JSON: `{ item: [ { id:1 } ] }`
|
|
@@ -346,7 +360,9 @@ Text of a child element
|
|
|
346
360
|
* Alternative JSON: `{ item: { $: "Hello" } }`
|
|
347
361
|
|
|
348
362
|
If an element contains both text, and children, you need to use the alternative `$` syntax
|
|
349
|
-
* XML: `<root><item>Hello<child id="1"
|
|
363
|
+
* XML: `<root><item>Hello<child id="1"/>
|
|
364
|
+
</item>
|
|
365
|
+
</root>`
|
|
350
366
|
* JSON: `{ item: { $: "Hello", child: { id:1 } }`
|
|
351
367
|
|
|
352
368
|
|
|
@@ -499,8 +515,8 @@ const DomUtil = client.DomUtil;
|
|
|
499
515
|
Create DOM from XML string:
|
|
500
516
|
```js
|
|
501
517
|
const doc = DomUtil.parse(`<root>
|
|
502
|
-
|
|
503
|
-
|
|
518
|
+
<one/>
|
|
519
|
+
</root>`);
|
|
504
520
|
```
|
|
505
521
|
|
|
506
522
|
Writes a DOM document or element as a string:
|
|
@@ -567,6 +583,49 @@ const document = DomUtil.fromJSON(json, "BadgerFish");
|
|
|
567
583
|
const json = DomUtil.toJSON(documentOrElement, "BadgerFish");
|
|
568
584
|
```
|
|
569
585
|
|
|
586
|
+
## Passing XML parameters
|
|
587
|
+
Many Campaign APIs take arguments which are DOM documents or DOM elements. For example, the nms:delivery#DeployTriggerMessages first argument is a DOMElement which is supposed to be a `<where>` clause used as a condition to select Message Center deliveries to publish.
|
|
588
|
+
|
|
589
|
+
```xml
|
|
590
|
+
<method name="DeployTriggerMessages" static="true">
|
|
591
|
+
<parameters>
|
|
592
|
+
<param inout="in" name="deliveries" type="DOMElement"/>
|
|
593
|
+
<param inout="in" name="localPublish" type="boolean"/>
|
|
594
|
+
</parameters>
|
|
595
|
+
</method>
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
For example, one would want to use the following condition to republish a particular delivery
|
|
599
|
+
|
|
600
|
+
```js
|
|
601
|
+
await client.NLWS.nmsDelivery.DeployTriggerMessages({
|
|
602
|
+
condition: [ {
|
|
603
|
+
expr: "@internalName='DM23'"
|
|
604
|
+
}]
|
|
605
|
+
}, false);
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
The JSON object corresponds to the following XML
|
|
609
|
+
```xml
|
|
610
|
+
<where>
|
|
611
|
+
<condition expr="@internalName='DM23'"/>
|
|
612
|
+
</where>
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
Note that in XML, unlike JSON, the root element `<where>` is explicitely named "where". When converting JSON to XML, there is no way for the SDK to know which tag name to used for the root XML element. The SDK contains some code to set it for the most common situation, but will rely on the user to specify, when necessary, the name of the root elment. This can be done using the `xtkschema` (all case insensitive) attribute as follows:
|
|
616
|
+
```js
|
|
617
|
+
await client.NLWS.nmsDelivery.DeployTriggerMessages({
|
|
618
|
+
xtkschema: 'xtk:where',
|
|
619
|
+
condition: [ {
|
|
620
|
+
expr: "@internalName='DM23'"
|
|
621
|
+
}]
|
|
622
|
+
}, false);
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
When the `xtkschema` attribute is set, the part after the colon (i.e. "where" in this example) will be used as the root element, effectively generating the right XML.
|
|
626
|
+
|
|
627
|
+
In our example, the `DeployTriggerMessages` will work properly regardless of the XML root of its `deliveries` parameter, so it's not needed to actually set the `xtkschema` attribute, but it's a best practice to do so, because some APIs will actually depend on receiving the right tag name.
|
|
628
|
+
|
|
570
629
|
## Error Management
|
|
571
630
|
|
|
572
631
|
If an API call fails (SOAP fault or HTTP error), a `CampaignException` object is thrown. This object contains the following attributes
|
|
@@ -645,6 +704,107 @@ const password = cipher.decryptPassword(encryptedPassword);
|
|
|
645
704
|
|
|
646
705
|
> **warning** This function is deprecated in version 1.0.0 of the SDK because it may break as we deploy Vault.
|
|
647
706
|
|
|
707
|
+
In order to set the password of an external account, you can use the `encryptPassword` API as follow
|
|
708
|
+
|
|
709
|
+
```js
|
|
710
|
+
const password = await this._client.NLWS.xtkSession.encryptPassword('password');
|
|
711
|
+
const account = {
|
|
712
|
+
xtkschema: "nms:extAccount",
|
|
713
|
+
name: name,
|
|
714
|
+
account: 'admin',
|
|
715
|
+
server: server,
|
|
716
|
+
password: password,
|
|
717
|
+
};
|
|
718
|
+
await this._client.NLWS.xtkSession.Write(account);
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
## HTTP Headers
|
|
723
|
+
|
|
724
|
+
### Out-of-the-box headers
|
|
725
|
+
In version 1.1.3 and above, the SDK will pass additional HTTP headers automatically
|
|
726
|
+
|
|
727
|
+
Header | Description
|
|
728
|
+
-------|------------
|
|
729
|
+
SOAPAction| name of the schema and SOAP method (ex: xtk:query#ExecuteQuery)
|
|
730
|
+
ACC-SDK-Version| Version of the SDK making the scores
|
|
731
|
+
ACC-SDK-Auth| Authentification type and ACC user
|
|
732
|
+
ACC-SDK-Client-App| Name of the application calling the client SDK
|
|
733
|
+
ACC-SDK-Call-RetryCount| In case an API call is retried, indicates the number of retries
|
|
734
|
+
ACC-SDK-Call-Internal| Indicates that an API call is performed byt the SDK for its own purpose
|
|
735
|
+
|
|
736
|
+
The `ACC-SDK` headers can be removed using the connection parameter `noSDKHeaders`.
|
|
737
|
+
|
|
738
|
+
### Custom HTTP headers
|
|
739
|
+
In version 1.1.3 and above, it is possible to pass additional HTTP headers or override HTTP headers set by the SDK. This can be done globally (i.e. for all API calls), or locally, i.e. just for a particular call, or both.
|
|
740
|
+
|
|
741
|
+
Http headers are passed through an object whose keys represent the header name and values the corresponding header value. Nothing particular is done in term of case sensitivity, headers will be passed as passed.
|
|
742
|
+
|
|
743
|
+
To set global HTTP headers for all API calls of a client, pass an http headers array in the connection parameters
|
|
744
|
+
```js
|
|
745
|
+
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
746
|
+
"https://myInstance.campaign.adobe.com",
|
|
747
|
+
"admin", "admin",
|
|
748
|
+
{ extraHttpHeaders: {
|
|
749
|
+
"X-ACC-JS-SDK-LBSAFE": "1",
|
|
750
|
+
"X-ACC-WEBUI-VERSION: "1.2"
|
|
751
|
+
} });
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
Subsequent API calls will have the corresponding headers set.
|
|
755
|
+
|
|
756
|
+
To set more HTTP headers for a particular API call, use the "headers" method of the NLWS object.
|
|
757
|
+
|
|
758
|
+
```js
|
|
759
|
+
const query = client.NLWS
|
|
760
|
+
.headers({'X-Test': 'hello'})
|
|
761
|
+
.xtkQueryDef.create(queryDef);
|
|
762
|
+
await query.executeQuery();
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
## Timeouts
|
|
766
|
+
|
|
767
|
+
By default, the SDK has a timeout of 5s when running in a node.js environment, and uses the browser defaults when run inside a browser (using the fetch API).
|
|
768
|
+
|
|
769
|
+
It is possible to overwrite the transport layer (see `The Transport Protocol` and use your own code to make and configure HTTP requests) to tune the timeout value. It is a bit cumbersome though.
|
|
770
|
+
|
|
771
|
+
Instead, you can use the `timeout` parameter, and set it either globally, as a connection parameter, or even at the API call level but using the `PushDown` mechanism described below.
|
|
772
|
+
|
|
773
|
+
Sets a timeout of 10s gloally
|
|
774
|
+
```js
|
|
775
|
+
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
776
|
+
"https://myInstance.campaign.adobe.com",
|
|
777
|
+
"admin", "admin",
|
|
778
|
+
{ timeout: 10000 });
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
Override the timeout to 1 min for a particular API call
|
|
782
|
+
```js
|
|
783
|
+
NLWS.xml.pushDown({ timeout: 60000 }).xtkBuilder.installPackage(dom);
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
## Pushdown mechanism
|
|
787
|
+
The Pushdown mechanism can be used to push down variables to the transport layer. A common use case it to pass a custom timeout value down to the transport layer.
|
|
788
|
+
|
|
789
|
+
The pushed down parameters are passed as a second parameter to the transport function. This parameter will contain all the connection parameters as well as any parameter that you can push down at the API call level. API call pushdowns can override default pushdowns.
|
|
790
|
+
|
|
791
|
+
Any key/value pairs can be pushed down. This example pushes down the timeout and foo variables to the transport layer.
|
|
792
|
+
```js
|
|
793
|
+
NLWS.xml.pushDown({ timeout: 60000, foo: 'bar' }).xtkBuilder.installPackage(dom);
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
## Troubleshooting
|
|
797
|
+
In the version 1.1.4 of the SDK, we are automatically adding the SOAP method name in the URL in order to simplify troubleshooting. Normally, all SOAP method calls are make to the soaprouter.jsp endpoint, which makes it difficult to understand which actual API call is being made.
|
|
798
|
+
In fact the SOAP call name is available via the SOAPAction HTTP header, but it's usually not immediatelly visible.
|
|
799
|
+
|
|
800
|
+
The SOAP calls URLs are now formed like this: `http://acc-sdk:8080/nl/jsp/soaprouter.jsp?xtk:queryDef#ExecuteQuery` where the SOAP method name is added as a query parameter. Campaign server ignores this parameter.
|
|
801
|
+
|
|
802
|
+
This can be disabled using the `noMethodInURL` connection parameter
|
|
803
|
+
|
|
804
|
+
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
805
|
+
"https://myInstance.campaign.adobe.com",
|
|
806
|
+
"admin", "admin",
|
|
807
|
+
{ noMethodInURL: true });
|
|
648
808
|
|
|
649
809
|
|
|
650
810
|
# Samples
|
|
@@ -870,12 +1030,16 @@ The transport protocol defines
|
|
|
870
1030
|
- What is the corresponding response
|
|
871
1031
|
- How errors are handled
|
|
872
1032
|
|
|
873
|
-
The transport protocol exports a single asynchronous function `request` which takes
|
|
1033
|
+
The transport protocol exports a single asynchronous function `request` which takes two parameters.
|
|
1034
|
+
|
|
1035
|
+
The first parameter is the request object with the following attributes. Note that it matches axios requests.
|
|
874
1036
|
* `method` is the HTTP verb
|
|
875
1037
|
* `url` is the URL to call
|
|
876
1038
|
* `headers` is an object containing key value pairs with http headers and their values
|
|
877
1039
|
* `data` is the request payload
|
|
878
1040
|
|
|
1041
|
+
The second parameter is an set of additional parameters that have been pushed down to the transport layer (see the `Pushdown` paragraph for more details). In particular, the `timeout` parameter should be honored by the transport layer.
|
|
1042
|
+
|
|
879
1043
|
If the request is successful, a promise is returned with the result payload, as a string.
|
|
880
1044
|
|
|
881
1045
|
If the request fails, the promise is rejected with an error object with class `HttpError`, a litteral with the following attributes:
|
|
@@ -883,7 +1047,7 @@ If the request fails, the promise is rejected with an error object with class `H
|
|
|
883
1047
|
* `statusText` is the HTTP status text coming with the error
|
|
884
1048
|
* `data` is the response data, if any
|
|
885
1049
|
|
|
886
|
-
For proper error handling by the ACC SDK, it's important that the actual class of returned objects is
|
|
1050
|
+
For proper error handling by the ACC SDK, it's important that the actual class of returned objects is named "HttpError"
|
|
887
1051
|
|
|
888
1052
|
The transport can be overriden by using the `client.setTransport` call and passing it a transport function, i.e. an async function which
|
|
889
1053
|
* Takes a `Request` object litteral as a parameter
|
|
@@ -940,14 +1104,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
940
1104
|
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
|
941
1105
|
xmlns:ns="http://xml.apache.org/xml-soap">
|
|
942
1106
|
<SOAP-ENV:Header>
|
|
943
|
-
|
|
944
|
-
|
|
1107
|
+
<Cookie>__sessiontoken=***</Cookie>
|
|
1108
|
+
<X-Security-Token>***</X-Security-Token>
|
|
945
1109
|
</SOAP-ENV:Header>
|
|
946
1110
|
<SOAP-ENV:Body>
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1111
|
+
<m:GetOption xmlns:m="urn:xtk:session" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
|
1112
|
+
<sessiontoken xsi:type="xsd:string">***</sessiontoken>
|
|
1113
|
+
<name xsi:type="xsd:string">XtkDatabaseId</name>
|
|
1114
|
+
</m:GetOption>
|
|
951
1115
|
</SOAP-ENV:Body>
|
|
952
1116
|
</SOAP-ENV:Envelope>
|
|
953
1117
|
|
|
@@ -957,10 +1121,10 @@ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
|
|
|
957
1121
|
xmlns:ns='urn:xtk:session'
|
|
958
1122
|
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
959
1123
|
<SOAP-ENV:Body>
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1124
|
+
<GetOptionResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
1125
|
+
<pstrValue xsi:type='xsd:string'>uFE80000000000000F1FA913DD7CC7C4804BA419F</pstrValue>
|
|
1126
|
+
<pbtType xsi:type='xsd:byte'>6</pbtType>
|
|
1127
|
+
</GetOptionResponse>
|
|
964
1128
|
</SOAP-ENV:Body>
|
|
965
1129
|
</SOAP-ENV:Envelope>
|
|
966
1130
|
`````
|
|
@@ -1135,6 +1299,17 @@ const folder = {
|
|
|
1135
1299
|
await NLWS.xtkSession.write(folder);
|
|
1136
1300
|
````
|
|
1137
1301
|
|
|
1302
|
+
Some objects, such as deliveries are created from templates. The `createFromModel` API is preferred in this case. Given a template name, and a patch object, it will return an object created from the template and the patch, applying all sort of business rules and default values. This object can be inserted using a writer.
|
|
1303
|
+
|
|
1304
|
+
In this example, an email delivery is created from the "mail" delivery template and it's label is set to "Hello".
|
|
1305
|
+
|
|
1306
|
+
Note the xtkschema attribute in the second parameter of the `createFromModel` API call which is needed for the SDK to perform the proper JSON to XML transformation.
|
|
1307
|
+
|
|
1308
|
+
```js
|
|
1309
|
+
const mail = await client.NLWS.nmsDelivery.createFromModel('mail', { xtkschema:'nms:delivery', label:'Hello'});
|
|
1310
|
+
await client.NLWS.xtkSession.write(mail);
|
|
1311
|
+
````
|
|
1312
|
+
|
|
1138
1313
|
# Workflow API
|
|
1139
1314
|
|
|
1140
1315
|
Start and stop wotkflows, passing either an id or workflow internal name
|
|
@@ -1338,6 +1513,7 @@ The `application` object can be obtained from a client, and will mimmic the Camp
|
|
|
1338
1513
|
| Attribute/Method | Description |
|
|
1339
1514
|
|---|---|
|
|
1340
1515
|
| **buildNumber** | The server build number
|
|
1516
|
+
| **version** | In SDK version 1.1.4 and above, returns the server version formatted as major.minor.servicePack (ex: 8.2.10)
|
|
1341
1517
|
| **instanceName** | The name of the Campaign instance
|
|
1342
1518
|
| **operator** | Information about the current operator (i.e. logged user), of class `CurrentLogin`
|
|
1343
1519
|
| **packages** | List of installed packages, as an array of strings
|
package/compile.js
CHANGED
|
@@ -38,8 +38,8 @@ var resources = [
|
|
|
38
38
|
{ name: "./optionCache.js" },
|
|
39
39
|
{ name: "./soap.js" },
|
|
40
40
|
{ name: "./crypto.js" },
|
|
41
|
-
{ name: "./testUtil.js" },
|
|
42
41
|
{ name: "./application.js" },
|
|
42
|
+
{ name: "./testUtil.js" },
|
|
43
43
|
{ name: "./client.js" },
|
|
44
44
|
{ name: "./index.js" },
|
|
45
45
|
];
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/acc-js-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@adobe/acc-js-sdk",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.4",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^0.25.0",
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
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 { DomUtil } = require('../src/domUtil.js');
|
|
13
|
+
const sdk = require('../src/index.js');
|
|
14
|
+
const utils = require("./utils.js");
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This sample illustrates how to generate and import packages
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
( async () => {
|
|
22
|
+
|
|
23
|
+
await utils.sample({
|
|
24
|
+
title: "Testing generating and importing packages",
|
|
25
|
+
labels: [ "Basics", "Packages", "xtk:builder", "InstallPackage" ],
|
|
26
|
+
description: `The xtkBuilder.installPackage() can be used to import packages`,
|
|
27
|
+
code: async() => {
|
|
28
|
+
return await utils.logon(async (client, NLWS) => {
|
|
29
|
+
console.log(`Generating package with an option named AccJsSdk`);
|
|
30
|
+
const doc = sdk.DomUtil.newDocument('pkgDesc');
|
|
31
|
+
const package = doc.createElement('package');
|
|
32
|
+
doc.documentElement.appendChild(package);
|
|
33
|
+
package.setAttribute('namespace', 'cus');
|
|
34
|
+
package.setAttribute('name', 'sdk');
|
|
35
|
+
package.setAttribute('buildNumber', '*');
|
|
36
|
+
package.setAttribute('buildVersion', '*');
|
|
37
|
+
package.setAttribute('label', 'Test package for ACC JS SDK');
|
|
38
|
+
package.setAttribute('vendor', 'acc-js-sdk');
|
|
39
|
+
|
|
40
|
+
const entities = doc.createElement('entities');
|
|
41
|
+
package.appendChild(entities);
|
|
42
|
+
entities.setAttribute('schema', 'xtk:option');
|
|
43
|
+
|
|
44
|
+
const option = doc.createElement('option');
|
|
45
|
+
option.setAttribute('name', 'AccJsSdk');
|
|
46
|
+
option.setAttribute('dataType', '6');
|
|
47
|
+
const version = client.application.version;
|
|
48
|
+
option.setAttribute('stringValue', JSON.stringify(version));
|
|
49
|
+
entities.appendChild(option);
|
|
50
|
+
|
|
51
|
+
// Install package. The package is in XML format and we set the timeout to 5 mins to prevent any issues
|
|
52
|
+
console.log(`Installing package`, DomUtil.toXMLString(doc));
|
|
53
|
+
await NLWS.xml.pushDown({ timeout: 5*60*1000 }).xtkBuilder.installPackage(doc);
|
|
54
|
+
console.log(`Package installed`);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
})();
|
|
60
|
+
|
package/samples/utils.js
CHANGED
|
@@ -47,7 +47,9 @@ async function run(main) {
|
|
|
47
47
|
*/
|
|
48
48
|
async function logon(callback) {
|
|
49
49
|
var main = async () => {
|
|
50
|
-
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(url, user, password
|
|
50
|
+
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(url, user, password, {
|
|
51
|
+
clientApp: 'acc-js-sdk sample'
|
|
52
|
+
});
|
|
51
53
|
const client = await sdk.init(connectionParameters);
|
|
52
54
|
const NLWS = client.NLWS;
|
|
53
55
|
|
package/src/application.js
CHANGED
|
@@ -1207,23 +1207,30 @@ class Application {
|
|
|
1207
1207
|
* The server build number
|
|
1208
1208
|
* @type {string}
|
|
1209
1209
|
*/
|
|
1210
|
-
|
|
1210
|
+
this.buildNumber = EntityAccessor.getAttributeAsString(serverInfo, "buildNumber");
|
|
1211
|
+
/**
|
|
1212
|
+
* The server version, formatted as major.minor.servicePack (ex: 8.2.10)
|
|
1213
|
+
* @type {string}
|
|
1214
|
+
*/
|
|
1215
|
+
this.version = EntityAccessor.getAttributeAsString(serverInfo, "majNumber") + "." +
|
|
1216
|
+
EntityAccessor.getAttributeAsString(serverInfo, "minNumber") + "." +
|
|
1217
|
+
EntityAccessor.getAttributeAsString(serverInfo, "servicePack");
|
|
1211
1218
|
/**
|
|
1212
1219
|
* The Campaign instance name
|
|
1213
1220
|
* @type {string}
|
|
1214
1221
|
*/
|
|
1215
|
-
|
|
1222
|
+
this.instanceName = EntityAccessor.getAttributeAsString(serverInfo, "instanceName");
|
|
1216
1223
|
const userInfo = EntityAccessor.getElement(info, "userInfo");
|
|
1217
1224
|
/**
|
|
1218
1225
|
* The logged operator
|
|
1219
1226
|
* @type {Campaign.CurrentLogin}
|
|
1220
1227
|
*/
|
|
1221
|
-
|
|
1228
|
+
this.operator = new CurrentLogin(userInfo);
|
|
1222
1229
|
/**
|
|
1223
1230
|
* The list of installed packages
|
|
1224
1231
|
* @type {string[]}
|
|
1225
1232
|
*/
|
|
1226
|
-
|
|
1233
|
+
this.packages = [];
|
|
1227
1234
|
for (var p of EntityAccessor.getChildElements(userInfo, "installed-package")) {
|
|
1228
1235
|
this.packages.push(`${EntityAccessor.getAttributeAsString(p, "namespace")}:${EntityAccessor.getAttributeAsString(p, "name")}`);
|
|
1229
1236
|
}
|