pacc 4.30.0 → 4.31.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 CHANGED
@@ -79,28 +79,30 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
79
79
  * [priority\_attribute](#priority_attribute)
80
80
  * [timeout\_attribute](#timeout_attribute)
81
81
  * [language\_attribute](#language_attribute)
82
- * [expand](#expand)
82
+ * [environmentValues](#environmentvalues)
83
83
  * [Parameters](#parameters-3)
84
- * [filter](#filter)
84
+ * [expand](#expand)
85
85
  * [Parameters](#parameters-4)
86
- * [setAttributes](#setattributes)
86
+ * [filter](#filter)
87
87
  * [Parameters](#parameters-5)
88
- * [getAttributes](#getattributes)
88
+ * [setAttributes](#setattributes)
89
89
  * [Parameters](#parameters-6)
90
+ * [getAttributes](#getattributes)
91
+ * [Parameters](#parameters-7)
90
92
  * [tokens](#tokens)
91
93
  * [tokens](#tokens-1)
92
- * [Parameters](#parameters-7)
93
- * [setAttribute](#setattribute)
94
94
  * [Parameters](#parameters-8)
95
- * [getAttribute](#getattribute)
95
+ * [setAttribute](#setattribute)
96
96
  * [Parameters](#parameters-9)
97
- * [getAttributeAndOperator](#getattributeandoperator)
97
+ * [getAttribute](#getattribute)
98
98
  * [Parameters](#parameters-10)
99
+ * [getAttributeAndOperator](#getattributeandoperator)
100
+ * [Parameters](#parameters-11)
99
101
  * [lookup](#lookup)
100
102
  * [Token](#token)
101
103
  * [Properties](#properties-1)
102
104
  * [createToken](#createtoken)
103
- * [Parameters](#parameters-11)
105
+ * [Parameters](#parameters-12)
104
106
  * [PLUS](#plus)
105
107
  * [MINUS](#minus)
106
108
  * [STAR](#star)
@@ -184,6 +186,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
184
186
  * `values` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)\<any>?** allowed values
185
187
  * `externalName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** attrubute name used by external system
186
188
  * `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
189
+ * `additionalValues` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** other values to be set in case our attribute is set
187
190
 
188
191
  ## default\_attribute
189
192
 
@@ -374,6 +377,18 @@ Type: [AttributeDefinition](#attributedefinition)
374
377
 
375
378
  Type: [AttributeDefinition](#attributedefinition)
376
379
 
380
+ ## environmentValues
381
+
382
+ Extract values from environment.
383
+
384
+ ### Parameters
385
+
386
+ * `attributes` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** as from process.env
387
+ * `env` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** as from process.env
388
+ * `instanceIdentifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** part of variable name.
389
+
390
+ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** undefined if no suitable environment variables have been found
391
+
377
392
  ## expand
378
393
 
379
394
  Expand expressions inside of object graphs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "4.30.0",
3
+ "version": "4.31.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -12,6 +12,7 @@
12
12
  * @property {any} [default] the default value
13
13
  * @property {Function} [set] set the value
14
14
  * @property {Function} [get] get the value can be used to calculate default values
15
+ * @property {Function} [prepareValue]
15
16
  * @property {Set<any>} [values] allowed values
16
17
  * @property {string} [externalName] attrubute name used by external system
17
18
  * @property {string[]|string} [env] environment variable(s) used to provide the value
@@ -2,12 +2,12 @@ import { attributeIterator, setAttribute } from "pacc";
2
2
 
3
3
  /**
4
4
  * Extract values from environment.
5
- * @param {Object} attributes as from process.env
6
5
  * @param {Object} env as from process.env
6
+ * @param {Object} attributes as from process.env
7
7
  * @param {string} instanceIdentifier part of variable name.
8
8
  * @return {Object|undefined} undefined if no suitable environment variables have been found
9
9
  */
10
- export function environmentValues(attributes, env, instanceIdentifier) {
10
+ export function environmentValues(env, attributes, instanceIdentifier) {
11
11
  let values;
12
12
 
13
13
  for (const [path, attribute] of attributeIterator(
@@ -23,7 +23,7 @@ export function environmentValues(attributes, env, instanceIdentifier) {
23
23
  name =>
24
24
  name && name.replace("{{instanceIdentifier}}", () => instanceIdentifier)
25
25
  )) {
26
- if (env[envName] !== undefined) {
26
+ if (env?.[envName] !== undefined) {
27
27
  values ??= {};
28
28
  setAttribute(values, name, env[envName]);
29
29
  }
@@ -12,6 +12,7 @@
12
12
  * @property {any} [default] the default value
13
13
  * @property {Function} [set] set the value
14
14
  * @property {Function} [get] get the value can be used to calculate default values
15
+ * @property {Function} [prepareValue]
15
16
  * @property {Set<any>} [values] allowed values
16
17
  * @property {string} [externalName] attrubute name used by external system
17
18
  * @property {string[]|string} [env] environment variable(s) used to provide the value
@@ -40,6 +41,7 @@ export namespace string_collection_attribute {
40
41
  export { _default as default };
41
42
  export let set: Function;
42
43
  export let get: Function;
44
+ export let prepareValue: Function;
43
45
  export let values: Set<any>;
44
46
  export let externalName: string;
45
47
  export let env: string[] | string;
@@ -196,6 +198,7 @@ export type AttributeDefinition = {
196
198
  * get the value can be used to calculate default values
197
199
  */
198
200
  get?: Function;
201
+ prepareValue?: Function;
199
202
  /**
200
203
  * allowed values
201
204
  */
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Extract values from environment.
3
- * @param {Object} attributes as from process.env
4
3
  * @param {Object} env as from process.env
4
+ * @param {Object} attributes as from process.env
5
5
  * @param {string} instanceIdentifier part of variable name.
6
6
  * @return {Object|undefined} undefined if no suitable environment variables have been found
7
7
  */
8
- export function environmentValues(attributes: any, env: any, instanceIdentifier: string): any | undefined;
8
+ export function environmentValues(env: any, attributes: any, instanceIdentifier: string): any | undefined;