pacc 9.2.14 → 9.3.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 +1 -1
- package/src/attributes.mjs +18 -4
- package/src/common-attributes.mjs +5 -3
- package/types/attributes.d.mts +12 -4
- package/types/common-attributes.d.mts +13 -7
package/package.json
CHANGED
package/src/attributes.mjs
CHANGED
|
@@ -45,17 +45,17 @@ function mergeAttributeDefinitions(dest, atts) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Iterate over
|
|
49
|
-
* @param {Object} definition
|
|
48
|
+
* Iterate over attributes.
|
|
49
|
+
* @param {Object} attribute definition
|
|
50
50
|
* @param {Function} [filter]
|
|
51
|
-
* @param {string[]} path
|
|
51
|
+
* @param {string[]} [path]
|
|
52
52
|
* @return {Iterable<[string[],object]>}
|
|
53
53
|
*/
|
|
54
54
|
export function* attributeIterator(definition, filter, path = []) {
|
|
55
55
|
if (definition) {
|
|
56
56
|
for (const [name, def] of Object.entries(definition)) {
|
|
57
57
|
const path2 = [...path, name];
|
|
58
|
-
if (typeof filter !==
|
|
58
|
+
if (typeof filter !== "function" || filter(name, def)) {
|
|
59
59
|
yield [path2, def];
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -64,6 +64,20 @@ export function* attributeIterator(definition, filter, path = []) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Iterate over all attributes of a type.
|
|
69
|
+
* @param {Type} type definition
|
|
70
|
+
* @param {Function} [filter]
|
|
71
|
+
* @param {string[]} [path]
|
|
72
|
+
* @return {Iterable<[string[],object]>}
|
|
73
|
+
*/
|
|
74
|
+
export function* extendingAttributeIterator(type, filter, path) {
|
|
75
|
+
if (type.extends) {
|
|
76
|
+
yield* extendingAttributeIterator(type.extends, filter, path);
|
|
77
|
+
}
|
|
78
|
+
yield* attributeIterator(type.attributes, filter, path);
|
|
79
|
+
}
|
|
80
|
+
|
|
67
81
|
export const filterWritable = (name, attribute) => attribute.writable;
|
|
68
82
|
export const filterPublic = (name, attribute) => !attribute.private;
|
|
69
83
|
|
|
@@ -5,6 +5,7 @@ import { types } from "./types.mjs";
|
|
|
5
5
|
*
|
|
6
6
|
* @property {object} type
|
|
7
7
|
* @property {boolean} isKey
|
|
8
|
+
* @property {boolean} isOwner are we the owner of the value
|
|
8
9
|
* @property {boolean} writable
|
|
9
10
|
* @property {boolean} mandatory
|
|
10
11
|
* @property {boolean} collection
|
|
@@ -19,11 +20,11 @@ import { types } from "./types.mjs";
|
|
|
19
20
|
* @property {Function} [get] get the value can be used to calculate default values
|
|
20
21
|
* @property {Function} [toInternal]
|
|
21
22
|
* @property {Function} [toExternal]
|
|
22
|
-
* @property {Set<any>} [values] allowed values
|
|
23
23
|
* @property {string} [externalName] attribute name used by external system
|
|
24
|
+
* @property {Set<any>} [values] allowed values
|
|
24
25
|
* @property {string[]|string} [env] environment variable(s) used to provide the value
|
|
25
26
|
* @property {object} [additionalValues] other values to be set in case our attribute is set
|
|
26
|
-
* @property {string} [separator]
|
|
27
|
+
* @property {string} [separator] separator for collections
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -38,7 +39,8 @@ export const default_attribute = {
|
|
|
38
39
|
persistent: false,
|
|
39
40
|
private: false,
|
|
40
41
|
credential: false,
|
|
41
|
-
isKey: false
|
|
42
|
+
isKey: false,
|
|
43
|
+
isOwner: true
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
/**
|
package/types/attributes.d.mts
CHANGED
|
@@ -6,13 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function prepareAttributesDefinitions(newDefinitions: Object, presentDefinitions?: Object): Object;
|
|
8
8
|
/**
|
|
9
|
-
* Iterate over
|
|
10
|
-
* @param {Object} definition
|
|
9
|
+
* Iterate over attributes.
|
|
10
|
+
* @param {Object} attribute definition
|
|
11
11
|
* @param {Function} [filter]
|
|
12
|
-
* @param {string[]} path
|
|
12
|
+
* @param {string[]} [path]
|
|
13
13
|
* @return {Iterable<[string[],object]>}
|
|
14
14
|
*/
|
|
15
|
-
export function attributeIterator(definition:
|
|
15
|
+
export function attributeIterator(definition: any, filter?: Function, path?: string[]): Iterable<[string[], object]>;
|
|
16
|
+
/**
|
|
17
|
+
* Iterate over all attributes of a type.
|
|
18
|
+
* @param {Type} type definition
|
|
19
|
+
* @param {Function} [filter]
|
|
20
|
+
* @param {string[]} [path]
|
|
21
|
+
* @return {Iterable<[string[],object]>}
|
|
22
|
+
*/
|
|
23
|
+
export function extendingAttributeIterator(type: Type, filter?: Function, path?: string[]): Iterable<[string[], object]>;
|
|
16
24
|
export function writableAttributeIterator(definition: any): Generator<[string[], object], void, any>;
|
|
17
25
|
export function toInternal(value: any, attribute: any): any;
|
|
18
26
|
export function toExternal(value: any, attribute: any): any;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @property {object} type
|
|
5
5
|
* @property {boolean} isKey
|
|
6
|
+
* @property {boolean} isOwner are we the owner of the value
|
|
6
7
|
* @property {boolean} writable
|
|
7
8
|
* @property {boolean} mandatory
|
|
8
9
|
* @property {boolean} collection
|
|
@@ -17,11 +18,11 @@
|
|
|
17
18
|
* @property {Function} [get] get the value can be used to calculate default values
|
|
18
19
|
* @property {Function} [toInternal]
|
|
19
20
|
* @property {Function} [toExternal]
|
|
20
|
-
* @property {Set<any>} [values] allowed values
|
|
21
21
|
* @property {string} [externalName] attribute name used by external system
|
|
22
|
+
* @property {Set<any>} [values] allowed values
|
|
22
23
|
* @property {string[]|string} [env] environment variable(s) used to provide the value
|
|
23
24
|
* @property {object} [additionalValues] other values to be set in case our attribute is set
|
|
24
|
-
* @property {string} [separator]
|
|
25
|
+
* @property {string} [separator] separator for collections
|
|
25
26
|
*/
|
|
26
27
|
/**
|
|
27
28
|
* Common attribute properties.
|
|
@@ -101,6 +102,7 @@ export namespace yesno_attribute_writable {
|
|
|
101
102
|
export let writable: boolean;
|
|
102
103
|
export let type: object;
|
|
103
104
|
export let isKey: boolean;
|
|
105
|
+
export let isOwner: boolean;
|
|
104
106
|
export let mandatory: boolean;
|
|
105
107
|
export let collection: boolean;
|
|
106
108
|
export let constructor: Function | undefined;
|
|
@@ -116,8 +118,8 @@ export namespace yesno_attribute_writable {
|
|
|
116
118
|
export let get: Function | undefined;
|
|
117
119
|
export let toInternal: Function | undefined;
|
|
118
120
|
export let toExternal: Function | undefined;
|
|
119
|
-
export let values: Set<any> | undefined;
|
|
120
121
|
export let externalName: string | undefined;
|
|
122
|
+
export let values: Set<any> | undefined;
|
|
121
123
|
export let env: string | string[] | undefined;
|
|
122
124
|
export let additionalValues: object | undefined;
|
|
123
125
|
export let separator: string | undefined;
|
|
@@ -228,6 +230,10 @@ export const language_attribute: AttributeDefinition;
|
|
|
228
230
|
export type AttributeDefinition = {
|
|
229
231
|
type: object;
|
|
230
232
|
isKey: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* are we the owner of the value
|
|
235
|
+
*/
|
|
236
|
+
isOwner: boolean;
|
|
231
237
|
writable: boolean;
|
|
232
238
|
mandatory: boolean;
|
|
233
239
|
collection: boolean;
|
|
@@ -269,14 +275,14 @@ export type AttributeDefinition = {
|
|
|
269
275
|
get?: Function | undefined;
|
|
270
276
|
toInternal?: Function | undefined;
|
|
271
277
|
toExternal?: Function | undefined;
|
|
272
|
-
/**
|
|
273
|
-
* allowed values
|
|
274
|
-
*/
|
|
275
|
-
values?: Set<any> | undefined;
|
|
276
278
|
/**
|
|
277
279
|
* attribute name used by external system
|
|
278
280
|
*/
|
|
279
281
|
externalName?: string | undefined;
|
|
282
|
+
/**
|
|
283
|
+
* allowed values
|
|
284
|
+
*/
|
|
285
|
+
values?: Set<any> | undefined;
|
|
280
286
|
/**
|
|
281
287
|
* environment variable(s) used to provide the value
|
|
282
288
|
*/
|