repository-provider 29.2.1 → 30.0.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
@@ -68,6 +68,8 @@ console.log(await readme.getString());
68
68
  * [toString](#tostring)
69
69
  * [displayName](#displayname)
70
70
  * [fullName](#fullname)
71
+ * [fullCondensedName](#fullcondensedname)
72
+ * [identifier](#identifier)
71
73
  * [isWritable](#iswritable)
72
74
  * [equals](#equals)
73
75
  * [Parameters](#parameters-8)
@@ -218,7 +220,7 @@ console.log(await readme.getString());
218
220
  * [Parameters](#parameters-50)
219
221
  * [decline](#decline)
220
222
  * [reviews](#reviews)
221
- * [identifier](#identifier)
223
+ * [identifier](#identifier-1)
222
224
  * [validStates](#validstates)
223
225
  * [defaultListStates](#defaultliststates)
224
226
  * [validMergeMethods](#validmergemethods)
@@ -247,8 +249,7 @@ console.log(await readme.getString());
247
249
  * [Parameters](#parameters-56)
248
250
  * [repository](#repository-2)
249
251
  * [fullName](#fullname-3)
250
- * [fullCondensedName](#fullcondensedname)
251
- * [identifier](#identifier-1)
252
+ * [fullCondensedName](#fullcondensedname-1)
252
253
  * [toString](#tostring-1)
253
254
  * [issuesURL](#issuesurl)
254
255
  * [homePageURL](#homepageurl-1)
@@ -271,7 +272,6 @@ console.log(await readme.getString());
271
272
  * [Properties](#properties-10)
272
273
  * [fullName](#fullname-4)
273
274
  * [slug](#slug)
274
- * [identifier](#identifier-2)
275
275
  * [entry](#entry-1)
276
276
  * [Parameters](#parameters-60)
277
277
  * [entries](#entries-1)
@@ -502,6 +502,18 @@ Complete name in the hierachy.
502
502
 
503
503
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
504
504
 
505
+ ### fullCondensedName
506
+
507
+ Complete name in the hierachy.
508
+
509
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
510
+
511
+ ### identifier
512
+
513
+ Short human readable identifier with provider and branch.
514
+
515
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
516
+
505
517
  ### isWritable
506
518
 
507
519
  By default cannot be written to.
@@ -1484,12 +1496,6 @@ But skipping the branch name if it is the default branch.
1484
1496
 
1485
1497
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 'user/repo#branch'
1486
1498
 
1487
- ### identifier
1488
-
1489
- Short human readable identifier with provider and branch.
1490
-
1491
- Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1492
-
1493
1499
  ### toString
1494
1500
 
1495
1501
  Same as identifier.
@@ -1620,12 +1626,6 @@ Name of the repo as used in the URL.
1620
1626
 
1621
1627
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1622
1628
 
1623
- ### identifier
1624
-
1625
- Short human readable identifier with provider and branch.
1626
-
1627
- Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1628
-
1629
1629
  ### entry
1630
1630
 
1631
1631
  Lookup entries form the head of the default branch.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "29.2.1",
3
+ "version": "30.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,7 +27,7 @@
27
27
  "docs": "documentation readme --section=API ./src/**/*.mjs",
28
28
  "lint": "npm run lint:docs && npm run lint:tsc",
29
29
  "lint:docs": "documentation lint ./src/**/*.mjs",
30
- "lint:tsc": "tsc --allowJs --checkJs --noEmit -t es2022 ./src/*.mjs"
30
+ "lint:tsc": "tsc --allowJs --checkJs --noEmit -t es2022 -m node16 ./src/*.mjs"
31
31
  },
32
32
  "dependencies": {
33
33
  "matching-iterator": "^2.0.4"
@@ -36,9 +36,9 @@
36
36
  "ava": "^4.2.0",
37
37
  "c8": "^7.11.3",
38
38
  "documentation": "^13.2.5",
39
- "repository-provider-test-support": "^2.1.18",
39
+ "repository-provider-test-support": "^2.1.19",
40
40
  "semantic-release": "^19.0.2",
41
- "typescript": "^4.6.3"
41
+ "typescript": "^4.7.2"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=16.15.0"
package/src/attribute.mjs CHANGED
@@ -65,6 +65,11 @@ export function definePropertiesFromOptions(
65
65
  value = attribute.set(value);
66
66
  } else {
67
67
  switch (attribute.type) {
68
+ case "set":
69
+ if (Array.isArray(value)) {
70
+ value = new Set(value);
71
+ }
72
+ break;
68
73
  case "boolean":
69
74
  if (value !== undefined) {
70
75
  value =
@@ -120,7 +125,7 @@ export function defaultValues(attributes, object) {
120
125
  a.push([name, attribute.default]);
121
126
  } else if (attribute.get !== undefined) {
122
127
  const value = attribute.get(attribute, object);
123
- if(value !== undefined) {
128
+ if (value !== undefined) {
124
129
  a.push([name, value]);
125
130
  }
126
131
  }
@@ -191,7 +196,11 @@ export function optionJSON(
191
196
  return Object.keys(attributes || {}).reduce((a, c) => {
192
197
  const value = object[c];
193
198
  if (value !== undefined && !(value instanceof Function)) {
194
- a[c] = value;
199
+ if (value instanceof Set) {
200
+ a[c] = [...value];
201
+ } else {
202
+ a[c] = value;
203
+ }
195
204
  }
196
205
  return a;
197
206
  }, initial);
package/src/branch.mjs CHANGED
@@ -7,7 +7,7 @@ import { Commit } from "./commit.mjs";
7
7
  /**
8
8
  * Abstract branch.
9
9
  * @see {@link Repository#_addBranch}
10
- * @param {Repository} repository
10
+ * @param {RepositoryOwner} owner
11
11
  * @param {string} name
12
12
  * @param {Object} options
13
13
  *
package/src/hook.mjs CHANGED
@@ -12,7 +12,8 @@ export class Hook extends OwnedObject {
12
12
  secret: { type: "string", private: true, writable: true },
13
13
  content_type: { type: "string", default: "json", writable: true },
14
14
  insecure_ssl: { type: "boolean", default: false },
15
- active: { type: "boolean", default: true, writable: true }
15
+ active: { type: "boolean", default: true, writable: true },
16
+ events: { type: "set", default: new Set(["*"]) }
16
17
  };
17
18
  }
18
19
 
@@ -20,17 +21,10 @@ export class Hook extends OwnedObject {
20
21
  return "_addHook";
21
22
  }
22
23
 
23
- constructor(owner, name, events = new Set(["*"]), options) {
24
- super(owner, name, options, {
25
- events: { value: events }
26
- });
27
- }
28
-
29
24
  /**
30
25
  * Provide name, events and all defined attributes.
31
26
  */
32
27
  toJSON() {
33
- return optionJSON(this, { name: this.name, id: this.id, events: [...this.events] });
28
+ return optionJSON(this, { name: this.name, id: this.id });
34
29
  }
35
30
  }
36
-
@@ -9,7 +9,7 @@ import { BaseProvider } from "./base-provider.mjs";
9
9
  * Abstract pull request.
10
10
  * {@link Repository#addPullRequest}
11
11
  * @param {Branch} source merge source
12
- * @param {Branch} destination merge target
12
+ * @param {Branch} owner merge target
13
13
  * @param {string} name
14
14
  * @param {Object} options
15
15
  * @param {string} [options.title]
@@ -218,9 +218,7 @@ export class PullRequest extends OwnedObject {
218
218
  * @return {BaseProvider}
219
219
  */
220
220
  get provider() {
221
- return this.owner === undefined
222
- ? undefined
223
- : this.owner.provider;
221
+ return this.owner && this.owner.provider;
224
222
  }
225
223
 
226
224
  /**
@@ -25,7 +25,6 @@ import { BaseProvider } from "./base-provider.mjs";
25
25
  * @property {Map<string,Milestone>} milestones
26
26
  */
27
27
  export class Repository extends OwnedObject {
28
-
29
28
  static get addMethodName() {
30
29
  return "_addRepository";
31
30
  }
@@ -128,8 +127,7 @@ export class Repository extends OwnedObject {
128
127
  * @param {Object} options
129
128
  * @return {AsyncIterator<Commit>} all matching commits in the repository
130
129
  */
131
- async *commits(options) {
132
- }
130
+ async *commits(options) {}
133
131
 
134
132
  /**
135
133
  * Urls to access the repo.
@@ -234,7 +232,7 @@ export class Repository extends OwnedObject {
234
232
  * @return {Promise<Branch>}
235
233
  */
236
234
  async branch(name) {
237
- if(name === this.defaultBranchName) {
235
+ if (name === this.defaultBranchName) {
238
236
  return this.#branches.get(name) || this.addBranch(name);
239
237
  }
240
238
 
@@ -242,8 +240,10 @@ export class Repository extends OwnedObject {
242
240
  return this.#branches.get(name);
243
241
  }
244
242
 
245
- get hasBranches()
246
- {
243
+ /**
244
+ * @return {boolean} true if there is at least one branch
245
+ */
246
+ get hasBranches() {
247
247
  return this.#branches.size > 0;
248
248
  }
249
249
 
@@ -277,7 +277,9 @@ export class Repository extends OwnedObject {
277
277
  * @return {Branch} newly created branch
278
278
  */
279
279
  addBranch(name, options) {
280
- return this.#branches.get(name) || new this.branchClass(this, name, options);
280
+ return (
281
+ this.#branches.get(name) || new this.branchClass(this, name, options)
282
+ );
281
283
  }
282
284
 
283
285
  _addBranch(branch) {
@@ -323,7 +325,7 @@ export class Repository extends OwnedObject {
323
325
  * @return {Tag} newly created tag
324
326
  */
325
327
  addTag(name, options) {
326
- return this.#tags.get(name) || new this.tagClass(this, name, options);
328
+ return this.#tags.get(name) || new this.tagClass(this, name, options);
327
329
  }
328
330
 
329
331
  _addTag(tag) {
@@ -394,11 +396,16 @@ export class Repository extends OwnedObject {
394
396
  }
395
397
 
396
398
  /**
397
- * Add a Hook.
398
- * @param {Hook} hook
399
+ * Add a new {@link Hook}.
400
+ * @param {string} name of the new hoook name
401
+ * @param {Object} options
402
+ * @return {Hook} newly created hook
399
403
  */
400
- addHook(hook) {
401
- this.#hooks.push(hook);
404
+ addHook(name, ...args) {
405
+ return (
406
+ this.#hooks.find(hook => hook.name == name) ||
407
+ new this.hookClass(this, name, ...args)
408
+ );
402
409
  }
403
410
 
404
411
  _addHook(hook) {
@@ -475,8 +482,7 @@ export class Repository extends OwnedObject {
475
482
  * @param {string} ref
476
483
  * @return {Promise<string>} sha of the ref
477
484
  */
478
- async refId(ref) {
479
- }
485
+ async refId(ref) {}
480
486
 
481
487
  /**
482
488
  * Provide name and all defined attributes