pacc 6.6.2 → 6.7.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 +21 -5
- package/package.json +2 -2
- package/src/attributes.mjs +1 -1
- package/src/common-attributes.mjs +10 -2
- package/src/expand.mjs +2 -2
- package/src/multiple.mjs +1 -1
- package/src/types.mjs +7 -6
- package/types/attributes.d.mts +2 -2
- package/types/common-attributes.d.mts +8 -4
- package/types/expand.d.mts +2 -2
- package/types/multiple.d.mts +2 -2
package/README.md
CHANGED
|
@@ -88,6 +88,7 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
|
|
|
88
88
|
* [Parameters](#parameters-4)
|
|
89
89
|
* [expand](#expand)
|
|
90
90
|
* [Parameters](#parameters-5)
|
|
91
|
+
* [promises](#promises)
|
|
91
92
|
* [filter](#filter)
|
|
92
93
|
* [Parameters](#parameters-6)
|
|
93
94
|
* [setAttributes](#setattributes)
|
|
@@ -146,6 +147,8 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
|
|
|
146
147
|
* [EOF](#eof)
|
|
147
148
|
* [Type](#type)
|
|
148
149
|
* [Properties](#properties-2)
|
|
150
|
+
* [raiseOnUnknownType](#raiseonunknowntype)
|
|
151
|
+
* [Parameters](#parameters-18)
|
|
149
152
|
|
|
150
153
|
## prepareAttributesDefinitions
|
|
151
154
|
|
|
@@ -176,7 +179,7 @@ Iterate over all attributes.
|
|
|
176
179
|
### Parameters
|
|
177
180
|
|
|
178
181
|
* `definition` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
179
|
-
* `filter` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
|
|
182
|
+
* `filter` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
180
183
|
* `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 `[]`)
|
|
181
184
|
|
|
182
185
|
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)]>** 
|
|
@@ -204,7 +207,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
204
207
|
* `collection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
205
208
|
* `private` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** should the value be shown
|
|
206
209
|
* `credential` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** any type of credential
|
|
207
|
-
* `persistent` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** should we be stored
|
|
210
|
+
* `persistent` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** should we be stored (especially critical for credentials)
|
|
208
211
|
* `depends` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** name of an attribute we depend on
|
|
209
212
|
* `description` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** human readable
|
|
210
213
|
* `default` **any?** the default value
|
|
@@ -212,7 +215,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
212
215
|
* `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
|
|
213
216
|
* `prepareValue` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
214
217
|
* `values` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)\<any>?** allowed values
|
|
215
|
-
* `externalName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
|
|
218
|
+
* `externalName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** attribute name used by external system
|
|
216
219
|
* `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
|
|
217
220
|
* `additionalValues` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** other values to be set in case our attribute is set
|
|
218
221
|
|
|
@@ -442,13 +445,17 @@ Expand expressions inside of object graphs.
|
|
|
442
445
|
* `object` **any** 
|
|
443
446
|
* `context` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{}`)
|
|
444
447
|
|
|
445
|
-
* `context.root` **any
|
|
448
|
+
* `context.root` **any?** 
|
|
446
449
|
* `context.stopClass` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
447
450
|
* `context.leadIn` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** 
|
|
448
451
|
* `context.leadOut` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** 
|
|
449
452
|
|
|
450
453
|
Returns **any** 
|
|
451
454
|
|
|
455
|
+
## promises
|
|
456
|
+
|
|
457
|
+
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<any>>
|
|
458
|
+
|
|
452
459
|
## filter
|
|
453
460
|
|
|
454
461
|
Generate filter function.
|
|
@@ -489,7 +496,7 @@ Retrive attribute values from an object.
|
|
|
489
496
|
|
|
490
497
|
* `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute value source
|
|
491
498
|
* `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
492
|
-
* `filter` **[
|
|
499
|
+
* `filter` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
493
500
|
|
|
494
501
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** values
|
|
495
502
|
|
|
@@ -710,6 +717,15 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
710
717
|
* `primitive` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** 
|
|
711
718
|
* `prepareValue` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
712
719
|
|
|
720
|
+
## raiseOnUnknownType
|
|
721
|
+
|
|
722
|
+
### Parameters
|
|
723
|
+
|
|
724
|
+
* `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** 
|
|
725
|
+
* `origin` **any** 
|
|
726
|
+
|
|
727
|
+
Returns **[Type](#type)** 
|
|
728
|
+
|
|
713
729
|
# install
|
|
714
730
|
|
|
715
731
|
With [npm](http://npmjs.org) do:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"ava": "^6.4.1",
|
|
42
|
-
"browser-ava": "^2.3.
|
|
42
|
+
"browser-ava": "^2.3.49",
|
|
43
43
|
"c8": "^10.1.3",
|
|
44
44
|
"documentation": "^14.0.3",
|
|
45
45
|
"semantic-release": "^25.0.2",
|
package/src/attributes.mjs
CHANGED
|
@@ -47,7 +47,7 @@ function mergeAttributeDefinitions(dest, atts) {
|
|
|
47
47
|
/**
|
|
48
48
|
* Iterate over all attributes.
|
|
49
49
|
* @param {Object} definition
|
|
50
|
-
* @param {Function} filter
|
|
50
|
+
* @param {Function} [filter]
|
|
51
51
|
* @param {string[]} path
|
|
52
52
|
* @return {Iterable<[string[],object]>}
|
|
53
53
|
*/
|
|
@@ -10,7 +10,7 @@ import { types } from "./types.mjs";
|
|
|
10
10
|
* @property {boolean} collection
|
|
11
11
|
* @property {boolean} [private] should the value be shown
|
|
12
12
|
* @property {boolean} [credential] any type of credential
|
|
13
|
-
* @property {boolean} [persistent] should we be stored
|
|
13
|
+
* @property {boolean} [persistent] should we be stored (especially critical for credentials)
|
|
14
14
|
* @property {string} [depends] name of an attribute we depend on
|
|
15
15
|
* @property {string} [description] human readable
|
|
16
16
|
* @property {any} [default] the default value
|
|
@@ -18,7 +18,7 @@ import { types } from "./types.mjs";
|
|
|
18
18
|
* @property {Function} [get] get the value can be used to calculate default values
|
|
19
19
|
* @property {Function} [prepareValue]
|
|
20
20
|
* @property {Set<any>} [values] allowed values
|
|
21
|
-
* @property {string} [externalName]
|
|
21
|
+
* @property {string} [externalName] attribute name used by external system
|
|
22
22
|
* @property {string[]|string} [env] environment variable(s) used to provide the value
|
|
23
23
|
* @property {object} [additionalValues] other values to be set in case our attribute is set
|
|
24
24
|
*/
|
|
@@ -367,6 +367,14 @@ export const duration_attribute = {
|
|
|
367
367
|
type: types.duration
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
+
/**
|
|
371
|
+
* @type {AttributeDefinition}
|
|
372
|
+
*/
|
|
373
|
+
export const duration_attribute_writable = {
|
|
374
|
+
...duration_attribute,
|
|
375
|
+
writable: true
|
|
376
|
+
};
|
|
377
|
+
|
|
370
378
|
/**
|
|
371
379
|
* @type {AttributeDefinition}
|
|
372
380
|
*/
|
package/src/expand.mjs
CHANGED
|
@@ -6,14 +6,14 @@ const maxNestingLevel = 5;
|
|
|
6
6
|
* Expand expressions inside of object graphs.
|
|
7
7
|
* @param {any} object
|
|
8
8
|
* @param {Object} context
|
|
9
|
-
* @param {any} context.root
|
|
9
|
+
* @param {any} [context.root]
|
|
10
10
|
* @param {function} [context.stopClass]
|
|
11
11
|
* @param {string} [context.leadIn]
|
|
12
12
|
* @param {string} [context.leadOut]
|
|
13
13
|
* @returns {any}
|
|
14
14
|
*/
|
|
15
15
|
export function expand(object, context = {}) {
|
|
16
|
-
const promises = [];
|
|
16
|
+
const /** @type {Array<Promise<any>>} */ promises = [];
|
|
17
17
|
|
|
18
18
|
const leadIn = context.leadIn ?? "${";
|
|
19
19
|
const leadOut = context.leadOut ?? "}";
|
package/src/multiple.mjs
CHANGED
|
@@ -60,7 +60,7 @@ export function getAttributes(object, definitions) {
|
|
|
60
60
|
* Retrive attribute values from an object.
|
|
61
61
|
* @param {Object} object attribute value source
|
|
62
62
|
* @param {Object} definitions
|
|
63
|
-
* @param {
|
|
63
|
+
* @param {Function} [filter]
|
|
64
64
|
* @return {Object} values
|
|
65
65
|
*/
|
|
66
66
|
export function getAttributesJSON(object, definitions, filter) {
|
package/src/types.mjs
CHANGED
|
@@ -61,10 +61,12 @@ export const types = {
|
|
|
61
61
|
object: { name: "object", primitive: false }
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {string|undefined} type
|
|
67
|
+
* @param {any} origin
|
|
68
|
+
* @returns {Type}
|
|
69
|
+
*/
|
|
68
70
|
function raiseOnUnknownType(type, origin) {
|
|
69
71
|
switch (typeof type) {
|
|
70
72
|
case "string":
|
|
@@ -72,7 +74,7 @@ function raiseOnUnknownType(type, origin) {
|
|
|
72
74
|
return types[type];
|
|
73
75
|
}
|
|
74
76
|
case "undefined":
|
|
75
|
-
|
|
77
|
+
throw new Error(`Unknown type ${type} in '${origin}'`, { cause: type });
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
return type;
|
|
@@ -174,7 +176,6 @@ export function resolveTypeLinks() {
|
|
|
174
176
|
|
|
175
177
|
export function typeFactory(type, owner, data) {
|
|
176
178
|
const factory = type.factoryFor?.(owner, data) || type.clazz;
|
|
177
|
-
//console.log(factory, type, owner, data);
|
|
178
179
|
const object = new factory(owner);
|
|
179
180
|
|
|
180
181
|
object.read(data);
|
package/types/attributes.d.mts
CHANGED
|
@@ -8,11 +8,11 @@ export function prepareAttributesDefinitions(newDefinitions: any, presentDefinit
|
|
|
8
8
|
/**
|
|
9
9
|
* Iterate over all attributes.
|
|
10
10
|
* @param {Object} definition
|
|
11
|
-
* @param {Function} filter
|
|
11
|
+
* @param {Function} [filter]
|
|
12
12
|
* @param {string[]} path
|
|
13
13
|
* @return {Iterable<[string[],object]>}
|
|
14
14
|
*/
|
|
15
|
-
export function attributeIterator(definition: any, filter
|
|
15
|
+
export function attributeIterator(definition: any, filter?: Function, path?: string[]): Iterable<[string[], object]>;
|
|
16
16
|
export function writableAttributeIterator(definition: any): Generator<[string[], any], void, any>;
|
|
17
17
|
export function prepareValue(value: any, attribute: any): any;
|
|
18
18
|
export function mandatoryAttributesPresent(object: any, attributes: any): boolean;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @property {boolean} collection
|
|
9
9
|
* @property {boolean} [private] should the value be shown
|
|
10
10
|
* @property {boolean} [credential] any type of credential
|
|
11
|
-
* @property {boolean} [persistent] should we be stored
|
|
11
|
+
* @property {boolean} [persistent] should we be stored (especially critical for credentials)
|
|
12
12
|
* @property {string} [depends] name of an attribute we depend on
|
|
13
13
|
* @property {string} [description] human readable
|
|
14
14
|
* @property {any} [default] the default value
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* @property {Function} [get] get the value can be used to calculate default values
|
|
17
17
|
* @property {Function} [prepareValue]
|
|
18
18
|
* @property {Set<any>} [values] allowed values
|
|
19
|
-
* @property {string} [externalName]
|
|
19
|
+
* @property {string} [externalName] attribute name used by external system
|
|
20
20
|
* @property {string[]|string} [env] environment variable(s) used to provide the value
|
|
21
21
|
* @property {object} [additionalValues] other values to be set in case our attribute is set
|
|
22
22
|
*/
|
|
@@ -186,6 +186,10 @@ export const priority_attribute: AttributeDefinition;
|
|
|
186
186
|
* @type {AttributeDefinition}
|
|
187
187
|
*/
|
|
188
188
|
export const duration_attribute: AttributeDefinition;
|
|
189
|
+
/**
|
|
190
|
+
* @type {AttributeDefinition}
|
|
191
|
+
*/
|
|
192
|
+
export const duration_attribute_writable: AttributeDefinition;
|
|
189
193
|
/**
|
|
190
194
|
* @type {AttributeDefinition}
|
|
191
195
|
*/
|
|
@@ -213,7 +217,7 @@ export type AttributeDefinition = {
|
|
|
213
217
|
*/
|
|
214
218
|
credential?: boolean;
|
|
215
219
|
/**
|
|
216
|
-
* should we be stored
|
|
220
|
+
* should we be stored (especially critical for credentials)
|
|
217
221
|
*/
|
|
218
222
|
persistent?: boolean;
|
|
219
223
|
/**
|
|
@@ -242,7 +246,7 @@ export type AttributeDefinition = {
|
|
|
242
246
|
*/
|
|
243
247
|
values?: Set<any>;
|
|
244
248
|
/**
|
|
245
|
-
*
|
|
249
|
+
* attribute name used by external system
|
|
246
250
|
*/
|
|
247
251
|
externalName?: string;
|
|
248
252
|
/**
|
package/types/expand.d.mts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Expand expressions inside of object graphs.
|
|
3
3
|
* @param {any} object
|
|
4
4
|
* @param {Object} context
|
|
5
|
-
* @param {any} context.root
|
|
5
|
+
* @param {any} [context.root]
|
|
6
6
|
* @param {function} [context.stopClass]
|
|
7
7
|
* @param {string} [context.leadIn]
|
|
8
8
|
* @param {string} [context.leadOut]
|
|
9
9
|
* @returns {any}
|
|
10
10
|
*/
|
|
11
11
|
export function expand(object: any, context?: {
|
|
12
|
-
root
|
|
12
|
+
root?: any;
|
|
13
13
|
stopClass?: Function;
|
|
14
14
|
leadIn?: string;
|
|
15
15
|
leadOut?: string;
|
package/types/multiple.d.mts
CHANGED
|
@@ -17,7 +17,7 @@ export function getAttributes(object: any, definitions: any): any;
|
|
|
17
17
|
* Retrive attribute values from an object.
|
|
18
18
|
* @param {Object} object attribute value source
|
|
19
19
|
* @param {Object} definitions
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {Function} [filter]
|
|
21
21
|
* @return {Object} values
|
|
22
22
|
*/
|
|
23
|
-
export function getAttributesJSON(object: any, definitions: any, filter
|
|
23
|
+
export function getAttributesJSON(object: any, definitions: any, filter?: Function): any;
|