@adobe/acc-js-sdk 1.1.10 → 1.1.12
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/README.md +8 -2170
- package/docs/404.html +11 -0
- package/docs/Gemfile +35 -0
- package/docs/Gemfile.lock +270 -0
- package/docs/_config.yml +55 -0
- package/docs/_data/navigation.yml +119 -0
- package/docs/_includes/navigation.html +33 -0
- package/docs/_layouts/default.html +21 -0
- package/docs/_layouts/home.html +4 -0
- package/docs/_layouts/page.html +5 -0
- package/docs/_layouts/post.html +7 -0
- package/docs/_posts/2022-10-14-welcome.html +149 -0
- package/docs/application.html +367 -0
- package/docs/architecture.html +24 -0
- package/docs/assets/css/styles.css +362 -0
- package/docs/assets/images/adobe-campaign-256.png +0 -0
- package/docs/assets/images/architecture.png +0 -0
- package/docs/assets/images/ref.svg +6 -0
- package/docs/badgerFish.html +14 -0
- package/docs/bestPractices.html +189 -0
- package/docs/blog.html +18 -0
- package/docs/buildAndRun.html +96 -0
- package/docs/caches.html +68 -0
- package/docs/changeLog.html +263 -0
- package/docs/checkList.html +168 -0
- package/docs/concepts.html +130 -0
- package/docs/connecting.html +210 -0
- package/docs/connectionParameters.html +109 -0
- package/docs/contribute.html +54 -0
- package/docs/dataTypes.html +124 -0
- package/docs/differences.html +4 -0
- package/docs/documentation.html +21 -0
- package/docs/domHelper.html +88 -0
- package/docs/dynamicInvoke.html +36 -0
- package/docs/entityAccessor.html +22 -0
- package/docs/errors.html +47 -0
- package/docs/escaping.html +76 -0
- package/docs/favicon.png +0 -0
- package/docs/healthCheck.html +66 -0
- package/docs/httpHeaders.html +78 -0
- package/docs/index.html +64 -0
- package/docs/installation.html +34 -0
- package/docs/license.html +208 -0
- package/docs/messageCenter.html +80 -0
- package/docs/methodLevelRepresentation.html +12 -0
- package/docs/midSourcing.html +19 -0
- package/docs/observability.html +169 -0
- package/docs/passwords.html +27 -0
- package/docs/profiles.html +103 -0
- package/docs/pushDown.html +13 -0
- package/docs/quickstart.html +69 -0
- package/docs/release.html +52 -0
- package/docs/samples.html +82 -0
- package/docs/simpleJson.html +88 -0
- package/docs/soapAPIs.html +234 -0
- package/docs/timeouts.html +23 -0
- package/docs/transport.html +45 -0
- package/docs/troubleshooting.html +17 -0
- package/docs/writeDoc.html +208 -0
- package/docs/xml2json.html +96 -0
- package/docs/xtkCaster.html +67 -0
- package/docs/xtkInterface.html +20 -0
- package/docs/xtkOption.html +54 -0
- package/docs/xtkPackage.html +16 -0
- package/docs/xtkPersist.html +213 -0
- package/docs/xtkQueryDef.html +245 -0
- package/docs/xtkSchema.html +39 -0
- package/docs/xtkSession.html +29 -0
- package/docs/xtkWorkflow.html +28 -0
- package/docs/xtkWrite.html +51 -0
- package/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/application.js +15 -5
- package/src/campaign.js +1 -1
- package/src/soap.js +6 -6
- package/test/application.test.js +21 -6
- package/test/soap.test.js +13 -0
- package/CHANGELOG.md +0 -252
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Connect to mid-sourcing
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<p>From a marketing client connection, one can get a client to a mid server</p>
|
|
7
|
+
|
|
8
|
+
<pre class="code">
|
|
9
|
+
console.log("Connecting to mid server...");
|
|
10
|
+
const credentials = await sdk.Credentials.ofExternalAccount(client, "defaultEmailMid");
|
|
11
|
+
const midClient = await sdk.init(credentials);
|
|
12
|
+
|
|
13
|
+
await midClient.client.logon();
|
|
14
|
+
const datbaseId = await midClient.getOption("XtkDatabaseId");
|
|
15
|
+
console.log("Mid datbaseId: " + datbaseId);
|
|
16
|
+
await midClient.NLWS.xtkSession.testCnx();
|
|
17
|
+
console.log("Disconnecting from mid");
|
|
18
|
+
await midClient.client.logoff();
|
|
19
|
+
</pre>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Observability
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
<p>The Campaign client implements an observer mechanism that you can use to hook into what's hapenning internally.</p>
|
|
8
|
+
|
|
9
|
+
<p>An <b>Observer</b>is an object having any of the following methods:</p>
|
|
10
|
+
|
|
11
|
+
<p>For SOAP calls</p>
|
|
12
|
+
<ul>
|
|
13
|
+
<li>onSOAPCall(soapCall, safeCallData)</li>
|
|
14
|
+
<li>onSOAPCallSuccess(soapCall, safeCallResponse) {}</li>
|
|
15
|
+
<li>onSOAPCallFailure(soapCall, exception) {}</li>
|
|
16
|
+
</ul>
|
|
17
|
+
|
|
18
|
+
<p>For HTTP calls (such as JSP, JSSP...). Note that despite SOAP calls are also HTTP calls, the following callbacks will not be called for SOAP calls.</p>
|
|
19
|
+
|
|
20
|
+
<ul>
|
|
21
|
+
<li>onHTTPCall(request, safeCallData)</li>
|
|
22
|
+
<li>onHTTPCallSuccess(request, safeCallResponse) {}</li>
|
|
23
|
+
<li>onHTTPCallFailure(request, exception) {}</li>
|
|
24
|
+
</ul>
|
|
25
|
+
|
|
26
|
+
<p>The <b>soapCall</b>parameter is the SOAP call which is being observed. In the <b>onSOAPCall</b>callback, the SOAP call has not been executed yet.</p>
|
|
27
|
+
|
|
28
|
+
<p>The <b>request</b>parameter is the HTTP request (as defined in the transport protocol above)</p>
|
|
29
|
+
|
|
30
|
+
<p>The <b>safeCallData</b>and <b>safeCallResponse</b>represent the text XML of the SOAP request and response, but in which all session and security tokens have been replaced with "***" string. Hence the name "safe". You should use those parameters for any logging purpose to avoid leaking credentials.</p>
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<p>The <b>soapCall</b>parameter is a <b>SoapMethodCall</b>object which describes the SOAP call. It has the following public attributes. </p>
|
|
34
|
+
|
|
35
|
+
<ul>
|
|
36
|
+
<li><b>urn</b>is the SOAP URN which corresponds to the Campaign schema id. For instance "xtk:session"</li>
|
|
37
|
+
<li><b>methodName</b>is the name of the method to call. For instance "Logon"</li>
|
|
38
|
+
<li><b>internal</b>is true or false, depending if the SOAP call is an internal SOAP call performed by the framework itself, or if it's a SOAP call issued by a SDK user</li>
|
|
39
|
+
<li><b>request</b>is a literal corresponding to the HTTP request. It's compatible with the <b>transport</b>protocol. It may be undefined if the SOAP call has need been completely built</li>
|
|
40
|
+
<li><b>response</b>is a string containing the XML result of the SOAP call if the call was successful. It may be undefined if the call was not executed yet or if the call failed</li>
|
|
41
|
+
</ul>
|
|
42
|
+
|
|
43
|
+
<p>In version 1.1.7, the observer interface is extended to listen for internal events of the SDK. The <b>event</b>function of the observer, if it exist will be call for each SDK event with 2 parameters: the event itself, and for some events, a parent event. For instance a SOAP response event will have the SOAP request for a parent event.</p>
|
|
44
|
+
|
|
45
|
+
<pre class="code">
|
|
46
|
+
client.registerObserver({
|
|
47
|
+
event: (event, parentEvent) => { ... },
|
|
48
|
+
});
|
|
49
|
+
</pre>
|
|
50
|
+
|
|
51
|
+
<p>The following events are available</p>
|
|
52
|
+
|
|
53
|
+
<table>
|
|
54
|
+
<thead>
|
|
55
|
+
<tr>
|
|
56
|
+
<th>Event name</th>
|
|
57
|
+
<th>Comment / Description</th>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
<tbody>
|
|
61
|
+
<tr>
|
|
62
|
+
<td>SDK//logon</td>
|
|
63
|
+
<td>A client logs on</td>
|
|
64
|
+
</tr>
|
|
65
|
+
<tr>
|
|
66
|
+
<td>SDK//logoff</td>
|
|
67
|
+
<td>A client logs off</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td>CACHE//stats</td>
|
|
71
|
+
<td>Regularly sends stats about internal caches</td>
|
|
72
|
+
</tr>
|
|
73
|
+
<tr>
|
|
74
|
+
<td>SOAP//request</td>
|
|
75
|
+
<td>The SDK executes a SOAP request</td>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr>
|
|
78
|
+
<td>SOAP//response</td>
|
|
79
|
+
<td>The SDK processes the successful response of a SOAP request</td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td>SOAP//failure</td>
|
|
83
|
+
<td>A SOAP request failed</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td>HTTP//request</td>
|
|
87
|
+
<td>The SDK executes an HTTP request</td>
|
|
88
|
+
</tr>
|
|
89
|
+
<tr>
|
|
90
|
+
<td>HTTP//response</td>
|
|
91
|
+
<td>The SDK processes the successful response of an HTTP request</td>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td>HTTP//failure</td>
|
|
95
|
+
<td>An HTTP request failed</td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr>
|
|
98
|
+
<td>CACHE_REFRESHER//start</td>
|
|
99
|
+
<td>A cache auto-refresher starts</td>
|
|
100
|
+
</tr>
|
|
101
|
+
<tr>
|
|
102
|
+
<td>CACHE_REFRESHER//stop</td>
|
|
103
|
+
<td>A cache auto-refresher stops</td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td>CACHE_REFRESHER//tick</td>
|
|
107
|
+
<td>A cache auto-refresh occurs</td>
|
|
108
|
+
</tr>
|
|
109
|
+
<tr>
|
|
110
|
+
<td>CACHE_REFRESHER//loggedOff</td>
|
|
111
|
+
<td>The cache auto-refresh was triggered whereas the client was logged of</td>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td>CACHE_REFRESHER//error</td>
|
|
115
|
+
<td>The cache auto-refresh failed. Auto-refresh will continue.</td>
|
|
116
|
+
</tr>
|
|
117
|
+
<tr>
|
|
118
|
+
<td>CACHE_REFRESHER//abort</td>
|
|
119
|
+
<td>The cache auto-refresh failed because the server does not support it. Auto-refresh will stop.</td>
|
|
120
|
+
</tr>
|
|
121
|
+
<tr>
|
|
122
|
+
<td>CACHE_REFRESHER//response</td>
|
|
123
|
+
<td>The server responded to an auto-refresh request</td>
|
|
124
|
+
</tr>
|
|
125
|
+
</tbody>
|
|
126
|
+
</table>
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
<h1>Logging all SOAP calls</h1>
|
|
131
|
+
|
|
132
|
+
<p>SOAP calls can be logged by setting the <b>traceAPICalls</b>attribute on the client at any time. For security reasons, the security and session tokens values will be replaced by "***" to avoid leaking them</p>
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
<pre class="code">
|
|
136
|
+
client.traceAPICalls(true);
|
|
137
|
+
</pre>
|
|
138
|
+
|
|
139
|
+
<p>This is an example of the logs</p>
|
|
140
|
+
<pre class="code">
|
|
141
|
+
SOAP//request xtk:session#GetOption <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
142
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
143
|
+
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
|
144
|
+
xmlns:ns="http://xml.apache.org/xml-soap">
|
|
145
|
+
<SOAP-ENV:Header>
|
|
146
|
+
<Cookie>__sessiontoken=***</Cookie>
|
|
147
|
+
<X-Security-Token>***</X-Security-Token>
|
|
148
|
+
</SOAP-ENV:Header>
|
|
149
|
+
<SOAP-ENV:Body>
|
|
150
|
+
<m:GetOption xmlns:m="urn:xtk:session" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
|
151
|
+
<sessiontoken xsi:type="xsd:string">***</sessiontoken>
|
|
152
|
+
<name xsi:type="xsd:string">XtkDatabaseId</name>
|
|
153
|
+
</m:GetOption>
|
|
154
|
+
</SOAP-ENV:Body>
|
|
155
|
+
</SOAP-ENV:Envelope>
|
|
156
|
+
|
|
157
|
+
SOAP//response xtk:session#GetOption <?xml version='1.0'?>
|
|
158
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema'
|
|
159
|
+
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
|
|
160
|
+
xmlns:ns='urn:xtk:session'
|
|
161
|
+
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
162
|
+
<SOAP-ENV:Body>
|
|
163
|
+
<GetOptionResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
164
|
+
<pstrValue xsi:type='xsd:string'>uFE80000000000000F1FA913DD7CC7C4804BA419F</pstrValue>
|
|
165
|
+
<pbtType xsi:type='xsd:byte'>6</pbtType>
|
|
166
|
+
</GetOptionResponse>
|
|
167
|
+
</SOAP-ENV:Body>
|
|
168
|
+
</SOAP-ENV:Envelope>
|
|
169
|
+
</pre>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Passwords
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<p>External account passwords can be decrypted using a Cipher. This function is deprecated since version 1.0.0 since it's not guaranteed to work in future versions of Campaign (V8 and above)</p>
|
|
7
|
+
|
|
8
|
+
<pre class="code">
|
|
9
|
+
const cipher = await client.getSecretKeyCipher();
|
|
10
|
+
const password = cipher.decryptPassword(encryptedPassword);
|
|
11
|
+
</pre>
|
|
12
|
+
|
|
13
|
+
<p class="warning">This function is deprecated in version 1.0.0 of the SDK because it may break as we deploy Vault.</p>
|
|
14
|
+
|
|
15
|
+
<p>In order to set the password of an external account, you can use the <b>encryptPassword</b> API as follow</p>
|
|
16
|
+
|
|
17
|
+
<pre class="code">
|
|
18
|
+
const password = await this._client.NLWS.xtkSession.encryptPassword('password');
|
|
19
|
+
const account = {
|
|
20
|
+
xtkschema: "nms:extAccount",
|
|
21
|
+
name: name,
|
|
22
|
+
account: 'admin',
|
|
23
|
+
server: server,
|
|
24
|
+
password: password,
|
|
25
|
+
};
|
|
26
|
+
await this._client.NLWS.xtkSession.Write(account);
|
|
27
|
+
</pre>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Profiles & Subscriptions
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
<p>Create a recipient</p>
|
|
8
|
+
<pre class="code">
|
|
9
|
+
var recipient = {
|
|
10
|
+
xtkschema: "nms:recipient",
|
|
11
|
+
_operation: "insert",
|
|
12
|
+
firstName: "Thomas",
|
|
13
|
+
lastName: "Jordy",
|
|
14
|
+
email: "jordy@adobe.com"
|
|
15
|
+
};
|
|
16
|
+
await NLWS.xtkSession.write(recipient);
|
|
17
|
+
</pre>
|
|
18
|
+
|
|
19
|
+
<p>Create multiple recipients</p>
|
|
20
|
+
<pre class="code">
|
|
21
|
+
var recipients = {
|
|
22
|
+
xtkschema: "nms:recipient",
|
|
23
|
+
recipient: [
|
|
24
|
+
{
|
|
25
|
+
_operation: "insert",
|
|
26
|
+
firstName: "Christophe",
|
|
27
|
+
lastName: "Protat",
|
|
28
|
+
email: "protat@adobe.com"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_operation: "insert",
|
|
32
|
+
firstName: "Eric",
|
|
33
|
+
lastName: "Perrin",
|
|
34
|
+
email: "perrin@adobe.com"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
await NLWS.xtkSession.writeCollection(recipients);
|
|
39
|
+
</pre>
|
|
40
|
+
|
|
41
|
+
<p>List all recipients in Adobe</p>
|
|
42
|
+
<pre class="code">
|
|
43
|
+
var queryDef = {
|
|
44
|
+
schema: "nms:recipient",
|
|
45
|
+
operation: "select",
|
|
46
|
+
select: {
|
|
47
|
+
node: [
|
|
48
|
+
{ expr: "@id" },
|
|
49
|
+
{ expr: "@firstName" },
|
|
50
|
+
{ expr: "@lastName" },
|
|
51
|
+
{ expr: "@email" }
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
where: {
|
|
55
|
+
condition: [
|
|
56
|
+
{ expr: "GetEmailDomain(@email)='adobe.com'" }
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const query = NLWS.xtkQueryDef.create(queryDef);
|
|
61
|
+
var recipients = await query.executeQuery();
|
|
62
|
+
console.log(JSON.stringify(recipients));
|
|
63
|
+
</pre>
|
|
64
|
+
|
|
65
|
+
<p>Count total number of profiles</p>
|
|
66
|
+
<pre class="code">
|
|
67
|
+
var queryDef = {
|
|
68
|
+
schema: "nms:recipient",
|
|
69
|
+
operation: "count"
|
|
70
|
+
}
|
|
71
|
+
var query = NLWS.xtkQueryDef.create(queryDef);
|
|
72
|
+
var count = await query.executeQuery();
|
|
73
|
+
count = XtkCaster.asLong(count.count);
|
|
74
|
+
console.log(count);
|
|
75
|
+
</pre>
|
|
76
|
+
|
|
77
|
+
<p>Update a profile. In this case, use the "@email" attribute as a key. If the `@_key` attribute is not specified, the primary key will be used.</p>
|
|
78
|
+
<pre class="code">
|
|
79
|
+
var recipient = {
|
|
80
|
+
xtkschema: "nms:recipient",
|
|
81
|
+
_key: "@email",
|
|
82
|
+
_operation: "update",
|
|
83
|
+
firstName: "Alexandre",
|
|
84
|
+
email: "amorin@adobe.com"
|
|
85
|
+
};
|
|
86
|
+
await NLWS.xtkSession.write(recipient);
|
|
87
|
+
</pre>
|
|
88
|
+
|
|
89
|
+
<p>Delete a profile</p>
|
|
90
|
+
<pre class="code">
|
|
91
|
+
var recipient = {
|
|
92
|
+
xtkschema: "nms:recipient",
|
|
93
|
+
_key: "@email",
|
|
94
|
+
_operation: "delete",
|
|
95
|
+
email: "amorin@adobe.com"
|
|
96
|
+
};
|
|
97
|
+
await NLWS.xtkSession.write(recipient);
|
|
98
|
+
</pre>
|
|
99
|
+
|
|
100
|
+
<p>Delete a set of profiles, based on condition. For instance delete everyone having an email address in adobe.com domain</p>
|
|
101
|
+
<pre class="code">
|
|
102
|
+
await NLWS.xtkSession.deleteCollection("nms:recipient", { condition: { expr: "GetEmailDomain(@email)='adobe.com'"} });
|
|
103
|
+
</pre>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Push down mechanism
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<p>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.</p>
|
|
7
|
+
|
|
8
|
+
<p>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.</p>
|
|
9
|
+
|
|
10
|
+
<p>Any key/value pairs can be pushed down. This example pushes down the timeout and foo variables to the transport layer.</p>
|
|
11
|
+
<pre class="code">
|
|
12
|
+
NLWS.xml.pushDown({ timeout: 60000, foo: 'bar' }).xtkBuilder.installPackage(dom);
|
|
13
|
+
</pre>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Quick Start
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Here's a small node.js application which displays all the target mappings in Campaign.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<p>Create a new node.js application</p>
|
|
10
|
+
<pre class="code">
|
|
11
|
+
mkdir acc-js-sdk-qstart
|
|
12
|
+
cd acc-js-sdk-qstart
|
|
13
|
+
</pre>
|
|
14
|
+
|
|
15
|
+
<p>Install the SDK</p>
|
|
16
|
+
<pre class="code">
|
|
17
|
+
npm i --save @adobe/acc-js-sdk
|
|
18
|
+
</pre>
|
|
19
|
+
|
|
20
|
+
<p>Now create a simple <b>index.js</b> flle. Replace the endppoint and credentials with your own</p>
|
|
21
|
+
|
|
22
|
+
<pre class="code">
|
|
23
|
+
const sdk = require('@adobe/acc-js-sdk');
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
// Display the SDK version
|
|
27
|
+
const version = sdk.getSDKVersion();
|
|
28
|
+
console.log(`${version.description} version ${version.version}`);
|
|
29
|
+
|
|
30
|
+
// Logon to a Campaign instance with user and password
|
|
31
|
+
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
32
|
+
"https://myInstance.campaign.adobe.com",
|
|
33
|
+
"admin", "admin");
|
|
34
|
+
const client = await sdk.init(connectionParameters);
|
|
35
|
+
await client.logon();
|
|
36
|
+
const NLWS = client.NLWS;
|
|
37
|
+
|
|
38
|
+
// Get and display the list of target mappings
|
|
39
|
+
const queryDef = {
|
|
40
|
+
schema: "nms:deliveryMapping",
|
|
41
|
+
operation: "select",
|
|
42
|
+
select: {
|
|
43
|
+
node: [
|
|
44
|
+
{ expr: "@id" },
|
|
45
|
+
{ expr: "@name" },
|
|
46
|
+
{ expr: "@label" },
|
|
47
|
+
{ expr: "@schema" }
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const query = NLWS.xtkQueryDef.create(queryDef);
|
|
52
|
+
const mappings = await query.executeQuery();
|
|
53
|
+
console.log(`Target mappings: ${JSON.stringify(mappings)}`);
|
|
54
|
+
})().catch((error) => {
|
|
55
|
+
console.log(error);
|
|
56
|
+
});
|
|
57
|
+
</pre>
|
|
58
|
+
|
|
59
|
+
<p>Run it</p>
|
|
60
|
+
<pre class="code">
|
|
61
|
+
node index.js
|
|
62
|
+
</pre>
|
|
63
|
+
|
|
64
|
+
<p>It will display something like this</p>
|
|
65
|
+
<pre class="code">
|
|
66
|
+
ACC Javascript SDK version 1.1.9
|
|
67
|
+
Target mappings: {"deliveryMapping":[{"id":"1747","label":"Recipients","name":"mapRecipient","schema":"nms:recipient"},{"id":"1826","label":"Subscriptions","name":"mapSubscribe","schema":"nms:subscription"},{"id":"1827","label":"Operators","name":"mapOperator","schema":"xtk:operator"},{"id":"1828","label":"External file","name":"mapAny","schema":""},{"id":"1830","label":"Visitors","name":"mapVisitor","schema":"nms:visitor"},{"id":"2035","label":"Real time event","name":"mapRtEvent","schema":"nms:rtEvent"},{"id":"2036","label":"Batch event","name":"mapBatchEvent","schema":"nms:batchEvent"},{"id":"2070","label":"Subscriber applications","name":"mapAppSubscriptionRcp","schema":"nms:appSubscriptionRcp"}]}
|
|
68
|
+
</pre>
|
|
69
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Releasing a new version
|
|
4
|
+
---
|
|
5
|
+
<p></p>
|
|
6
|
+
|
|
7
|
+
<ul>
|
|
8
|
+
<li>First, increase the version in <b>package.json</b></li>
|
|
9
|
+
<li>Run <b>npm install</b> to update dependencies</li>
|
|
10
|
+
</ul>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<p>Then, make sure that the <a href="{{ site.baseurl }}/checkList.html">Commit Checklist</a> is fullfiled.</p>
|
|
14
|
+
|
|
15
|
+
<ul>
|
|
16
|
+
<li>Check that tests run with 100% coverage</li>
|
|
17
|
+
<li>Check and resolve any security issues</li>
|
|
18
|
+
<li>Check if there are any code warnings</li>
|
|
19
|
+
<li>Check that JavaScript documentation builds and is complete</li>
|
|
20
|
+
<li>Check that your new features or fixed are documented and appear in the changelog</li>
|
|
21
|
+
<li>Check that the client-side library builds and work</li>
|
|
22
|
+
</ul>
|
|
23
|
+
|
|
24
|
+
<p>In a nutshell</p>
|
|
25
|
+
|
|
26
|
+
<pre class="code">
|
|
27
|
+
npm i
|
|
28
|
+
npm run unit-tests
|
|
29
|
+
npm audit
|
|
30
|
+
node_modules/jshint/bin/jshint src/
|
|
31
|
+
npm run jsdoc
|
|
32
|
+
open ./docs/jsdoc/index.html
|
|
33
|
+
node ./compile.js
|
|
34
|
+
</pre>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<p>To release and deploy to npm</p>
|
|
38
|
+
|
|
39
|
+
<p>Push a commit with message <b>Release 1.2.3</b> in master<p>
|
|
40
|
+
|
|
41
|
+
<pre class="code">
|
|
42
|
+
git commit -m "Release 1.2.3"
|
|
43
|
+
git push origin
|
|
44
|
+
</pre>
|
|
45
|
+
|
|
46
|
+
<p class="info">There's a publication action that will publish released automatically when there's a commit named "Release ..." in master AND the version matches the one in package.json
|
|
47
|
+
Do not create a git tag for this version, the publication hook will take care of it. If you have created a tag with the release name, the publication will fail
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
<p>You can follow the results of the actions <a href="https://github.com/adobe/acc-js-sdk/actions">here</a></p>
|
|
51
|
+
|
|
52
|
+
<p class="info">It usually takes a few hours for the package to show up in the <a href="https://www.npmjs.com/package/@adobe/acc-js-sdk">NPM UI</a> but you can still use the package by using npm</p>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Sample Code
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<p>The <b>samples</b> folder contains several samples illustrating how to use the various Campaing APIs.</p>
|
|
7
|
+
|
|
8
|
+
<p>A sample file looks like this</p>
|
|
9
|
+
|
|
10
|
+
<ul>
|
|
11
|
+
<li>It includes the <b>utils</b> library which contains a few helper functions.s</li>
|
|
12
|
+
<li>It starts with an asynchronous auto-execute function that is used to run the sample from the command line</li>
|
|
13
|
+
<li>This function contains one or more calls to the <b>utils.sample</b> function. Each such call describes and execute a sample.</li>
|
|
14
|
+
<li>A sample file should not do anything else or have any side effect: all the actual sample code should be inside calls to <b>utils.sample</b></li>
|
|
15
|
+
</ul>
|
|
16
|
+
|
|
17
|
+
<p class="info"> Note the use of <b>await</b> when calling <b>utils.sample</b></p>
|
|
18
|
+
|
|
19
|
+
<pre class="code">
|
|
20
|
+
const utils = require("./utils.js");
|
|
21
|
+
( async () => {
|
|
22
|
+
await utils.sample({
|
|
23
|
+
title: "The Sample title",
|
|
24
|
+
labels: [ "xtk:queryDef", "Basics", "Query", "QueryDef", "Get" ],
|
|
25
|
+
description: `A description of the sample`,
|
|
26
|
+
code: async() => {
|
|
27
|
+
//... Sample code goes there
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await utils.sample({
|
|
32
|
+
title: "A Second sample",
|
|
33
|
+
labels: [ "xtk:queryDef", "Basics", "Query", "QueryDef", "Get" ],
|
|
34
|
+
description: `A description of the sample`,
|
|
35
|
+
code: async() => {
|
|
36
|
+
//... Sample code goes there
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
})();
|
|
40
|
+
</pre>
|
|
41
|
+
|
|
42
|
+
<p>The <b>utils.sample</b> function takes 1 parameters describing the sample:</p>
|
|
43
|
+
<ul>
|
|
44
|
+
<li><b>title</b> is the sample title, a short, human friendly name for the sample</li>
|
|
45
|
+
<li><b>labels</b> is a list of keywords that can be used to retreive the samples in a large list</li>
|
|
46
|
+
<li><b>description</b> is a longer, multi-line description of the sample</li>
|
|
47
|
+
<li><b>code</b> is an async function, the code of the sample</li>
|
|
48
|
+
</ul>
|
|
49
|
+
|
|
50
|
+
<p>Most of the samples - actually all of them except some specific samples needing specific logon - will also use the `utils.logon` function. This is a helper function which will perform the Campaign Logon and Logoff for you, and call your callback function with pre-initialized `client` and `NLWS` objects</p>
|
|
51
|
+
|
|
52
|
+
<p class="info"> Note the use of <b>await</b> when calling <b>utils.logon</b></p>
|
|
53
|
+
|
|
54
|
+
<pre class="code">
|
|
55
|
+
await utils.sample({
|
|
56
|
+
title: "The Sample title",
|
|
57
|
+
labels: [ "xtk:queryDef", "Basics", "Query", "QueryDef", "Get" ],
|
|
58
|
+
description: `A description of the sample`,
|
|
59
|
+
code: async() => {
|
|
60
|
+
return await utils.logon(async (client, NLWS) => {
|
|
61
|
+
//... Sample code goes there
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
</pre>
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
<h1>Running samples</h1>
|
|
69
|
+
<p>Samples can be run from the command line. First, set 3 environment variables with your instance credentials:</p>
|
|
70
|
+
|
|
71
|
+
<pre class="code">
|
|
72
|
+
export ACC_URL=https://myInstance.campaign.adobe.com
|
|
73
|
+
export ACC_USERadmin
|
|
74
|
+
export ACC_PASSWORD=...
|
|
75
|
+
</pre>
|
|
76
|
+
|
|
77
|
+
<p>and then run the samples</p>
|
|
78
|
+
<pre class="code">
|
|
79
|
+
node samples/000\ -\ basics\ -\ logon.js
|
|
80
|
+
</pre>`
|
|
81
|
+
|
|
82
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: SimpleJson format
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<p>The <b>SimpleJson</b> format is the format used by default by the SDK to conver between Campaign XML and JSON</p>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<ul>
|
|
10
|
+
<li>XML attributes are JSON properties (without the “@” sign)</li>
|
|
11
|
+
<li>XML elements are JSON objects</li>
|
|
12
|
+
<li>XML collections are JSON arrays</li>
|
|
13
|
+
<li>XML text use “$” sign</li>
|
|
14
|
+
</ul>
|
|
15
|
+
|
|
16
|
+
<p></p>
|
|
17
|
+
<pre class="code">
|
|
18
|
+
<book title="A confederacy of dunces"> {
|
|
19
|
+
<author>John Kennedy Toole</author> "$author": "John Kennedy Toole",
|
|
20
|
+
"chapter": [
|
|
21
|
+
<chapter name="Chapter I" pages="20"> { "name": "Chapter I",
|
|
22
|
+
</chapter> "pages": 20 },
|
|
23
|
+
<chapter name="Chapter II" pages="34"> { "name": "Chapter II",
|
|
24
|
+
</chapter> "pages": 3 },
|
|
25
|
+
]
|
|
26
|
+
</book> }
|
|
27
|
+
</pre>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<p>The XML root element tag is automatically determined by the SDK as it's generating the XML, usually from the current schema name.</p>
|
|
31
|
+
|
|
32
|
+
<pre class="code">
|
|
33
|
+
XML: <root/>
|
|
34
|
+
JSON: {}
|
|
35
|
+
</pre>
|
|
36
|
+
|
|
37
|
+
<p>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.
|
|
38
|
+
Values in JSON attributes can be indifferently typed (ex: number, boolean), or strings (ex: "3" instead of just 3) depending if the conversion could determine the attribute type or not.
|
|
39
|
+
API users should expect and handle both value and use the `XtkCaster` object to ensure proper conversion when using.</p>
|
|
40
|
+
|
|
41
|
+
<pre class="code">
|
|
42
|
+
XML <root hello="world" count="3" ok="true"/>
|
|
43
|
+
JSON: { hello:"world", count:"3", ok:"true" }
|
|
44
|
+
</pre>
|
|
45
|
+
|
|
46
|
+
<p>XML elements are mapped to JSON objects</p>
|
|
47
|
+
|
|
48
|
+
<pre class="code">
|
|
49
|
+
XML: <root><item id="1"/></root>
|
|
50
|
+
JSON: { item: { id:"1" } }
|
|
51
|
+
</pre>
|
|
52
|
+
|
|
53
|
+
<p>If the parent element tag ends with <b>-collection</b> 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. </p>
|
|
54
|
+
|
|
55
|
+
<pre class="code">
|
|
56
|
+
XML: <root-collection><item id=1/></root>
|
|
57
|
+
JSON: { item: [ { id:"1" } ] }
|
|
58
|
+
</pre>
|
|
59
|
+
|
|
60
|
+
<p>When an XML element is repeated, an JSON array is used</p>
|
|
61
|
+
|
|
62
|
+
<pre class="code">
|
|
63
|
+
XML: <root><item id=1/><item id=2/></root>
|
|
64
|
+
JSON: { item: [ { id:"1" }, { id:"2" } ] }
|
|
65
|
+
</pre>
|
|
66
|
+
|
|
67
|
+
<p>Text of XML element is handle with the <b>$</b> sign in the JSON attribute name, or with a child JSON object name <b>$</b></p>
|
|
68
|
+
|
|
69
|
+
<p>Text of the root element</p>
|
|
70
|
+
<pre class="code">
|
|
71
|
+
XML: <root>Hello</root>
|
|
72
|
+
JSON: { $: "Hello" }
|
|
73
|
+
</pre>
|
|
74
|
+
|
|
75
|
+
<p>Text of a child element</p>
|
|
76
|
+
<pre class="code">
|
|
77
|
+
XML: <root><item>Hello</item></root>`
|
|
78
|
+
JSON: { $item: "Hello" }
|
|
79
|
+
Alternative JSON: { item: { $: "Hello" } }
|
|
80
|
+
</pre>
|
|
81
|
+
|
|
82
|
+
<p>If an element contains both text, and children, you need to use the alternative <b>$</b> syntax</p>
|
|
83
|
+
<pre class="code">
|
|
84
|
+
XML: <root><item>Hello<child id="1"/>
|
|
85
|
+
</item>
|
|
86
|
+
</root>
|
|
87
|
+
JSON: { item: { $: "Hello", child: { id:"1" } }
|
|
88
|
+
</pre>
|