@adobe/acc-js-sdk 1.1.2 → 1.1.5
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 +188 -21
- 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 +89 -16
- 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 +415 -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.5
|
|
9
|
+
_2022/07/07__
|
|
10
|
+
|
|
11
|
+
* The SOAP method name was not showing up properly in the Chrome console
|
|
12
|
+
|
|
13
|
+
## Version 1.1.4
|
|
14
|
+
_2022/07/07__
|
|
15
|
+
|
|
16
|
+
* Added `application.version` which returns the server version in the format major.minor.servicePack (ex: 8.2.10)
|
|
17
|
+
* Added the ability to push down parameters to the SOAP and transport layers. See the pushDown section of the readme file.
|
|
18
|
+
* The pushDown mechanism can be used to simply overwrite the request timeout, either globally or at the method level
|
|
19
|
+
* Publicly export the HttpError class so that custom transports can be written more safely. A failure during transport should return an HttpError object
|
|
20
|
+
* By default, the SOAP method name is now added in the URLs for better troubleshooting
|
|
21
|
+
|
|
22
|
+
## Version 1.1.3
|
|
23
|
+
_2022/05/30_
|
|
24
|
+
|
|
25
|
+
* 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.
|
|
26
|
+
* 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.
|
|
27
|
+
* 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.
|
|
28
|
+
* 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
|
|
29
|
+
* Document how to set the password of an external account
|
|
30
|
+
* By default, SDK will send additional HTTP headers to help troubleshooting and usage tracking
|
|
31
|
+
* 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
|
|
32
|
+
* Remove .vscode folder from the sources
|
|
33
|
+
* Example for xtkBuilder.installPackage API
|
|
34
|
+
* For APIs which have parameters of type DOMElement and which are called using XML, support passing either a DOMElement or a DOMDocument
|
|
35
|
+
|
|
36
|
+
|
|
8
37
|
## Version 1.1.2
|
|
9
38
|
_2022/03/22_
|
|
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
|
|
|
@@ -318,7 +322,8 @@ The Simple JSON format works like this:
|
|
|
318
322
|
|
|
319
323
|
The XML root element tag is determined by the SDK as it's generating the XML, usually from the current schema name.
|
|
320
324
|
|
|
321
|
-
* XML: `<root
|
|
325
|
+
* XML: `<root/>
|
|
326
|
+
`
|
|
322
327
|
* JSON: `{}`
|
|
323
328
|
|
|
324
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.
|
|
@@ -355,7 +360,9 @@ Text of a child element
|
|
|
355
360
|
* Alternative JSON: `{ item: { $: "Hello" } }`
|
|
356
361
|
|
|
357
362
|
If an element contains both text, and children, you need to use the alternative `$` syntax
|
|
358
|
-
* XML: `<root><item>Hello<child id="1"
|
|
363
|
+
* XML: `<root><item>Hello<child id="1"/>
|
|
364
|
+
</item>
|
|
365
|
+
</root>`
|
|
359
366
|
* JSON: `{ item: { $: "Hello", child: { id:1 } }`
|
|
360
367
|
|
|
361
368
|
|
|
@@ -508,8 +515,8 @@ const DomUtil = client.DomUtil;
|
|
|
508
515
|
Create DOM from XML string:
|
|
509
516
|
```js
|
|
510
517
|
const doc = DomUtil.parse(`<root>
|
|
511
|
-
|
|
512
|
-
|
|
518
|
+
<one/>
|
|
519
|
+
</root>`);
|
|
513
520
|
```
|
|
514
521
|
|
|
515
522
|
Writes a DOM document or element as a string:
|
|
@@ -576,6 +583,49 @@ const document = DomUtil.fromJSON(json, "BadgerFish");
|
|
|
576
583
|
const json = DomUtil.toJSON(documentOrElement, "BadgerFish");
|
|
577
584
|
```
|
|
578
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
|
+
|
|
579
629
|
## Error Management
|
|
580
630
|
|
|
581
631
|
If an API call fails (SOAP fault or HTTP error), a `CampaignException` object is thrown. This object contains the following attributes
|
|
@@ -654,6 +704,107 @@ const password = cipher.decryptPassword(encryptedPassword);
|
|
|
654
704
|
|
|
655
705
|
> **warning** This function is deprecated in version 1.0.0 of the SDK because it may break as we deploy Vault.
|
|
656
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.5 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 });
|
|
657
808
|
|
|
658
809
|
|
|
659
810
|
# Samples
|
|
@@ -879,12 +1030,16 @@ The transport protocol defines
|
|
|
879
1030
|
- What is the corresponding response
|
|
880
1031
|
- How errors are handled
|
|
881
1032
|
|
|
882
|
-
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.
|
|
883
1036
|
* `method` is the HTTP verb
|
|
884
1037
|
* `url` is the URL to call
|
|
885
1038
|
* `headers` is an object containing key value pairs with http headers and their values
|
|
886
1039
|
* `data` is the request payload
|
|
887
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
|
+
|
|
888
1043
|
If the request is successful, a promise is returned with the result payload, as a string.
|
|
889
1044
|
|
|
890
1045
|
If the request fails, the promise is rejected with an error object with class `HttpError`, a litteral with the following attributes:
|
|
@@ -892,7 +1047,7 @@ If the request fails, the promise is rejected with an error object with class `H
|
|
|
892
1047
|
* `statusText` is the HTTP status text coming with the error
|
|
893
1048
|
* `data` is the response data, if any
|
|
894
1049
|
|
|
895
|
-
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"
|
|
896
1051
|
|
|
897
1052
|
The transport can be overriden by using the `client.setTransport` call and passing it a transport function, i.e. an async function which
|
|
898
1053
|
* Takes a `Request` object litteral as a parameter
|
|
@@ -949,14 +1104,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
949
1104
|
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
|
950
1105
|
xmlns:ns="http://xml.apache.org/xml-soap">
|
|
951
1106
|
<SOAP-ENV:Header>
|
|
952
|
-
|
|
953
|
-
|
|
1107
|
+
<Cookie>__sessiontoken=***</Cookie>
|
|
1108
|
+
<X-Security-Token>***</X-Security-Token>
|
|
954
1109
|
</SOAP-ENV:Header>
|
|
955
1110
|
<SOAP-ENV:Body>
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
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>
|
|
960
1115
|
</SOAP-ENV:Body>
|
|
961
1116
|
</SOAP-ENV:Envelope>
|
|
962
1117
|
|
|
@@ -966,10 +1121,10 @@ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
|
|
|
966
1121
|
xmlns:ns='urn:xtk:session'
|
|
967
1122
|
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
968
1123
|
<SOAP-ENV:Body>
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
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>
|
|
973
1128
|
</SOAP-ENV:Body>
|
|
974
1129
|
</SOAP-ENV:Envelope>
|
|
975
1130
|
`````
|
|
@@ -1144,6 +1299,17 @@ const folder = {
|
|
|
1144
1299
|
await NLWS.xtkSession.write(folder);
|
|
1145
1300
|
````
|
|
1146
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
|
+
|
|
1147
1313
|
# Workflow API
|
|
1148
1314
|
|
|
1149
1315
|
Start and stop wotkflows, passing either an id or workflow internal name
|
|
@@ -1347,6 +1513,7 @@ The `application` object can be obtained from a client, and will mimmic the Camp
|
|
|
1347
1513
|
| Attribute/Method | Description |
|
|
1348
1514
|
|---|---|
|
|
1349
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)
|
|
1350
1517
|
| **instanceName** | The name of the Campaign instance
|
|
1351
1518
|
| **operator** | Information about the current operator (i.e. logged user), of class `CurrentLogin`
|
|
1352
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.5",
|
|
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.5",
|
|
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
|
}
|