pacc 9.2.14 → 9.3.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 +36 -20
- 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 +17 -8
package/README.md
CHANGED
|
@@ -75,8 +75,10 @@ tokens "abc" "
|
|
|
75
75
|
* [Parameters](#parameters-1)
|
|
76
76
|
* [attributeIterator](#attributeiterator)
|
|
77
77
|
* [Parameters](#parameters-2)
|
|
78
|
-
* [
|
|
78
|
+
* [extendingAttributeIterator](#extendingattributeiterator)
|
|
79
79
|
* [Parameters](#parameters-3)
|
|
80
|
+
* [parseBytes](#parsebytes)
|
|
81
|
+
* [Parameters](#parameters-4)
|
|
80
82
|
* [AttributeDefinition](#attributedefinition)
|
|
81
83
|
* [Properties](#properties-1)
|
|
82
84
|
* [default\_attribute](#default_attribute)
|
|
@@ -134,40 +136,40 @@ tokens "abc" "
|
|
|
134
136
|
* [timeout\_attribute](#timeout_attribute)
|
|
135
137
|
* [language\_attribute](#language_attribute)
|
|
136
138
|
* [environmentValues](#environmentvalues)
|
|
137
|
-
* [Parameters](#parameters-
|
|
139
|
+
* [Parameters](#parameters-5)
|
|
138
140
|
* [expandContextDefault](#expandcontextdefault)
|
|
139
141
|
* [expandContextDoubbleCurly](#expandcontextdoubblecurly)
|
|
140
142
|
* [expand](#expand)
|
|
141
|
-
* [Parameters](#parameters-
|
|
143
|
+
* [Parameters](#parameters-6)
|
|
142
144
|
* [promises](#promises)
|
|
143
145
|
* [filter](#filter)
|
|
144
|
-
* [Parameters](#parameters-6)
|
|
145
|
-
* [setAttributes](#setattributes)
|
|
146
146
|
* [Parameters](#parameters-7)
|
|
147
|
-
* [
|
|
147
|
+
* [setAttributes](#setattributes)
|
|
148
148
|
* [Parameters](#parameters-8)
|
|
149
|
-
* [
|
|
149
|
+
* [getAttributes](#getattributes)
|
|
150
150
|
* [Parameters](#parameters-9)
|
|
151
|
+
* [getAttributesJSON](#getattributesjson)
|
|
152
|
+
* [Parameters](#parameters-10)
|
|
151
153
|
* [tokens](#tokens)
|
|
152
154
|
* [tokens](#tokens-1)
|
|
153
|
-
* [Parameters](#parameters-10)
|
|
154
|
-
* [setAttribute](#setattribute)
|
|
155
155
|
* [Parameters](#parameters-11)
|
|
156
|
-
* [
|
|
156
|
+
* [setAttribute](#setattribute)
|
|
157
157
|
* [Parameters](#parameters-12)
|
|
158
|
-
* [
|
|
158
|
+
* [getAttribute](#getattribute)
|
|
159
159
|
* [Parameters](#parameters-13)
|
|
160
|
-
* [
|
|
160
|
+
* [getAttributeAndOperator](#getattributeandoperator)
|
|
161
161
|
* [Parameters](#parameters-14)
|
|
162
|
-
* [
|
|
162
|
+
* [parseDuration](#parseduration)
|
|
163
163
|
* [Parameters](#parameters-15)
|
|
164
|
-
* [
|
|
164
|
+
* [formatDuration](#formatduration)
|
|
165
165
|
* [Parameters](#parameters-16)
|
|
166
|
+
* [formatDurationISO](#formatdurationiso)
|
|
167
|
+
* [Parameters](#parameters-17)
|
|
166
168
|
* [lookup](#lookup)
|
|
167
169
|
* [Token](#token)
|
|
168
170
|
* [Properties](#properties-2)
|
|
169
171
|
* [createToken](#createtoken)
|
|
170
|
-
* [Parameters](#parameters-
|
|
172
|
+
* [Parameters](#parameters-18)
|
|
171
173
|
* [PLUS](#plus)
|
|
172
174
|
* [MINUS](#minus)
|
|
173
175
|
* [STAR](#star)
|
|
@@ -202,7 +204,7 @@ tokens "abc" "
|
|
|
202
204
|
* [Type](#type)
|
|
203
205
|
* [Properties](#properties-3)
|
|
204
206
|
* [raiseOnUnknownType](#raiseonunknowntype)
|
|
205
|
-
* [Parameters](#parameters-
|
|
207
|
+
* [Parameters](#parameters-19)
|
|
206
208
|
|
|
207
209
|
## AST
|
|
208
210
|
|
|
@@ -236,13 +238,26 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
236
238
|
|
|
237
239
|
## attributeIterator
|
|
238
240
|
|
|
239
|
-
Iterate over
|
|
241
|
+
Iterate over attributes.
|
|
240
242
|
|
|
241
243
|
### Parameters
|
|
242
244
|
|
|
243
|
-
* `definition`
|
|
245
|
+
* `definition`  
|
|
244
246
|
* `filter` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
245
|
-
* `path` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
247
|
+
* `path` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** (optional, default `[]`)
|
|
248
|
+
* `attribute` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** definition
|
|
249
|
+
|
|
250
|
+
Returns **Iterable<\[[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)]>** 
|
|
251
|
+
|
|
252
|
+
## extendingAttributeIterator
|
|
253
|
+
|
|
254
|
+
Iterate over all attributes of a type.
|
|
255
|
+
|
|
256
|
+
### Parameters
|
|
257
|
+
|
|
258
|
+
* `type` **[Type](#type)** definition
|
|
259
|
+
* `filter` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
260
|
+
* `path` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** 
|
|
246
261
|
|
|
247
262
|
Returns **Iterable<\[[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)]>** 
|
|
248
263
|
|
|
@@ -264,6 +279,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
264
279
|
|
|
265
280
|
* `type` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
266
281
|
* `isKey` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
282
|
+
* `isOwner` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** are we the owner of the value
|
|
267
283
|
* `writable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
268
284
|
* `mandatory` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
269
285
|
* `collection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
@@ -278,8 +294,8 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
278
294
|
* `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
|
|
279
295
|
* `toInternal` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
280
296
|
* `toExternal` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
281
|
-
* `values` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)\<any>?** allowed values
|
|
282
297
|
* `externalName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** attribute name used by external system
|
|
298
|
+
* `values` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)\<any>?** allowed values
|
|
283
299
|
* `env` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** environment variable(s) used to provide the value
|
|
284
300
|
* `additionalValues` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** other values to be set in case our attribute is set
|
|
285
301
|
* `separator` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** separator for collections
|
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
|
|
|
@@ -7,7 +7,8 @@ import { types } from "./types.mjs";
|
|
|
7
7
|
* @property {boolean} isKey
|
|
8
8
|
* @property {boolean} writable
|
|
9
9
|
* @property {boolean} mandatory
|
|
10
|
-
* @property {boolean} collection
|
|
10
|
+
* @property {boolean} collection are we a collection (set, map, array)
|
|
11
|
+
* @property {boolean} owner are we the owner of the value
|
|
11
12
|
* @property {Function} [constructor] (collection) constructor
|
|
12
13
|
* @property {boolean} [private] should the value be shown
|
|
13
14
|
* @property {boolean} [credential] any type of credential
|
|
@@ -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
|
/**
|
|
@@ -35,6 +36,7 @@ export const default_attribute = {
|
|
|
35
36
|
writable: false,
|
|
36
37
|
mandatory: false,
|
|
37
38
|
collection: false,
|
|
39
|
+
owner: true,
|
|
38
40
|
persistent: false,
|
|
39
41
|
private: false,
|
|
40
42
|
credential: false,
|
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;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* @property {boolean} isKey
|
|
6
6
|
* @property {boolean} writable
|
|
7
7
|
* @property {boolean} mandatory
|
|
8
|
-
* @property {boolean} collection
|
|
8
|
+
* @property {boolean} collection are we a collection (set, map, array)
|
|
9
|
+
* @property {boolean} owner are we the owner of the value
|
|
9
10
|
* @property {Function} [constructor] (collection) constructor
|
|
10
11
|
* @property {boolean} [private] should the value be shown
|
|
11
12
|
* @property {boolean} [credential] any type of credential
|
|
@@ -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.
|
|
@@ -103,6 +104,7 @@ export namespace yesno_attribute_writable {
|
|
|
103
104
|
export let isKey: boolean;
|
|
104
105
|
export let mandatory: boolean;
|
|
105
106
|
export let collection: boolean;
|
|
107
|
+
export let owner: boolean;
|
|
106
108
|
export let constructor: Function | undefined;
|
|
107
109
|
let _private: boolean | undefined;
|
|
108
110
|
export { _private as private };
|
|
@@ -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;
|
|
@@ -230,7 +232,14 @@ export type AttributeDefinition = {
|
|
|
230
232
|
isKey: boolean;
|
|
231
233
|
writable: boolean;
|
|
232
234
|
mandatory: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* are we a collection (set, map, array)
|
|
237
|
+
*/
|
|
233
238
|
collection: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* are we the owner of the value
|
|
241
|
+
*/
|
|
242
|
+
owner: boolean;
|
|
234
243
|
/**
|
|
235
244
|
* (collection) constructor
|
|
236
245
|
*/
|
|
@@ -269,14 +278,14 @@ export type AttributeDefinition = {
|
|
|
269
278
|
get?: Function | undefined;
|
|
270
279
|
toInternal?: Function | undefined;
|
|
271
280
|
toExternal?: Function | undefined;
|
|
272
|
-
/**
|
|
273
|
-
* allowed values
|
|
274
|
-
*/
|
|
275
|
-
values?: Set<any> | undefined;
|
|
276
281
|
/**
|
|
277
282
|
* attribute name used by external system
|
|
278
283
|
*/
|
|
279
284
|
externalName?: string | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* allowed values
|
|
287
|
+
*/
|
|
288
|
+
values?: Set<any> | undefined;
|
|
280
289
|
/**
|
|
281
290
|
* environment variable(s) used to provide the value
|
|
282
291
|
*/
|