pacc 4.12.1 → 4.13.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/README.md +1 -1
- package/package.json +1 -1
- package/src/attributes.mjs +6 -4
- package/src/common-attributes.mjs +8 -1
- package/src/properties.mjs +3 -6
- package/types/common-attributes.d.mts +4 -0
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ Create attributes from its definition.
|
|
|
133
133
|
### Parameters
|
|
134
134
|
|
|
135
135
|
* `newDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
136
|
-
* `presentDefinitions` **
|
|
136
|
+
* `presentDefinitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** optional merg in attributes
|
|
137
137
|
|
|
138
138
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attributes
|
|
139
139
|
|
package/package.json
CHANGED
package/src/attributes.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
const types = {
|
|
2
2
|
base: { name: "base" },
|
|
3
|
-
string: { name: "string" },
|
|
4
|
-
number: { name: "number" },
|
|
3
|
+
string: { name: "string", extends: "base" },
|
|
4
|
+
number: { name: "number", extends: "base" },
|
|
5
5
|
integer: {
|
|
6
6
|
name: "integer",
|
|
7
|
+
extends: "base",
|
|
7
8
|
convertValue: value => (typeof value === "string" ? parseInt(value) : value)
|
|
8
9
|
},
|
|
9
10
|
"unsigned-integer": { name: "unsigned-integer", extends: "integer" },
|
|
10
11
|
boolean: {
|
|
11
12
|
name: "boolean",
|
|
13
|
+
extends: "base",
|
|
12
14
|
convertValue: value => (!value || value === "0" ? false : true)
|
|
13
15
|
},
|
|
14
|
-
url: { name: "url" },
|
|
15
|
-
object: { name: "object" }
|
|
16
|
+
url: { name: "url", extends: "string" },
|
|
17
|
+
object: { name: "object", extends: "base" }
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -67,6 +67,14 @@ export const name_attribute = {
|
|
|
67
67
|
isKey: true
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* @type {AttributeDefinition}
|
|
72
|
+
*/
|
|
73
|
+
export const name_attribute_writable = {
|
|
74
|
+
...name_attribute,
|
|
75
|
+
writable: true
|
|
76
|
+
};
|
|
77
|
+
|
|
70
78
|
/**
|
|
71
79
|
* @type {AttributeDefinition}
|
|
72
80
|
*/
|
|
@@ -176,7 +184,6 @@ export { secret_attribute as username_attribute };
|
|
|
176
184
|
*/
|
|
177
185
|
export { secret_attribute as password_attribute };
|
|
178
186
|
|
|
179
|
-
|
|
180
187
|
/**
|
|
181
188
|
* @type {AttributeDefinition}
|
|
182
189
|
*/
|
package/src/properties.mjs
CHANGED
|
@@ -6,14 +6,14 @@ export function definePropertiesFromAttributes(
|
|
|
6
6
|
object,
|
|
7
7
|
attributes,
|
|
8
8
|
values,
|
|
9
|
-
properties={}
|
|
9
|
+
properties = {}
|
|
10
10
|
) {
|
|
11
11
|
const applyLater = {};
|
|
12
12
|
|
|
13
13
|
for (const [path, attribute] of attributeIterator(attributes)) {
|
|
14
14
|
const name = path.join(".");
|
|
15
15
|
|
|
16
|
-
let value = getAttribute(values, name, attribute);
|
|
16
|
+
let value = getAttribute(values, name, attribute) ?? values?.[name];
|
|
17
17
|
|
|
18
18
|
if (value !== undefined && path.length === 1) {
|
|
19
19
|
const op = Object.getOwnPropertyDescriptor(
|
|
@@ -27,10 +27,7 @@ export function definePropertiesFromAttributes(
|
|
|
27
27
|
if (op?.set || property?.set) {
|
|
28
28
|
applyLater[name] = value;
|
|
29
29
|
} else {
|
|
30
|
-
properties[name] = Object.assign(
|
|
31
|
-
{ value, writable: attribute.writable },
|
|
32
|
-
property
|
|
33
|
-
);
|
|
30
|
+
properties[name] = Object.assign({ ...attribute, value }, property);
|
|
34
31
|
}
|
|
35
32
|
} else {
|
|
36
33
|
setAttribute(object, name, value, attribute);
|
|
@@ -47,6 +47,10 @@ export const string_collection_attribute_writable: AttributeDefinition;
|
|
|
47
47
|
* @type {AttributeDefinition}
|
|
48
48
|
*/
|
|
49
49
|
export const name_attribute: AttributeDefinition;
|
|
50
|
+
/**
|
|
51
|
+
* @type {AttributeDefinition}
|
|
52
|
+
*/
|
|
53
|
+
export const name_attribute_writable: AttributeDefinition;
|
|
50
54
|
/**
|
|
51
55
|
* @type {AttributeDefinition}
|
|
52
56
|
*/
|