repository-provider 32.7.9 → 32.7.11

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
@@ -1,6 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/repository-provider.svg)](https://www.npmjs.com/package/repository-provider)
2
2
  [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3
- [![Open Bundle](https://bundlejs.com/badge-light.svg)](https://bundlejs.com/?q=repository-provider)
3
+ [![bundlejs](https://deno.bundlejs.com/?q=repository-provider\&badge=detailed)](https://bundlejs.com/?q=repository-provider)
4
4
  [![downloads](http://img.shields.io/npm/dm/repository-provider.svg?style=flat-square)](https://npmjs.org/package/repository-provider)
5
5
  [![GitHub Issues](https://img.shields.io/github/issues/arlac77/repository-provider.svg?style=flat-square)](https://github.com/arlac77/repository-provider/issues)
6
6
  [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Frepository-provider%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/arlac77/repository-provider/goto)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "32.7.9",
3
+ "version": "32.7.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,7 +37,7 @@
37
37
  "browser-ava": "^1.3.38",
38
38
  "c8": "^7.13.0",
39
39
  "documentation": "^14.0.1",
40
- "repository-provider-test-support": "^2.3.2",
40
+ "repository-provider-test-support": "^2.3.3",
41
41
  "semantic-release": "^21.0.2",
42
42
  "typescript": "^5.0.4"
43
43
  },
@@ -32,10 +32,6 @@ export function definePropertiesFromOptions(
32
32
  const applyLater = {};
33
33
 
34
34
  Object.entries(attributes).forEach(([name, attribute]) => {
35
- const path = name.split(/\./);
36
- const first = path.shift();
37
- const property = properties[first];
38
-
39
35
  let value = getAttribute(options, name);
40
36
 
41
37
  if (value === undefined) {
@@ -67,8 +63,13 @@ export function definePropertiesFromOptions(
67
63
  }
68
64
  }
69
65
 
66
+ const path = name.split(/\./);
67
+ const first = path.shift();
68
+ const property = properties[first];
69
+
70
70
  if (path.length) {
71
71
  const remaining = path.join(".");
72
+
72
73
  if (property) {
73
74
  setAttribute(property.value, remaining, value);
74
75
  } else {
@@ -4,11 +4,12 @@ import {
4
4
  } from "./attribute-extras.mjs";
5
5
  import { description_attribute, id_attribute } from "./attributes.mjs";
6
6
 
7
- /**
8
- * @param {Object} options
9
- * @param {Object} additionalProperties
10
- */
11
- export class BaseObject {
7
+ /**
8
+ * Creates an instance of BaseObject.
9
+ * @param {Object|undefined} options
10
+ * @param {Object|undefined} additionalProperties
11
+ */
12
+ export class BaseObject {
12
13
  /**
13
14
  * @return {string} type we represent
14
15
  */
@@ -56,18 +57,13 @@ export class BaseObject {
56
57
  return {};
57
58
  }
58
59
 
59
- /**
60
- * Creates an instance of BaseObject.
61
- * @param {Object} options
62
- * @param {Object} additionalProperties
63
- */
64
60
  constructor(options, additionalProperties) {
65
61
  this.updateAttributes(options, additionalProperties);
66
62
  }
67
63
 
68
64
  /**
69
65
  * Takes values from options.
70
- * @param {Object} options
66
+ * @param {Object|undefined} options
71
67
  */
72
68
  updateAttributes(options, additionalProperties) {
73
69
  definePropertiesFromOptions(
@@ -12,7 +12,8 @@ import {
12
12
  url_attribute,
13
13
  name_attribute,
14
14
  description_attribute,
15
- priority_attribute
15
+ priority_attribute,
16
+ default_attribute
16
17
  } from "./attributes.mjs";
17
18
 
18
19
  /**
@@ -119,9 +120,9 @@ export class BaseProvider extends BaseObject {
119
120
  * To forward info/warn and error messages to
120
121
  */
121
122
  messageDestination: {
123
+ ...default_attribute,
122
124
  type: "object",
123
125
  default: console,
124
- mandatory: false,
125
126
  writable: true,
126
127
  private: true
127
128
  }
@@ -300,7 +301,7 @@ export class BaseProvider extends BaseObject {
300
301
  * List provider objects of a given type.
301
302
  *
302
303
  * @param {string} type name of the method to deliver typed iterator projects,milestones,hooks,repositories,branches,tags
303
- * @param {string|string[]} patterns group / repository filter
304
+ * @param {string[]|string} patterns group / repository filter
304
305
  */
305
306
  async *list(type, patterns) {
306
307
  if (patterns === undefined) {
package/src/branch.mjs CHANGED
@@ -201,7 +201,7 @@ export class Branch extends Ref {
201
201
  * Create a new {@link Branch} by cloning a given source branch.
202
202
  * Simply calls Repository.createBranch() with the receiver as source branch
203
203
  * @param {string} name the new branch
204
- * @param {Object|undefined} options
204
+ * @param {Object|undefined} options passed through
205
205
  * @return {Promise<Branch>} newly created branch (or already present old one with the same name)
206
206
  */
207
207
  async createBranch(name, options) {
@@ -90,7 +90,7 @@ export class MultiGroupProvider extends BaseProvider {
90
90
  * Create a new repository group.
91
91
  * If there is already a group for the given name it will be returend instead
92
92
  * @param {string} name of the group
93
- * @param {Object} options
93
+ * @param {Object|undefined} options
94
94
  * @return {Promise<RepositoryGroup>}
95
95
  */
96
96
  async createRepositoryGroup(name, options) {
@@ -100,7 +100,7 @@ export class MultiGroupProvider extends BaseProvider {
100
100
  /**
101
101
  * Add a new repository group (not provider specific actions are executed).
102
102
  * @param {string} name of the group
103
- * @param {Object} options
103
+ * @param {Object|undefined} options
104
104
  * @return {RepositoryGroup}
105
105
  */
106
106
  addRepositoryGroup(name, options) {
@@ -9,8 +9,8 @@ import {
9
9
  /**
10
10
  * Object with a name.
11
11
  * @param {string} name
12
- * @param {Object} options
13
- * @param {Object} additionalProperties
12
+ * @param {Object|undefined} options
13
+ * @param {Object|undefined} additionalProperties
14
14
  *
15
15
  * @property {string} name
16
16
  */
package/src/ref.mjs CHANGED
@@ -70,7 +70,7 @@ export class Ref extends OwnedObject {
70
70
  /**
71
71
  * Get exactly one matching entry by name or undefine if no such entry is found.
72
72
  * @param {string} name
73
- * @return {Promise<ContentEntry>}
73
+ * @return {Promise<ContentEntry|undefined>}
74
74
  */
75
75
  async maybeEntry(name) {
76
76
  return (await this.entries(name).next()).value;
@@ -11,7 +11,7 @@ import {
11
11
  * Abstract repository collection.
12
12
  * @param {BaseProvider} provider
13
13
  * @param {string} name of the group
14
- * @param {Object} options
14
+ * @param {Object|undefined} options
15
15
  * @param {string} [options.description] human readable description
16
16
  * @param {string} [options.id] internal id
17
17
  * @param {string} [options.uuid] internal id
@@ -1,11 +1,12 @@
1
1
  import { matcher } from "matching-iterator";
2
2
  import { Branch } from "./branch.mjs";
3
3
  import { Repository } from "./repository.mjs";
4
+ import { NamedObject } from "./named-object.mjs";
4
5
  import { asArray, stripBaseName, stripBaseNames } from "./util.mjs";
5
6
 
6
7
  /**
7
8
  * Mixin to define a class able to handle a collection of repositories.
8
- * @param {Class} base to be extendet
9
+ * @param {Object} base to be extendet
9
10
  */
10
11
  export function RepositoryOwner(base) {
11
12
  return class RepositoryOwner extends base {
@@ -108,7 +109,7 @@ export function RepositoryOwner(base) {
108
109
  /**
109
110
  * List entities for a given type and pattern.
110
111
  * @param {string} type
111
- * @param {string|string[]} patterns
112
+ * @param {string[]|string} patterns
112
113
  * @param {function} [split]
113
114
  * @param {Object} [defaultItem]
114
115
  * @return {AsyncIterator<NamedObject>} matching type and pattern
@@ -23,7 +23,7 @@ import {
23
23
  * @class Repository
24
24
  * @param {RepositoryOwner} owner
25
25
  * @param {string} name (#branch) will be removed
26
- * @param {Object} options
26
+ * @param {Object|undefined} options
27
27
  * @param {string} [options.description] human readable description
28
28
  * @param {string} [options.id] internal id
29
29
  *
@@ -108,7 +108,7 @@ export class Repository extends OwnedObject {
108
108
 
109
109
  /**
110
110
  * List entries of the default branch.
111
- * @param {string[]} matchingPatterns
111
+ * @param {string[]|string} matchingPatterns
112
112
  * @return {AsyncIterator<ContentEntry>} all matching entries in the branch
113
113
  */
114
114
  async *entries(matchingPatterns) {
@@ -126,7 +126,7 @@ export class Repository extends OwnedObject {
126
126
 
127
127
  /**
128
128
  * List commits of the default branch.
129
- * @param {Object} options
129
+ * @param {Object|undefined} options
130
130
  * @return {AsyncIterator<Commit>} all matching commits in the repository
131
131
  */
132
132
  async *commits(options) {}
@@ -207,7 +207,7 @@ export class Repository extends OwnedObject {
207
207
  /**
208
208
  * Lookup branch by name.
209
209
  * @param {string} name
210
- * @return {Promise<Branch>}
210
+ * @return {Promise<Branch|undefined>}
211
211
  */
212
212
  async branch(name) {
213
213
  if (name === this.defaultBranchName) {
@@ -226,6 +226,7 @@ export class Repository extends OwnedObject {
226
226
  }
227
227
 
228
228
  /**
229
+ * @param {string[]|string} patterns
229
230
  * @return {AsyncIterator<Branch>} of all branches
230
231
  */
231
232
  async *branches(patterns) {
@@ -239,7 +240,7 @@ export class Repository extends OwnedObject {
239
240
  * Create a new {@link Branch} by cloning a given source branch.
240
241
  * @param {string} name of the new branch
241
242
  * @param {Branch} source branch defaults to the defaultBranch
242
- * @param {Object} options
243
+ * @param {Object|undefined} options
243
244
  * @return {Promise<Branch>} newly created branch (or already present old one with the same name)
244
245
  */
245
246
  async createBranch(name, source, options) {
@@ -291,7 +292,7 @@ export class Repository extends OwnedObject {
291
292
  }
292
293
 
293
294
  /**
294
- * @param {string|string[]} patterns
295
+ * @param {string[]|string} patterns
295
296
  * @return {AsyncIterator<Tag>} of all tags
296
297
  */
297
298
  async *tags(patterns) {
@@ -333,7 +334,7 @@ export class Repository extends OwnedObject {
333
334
  * Add a pull request.
334
335
  * @param {string} name
335
336
  * @param {Branch} source
336
- * @param {Object} options
337
+ * @param {Object|undefined} options
337
338
  * @return {PullRequest}
338
339
  */
339
340
  addPullRequest(name, source, options) {
@@ -362,9 +363,9 @@ export class Repository extends OwnedObject {
362
363
  }
363
364
 
364
365
  /**
365
- * The @{link PullRequest} for a given name.
366
+ * The @see {@link PullRequest} for a given name.
366
367
  * @param {string} name
367
- * @return {Promise<PullRequest>}
368
+ * @return {Promise<PullRequest|undefined>}
368
369
  */
369
370
  async pullRequest(name) {
370
371
  await this.initializePullRequests();
@@ -383,7 +384,7 @@ export class Repository extends OwnedObject {
383
384
  /**
384
385
  * Add a new {@link Hook}.
385
386
  * @param {string} name of the new hoook name
386
- * @param {Object} options
387
+ * @param {Object|undefined} options
387
388
  * @return {Hook} newly created hook
388
389
  */
389
390
  addHook(name, options) {
@@ -434,6 +435,11 @@ export class Repository extends OwnedObject {
434
435
  this.#milestones.set(milestone.name, milestone);
435
436
  }
436
437
 
438
+ /**
439
+ * Get a Milestone.
440
+ * @param {string} name
441
+ * @return {Promise<Milestone|undefined>} for the given name
442
+ */
437
443
  async milestone(name) {
438
444
  return this.#milestones.get(name);
439
445
  }
@@ -442,6 +448,11 @@ export class Repository extends OwnedObject {
442
448
  this.#projects.set(project.name, project);
443
449
  }
444
450
 
451
+ /**
452
+ * Get a Project.
453
+ * @param {string} name
454
+ * @return {Promise<Project|undefined>} for the given name
455
+ */
445
456
  async project(name) {
446
457
  return this.#projects.get(name);
447
458
  }
@@ -450,6 +461,11 @@ export class Repository extends OwnedObject {
450
461
  this.#applications.set(application.name, application);
451
462
  }
452
463
 
464
+ /**
465
+ * Get an Application.
466
+ * @param {string} name
467
+ * @return {Promise<Application|undefined>} for the given name
468
+ */
453
469
  async application(name) {
454
470
  return this.#applications.get(name);
455
471
  }
@@ -465,7 +481,7 @@ export class Repository extends OwnedObject {
465
481
  /**
466
482
  * Get sha of a ref.
467
483
  * @param {string} ref
468
- * @return {Promise<string>} sha of the ref
484
+ * @return {Promise<string|undefined>} sha of the ref
469
485
  */
470
486
  async refId(ref) {}
471
487
 
package/src/util.mjs CHANGED
@@ -19,6 +19,7 @@ export function asArray(value) {
19
19
  * @return {string} name without base
20
20
  */
21
21
  export function stripBaseName(name, repositoryBases, whenFound) {
22
+ if(name) {
22
23
  for (const b of repositoryBases) {
23
24
  const m = name.match(/^(\w+:)\/\/([^@]+@)/);
24
25
  if (m) {
@@ -30,12 +31,13 @@ export function stripBaseName(name, repositoryBases, whenFound) {
30
31
  return name.slice(b.length);
31
32
  }
32
33
  }
34
+ }
33
35
  return name;
34
36
  }
35
37
 
36
38
  /**
37
39
  * Loops over names and executes stripBaseName.
38
- * @param {string|string[]} names
40
+ * @param {string[]|string|undefined} names
39
41
  * @param {string[]} repositoryBases all possible bases
40
42
  * @param {Function} [whenFound] to be called with the found base name
41
43
  * @return {string[]|string|undefined} names without base
@@ -43,7 +45,7 @@ export function stripBaseName(name, repositoryBases, whenFound) {
43
45
  export function stripBaseNames(names, repositoryBases, whenFound) {
44
46
  return Array.isArray(names)
45
47
  ? names.map(name => stripBaseName(name, repositoryBases, whenFound))
46
- : names && stripBaseName(names, repositoryBases, whenFound);
48
+ : stripBaseName(names, repositoryBases, whenFound);
47
49
  }
48
50
 
49
51
  /**