repository-provider 32.7.17 → 32.7.18

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
@@ -422,7 +422,7 @@ mapAttributes({a:1},{a:"a'"}) // {"a'": 1}
422
422
 
423
423
  ### Parameters
424
424
 
425
- * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** 
425
+ * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
426
426
  * `mapping` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
427
427
 
428
428
  Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** keys renamed after mapping
@@ -454,7 +454,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
454
454
  * `default` **any?** the default value
455
455
  * `set` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** set the value
456
456
  * `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
457
- * `env` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)?** environment variable use to provide the value
457
+ * `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 use to provide the value
458
458
 
459
459
  ## tokens
460
460
 
@@ -464,8 +464,6 @@ Split property path into tokens
464
464
 
465
465
  * `string` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
466
466
 
467
- Returns **Iterator<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
468
-
469
467
  ## setAttribute
470
468
 
471
469
  Set Object attribute.
@@ -520,7 +518,7 @@ Creates an instance of BaseObject.
520
518
 
521
519
  ### Parameters
522
520
 
523
- * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
521
+ * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
524
522
  * `additionalProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
525
523
 
526
524
  ### updateAttributes
@@ -529,8 +527,8 @@ Takes values from options.
529
527
 
530
528
  #### Parameters
531
529
 
532
- * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
533
- * `additionalProperties` &#x20;
530
+ * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
531
+ * `additionalProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
534
532
 
535
533
  ### update
536
534
 
@@ -1100,8 +1098,7 @@ Object with a name.
1100
1098
 
1101
1099
  * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
1102
1100
  * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
1103
- * `additionalProperties` &#x20;
1104
- * `Object` |
1101
+ * `additionalProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
1105
1102
 
1106
1103
  ### Properties
1107
1104
 
@@ -1552,7 +1549,6 @@ Abstract repository collection.
1552
1549
 
1553
1550
  * `options.description` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** human readable description
1554
1551
  * `options.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** internal id
1555
- * `options.uuid` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** internal id
1556
1552
  * `options.url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** home
1557
1553
 
1558
1554
  ### Properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "32.7.17",
3
+ "version": "32.7.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "ava": "^5.2.0",
37
- "browser-ava": "^1.3.38",
37
+ "browser-ava": "^1.3.43",
38
38
  "c8": "^7.13.0",
39
- "documentation": "^14.0.1",
40
- "repository-provider-test-support": "^2.3.5",
39
+ "documentation": "^14.0.2",
40
+ "repository-provider-test-support": "^2.3.6",
41
41
  "semantic-release": "^21.0.2",
42
42
  "typescript": "^5.0.4"
43
43
  },
@@ -155,7 +155,7 @@ export function optionJSON(
155
155
  * ```js
156
156
  * mapAttributes({a:1},{a:"a'"}) // {"a'": 1}
157
157
  * ```
158
- * @param {Object} [object]
158
+ * @param {Object} object
159
159
  * @param {Object} mapping
160
160
  * @return {Object} keys renamed after mapping
161
161
  */
package/src/attribute.mjs CHANGED
@@ -10,29 +10,60 @@
10
10
  * @property {any} [default] the default value
11
11
  * @property {Function} [set] set the value
12
12
  * @property {Function} [get] get the value can be used to calculate default values
13
- * @property {string|string[]} [env] environment variable use to provide the value
13
+ * @property {string[]|string} [env] environment variable use to provide the value
14
14
  */
15
15
 
16
16
  /**
17
17
  * Split property path into tokens
18
+ * @generator
18
19
  * @param {string} string
19
- * @return {Iterator<string>}
20
+ * @yields {string}
20
21
  */
21
- function* tokens(string) {
22
+ export function* tokens(string) {
22
23
  let identifier = "";
24
+ let last;
23
25
 
24
26
  for (const c of string) {
25
27
  switch (c) {
26
28
  case "\t":
27
29
  case " ":
30
+ if (identifier.length) {
31
+ yield identifier;
32
+ identifier = "";
33
+ }
34
+ if (last) {
35
+ yield last;
36
+ last = undefined;
37
+ }
28
38
  break;
29
39
 
40
+ case "!":
30
41
  case ">":
31
42
  case "<":
43
+ if (last) {
44
+ yield last;
45
+ }
46
+ last = c;
47
+ break;
48
+
49
+ case "=":
50
+ if (last) {
51
+ yield last + c;
52
+ last = undefined;
53
+ break;
54
+ }
32
55
 
56
+ case "+":
57
+ case "-":
33
58
  case ".":
59
+ case "(":
60
+ case ")":
34
61
  case "[":
35
62
  case "]":
63
+ if (last) {
64
+ yield last;
65
+ last = undefined;
66
+ }
36
67
  if (identifier.length) {
37
68
  yield identifier;
38
69
  identifier = "";
@@ -40,6 +71,10 @@ function* tokens(string) {
40
71
  yield c;
41
72
  break;
42
73
  default:
74
+ if (last) {
75
+ yield last;
76
+ last = undefined;
77
+ }
43
78
  identifier += c;
44
79
  }
45
80
  }
@@ -47,6 +82,9 @@ function* tokens(string) {
47
82
  if (identifier.length) {
48
83
  yield identifier;
49
84
  }
85
+ if (last) {
86
+ yield last;
87
+ }
50
88
  }
51
89
 
52
90
  /**
@@ -116,3 +154,47 @@ export function getAttribute(object, name) {
116
154
 
117
155
  return object;
118
156
  }
157
+
158
+ /**
159
+ * Deliver attribute value and operator.
160
+ * The name may be a property path like 'a.b.c <='.
161
+ * @param {Object} object
162
+ * @param {string} expression
163
+ * @returns {[any,string]} value associated with the given property name
164
+ */
165
+ export function getAttributeAndOperator(object, expression, getters = {}) {
166
+ let op = "=";
167
+
168
+ for (const token of tokens(expression)) {
169
+ switch (token) {
170
+ case ">=":
171
+ case "<=":
172
+ case ">":
173
+ case "<":
174
+ case "=":
175
+ case "!=":
176
+ op = token;
177
+ break;
178
+ case ".":
179
+ case "[":
180
+ case "]":
181
+ break;
182
+
183
+ default:
184
+ if (object === undefined) {
185
+ break;
186
+ }
187
+
188
+ const g = getters[token];
189
+ if (g) {
190
+ object = g(object);
191
+ } else {
192
+ if (object[token] !== undefined) {
193
+ object = object[token];
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ return [object, op];
200
+ }
@@ -6,7 +6,7 @@ import { description_attribute, id_attribute } from "./attributes.mjs";
6
6
 
7
7
  /**
8
8
  * Creates an instance of BaseObject.
9
- * @param {Object} [options]
9
+ * @param {Object} options
10
10
  * @param {Object} [additionalProperties]
11
11
  */
12
12
  export class BaseObject {
@@ -63,7 +63,8 @@ import { description_attribute, id_attribute } from "./attributes.mjs";
63
63
 
64
64
  /**
65
65
  * Takes values from options.
66
- * @param {Object} [options]
66
+ * @param {Object} options
67
+ * @param {Object} [additionalProperties]
67
68
  */
68
69
  updateAttributes(options, additionalProperties) {
69
70
  definePropertiesFromOptions(