@adobe/acc-js-sdk 1.1.7 → 1.1.8

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/CHANGELOG.md CHANGED
@@ -5,13 +5,17 @@ This is a node.js SDK for Campaign API. It exposes the Campaign API exactly like
5
5
 
6
6
  # Changelog
7
7
 
8
+ ## Version 1.1.8
9
+ _2022_10_03_
10
+
11
+ * Added translation ids (`labelLocalizationId`,`descriptionLocalizationId`, `labelSingularLocalizationId`) for `XtkSchema`, `XtkSchemaNode`, `XtkEnumerationValue` and `XtkEnumeration`
12
+
8
13
  ## Version 1.1.7
9
14
  _2022_08_30_
10
15
 
11
16
  * New listener interface to be notified of internal events from the SDK. Can be used to integrate with observability frameworks. See the "Observers" section of the README file.
12
17
  * Experimental file upload feature. Will require server-side changes to work, and is currently limited to be used with browsers only.
13
18
 
14
-
15
19
  ## Version 1.1.6
16
20
  _2022_08_19_
17
21
 
package/README.md CHANGED
@@ -1753,7 +1753,9 @@ const root = await node.linkTarget();
1753
1753
  | **namespace** | The namespace of the schema. For instance "nms"
1754
1754
  | **name** | The name of the schema (internal name)
1755
1755
  | **label** | The label (i.e. human readable, localised) name of the node.
1756
+ | **labelLocalizationId** | The translation id of the label of the node.
1756
1757
  | **labelSingular** | The singular label (i.e. human readable, localised) name of the schema. The label of a schema is typically a plural.
1758
+ | **labelSingularTranslationId** | The translation id of the label of the node of the singular label.
1757
1759
  | **isLibrary** | For schemas, indicates if the schema is a library
1758
1760
  | **mappingType** |Schema mapping type. Usually "sql"
1759
1761
  | **md5** | The MD5 code of the schema in the form of a hexadecimal string
@@ -1771,6 +1773,7 @@ A schema is also a `XtkSchemaNode` and the corresponding properties/methods are
1771
1773
  | **children** | A array/map of children of the node. See note on the ArrayMap structure below
1772
1774
  | **dataPolicy** | Returns a string of characters which provides the data policy of the current node.
1773
1775
  | **description** | A long, human readable, description of the node
1776
+ | **descriptionLocalizationId** | The translation id of the description of the node.
1774
1777
  | **editType** |Returns a string of characters which specifies the editing type of the current node.
1775
1778
  | **enum** | The name of the enumeration for the node, or an empty string if the node does node have an enumeration. See `enumeration()` method to get the corresponding `XtkSchemaNode`
1776
1779
  | **enumerationImage** | Returns the name of the image of the current node in the form of a string of characters.
@@ -1810,6 +1813,7 @@ A schema is also a `XtkSchemaNode` and the corresponding properties/methods are
1810
1813
  | **unbound** | Returns a boolean which indicates whether the current node has an unlimited number of children of the same type.
1811
1814
  | **joins** | Element of type "link" has an array of XtkJoin. See `joinNodes` method.
1812
1815
  | **label** | The label (i.e. human readable, localised) name of the node.
1816
+ | **labelLocalizationId** | The translation id of the label of the node.
1813
1817
  | **name** | The name of the node (internal name)
1814
1818
  | **nodePath** | The xpath of the node
1815
1819
  | **parent** | The parent node (a `XtkSchemaNode` object). Will be null for schema nodes
@@ -1862,7 +1866,9 @@ A schema is also a `XtkSchemaNode` and the corresponding properties/methods are
1862
1866
  |---|---|
1863
1867
  | **name** | The name of the enumeration, fully qualified, i.e. prefixed with the schema id
1864
1868
  | **label** | The label (i.e. human readable, localised) name of the key
1869
+ | **labelLocalizationId** | The translation id of the label of the key.
1865
1870
  | **description** | A long, human readable, description of the key
1871
+ | **descriptionLocalizationId** | The translation id of the description of the key.
1866
1872
  | **baseType** | The base type of the enumeration, usually "string" or "byte"
1867
1873
  | **default** | The default value of the enumeration, casted to the enumeration type
1868
1874
  | **hasImage** | If the enumeration has an image
@@ -1874,7 +1880,9 @@ A schema is also a `XtkSchemaNode` and the corresponding properties/methods are
1874
1880
  |---|---|
1875
1881
  | **name** | The name of the key (internal name)
1876
1882
  | **label** | The label (i.e. human readable, localised) name of the key
1883
+ | **labelLocalizationId** | The translation id of the label of the key.
1877
1884
  | **description** | A long, human readable, description of the key
1885
+ | **descriptionLocalizationId** | The translation id of the description of the key.
1878
1886
  | **image** |
1879
1887
  | **enabledIf** |
1880
1888
  | **applicableIf** |
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@adobe/acc-js-sdk",
9
- "version": "1.1.7",
9
+ "version": "1.1.8",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "axios": "^0.25.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
@@ -422,6 +422,8 @@ class XtkSchemaNode {
422
422
  */
423
423
  this.nodePath = this._getNodePath(true)._path;
424
424
 
425
+ this._buildLocalizationIds();
426
+
425
427
  /**
426
428
  * Element of type "link" has an array of XtkJoin
427
429
  * @type {XtkJoin[]}
@@ -634,6 +636,35 @@ class XtkSchemaNode {
634
636
  propagateImplicitValues(this);
635
637
  }
636
638
 
639
+ /* create two ids that are identifying in an unique way the node label and
640
+ * the node description
641
+ * examples:
642
+ * nms__recipient__e____recipient__emailFormat__@desc
643
+ * nms__recipient__e____recipient__mobilePhone__@label
644
+ * */
645
+ _buildLocalizationIds() {
646
+ if (!this.parent) {
647
+ this._localizationId = this.schema.id.replace(":", "__");
648
+ } else {
649
+ this._localizationId = this.parent._localizationId;
650
+ }
651
+
652
+ if (this.parent) {
653
+ // Separate each element of the path with a double _
654
+ if (this.isAttribute) {
655
+ this._localizationId = this._localizationId + "__" + this.name.replace('@', '');
656
+ } else {
657
+ // node is not an attribute so it is an element add "e____"
658
+ this._localizationId = this._localizationId + "__e____" + this.name;
659
+ }
660
+ }
661
+ this.labelLocalizationId = this._localizationId + "__@label";
662
+ this.descriptionLocalizationId = this._localizationId + "__@desc";
663
+ if (!this.parent) {
664
+ this.labelSingularLocalizationId = this._localizationId + "__@labelSingular";
665
+ }
666
+ }
667
+
637
668
  /**
638
669
  * Indicates whether the current node has an unlimited number of children of the same type.
639
670
  *
@@ -901,9 +932,10 @@ class XtkSchemaNode {
901
932
  * @constructor
902
933
  * @param {XML.XtkObject} The enumeration value definition
903
934
  * @param {Campaign.XtkEnumerationType} baseType the enumeration type (often "string" or "byte")
935
+ * @param {string} parentTranslationId the translation id of the parent node
904
936
  * @memberof Campaign
905
937
  */
906
- function XtkEnumerationValue(xml, baseType) {
938
+ function XtkEnumerationValue(xml, baseType, parentTranslationId) {
907
939
  /**
908
940
  * The value (unique) name
909
941
  * @type {string}
@@ -914,6 +946,14 @@ function XtkEnumerationValue(xml, baseType) {
914
946
  * @type {string}
915
947
  */
916
948
  this.label = EntityAccessor.getAttributeAsString(xml, "label");
949
+ /**
950
+ * Unique identifier for the translation of the label
951
+ * */
952
+ this.labelLocalizationId = parentTranslationId + '__' + this.name + '__@label';
953
+ /**
954
+ * Unique identifier for the tran,slation of the description of the label
955
+ * */
956
+ this.descriptionLocalizationId = parentTranslationId + '__' + this.name + '__@desc';
917
957
  /**
918
958
  * A human friendly long description of the value
919
959
  * @type {string}
@@ -997,25 +1037,29 @@ class XtkEnumeration {
997
1037
  */
998
1038
  this.values = new ArrayMap();
999
1039
 
1000
- var defaultValue = EntityAccessor.getAttributeAsString(xml, "default");
1040
+ var defaultValue = EntityAccessor.getAttributeAsString(xml, "default");
1041
+ this._localizationId = `${schemaId}__${this.name}`.replace(':','__');
1001
1042
 
1002
- for (var child of EntityAccessor.getChildElements(xml, "value")) {
1003
- const e = new XtkEnumerationValue(child, this.baseType);
1004
- this.values._push(e.name, e);
1005
- if (e.image != "") this.hasImage = true;
1006
- const stringValue = EntityAccessor.getAttributeAsString(child, "value");
1007
- if (defaultValue == stringValue)
1008
- this.default = e;
1009
- }
1043
+ for (var child of EntityAccessor.getChildElements(xml, "value")) {
1044
+ const e = new XtkEnumerationValue(child, this.baseType, this._localizationId);
1045
+ this.values._push(e.name, e);
1046
+ if (e.image != "") this.hasImage = true;
1047
+ const stringValue = EntityAccessor.getAttributeAsString(child, "value");
1048
+ if (defaultValue == stringValue)
1049
+ this.default = e;
1050
+ }
1010
1051
 
1011
- propagateImplicitValues(this, true);
1052
+ this.labelLocalizationId = this._localizationId + "__@label";
1053
+ this.descriptionLocalizationId = this._localizationId + "__@desc";
1054
+ propagateImplicitValues(this, true);
1012
1055
 
1013
1056
  /**
1014
1057
  * The system enumeration name, without the schema id prefix
1015
1058
  * @type {string}
1016
1059
  */
1017
1060
  this.shortName = this.name;
1018
- this.name = `${schemaId}:${this.shortName}`;
1061
+ this.name = `${schemaId}:${this.shortName}`;
1062
+
1019
1063
  }
1020
1064
  }
1021
1065
 
@@ -1063,7 +1107,6 @@ class XtkSchema extends XtkSchemaNode {
1063
1107
  * @type {string}
1064
1108
  */
1065
1109
  this.labelSingular = EntityAccessor.getAttributeAsString(xml, "labelSingular");
1066
-
1067
1110
  /**
1068
1111
  * The schema mappgin type, following the xtk:srcSchema:mappingType enumeration
1069
1112
  * @type {Campaign.XtkSchemaMappingType}
@@ -2021,6 +2021,77 @@ describe('Application', () => {
2021
2021
  expect(schema.userDescription).toBe("recipient");
2022
2022
  });
2023
2023
  });
2024
+
2025
+ describe("Translation ids", () => {
2026
+ it("schema should have a correct label localization id", () => {
2027
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2028
+ const schema = newSchema(xml);
2029
+ expect(schema.labelLocalizationId).toBe('nms__recipient__@label');
2030
+ expect(schema.descriptionLocalizationId).toBe('nms__recipient__@desc');
2031
+ });
2032
+
2033
+ it("schema should have a correct singular label localization id", () => {
2034
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2035
+ const schema = newSchema(xml);
2036
+ expect(schema.labelSingularLocalizationId).toBe('nms__recipient__@labelSingular');
2037
+ });
2038
+
2039
+ it("root node should have a correct label localization id", () => {
2040
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2041
+ const schema = newSchema(xml);
2042
+ const root = schema.root;
2043
+ expect(root.labelLocalizationId).toBe('nms__recipient__e____recipient__@label');
2044
+ expect(root.descriptionLocalizationId).toBe('nms__recipient__e____recipient__@desc');
2045
+ });
2046
+
2047
+ it("child node should have a correct label localization id", () => {
2048
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='lib' label='library'/><element name='recipient' label='Recipients'/></schema>");
2049
+ const schema = newSchema(xml);
2050
+ const lib = schema.children["lib"];
2051
+ expect(lib.labelLocalizationId).toBe('nms__recipient__e____lib__@label');
2052
+ expect(lib.descriptionLocalizationId).toBe('nms__recipient__e____lib__@desc');
2053
+ });
2054
+
2055
+ it("attribute should have a correct label localization id", () => {
2056
+ const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
2057
+ <element name='recipient' label='Recipients'>
2058
+ <attribute name='email' type='string' label='email' length='3'/>
2059
+ </element>
2060
+ </schema>`);
2061
+ const schema = newSchema(xml);
2062
+ const root = schema.root;
2063
+ expect(root.children.get("@email").labelLocalizationId).toBe('nms__recipient__e____recipient__email__@label');
2064
+ expect(root.children.get("@email").descriptionLocalizationId).toBe('nms__recipient__e____recipient__email__@desc');
2065
+ });
2066
+
2067
+ it("Enumeration should have a correct label localization id", () => {
2068
+ const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
2069
+ <enumeration name="gender" basetype="byte"/>
2070
+ <element name='recipient' label='Recipients'></element>
2071
+ </schema>`);
2072
+ const schema = newSchema(xml);
2073
+ const enumerations = schema.enumerations;
2074
+ expect(enumerations.gender.labelLocalizationId).toBe('nms__recipient__gender__@label');
2075
+ expect(enumerations.gender.descriptionLocalizationId).toBe('nms__recipient__gender__@desc');
2076
+ });
2077
+
2078
+ it("Enumeration value should have a correct label localization id", () => {
2079
+ const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
2080
+ <enumeration name="gender" basetype="byte">
2081
+ <value name="male" value="0"/>
2082
+ <value name="female" value="1"/>
2083
+ </enumeration>
2084
+ <element name='recipient' label='Recipients'>
2085
+ <attribute advanced="true" desc="Recipient sex" enum="nms:recipient:gender"
2086
+ label="Gender" name="gender" sqlname="iGender" type="byte"/>
2087
+ </element>
2088
+ </schema>`);
2089
+ const schema = newSchema(xml);
2090
+ const enumerations = schema.enumerations;
2091
+ expect(enumerations.gender.values.male.labelLocalizationId).toBe('nms__recipient__gender__male__@label');
2092
+ expect(enumerations.gender.values.male.descriptionLocalizationId).toBe('nms__recipient__gender__male__@desc');
2093
+ })
2094
+ });
2024
2095
  });
2025
2096
 
2026
2097
  describe("CurrentLogin", () => {