pacc 3.8.0 → 3.9.1
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/README.md +9 -2
- package/package.json +1 -1
- package/src/common-attributes.mjs +9 -0
- package/src/multiple.mjs +20 -11
- package/types/common-attributes.d.mts +4 -0
- package/types/multiple.d.mts +5 -4
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
|
|
|
48
48
|
* [uuid\_attribute](#uuid_attribute)
|
|
49
49
|
* [empty\_attribute](#empty_attribute)
|
|
50
50
|
* [secret\_attribute](#secret_attribute)
|
|
51
|
+
* [token\_attribute](#token_attribute)
|
|
51
52
|
* [count\_attribute](#count_attribute)
|
|
52
53
|
* [size\_attribute](#size_attribute)
|
|
53
54
|
* [url\_attribute](#url_attribute)
|
|
@@ -207,6 +208,10 @@ Type: [AttributeDefinition](#attributedefinition)
|
|
|
207
208
|
|
|
208
209
|
Type: [AttributeDefinition](#attributedefinition)
|
|
209
210
|
|
|
211
|
+
## token\_attribute
|
|
212
|
+
|
|
213
|
+
Type: [AttributeDefinition](#attributedefinition)
|
|
214
|
+
|
|
210
215
|
## count\_attribute
|
|
211
216
|
|
|
212
217
|
Type: [AttributeDefinition](#attributedefinition)
|
|
@@ -268,7 +273,9 @@ Create attributes from its definition.
|
|
|
268
273
|
|
|
269
274
|
### Parameters
|
|
270
275
|
|
|
271
|
-
* `
|
|
276
|
+
* `newDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
277
|
+
* `presentDefinitions`  
|
|
278
|
+
* `baseDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** optional merg in attributes
|
|
272
279
|
|
|
273
280
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attributes
|
|
274
281
|
|
|
@@ -279,7 +286,7 @@ Merge attribute definitions.
|
|
|
279
286
|
### Parameters
|
|
280
287
|
|
|
281
288
|
* `dest` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used also the merge target
|
|
282
|
-
* `atts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
|
|
289
|
+
* `atts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** attribute definitions to be used
|
|
283
290
|
|
|
284
291
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** merged definitions (dest)
|
|
285
292
|
|
package/package.json
CHANGED
|
@@ -100,6 +100,15 @@ export const secret_attribute = {
|
|
|
100
100
|
writable: true
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @type {AttributeDefinition}
|
|
105
|
+
*/
|
|
106
|
+
export const token_attribute = {
|
|
107
|
+
...default_attribute,
|
|
108
|
+
private: true,
|
|
109
|
+
writable: true
|
|
110
|
+
};
|
|
111
|
+
|
|
103
112
|
/**
|
|
104
113
|
* @type {AttributeDefinition}
|
|
105
114
|
*/
|
package/src/multiple.mjs
CHANGED
|
@@ -12,36 +12,45 @@ const types = {
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Create attributes from its definition.
|
|
15
|
-
* @param {Object}
|
|
15
|
+
* @param {Object} newDefinitions
|
|
16
|
+
* @param {Object?} baseDefinitions optional merg in attributes
|
|
16
17
|
* @return {Object} attributes
|
|
17
18
|
*/
|
|
18
|
-
export function prepareAttributesDefinitions(
|
|
19
|
-
for (const [name, d] of Object.entries(
|
|
19
|
+
export function prepareAttributesDefinitions(newDefinitions, presentDefinitions) {
|
|
20
|
+
for (const [name, d] of Object.entries(newDefinitions)) {
|
|
20
21
|
if (d.attributes === undefined) {
|
|
21
22
|
d.type = types[d.type] || types.base;
|
|
22
23
|
}
|
|
24
|
+
else {
|
|
25
|
+
prepareAttributesDefinitions(d.attributes);
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
|
-
|
|
28
|
+
|
|
29
|
+
return mergeAttributeDefinitions(newDefinitions, presentDefinitions);
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* Merge attribute definitions.
|
|
29
34
|
* @param {Object} dest attribute definitions to be used also the merge target
|
|
30
|
-
* @param {Object} atts attribute definitions to be used
|
|
35
|
+
* @param {Object?} atts attribute definitions to be used
|
|
31
36
|
* @return {Object} merged definitions (dest)
|
|
32
37
|
*/
|
|
33
38
|
export function mergeAttributeDefinitions(dest, atts) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
if (atts) {
|
|
40
|
+
for (const [name, ca] of Object.entries(atts)) {
|
|
41
|
+
if (ca.attributes !== undefined) {
|
|
42
|
+
const bn = dest[name];
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
if (bn !== undefined) {
|
|
45
|
+
Object.assign(ca.attributes, bn.attributes);
|
|
46
|
+
}
|
|
40
47
|
}
|
|
41
48
|
}
|
|
49
|
+
|
|
50
|
+
return Object.assign(dest, atts);
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
return
|
|
53
|
+
return dest;
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
/**
|
|
@@ -56,6 +56,10 @@ export const empty_attribute: AttributeDefinition;
|
|
|
56
56
|
* @type {AttributeDefinition}
|
|
57
57
|
*/
|
|
58
58
|
export const secret_attribute: AttributeDefinition;
|
|
59
|
+
/**
|
|
60
|
+
* @type {AttributeDefinition}
|
|
61
|
+
*/
|
|
62
|
+
export const token_attribute: AttributeDefinition;
|
|
59
63
|
/**
|
|
60
64
|
* @type {AttributeDefinition}
|
|
61
65
|
*/
|
package/types/multiple.d.mts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create attributes from its definition.
|
|
3
|
-
* @param {Object}
|
|
3
|
+
* @param {Object} newDefinitions
|
|
4
|
+
* @param {Object?} baseDefinitions optional merg in attributes
|
|
4
5
|
* @return {Object} attributes
|
|
5
6
|
*/
|
|
6
|
-
export function prepareAttributesDefinitions(
|
|
7
|
+
export function prepareAttributesDefinitions(newDefinitions: any, presentDefinitions: any): any;
|
|
7
8
|
/**
|
|
8
9
|
* Merge attribute definitions.
|
|
9
10
|
* @param {Object} dest attribute definitions to be used also the merge target
|
|
10
|
-
* @param {Object} atts attribute definitions to be used
|
|
11
|
+
* @param {Object?} atts attribute definitions to be used
|
|
11
12
|
* @return {Object} merged definitions (dest)
|
|
12
13
|
*/
|
|
13
|
-
export function mergeAttributeDefinitions(dest: any, atts: any): any;
|
|
14
|
+
export function mergeAttributeDefinitions(dest: any, atts: any | null): any;
|
|
14
15
|
/**
|
|
15
16
|
* Copies attribute values from a source object into a destination object.
|
|
16
17
|
* @param {Object} object target object to be modified
|