@adobe/acc-js-sdk 1.1.7 → 1.1.9
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 +14 -5
- package/README.md +9 -1
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/application.js +62 -13
- package/test/application.test.js +86 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,25 +5,34 @@ 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.9
|
|
9
|
+
_2022/10/11_
|
|
10
|
+
|
|
11
|
+
* Added support for schema visibleIf attribute
|
|
12
|
+
|
|
13
|
+
## Version 1.1.8
|
|
14
|
+
_2022/10/03_
|
|
15
|
+
|
|
16
|
+
* Added translation ids (`labelLocalizationId`,`descriptionLocalizationId`, `labelSingularLocalizationId`) for `XtkSchema`, `XtkSchemaNode`, `XtkEnumerationValue` and `XtkEnumeration`
|
|
17
|
+
|
|
8
18
|
## Version 1.1.7
|
|
9
|
-
|
|
19
|
+
_2022/08/30_
|
|
10
20
|
|
|
11
21
|
* 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
22
|
* Experimental file upload feature. Will require server-side changes to work, and is currently limited to be used with browsers only.
|
|
13
23
|
|
|
14
|
-
|
|
15
24
|
## Version 1.1.6
|
|
16
|
-
|
|
25
|
+
_2022/08/19_
|
|
17
26
|
|
|
18
27
|
* New auto-refresh mechanism to keep schemas and option caches up-to-date. See `client.startRefreshCaches` and `client.stopRefreshCaches` functions.
|
|
19
28
|
|
|
20
29
|
## Version 1.1.5
|
|
21
|
-
_2022/07/
|
|
30
|
+
_2022/07/07_
|
|
22
31
|
|
|
23
32
|
* The SOAP method name was not showing up properly in the Chrome console
|
|
24
33
|
|
|
25
34
|
## Version 1.1.4
|
|
26
|
-
_2022/07/
|
|
35
|
+
_2022/07/07_
|
|
27
36
|
|
|
28
37
|
* Added `application.version` which returns the server version in the format major.minor.servicePack (ex: 8.2.10)
|
|
29
38
|
* Added the ability to push down parameters to the SOAP and transport layers. See the pushDown section of the readme file.
|
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
|
|
@@ -1826,7 +1830,7 @@ A schema is also a `XtkSchemaNode` and the corresponding properties/methods are
|
|
|
1826
1830
|
| **userEnumeration** | Returns a string of characters which is the name of the user enumeration used by the current node.
|
|
1827
1831
|
| **ref** | Some nodes are only references to other nodes. There are 2 kind of references. Local references are simply a xpath in the current schema (starting from the schema itself, and not the schema root). Fully qualified references are prefixed with a schema id. The target node can be accessed with the `refTarget` funtion.
|
|
1828
1832
|
| **isMappedAsXml** | Is the field mapped as XML?
|
|
1829
|
-
|
|
1833
|
+
| **visibleIf** | The visibility expression of the node (if any) since version 1.1.9 of the SDK
|
|
1830
1834
|
|
|
1831
1835
|
|
|
1832
1836
|
| Method | Description |
|
|
@@ -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.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@adobe/acc-js-sdk",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.9",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^0.25.0",
|
package/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -373,6 +373,12 @@ class XtkSchemaNode {
|
|
|
373
373
|
*/
|
|
374
374
|
this.unbound = EntityAccessor.getAttributeAsBoolean(xml, "unbound");
|
|
375
375
|
|
|
376
|
+
/**
|
|
377
|
+
* The expression controlling the visibility of the current node
|
|
378
|
+
* @type {string}
|
|
379
|
+
*/
|
|
380
|
+
this.visibleIf = EntityAccessor.getAttributeAsString(xml, "visibleIf");
|
|
381
|
+
|
|
376
382
|
/**
|
|
377
383
|
* Has an unlimited number of children of the same type
|
|
378
384
|
* @type {boolean}
|
|
@@ -422,6 +428,8 @@ class XtkSchemaNode {
|
|
|
422
428
|
*/
|
|
423
429
|
this.nodePath = this._getNodePath(true)._path;
|
|
424
430
|
|
|
431
|
+
this._buildLocalizationIds();
|
|
432
|
+
|
|
425
433
|
/**
|
|
426
434
|
* Element of type "link" has an array of XtkJoin
|
|
427
435
|
* @type {XtkJoin[]}
|
|
@@ -634,6 +642,35 @@ class XtkSchemaNode {
|
|
|
634
642
|
propagateImplicitValues(this);
|
|
635
643
|
}
|
|
636
644
|
|
|
645
|
+
/* create two ids that are identifying in an unique way the node label and
|
|
646
|
+
* the node description
|
|
647
|
+
* examples:
|
|
648
|
+
* nms__recipient__e____recipient__emailFormat__@desc
|
|
649
|
+
* nms__recipient__e____recipient__mobilePhone__@label
|
|
650
|
+
* */
|
|
651
|
+
_buildLocalizationIds() {
|
|
652
|
+
if (!this.parent) {
|
|
653
|
+
this._localizationId = this.schema.id.replace(":", "__");
|
|
654
|
+
} else {
|
|
655
|
+
this._localizationId = this.parent._localizationId;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (this.parent) {
|
|
659
|
+
// Separate each element of the path with a double _
|
|
660
|
+
if (this.isAttribute) {
|
|
661
|
+
this._localizationId = this._localizationId + "__" + this.name.replace('@', '');
|
|
662
|
+
} else {
|
|
663
|
+
// node is not an attribute so it is an element add "e____"
|
|
664
|
+
this._localizationId = this._localizationId + "__e____" + this.name;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
this.labelLocalizationId = this._localizationId + "__@label";
|
|
668
|
+
this.descriptionLocalizationId = this._localizationId + "__@desc";
|
|
669
|
+
if (!this.parent) {
|
|
670
|
+
this.labelSingularLocalizationId = this._localizationId + "__@labelSingular";
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
637
674
|
/**
|
|
638
675
|
* Indicates whether the current node has an unlimited number of children of the same type.
|
|
639
676
|
*
|
|
@@ -901,9 +938,10 @@ class XtkSchemaNode {
|
|
|
901
938
|
* @constructor
|
|
902
939
|
* @param {XML.XtkObject} The enumeration value definition
|
|
903
940
|
* @param {Campaign.XtkEnumerationType} baseType the enumeration type (often "string" or "byte")
|
|
941
|
+
* @param {string} parentTranslationId the translation id of the parent node
|
|
904
942
|
* @memberof Campaign
|
|
905
943
|
*/
|
|
906
|
-
function XtkEnumerationValue(xml, baseType) {
|
|
944
|
+
function XtkEnumerationValue(xml, baseType, parentTranslationId) {
|
|
907
945
|
/**
|
|
908
946
|
* The value (unique) name
|
|
909
947
|
* @type {string}
|
|
@@ -914,6 +952,14 @@ function XtkEnumerationValue(xml, baseType) {
|
|
|
914
952
|
* @type {string}
|
|
915
953
|
*/
|
|
916
954
|
this.label = EntityAccessor.getAttributeAsString(xml, "label");
|
|
955
|
+
/**
|
|
956
|
+
* Unique identifier for the translation of the label
|
|
957
|
+
* */
|
|
958
|
+
this.labelLocalizationId = parentTranslationId + '__' + this.name + '__@label';
|
|
959
|
+
/**
|
|
960
|
+
* Unique identifier for the tran,slation of the description of the label
|
|
961
|
+
* */
|
|
962
|
+
this.descriptionLocalizationId = parentTranslationId + '__' + this.name + '__@desc';
|
|
917
963
|
/**
|
|
918
964
|
* A human friendly long description of the value
|
|
919
965
|
* @type {string}
|
|
@@ -997,25 +1043,29 @@ class XtkEnumeration {
|
|
|
997
1043
|
*/
|
|
998
1044
|
this.values = new ArrayMap();
|
|
999
1045
|
|
|
1000
|
-
|
|
1046
|
+
var defaultValue = EntityAccessor.getAttributeAsString(xml, "default");
|
|
1047
|
+
this._localizationId = `${schemaId}__${this.name}`.replace(':','__');
|
|
1001
1048
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1049
|
+
for (var child of EntityAccessor.getChildElements(xml, "value")) {
|
|
1050
|
+
const e = new XtkEnumerationValue(child, this.baseType, this._localizationId);
|
|
1051
|
+
this.values._push(e.name, e);
|
|
1052
|
+
if (e.image != "") this.hasImage = true;
|
|
1053
|
+
const stringValue = EntityAccessor.getAttributeAsString(child, "value");
|
|
1054
|
+
if (defaultValue == stringValue)
|
|
1055
|
+
this.default = e;
|
|
1056
|
+
}
|
|
1010
1057
|
|
|
1011
|
-
|
|
1058
|
+
this.labelLocalizationId = this._localizationId + "__@label";
|
|
1059
|
+
this.descriptionLocalizationId = this._localizationId + "__@desc";
|
|
1060
|
+
propagateImplicitValues(this, true);
|
|
1012
1061
|
|
|
1013
1062
|
/**
|
|
1014
1063
|
* The system enumeration name, without the schema id prefix
|
|
1015
1064
|
* @type {string}
|
|
1016
1065
|
*/
|
|
1017
1066
|
this.shortName = this.name;
|
|
1018
|
-
|
|
1067
|
+
this.name = `${schemaId}:${this.shortName}`;
|
|
1068
|
+
|
|
1019
1069
|
}
|
|
1020
1070
|
}
|
|
1021
1071
|
|
|
@@ -1063,7 +1113,6 @@ class XtkSchema extends XtkSchemaNode {
|
|
|
1063
1113
|
* @type {string}
|
|
1064
1114
|
*/
|
|
1065
1115
|
this.labelSingular = EntityAccessor.getAttributeAsString(xml, "labelSingular");
|
|
1066
|
-
|
|
1067
1116
|
/**
|
|
1068
1117
|
* The schema mappgin type, following the xtk:srcSchema:mappingType enumeration
|
|
1069
1118
|
* @type {Campaign.XtkSchemaMappingType}
|
package/test/application.test.js
CHANGED
|
@@ -1255,6 +1255,21 @@ describe('Application', () => {
|
|
|
1255
1255
|
});
|
|
1256
1256
|
});
|
|
1257
1257
|
|
|
1258
|
+
describe("visibleIf", () => {
|
|
1259
|
+
|
|
1260
|
+
it("Should extract visibleIf", async () => {
|
|
1261
|
+
var xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
|
|
1262
|
+
<element name='recipient' label='Recipients'>
|
|
1263
|
+
<element name="myAddress" visibleIf="HasPackage('pkg')"/>
|
|
1264
|
+
</element>
|
|
1265
|
+
</schema>`);
|
|
1266
|
+
var schema = newSchema(xml);
|
|
1267
|
+
// Pointing to the node with ref itself => return it
|
|
1268
|
+
var node = await schema.root.findNode("myAddress");
|
|
1269
|
+
expect(node).toMatchObject({ name:"myAddress", visibleIf:"HasPackage('pkg')", childrenCount:0 });
|
|
1270
|
+
});
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1258
1273
|
describe("Links", () => {
|
|
1259
1274
|
it("Should find link node", async () => {
|
|
1260
1275
|
var xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
|
|
@@ -2021,6 +2036,77 @@ describe('Application', () => {
|
|
|
2021
2036
|
expect(schema.userDescription).toBe("recipient");
|
|
2022
2037
|
});
|
|
2023
2038
|
});
|
|
2039
|
+
|
|
2040
|
+
describe("Translation ids", () => {
|
|
2041
|
+
it("schema should have a correct label localization id", () => {
|
|
2042
|
+
const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
|
|
2043
|
+
const schema = newSchema(xml);
|
|
2044
|
+
expect(schema.labelLocalizationId).toBe('nms__recipient__@label');
|
|
2045
|
+
expect(schema.descriptionLocalizationId).toBe('nms__recipient__@desc');
|
|
2046
|
+
});
|
|
2047
|
+
|
|
2048
|
+
it("schema should have a correct singular label localization id", () => {
|
|
2049
|
+
const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
|
|
2050
|
+
const schema = newSchema(xml);
|
|
2051
|
+
expect(schema.labelSingularLocalizationId).toBe('nms__recipient__@labelSingular');
|
|
2052
|
+
});
|
|
2053
|
+
|
|
2054
|
+
it("root node should have a correct label localization id", () => {
|
|
2055
|
+
const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
|
|
2056
|
+
const schema = newSchema(xml);
|
|
2057
|
+
const root = schema.root;
|
|
2058
|
+
expect(root.labelLocalizationId).toBe('nms__recipient__e____recipient__@label');
|
|
2059
|
+
expect(root.descriptionLocalizationId).toBe('nms__recipient__e____recipient__@desc');
|
|
2060
|
+
});
|
|
2061
|
+
|
|
2062
|
+
it("child node should have a correct label localization id", () => {
|
|
2063
|
+
const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='lib' label='library'/><element name='recipient' label='Recipients'/></schema>");
|
|
2064
|
+
const schema = newSchema(xml);
|
|
2065
|
+
const lib = schema.children["lib"];
|
|
2066
|
+
expect(lib.labelLocalizationId).toBe('nms__recipient__e____lib__@label');
|
|
2067
|
+
expect(lib.descriptionLocalizationId).toBe('nms__recipient__e____lib__@desc');
|
|
2068
|
+
});
|
|
2069
|
+
|
|
2070
|
+
it("attribute should have a correct label localization id", () => {
|
|
2071
|
+
const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
|
|
2072
|
+
<element name='recipient' label='Recipients'>
|
|
2073
|
+
<attribute name='email' type='string' label='email' length='3'/>
|
|
2074
|
+
</element>
|
|
2075
|
+
</schema>`);
|
|
2076
|
+
const schema = newSchema(xml);
|
|
2077
|
+
const root = schema.root;
|
|
2078
|
+
expect(root.children.get("@email").labelLocalizationId).toBe('nms__recipient__e____recipient__email__@label');
|
|
2079
|
+
expect(root.children.get("@email").descriptionLocalizationId).toBe('nms__recipient__e____recipient__email__@desc');
|
|
2080
|
+
});
|
|
2081
|
+
|
|
2082
|
+
it("Enumeration should have a correct label localization id", () => {
|
|
2083
|
+
const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
|
|
2084
|
+
<enumeration name="gender" basetype="byte"/>
|
|
2085
|
+
<element name='recipient' label='Recipients'></element>
|
|
2086
|
+
</schema>`);
|
|
2087
|
+
const schema = newSchema(xml);
|
|
2088
|
+
const enumerations = schema.enumerations;
|
|
2089
|
+
expect(enumerations.gender.labelLocalizationId).toBe('nms__recipient__gender__@label');
|
|
2090
|
+
expect(enumerations.gender.descriptionLocalizationId).toBe('nms__recipient__gender__@desc');
|
|
2091
|
+
});
|
|
2092
|
+
|
|
2093
|
+
it("Enumeration value should have a correct label localization id", () => {
|
|
2094
|
+
const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
|
|
2095
|
+
<enumeration name="gender" basetype="byte">
|
|
2096
|
+
<value name="male" value="0"/>
|
|
2097
|
+
<value name="female" value="1"/>
|
|
2098
|
+
</enumeration>
|
|
2099
|
+
<element name='recipient' label='Recipients'>
|
|
2100
|
+
<attribute advanced="true" desc="Recipient sex" enum="nms:recipient:gender"
|
|
2101
|
+
label="Gender" name="gender" sqlname="iGender" type="byte"/>
|
|
2102
|
+
</element>
|
|
2103
|
+
</schema>`);
|
|
2104
|
+
const schema = newSchema(xml);
|
|
2105
|
+
const enumerations = schema.enumerations;
|
|
2106
|
+
expect(enumerations.gender.values.male.labelLocalizationId).toBe('nms__recipient__gender__male__@label');
|
|
2107
|
+
expect(enumerations.gender.values.male.descriptionLocalizationId).toBe('nms__recipient__gender__male__@desc');
|
|
2108
|
+
})
|
|
2109
|
+
});
|
|
2024
2110
|
});
|
|
2025
2111
|
|
|
2026
2112
|
describe("CurrentLogin", () => {
|