repository-provider 29.1.0 → 29.1.3

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,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "29.1.0",
3
+ "version": "29.1.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,7 +36,7 @@
36
36
  "ava": "^4.2.0",
37
37
  "c8": "^7.11.2",
38
38
  "documentation": "^13.2.5",
39
- "repository-provider-test-support": "^2.1.14",
39
+ "repository-provider-test-support": "^2.1.16",
40
40
  "semantic-release": "^19.0.2",
41
41
  "typescript": "^4.6.3"
42
42
  },
@@ -1,5 +1,5 @@
1
1
  import { optionJSON } from "./attribute.mjs";
2
- import { NamedObject } from "./named-object.mjs";
2
+ import { OwnedObject } from "./owned-object.mjs";
3
3
  import { Branch } from "./branch.mjs";
4
4
  import { Repository } from "./repository.mjs";
5
5
  import { Review } from "./review.mjs";
@@ -26,7 +26,12 @@ import { BaseProvider } from "./base-provider.mjs";
26
26
  * @property {boolean} [locked]
27
27
  * @property {string} url
28
28
  */
29
- export class PullRequest extends NamedObject {
29
+ export class PullRequest extends OwnedObject {
30
+
31
+ static get registerInstanceMethodName() {
32
+ return "_addPullRequest";
33
+ }
34
+
30
35
  /**
31
36
  * All valid states
32
37
  * @return {Set<string>} valid states
@@ -142,12 +147,11 @@ export class PullRequest extends NamedObject {
142
147
  };
143
148
  }
144
149
 
145
- constructor(source, destination, name, options) {
150
+ constructor(source, owner, name, options) {
146
151
  let state = "OPEN";
147
152
 
148
- super(name, options, {
153
+ super(owner, name, options, {
149
154
  source: { value: source },
150
- destination: { value: destination },
151
155
  state: {
152
156
  set(value) {
153
157
  value = value.toUpperCase();
@@ -170,10 +174,11 @@ export class PullRequest extends NamedObject {
170
174
  }
171
175
  }
172
176
  });
177
+ }
173
178
 
174
- if (destination !== undefined) {
175
- destination._addPullRequest(this);
176
- }
179
+ get destination()
180
+ {
181
+ return this.owner;
177
182
  }
178
183
 
179
184
  /**
@@ -181,7 +186,7 @@ export class PullRequest extends NamedObject {
181
186
  * @return {string} PR full name
182
187
  */
183
188
  get fullName() {
184
- return `${this.destination.repository.fullName}/${this.name}`;
189
+ return `${this.repository.fullName}/${this.name}`;
185
190
  }
186
191
 
187
192
  /**
@@ -189,7 +194,7 @@ export class PullRequest extends NamedObject {
189
194
  * @return {string} url
190
195
  */
191
196
  get url() {
192
- return `${this.provider.url}${this.destination.repository.fullName}/pull/${this.name}`;
197
+ return `${this.provider.url}${this.repository.fullName}/pull/${this.name}`;
193
198
  }
194
199
 
195
200
  get number() {
@@ -204,18 +209,18 @@ export class PullRequest extends NamedObject {
204
209
  * @return {Repository} destination repository
205
210
  */
206
211
  get repository() {
207
- return this.destination === undefined
212
+ return this.owner === undefined
208
213
  ? undefined
209
- : this.destination.repository;
214
+ : this.owner.repository;
210
215
  }
211
216
 
212
217
  /**
213
218
  * @return {BaseProvider}
214
219
  */
215
220
  get provider() {
216
- return this.destination === undefined
221
+ return this.owner === undefined
217
222
  ? undefined
218
- : this.destination.provider;
223
+ : this.owner.provider;
219
224
  }
220
225
 
221
226
  /**
@@ -233,9 +238,9 @@ export class PullRequest extends NamedObject {
233
238
  * @return {Promise}
234
239
  */
235
240
  async delete() {
236
- return this.destination === undefined
241
+ return this.owner === undefined
237
242
  ? undefined
238
- : this.destination.deletePullRequest(this.number);
243
+ : this.owner.deletePullRequest(this.number);
239
244
  }
240
245
 
241
246
  /**
@@ -266,7 +271,7 @@ export class PullRequest extends NamedObject {
266
271
  return [
267
272
  [this.name, this.title],
268
273
  ["source", this.source.identifier],
269
- ["destination", this.destination.identifier],
274
+ ["destination", this.owner.identifier],
270
275
  ...Object.keys(this.constructor.attributes)
271
276
  .filter(
272
277
  k =>
@@ -281,7 +286,7 @@ export class PullRequest extends NamedObject {
281
286
  toJSON() {
282
287
  return optionJSON(this, {
283
288
  source: this.source,
284
- destination: this.destination,
289
+ destination: this.owner,
285
290
  name: this.name
286
291
  });
287
292
  }
@@ -291,6 +296,6 @@ export class PullRequest extends NamedObject {
291
296
  * @return {string}
292
297
  */
293
298
  get identifier() {
294
- return `${this.destination.identifier}[${this.name}]`;
299
+ return `${this.owner.identifier}[${this.name}]`;
295
300
  }
296
301
  }