repository-provider 35.5.16 → 35.6.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/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "35.5.16",
3
+ "version": "35.6.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
7
7
  },
8
+ "packageManager": "npm@11.6.0+sha512.77f3fb0dbbd881835d7bd1217deabdf7ed77fc4ec4f363df64fc3cb986404abf6c437661041080f5c5d225103508e7c9ea30cb2742b7e942675d05a10af2d7b9",
8
9
  "types": "./types/index.d.mts",
9
10
  "exports": {
10
11
  ".": {
@@ -37,21 +38,21 @@
37
38
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
38
39
  },
39
40
  "dependencies": {
40
- "content-entry": "^14.2.4",
41
+ "content-entry": "^14.2.5",
41
42
  "matching-iterator": "^2.1.4",
42
- "pacc": "^4.9.1"
43
+ "pacc": "^4.37.4"
43
44
  },
44
45
  "devDependencies": {
45
46
  "ava": "^6.4.1",
46
- "browser-ava": "^2.3.31",
47
+ "browser-ava": "^2.3.33",
47
48
  "c8": "^10.1.3",
48
49
  "documentation": "^14.0.3",
49
50
  "repository-provider-test-support": "^3.1.52",
50
- "semantic-release": "^24.2.7",
51
+ "semantic-release": "^24.2.9",
51
52
  "typescript": "^5.9.2"
52
53
  },
53
54
  "engines": {
54
- "node": ">=22.18.0"
55
+ "node": ">=22.19.5"
55
56
  },
56
57
  "repository": {
57
58
  "type": "git",
@@ -1,8 +1,8 @@
1
1
  import {
2
- definePropertiesFromOptions,
3
- mapAttributes
4
- } from "./attribute-extras.mjs";
5
- import { description_attribute, id_attribute } from "pacc";
2
+ definePropertiesFromAttributes,
3
+ description_attribute,
4
+ id_attribute
5
+ } from "pacc";
6
6
 
7
7
  /**
8
8
  * Creates an instance of BaseObject.
@@ -52,12 +52,6 @@ export class BaseObject {
52
52
  );
53
53
  }
54
54
 
55
- /**
56
- * Map attributes between external and internal representation.
57
- * @return {Object}
58
- */
59
- static attributeMapping = {};
60
-
61
55
  /** @type {string} */ id;
62
56
  /** @type {string} */ description;
63
57
 
@@ -66,10 +60,9 @@ export class BaseObject {
66
60
  * @param {Object} [options]
67
61
  * @param {string} [options.id]
68
62
  * @param {string} [options.description]
69
- * @param {Object} [additionalProperties]
70
63
  */
71
- constructor(options, additionalProperties) {
72
- this.updateAttributes(options, additionalProperties);
64
+ constructor(options) {
65
+ this.updateAttributes(options);
73
66
  }
74
67
 
75
68
  /**
@@ -77,13 +70,8 @@ export class BaseObject {
77
70
  * @param {Object} [options]
78
71
  * @param {Object} [additionalProperties]
79
72
  */
80
- updateAttributes(options, additionalProperties) {
81
- definePropertiesFromOptions(
82
- this,
83
- // @ts-ignore
84
- mapAttributes(options, this.constructor.attributeMapping),
85
- additionalProperties
86
- );
73
+ updateAttributes(options) {
74
+ definePropertiesFromAttributes(this, this.constructor.attributes, options);
87
75
  }
88
76
 
89
77
  /**
@@ -1,8 +1,10 @@
1
1
  import {
2
+ manadatoryAttributesPresent,
3
+ environmentValues,
2
4
  url_attribute,
3
- name_attribute,
5
+ name_attribute_writable,
4
6
  priority_attribute,
5
- default_attribute
7
+ object_attribute
6
8
  } from "pacc";
7
9
  import { asArray, stripBaseName } from "./util.mjs";
8
10
  import { PullRequest } from "./pull-request.mjs";
@@ -58,65 +60,6 @@ export class BaseProvider extends BaseObject {
58
60
  return "";
59
61
  }
60
62
 
61
- /**
62
- * Extract options suitable for the constructor.
63
- * Form the given set of environment variables.
64
- * Object with the detected key value pairs is delivered.
65
- * @param {Object} [env] as from process.env
66
- * @param {string} instanceIdentifier part of variable name.
67
- * @return {Object|undefined} undefined if no suitable environment variables have been found
68
- */
69
- static optionsFromEnvironment(
70
- env,
71
- instanceIdentifier = this.instanceIdentifier
72
- ) {
73
- let options;
74
-
75
- if (env !== undefined) {
76
- const attributes = this.attributes;
77
-
78
- for (let [envName, value] of Object.entries(env)) {
79
- for (const [name, attribute] of Object.entries(attributes)) {
80
- if (
81
- asArray(attribute.env).find(
82
- e =>
83
- e.replace(
84
- "{{instanceIdentifier}}",
85
- () => instanceIdentifier
86
- ) === envName
87
- )
88
- ) {
89
- options ??= {};
90
-
91
- if (options[name] === undefined) {
92
- options[name] = value;
93
- Object.assign(options, attribute.additionalAttributes);
94
- }
95
- break;
96
- }
97
- }
98
- }
99
- }
100
- return options;
101
- }
102
-
103
- /**
104
- * Check if given options are sufficient to create a provider.
105
- * @param {Object} options
106
- * @return {boolean} true if options ar sufficient to construct a provider
107
- */
108
- static areOptionsSufficcient(options) {
109
- for (const [name, attribute] of Object.entries(this.attributes).filter(
110
- ([name, attribute]) => attribute.mandatory
111
- )) {
112
- if (options[name] === undefined) {
113
- return false;
114
- }
115
- }
116
-
117
- return true;
118
- }
119
-
120
63
  static attributes = {
121
64
  ...BaseObject.attributes,
122
65
 
@@ -124,7 +67,7 @@ export class BaseProvider extends BaseObject {
124
67
  * Name of the provider.
125
68
  */
126
69
  name: {
127
- ...name_attribute,
70
+ ...name_attribute_writable,
128
71
  env: "{{instanceIdentifier}}NAME"
129
72
  },
130
73
 
@@ -135,8 +78,7 @@ export class BaseProvider extends BaseObject {
135
78
  * To forward info/warn and error messages to
136
79
  */
137
80
  messageDestination: {
138
- ...default_attribute,
139
- type: "object",
81
+ ...object_attribute,
140
82
  default: console,
141
83
  writable: true,
142
84
  private: true
@@ -163,10 +105,14 @@ export class BaseProvider extends BaseObject {
163
105
  static initialize(options, env) {
164
106
  options = {
165
107
  ...options,
166
- ...this.optionsFromEnvironment(env, options?.instanceIdentifier)
108
+ ...environmentValues(
109
+ env,
110
+ this.attributes,
111
+ options?.instanceIdentifier ?? this.instanceIdentifier
112
+ )
167
113
  };
168
114
 
169
- if (this.areOptionsSufficcient(options)) {
115
+ if (manadatoryAttributesPresent(options, this.attributes)) {
170
116
  return new this(options);
171
117
  }
172
118
  }
package/src/hook.mjs CHANGED
@@ -2,8 +2,9 @@ import {
2
2
  secret_attribute,
3
3
  boolean_attribute,
4
4
  active_attribute,
5
- url_attribute,
6
- string_attribute
5
+ url_attribute_writable,
6
+ string_attribute_writable,
7
+ string_collection_attribute_writable
7
8
  } from "pacc";
8
9
  import { OwnedObject } from "./owned-object.mjs";
9
10
 
@@ -17,12 +18,23 @@ export class Hook extends OwnedObject {
17
18
  ...super.attributes,
18
19
  active: active_attribute,
19
20
  secret: secret_attribute,
20
- url: { ...url_attribute, description: "target url", writable: true },
21
- content_type: { ...string_attribute, default: "json", writable: true },
21
+ url: { ...url_attribute_writable, description: "target url" },
22
+ content_type: { ...string_attribute_writable, default: "json" },
22
23
  insecure_ssl: boolean_attribute,
23
- events: { type: "set", default: this.defaultEvents }
24
+ events: {
25
+ ...string_collection_attribute_writable,
26
+ default: this.defaultEvents
27
+ }
24
28
  };
25
29
 
30
+ set events(value) {
31
+ this._events = new Set(value);
32
+ }
33
+
34
+ get events() {
35
+ return this._events;
36
+ }
37
+
26
38
  static get addMethodName() {
27
39
  return "_addHook";
28
40
  }
package/src/index.mjs CHANGED
@@ -18,5 +18,4 @@ export * from "./hook.mjs";
18
18
  export * from "./milestone.mjs";
19
19
  export * from "./review.mjs";
20
20
  export * from "./application.mjs";
21
- export * from "./attribute-extras.mjs";
22
21
  export * from "./util.mjs";
package/src/milestone.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { state_attribute } from "pacc";
1
+ import { state_attribute_writable } from "pacc";
2
2
  import { OwnedObject } from "./owned-object.mjs";
3
3
 
4
4
  /**
@@ -6,7 +6,7 @@ import { OwnedObject } from "./owned-object.mjs";
6
6
  export class Milestone extends OwnedObject {
7
7
  static attributes = {
8
8
  ...super.attributes,
9
- state: state_attribute
9
+ state: state_attribute_writable
10
10
  };
11
11
 
12
12
  async *issues() {}
@@ -1,5 +1,4 @@
1
- import { name_attribute } from "pacc";
2
- import { optionJSON } from "./attribute-extras.mjs";
1
+ import { getAttributesJSON, name_attribute_writable } from "pacc";
3
2
  import { BaseObject } from "./base-object.mjs";
4
3
 
5
4
  /**
@@ -16,24 +15,15 @@ import { BaseObject } from "./base-object.mjs";
16
15
  export class NamedObject extends BaseObject {
17
16
  static attributes = {
18
17
  ...BaseObject.attributes,
19
- name: name_attribute
18
+ name: name_attribute_writable
20
19
  };
21
20
 
22
- constructor(name, options, additionalProperties) {
23
- super(options, {
24
- name: { value: name },
25
- ...additionalProperties
26
- });
27
- }
28
-
29
- /** @type {string} */ #name;
30
-
31
- get name() {
32
- return this.#name;
33
- }
21
+ name;
34
22
 
35
- set name(name) {
36
- this.#name = name;
23
+ constructor(name, options) {
24
+ delete options?.name; // TODO
25
+ super(options);
26
+ this.name = name;
37
27
  }
38
28
 
39
29
  /**
@@ -77,9 +67,7 @@ export class NamedObject extends BaseObject {
77
67
  /**
78
68
  * Provided name and all defined attributes.
79
69
  */
80
- toJSON() {
81
- return optionJSON(this, {
82
- name: this.name
83
- });
70
+ toJSON(filter) {
71
+ return { ...getAttributesJSON(this, this.constructor.attributes, filter), name: this.name };
84
72
  }
85
73
  }
@@ -29,8 +29,8 @@ export class OwnedObject extends NamedObject {
29
29
 
30
30
  owner;
31
31
 
32
- constructor(owner, name, options, additionalProperties) {
33
- super(name, options, additionalProperties);
32
+ constructor(owner, name, options) {
33
+ super(name, options);
34
34
  this.owner = owner;
35
35
  // @ts-ignore
36
36
  owner[this.constructor.addMethodName](this);
@@ -1,12 +1,15 @@
1
1
  import {
2
+ getAttributesJSON,
3
+ attributeIterator,
2
4
  url_attribute,
3
- state_attribute,
4
- body_attribute,
5
- title_attribute,
5
+ state_attribute_writable,
6
+ body_attribute_writable,
7
+ title_attribute_writable,
6
8
  boolean_attribute_false,
7
- empty_attribute
9
+ boolean_attribute_writable_false,
10
+ empty_attribute,
11
+ types
8
12
  } from "pacc";
9
- import { optionJSON } from "./attribute-extras.mjs";
10
13
  import { OwnedObject } from "./owned-object.mjs";
11
14
  import { Branch } from "./branch.mjs";
12
15
  import { Repository } from "./repository.mjs";
@@ -94,8 +97,8 @@ export class PullRequest extends OwnedObject {
94
97
 
95
98
  static attributes = {
96
99
  ...super.attributes,
97
- body: body_attribute,
98
- title: title_attribute,
100
+ body: body_attribute_writable,
101
+ title: title_attribute_writable,
99
102
  url: url_attribute,
100
103
 
101
104
  /**
@@ -106,7 +109,7 @@ export class PullRequest extends OwnedObject {
106
109
  * @return {string}
107
110
  */
108
111
  state: {
109
- ...state_attribute,
112
+ ...state_attribute_writable,
110
113
  default: "OPEN",
111
114
  values: this.states
112
115
  },
@@ -115,7 +118,7 @@ export class PullRequest extends OwnedObject {
115
118
  * Locked state of the pull request.
116
119
  * @return {boolean}
117
120
  */
118
- locked: boolean_attribute_false,
121
+ locked: boolean_attribute_writable_false,
119
122
 
120
123
  /**
121
124
  * Merged state of the pull request.
@@ -127,44 +130,41 @@ export class PullRequest extends OwnedObject {
127
130
  * Draft state of the pull request.
128
131
  * @return {boolean}
129
132
  */
130
- draft: boolean_attribute_false,
133
+ draft: boolean_attribute_writable_false,
131
134
  dry: boolean_attribute_false,
132
135
  empty: empty_attribute
133
136
  };
134
137
 
135
138
  /** @type {Branch} */ source;
136
139
 
137
- constructor(source, owner, name, options) {
138
- let state = "OPEN";
139
-
140
- super(owner, name, options, {
141
- state: {
142
- set(value) {
143
- value = value.toUpperCase();
144
- // @ts-ignore
145
- if (this.constructor.attributes.state.values.has(value)) {
146
- state = value;
147
- } else throw new Error(`Invalid Pull Request state ${value}`);
148
- },
149
- get() {
150
- return state;
151
- }
152
- },
153
- merged: {
154
- set(value) {
155
- if (value) {
156
- state = "MERGED";
157
- }
158
- },
159
- get() {
160
- return state === "MERGED";
161
- }
162
- }
163
- });
140
+ _state = "OPEN";
164
141
 
142
+ constructor(source, owner, name, options) {
143
+ super(owner, name, options);
165
144
  this.source = source;
166
145
  }
167
146
 
147
+ set state(value) {
148
+ value = value.toUpperCase();
149
+ if (this.constructor.attributes.state.values.has(value)) {
150
+ this._state = value;
151
+ } else throw new Error(`Invalid Pull Request state ${value}`);
152
+ }
153
+
154
+ get state() {
155
+ return this._state;
156
+ }
157
+
158
+ set merged(value) {
159
+ if (value) {
160
+ this.state = "MERGED";
161
+ }
162
+ }
163
+
164
+ get merged() {
165
+ return this.state === "MERGED";
166
+ }
167
+
168
168
  get destination() {
169
169
  return this.owner;
170
170
  }
@@ -237,31 +237,34 @@ export class PullRequest extends OwnedObject {
237
237
 
238
238
  toString() {
239
239
  return [
240
- // @ts-ignore
241
240
  [this.name, this.title],
242
241
  ["source", this.source?.identifier],
243
242
  ["destination", this.owner.identifier],
244
- // @ts-ignore
245
- ...Object.entries(this.constructor.attributes)
246
- .filter(
247
- ([k, v]) =>
248
- !v.isKey &&
249
- v.type !== "url" &&
250
- k !== "title" &&
251
- k !== "body" &&
252
- this[k] !== undefined
243
+ ...[
244
+ ...attributeIterator(
245
+ this.constructor.attributes,
246
+ (name, attribute) =>
247
+ !attribute.isKey &&
248
+ attribute.type !== types.url &&
249
+ name !== "title" &&
250
+ name !== "body" &&
251
+ this[name] !== undefined
253
252
  )
254
- .map(([k]) => [k, this[k]])
253
+ ].map(([path, attribute]) => {
254
+ const name = path.join(".");
255
+ return [name, this[name]];
256
+ })
255
257
  ]
256
- .map(([k, v]) => `${k}: ${v}`)
257
- .join(", ");
258
+ .map(([name, value]) => `${name}:${value}`)
259
+ .join(",");
258
260
  }
259
261
 
260
- toJSON() {
261
- return optionJSON(this, {
262
+ toJSON(filter) {
263
+ return {
264
+ ...getAttributesJSON(this, this.constructor.attributes, filter),
262
265
  source: this.source,
263
266
  destination: this.owner
264
- });
267
+ };
265
268
  }
266
269
 
267
270
  /**
package/src/ref.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { name_attribute, boolean_attribute_writable_false } from "pacc";
1
+ import { name_attribute_writable, boolean_attribute_writable_false } from "pacc";
2
2
  import { ContentEntry } from "content-entry";
3
3
  import { OwnedObject } from "./owned-object.mjs";
4
4
 
@@ -16,17 +16,13 @@ export class Ref extends OwnedObject {
16
16
  * @type {Object}
17
17
  */
18
18
  static attributes = {
19
- name: name_attribute,
19
+ name: name_attribute_writable,
20
20
 
21
21
  /**
22
22
  * Can the ref be modified.
23
23
  * @return {boolean}
24
24
  */
25
- isProtected: boolean_attribute_writable_false
26
- };
27
-
28
- static attributeMapping = {
29
- protected: "isProtected"
25
+ isProtected: {...boolean_attribute_writable_false, externalName: "protected" }
30
26
  };
31
27
 
32
28
  get refType() {
@@ -1,4 +1,4 @@
1
- import { url_attribute, url_attribute_writble, boolean_attribute, type_attribute } from "pacc";
1
+ import { url_attribute, url_attribute_writable, boolean_attribute, type_attribute } from "pacc";
2
2
  import { RepositoryOwner } from "./repository-owner.mjs";
3
3
  import { OwnedObject } from "./owned-object.mjs";
4
4
  import { BaseProvider } from "./base-provider.mjs";
@@ -46,14 +46,9 @@ export class RepositoryGroup extends RepositoryOwner(OwnedObject) {
46
46
  * The url of home page.
47
47
  * @return {string}
48
48
  */
49
- homePageURL: url_attribute_writble
49
+ homePageURL: url_attribute_writable
50
50
  };
51
51
 
52
- /**
53
- * Map attributes between external and internal representation.
54
- */
55
- static attributeMapping() {}
56
-
57
52
  get isAdmin() {
58
53
  return false;
59
54
  }
@@ -1,8 +1,8 @@
1
1
  import {
2
- string_attribute,
2
+ string_attribute_writable,
3
3
  url_attribute,
4
- boolean_attribute,
5
- boolean_attribute_false
4
+ boolean_attribute_false,
5
+ boolean_attribute_writable_false
6
6
  } from "pacc";
7
7
  import { matcher } from "matching-iterator";
8
8
  import { ContentEntry } from "content-entry";
@@ -56,16 +56,18 @@ export class Repository extends OwnedObject {
56
56
  * @return {string}
57
57
  */
58
58
  defaultBranchName: {
59
- ...string_attribute,
60
- default: Repository.defaultBranchName
59
+ ...string_attribute_writable,
60
+ default: this.defaultBranchName,
61
+ externalName: "default_branch"
61
62
  },
62
63
 
63
64
  cloneURL: url_attribute,
64
- isArchived: boolean_attribute,
65
- isLocked: boolean_attribute,
66
- isDisabled: boolean_attribute,
67
- isTemplate: boolean_attribute,
68
- isFork: boolean_attribute_false
65
+ isArchived: { ...boolean_attribute_writable_false, externalName: "archived" },
66
+ isLocked: { ...boolean_attribute_writable_false, externalName: "locked" },
67
+ isDisabled: { ...boolean_attribute_writable_false, externalName: "disabled" },
68
+ isTemplate: { ...boolean_attribute_writable_false, externalName: "template" },
69
+ isFork: { ...boolean_attribute_false, externalName: "fork" },
70
+ isPrivate: { ...boolean_attribute_writable_false, externalName: "private" }
69
71
  };
70
72
 
71
73
  /** @type {Map<string,Branch>} */ #branches = new Map();
@@ -85,14 +87,12 @@ export class Repository extends OwnedObject {
85
87
  * @param {Object} [options]
86
88
  * @param {string} [options.id]
87
89
  * @param {string} [options.description]
88
- * @param {Object} [additionalProperties]
89
90
  */
90
- constructor(owner, name, options, additionalProperties) {
91
+ constructor(owner, name, options) {
91
92
  super(
92
93
  owner,
93
94
  owner.normalizeRepositoryName(name, false),
94
- options,
95
- additionalProperties
95
+ options
96
96
  );
97
97
  }
98
98
 
@@ -113,7 +113,7 @@ export class Repository extends OwnedObject {
113
113
  }
114
114
 
115
115
  get defaultBranchName() {
116
- return Repository.defaultBranchName;
116
+ return this.constructor.defaultBranchName;
117
117
  }
118
118
 
119
119
  /**
@@ -34,22 +34,16 @@ export class BaseObject {
34
34
  * @return {Object} writable attributes
35
35
  */
36
36
  static get writableAttributes(): any;
37
- /**
38
- * Map attributes between external and internal representation.
39
- * @return {Object}
40
- */
41
- static attributeMapping: {};
42
37
  /**
43
38
  * Creates an instance of BaseObject.
44
39
  * @param {Object} [options]
45
40
  * @param {string} [options.id]
46
41
  * @param {string} [options.description]
47
- * @param {Object} [additionalProperties]
48
42
  */
49
43
  constructor(options?: {
50
44
  id?: string;
51
45
  description?: string;
52
- }, additionalProperties?: any);
46
+ });
53
47
  /** @type {string} */ id: string;
54
48
  /** @type {string} */ description: string;
55
49
  /**
@@ -57,7 +51,7 @@ export class BaseObject {
57
51
  * @param {Object} [options]
58
52
  * @param {Object} [additionalProperties]
59
53
  */
60
- updateAttributes(options?: any, additionalProperties?: any): void;
54
+ updateAttributes(options?: any): void;
61
55
  /**
62
56
  * Save object attributes in the backing store.
63
57
  */
@@ -33,28 +33,13 @@ export class BaseProvider extends BaseObject {
33
33
  * @return {string} identifier for environment options
34
34
  */
35
35
  static get instanceIdentifier(): string;
36
- /**
37
- * Extract options suitable for the constructor.
38
- * Form the given set of environment variables.
39
- * Object with the detected key value pairs is delivered.
40
- * @param {Object} [env] as from process.env
41
- * @param {string} instanceIdentifier part of variable name.
42
- * @return {Object|undefined} undefined if no suitable environment variables have been found
43
- */
44
- static optionsFromEnvironment(env?: any, instanceIdentifier?: string): any | undefined;
45
- /**
46
- * Check if given options are sufficient to create a provider.
47
- * @param {Object} options
48
- * @return {boolean} true if options ar sufficient to construct a provider
49
- */
50
- static areOptionsSufficcient(options: any): boolean;
51
36
  static attributes: {
52
37
  /**
53
38
  * Name of the provider.
54
39
  */
55
40
  name: {
56
41
  env: string;
57
- type: string;
42
+ type: object;
58
43
  isKey: boolean;
59
44
  writable: boolean;
60
45
  mandatory: boolean;
@@ -65,6 +50,10 @@ export class BaseProvider extends BaseObject {
65
50
  default?: any;
66
51
  set?: Function;
67
52
  get?: Function;
53
+ prepareValue?: Function;
54
+ values?: Set<any>;
55
+ externalName?: string;
56
+ additionalValues?: object;
68
57
  };
69
58
  url: import("pacc").AttributeDefinition;
70
59
  priority: import("pacc").AttributeDefinition;
@@ -72,10 +61,10 @@ export class BaseProvider extends BaseObject {
72
61
  * To forward info/warn and error messages to
73
62
  */
74
63
  messageDestination: {
75
- type: string;
76
64
  default: Console;
77
65
  writable: boolean;
78
66
  private: boolean;
67
+ type: object;
79
68
  isKey: boolean;
80
69
  mandatory: boolean;
81
70
  collection: boolean;
@@ -83,7 +72,11 @@ export class BaseProvider extends BaseObject {
83
72
  description?: string;
84
73
  set?: Function;
85
74
  get?: Function;
75
+ prepareValue?: Function;
76
+ values?: Set<any>;
77
+ externalName?: string;
86
78
  env?: string[] | string;
79
+ additionalValues?: object;
87
80
  };
88
81
  id: import("pacc").AttributeDefinition;
89
82
  description: import("pacc").AttributeDefinition;
@@ -11,7 +11,6 @@
11
11
  * @property {string} name
12
12
  */
13
13
  export class Branch extends Ref {
14
- constructor(owner: any, name: any, options: any);
15
14
  /**
16
15
  * Delete the branch from the {@link Repository}.
17
16
  * @see {@link Repository#deleteBranch}
package/types/hook.d.mts CHANGED
@@ -8,9 +8,9 @@ export class Hook extends OwnedObject {
8
8
  secret: import("pacc").AttributeDefinition;
9
9
  url: {
10
10
  description: string;
11
- writable: boolean;
12
- type: string;
11
+ type: object;
13
12
  isKey: boolean;
13
+ writable: boolean;
14
14
  mandatory: boolean;
15
15
  collection: boolean;
16
16
  private?: boolean;
@@ -18,13 +18,17 @@ export class Hook extends OwnedObject {
18
18
  default?: any;
19
19
  set?: Function;
20
20
  get?: Function;
21
+ prepareValue?: Function;
22
+ values?: Set<any>;
23
+ externalName?: string;
21
24
  env?: string[] | string;
25
+ additionalValues?: object;
22
26
  };
23
27
  content_type: {
24
28
  default: string;
25
- writable: boolean;
26
- type: string;
29
+ type: object;
27
30
  isKey: boolean;
31
+ writable: boolean;
28
32
  mandatory: boolean;
29
33
  collection: boolean;
30
34
  private?: boolean;
@@ -32,17 +36,38 @@ export class Hook extends OwnedObject {
32
36
  description?: string;
33
37
  set?: Function;
34
38
  get?: Function;
39
+ prepareValue?: Function;
40
+ values?: Set<any>;
41
+ externalName?: string;
35
42
  env?: string[] | string;
43
+ additionalValues?: object;
36
44
  };
37
45
  insecure_ssl: import("pacc").AttributeDefinition;
38
46
  events: {
39
- type: string;
40
47
  default: Set<string>;
48
+ type: object;
49
+ isKey: boolean;
50
+ writable: boolean;
51
+ mandatory: boolean;
52
+ collection: boolean;
53
+ private?: boolean;
54
+ depends?: string;
55
+ description?: string;
56
+ set?: Function;
57
+ get?: Function;
58
+ prepareValue?: Function;
59
+ values?: Set<any>;
60
+ externalName?: string;
61
+ env?: string[] | string;
62
+ additionalValues?: object;
41
63
  };
42
64
  name: import("pacc").AttributeDefinition;
43
65
  id: import("pacc").AttributeDefinition;
44
66
  description: import("pacc").AttributeDefinition;
45
67
  };
46
68
  static get delteteMethodName(): string;
69
+ set events(value: Set<any>);
70
+ get events(): Set<any>;
71
+ _events: any;
47
72
  }
48
73
  import { OwnedObject } from "./owned-object.mjs";
package/types/index.d.mts CHANGED
@@ -15,7 +15,6 @@ export * from "./hook.mjs";
15
15
  export * from "./milestone.mjs";
16
16
  export * from "./review.mjs";
17
17
  export * from "./application.mjs";
18
- export * from "./attribute-extras.mjs";
19
18
  export * from "./util.mjs";
20
19
  export { OwnedObject } from "./owned-object.mjs";
21
20
  export { BaseProvider } from "./base-provider.mjs";
@@ -15,9 +15,8 @@ export class NamedObject extends BaseObject {
15
15
  id: import("pacc").AttributeDefinition;
16
16
  description: import("pacc").AttributeDefinition;
17
17
  };
18
- constructor(name: any, options: any, additionalProperties: any);
19
- set name(name: string);
20
- get name(): string;
18
+ constructor(name: any, options: any);
19
+ name: any;
21
20
  /**
22
21
  * Beautified name use for human displaying only.
23
22
  * @return {string} human readable name
@@ -42,7 +41,6 @@ export class NamedObject extends BaseObject {
42
41
  /**
43
42
  * Provided name and all defined attributes.
44
43
  */
45
- toJSON(): any;
46
- #private;
44
+ toJSON(filter: any): any;
47
45
  }
48
46
  import { BaseObject } from "./base-object.mjs";
@@ -18,7 +18,7 @@ export class OwnedObject extends NamedObject {
18
18
  * @return {string}
19
19
  */
20
20
  static get deleteMethodName(): string;
21
- constructor(owner: any, name: any, options: any, additionalProperties: any);
21
+ constructor(owner: any, name: any, options: any);
22
22
  owner: any;
23
23
  /**
24
24
  * Removes the receiver from the owner.
@@ -73,7 +73,7 @@ export class PullRequest extends OwnedObject {
73
73
  state: {
74
74
  default: string;
75
75
  values: Set<string>;
76
- type: string;
76
+ type: object;
77
77
  isKey: boolean;
78
78
  writable: boolean;
79
79
  mandatory: boolean;
@@ -83,7 +83,10 @@ export class PullRequest extends OwnedObject {
83
83
  description?: string;
84
84
  set?: Function;
85
85
  get?: Function;
86
+ prepareValue?: Function;
87
+ externalName?: string;
86
88
  env?: string[] | string;
89
+ additionalValues?: object;
87
90
  };
88
91
  /**
89
92
  * Locked state of the pull request.
@@ -106,9 +109,15 @@ export class PullRequest extends OwnedObject {
106
109
  id: import("pacc").AttributeDefinition;
107
110
  description: import("pacc").AttributeDefinition;
108
111
  };
112
+ constructor(source: any, owner: any, name: any, options: any);
109
113
  /** @type {Branch} */ source: Branch;
114
+ _state: string;
115
+ set state(value: string);
116
+ get state(): string;
117
+ set merged(value: boolean);
118
+ get merged(): boolean;
110
119
  get destination(): any;
111
- get number(): string;
120
+ get number(): any;
112
121
  get dry(): boolean;
113
122
  /**
114
123
  * @return {Repository} destination repository
@@ -125,7 +134,6 @@ export class PullRequest extends OwnedObject {
125
134
  * @param {string} method
126
135
  */
127
136
  merge(method?: string): Promise<void>;
128
- merged: boolean;
129
137
  /**
130
138
  * Decline the pull request.
131
139
  */
package/types/ref.d.mts CHANGED
@@ -10,9 +10,6 @@ export class Ref extends OwnedObject {
10
10
  * @type {Object}
11
11
  */
12
12
  static attributes: any;
13
- static attributeMapping: {
14
- protected: string;
15
- };
16
13
  get refType(): string;
17
14
  /**
18
15
  * Full ref path.
@@ -47,10 +47,6 @@ export class RepositoryGroup extends RepositoryGroup_base {
47
47
  static get type(): string;
48
48
  static get collectionName(): string;
49
49
  static attributes: any;
50
- /**
51
- * Map attributes between external and internal representation.
52
- */
53
- static attributeMapping(): void;
54
50
  get isAdmin(): boolean;
55
51
  get areRepositoryNamesCaseSensitive(): any;
56
52
  get areRepositoryGroupNamesCaseSensitive(): any;
@@ -23,7 +23,8 @@ export class Repository extends OwnedObject {
23
23
  */
24
24
  defaultBranchName: {
25
25
  default: string;
26
- type: string;
26
+ externalName: string;
27
+ type: object;
27
28
  isKey: boolean;
28
29
  writable: boolean;
29
30
  mandatory: boolean;
@@ -33,14 +34,120 @@ export class Repository extends OwnedObject {
33
34
  description?: string;
34
35
  set?: Function;
35
36
  get?: Function;
37
+ prepareValue?: Function;
38
+ values?: Set<any>;
36
39
  env?: string[] | string;
40
+ additionalValues?: object;
37
41
  };
38
42
  cloneURL: import("pacc").AttributeDefinition;
39
- isArchived: import("pacc").AttributeDefinition;
40
- isLocked: import("pacc").AttributeDefinition;
41
- isDisabled: import("pacc").AttributeDefinition;
42
- isTemplate: import("pacc").AttributeDefinition;
43
- isFork: import("pacc").AttributeDefinition;
43
+ isArchived: {
44
+ externalName: string;
45
+ type: object;
46
+ isKey: boolean;
47
+ writable: boolean;
48
+ mandatory: boolean;
49
+ collection: boolean;
50
+ private?: boolean;
51
+ depends?: string;
52
+ description?: string;
53
+ default?: any;
54
+ set?: Function;
55
+ get?: Function;
56
+ prepareValue?: Function;
57
+ values?: Set<any>;
58
+ env?: string[] | string;
59
+ additionalValues?: object;
60
+ };
61
+ isLocked: {
62
+ externalName: string;
63
+ type: object;
64
+ isKey: boolean;
65
+ writable: boolean;
66
+ mandatory: boolean;
67
+ collection: boolean;
68
+ private?: boolean;
69
+ depends?: string;
70
+ description?: string;
71
+ default?: any;
72
+ set?: Function;
73
+ get?: Function;
74
+ prepareValue?: Function;
75
+ values?: Set<any>;
76
+ env?: string[] | string;
77
+ additionalValues?: object;
78
+ };
79
+ isDisabled: {
80
+ externalName: string;
81
+ type: object;
82
+ isKey: boolean;
83
+ writable: boolean;
84
+ mandatory: boolean;
85
+ collection: boolean;
86
+ private?: boolean;
87
+ depends?: string;
88
+ description?: string;
89
+ default?: any;
90
+ set?: Function;
91
+ get?: Function;
92
+ prepareValue?: Function;
93
+ values?: Set<any>;
94
+ env?: string[] | string;
95
+ additionalValues?: object;
96
+ };
97
+ isTemplate: {
98
+ externalName: string;
99
+ type: object;
100
+ isKey: boolean;
101
+ writable: boolean;
102
+ mandatory: boolean;
103
+ collection: boolean;
104
+ private?: boolean;
105
+ depends?: string;
106
+ description?: string;
107
+ default?: any;
108
+ set?: Function;
109
+ get?: Function;
110
+ prepareValue?: Function;
111
+ values?: Set<any>;
112
+ env?: string[] | string;
113
+ additionalValues?: object;
114
+ };
115
+ isFork: {
116
+ externalName: string;
117
+ type: object;
118
+ isKey: boolean;
119
+ writable: boolean;
120
+ mandatory: boolean;
121
+ collection: boolean;
122
+ private?: boolean;
123
+ depends?: string;
124
+ description?: string;
125
+ default?: any;
126
+ set?: Function;
127
+ get?: Function;
128
+ prepareValue?: Function;
129
+ values?: Set<any>;
130
+ env?: string[] | string;
131
+ additionalValues?: object;
132
+ };
133
+ isPrivate: {
134
+ externalName: string;
135
+ type: object;
136
+ isKey: boolean;
137
+ writable: boolean;
138
+ mandatory: boolean;
139
+ collection: boolean;
140
+ private?: boolean;
141
+ depends?: string;
142
+ description?: string;
143
+ default?: any;
144
+ set?: Function;
145
+ get?: Function;
146
+ prepareValue?: Function;
147
+ values?: Set<any>;
148
+ env?: string[] | string;
149
+ additionalValues?: object;
150
+ };
44
151
  name: import("pacc").AttributeDefinition;
45
152
  id: import("pacc").AttributeDefinition;
46
153
  description: import("pacc").AttributeDefinition;
@@ -54,13 +161,12 @@ export class Repository extends OwnedObject {
54
161
  * @param {Object} [options]
55
162
  * @param {string} [options.id]
56
163
  * @param {string} [options.description]
57
- * @param {Object} [additionalProperties]
58
164
  */
59
165
  constructor(owner: typeof RepositoryOwner, name: string, options?: {
60
166
  description?: string;
61
167
  id?: string;
62
- }, additionalProperties?: any);
63
- get defaultBranchName(): string;
168
+ });
169
+ get defaultBranchName(): any;
64
170
  /**
65
171
  * Lookup entries form the head of the default branch.
66
172
  * {@link Branch#entry}
@@ -1,171 +0,0 @@
1
- import { setAttribute, getAttribute } from "pacc";
2
-
3
- /**
4
- * Create properties from options and default options.
5
- * Already present properties (direct) are skipped.
6
- * The attribute list from the class will be applied to the
7
- * options and merged with the given set of properties.
8
- * ```js
9
- * class aClass {
10
- * static attributes = {
11
- * with_default: { default: 77 }
12
- * }
13
- * }
14
- *
15
- * definePropertiesFromOptions(new aClass());
16
- * // equivalent to
17
- * Object.definedProperties(new aClass(),{ with_default: { value: 77 }})
18
- * ```
19
- * @see Object.definedProperties()
20
- * @see Object.getOwnPropertyDescriptor()
21
- * @param {Object} object target object
22
- * @param {Object} options as passed to object constructor. Used as values for the attributes.
23
- * @param {Object} properties object properties
24
- * @param {Object} [attributes] attribute meta info
25
- */
26
- export function definePropertiesFromOptions(
27
- object,
28
- options = {},
29
- properties = {},
30
- attributes = object.constructor.attributes
31
- ) {
32
- const applyLater = {};
33
-
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
- }
47
- }
48
-
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
- }
65
- }
66
-
67
- const path = name.split(/\./);
68
- const first = path.shift();
69
-
70
- if (first !== undefined) {
71
- const property = properties[first];
72
-
73
- if (path.length) {
74
- const remaining = path.join(".");
75
-
76
- if (property) {
77
- setAttribute(property.value, remaining, value);
78
- } else {
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
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
- }
98
- }
99
- }
100
- }
101
- });
102
- }
103
-
104
- Object.defineProperties(object, properties);
105
- Object.assign(object, applyLater);
106
- }
107
-
108
- /**
109
- * Create json based on present options.
110
- * In other words only produce key value pairs if value is defined.
111
- * @param {Object} object
112
- * @param {Object} initial
113
- * @param {Object} attributes to operator on
114
- * @return {Object} initial + defined values
115
- */
116
- export function optionJSON(
117
- object,
118
- initial = {},
119
- attributes = object.constructor.attributes
120
- ) {
121
- return attributes
122
- ? Object.keys(attributes).reduce((a, c) => {
123
- const value = object[c];
124
- if (value !== undefined && !(value instanceof Function)) {
125
- a[c] = value instanceof Set ? [...value] : value;
126
- }
127
- return a;
128
- }, initial)
129
- : initial;
130
- }
131
-
132
- /**
133
- * Rename attributes.
134
- * Filters out null, undefined and empty strings.
135
- * ```js
136
- * mapAttributes({a:1},{a:"a'"}) // {"a'": 1}
137
- * ```
138
- * @param {Object} object
139
- * @param {Object} mapping
140
- * @return {Object} keys renamed after mapping
141
- */
142
- export function mapAttributes(object, mapping) {
143
- if (object !== undefined) {
144
- const o = {};
145
-
146
- for (const k of Object.keys(object)) {
147
- const v = getAttribute(object, k);
148
- if (v !== undefined && v !== null && v !== "") {
149
- setAttribute(o, mapping[k] || k, v);
150
- }
151
- }
152
-
153
- return o;
154
- }
155
- }
156
-
157
- /**
158
- * Same as mapAttributes but with the inverse mapping.
159
- * Filters out null, undefined and empty strings
160
- * @param {Object} object
161
- * @param {Object} [mapping]
162
- * @return {Object} keys renamed after mapping
163
- */
164
- export function mapAttributesInverse(object, mapping) {
165
- return mapping === undefined
166
- ? object
167
- : mapAttributes(
168
- object,
169
- Object.fromEntries(Object.entries(mapping).map(([k, v]) => [v, k]))
170
- );
171
- }
@@ -1,52 +0,0 @@
1
- /**
2
- * Create properties from options and default options.
3
- * Already present properties (direct) are skipped.
4
- * The attribute list from the class will be applied to the
5
- * options and merged with the given set of properties.
6
- * ```js
7
- * class aClass {
8
- * static attributes = {
9
- * with_default: { default: 77 }
10
- * }
11
- * }
12
- *
13
- * definePropertiesFromOptions(new aClass());
14
- * // equivalent to
15
- * Object.definedProperties(new aClass(),{ with_default: { value: 77 }})
16
- * ```
17
- * @see Object.definedProperties()
18
- * @see Object.getOwnPropertyDescriptor()
19
- * @param {Object} object target object
20
- * @param {Object} options as passed to object constructor. Used as values for the attributes.
21
- * @param {Object} properties object properties
22
- * @param {Object} [attributes] attribute meta info
23
- */
24
- export function definePropertiesFromOptions(object: any, options?: any, properties?: any, attributes?: any): void;
25
- /**
26
- * Create json based on present options.
27
- * In other words only produce key value pairs if value is defined.
28
- * @param {Object} object
29
- * @param {Object} initial
30
- * @param {Object} attributes to operator on
31
- * @return {Object} initial + defined values
32
- */
33
- export function optionJSON(object: any, initial?: any, attributes?: any): any;
34
- /**
35
- * Rename attributes.
36
- * Filters out null, undefined and empty strings.
37
- * ```js
38
- * mapAttributes({a:1},{a:"a'"}) // {"a'": 1}
39
- * ```
40
- * @param {Object} object
41
- * @param {Object} mapping
42
- * @return {Object} keys renamed after mapping
43
- */
44
- export function mapAttributes(object: any, mapping: any): any;
45
- /**
46
- * Same as mapAttributes but with the inverse mapping.
47
- * Filters out null, undefined and empty strings
48
- * @param {Object} object
49
- * @param {Object} [mapping]
50
- * @return {Object} keys renamed after mapping
51
- */
52
- export function mapAttributesInverse(object: any, mapping?: any): any;