repository-provider 31.2.7 → 32.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
@@ -200,7 +200,6 @@ console.log(await readme.getString());
200
200
  * [fullName](#fullname-1)
201
201
  * [toJSON](#tojson-1)
202
202
  * [attributes](#attributes-1)
203
- * [avatarURL](#avatarurl)
204
203
  * [homePageURL](#homepageurl)
205
204
  * [OwnedObject](#ownedobject)
206
205
  * [Parameters](#parameters-45)
@@ -241,14 +240,13 @@ console.log(await readme.getString());
241
240
  * [Ref](#ref)
242
241
  * [ref](#ref-1)
243
242
  * [refId](#refid)
244
- * [Parameters](#parameters-52)
245
243
  * [entries](#entries)
246
- * [Parameters](#parameters-53)
244
+ * [Parameters](#parameters-52)
247
245
  * [asyncIterator](#asynciterator)
248
246
  * [maybeEntry](#maybeentry)
249
- * [Parameters](#parameters-54)
247
+ * [Parameters](#parameters-53)
250
248
  * [entry](#entry)
251
- * [Parameters](#parameters-55)
249
+ * [Parameters](#parameters-54)
252
250
  * [repository](#repository-2)
253
251
  * [fullName](#fullname-3)
254
252
  * [fullCondensedName](#fullcondensedname-1)
@@ -262,27 +260,28 @@ console.log(await readme.getString());
262
260
  * [attributes](#attributes-2)
263
261
  * [isProtected](#isprotected-1)
264
262
  * [RepositoryGroup](#repositorygroup-1)
265
- * [Parameters](#parameters-56)
263
+ * [Parameters](#parameters-55)
266
264
  * [Properties](#properties-9)
267
265
  * [attributeMapping](#attributemapping-1)
268
266
  * [type](#type-1)
269
267
  * [url](#url-3)
270
268
  * [url](#url-4)
269
+ * [avatarURL](#avatarurl)
271
270
  * [RepositoryOwner](#repositoryowner)
272
- * [Parameters](#parameters-57)
271
+ * [Parameters](#parameters-56)
273
272
  * [Repository](#repository-3)
274
- * [Parameters](#parameters-58)
273
+ * [Parameters](#parameters-57)
275
274
  * [Properties](#properties-10)
276
275
  * [fullName](#fullname-4)
277
276
  * [slug](#slug)
278
277
  * [entry](#entry-1)
279
- * [Parameters](#parameters-59)
278
+ * [Parameters](#parameters-58)
280
279
  * [entries](#entries-1)
281
- * [Parameters](#parameters-60)
280
+ * [Parameters](#parameters-59)
282
281
  * [maybeEntry](#maybeentry-1)
283
- * [Parameters](#parameters-61)
282
+ * [Parameters](#parameters-60)
284
283
  * [commits](#commits)
285
- * [Parameters](#parameters-62)
284
+ * [Parameters](#parameters-61)
286
285
  * [cloneURL](#cloneurl)
287
286
  * [issuesURL](#issuesurl-1)
288
287
  * [homePageURL](#homepageurl-2)
@@ -293,63 +292,62 @@ console.log(await readme.getString());
293
292
  * [delete](#delete-2)
294
293
  * [defaultBranch](#defaultbranch)
295
294
  * [branch](#branch-2)
296
- * [Parameters](#parameters-63)
295
+ * [Parameters](#parameters-62)
297
296
  * [hasBranches](#hasbranches)
298
297
  * [branches](#branches-1)
299
- * [Parameters](#parameters-64)
298
+ * [Parameters](#parameters-63)
300
299
  * [createBranch](#createbranch-1)
301
- * [Parameters](#parameters-65)
300
+ * [Parameters](#parameters-64)
302
301
  * [addBranch](#addbranch)
303
- * [Parameters](#parameters-66)
302
+ * [Parameters](#parameters-65)
304
303
  * [deleteBranch](#deletebranch)
305
- * [Parameters](#parameters-67)
304
+ * [Parameters](#parameters-66)
306
305
  * [tag](#tag)
307
- * [Parameters](#parameters-68)
306
+ * [Parameters](#parameters-67)
308
307
  * [tags](#tags-1)
309
- * [Parameters](#parameters-69)
308
+ * [Parameters](#parameters-68)
310
309
  * [addTag](#addtag)
311
- * [Parameters](#parameters-70)
310
+ * [Parameters](#parameters-69)
312
311
  * [createPullRequest](#createpullrequest-1)
313
- * [Parameters](#parameters-71)
312
+ * [Parameters](#parameters-70)
314
313
  * [addPullRequest](#addpullrequest)
315
- * [Parameters](#parameters-72)
314
+ * [Parameters](#parameters-71)
316
315
  * [pullRequests](#pullrequests-1)
317
316
  * [pullRequest](#pullrequest-1)
318
- * [Parameters](#parameters-73)
317
+ * [Parameters](#parameters-72)
319
318
  * [deletePullRequest](#deletepullrequest)
320
- * [Parameters](#parameters-74)
319
+ * [Parameters](#parameters-73)
321
320
  * [addHook](#addhook)
322
- * [Parameters](#parameters-75)
321
+ * [Parameters](#parameters-74)
323
322
  * [createHook](#createhook)
324
- * [Parameters](#parameters-76)
323
+ * [Parameters](#parameters-75)
325
324
  * [hooks](#hooks-1)
326
325
  * [hook](#hook-1)
327
- * [Parameters](#parameters-77)
326
+ * [Parameters](#parameters-76)
328
327
  * [type](#type-2)
329
328
  * [refId](#refid-1)
330
- * [Parameters](#parameters-78)
331
- * [toJSON](#tojson-2)
329
+ * [Parameters](#parameters-77)
332
330
  * [attributes](#attributes-3)
333
331
  * [defaultBranchName](#defaultbranchname)
334
332
  * [issuesURL](#issuesurl-2)
335
333
  * [Review](#review)
336
334
  * [SingleGroupProvider](#singlegroupprovider)
337
335
  * [repository](#repository-4)
338
- * [Parameters](#parameters-79)
336
+ * [Parameters](#parameters-78)
339
337
  * [repositoryGroup](#repositorygroup-2)
340
- * [Parameters](#parameters-80)
338
+ * [Parameters](#parameters-79)
341
339
  * [repositoryGroups](#repositorygroups-1)
342
- * [Parameters](#parameters-81)
340
+ * [Parameters](#parameters-80)
343
341
  * [Tag](#tag-1)
344
342
  * [refType](#reftype-1)
345
343
  * [asArray](#asarray)
346
- * [Parameters](#parameters-82)
344
+ * [Parameters](#parameters-81)
347
345
  * [stripBaseName](#stripbasename)
348
- * [Parameters](#parameters-83)
346
+ * [Parameters](#parameters-82)
349
347
  * [stripBaseNames](#stripbasenames)
350
- * [Parameters](#parameters-84)
348
+ * [Parameters](#parameters-83)
351
349
  * [generateBranchName](#generatebranchname)
352
- * [Parameters](#parameters-85)
350
+ * [Parameters](#parameters-84)
353
351
 
354
352
  ## Application
355
353
 
@@ -1193,12 +1191,6 @@ Provided name and all defined attributes.
1193
1191
 
1194
1192
  options
1195
1193
 
1196
- ## avatarURL
1197
-
1198
- Avatar.
1199
-
1200
- Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1201
-
1202
1194
  ## homePageURL
1203
1195
 
1204
1196
  The url of home page.
@@ -1437,10 +1429,6 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
1437
1429
 
1438
1430
  Get sha of a ref.
1439
1431
 
1440
- #### Parameters
1441
-
1442
- * `ref` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (optional, default `this.ref`)
1443
-
1444
1432
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** sha of the ref
1445
1433
 
1446
1434
  ### entries
@@ -1591,6 +1579,12 @@ URL of the repository
1591
1579
 
1592
1580
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1593
1581
 
1582
+ ## avatarURL
1583
+
1584
+ Avatar.
1585
+
1586
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1587
+
1594
1588
  ## RepositoryOwner
1595
1589
 
1596
1590
  Mixin to define a class able to handle a collection of repositories.
@@ -1920,10 +1914,6 @@ Get sha of a ref.
1920
1914
 
1921
1915
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** sha of the ref
1922
1916
 
1923
- ### toJSON
1924
-
1925
- Provide name and all defined attributes
1926
-
1927
1917
  ### attributes
1928
1918
 
1929
1919
  options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "31.2.7",
3
+ "version": "32.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,9 +36,9 @@
36
36
  "ava": "^4.3.0",
37
37
  "c8": "^7.11.3",
38
38
  "documentation": "^13.2.5",
39
- "repository-provider-test-support": "^2.2.4",
39
+ "repository-provider-test-support": "^2.2.6",
40
40
  "semantic-release": "^19.0.3",
41
- "typescript": "^4.7.3"
41
+ "typescript": "^4.7.4"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=16.15.1"
package/src/ref.mjs CHANGED
@@ -38,12 +38,11 @@ export class Ref extends OwnedObject {
38
38
  }
39
39
 
40
40
  /**
41
- * Get sha of a ref.
42
- * @param {string} ref
41
+ * Get sha of our ref.
43
42
  * @return {Promise<string>} sha of the ref
44
43
  */
45
- async refId(ref = this.ref) {
46
- return this.owner.refId(ref);
44
+ get refId() {
45
+ return this.owner.refId(this.ref);
47
46
  }
48
47
 
49
48
  /**
@@ -81,7 +81,15 @@ export function RepositoryOwner(base) {
81
81
  );
82
82
  }
83
83
 
84
- async _lookup(type, name, split, defaultItem) {
84
+ /**
85
+ * Lookup entity of a given type and name.
86
+ * @param {string} type
87
+ * @param {string} name
88
+ * @param {function} split
89
+ * @param {Object} defaultItem
90
+ * @returns {NamedObject} from a repository
91
+ */
92
+ async lookup(type, name, split, defaultItem) {
85
93
  if (name !== undefined) {
86
94
  await this.initializeRepositories();
87
95
 
@@ -100,7 +108,15 @@ export function RepositoryOwner(base) {
100
108
  }
101
109
  }
102
110
 
103
- async *_list(type, patterns, split, defaultItem) {
111
+ /**
112
+ * List entities for a given type and pattern.
113
+ * @param {string} type
114
+ * @param {string|string[]} patterns
115
+ * @param {function} split
116
+ * @param {Object} defaultItem
117
+ * @return {AsyncIterator<NamedObject>} matching type and pattern
118
+ */
119
+ async *list(type, patterns, split, defaultItem) {
104
120
  await this.initializeRepositories();
105
121
 
106
122
  patterns = stripBaseNames(patterns, this.provider.repositoryBases);
@@ -175,7 +191,7 @@ export function RepositoryOwner(base) {
175
191
  * @return {Promise<Branch|undefined>}
176
192
  */
177
193
  async branch(name) {
178
- return this._lookup(
194
+ return this.lookup(
179
195
  "branch",
180
196
  name,
181
197
  name => name.split(/#/),
@@ -189,7 +205,7 @@ export function RepositoryOwner(base) {
189
205
  * @return {AsyncIterator<Branch>} all matching branches of the owner
190
206
  */
191
207
  async *branches(patterns) {
192
- yield* this._list(
208
+ yield* this.list(
193
209
  "branches",
194
210
  patterns,
195
211
  pattern => pattern.split(/#/),
@@ -198,51 +214,51 @@ export function RepositoryOwner(base) {
198
214
  }
199
215
 
200
216
  async tag(name) {
201
- return this._lookup("tag", name, name => name.split(/#/));
217
+ return this.lookup("tag", name, name => name.split(/#/));
202
218
  }
203
219
 
204
220
  async *tags(patterns) {
205
- yield* this._list("tags", patterns, pattern => pattern.split(/#/));
221
+ yield* this.list("tags", patterns, pattern => pattern.split(/#/));
206
222
  }
207
223
 
208
224
  async pullRequest(name) {
209
- return this._lookup("pullRequest", name);
225
+ return this.lookup("pullRequest", name);
210
226
  }
211
227
 
212
228
  async *pullRequests(patterns) {
213
- yield* this._list("pullRequests", patterns);
229
+ yield* this.list("pullRequests", patterns);
214
230
  }
215
231
 
216
232
  async project(name) {
217
- return this._lookup("project", name);
233
+ return this.lookup("project", name);
218
234
  }
219
235
 
220
236
  async *projects(patterns) {
221
- yield* this._list("projects", patterns);
237
+ yield* this.list("projects", patterns);
222
238
  }
223
239
 
224
240
  async application(name) {
225
- return this._lookup("application", name);
241
+ return this.lookup("application", name);
226
242
  }
227
243
 
228
244
  async *applications(patterns) {
229
- yield* this._list("applications", patterns);
245
+ yield* this.list("applications", patterns);
230
246
  }
231
247
 
232
248
  async milestone(name) {
233
- return this._lookup("milestone", name);
249
+ return this.lookup("milestone", name);
234
250
  }
235
251
 
236
252
  async *milestones(patterns) {
237
- yield* this._list("milestones", patterns);
253
+ yield* this.list("milestones", patterns);
238
254
  }
239
255
 
240
256
  async hook(name) {
241
- return this._lookup("hook", name);
257
+ return this.lookup("hook", name);
242
258
  }
243
259
 
244
260
  async *hooks(patterns) {
245
- yield* this._list("hooks", patterns);
261
+ yield* this.list("hooks", patterns);
246
262
  }
247
263
  };
248
264
  }
@@ -465,16 +465,6 @@ export class Repository extends OwnedObject {
465
465
  */
466
466
  async refId(ref) {}
467
467
 
468
- /**
469
- * Provide name and all defined attributes
470
- */
471
- toJSON() {
472
- return optionJSON(this, {
473
- name: this.name,
474
- fullName: this.fullName,
475
- });
476
- }
477
-
478
468
  initialize() {}
479
469
 
480
470
  initializeHooks() {