@adobe/acc-js-sdk 1.1.31 → 1.1.33

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.
@@ -3,6 +3,20 @@ layout: page
3
3
  title: Change Log
4
4
  ---
5
5
 
6
+ <section class="changelog"><h1>Version 1.1.33</h1>
7
+ <h2>2023/07/08</h2>
8
+ <li>
9
+ Because of a server-side bug, there could be shemas with multiple copies of an enumeration. Make sure the SDK will not fail loading such schemas (only the first copy of the enumeration will be considered)
10
+ </li>
11
+ </section>
12
+
13
+ <section class="changelog"><h1>Version 1.1.32</h1>
14
+ <h2>2023/06/22</h2>
15
+ <li>
16
+ Support the fact that "translatedDefault" can be an element in a schema (and not just an attribute)
17
+ </li>
18
+ </section>
19
+
6
20
  <section class="changelog"><h1>Version 1.1.31</h1>
7
21
  <h2>2023/06/19</h2>
8
22
  <li>
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.31",
3
+ "version": "1.1.33",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.31",
9
+ "version": "1.1.33",
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.31",
3
+ "version": "1.1.33",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
@@ -652,14 +652,22 @@ class XtkSchemaNode {
652
652
  this.expr = EntityAccessor.getAttributeAsString(child, "expr");
653
653
  this.isCalculated = false;
654
654
  }
655
- if (child.tagName === "default") {
655
+ if (child.tagName === "default" || child.tagName === "translatedDefault") {
656
656
  if(this.unbound) {
657
657
  // Default value for a collection of elements
658
658
  const xml = DomUtil.parse(`<xml>${child.textContent}</xml>`);
659
659
  const json = DomUtil.toJSON(xml);
660
- this.default = XtkCaster.asArray(json[this.name]);
660
+ if(child.tagName === "translatedDefault") {
661
+ this.translatedDefault = XtkCaster.asArray(json[this.name]);
662
+ } else {
663
+ this.default = XtkCaster.asArray(json[this.name]);
664
+ }
661
665
  } else {
662
- this.default = child.textContent;
666
+ if(child.tagName === "translatedDefault") {
667
+ this.translatedDefault = child.textContent;
668
+ } else {
669
+ this.default = child.textContent;
670
+ }
663
671
  }
664
672
  }
665
673
  }
@@ -1216,7 +1224,9 @@ class XtkSchema extends XtkSchemaNode {
1216
1224
  this.enumerations = new ArrayMap();
1217
1225
  for (var child of EntityAccessor.getChildElements(xml, "enumeration")) {
1218
1226
  const e = new XtkEnumeration(this.id, child);
1219
- this.enumerations._push(e.shortName, e);
1227
+ if (this.enumerations.get(e.shortName) === undefined) {
1228
+ this.enumerations._push(e.shortName, e);
1229
+ }
1220
1230
  }
1221
1231
  }
1222
1232
 
@@ -345,6 +345,19 @@ describe('Application', () => {
345
345
  expect(enumerations[1].label).toBe("Status code");
346
346
  });
347
347
 
348
+ it("Should support duplicate enumerations", () => {
349
+ var xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
350
+ <enumeration name="duplicated" basetype="byte"/>
351
+ <enumeration name="duplicated" basetype="byte"/>
352
+ <element name='recipient' label='Recipients'></element>
353
+ </schema>`);
354
+ var schema = newSchema(xml);
355
+ var enumerations = schema.enumerations;
356
+ expect(enumerations.duplicated.dummy).toBeFalsy();
357
+ expect(enumerations[0].label).toBe("Duplicated");
358
+ expect(enumerations[1]).toBeUndefined();
359
+ });
360
+
348
361
  it("Should test images", () => {
349
362
  var xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
350
363
  <enumeration name="gender" basetype="byte">
@@ -2096,7 +2109,23 @@ describe('Application', () => {
2096
2109
  expect(node).toMatchObject({ name:"period", childrenCount:0, default: "\"m_abDay='7' m_abDay[0]='0' m_abDay[1]='0'\"" });
2097
2110
  });
2098
2111
 
2099
- it("Should extract translatedDefault", async () => {
2112
+ it("Should extract translated default values of a memo", async () => {
2113
+ var xml = DomUtil.parse(`<schema namespace='xtk' name='workflow'>
2114
+ <element name='workflow' label='Workflow'>
2115
+ <element name="directorywatcher" label="File collector">
2116
+ <element name="period" type="memo" label="Schedule">
2117
+ <translatedDefault>"m_abDay='7' m_abDay[0]='0' m_abDay[1]='0'"</translatedDefault>
2118
+ </element>
2119
+ </element>
2120
+ </element>
2121
+ </schema>`);
2122
+ var schema = newSchema(xml);
2123
+
2124
+ var node = await schema.root.findNode("directorywatcher/period");
2125
+ expect(node).toMatchObject({ name:"period", childrenCount:0, translatedDefault: "\"m_abDay='7' m_abDay[0]='0' m_abDay[1]='0'\"" });
2126
+ });
2127
+
2128
+ it("Should extract translatedDefault attribute", async () => {
2100
2129
  var xml = DomUtil.parse(`<schema namespace='xtk' name='workflow'>
2101
2130
  <element name='workflow' label='Workflow'>
2102
2131
  <element name="delivery" label="Delivery">
@@ -2114,6 +2143,37 @@ describe('Application', () => {
2114
2143
  expect(node).toMatchObject({ name:"@label", childrenCount:0, translatedDefault: "'Ok'" });
2115
2144
  });
2116
2145
 
2146
+ it("Should extract translatedDefault element", async () => {
2147
+ var xml = DomUtil.parse(`<schema namespace='xtk' name='workflow'>
2148
+ <element name='workflow' label='Workflow'>
2149
+ <element name="extract" label="Split">
2150
+ <element label="Transitions" name="transitions" xml="true">
2151
+ <element name="extractOutput" ordered="true" template="nms:workflow:extractOutput" unbound="true">
2152
+ <translatedDefault>&lt;extractOutput enabled="true" label="Segment" name="subSet" &gt;
2153
+ &lt;limiter type="percent" percent="10" random="true"/&gt;
2154
+ &lt;filter enabled="true"/&gt;
2155
+ &lt;/extractOutput&gt;</translatedDefault>
2156
+ </element>
2157
+ </element>
2158
+ </element>
2159
+ </element>
2160
+ </schema>`);
2161
+ var schema = newSchema(xml);
2162
+
2163
+ var node = await schema.root.findNode("extract/transitions/extractOutput");
2164
+ expect(node).toMatchObject(
2165
+ { translatedDefault: [
2166
+ {
2167
+ enabled: "true", name:"subSet",
2168
+ limiter: {
2169
+ type: 'percent',
2170
+ percent: '10',
2171
+ random: 'true'
2172
+ }
2173
+ }]
2174
+ });
2175
+ });
2176
+
2117
2177
  });
2118
2178
 
2119
2179
  describe("toString", () => {