@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.
Files changed (61) hide show
  1. package/.cursor/commands/opsx-apply.md +152 -0
  2. package/.cursor/commands/opsx-archive.md +157 -0
  3. package/.cursor/commands/opsx-explore.md +173 -0
  4. package/.cursor/commands/opsx-propose.md +106 -0
  5. package/.cursor/skills/openspec-apply-change/SKILL.md +156 -0
  6. package/.cursor/skills/openspec-archive-change/SKILL.md +114 -0
  7. package/.cursor/skills/openspec-explore/SKILL.md +288 -0
  8. package/.cursor/skills/openspec-propose/SKILL.md +110 -0
  9. package/.eslintrc.js +2 -2
  10. package/.github/prompts/opsx-apply.prompt.md +149 -0
  11. package/.github/prompts/opsx-archive.prompt.md +154 -0
  12. package/.github/prompts/opsx-explore.prompt.md +170 -0
  13. package/.github/prompts/opsx-propose.prompt.md +103 -0
  14. package/.github/skills/openspec-apply-change/SKILL.md +156 -0
  15. package/.github/skills/openspec-archive-change/SKILL.md +114 -0
  16. package/.github/skills/openspec-explore/SKILL.md +288 -0
  17. package/.github/skills/openspec-propose/SKILL.md +110 -0
  18. package/.github/workflows/codeql-analysis.yml +5 -4
  19. package/.github/workflows/npm-publish.yml +3 -3
  20. package/AGENTS.md +117 -0
  21. package/CLAUDE.md +2 -0
  22. package/MIGRATION.md +10 -0
  23. package/README.md +6 -2
  24. package/ai-docs/coding-rules.md +95 -0
  25. package/ai-docs/tech-stack.md +43 -0
  26. package/babel.config.js +5 -0
  27. package/docs/changeLog.html +28 -2
  28. package/docs/checkList.html +2 -2
  29. package/docs/quickstart.html +2 -1
  30. package/docs/release.html +1 -1
  31. package/openspec/config.yaml +20 -0
  32. package/package-lock.json +6055 -4036
  33. package/package.json +9 -7
  34. package/src/AGENTS.md +98 -0
  35. package/src/CLAUDE.md +2 -0
  36. package/src/application.js +637 -637
  37. package/src/cache.js +133 -133
  38. package/src/cacheRefresher.js +190 -190
  39. package/src/campaign.js +532 -532
  40. package/src/client.js +1539 -1537
  41. package/src/crypto.js +52 -52
  42. package/src/domUtil.js +346 -346
  43. package/src/entityAccessor.js +61 -61
  44. package/src/index.js +83 -83
  45. package/src/methodCache.js +69 -69
  46. package/src/optionCache.js +26 -26
  47. package/src/soap.js +321 -322
  48. package/src/testUtil.js +13 -13
  49. package/src/transport.js +70 -70
  50. package/src/util.js +147 -147
  51. package/src/web/bundler.js +5 -5
  52. package/src/xtkCaster.js +258 -258
  53. package/src/xtkEntityCache.js +34 -34
  54. package/src/xtkJob.js +185 -185
  55. package/test/AGENTS.md +37 -0
  56. package/test/CLAUDE.md +2 -0
  57. package/test/cacheRefresher.test.js +7 -0
  58. package/test/client.test.js +90 -78
  59. package/test/jest.config.js +6 -0
  60. package/test/observability.test.js +6 -1
  61. package/test/xtkJob.test.js +2 -2
@@ -10,22 +10,22 @@ 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";
13
+ "use strict";
14
14
 
15
- /**********************************************************************************
15
+ /**********************************************************************************
16
16
  *
17
17
  * Helper function to navigate an entity, regardless of its representation
18
18
  *
19
19
  *********************************************************************************/
20
- const XtkCaster = require('./xtkCaster.js').XtkCaster;
21
- const { DomUtil, BadgerFishObject } = require('./domUtil.js');
22
- const { Util } = require("./util.js");
20
+ const XtkCaster = require('./xtkCaster.js').XtkCaster;
21
+ const { DomUtil, BadgerFishObject } = require('./domUtil.js');
22
+ const { Util } = require("./util.js");
23
23
 
24
- /**
24
+ /**
25
25
  * @namespace XML
26
26
  */
27
27
 
28
- /**
28
+ /**
29
29
  * The XtkObject type is a Campaign entity, represented either as a DOM element, or as a JavaScript
30
30
  * literal object, depending on the selected representation (xml, SimpleJson or BadgerFish)
31
31
  *
@@ -33,7 +33,7 @@ const { Util } = require("./util.js");
33
33
  * @memberOf XML
34
34
  */
35
35
 
36
- /**
36
+ /**
37
37
  * An entity accessor enables you to access properties of entity objects manipulated by
38
38
  * the JS SDK. With the representations mechanism, the SDK can work with either xml or
39
39
  * json documents. You can use the DOM API to manipulate XML documents, and native
@@ -45,7 +45,7 @@ const { Util } = require("./util.js");
45
45
  * @class
46
46
  * @memberof XML
47
47
  */
48
- class EntityAccessor {
48
+ class EntityAccessor {
49
49
 
50
50
  constructor() {
51
51
  }
@@ -68,13 +68,13 @@ class EntityAccessor {
68
68
  * expect(EntityAccessor.getAttributeAsString(entity, "hello")).toBe("world");
69
69
  */
70
70
  static getAttributeAsString(entity, name) {
71
- if (entity.documentElement) entity = entity.documentElement;
72
- if (entity.nodeType && entity.tagName)
73
- return DomUtil.getAttributeAsString(entity, name);
74
- else if (entity instanceof BadgerFishObject)
75
- return XtkCaster.asString(entity[`@${name}`]);
76
- else
77
- return XtkCaster.asString(entity[name]);
71
+ if (entity.documentElement) entity = entity.documentElement;
72
+ if (entity.nodeType && entity.tagName)
73
+ return DomUtil.getAttributeAsString(entity, name);
74
+ else if (entity instanceof BadgerFishObject)
75
+ return XtkCaster.asString(entity[`@${name}`]);
76
+ else
77
+ return XtkCaster.asString(entity[name]);
78
78
  }
79
79
 
80
80
  /**
@@ -94,13 +94,13 @@ class EntityAccessor {
94
94
  * expect(EntityAccessor.getAttributeAsLong(entity, "hello")).toBe(42);
95
95
  */
96
96
  static getAttributeAsLong(entity, name) {
97
- if (entity.documentElement) entity = entity.documentElement;
98
- if (entity.nodeType && entity.tagName)
99
- return DomUtil.getAttributeAsLong(entity, name);
100
- else if (entity instanceof BadgerFishObject)
101
- return XtkCaster.asLong(entity[`@${name}`]);
102
- else
103
- return XtkCaster.asLong(entity[name]);
97
+ if (entity.documentElement) entity = entity.documentElement;
98
+ if (entity.nodeType && entity.tagName)
99
+ return DomUtil.getAttributeAsLong(entity, name);
100
+ else if (entity instanceof BadgerFishObject)
101
+ return XtkCaster.asLong(entity[`@${name}`]);
102
+ else
103
+ return XtkCaster.asLong(entity[name]);
104
104
  }
105
105
 
106
106
  /**
@@ -120,13 +120,13 @@ class EntityAccessor {
120
120
  * expect(EntityAccessor.getAttributeAsBoolean(entity, "hello")).toBe(true);
121
121
  */
122
122
  static getAttributeAsBoolean(entity, name) {
123
- if (entity.documentElement) entity = entity.documentElement;
124
- if (entity.nodeType && entity.tagName)
125
- return DomUtil.getAttributeAsBoolean(entity, name);
126
- else if (entity instanceof BadgerFishObject)
127
- return XtkCaster.asBoolean(entity[`@${name}`]);
128
- else
129
- return XtkCaster.asBoolean(entity[name]);
123
+ if (entity.documentElement) entity = entity.documentElement;
124
+ if (entity.nodeType && entity.tagName)
125
+ return DomUtil.getAttributeAsBoolean(entity, name);
126
+ else if (entity instanceof BadgerFishObject)
127
+ return XtkCaster.asBoolean(entity[`@${name}`]);
128
+ else
129
+ return XtkCaster.asBoolean(entity[name]);
130
130
  }
131
131
 
132
132
  /**
@@ -147,22 +147,22 @@ class EntityAccessor {
147
147
  * EntityAccessor.getChildElements(entity, "chapter");
148
148
  */
149
149
  static getChildElements(entity, tagName) {
150
- if (entity.documentElement) entity = entity.documentElement;
151
- if (entity.nodeType && entity.tagName) {
152
- const elements = [];
153
- var child = DomUtil.getFirstChildElement(entity);
154
- while (child) {
155
- if (!tagName || tagName == child.tagName)
156
- elements.push(child);
157
- child = DomUtil.getNextSiblingElement(child);
158
- }
159
- return elements;
160
- }
161
- else {
162
- var elements = entity[tagName] || [];
163
- if (!Util.isArray(elements)) elements = [ elements ];
164
- return elements;
150
+ if (entity.documentElement) entity = entity.documentElement;
151
+ if (entity.nodeType && entity.tagName) {
152
+ const elements = [];
153
+ var child = DomUtil.getFirstChildElement(entity);
154
+ while (child) {
155
+ if (!tagName || tagName == child.tagName)
156
+ elements.push(child);
157
+ child = DomUtil.getNextSiblingElement(child);
165
158
  }
159
+ return elements;
160
+ }
161
+ else {
162
+ var elements = entity[tagName] || [];
163
+ if (!Util.isArray(elements)) elements = [ elements ];
164
+ return elements;
165
+ }
166
166
  }
167
167
 
168
168
  /**
@@ -183,26 +183,26 @@ class EntityAccessor {
183
183
  * EntityAccessor.getElement(entity, "body");
184
184
  */
185
185
  static getElement(entity, tagName) {
186
- if (entity.documentElement) entity = entity.documentElement;
187
- if (entity.nodeType && entity.tagName) {
188
- var child = DomUtil.getFirstChildElement(entity);
189
- while (child) {
190
- if (tagName == child.tagName)
191
- return child;
192
- child = DomUtil.getNextSiblingElement(child);
193
- }
194
- return null;
195
- }
196
- else {
197
- const child = entity[tagName];
198
- return child ? child : null;
186
+ if (entity.documentElement) entity = entity.documentElement;
187
+ if (entity.nodeType && entity.tagName) {
188
+ var child = DomUtil.getFirstChildElement(entity);
189
+ while (child) {
190
+ if (tagName == child.tagName)
191
+ return child;
192
+ child = DomUtil.getNextSiblingElement(child);
199
193
  }
194
+ return null;
195
+ }
196
+ else {
197
+ const child = entity[tagName];
198
+ return child ? child : null;
199
+ }
200
200
  }
201
201
 
202
- }
202
+ }
203
203
 
204
204
 
205
- // Public exports
206
- exports.EntityAccessor = EntityAccessor;
205
+ // Public exports
206
+ exports.EntityAccessor = EntityAccessor;
207
207
 
208
208
  })();
package/src/index.js CHANGED
@@ -10,23 +10,23 @@ 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";
13
+ "use strict";
14
14
 
15
- /**********************************************************************************
15
+ /**********************************************************************************
16
16
  *
17
17
  * Adobe Campaign Classic Core SDK
18
18
  *
19
19
  *********************************************************************************/
20
20
 
21
- const pjson = require('../package.json');
22
- const DomUtil = require('./domUtil.js').DomUtil;
23
- const XtkCaster = require('./xtkCaster.js').XtkCaster;
24
- const { Client, Credentials, ConnectionParameters } = require('./client.js');
25
- const request = require('./transport.js').request;
26
- const { TestUtil } = require('./testUtil.js');
27
- const { HttpError } = require('./transport.js');
21
+ const pjson = require('../package.json');
22
+ const DomUtil = require('./domUtil.js').DomUtil;
23
+ const XtkCaster = require('./xtkCaster.js').XtkCaster;
24
+ const { Client, Credentials, ConnectionParameters } = require('./client.js');
25
+ const request = require('./transport.js').request;
26
+ const { TestUtil } = require('./testUtil.js');
27
+ const { HttpError } = require('./transport.js');
28
28
 
29
- /**
29
+ /**
30
30
  * Get/Set the transport function (defaults to Axios). This function is used for testing / mocking the transport layer.
31
31
  * Called without arguments, it returns the current transport function
32
32
  * Called with an argument, it sets the current transport function and returns the previous one
@@ -41,23 +41,23 @@ const { HttpError } = require('./transport.js');
41
41
  * }
42
42
  */
43
43
 
44
- var transport = request;
44
+ var transport = request;
45
45
 
46
- /**
46
+ /**
47
47
  * @namespace Campaign
48
48
  */
49
- class SDK {
49
+ class SDK {
50
50
 
51
51
  constructor() {
52
52
  }
53
53
 
54
54
  _transport(t) {
55
- if (t) {
56
- const old = transport;
57
- transport = t;
58
- return old;
59
- }
60
- return transport;
55
+ if (t) {
56
+ const old = transport;
57
+ transport = t;
58
+ return old;
59
+ }
60
+ return transport;
61
61
  }
62
62
 
63
63
  /**
@@ -68,8 +68,8 @@ class SDK {
68
68
  * @return {Promise<Client>} an ACC client object
69
69
  */
70
70
  async init (connectionParameters) {
71
- const client = new Client(this, connectionParameters);
72
- return client;
71
+ const client = new Client(this, connectionParameters);
72
+ return client;
73
73
  }
74
74
 
75
75
  /**
@@ -86,11 +86,11 @@ class SDK {
86
86
  * @returns {Campaign.SDKVersion} an object containing information about the SDK, such as it's name, version, etc.
87
87
  */
88
88
  getSDKVersion() {
89
- return {
90
- version: pjson.version,
91
- name: pjson.name,
92
- description: pjson.description
93
- };
89
+ return {
90
+ version: pjson.version,
91
+ name: pjson.name,
92
+ description: pjson.description
93
+ };
94
94
  }
95
95
 
96
96
  /**
@@ -98,9 +98,9 @@ class SDK {
98
98
  * Can be useful to troubleshoot IP whitelisting issues
99
99
  */
100
100
  async ip() {
101
- const transport = this._transport();
102
- const ip = await transport({ url: "https://api.db-ip.com/v2/free/self" });
103
- return ip;
101
+ const transport = this._transport();
102
+ const ip = await transport({ url: "https://api.db-ip.com/v2/free/self" });
103
+ return ip;
104
104
  }
105
105
 
106
106
  /**
@@ -130,23 +130,23 @@ class SDK {
130
130
  * expect(sdk.escapeXtk`@name=${"Rock 'n' Roll"}`).toBe("@name='Rock \\'n\\' Roll'");
131
131
  */
132
132
  escapeXtk(p1, ...p2) {
133
- // first syntax: only one parameter which is a string => returns the escaped string.
134
- // that's how the Campaign function in common.js behaves
135
- if (p1 === undefined || p1 === null)
136
- return "''";
137
- if (typeof p1 === 'string') {
138
- return "'" + String(p1).replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'";
139
- }
140
-
141
- // Second syntax: for use in tagged template literals
142
- // instead of writing: { expr: "@name = " + escapeXtk(userName) }
143
- // you write { expr: escapeXtk`@name = {userName}` }
144
- if (p1.length == 0) return "''";
145
- var str = p1[0];
146
- for (var i=1; i<p1.length; i++) {
147
- str = str + this.escapeXtk(p2[i-1]) + p1[i];
148
- }
149
- return str;
133
+ // first syntax: only one parameter which is a string => returns the escaped string.
134
+ // that's how the Campaign function in common.js behaves
135
+ if (p1 === undefined || p1 === null)
136
+ return "''";
137
+ if (typeof p1 === 'string') {
138
+ return "'" + String(p1).replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'";
139
+ }
140
+
141
+ // Second syntax: for use in tagged template literals
142
+ // instead of writing: { expr: "@name = " + escapeXtk(userName) }
143
+ // you write { expr: escapeXtk`@name = {userName}` }
144
+ if (p1.length == 0) return "''";
145
+ var str = p1[0];
146
+ for (var i=1; i<p1.length; i++) {
147
+ str = str + this.escapeXtk(p2[i-1]) + p1[i];
148
+ }
149
+ return str;
150
150
  }
151
151
 
152
152
  /**
@@ -156,14 +156,14 @@ class SDK {
156
156
  * @returns the escaped string
157
157
  */
158
158
  escapeForLike(text, escapeXtkParams) {
159
- text = XtkCaster.asString(text);
160
- if (!text) return "";
161
- text = text.replace(/\\/g, "\\\\")
162
- .replace(/'/g, "\\'")
163
- .replace(/%/g, "\\%")
164
- .replace(/_/g, "\\_");
165
- if (escapeXtkParams)
166
- text = text.replace(/\$/g, "' + Char('36') + '");
159
+ text = XtkCaster.asString(text);
160
+ if (!text) return "";
161
+ text = text.replace(/\\/g, "\\\\")
162
+ .replace(/'/g, "\\'")
163
+ .replace(/%/g, "\\%")
164
+ .replace(/_/g, "\\_");
165
+ if (escapeXtkParams)
166
+ text = text.replace(/\$/g, "' + Char('36') + '");
167
167
  return text;
168
168
  }
169
169
 
@@ -173,19 +173,19 @@ class SDK {
173
173
  * @returns {string} the expanded xpath
174
174
  */
175
175
  expandXPath(xpath) {
176
- if (!xpath) return xpath;
177
- if (xpath.startsWith("[") && xpath.endsWith("]"))
178
- return xpath;
179
- if (xpath.indexOf('/') === -1 && xpath.indexOf('-') === -1 && xpath.indexOf(':') === -1)
180
- return xpath;
181
- return `[${xpath}]`;
176
+ if (!xpath) return xpath;
177
+ if (xpath.startsWith("[") && xpath.endsWith("]"))
178
+ return xpath;
179
+ if (xpath.indexOf('/') === -1 && xpath.indexOf('-') === -1 && xpath.indexOf(':') === -1)
180
+ return xpath;
181
+ return `[${xpath}]`;
182
182
  }
183
183
 
184
184
  unexpandXPath(xpath) {
185
- if (!xpath) return xpath;
186
- if (xpath.startsWith("[") && xpath.endsWith("]"))
187
- return xpath.substring(1, xpath.length - 1);
188
- return xpath;
185
+ if (!xpath) return xpath;
186
+ if (xpath.startsWith("[") && xpath.endsWith("]"))
187
+ return xpath.substring(1, xpath.length - 1);
188
+ return xpath;
189
189
  }
190
190
 
191
191
  /**
@@ -195,26 +195,26 @@ class SDK {
195
195
  * @returns {string} the text literal which can be used in a Xtk expression or condition
196
196
  */
197
197
  xtkConstText(value, type) {
198
- if (!type || type === 'string' || type === 'memo') {
199
- return sdk.escapeXtk(XtkCaster.asString(value));
200
- }
201
- const constText = XtkCaster.asString(XtkCaster.as(value, type));
202
- if (XtkCaster.isTimeType(type))
203
- return `#${constText}#`;
204
- return constText;
198
+ if (!type || type === 'string' || type === 'memo') {
199
+ return sdk.escapeXtk(XtkCaster.asString(value));
200
+ }
201
+ const constText = XtkCaster.asString(XtkCaster.as(value, type));
202
+ if (XtkCaster.isTimeType(type))
203
+ return `#${constText}#`;
204
+ return constText;
205
205
  }
206
- }
207
-
208
- const sdk = new SDK();
209
- sdk.TestUtil = TestUtil;
210
- sdk.XtkCaster = XtkCaster;
211
- sdk.Credentials = Credentials;
212
- sdk.DomUtil = DomUtil;
213
- sdk.ConnectionParameters = ConnectionParameters;
214
- sdk.HttpError = HttpError;
215
-
216
- // Public exports
217
- module.exports = sdk;
206
+ }
207
+
208
+ const sdk = new SDK();
209
+ sdk.TestUtil = TestUtil;
210
+ sdk.XtkCaster = XtkCaster;
211
+ sdk.Credentials = Credentials;
212
+ sdk.DomUtil = DomUtil;
213
+ sdk.ConnectionParameters = ConnectionParameters;
214
+ sdk.HttpError = HttpError;
215
+
216
+ // Public exports
217
+ module.exports = sdk;
218
218
 
219
219
 
220
220
  })();
@@ -10,32 +10,32 @@ 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";
13
+ "use strict";
14
14
 
15
15
 
16
- /**********************************************************************************
16
+ /**********************************************************************************
17
17
  *
18
18
  * A cache for Campaign SOAP methods definition
19
19
  *
20
20
  *********************************************************************************/
21
21
 
22
- const DomUtil = require('./domUtil.js').DomUtil;
23
- const { Cache } = require('./cache.js');
22
+ const DomUtil = require('./domUtil.js').DomUtil;
23
+ const { Cache } = require('./cache.js');
24
24
 
25
- /**
25
+ /**
26
26
  * @namespace Campaign
27
27
  *
28
28
  * @typedef {DOMElement} SoapMethodDefinition
29
29
  * @memberof Campaign
30
30
  */
31
31
 
32
- /**
32
+ /**
33
33
  * @private
34
34
  * @class
35
35
  * @constructor
36
36
  * @memberof Campaign
37
37
  */
38
- class MethodCache extends Cache {
38
+ class MethodCache extends Cache {
39
39
 
40
40
  /**
41
41
  * A in-memory cache for SOAP call method definitions. Not intended to be used directly,
@@ -52,20 +52,20 @@ class MethodCache extends Cache {
52
52
  * @param {number} ttl is the TTL for objects in ms. Defaults to 5 mins
53
53
  */
54
54
  constructor(storage, rootKey, ttl) {
55
- super(storage, rootKey, ttl, ((schemaId, methodName) => schemaId + "#" + methodName ), (item, serDeser) => {
56
- if (serDeser) {
57
- if (!item || !item.value || !item.value.method) throw Error(`Cannot serialize falsy cached item`);
58
- const value = Object.assign({}, item); // shallow copy
59
- value.value = Object.assign({}, value.value); // dummy deep copy
60
- value.value.method = DomUtil.toXMLString(item.value.method);
61
- return JSON.stringify(value);
62
- }
63
- else {
64
- const json = JSON.parse(item);
65
- json.value.method = DomUtil.parse(json.value.method).documentElement;
66
- return json;
67
- }
68
- });
55
+ super(storage, rootKey, ttl, ((schemaId, methodName) => schemaId + "#" + methodName ), (item, serDeser) => {
56
+ if (serDeser) {
57
+ if (!item || !item.value || !item.value.method) throw Error(`Cannot serialize falsy cached item`);
58
+ const value = Object.assign({}, item); // shallow copy
59
+ value.value = Object.assign({}, value.value); // dummy deep copy
60
+ value.value.method = DomUtil.toXMLString(item.value.method);
61
+ return JSON.stringify(value);
62
+ }
63
+ else {
64
+ const json = JSON.parse(item);
65
+ json.value.method = DomUtil.parse(json.value.method).documentElement;
66
+ return json;
67
+ }
68
+ });
69
69
  }
70
70
 
71
71
  /**
@@ -76,7 +76,7 @@ class MethodCache extends Cache {
76
76
  * @param {Element} schema DOM document node represening the schema
77
77
  */
78
78
  async cache(schema) {
79
- return await this.put(schema);
79
+ return await this.put(schema);
80
80
  }
81
81
 
82
82
  /**
@@ -85,49 +85,49 @@ class MethodCache extends Cache {
85
85
  * @param {Element} schema DOM document node represening the schema
86
86
  */
87
87
  async put(schema) {
88
- var namespace = DomUtil.getAttributeAsString(schema, "namespace");
89
- var name = DomUtil.getAttributeAsString(schema, "name");
90
- var impls = DomUtil.getAttributeAsString(schema, "implements");
91
- var root = DomUtil.getFirstChildElement(schema);
92
- while (root) {
93
- let schemaId;
94
- if (root.nodeName == "interface") {
95
- const nodeName = DomUtil.getAttributeAsString(root, "name");
96
- schemaId = `${namespace}:${nodeName}`;
97
- }
98
- else if (root.nodeName == "methods") {
99
- schemaId = `${namespace}:${name}`;
100
- }
101
- if (schemaId) {
102
- var child = DomUtil.getFirstChildElement(root, "method");
103
- while (child) {
104
- const methodName = DomUtil.getAttributeAsString(child, "name");
105
- const cached = { method: child, urn: schemaId };
106
- await super.put(schemaId, methodName, cached);
107
- child = DomUtil.getNextSiblingElement(child, "method");
108
- }
109
- }
110
- root = DomUtil.getNextSiblingElement(root);
88
+ var namespace = DomUtil.getAttributeAsString(schema, "namespace");
89
+ var name = DomUtil.getAttributeAsString(schema, "name");
90
+ var impls = DomUtil.getAttributeAsString(schema, "implements");
91
+ var root = DomUtil.getFirstChildElement(schema);
92
+ while (root) {
93
+ let schemaId;
94
+ if (root.nodeName == "interface") {
95
+ const nodeName = DomUtil.getAttributeAsString(root, "name");
96
+ schemaId = `${namespace}:${nodeName}`;
97
+ }
98
+ else if (root.nodeName == "methods") {
99
+ schemaId = `${namespace}:${name}`;
100
+ }
101
+ if (schemaId) {
102
+ var child = DomUtil.getFirstChildElement(root, "method");
103
+ while (child) {
104
+ const methodName = DomUtil.getAttributeAsString(child, "name");
105
+ const cached = { method: child, urn: schemaId };
106
+ await super.put(schemaId, methodName, cached);
107
+ child = DomUtil.getNextSiblingElement(child, "method");
108
+ }
111
109
  }
110
+ root = DomUtil.getNextSiblingElement(root);
111
+ }
112
112
 
113
- // If the schema implements an interface, then add the interface methods to the schema
114
- // methods in the cache, using the "<interface>|<schemaId>" urn
115
- // example: xtk:session implements xtk:persist, and therefore will have xtk:persist methods
116
- // under the urn "xtk:persist|xtk:session"
117
- if (impls) {
118
- const schemaId = `${namespace}:${name}`;
119
- const prefix = `${impls}#`;
120
- const urn = `${impls}|${schemaId}`;
121
- const keys = Object.keys(this._cache);
122
- for (const key of keys) {
123
- if (key.startsWith(prefix)) {
124
- let cached = this._cache[key].value;
125
- cached = { method: cached.method, urn: urn };
126
- const methodName = DomUtil.getAttributeAsString(cached.method, "name");
127
- await super.put(schemaId, methodName, cached);
128
- }
129
- }
113
+ // If the schema implements an interface, then add the interface methods to the schema
114
+ // methods in the cache, using the "<interface>|<schemaId>" urn
115
+ // example: xtk:session implements xtk:persist, and therefore will have xtk:persist methods
116
+ // under the urn "xtk:persist|xtk:session"
117
+ if (impls) {
118
+ const schemaId = `${namespace}:${name}`;
119
+ const prefix = `${impls}#`;
120
+ const urn = `${impls}|${schemaId}`;
121
+ const keys = Object.keys(this._cache);
122
+ for (const key of keys) {
123
+ if (key.startsWith(prefix)) {
124
+ let cached = this._cache[key].value;
125
+ cached = { method: cached.method, urn: urn };
126
+ const methodName = DomUtil.getAttributeAsString(cached.method, "name");
127
+ await super.put(schemaId, methodName, cached);
128
+ }
130
129
  }
130
+ }
131
131
  }
132
132
 
133
133
  /**
@@ -138,8 +138,8 @@ class MethodCache extends Cache {
138
138
  * @returns {Campaign.SoapMethodDefinition} the method definition, or undefined if the schema or the method is not found
139
139
  */
140
140
  async get(schemaId, methodName) {
141
- const cached = await super.get(schemaId, methodName);
142
- return cached ? cached.method : undefined;
141
+ const cached = await super.get(schemaId, methodName);
142
+ return cached ? cached.method : undefined;
143
143
  }
144
144
 
145
145
  /**
@@ -150,13 +150,13 @@ class MethodCache extends Cache {
150
150
  * @returns {string} the URN (or Soap action header), or undefined if the schema or the method is not found
151
151
  */
152
152
  async getSoapUrn(schemaId, methodName) {
153
- const cached = await super.get(schemaId, methodName);
154
- return cached ? cached.urn : undefined;
153
+ const cached = await super.get(schemaId, methodName);
154
+ return cached ? cached.urn : undefined;
155
155
  }
156
- }
156
+ }
157
157
 
158
158
 
159
- // Public exports
160
- exports.MethodCache = MethodCache;
159
+ // Public exports
160
+ exports.MethodCache = MethodCache;
161
161
 
162
162
  })();