@adobe/acc-js-sdk 1.0.7 → 1.1.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.
- package/CHANGELOG.md +39 -1
- package/MIGRATION.md +160 -0
- package/README.md +303 -64
- package/compile.js +1 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/application.js +687 -186
- package/src/client.js +18 -10
- package/src/domUtil.js +6 -3
- package/src/entityAccessor.js +5 -5
- package/src/index.js +58 -2
- package/src/testUtil.js +47 -0
- package/src/util.js +144 -0
- package/src/xtkCaster.js +37 -0
- package/test/application.test.js +2053 -649
- package/test/client.test.js +78 -7
- package/test/domUtil.test.js +150 -2
- package/test/escape.test.js +79 -47
- package/test/index.test.js +69 -1
- package/test/mock.js +11 -1
- package/test/testUtil.test.js +64 -0
- package/test/util.test.js +167 -1
- package/test/xtkCaster.test.js +122 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,46 @@ 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.0
|
|
9
|
+
_2022/03/05_
|
|
10
|
+
|
|
11
|
+
Changes in the metadata api (`application.getSchema`) which was not completely implemented. While this API is meant to be largely compatible with the [ACC JS API](https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/c-Application.html), it's not always possible to do so because of the asynchronous nature of the SDK. The JS API is executed inside the Campaign application server can will synchronously and transparently fetch schemas as needed. Howerer the SDK runs outside of the Campaign server. It will synchronously and transparently fetch schemas as needed, but this will be done adynchronously.
|
|
12
|
+
|
|
13
|
+
Differences are document in the `Application` section of the README.
|
|
14
|
+
|
|
15
|
+
* Provide array and map access to XtkSchemaKey.fields,
|
|
16
|
+
* The order of children of a node has been changed. Beore 1.1.0, it was attributes, then elements. After 1.1.0, it's the order defined in the schema XML
|
|
17
|
+
* New application.getEnumeration function to retreive an enumeration
|
|
18
|
+
* Removed the XtkSchemaNode.hasChild function
|
|
19
|
+
* Support for ref nodes and links: XtkSchemaNode.refTarget(), XtkSchemaNode.linkTarget() functions
|
|
20
|
+
* Reviews XtkSchemaNode.findNode() function to support links, refs, ANY type, etc. and is now asynchronous
|
|
21
|
+
* The name attribute of enumerations (`XtkEnumeration.name`) is now the fully qualified name of the enumeration, i.e. is prefixed by the schema id
|
|
22
|
+
|
|
23
|
+
## Version 1.0.9
|
|
24
|
+
_2022/03/02_
|
|
25
|
+
|
|
26
|
+
* Ability to invoke SOAP calls dynamically with parameters computed at invocation time by a delegate function
|
|
27
|
+
* Fixed bug in XPath constructor which now supports expanded paths, i.e. xpaths such as `[@recipient-id]`.
|
|
28
|
+
* EntityAccessor: change the heuristic to detect XML types: use "nodeType" and "tagName" functions instead of "insertAdjacentElement" (which was not always working in the context of a React application)
|
|
29
|
+
* Add new escaping functions: `escapeForLike`, `expandXPath`, `unexpandXPath`, `xtkConstText`
|
|
30
|
+
* New XtkCaster methods: `asDatetime` (alias to `asTimestamp`), `isStringType`, and `isNumericType`
|
|
31
|
+
* Metadata API (application.getSchema)
|
|
32
|
+
* keys have a `isInternal` internal attribute which was mistakenly using the "string" type. It's now correctly using the boolean type.
|
|
33
|
+
* Added missing attributes on the XtkSchema: md5
|
|
34
|
+
* Added missing attributes on the XtkSchemaNode objects: dataPolicy, editType folderModel, enumerationImage, size, userEnumeration, hasUserEnumeration, isCollection,
|
|
35
|
+
isAdvanced, isAnyType, isLink, hasEnumeration, hasSQLTable, SQLName, SQLTable, isMappedAsXML, isTemporaryTable, isElementOnly, isDefaultOnDuplicate, isExternalJoin,
|
|
36
|
+
isMemo, isMemoData, isBlob, isCDATA, isNotNull, isRequired, isSQL, PKSequence, revLink, isCalculated, expr, isAutoIncrement, isAutoPK, isAutoUUID, isAutoStg, packageStatusString, and packageStatus
|
|
37
|
+
* Attribute type defaults to string if not set
|
|
38
|
+
* Removed userDescription attribut from schema nodes (only available at the schema level)
|
|
39
|
+
* Changed the toString function to use 4 spaces instead of 3 for indentation and display node label and internal name
|
|
40
|
+
* When label or description is missing from schema nodes or from enumerations, they default to the name value
|
|
41
|
+
* application.getSchema now uses a in-memory cache
|
|
42
|
+
|
|
43
|
+
For breaking changes see the [migration guide](MIGRATION.md)
|
|
44
|
+
|
|
45
|
+
|
|
8
46
|
## Version 1.0.7
|
|
9
|
-
|
|
47
|
+
_2022/01/24_
|
|
10
48
|
* Added a hook `refreshClient` on connection parameters. This is a callback called when an authentication token expires. It can be used to implement reconnection logic
|
|
11
49
|
* New attributes on the schema API (application.getSchema)
|
|
12
50
|
* The `enum` attribute of a schema node returns the corresponding enum attribute, i.e. the enumeration name
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Migration guide
|
|
2
|
+
|
|
3
|
+
# Version 1.1.0
|
|
4
|
+
|
|
5
|
+
In version 1.1.0, changes were made in the metadata API. The SDK lets you access schema as JSON objects (method `client.getSchema`) or provides an object model around schemas with typed objects, as in https://experienceleague.adobe.com/developer/campaign-api/api/c-Schema.html, which can be accessed with `application.getSchema`.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
The following potentially breaking changes were introduced
|
|
9
|
+
|
|
10
|
+
* Schemas retreived by `application.getSchema` are cached in memory
|
|
11
|
+
* Attributes without an explicit type will be reported as `string` type instead of empty type
|
|
12
|
+
* The `userDescription` property removed from `XtkSchemaNode` and only available on `XtkSchema`
|
|
13
|
+
* The `children` of a `XtkSchemaNode` are now reported in the same order as they appear in the schema
|
|
14
|
+
* Implicit values are propagated for `XtkSchemaNode` and enumeration. It means that empty labels and desciptions not have a non empty value infered from the name attribute
|
|
15
|
+
* The `XtkSchemaNode.hasChild` function has been removed
|
|
16
|
+
* Enumerations of a schema, values of an enumeration, children of a schema node, keys of a schema, and fields of a key are now returned as a `ArrayMap` type instead of a key/value. This change allows to access elements as either an array or a dictionary, or map, filter, iterate through elements.
|
|
17
|
+
* The string representation of schema nodes : `XtkSchema.toString` and `XtkSchemaNode.toString` has changed
|
|
18
|
+
* The `XtkSchemaNode.findNode` method is now asynchronous and its signature has changed
|
|
19
|
+
* The name attribute of enumerations is now always the fully qualified name (ex: `nms:recipient:gender` instead of `gender`). The non qualified name is still available with the `shortName` property.
|
|
20
|
+
|
|
21
|
+
## In-memory cache
|
|
22
|
+
Schema objects have their own in-memory cache, in addition to the SDK cache
|
|
23
|
+
|
|
24
|
+
## Attribute type
|
|
25
|
+
Attributes with no type are now reported as `string`.
|
|
26
|
+
|
|
27
|
+
Before
|
|
28
|
+
```js
|
|
29
|
+
// Deprecated syntax
|
|
30
|
+
if (!attribute.type || attribute.type === "string") ...
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
After
|
|
34
|
+
```js
|
|
35
|
+
if (attribute.type === "string") ...
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
or better, use `XtkCaster.isStringType` which will handle all variant of string types, such as `memo`, `html`, etc.
|
|
39
|
+
```js
|
|
40
|
+
if (XtkCaster.isStringType(attribute.type)) ...
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## userDescription property
|
|
44
|
+
The `userDescription` property was set on the `XtkSchemaNode` object and has been moved to the `XtkSchema` object
|
|
45
|
+
|
|
46
|
+
## Order of children
|
|
47
|
+
The order of children of a node has been changed. Beore 1.1.0, it was attributes, then elements. After 1.1.0, it's the order defined in the schema XML
|
|
48
|
+
|
|
49
|
+
## Propagate implicit values
|
|
50
|
+
Automatically set schema nodes label and description properties if they are not set.
|
|
51
|
+
* Schema node. If a node does not have a label, the SDK will generate a label from the name (with first letter in upper case) instead of returning an empty string. Similarly, the node description property will be set from the label.
|
|
52
|
+
* enumeration label will be set with the same rules
|
|
53
|
+
|
|
54
|
+
## Removed hasChild function
|
|
55
|
+
The function `XtkSchemaNode.hasChild` has been removed.
|
|
56
|
+
|
|
57
|
+
Before
|
|
58
|
+
```js
|
|
59
|
+
// Deprecated syntax (will fail at runtime)
|
|
60
|
+
if (node.hasChild("@email")) { ... }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
After
|
|
64
|
+
```js
|
|
65
|
+
if (!node.children.get("@email")) { ... }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## ArrayMaps
|
|
69
|
+
Collection of child elements which were accessed as maps are now accessed with a special `ArrayMap` object which allows to access them either as maps of arrays and include convenience functions for iteration
|
|
70
|
+
* fields of a key (`XtkSchemaKey.fields`)
|
|
71
|
+
* chldren of a node (`XtkSchemaNode.children`)
|
|
72
|
+
* keys of a node (`XtkSchemaNode.keys`)
|
|
73
|
+
* values of an enumeration (`XtkEnumeration.values`)
|
|
74
|
+
* enumerations of a schema (`XtkSchema.enumerations`)
|
|
75
|
+
|
|
76
|
+
As a consequence, it's deprecated to access the properties above by name. It still works in most of the cases, but will fail for object whose name collides with JavaScript function names. For exampl, for an element named 'forEach'.
|
|
77
|
+
|
|
78
|
+
Instead, use one of the following constructs.
|
|
79
|
+
|
|
80
|
+
To iterate over a collection, use `map`, `forEach`, or a `for ... of` loop. Do not use the for ... in loop.
|
|
81
|
+
|
|
82
|
+
Before
|
|
83
|
+
```js
|
|
84
|
+
// Not supported anymore. Will only work in some cases
|
|
85
|
+
for (key in node.children) { const child = node.children[key]; ... }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
After
|
|
89
|
+
```js
|
|
90
|
+
node.children.forEach(child => ...);
|
|
91
|
+
node.children.map(child => ...);
|
|
92
|
+
for (child of node.children) { ... }
|
|
93
|
+
for (let i=0 i<node.children.lenght; i++) { const child = node.children[i]; ... }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Collection items can be accessed by name or index with the `get` function, or with an array index.
|
|
97
|
+
|
|
98
|
+
Before
|
|
99
|
+
```js
|
|
100
|
+
// Not supported anymore. Will only work in some cases
|
|
101
|
+
const child = node.children["@email"];
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
After
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
const child = node.children[3];
|
|
108
|
+
const child = node.children.get(3);
|
|
109
|
+
const child = node.children.get("@email");
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## Schema and SchemaNode toString
|
|
114
|
+
The `toString` function has been changed to better display a node structure. In general, this function is mostly for debugging purpose, and you should not rely on the exact output.
|
|
115
|
+
|
|
116
|
+
## XtkSchemaNode.findNode
|
|
117
|
+
The `findNode` function has been modified in multiple ways.
|
|
118
|
+
|
|
119
|
+
* The function is now **asynchronous** and returns a Promise. The reason is that in order to support all the use cases supported in Campaign JS API, findNode needs to follow references and links, and therefore may have to dynamically load schemas.
|
|
120
|
+
|
|
121
|
+
* The function now supports `ref` nodes. Ref nodes are schema nodes having a `ref` property which is a reference to another node, possibly in a different schema.
|
|
122
|
+
* If the xpath passed to the function ends with a ref node, the ref node itself will be returned. We're not following the reference. You can use the `refTarget` method to explicitely follow the reference
|
|
123
|
+
* If the xpath traverse intermediate nodes which are ref nodes, the `findNode` method will follow the reference. For instance, the start activity in a workflow is a reference. Finding the xpath "start/@img" will follow the start reference and find the @img attribute from there
|
|
124
|
+
|
|
125
|
+
* Support of type `ANY`. The type `ANY` in Campaign is used to describe a node which can contain arbitrary child nodes, without any strongly defined structure. The `findNode` function will only be able to return direct children of a node of `ANY` type.
|
|
126
|
+
|
|
127
|
+
* Support for links. If the xpath parameter contains links, `findNode` will follow the link target with the same rules as for reference nodes. To get the target of a link, use the `linkTarget` method instead of `refTarget`.
|
|
128
|
+
|
|
129
|
+
* The `findNode` function now takes only one parameter: the xpath to search for. The `strict` and `mustExist` parameters were removed. The function is now always in strict mode, i.e. will not try to guess if you're searching for an element or attribute. The function will only throw if the schema it's working on are malformed. For instance, if the target property of a link is not a syntaxically correct schema id. If however, the node you're looking for does not exist, or if an intermediate node or schema does not exist, findNode will simply return null or undefined, and will not throw. The `mustExist` param may be reintroduced in the future for better error reporting.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
Basic usage of `findNode`
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
Before
|
|
136
|
+
```js
|
|
137
|
+
// Deprecated, will not work anymore
|
|
138
|
+
try {
|
|
139
|
+
const email = schema.root.findNode("@email");
|
|
140
|
+
} catch(error) {
|
|
141
|
+
// maybe @email does not exist, or maybe the schema is invalid
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
After
|
|
146
|
+
```js
|
|
147
|
+
try {
|
|
148
|
+
const email = await schema.root.findNode("@email");
|
|
149
|
+
if (!email) {
|
|
150
|
+
// @email does not exist
|
|
151
|
+
}
|
|
152
|
+
} catch(error) {
|
|
153
|
+
// schema is invalid
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## Enumeration name
|
|
159
|
+
|
|
160
|
+
* The name attribute of enumerations (`XtkEnumeration.name`) is now the fully qualified name of the enumeration, i.e. is prefixed by the schema id
|