pacc 3.8.0 → 3.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -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} definitions
15
+ * @param {Object} newDefinitions
16
+ * @param {Object?} baseDefinitions optional merg in attributes
16
17
  * @return {Object} attributes
17
18
  */
18
- export function prepareAttributesDefinitions(definitions) {
19
- for (const [name, d] of Object.entries(definitions)) {
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
- return definitions;
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
- for (const [name, ca] of Object.entries(atts)) {
35
- if (ca.attributes !== undefined) {
36
- const bn = dest[name];
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
- if (bn !== undefined) {
39
- Object.assign(ca.attributes, bn.attributes);
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 Object.assign(dest, atts);
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
  */
@@ -1,16 +1,17 @@
1
1
  /**
2
2
  * Create attributes from its definition.
3
- * @param {Object} definitions
3
+ * @param {Object} newDefinitions
4
+ * @param {Object?} baseDefinitions optional merg in attributes
4
5
  * @return {Object} attributes
5
6
  */
6
- export function prepareAttributesDefinitions(definitions: any): any;
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