@adobe/acc-js-sdk 1.1.62 → 1.2.0
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/.cursor/commands/opsx-apply.md +152 -0
- package/.cursor/commands/opsx-archive.md +157 -0
- package/.cursor/commands/opsx-explore.md +173 -0
- package/.cursor/commands/opsx-propose.md +106 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +156 -0
- package/.cursor/skills/openspec-archive-change/SKILL.md +114 -0
- package/.cursor/skills/openspec-explore/SKILL.md +288 -0
- package/.cursor/skills/openspec-propose/SKILL.md +110 -0
- package/.eslintrc.js +2 -2
- package/.github/prompts/opsx-apply.prompt.md +149 -0
- package/.github/prompts/opsx-archive.prompt.md +154 -0
- package/.github/prompts/opsx-explore.prompt.md +170 -0
- package/.github/prompts/opsx-propose.prompt.md +103 -0
- package/.github/skills/openspec-apply-change/SKILL.md +156 -0
- package/.github/skills/openspec-archive-change/SKILL.md +114 -0
- package/.github/skills/openspec-explore/SKILL.md +288 -0
- package/.github/skills/openspec-propose/SKILL.md +110 -0
- package/.github/workflows/codeql-analysis.yml +5 -4
- package/.github/workflows/npm-publish.yml +3 -3
- package/AGENTS.md +117 -0
- package/CLAUDE.md +2 -0
- package/MIGRATION.md +10 -0
- package/README.md +6 -2
- package/ai-docs/coding-rules.md +95 -0
- package/ai-docs/tech-stack.md +43 -0
- package/babel.config.js +5 -0
- package/docs/changeLog.html +28 -2
- package/docs/checkList.html +2 -2
- package/docs/quickstart.html +2 -1
- package/docs/release.html +1 -1
- package/openspec/config.yaml +20 -0
- package/package-lock.json +6055 -4036
- package/package.json +9 -7
- package/src/AGENTS.md +98 -0
- package/src/CLAUDE.md +2 -0
- package/src/application.js +637 -637
- package/src/cache.js +133 -133
- package/src/cacheRefresher.js +190 -190
- package/src/campaign.js +532 -532
- package/src/client.js +1539 -1537
- package/src/crypto.js +52 -52
- package/src/domUtil.js +346 -346
- package/src/entityAccessor.js +61 -61
- package/src/index.js +83 -83
- package/src/methodCache.js +69 -69
- package/src/optionCache.js +26 -26
- package/src/soap.js +321 -322
- package/src/testUtil.js +13 -13
- package/src/transport.js +70 -70
- package/src/util.js +147 -147
- package/src/web/bundler.js +5 -5
- package/src/xtkCaster.js +258 -258
- package/src/xtkEntityCache.js +34 -34
- package/src/xtkJob.js +185 -185
- package/test/AGENTS.md +37 -0
- package/test/CLAUDE.md +2 -0
- package/test/cacheRefresher.test.js +7 -0
- package/test/client.test.js +90 -78
- package/test/jest.config.js +6 -0
- package/test/observability.test.js +6 -1
- package/test/xtkJob.test.js +2 -2
package/src/soap.js
CHANGED
|
@@ -10,10 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
(function() {
|
|
13
|
-
"use strict";
|
|
14
|
-
/*jshint sub:true*/
|
|
13
|
+
"use strict";
|
|
15
14
|
|
|
16
|
-
/**********************************************************************************
|
|
15
|
+
/**********************************************************************************
|
|
17
16
|
*
|
|
18
17
|
* SOAP calls wrapper
|
|
19
18
|
*
|
|
@@ -46,28 +45,28 @@ governing permissions and limitations under the License.
|
|
|
46
45
|
*
|
|
47
46
|
*********************************************************************************/
|
|
48
47
|
|
|
49
|
-
const { DomUtil, DomException } = require('./domUtil.js');
|
|
50
|
-
const XtkCaster = require('./xtkCaster.js').XtkCaster;
|
|
51
|
-
const { CampaignException, makeCampaignException } = require('./campaign.js');
|
|
52
|
-
const SOAP_ENCODING_NATIVE = "http://schemas.xmlsoap.org/soap/encoding/";
|
|
53
|
-
const SOAP_ENCODING_XML = "http://xml.apache.org/xml-soap/literalxml";
|
|
54
|
-
const NS_ENV = "http://schemas.xmlsoap.org/soap/envelope/";
|
|
55
|
-
const NS_XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
56
|
-
const NS_XSD = "http://www.w3.org/2001/XMLSchema";
|
|
48
|
+
const { DomUtil, DomException } = require('./domUtil.js');
|
|
49
|
+
const XtkCaster = require('./xtkCaster.js').XtkCaster;
|
|
50
|
+
const { CampaignException, makeCampaignException } = require('./campaign.js');
|
|
51
|
+
const SOAP_ENCODING_NATIVE = "http://schemas.xmlsoap.org/soap/encoding/";
|
|
52
|
+
const SOAP_ENCODING_XML = "http://xml.apache.org/xml-soap/literalxml";
|
|
53
|
+
const NS_ENV = "http://schemas.xmlsoap.org/soap/envelope/";
|
|
54
|
+
const NS_XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
55
|
+
const NS_XSD = "http://www.w3.org/2001/XMLSchema";
|
|
57
56
|
|
|
58
57
|
|
|
59
|
-
/**
|
|
58
|
+
/**
|
|
60
59
|
* @namespace SOAP
|
|
61
60
|
*/
|
|
62
61
|
|
|
63
62
|
|
|
64
63
|
|
|
65
|
-
/**
|
|
64
|
+
/**
|
|
66
65
|
* @namespace SOAP
|
|
67
66
|
*/
|
|
68
67
|
|
|
69
68
|
|
|
70
|
-
/**
|
|
69
|
+
/**
|
|
71
70
|
* Creates a SOAP method call object which encapsulates a SOAP call and helper methods to constructs
|
|
72
71
|
* the call and decode the result.
|
|
73
72
|
*
|
|
@@ -83,47 +82,47 @@ const NS_XSD = "http://www.w3.org/2001/XMLSchema";
|
|
|
83
82
|
* @param {string} bearerToken The bearer token to use for HTTP requests. Only required for ImsBearerToken authentication
|
|
84
83
|
* @memberof SOAP
|
|
85
84
|
*/
|
|
86
|
-
class SoapMethodCall {
|
|
85
|
+
class SoapMethodCall {
|
|
87
86
|
|
|
88
87
|
constructor(transport, urn, methodName, sessionToken, securityToken, userAgentString, pushDownOptions, extraHttpHeaders, bearerToken) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
this.request = undefined; // The HTTP request (object literal passed to the transport layer)
|
|
89
|
+
this.requestOptions = undefined;
|
|
90
|
+
this.response = undefined; // The HTTP response object (in case of success)
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
// Current URN and method (for error reporting)
|
|
93
|
+
this.urn = urn;
|
|
94
|
+
this.methodName = methodName;
|
|
95
|
+
this.isStatic = false;
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
// Soap calls marked as internal are calls performed by the framework internally
|
|
98
|
+
// (such as GetEntityIfMoreRecent calls needed to lookup schemas)
|
|
99
|
+
this.internal = false;
|
|
100
|
+
// Enable soap retry
|
|
101
|
+
this.retry = true;
|
|
102
|
+
this._retryCount = 0;
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
this._sessionToken = sessionToken || "";
|
|
105
|
+
this._securityToken = securityToken || "";
|
|
106
|
+
this._bearerToken = bearerToken; // may be undefined if not using bearer token authentication
|
|
107
|
+
this._userAgentString = userAgentString;
|
|
108
|
+
this._pushDownOptions = pushDownOptions || {};
|
|
109
|
+
this._charset = this._pushDownOptions.charset || '';
|
|
110
|
+
this._extraHttpHeaders = extraHttpHeaders || {};
|
|
112
111
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
// THe SOAP call being built
|
|
113
|
+
this._doc = undefined; // XML document for SOAP call
|
|
114
|
+
this._root = undefined; // Root of the document
|
|
115
|
+
this._header = undefined; // SOAP-ENV:Header
|
|
116
|
+
this._data = undefined; // SOAP-ENV:Body
|
|
117
|
+
this._method = undefined; // XML element for the method
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
this._initMessage(urn, methodName, SOAP_ENCODING_NATIVE);
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
// Current DOM element for reading result (getNext* functions)
|
|
122
|
+
this.elemCurrent = undefined;
|
|
124
123
|
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
// Transport object to perform HTTP request (request or mock)
|
|
125
|
+
this._transport = transport;
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
/**
|
|
@@ -131,9 +130,9 @@ class SoapMethodCall {
|
|
|
131
130
|
* @returns {boolean} indicates if the call requires a Logon first
|
|
132
131
|
*/
|
|
133
132
|
requiresLogon() {
|
|
134
|
-
|
|
133
|
+
const requiresLogon = !(this.urn === "xtk:session" &&
|
|
135
134
|
(this.methodName === "Logon" || this.methodName === "BearerTokenLogon") ) ;
|
|
136
|
-
|
|
135
|
+
return requiresLogon;
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
/**
|
|
@@ -145,24 +144,24 @@ class SoapMethodCall {
|
|
|
145
144
|
* @param {string} encoding the SOAP encoding style (SOAP-ENV:encodingStyle)
|
|
146
145
|
*/
|
|
147
146
|
_initMessage(urn, method, encoding) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
this.urn = urn;
|
|
148
|
+
this.methodName = method;
|
|
149
|
+
this.encoding = encoding;
|
|
150
|
+
var urnPath = "urn:" + urn;
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
this._doc = DomUtil.parse(`<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:xsd='${NS_XSD}' xmlns:xsi='${NS_XSI}' xmlns:SOAP-ENV='${NS_ENV}' xmlns:ns='http://xml.apache.org/xml-soap'></SOAP-ENV:Envelope>`);
|
|
153
|
+
this._root = this._doc.documentElement;
|
|
155
154
|
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
this._header = this._doc.createElement(`SOAP-ENV:Header`);
|
|
156
|
+
this._root.appendChild(this._header);
|
|
158
157
|
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
this._data = this._doc.createElement(`SOAP-ENV:Body`);
|
|
159
|
+
this._root.appendChild(this._data);
|
|
161
160
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
this._method = this._doc.createElement(`m:${method}`);
|
|
162
|
+
this._method.setAttribute(`xmlns:m`, urnPath);
|
|
163
|
+
this._method.setAttribute(`SOAP-ENV:encodingStyle`, encoding);
|
|
164
|
+
this._data.appendChild(this._method);
|
|
166
165
|
}
|
|
167
166
|
|
|
168
167
|
/**
|
|
@@ -176,14 +175,14 @@ class SoapMethodCall {
|
|
|
176
175
|
* @returns the XML element to be added to the SOAP call
|
|
177
176
|
*/
|
|
178
177
|
_addNode(tag, type, value, encoding) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
const node = this._doc.createElement(tag);
|
|
179
|
+
node.setAttribute("xsi:type", type);
|
|
180
|
+
if (encoding != this.encoding)
|
|
182
181
|
node.setAttribute("SOAP-ENV:encodingStyle", encoding);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
if (value !== null && value !== undefined)
|
|
183
|
+
node.textContent = value;
|
|
184
|
+
this._method.appendChild(node);
|
|
185
|
+
return node;
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
/**
|
|
@@ -192,8 +191,8 @@ class SoapMethodCall {
|
|
|
192
191
|
* @param {*} value the parameter value, which will be casted to a byte according to xtk rules
|
|
193
192
|
*/
|
|
194
193
|
writeByte(tag, value) {
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
value = XtkCaster.asByte(value);
|
|
195
|
+
this._addNode(tag, "xsd:byte", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
197
196
|
}
|
|
198
197
|
|
|
199
198
|
/**
|
|
@@ -202,8 +201,8 @@ class SoapMethodCall {
|
|
|
202
201
|
* @param {*} value the parameter value, which will be casted to a boolean according to xtk rules
|
|
203
202
|
*/
|
|
204
203
|
writeBoolean(tag, value) {
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
value = XtkCaster.asBoolean(value);
|
|
205
|
+
this._addNode(tag, "xsd:boolean", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
207
206
|
}
|
|
208
207
|
|
|
209
208
|
/**
|
|
@@ -212,8 +211,8 @@ class SoapMethodCall {
|
|
|
212
211
|
* @param {*} value the parameter value, which will be casted to a short according to xtk rules
|
|
213
212
|
*/
|
|
214
213
|
writeShort(tag, value) {
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
value = XtkCaster.asShort(value);
|
|
215
|
+
this._addNode(tag, "xsd:short", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
/**
|
|
@@ -222,8 +221,8 @@ class SoapMethodCall {
|
|
|
222
221
|
* @param {*} value the parameter value, which will be casted to a int32 according to xtk rules
|
|
223
222
|
*/
|
|
224
223
|
writeLong(tag, value) {
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
value = XtkCaster.asLong(value);
|
|
225
|
+
this._addNode(tag, "xsd:int", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
/**
|
|
@@ -232,8 +231,8 @@ class SoapMethodCall {
|
|
|
232
231
|
* @param {*} value the parameter value, which will be casted to a int64 according to xtk rules
|
|
233
232
|
*/
|
|
234
233
|
writeInt64(tag, value) {
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
value = XtkCaster.asInt64(value);
|
|
235
|
+
this._addNode(tag, "xsd:long", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
237
236
|
}
|
|
238
237
|
|
|
239
238
|
/**
|
|
@@ -242,8 +241,8 @@ class SoapMethodCall {
|
|
|
242
241
|
* @param {*} value the parameter value, which will be casted to a float according to xtk rules
|
|
243
242
|
*/
|
|
244
243
|
writeFloat(tag, value) {
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
value = XtkCaster.asNumber(value);
|
|
245
|
+
this._addNode(tag, "xsd:float", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
247
246
|
}
|
|
248
247
|
|
|
249
248
|
/**
|
|
@@ -252,8 +251,8 @@ class SoapMethodCall {
|
|
|
252
251
|
* @param {*} value the parameter value, which will be casted to a double according to xtk rules
|
|
253
252
|
*/
|
|
254
253
|
writeDouble(tag, value) {
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
value = XtkCaster.asNumber(value);
|
|
255
|
+
this._addNode(tag, "xsd:double", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
/**
|
|
@@ -262,8 +261,8 @@ class SoapMethodCall {
|
|
|
262
261
|
* @param {*} value the parameter value, which will be casted to a string according to xtk rules
|
|
263
262
|
*/
|
|
264
263
|
writeString(tag, value) {
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
value = XtkCaster.asString(value);
|
|
265
|
+
this._addNode(tag, "xsd:string", value, SOAP_ENCODING_NATIVE);
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
/**
|
|
@@ -272,8 +271,8 @@ class SoapMethodCall {
|
|
|
272
271
|
* @param {*} value the parameter value, which will be casted to a timestamp according to xtk rules
|
|
273
272
|
*/
|
|
274
273
|
writeTimestamp(tag, value) {
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
value = XtkCaster.asTimestamp(value);
|
|
275
|
+
this._addNode(tag, "xsd:datetime", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
277
276
|
}
|
|
278
277
|
|
|
279
278
|
/**
|
|
@@ -282,8 +281,8 @@ class SoapMethodCall {
|
|
|
282
281
|
* @param {*} value the parameter value, which will be casted to a date according to xtk rules
|
|
283
282
|
*/
|
|
284
283
|
writeDate(tag, value) {
|
|
285
|
-
|
|
286
|
-
|
|
284
|
+
value = XtkCaster.asDate(value);
|
|
285
|
+
this._addNode(tag, "xsd:date", XtkCaster.asString(value), SOAP_ENCODING_NATIVE);
|
|
287
286
|
}
|
|
288
287
|
|
|
289
288
|
/**
|
|
@@ -292,12 +291,12 @@ class SoapMethodCall {
|
|
|
292
291
|
* @param {Element} value the parameter value (XML element)
|
|
293
292
|
*/
|
|
294
293
|
writeElement(tag, element) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
294
|
+
const node = this._addNode(tag, "ns:Element", null, SOAP_ENCODING_XML);
|
|
295
|
+
if (element !== null && element !== undefined) {
|
|
296
|
+
if (element.nodeType === 9) element = element.documentElement;
|
|
297
|
+
const child = this._doc.importNode(element, true);
|
|
298
|
+
node.appendChild(child);
|
|
299
|
+
}
|
|
301
300
|
}
|
|
302
301
|
|
|
303
302
|
/**
|
|
@@ -306,12 +305,12 @@ class SoapMethodCall {
|
|
|
306
305
|
* @param {Document} value the parameter value (XML document)
|
|
307
306
|
*/
|
|
308
307
|
writeDocument(tag, document) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
308
|
+
const node = this._addNode(tag, "", null, SOAP_ENCODING_XML);
|
|
309
|
+
if (document !== null && document !== undefined) {
|
|
310
|
+
const element = document.nodeType === 1 ? document : document.documentElement;
|
|
311
|
+
const child = this._doc.importNode(element, true);
|
|
312
|
+
node.appendChild(child);
|
|
313
|
+
}
|
|
315
314
|
}
|
|
316
315
|
|
|
317
316
|
/**
|
|
@@ -323,14 +322,14 @@ class SoapMethodCall {
|
|
|
323
322
|
* @throws {CampaignException} if the current return value type does not match the expected type
|
|
324
323
|
*/
|
|
325
324
|
_checkTypeMatch(type) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
325
|
+
if (this.elemCurrent === null || this.elemCurrent === undefined) {
|
|
326
|
+
throw new CampaignException(this, 400, `Missing parameter for method '${this.methodName}' of urn '${this.urn}'`);
|
|
327
|
+
} else if ( type != "ns:Document") {
|
|
328
|
+
var xsiType = this.elemCurrent.getAttribute("xsi:type");
|
|
329
|
+
if (xsiType === null || xsiType === undefined || xsiType !== type) {
|
|
330
|
+
throw new CampaignException(this, 400, `Parameter type mismatch for method '${this.methodName}' of urn '${this.urn}'. Expected '${type}', got '${xsiType}'`);
|
|
333
331
|
}
|
|
332
|
+
}
|
|
334
333
|
}
|
|
335
334
|
|
|
336
335
|
/**
|
|
@@ -343,16 +342,16 @@ class SoapMethodCall {
|
|
|
343
342
|
* @returns the Entity DOM Element if there's one, or null if there isn't. The currentElement pointer will be updated accordingly
|
|
344
343
|
*/
|
|
345
344
|
getEntity() {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
345
|
+
if (!this.elemCurrent)
|
|
346
|
+
return null;
|
|
347
|
+
if (this.elemCurrent.getAttribute("xsi:type") != "ns:Element")
|
|
348
|
+
return null;
|
|
349
|
+
if (this.elemCurrent.tagName != "entity" && this.elemCurrent.tagName != "this")
|
|
350
|
+
return null;
|
|
351
|
+
var entity = this.elemCurrent;
|
|
352
|
+
entity = DomUtil.getFirstChildElement(entity);
|
|
353
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
354
|
+
return entity;
|
|
356
355
|
}
|
|
357
356
|
|
|
358
357
|
/**
|
|
@@ -361,10 +360,10 @@ class SoapMethodCall {
|
|
|
361
360
|
* @returns {string} the string result value
|
|
362
361
|
*/
|
|
363
362
|
getNextString() {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
363
|
+
this._checkTypeMatch("xsd:string");
|
|
364
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
365
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
366
|
+
return value;
|
|
368
367
|
}
|
|
369
368
|
|
|
370
369
|
/**
|
|
@@ -373,10 +372,10 @@ class SoapMethodCall {
|
|
|
373
372
|
* @returns {string} the primary key string result value
|
|
374
373
|
*/
|
|
375
374
|
getNextPrimaryKey() {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
375
|
+
this._checkTypeMatch("xsd:primarykey");
|
|
376
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
377
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
378
|
+
return value;
|
|
380
379
|
}
|
|
381
380
|
|
|
382
381
|
/**
|
|
@@ -385,10 +384,10 @@ class SoapMethodCall {
|
|
|
385
384
|
* @returns {number} the boolean result value
|
|
386
385
|
*/
|
|
387
386
|
getNextBoolean() {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
387
|
+
this._checkTypeMatch("xsd:boolean");
|
|
388
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
389
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
390
|
+
return XtkCaster.asBoolean(value);
|
|
392
391
|
}
|
|
393
392
|
|
|
394
393
|
/**
|
|
@@ -397,10 +396,10 @@ class SoapMethodCall {
|
|
|
397
396
|
* @returns {number} the byte result value
|
|
398
397
|
*/
|
|
399
398
|
getNextByte() {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
this._checkTypeMatch("xsd:byte");
|
|
400
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
401
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
402
|
+
return XtkCaster.asByte(value);
|
|
404
403
|
}
|
|
405
404
|
|
|
406
405
|
/**
|
|
@@ -409,10 +408,10 @@ class SoapMethodCall {
|
|
|
409
408
|
* @returns {number} the short result value
|
|
410
409
|
*/
|
|
411
410
|
getNextShort() {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
411
|
+
this._checkTypeMatch("xsd:short");
|
|
412
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
413
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
414
|
+
return XtkCaster.asShort(value);
|
|
416
415
|
}
|
|
417
416
|
|
|
418
417
|
/**
|
|
@@ -421,10 +420,10 @@ class SoapMethodCall {
|
|
|
421
420
|
* @returns {number} the int32 result value
|
|
422
421
|
*/
|
|
423
422
|
getNextLong() {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
423
|
+
this._checkTypeMatch("xsd:int");
|
|
424
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
425
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
426
|
+
return XtkCaster.asLong(value);
|
|
428
427
|
}
|
|
429
428
|
|
|
430
429
|
/**
|
|
@@ -434,10 +433,10 @@ class SoapMethodCall {
|
|
|
434
433
|
* @returns {string} the int64 result value as a string
|
|
435
434
|
*/
|
|
436
435
|
getNextInt64() {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
436
|
+
this._checkTypeMatch("xsd:long");
|
|
437
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
438
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
439
|
+
return value;
|
|
441
440
|
}
|
|
442
441
|
|
|
443
442
|
/**
|
|
@@ -446,10 +445,10 @@ class SoapMethodCall {
|
|
|
446
445
|
* @returns {number} the float result value
|
|
447
446
|
*/
|
|
448
447
|
getNextFloat() {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
448
|
+
this._checkTypeMatch("xsd:float");
|
|
449
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
450
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
451
|
+
return XtkCaster.asFloat(value);
|
|
453
452
|
}
|
|
454
453
|
|
|
455
454
|
/**
|
|
@@ -458,10 +457,10 @@ class SoapMethodCall {
|
|
|
458
457
|
* @returns {number} the double result value
|
|
459
458
|
*/
|
|
460
459
|
getNextDouble() {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
460
|
+
this._checkTypeMatch("xsd:double");
|
|
461
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
462
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
463
|
+
return XtkCaster.asDouble(value);
|
|
465
464
|
}
|
|
466
465
|
|
|
467
466
|
/**
|
|
@@ -470,10 +469,10 @@ class SoapMethodCall {
|
|
|
470
469
|
* @returns {Date} the timestamp result value
|
|
471
470
|
*/
|
|
472
471
|
getNextDateTime() {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
472
|
+
this._checkTypeMatch("xsd:dateTime");
|
|
473
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
474
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
475
|
+
return XtkCaster.asTimestamp(value);
|
|
477
476
|
}
|
|
478
477
|
|
|
479
478
|
/**
|
|
@@ -482,10 +481,10 @@ class SoapMethodCall {
|
|
|
482
481
|
* @returns {Date} the date result value
|
|
483
482
|
*/
|
|
484
483
|
getNextDate() {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
484
|
+
this._checkTypeMatch("xsd:date");
|
|
485
|
+
var value = DomUtil.elementValue(this.elemCurrent);
|
|
486
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
487
|
+
return XtkCaster.asDate(value);
|
|
489
488
|
}
|
|
490
489
|
|
|
491
490
|
/**
|
|
@@ -494,15 +493,15 @@ class SoapMethodCall {
|
|
|
494
493
|
* @returns {Document} the XML document result value
|
|
495
494
|
*/
|
|
496
495
|
getNextDocument() {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
496
|
+
this._checkTypeMatch("ns:Document");
|
|
497
|
+
var elemValue = DomUtil.getFirstChildElement(this.elemCurrent);
|
|
498
|
+
if (elemValue === null || elemValue === undefined) {
|
|
499
|
+
this.elemValue = null;
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
var docValue = elemValue;
|
|
503
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
504
|
+
return docValue;
|
|
506
505
|
}
|
|
507
506
|
|
|
508
507
|
/**
|
|
@@ -511,14 +510,14 @@ class SoapMethodCall {
|
|
|
511
510
|
* @returns {Element} the XML element result value
|
|
512
511
|
*/
|
|
513
512
|
getNextElement() {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
513
|
+
this._checkTypeMatch("ns:Element");
|
|
514
|
+
var elemValue = DomUtil.getFirstChildElement(this.elemCurrent);
|
|
515
|
+
if (elemValue === null || elemValue === undefined) {
|
|
516
|
+
this.elemValue = null;
|
|
517
|
+
return null;
|
|
518
|
+
}
|
|
519
|
+
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent);
|
|
520
|
+
return elemValue;
|
|
522
521
|
}
|
|
523
522
|
|
|
524
523
|
/**
|
|
@@ -527,7 +526,7 @@ class SoapMethodCall {
|
|
|
527
526
|
* @returns a boolean set to true if ther are no more response args to read
|
|
528
527
|
*/
|
|
529
528
|
checkNoMoreArgs() {
|
|
530
|
-
|
|
529
|
+
return !this.elemCurrent;
|
|
531
530
|
}
|
|
532
531
|
|
|
533
532
|
/**
|
|
@@ -538,44 +537,44 @@ class SoapMethodCall {
|
|
|
538
537
|
*/
|
|
539
538
|
_createHTTPRequest(url, requestOptions) {
|
|
540
539
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
540
|
+
const headers = {
|
|
541
|
+
'Content-type': `application/soap+xml${this._charset ? ";charset=" + this._charset : ""}`,
|
|
542
|
+
'SoapAction': `${this.urn}#${this.methodName}`,
|
|
543
|
+
};
|
|
544
|
+
if (this._bearerToken) {
|
|
545
|
+
headers['Authorization'] = `Bearer ${this._bearerToken}`;
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
headers['X-Security-Token'] = this._securityToken;
|
|
549
|
+
headers['X-Session-Token'] = this._sessionToken;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// Add HTTP headers specific to the SOAP call for better tracing/troubleshooting
|
|
553
|
+
if (this._extraHttpHeaders && this._extraHttpHeaders['ACC-SDK-Version']) {
|
|
554
|
+
// "this.retry" means that the call can be retried, not that it is being retried. The HTTP header howerver, indicates that this
|
|
555
|
+
// is actually a retry of a previously failed call (expired token)
|
|
556
|
+
if (this._retryCount > 0) headers["ACC-SDK-Call-RetryCount"] = `${this._retryCount}`;
|
|
557
|
+
if (this.internal) headers["ACC-SDK-Call-Internal"] = "1";
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const request = {
|
|
561
|
+
url: url,
|
|
562
|
+
method: 'POST',
|
|
563
|
+
headers: headers,
|
|
564
|
+
data: DomUtil.toXMLString(this._doc)
|
|
565
|
+
};
|
|
566
|
+
if (this._sessionToken)
|
|
567
|
+
request.headers.Cookie = '__sessiontoken=' + this._sessionToken;
|
|
568
|
+
if (this._userAgentString)
|
|
569
|
+
request.headers['User-Agent'] = this._userAgentString;
|
|
570
|
+
|
|
571
|
+
// Override http headers with custom headers
|
|
572
|
+
for (let h in this._extraHttpHeaders) {
|
|
573
|
+
request.headers[h] = this._extraHttpHeaders[h];
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
const extraOptions = Object.assign({}, this._pushDownOptions, requestOptions);
|
|
577
|
+
return [ request, extraOptions ];
|
|
579
578
|
}
|
|
580
579
|
|
|
581
580
|
/**
|
|
@@ -584,50 +583,50 @@ class SoapMethodCall {
|
|
|
584
583
|
* @param {client.Client} sdk client (optional)
|
|
585
584
|
*/
|
|
586
585
|
finalize(url, client) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
586
|
+
if (client) {
|
|
587
|
+
this._sessionToken = client._sessionToken;
|
|
588
|
+
this._securityToken = client._securityToken;
|
|
589
|
+
this._bearerToken = client._bearerToken;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
var cookieHeader = DomUtil.findElement(this._header, "Cookie");
|
|
593
|
+
if (this._sessionToken) {
|
|
594
|
+
if (!cookieHeader) {
|
|
595
|
+
cookieHeader = this._doc.createElement("Cookie");
|
|
596
|
+
this._header.appendChild(cookieHeader);
|
|
591
597
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
//
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
}
|
|
625
|
-
const noMethodInURL = !!this._pushDownOptions.noMethodInURL;
|
|
626
|
-
const actualUrl = noMethodInURL ? url : `${url}?soapAction=${encodeURIComponent(this.urn + "#" + this.methodName)}`;
|
|
627
|
-
|
|
628
|
-
// Prepare request and empty response objects
|
|
629
|
-
[this.request, this.requestOptions] = this._createHTTPRequest(actualUrl);
|
|
630
|
-
this.response = undefined;
|
|
598
|
+
cookieHeader.textContent = `__sessiontoken=${this._sessionToken}`;
|
|
599
|
+
} else if (cookieHeader) {
|
|
600
|
+
cookieHeader.remove();
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
var securityTokenHeader = DomUtil.findElement(this._header, "X-Security-Token");
|
|
604
|
+
if (!securityTokenHeader) {
|
|
605
|
+
securityTokenHeader = this._doc.createElement("X-Security-Token");
|
|
606
|
+
this._header.appendChild(securityTokenHeader);
|
|
607
|
+
}
|
|
608
|
+
securityTokenHeader.textContent = this._securityToken;
|
|
609
|
+
|
|
610
|
+
// Always write a sessiontoken element as the first parameter. Even when using SecurityToken authentication
|
|
611
|
+
// and when the session token is actually passed implicitely as a cookie, one must write a sessiontoken
|
|
612
|
+
// element. If not, authentication will fail because the first parameter is interpreted as the "authentication mode"
|
|
613
|
+
// and eventually passed as the first parameter of CXtkLocalSessionPart::GetXtkSecurity
|
|
614
|
+
var sessionTokenElem = DomUtil.findElement(this._method, "sessiontoken");
|
|
615
|
+
if (sessionTokenElem) {
|
|
616
|
+
sessionTokenElem.textContent = this._sessionToken;
|
|
617
|
+
} else {
|
|
618
|
+
sessionTokenElem = this._doc.createElement("sessiontoken");
|
|
619
|
+
sessionTokenElem.setAttribute("xsi:type", "xsd:string");
|
|
620
|
+
// sessionTokenElem.setAttribute("SOAP-ENV:encodingStyle", SOAP_ENCODING_NATIVE);
|
|
621
|
+
sessionTokenElem.textContent = this._sessionToken;
|
|
622
|
+
this._method.prepend(sessionTokenElem);
|
|
623
|
+
}
|
|
624
|
+
const noMethodInURL = !!this._pushDownOptions.noMethodInURL;
|
|
625
|
+
const actualUrl = noMethodInURL ? url : `${url}?soapAction=${encodeURIComponent(this.urn + "#" + this.methodName)}`;
|
|
626
|
+
|
|
627
|
+
// Prepare request and empty response objects
|
|
628
|
+
[this.request, this.requestOptions] = this._createHTTPRequest(actualUrl);
|
|
629
|
+
this.response = undefined;
|
|
631
630
|
}
|
|
632
631
|
|
|
633
632
|
/**
|
|
@@ -638,65 +637,65 @@ class SoapMethodCall {
|
|
|
638
637
|
* @param {string} url the Campaign endpoint, such as "http://ffdamkt:8080/nl/jsp/soaprouter.jsp"
|
|
639
638
|
*/
|
|
640
639
|
async execute() {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
640
|
+
const that = this;
|
|
641
|
+
const promise = this._transport(this.request, this.requestOptions);
|
|
642
|
+
return promise.then(function(body) {
|
|
643
|
+
that.response = body;
|
|
644
|
+
// Response is a serialized XML document with the following structure
|
|
645
|
+
//
|
|
646
|
+
// Success:
|
|
647
|
+
// <SOAP-ENV:Envelope>
|
|
648
|
+
// <SOAP-ENV:Body>
|
|
649
|
+
// <{{method}}Response>
|
|
650
|
+
// {{ return values (one element per return value) }}
|
|
651
|
+
// </{{method}}Response>
|
|
652
|
+
// </SOAP-ENV:Body>
|
|
653
|
+
// </SOAP-ENV:Envelope>
|
|
654
|
+
//
|
|
655
|
+
// Failure:
|
|
656
|
+
// <SOAP-ENV:Envelope>
|
|
657
|
+
// <SOAP-ENV:Body>
|
|
658
|
+
// <SOAP-ENV:Fault>
|
|
659
|
+
// <faultcode/>
|
|
660
|
+
// <faultstring/>
|
|
661
|
+
// <detail/>
|
|
662
|
+
// </SOAP-ENV:Fault>
|
|
663
|
+
// </SOAP-ENV:Body>
|
|
664
|
+
// </SOAP-ENV:Envelope>
|
|
665
|
+
const dom = DomUtil.parse(body);
|
|
666
|
+
that.elemCurrent = dom.documentElement;
|
|
667
|
+
that.elemCurrent = DomUtil.findElement(that.elemCurrent, "SOAP-ENV:Body");
|
|
668
|
+
if (!that.elemCurrent)
|
|
669
|
+
throw new DomException("Malformed SOAP response: missing body element");
|
|
670
|
+
that.elemCurrent = DomUtil.getFirstChildElement(that.elemCurrent);
|
|
671
|
+
if (!that.elemCurrent)
|
|
672
|
+
throw new DomException("Malformed SOAP response: body element is empty");
|
|
674
673
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
674
|
+
// Error management
|
|
675
|
+
if (that.elemCurrent.nodeName == "SOAP-ENV:Fault") {
|
|
676
|
+
const faultCode = DomUtil.findElement(that.elemCurrent, "faultcode").textContent;
|
|
677
|
+
const faultString = DomUtil.findElement(that.elemCurrent, "faultstring").textContent;
|
|
678
|
+
const detailNode = DomUtil.findElement(that.elemCurrent, "detail");
|
|
679
|
+
const detail = detailNode ? detailNode.textContent : undefined;
|
|
680
|
+
throw new CampaignException(that, 500, faultCode, faultString, detail);
|
|
681
|
+
}
|
|
682
|
+
// Set current element for subsequent calls to getNext*
|
|
683
|
+
while (that.elemCurrent) {
|
|
684
|
+
var responseMethodTag = `${that.methodName}Response`;
|
|
685
|
+
var nodeName = that.elemCurrent.nodeName;
|
|
686
|
+
//if (nodeName === responseMethodTag || nodeName.endsWith(`:${responseMethodTag}`)) {
|
|
687
|
+
if (nodeName === responseMethodTag) {
|
|
688
|
+
that.elemCurrent = DomUtil.getFirstChildElement(that.elemCurrent);
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
else
|
|
692
|
+
that.elemCurrent = DomUtil.getNextSiblingElement(that.elemCurrent);
|
|
693
|
+
}
|
|
694
|
+
})
|
|
696
695
|
.catch(function(err) {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
696
|
+
if (that.response && that.response.indexOf(`XSV-350008`) != -1)
|
|
697
|
+
throw CampaignException.SESSION_EXPIRED();
|
|
698
|
+
else throw makeCampaignException(that, err);
|
|
700
699
|
});
|
|
701
700
|
}
|
|
702
701
|
|
|
@@ -709,12 +708,12 @@ class SoapMethodCall {
|
|
|
709
708
|
* @returns {Element} the XML element (empty)
|
|
710
709
|
*/
|
|
711
710
|
createElement(tagName) {
|
|
712
|
-
|
|
711
|
+
return this._doc.createElement(tagName);
|
|
713
712
|
}
|
|
714
713
|
|
|
715
|
-
}
|
|
714
|
+
}
|
|
716
715
|
|
|
717
|
-
// Public exports
|
|
718
|
-
exports.SoapMethodCall = SoapMethodCall;
|
|
716
|
+
// Public exports
|
|
717
|
+
exports.SoapMethodCall = SoapMethodCall;
|
|
719
718
|
|
|
720
719
|
})();
|