repository-provider 32.7.26 → 32.7.28

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
@@ -81,6 +81,7 @@ console.log(await readme.string);
81
81
  * [displayName](#displayname)
82
82
  * [fullName](#fullname)
83
83
  * [fullCondensedName](#fullcondensedname)
84
+ * [condensedName](#condensedname)
84
85
  * [isWritable](#iswritable)
85
86
  * [equals](#equals)
86
87
  * [Parameters](#parameters-11)
@@ -388,7 +389,7 @@ Object.definedProperties(new aClass(),{ with_default: { value: 77 }})
388
389
  * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** target object
389
390
  * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** as passed to object constructor (optional, default `{}`)
390
391
  * `properties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object properties (optional, default `{}`)
391
- * `attributes` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `object.constructor.attributes||[]`)
392
+ * `attributes` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** attribute meta info (optional, default `object.constructor.attributes`)
392
393
 
393
394
  ## defaultValues
394
395
 
@@ -572,6 +573,12 @@ Complete name in the hierachy.
572
573
 
573
574
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
574
575
 
576
+ ### condensedName
577
+
578
+ Name with default parts removed
579
+
580
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
581
+
575
582
  ### isWritable
576
583
 
577
584
  By default cannot be written to.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "32.7.26",
3
+ "version": "32.7.28",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,12 +34,12 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "ava": "^5.3.1",
37
- "browser-ava": "^1.3.49",
37
+ "browser-ava": "^1.3.51",
38
38
  "c8": "^8.0.0",
39
39
  "documentation": "^14.0.2",
40
- "repository-provider-test-support": "^2.4.0",
41
- "semantic-release": "^21.0.5",
42
- "typescript": "^5.1.3"
40
+ "repository-provider-test-support": "^2.4.1",
41
+ "semantic-release": "^21.0.7",
42
+ "typescript": "^5.1.6"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=16.20.1"
@@ -21,83 +21,85 @@ import { setAttribute, getAttribute } from "./attribute.mjs";
21
21
  * @param {Object} object target object
22
22
  * @param {Object} options as passed to object constructor
23
23
  * @param {Object} properties object properties
24
- * @param {Object} attributes
24
+ * @param {Object} [attributes] attribute meta info
25
25
  */
26
26
  export function definePropertiesFromOptions(
27
27
  object,
28
28
  options = {},
29
29
  properties = {},
30
- attributes = object.constructor.attributes || []
30
+ attributes = object.constructor.attributes
31
31
  ) {
32
32
  const applyLater = {};
33
33
 
34
- Object.entries(attributes).forEach(([name, attribute]) => {
35
- let value = getAttribute(options, name);
36
-
37
- if (value === undefined) {
38
- if (attribute.get) {
39
- value = attribute.get(attribute, object, properties);
40
- } else if (
41
- attribute.default !== undefined &&
42
- attribute.default !== getAttribute(object, name)
43
- ) {
44
- value = attribute.default;
34
+ if (attributes !== undefined) {
35
+ Object.entries(attributes).forEach(([name, attribute]) => {
36
+ let value = getAttribute(options, name);
37
+
38
+ if (value === undefined) {
39
+ if (attribute.get) {
40
+ value = attribute.get(attribute, object, properties);
41
+ } else if (
42
+ attribute.default !== undefined &&
43
+ attribute.default !== getAttribute(object, name)
44
+ ) {
45
+ value = attribute.default;
46
+ }
45
47
  }
46
- }
47
48
 
48
- if (attribute.set) {
49
- value = attribute.set(value);
50
- } else {
51
- switch (attribute.type) {
52
- case "set":
53
- if (Array.isArray(value)) {
54
- value = new Set(value);
55
- }
56
- break;
57
- case "boolean":
58
- if (value !== undefined) {
59
- value =
60
- value === 0 || value === "0" || value === false ? false : true;
61
- }
62
- break;
49
+ if (attribute.set) {
50
+ value = attribute.set(value);
51
+ } else {
52
+ switch (attribute.type) {
53
+ case "set":
54
+ if (Array.isArray(value)) {
55
+ value = new Set(value);
56
+ }
57
+ break;
58
+ case "boolean":
59
+ if (value !== undefined) {
60
+ value =
61
+ value === 0 || value === "0" || value === false ? false : true;
62
+ }
63
+ break;
64
+ }
63
65
  }
64
- }
65
66
 
66
- const path = name.split(/\./);
67
- const first = path.shift();
67
+ const path = name.split(/\./);
68
+ const first = path.shift();
68
69
 
69
- if (first !== undefined) {
70
- const property = properties[first];
70
+ if (first !== undefined) {
71
+ const property = properties[first];
71
72
 
72
- if (path.length) {
73
- const remaining = path.join(".");
73
+ if (path.length) {
74
+ const remaining = path.join(".");
74
75
 
75
- if (property) {
76
- setAttribute(property.value, remaining, value);
77
- } else {
78
- const slice = {};
79
- setAttribute(slice, remaining, value);
80
- properties[first] = { configurable: true, value: slice };
81
- }
82
- } else {
83
- if (value !== undefined) {
84
- const op = Object.getOwnPropertyDescriptor(
85
- object.constructor.prototype,
86
- first
87
- );
88
-
89
- if (op?.set || property?.set) {
90
- applyLater[first] = value;
76
+ if (property) {
77
+ setAttribute(property.value, remaining, value);
91
78
  } else {
92
- properties[first] = Object.assign(
93
- { value, writable: attribute.writable },
94
- property
79
+ const slice = {};
80
+ setAttribute(slice, remaining, value);
81
+ properties[first] = { configurable: true, value: slice };
82
+ }
83
+ } else {
84
+ if (value !== undefined) {
85
+ const op = Object.getOwnPropertyDescriptor(
86
+ object.constructor.prototype,
87
+ first
95
88
  );
89
+
90
+ if (op?.set || property?.set) {
91
+ applyLater[first] = value;
92
+ } else {
93
+ properties[first] = Object.assign(
94
+ { value, writable: attribute.writable },
95
+ property
96
+ );
97
+ }
96
98
  }
97
99
  }
98
100
  }
99
- }
100
- });
101
+ });
102
+ }
101
103
 
102
104
  Object.defineProperties(object, properties);
103
105
  Object.assign(object, applyLater);
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const default_attribute = {
5
5
  type: "string",
6
- writeable: false,
6
+ writable: false,
7
7
  mandatory: false,
8
8
  private: false,
9
9
  isKey: false,
@@ -13,7 +13,7 @@ export const default_attribute = {
13
13
 
14
14
  export const boolean_attribute = {
15
15
  ...default_attribute,
16
- writeable: true,
16
+ writable: true,
17
17
  default: false,
18
18
  type: "boolean"
19
19
  };
@@ -67,7 +67,7 @@ export const id_attribute = {
67
67
 
68
68
  export const state_attribute = {
69
69
  ...default_attribute,
70
- writeable: true
70
+ writable: true
71
71
  };
72
72
 
73
73
  /**
@@ -114,6 +114,10 @@ import { description_attribute, id_attribute } from "./attributes.mjs";
114
114
  return this.fullName;
115
115
  }
116
116
 
117
+ /**
118
+ * Name with default parts removed
119
+ * @return {string}
120
+ */
117
121
  get condensedName() {
118
122
  return this.name;
119
123
  }