@adobe/acc-js-sdk 1.1.23 → 1.1.24

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.
@@ -289,6 +289,8 @@ const root = await node.linkTarget();
289
289
  <tr><td><b>isMappedAsXml</b></td><td>Is the field mapped as XML?</td></tr>
290
290
  <tr><td><b>visibleIf</b></td><td>The visibility expression of the node (if any) since version 1.1.9 of the SDK</td></tr>
291
291
  <tr><td><b>belongsTo</b></td><td>For attribute and elements, indicates the schema id in which they were defined. Since version 1.1.10 of the SDK</td></tr>
292
+ <tr><td><b>default</b></td><td>Default value if any. Can be an array for collections. Since version 1.1.24 of the SDK</td></tr>
293
+ <tr><td><b>translatedDefault</b></td><td>Default value if any. Since version 1.1.24 of the SDK</td></tr>
292
294
  </tbody>
293
295
  </table>
294
296
 
@@ -2,6 +2,17 @@
2
2
  layout: page
3
3
  title: Change Log
4
4
  ---
5
+ <section class="changelog"><h1>Version 1.1.24</h1>
6
+ <h2>2023/03/07</h2>
7
+
8
+ <li>
9
+ Added support for abortable requests. See <a href="https://opensource.adobe.com/acc-js-sdk/abortRequest.html"> for more details.</a>
10
+ </li>
11
+ <li>
12
+ Fixed compilation of vanilla JS bundle
13
+ </li>
14
+ </section>
15
+
5
16
  <section class="changelog"><h1>Version 1.1.23</h1>
6
17
  <h2>2023/03/02</h2>
7
18
 
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.23",
9
+ "version": "1.1.24",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "axios": "^1.2.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
@@ -19,7 +19,7 @@ governing permissions and limitations under the License.
19
19
  * https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/c-Application.html
20
20
  *
21
21
  *********************************************************************************/
22
- const { DomException, XPath } = require('./domUtil.js');
22
+ const { DomException, DomUtil, XPath } = require('./domUtil.js');
23
23
  const XtkCaster = require('./xtkCaster.js').XtkCaster;
24
24
  const EntityAccessor = require('./entityAccessor.js').EntityAccessor;
25
25
  const { ArrayMap } = require('./util.js');
@@ -419,6 +419,18 @@ class XtkSchemaNode {
419
419
  */
420
420
  this.childrenCount = 0;
421
421
 
422
+ /**
423
+ * Get the default value of a node
424
+ * @type {string}
425
+ */
426
+ this.default = EntityAccessor.getAttributeAsString(xml, "default");
427
+
428
+ /**
429
+ * Get the default translation for the default value of a node
430
+ * @type {string}
431
+ */
432
+ this.translatedDefault = EntityAccessor.getAttributeAsString(xml, "translatedDefault");
433
+
422
434
  /**
423
435
  * Indicates if the node is the root node, i.e. the first child node of the schema, whose name is the same as the schema name
424
436
  * @type {boolean}
@@ -639,6 +651,16 @@ class XtkSchemaNode {
639
651
  this.expr = EntityAccessor.getAttributeAsString(child, "expr");
640
652
  this.isCalculated = false;
641
653
  }
654
+ if (child.tagName === "default") {
655
+ if(this.unbound) {
656
+ // Default value for a collection of elements
657
+ const xml = DomUtil.parse(`<xml>${child.textContent}</xml>`);
658
+ const json = DomUtil.toJSON(xml);
659
+ this.default = XtkCaster.asArray(json[this.name]);
660
+ } else {
661
+ this.default = child.textContent;
662
+ }
663
+ }
642
664
  }
643
665
  for (const childNode of childNodes) {
644
666
  this.children._push(childNode.name, childNode);
package/src/cache.js CHANGED
@@ -12,7 +12,7 @@ governing permissions and limitations under the License.
12
12
  (function() {
13
13
  "use strict";
14
14
 
15
- const { Util } = require("./util");
15
+ const { Util } = require("./util.js");
16
16
 
17
17
 
18
18
  /**********************************************************************************
package/src/domUtil.js CHANGED
@@ -114,7 +114,6 @@ class DomUtil {
114
114
  const doc = dom.window.document;
115
115
  doc.__jsdom__ = dom;
116
116
  return doc;
117
- //return parseXML(xmlString);
118
117
  }
119
118
 
120
119
  /**
@@ -1939,6 +1939,86 @@ describe('Application', () => {
1939
1939
  });
1940
1940
  });
1941
1941
 
1942
+ describe("default values", () => {
1943
+
1944
+ it("Should extract default", async () => {
1945
+ var xml = DomUtil.parse(`<schema namespace='xtk' name='workflow'>
1946
+ <element name='workflow' label='Workflow'>
1947
+ <attribute default="true" label="In simulation mode: execute" name="runOnsimulation" type="boolean" xml="true"/>
1948
+ </element>
1949
+ </schema>`);
1950
+ var schema = newSchema(xml);
1951
+
1952
+ var node = await schema.root.findNode("@runOnsimulation");
1953
+ expect(node).toMatchObject({ name:"@runOnsimulation", childrenCount:0, default: 'true' });
1954
+ });
1955
+
1956
+ it("Should extract default values of a collection of elements", async () => {
1957
+ var xml = DomUtil.parse(`<schema namespace='xtk' name='workflow'>
1958
+ <element name='workflow' label='Workflow'>
1959
+ <element name="fork" label="Fork">
1960
+ <element label="Transitions" name="transitions" xml="true">
1961
+ <element label="transition" name="transition" ref="transition" unbound="true" xml="true">
1962
+ <default>
1963
+ &lt;transition name="transition1" enabled="true"/&gt;
1964
+ &lt;transition name="transition2" enabled="true"/&gt;
1965
+ </default>
1966
+ </element>
1967
+ </element>
1968
+ </element>
1969
+ </element>
1970
+ </schema>`);
1971
+ var schema = newSchema(xml);
1972
+
1973
+ var node = await schema.root.findNode("fork/transitions/transition");
1974
+ expect(node).toMatchObject({ name:"transition", childrenCount:0, default: [
1975
+ {
1976
+ "enabled": "true",
1977
+ "name": "transition1"
1978
+ },
1979
+ {
1980
+ "enabled": "true",
1981
+ "name": "transition2"
1982
+ }
1983
+ ] });
1984
+ });
1985
+
1986
+ it("Should extract default values of a memo", async () => {
1987
+ var xml = DomUtil.parse(`<schema namespace='xtk' name='workflow'>
1988
+ <element name='workflow' label='Workflow'>
1989
+ <element name="directorywatcher" label="File collector">
1990
+ <element name="period" type="memo" label="Schedule">
1991
+ <default>"m_abDay='7' m_abDay[0]='0' m_abDay[1]='0'"</default>
1992
+ </element>
1993
+ </element>
1994
+ </element>
1995
+ </schema>`);
1996
+ var schema = newSchema(xml);
1997
+
1998
+ var node = await schema.root.findNode("directorywatcher/period");
1999
+ expect(node).toMatchObject({ name:"period", childrenCount:0, default: "\"m_abDay='7' m_abDay[0]='0' m_abDay[1]='0'\"" });
2000
+ });
2001
+
2002
+ it("Should extract translatedDefault", async () => {
2003
+ var xml = DomUtil.parse(`<schema namespace='xtk' name='workflow'>
2004
+ <element name='workflow' label='Workflow'>
2005
+ <element name="delivery" label="Delivery">
2006
+ <element label="Transitions" name="transitions" xml="true">
2007
+ <element label="transition" name="done" xml="true">
2008
+ <attribute label="Label" name="label" type="string" translatedDefault="'Ok'" xml="true"/>
2009
+ </element>
2010
+ </element>
2011
+ </element>
2012
+ </element>
2013
+ </schema>`);
2014
+ var schema = newSchema(xml);
2015
+
2016
+ var node = await schema.root.findNode("delivery/transitions/done/@label");
2017
+ expect(node).toMatchObject({ name:"@label", childrenCount:0, translatedDefault: "'Ok'" });
2018
+ });
2019
+
2020
+ });
2021
+
1942
2022
  describe("toString", () => {
1943
2023
  var xml = DomUtil.parse(`<schema namespace='nms' name='recipient' label="Recipients" labelSingular="Recipient">
1944
2024
  <element name='recipient'>
@@ -943,5 +943,5 @@ describe('DomUtil', function() {
943
943
  expect(new XPathElement("..").isParent()).toBe(true);
944
944
  expect(new XPathElement(".").isParent()).toBe(false);
945
945
  })
946
- })
946
+ });
947
947
  });