@noldova/git.hosting.protocol 0.0.10 → 0.0.12

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.
Files changed (35) hide show
  1. package/package.json +3 -2
  2. package/src/api/index.d.ts +182 -0
  3. package/src/api/index.js +2 -0
  4. package/src/models/branch-pull-request.js +8 -7
  5. package/src/models/branch-query.js +2 -1
  6. package/src/models/field-check.js +7 -6
  7. package/src/models/host-account-entry.js +3 -2
  8. package/src/models/host-account.js +3 -2
  9. package/src/models/host-avatar.js +2 -1
  10. package/src/models/host-build.js +7 -6
  11. package/src/models/host-check.js +2 -1
  12. package/src/models/host-comment.js +2 -1
  13. package/src/models/host-commit-comments.js +3 -2
  14. package/src/models/host-item.js +4 -3
  15. package/src/models/host-person.js +5 -4
  16. package/src/models/host-policy.js +3 -2
  17. package/src/models/host-pull-request-file.js +3 -2
  18. package/src/models/host-pull-request-files.js +4 -3
  19. package/src/models/host-pull-request-head.js +2 -1
  20. package/src/models/host-pull-request-row.js +2 -1
  21. package/src/models/host-pull-request-update.js +2 -1
  22. package/src/models/host-pull-request.js +4 -3
  23. package/src/models/host-reference.js +3 -2
  24. package/src/models/host-repository-list.js +42 -0
  25. package/src/models/host-repository.js +41 -0
  26. package/src/models/host-review-request.js +3 -2
  27. package/src/models/host-sign-in.js +8 -7
  28. package/src/models/host-thread.js +4 -3
  29. package/src/models/host-work-item-detail.js +8 -7
  30. package/src/models/host-work-item-type.js +2 -1
  31. package/src/models/host-work-item.js +5 -4
  32. package/src/models/hosting-names.js +1 -0
  33. package/src/models/repository-account.js +3 -2
  34. package/src/models/work-item-update.js +2 -1
  35. package/src/resources.js +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noldova/git.hosting.protocol",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "The hosting protocol that each of Git's host modules implements: a reference to an issue or pull request, the item and its checks, a branch's pull request, a pull request draft, and the sign-in's account and device code.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,8 +30,9 @@
30
30
  "registry": "https://registry.npmjs.org/"
31
31
  },
32
32
  "peerDependencies": {
33
+ "@noldova/context.core": ">=0.0.18 <0.1.0",
33
34
  "@noldova/context.exceptions": ">=0.0.18 <0.1.0",
34
35
  "@noldova/context.json": ">=0.0.18 <0.1.0"
35
36
  },
36
- "gitHead": "eedb612e4e62dc05d714de998def800b222028a3"
37
+ "gitHead": "20d594ec9f183a11399993db53d2e6510e31e41f"
37
38
  }
@@ -876,6 +876,13 @@ export declare class HostingNames {
876
876
  */
877
877
  public static readonly readReviewRequestsMethod: string;
878
878
 
879
+ /**
880
+ * The method that takes an `AccountQuery` as JSON and answers the repositories that account can clone as `HostRepositoryList` JSON, the most
881
+ * recently pushed first where the host tells when; for an account that isn't signed in, `HostRepositoryList.signedOut()`, having asked the host
882
+ * nothing.
883
+ */
884
+ public static readonly readRepositoriesMethod: string;
885
+
879
886
  /**
880
887
  * The method that takes a `CommitQuery` as JSON and answers the review comments on that commit as `HostCommitComments` JSON: their count, whether
881
888
  * a page of the host's answer was full, and the page that shows them; `HostCommitComments.none()` when signed out, for another host, or when the host
@@ -5159,6 +5166,181 @@ export declare class HostReviewRequestList {
5159
5166
  public toJson(): JsonObject;
5160
5167
  }
5161
5168
 
5169
+ /**
5170
+ * A repository an account can clone: its name on the host, its https clone address, whether it is private, and when it was last pushed to.
5171
+ *
5172
+ * @example
5173
+ * ```ts
5174
+ * import type { HostRepository } from "@noldova/git.hosting.protocol";
5175
+ *
5176
+ * const describe = (repository: HostRepository): string => `${repository.name} at ${repository.url}`;
5177
+ * ```
5178
+ */
5179
+ export declare class HostRepository {
5180
+ /**
5181
+ * The repository's name as the host shows it, such as `octocat/hello-world` or `Fabrikam/Website`.
5182
+ */
5183
+ public readonly name: string;
5184
+
5185
+ /**
5186
+ * The repository's https clone address.
5187
+ */
5188
+ public readonly url: string;
5189
+
5190
+ /**
5191
+ * Whether only those the host lets in can see the repository.
5192
+ */
5193
+ public readonly isPrivate: boolean;
5194
+
5195
+ /**
5196
+ * When the repository was last pushed to, in milliseconds since 1970; null when the host doesn't tell.
5197
+ */
5198
+ public readonly pushedAt: number | null;
5199
+
5200
+ /**
5201
+ * Makes a repository from its parts.
5202
+ *
5203
+ * @param name The name, not empty.
5204
+ * @param url The https clone address.
5205
+ * @param isPrivate Whether it is private.
5206
+ * @param pushedAt When it was last pushed to, a positive number of milliseconds since 1970, or null.
5207
+ * @param reader The reader the values came from, so an error names the field by its path; omitted for values that didn't come from JSON.
5208
+ * @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `url`.
5209
+ * @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.url`.
5210
+ * @example
5211
+ * ```ts
5212
+ * import { HostRepository } from "@noldova/git.hosting.protocol";
5213
+ *
5214
+ * const repository = new HostRepository("octocat/hello-world", "https://github.com/octocat/hello-world.git", false, 1_700_000_000_000);
5215
+ * ```
5216
+ */
5217
+ public constructor(name: string, url: string, isPrivate: boolean, pushedAt: number | null, reader?: JsonReader);
5218
+
5219
+ /**
5220
+ * Reads a repository from its JSON.
5221
+ *
5222
+ * @param value The JSON, with exactly the fields `toJson` writes.
5223
+ * @param path The JSON's path, `$` by default.
5224
+ * @returns The repository.
5225
+ * @throws {JsonException} When the value isn't an object, or a field is missing or of the wrong type; it comes from `@noldova/context.json`.
5226
+ * @throws {HostingFieldException} When the value holds an unknown field, or a field is out of its range.
5227
+ * @example
5228
+ * ```ts
5229
+ * import { HostRepository } from "@noldova/git.hosting.protocol";
5230
+ *
5231
+ * const repository = HostRepository.fromJson({ name: "octocat/hello-world", url: "https://github.com/octocat/hello-world.git", isPrivate: false,
5232
+ * pushedAt: null });
5233
+ * ```
5234
+ */
5235
+ public static fromJson(value: unknown, path?: string): HostRepository;
5236
+
5237
+ /**
5238
+ * Writes the repository as JSON: `name`, `url`, `isPrivate` and `pushedAt`.
5239
+ *
5240
+ * @returns The JSON.
5241
+ * @example
5242
+ * ```ts
5243
+ * import { HostRepository } from "@noldova/git.hosting.protocol";
5244
+ *
5245
+ * console.log(new HostRepository("octocat/hello-world", "https://github.com/octocat/hello-world.git", false, null).toJson());
5246
+ * ```
5247
+ */
5248
+ public toJson(): JsonObject;
5249
+ }
5250
+
5251
+ /**
5252
+ * The repositories an account can clone, at most 300, with whether the host has more past them and whether the account was signed in.
5253
+ *
5254
+ * @example
5255
+ * ```ts
5256
+ * import type { HostRepositoryList } from "@noldova/git.hosting.protocol";
5257
+ *
5258
+ * const names = (list: HostRepositoryList): string[] => list.rows.map(t => t.name);
5259
+ * ```
5260
+ */
5261
+ export declare class HostRepositoryList {
5262
+ /**
5263
+ * The most rows a list holds: 300.
5264
+ */
5265
+ public static readonly maximumRows: number;
5266
+
5267
+ /**
5268
+ * The repositories, the most recently pushed first where the host tells when; none while signed out.
5269
+ */
5270
+ public readonly rows: readonly HostRepository[];
5271
+
5272
+ /**
5273
+ * Whether the host has more repositories past these rows.
5274
+ */
5275
+ public readonly hasMore: boolean;
5276
+
5277
+ /**
5278
+ * Whether the account was signed in to read them.
5279
+ */
5280
+ public readonly isSignedIn: boolean;
5281
+
5282
+ /**
5283
+ * Makes a list from its parts.
5284
+ *
5285
+ * @param rows The rows, at most 300, and none while signed out.
5286
+ * @param hasMore Whether the host has more, only while signed in.
5287
+ * @param isSignedIn Whether the account was signed in; true by default.
5288
+ * @param reader The reader the values came from, so an error names the field by its path; omitted for values that didn't come from JSON.
5289
+ * @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `rows`.
5290
+ * @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.rows`.
5291
+ * @example
5292
+ * ```ts
5293
+ * import { HostRepositoryList } from "@noldova/git.hosting.protocol";
5294
+ *
5295
+ * const empty = new HostRepositoryList([], false);
5296
+ * ```
5297
+ */
5298
+ public constructor(rows: readonly HostRepository[], hasMore: boolean, isSignedIn?: boolean, reader?: JsonReader);
5299
+
5300
+ /**
5301
+ * The list a host answers for an account that isn't signed in: no rows, and not signed in.
5302
+ *
5303
+ * @returns The list.
5304
+ * @example
5305
+ * ```ts
5306
+ * import { HostRepositoryList } from "@noldova/git.hosting.protocol";
5307
+ *
5308
+ * const answer = HostRepositoryList.signedOut().toJson();
5309
+ * ```
5310
+ */
5311
+ public static signedOut(): HostRepositoryList;
5312
+
5313
+ /**
5314
+ * Reads a list from its JSON.
5315
+ *
5316
+ * @param value The JSON, with exactly the fields `toJson` writes.
5317
+ * @param path The JSON's path, `$` by default.
5318
+ * @returns The list.
5319
+ * @throws {JsonException} When the value isn't an object, or a field is missing or of the wrong type; it comes from `@noldova/context.json`.
5320
+ * @throws {HostingFieldException} When the value holds an unknown field, or a field is out of its range.
5321
+ * @example
5322
+ * ```ts
5323
+ * import { HostRepositoryList } from "@noldova/git.hosting.protocol";
5324
+ *
5325
+ * const list = HostRepositoryList.fromJson({ rows: [], hasMore: false, isSignedIn: false });
5326
+ * ```
5327
+ */
5328
+ public static fromJson(value: unknown, path?: string): HostRepositoryList;
5329
+
5330
+ /**
5331
+ * Writes the list as JSON: `rows`, `hasMore` and `isSignedIn`.
5332
+ *
5333
+ * @returns The JSON.
5334
+ * @example
5335
+ * ```ts
5336
+ * import { HostRepositoryList } from "@noldova/git.hosting.protocol";
5337
+ *
5338
+ * console.log(HostRepositoryList.signedOut().toJson());
5339
+ * ```
5340
+ */
5341
+ public toJson(): JsonObject;
5342
+ }
5343
+
5162
5344
  /**
5163
5345
  * One of the accounts a module keeps, by its id, for a sign-in method that acts on one account.
5164
5346
  *
package/src/api/index.js CHANGED
@@ -56,6 +56,8 @@ export { HostPullRequestThreads } from "../models/host-pull-request-threads.js";
56
56
  export { HostPullRequestUpdate } from "../models/host-pull-request-update.js";
57
57
  export { HostPullRequestUpdates } from "../models/host-pull-request-updates.js";
58
58
  export { HostReference } from "../models/host-reference.js";
59
+ export { HostRepository } from "../models/host-repository.js";
60
+ export { HostRepositoryList } from "../models/host-repository-list.js";
59
61
  export { HostReviewRequest } from "../models/host-review-request.js";
60
62
  export { HostReviewRequestList } from "../models/host-review-request-list.js";
61
63
  export { HostReviewer } from "../models/host-reviewer.js";
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { CheckState } from "../enums/check-state.js";
10
11
  import { ReferenceKind } from "../enums/reference-kind.js";
@@ -22,16 +23,16 @@ export class BranchPullRequest {
22
23
  checks;
23
24
  reviewDecision;
24
25
  approvals;
25
- constructor(pullRequest, checks, reviewDecision = pullRequest === null ? null : ReviewDecision.Waiting, approvals = null, reader) {
26
- if (pullRequest !== null && pullRequest.kind !== ReferenceKind.PullRequest)
26
+ constructor(pullRequest, checks, reviewDecision = Object.isNull(pullRequest) ? null : ReviewDecision.Waiting, approvals = null, reader) {
27
+ if (!Object.isNull(pullRequest) && pullRequest.kind !== ReferenceKind.PullRequest)
27
28
  FieldCheck.fail(Resources.pullRequestField, Resources.pullRequestExpected, reader);
28
- if (pullRequest === null && checks.length > 0)
29
+ if (Object.isNull(pullRequest) && checks.length > 0)
29
30
  FieldCheck.fail(Resources.checksField, Resources.checksExpected, reader);
30
- if ((pullRequest === null) !== (reviewDecision === null))
31
+ if ((Object.isNull(pullRequest)) !== (Object.isNull(reviewDecision)))
31
32
  FieldCheck.fail(Resources.reviewDecisionField, Resources.reviewDecisionExpected, reader);
32
- if (pullRequest === null && approvals !== null)
33
+ if (Object.isNull(pullRequest) && !Object.isNull(approvals))
33
34
  FieldCheck.fail(Resources.approvalsField, Resources.approvalsExpected, reader);
34
- if (approvals !== null)
35
+ if (!Object.isNull(approvals))
35
36
  FieldCheck.requireCount(approvals, Resources.approvalsField, reader);
36
37
  this.pullRequest = pullRequest;
37
38
  this.checks = [...checks];
@@ -46,7 +47,7 @@ export class BranchPullRequest {
46
47
  FieldCheck.refuseUnknownFields(reader, BranchPullRequest.FIELDS);
47
48
  const pullRequest = FieldCheck.readNullableModel(reader, Resources.pullRequestField, HostItem.fromJson);
48
49
  return new BranchPullRequest(pullRequest, reader.readObjectArray(Resources.checksField).map(t => HostCheck.fromJson(t.toJson(), t.path)), reader.hasField(Resources.reviewDecisionField) ? FieldCheck.readNullableMember(reader, Resources.reviewDecisionField, BranchPullRequest.DECISIONS)
49
- : pullRequest === null ? null : ReviewDecision.Waiting, reader.hasField(Resources.approvalsField) ? reader.readNullableInteger(Resources.approvalsField) : null, reader);
50
+ : Object.isNull(pullRequest) ? null : ReviewDecision.Waiting, reader.hasField(Resources.approvalsField) ? reader.readNullableInteger(Resources.approvalsField) : null, reader);
50
51
  }
51
52
  toJson() {
52
53
  return {
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -18,7 +19,7 @@ export class BranchQuery {
18
19
  FieldCheck.requireText(host, Resources.hostField, reader);
19
20
  FieldCheck.requirePath(path, Resources.pathField, reader);
20
21
  FieldCheck.requireText(branch, Resources.branchField, reader);
21
- if (headCommit !== null)
22
+ if (!Object.isNull(headCommit))
22
23
  FieldCheck.requireCommit(headCommit, Resources.headCommitField, reader);
23
24
  this.host = host;
24
25
  this.path = path;
@@ -5,12 +5,13 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { HostingArgumentException } from "../exceptions/hosting-argument.exception.js";
9
10
  import { HostingFieldException } from "../exceptions/hosting-field.exception.js";
10
11
  import { Resources } from "../resources.js";
11
12
  export class FieldCheck {
12
13
  static fail(field, expectation, reader) {
13
- if (reader === undefined)
14
+ if (Object.isUndefined(reader))
14
15
  throw new HostingArgumentException(field, expectation);
15
16
  throw new HostingFieldException(Resources.formatFieldPath(reader.path, field), expectation);
16
17
  }
@@ -21,14 +22,14 @@ export class FieldCheck {
21
22
  }
22
23
  static readNullableModel(reader, field, fromJson) {
23
24
  const child = reader.readNullableObject(field);
24
- return child === null ? null : fromJson(child.toJson(), child.path);
25
+ return Object.isNull(child) ? null : fromJson(child.toJson(), child.path);
25
26
  }
26
27
  static readNullableMember(reader, field, members) {
27
- return reader.readValue(field) === null ? null : reader.readOneOf(field, members);
28
+ return Object.isNull(reader.readValue(field)) ? null : reader.readOneOf(field, members);
28
29
  }
29
30
  static requireMember(value, members, field, reader) {
30
31
  const member = members.find(t => t === value);
31
- if (member === undefined)
32
+ if (Object.isUndefined(member))
32
33
  FieldCheck.fail(field, Resources.formatMemberExpected(members), reader);
33
34
  return member;
34
35
  }
@@ -58,7 +59,7 @@ export class FieldCheck {
58
59
  }
59
60
  static requireAvatar(value, field, reader) {
60
61
  const payload = Resources.avatarPattern.exec(value)?.[1];
61
- if (payload === undefined || payload.length === 0 || payload.length > Resources.maximumAvatarLength)
62
+ if (Object.isUndefined(payload) || payload.length === 0 || payload.length > Resources.maximumAvatarLength)
62
63
  FieldCheck.fail(field, Resources.avatarExpected, reader);
63
64
  }
64
65
  static requirePlace(value, field, reader) {
@@ -67,7 +68,7 @@ export class FieldCheck {
67
68
  }
68
69
  static requireHttps(value, field, reader) {
69
70
  const url = URL.parse(value);
70
- if (url === null || url.protocol !== Resources.httpsProtocol || url.username.length > 0 || url.password.length > 0)
71
+ if (Object.isNull(url) || url.protocol !== Resources.httpsProtocol || url.username.length > 0 || url.password.length > 0)
71
72
  FieldCheck.fail(field, Resources.httpsAddressExpected, reader);
72
73
  }
73
74
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -16,7 +17,7 @@ export class HostAccountEntry {
16
17
  place;
17
18
  constructor(id, signIn, place = null, reader) {
18
19
  FieldCheck.requirePositive(id, Resources.idField, reader);
19
- if (place !== null)
20
+ if (!Object.isNull(place))
20
21
  FieldCheck.requirePlace(place, Resources.placeField, reader);
21
22
  this.id = id;
22
23
  this.signIn = signIn;
@@ -31,7 +32,7 @@ export class HostAccountEntry {
31
32
  toJson() {
32
33
  return {
33
34
  [Resources.idField]: this.id, [Resources.signInField]: this.signIn.toJson(),
34
- ...(this.place === null ? {} : { [Resources.placeField]: this.place })
35
+ ...(Object.isNull(this.place) ? {} : { [Resources.placeField]: this.place })
35
36
  };
36
37
  }
37
38
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -16,9 +17,9 @@ export class HostAccount {
16
17
  scopes;
17
18
  constructor(login, name, avatar, scopes, reader) {
18
19
  FieldCheck.requireText(login, Resources.loginField, reader);
19
- if (name !== null)
20
+ if (!Object.isNull(name))
20
21
  FieldCheck.requireText(name, Resources.nameField, reader);
21
- if (avatar !== null)
22
+ if (!Object.isNull(avatar))
22
23
  FieldCheck.requireAvatar(avatar, Resources.avatarField, reader);
23
24
  for (const scope of scopes)
24
25
  FieldCheck.requireText(scope, Resources.scopesField, reader);
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -12,7 +13,7 @@ export class HostAvatar {
12
13
  static FIELDS = [Resources.avatarField];
13
14
  avatar;
14
15
  constructor(avatar, reader) {
15
- if (avatar !== null)
16
+ if (!Object.isNull(avatar))
16
17
  FieldCheck.requireAvatar(avatar, Resources.avatarField, reader);
17
18
  this.avatar = avatar;
18
19
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { CheckState } from "../enums/check-state.js";
10
11
  import { Resources } from "../resources.js";
@@ -22,17 +23,17 @@ export class HostBuild {
22
23
  number;
23
24
  constructor(name, state, url, startedAt, finishedAt, number = null, reader) {
24
25
  FieldCheck.requireText(name, Resources.nameField, reader);
25
- if (number !== null)
26
+ if (!Object.isNull(number))
26
27
  FieldCheck.requireText(number, Resources.numberField, reader);
27
- if (url !== null)
28
+ if (!Object.isNull(url))
28
29
  FieldCheck.requireHttps(url, Resources.urlField, reader);
29
- if (startedAt !== null)
30
+ if (!Object.isNull(startedAt))
30
31
  FieldCheck.requirePositive(startedAt, Resources.startedAtField, reader);
31
- if (HostBuild.FINISHED.includes(state) !== (finishedAt !== null))
32
+ if (HostBuild.FINISHED.includes(state) !== (!Object.isNull(finishedAt)))
32
33
  FieldCheck.fail(Resources.finishedAtField, Resources.finishedAtExpected, reader);
33
- if (finishedAt !== null) {
34
+ if (!Object.isNull(finishedAt)) {
34
35
  FieldCheck.requirePositive(finishedAt, Resources.finishedAtField, reader);
35
- if (startedAt !== null && finishedAt < startedAt)
36
+ if (!Object.isNull(startedAt) && finishedAt < startedAt)
36
37
  FieldCheck.fail(Resources.finishedAtField, Resources.finishedAtExpected, reader);
37
38
  }
38
39
  this.name = name;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { CheckState } from "../enums/check-state.js";
10
11
  import { Resources } from "../resources.js";
@@ -17,7 +18,7 @@ export class HostCheck {
17
18
  url;
18
19
  constructor(name, state, url, reader) {
19
20
  FieldCheck.requireText(name, Resources.nameField, reader);
20
- if (url !== null)
21
+ if (!Object.isNull(url))
21
22
  FieldCheck.requireHttps(url, Resources.urlField, reader);
22
23
  this.name = name;
23
24
  this.state = state;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -19,7 +20,7 @@ export class HostComment {
19
20
  body;
20
21
  constructor(id, parent, author, publishedAt, body, reader) {
21
22
  FieldCheck.requirePositive(id, Resources.idField, reader);
22
- if (parent !== null) {
23
+ if (!Object.isNull(parent)) {
23
24
  FieldCheck.requirePositive(parent, Resources.parentField, reader);
24
25
  if (parent === id)
25
26
  FieldCheck.fail(Resources.parentField, Resources.commentParentExpected, reader);
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -20,9 +21,9 @@ export class HostCommitComments {
20
21
  FieldCheck.fail(Resources.countField, Resources.commitCommentsExpected, reader);
21
22
  if (isCapped && count === 0)
22
23
  FieldCheck.fail(Resources.isCappedField, Resources.commitCommentsCappedExpected, reader);
23
- if ((count === 0) !== (url === null))
24
+ if ((count === 0) !== (Object.isNull(url)))
24
25
  FieldCheck.fail(Resources.urlField, Resources.commitCommentsUrlExpected, reader);
25
- if (url !== null)
26
+ if (!Object.isNull(url))
26
27
  FieldCheck.requireHttps(url, Resources.urlField, reader);
27
28
  this.count = count;
28
29
  this.isCapped = isCapped;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { ReferenceKind } from "../enums/reference-kind.js";
10
11
  import { ReferenceState } from "../enums/reference-state.js";
@@ -39,12 +40,12 @@ export class HostItem {
39
40
  FieldCheck.requireText(title, Resources.titleField, reader);
40
41
  FieldCheck.requireHttps(url, Resources.urlField, reader);
41
42
  FieldCheck.requirePositive(createdAt, Resources.createdAtField, reader);
42
- if (HostItem.OPEN_STATES.includes(state) !== (closedAt === null))
43
+ if (HostItem.OPEN_STATES.includes(state) !== (Object.isNull(closedAt)))
43
44
  FieldCheck.fail(Resources.closedAtField, Resources.closedAtExpected, reader);
44
- if (closedAt !== null)
45
+ if (!Object.isNull(closedAt))
45
46
  FieldCheck.requirePositive(closedAt, Resources.closedAtField, reader);
46
47
  FieldCheck.requireCount(comments, Resources.commentsField, reader);
47
- if (isPullRequest !== (changes !== null))
48
+ if (isPullRequest !== (!Object.isNull(changes)))
48
49
  FieldCheck.fail(Resources.changesField, Resources.changesExpected, reader);
49
50
  this.reference = reference;
50
51
  this.kind = kind;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -16,11 +17,11 @@ export class HostPerson {
16
17
  name;
17
18
  constructor(login, avatar, url, reader, name = null) {
18
19
  FieldCheck.requireText(login, Resources.loginField, reader);
19
- if (avatar !== null)
20
+ if (!Object.isNull(avatar))
20
21
  FieldCheck.requireAvatar(avatar, Resources.avatarField, reader);
21
- if (url !== null)
22
+ if (!Object.isNull(url))
22
23
  FieldCheck.requireHttps(url, Resources.urlField, reader);
23
- if (name !== null)
24
+ if (!Object.isNull(name))
24
25
  FieldCheck.requireText(name, Resources.nameField, reader);
25
26
  this.login = login;
26
27
  this.avatar = avatar;
@@ -34,6 +35,6 @@ export class HostPerson {
34
35
  }
35
36
  toJson() {
36
37
  const person = { [Resources.loginField]: this.login, [Resources.avatarField]: this.avatar, [Resources.urlField]: this.url };
37
- return this.name === null ? person : { ...person, [Resources.nameField]: this.name };
38
+ return Object.isNull(this.name) ? person : { ...person, [Resources.nameField]: this.name };
38
39
  }
39
40
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { PolicyState } from "../enums/policy-state.js";
10
11
  import { Resources } from "../resources.js";
@@ -19,9 +20,9 @@ export class HostPolicy {
19
20
  buildNumber;
20
21
  constructor(name, state, isBlocking, url, buildNumber = null, reader) {
21
22
  FieldCheck.requireText(name, Resources.nameField, reader);
22
- if (url !== null)
23
+ if (!Object.isNull(url))
23
24
  FieldCheck.requireHttps(url, Resources.urlField, reader);
24
- if (buildNumber !== null)
25
+ if (!Object.isNull(buildNumber))
25
26
  FieldCheck.requireText(buildNumber, Resources.buildNumberField, reader);
26
27
  this.name = name;
27
28
  this.state = state;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { FileChangeKind } from "../enums/file-change-kind.js";
10
11
  import { Resources } from "../resources.js";
@@ -17,9 +18,9 @@ export class HostPullRequestFile {
17
18
  previousPath;
18
19
  constructor(path, kind, previousPath, reader) {
19
20
  FieldCheck.requireText(path, Resources.pathField, reader);
20
- if (previousPath !== null)
21
+ if (!Object.isNull(previousPath))
21
22
  FieldCheck.requireText(previousPath, Resources.previousPathField, reader);
22
- if ((previousPath !== null) !== (kind === FileChangeKind.Renamed))
23
+ if ((!Object.isNull(previousPath)) !== (kind === FileChangeKind.Renamed))
23
24
  FieldCheck.fail(Resources.previousPathField, Resources.previousPathExpected, reader);
24
25
  this.path = path;
25
26
  this.kind = kind;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -17,11 +18,11 @@ export class HostPullRequestFiles {
17
18
  files;
18
19
  hasMore;
19
20
  constructor(sourceCommit, commonCommit, files, hasMore, reader) {
20
- if (sourceCommit !== null)
21
+ if (!Object.isNull(sourceCommit))
21
22
  FieldCheck.requireCommit(sourceCommit, Resources.sourceCommitField, reader);
22
- if (commonCommit !== null)
23
+ if (!Object.isNull(commonCommit))
23
24
  FieldCheck.requireCommit(commonCommit, Resources.commonCommitField, reader);
24
- if (sourceCommit === null && (commonCommit !== null || files.length > 0 || hasMore))
25
+ if (Object.isNull(sourceCommit) && (!Object.isNull(commonCommit) || files.length > 0 || hasMore))
25
26
  FieldCheck.fail(Resources.sourceCommitField, Resources.pullRequestFilesCommitExpected, reader);
26
27
  if (files.length > Resources.maximumPullRequestFiles)
27
28
  FieldCheck.fail(Resources.filesField, Resources.pullRequestFilesExpected, reader);
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -21,7 +22,7 @@ export class HostPullRequestHead {
21
22
  FieldCheck.requireText(title, Resources.titleField, reader);
22
23
  FieldCheck.requireHttps(url, Resources.urlField, reader);
23
24
  FieldCheck.requireText(headBranch, Resources.headBranchField, reader);
24
- if (baseBranch !== null)
25
+ if (!Object.isNull(baseBranch))
25
26
  FieldCheck.requireText(baseBranch, Resources.baseBranchField, reader);
26
27
  this.reference = reference;
27
28
  this.title = title;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { CheckState } from "../enums/check-state.js";
10
11
  import { PullRequestStatus } from "../enums/pull-request-status.js";
@@ -32,7 +33,7 @@ export class HostPullRequestRow {
32
33
  FieldCheck.requireCount(failing, Resources.failingField, reader);
33
34
  FieldCheck.requireCount(pending, Resources.pendingField, reader);
34
35
  FieldCheck.requireText(headBranch, Resources.headBranchField, reader);
35
- if (baseBranch !== null)
36
+ if (!Object.isNull(baseBranch))
36
37
  FieldCheck.requireText(baseBranch, Resources.baseBranchField, reader);
37
38
  this.reference = reference;
38
39
  this.title = title;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -21,7 +22,7 @@ export class HostPullRequestUpdate {
21
22
  FieldCheck.requirePositive(number, Resources.numberField, reader);
22
23
  FieldCheck.requirePositive(createdAt, Resources.createdAtField, reader);
23
24
  FieldCheck.requireCommit(sourceCommit, Resources.sourceCommitField, reader);
24
- if (commonCommit !== null)
25
+ if (!Object.isNull(commonCommit))
25
26
  FieldCheck.requireCommit(commonCommit, Resources.commonCommitField, reader);
26
27
  this.number = number;
27
28
  this.author = author;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { ReferenceKind } from "../enums/reference-kind.js";
10
11
  import { Resources } from "../resources.js";
@@ -31,9 +32,9 @@ export class HostPullRequest {
31
32
  constructor(item, reviewers, policies, builds, isAutoComplete, description, commitCount, workItems, autoCompleteMergeType = null, hasConflicts = null, reader) {
32
33
  if (item.kind !== ReferenceKind.PullRequest)
33
34
  FieldCheck.fail(Resources.itemField, Resources.pullRequestExpected, reader);
34
- if (commitCount !== null)
35
+ if (!Object.isNull(commitCount))
35
36
  FieldCheck.requireCount(commitCount, Resources.commitCountField, reader);
36
- if (autoCompleteMergeType !== null)
37
+ if (!Object.isNull(autoCompleteMergeType))
37
38
  FieldCheck.requireText(autoCompleteMergeType, Resources.autoCompleteMergeTypeField, reader);
38
39
  this.item = item;
39
40
  this.reviewers = [...reviewers];
@@ -50,7 +51,7 @@ export class HostPullRequest {
50
51
  const reader = JsonReader.fromValue(value, path);
51
52
  FieldCheck.refuseUnknownFields(reader, HostPullRequest.FIELDS);
52
53
  const item = reader.readObject(Resources.itemField);
53
- return new HostPullRequest(HostItem.fromJson(item.toJson(), item.path), reader.readObjectArray(Resources.reviewersField).map(t => HostReviewer.fromJson(t.toJson(), t.path)), reader.readObjectArray(Resources.policiesField).map(t => HostPolicy.fromJson(t.toJson(), t.path)), reader.readObjectArray(Resources.buildsField).map(t => HostBuild.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.isAutoCompleteField), reader.readString(Resources.descriptionField), reader.readNullableInteger(Resources.commitCountField), reader.readObjectArray(Resources.workItemsField).map(t => HostWorkItemLink.fromJson(t.toJson(), t.path)), reader.readNullableString(Resources.autoCompleteMergeTypeField), reader.readValue(Resources.hasConflictsField) === null ? null : reader.readBoolean(Resources.hasConflictsField), reader);
54
+ return new HostPullRequest(HostItem.fromJson(item.toJson(), item.path), reader.readObjectArray(Resources.reviewersField).map(t => HostReviewer.fromJson(t.toJson(), t.path)), reader.readObjectArray(Resources.policiesField).map(t => HostPolicy.fromJson(t.toJson(), t.path)), reader.readObjectArray(Resources.buildsField).map(t => HostBuild.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.isAutoCompleteField), reader.readString(Resources.descriptionField), reader.readNullableInteger(Resources.commitCountField), reader.readObjectArray(Resources.workItemsField).map(t => HostWorkItemLink.fromJson(t.toJson(), t.path)), reader.readNullableString(Resources.autoCompleteMergeTypeField), Object.isNull(reader.readValue(Resources.hasConflictsField)) ? null : reader.readBoolean(Resources.hasConflictsField), reader);
54
55
  }
55
56
  toJson() {
56
57
  return {
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -20,7 +21,7 @@ export class HostReference {
20
21
  FieldCheck.requirePath(owner, Resources.ownerField, reader);
21
22
  FieldCheck.requireName(repository, Resources.repositoryField, reader);
22
23
  FieldCheck.requirePositive(number, Resources.numberField, reader);
23
- if (place !== null)
24
+ if (!Object.isNull(place))
24
25
  FieldCheck.requirePlace(place, Resources.placeField, reader);
25
26
  this.host = host;
26
27
  this.owner = owner;
@@ -42,7 +43,7 @@ export class HostReference {
42
43
  [Resources.ownerField]: this.owner,
43
44
  [Resources.repositoryField]: this.repository,
44
45
  [Resources.numberField]: this.number,
45
- ...(this.place === null ? {} : { [Resources.placeField]: this.place })
46
+ ...(Object.isNull(this.place) ? {} : { [Resources.placeField]: this.place })
46
47
  };
47
48
  }
48
49
  }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { JsonReader } from "@noldova/context.json";
9
+ import { Resources } from "../resources.js";
10
+ import { FieldCheck } from "./field-check.js";
11
+ import { HostRepository } from "./host-repository.js";
12
+ export class HostRepositoryList {
13
+ static maximumRows = Resources.maximumRepositoryRows;
14
+ static FIELDS = [Resources.rowsField, Resources.hasMoreField, Resources.isSignedInField];
15
+ rows;
16
+ hasMore;
17
+ isSignedIn;
18
+ constructor(rows, hasMore, isSignedIn = true, reader) {
19
+ if (rows.length > Resources.maximumRepositoryRows || (!isSignedIn && rows.length > 0))
20
+ FieldCheck.fail(Resources.rowsField, Resources.repositoryRowsExpected, reader);
21
+ if (hasMore && !isSignedIn)
22
+ FieldCheck.fail(Resources.hasMoreField, Resources.repositoriesMoreExpected, reader);
23
+ this.rows = [...rows];
24
+ this.hasMore = hasMore;
25
+ this.isSignedIn = isSignedIn;
26
+ }
27
+ static signedOut() {
28
+ return new HostRepositoryList([], false, false);
29
+ }
30
+ static fromJson(value, path) {
31
+ const reader = JsonReader.fromValue(value, path);
32
+ FieldCheck.refuseUnknownFields(reader, HostRepositoryList.FIELDS);
33
+ return new HostRepositoryList(reader.readObjectArray(Resources.rowsField).map(t => HostRepository.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.hasMoreField), reader.readBoolean(Resources.isSignedInField), reader);
34
+ }
35
+ toJson() {
36
+ return {
37
+ [Resources.rowsField]: this.rows.map(t => t.toJson()),
38
+ [Resources.hasMoreField]: this.hasMore,
39
+ [Resources.isSignedInField]: this.isSignedIn
40
+ };
41
+ }
42
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { JsonReader } from "@noldova/context.json";
10
+ import { Resources } from "../resources.js";
11
+ import { FieldCheck } from "./field-check.js";
12
+ export class HostRepository {
13
+ static FIELDS = [Resources.nameField, Resources.urlField, Resources.isPrivateField, Resources.pushedAtField];
14
+ name;
15
+ url;
16
+ isPrivate;
17
+ pushedAt;
18
+ constructor(name, url, isPrivate, pushedAt, reader) {
19
+ FieldCheck.requireText(name, Resources.nameField, reader);
20
+ FieldCheck.requireHttps(url, Resources.urlField, reader);
21
+ if (!Object.isNull(pushedAt))
22
+ FieldCheck.requirePositive(pushedAt, Resources.pushedAtField, reader);
23
+ this.name = name;
24
+ this.url = url;
25
+ this.isPrivate = isPrivate;
26
+ this.pushedAt = pushedAt;
27
+ }
28
+ static fromJson(value, path) {
29
+ const reader = JsonReader.fromValue(value, path);
30
+ FieldCheck.refuseUnknownFields(reader, HostRepository.FIELDS);
31
+ return new HostRepository(reader.readString(Resources.nameField), reader.readString(Resources.urlField), reader.readBoolean(Resources.isPrivateField), reader.readNullableInteger(Resources.pushedAtField), reader);
32
+ }
33
+ toJson() {
34
+ return {
35
+ [Resources.nameField]: this.name,
36
+ [Resources.urlField]: this.url,
37
+ [Resources.isPrivateField]: this.isPrivate,
38
+ [Resources.pushedAtField]: this.pushedAt
39
+ };
40
+ }
41
+ }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -22,7 +23,7 @@ export class HostReviewRequest {
22
23
  FieldCheck.requireText(title, Resources.titleField, reader);
23
24
  FieldCheck.requireHttps(url, Resources.urlField, reader);
24
25
  FieldCheck.requirePositive(createdAt, Resources.createdAtField, reader);
25
- if (account !== null)
26
+ if (!Object.isNull(account))
26
27
  FieldCheck.requireText(account, Resources.accountField, reader);
27
28
  this.reference = reference;
28
29
  this.title = title;
@@ -44,7 +45,7 @@ export class HostReviewRequest {
44
45
  [Resources.urlField]: this.url,
45
46
  [Resources.isDraftField]: this.isDraft,
46
47
  [Resources.createdAtField]: this.createdAt,
47
- ...(this.account === null ? {} : { [Resources.accountField]: this.account })
48
+ ...(Object.isNull(this.account) ? {} : { [Resources.accountField]: this.account })
48
49
  };
49
50
  }
50
51
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { SignInFailure } from "../enums/sign-in-failure.js";
10
11
  import { SignInState } from "../enums/sign-in-state.js";
@@ -23,15 +24,15 @@ export class HostSignIn {
23
24
  account;
24
25
  failure;
25
26
  constructor(state, deviceCode, account, failure, reader, address = null) {
26
- if ((state === SignInState.Waiting) !== (deviceCode !== null || address !== null))
27
- FieldCheck.fail(deviceCode === null && address !== null ? Resources.addressField : Resources.deviceCodeField, Resources.deviceCodeExpected, reader);
28
- if (deviceCode !== null && address !== null)
27
+ if ((state === SignInState.Waiting) !== (!Object.isNull(deviceCode) || !Object.isNull(address)))
28
+ FieldCheck.fail(Object.isNull(deviceCode) && !Object.isNull(address) ? Resources.addressField : Resources.deviceCodeField, Resources.deviceCodeExpected, reader);
29
+ if (!Object.isNull(deviceCode) && !Object.isNull(address))
29
30
  FieldCheck.fail(Resources.addressField, Resources.deviceCodeExpected, reader);
30
- if (address !== null)
31
+ if (!Object.isNull(address))
31
32
  FieldCheck.requireHttps(address, Resources.addressField, reader);
32
- if ((state === SignInState.SignedIn) !== (account !== null))
33
+ if ((state === SignInState.SignedIn) !== (!Object.isNull(account)))
33
34
  FieldCheck.fail(Resources.accountField, Resources.accountExpected, reader);
34
- if (state !== SignInState.SignedOut && failure !== null)
35
+ if (state !== SignInState.SignedOut && !Object.isNull(failure))
35
36
  FieldCheck.fail(Resources.failureField, Resources.failureExpected, reader);
36
37
  this.state = state;
37
38
  this.deviceCode = deviceCode;
@@ -62,7 +63,7 @@ export class HostSignIn {
62
63
  [Resources.deviceCodeField]: this.deviceCode?.toJson() ?? null,
63
64
  [Resources.accountField]: this.account?.toJson() ?? null,
64
65
  [Resources.failureField]: this.failure,
65
- ...this.address === null ? {} : { [Resources.addressField]: this.address }
66
+ ...Object.isNull(this.address) ? {} : { [Resources.addressField]: this.address }
66
67
  };
67
68
  }
68
69
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { ThreadStatus } from "../enums/thread-status.js";
10
11
  import { Resources } from "../resources.js";
@@ -21,10 +22,10 @@ export class HostThread {
21
22
  comments;
22
23
  constructor(id, state, path, line, comments, reader) {
23
24
  FieldCheck.requirePositive(id, Resources.idField, reader);
24
- if (path !== null)
25
+ if (!Object.isNull(path))
25
26
  FieldCheck.requireText(path, Resources.pathField, reader);
26
- if (line !== null) {
27
- if (path === null)
27
+ if (!Object.isNull(line)) {
28
+ if (Object.isNull(path))
28
29
  FieldCheck.fail(Resources.lineField, Resources.lineExpected, reader);
29
30
  FieldCheck.requirePositive(line, Resources.lineField, reader);
30
31
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -30,9 +31,9 @@ export class HostWorkItemDetail {
30
31
  HostWorkItemDetail.requireAmount(points, Resources.pointsField, reader);
31
32
  HostWorkItemDetail.requireAmount(remaining, Resources.remainingField, reader);
32
33
  HostWorkItemDetail.requireAmount(completed, Resources.completedField, reader);
33
- if (order !== null && !Number.isFinite(order))
34
+ if (!Object.isNull(order) && !Number.isFinite(order))
34
35
  FieldCheck.fail(Resources.orderField, Resources.finiteExpected, reader);
35
- if (acceptance !== null)
36
+ if (!Object.isNull(acceptance))
36
37
  FieldCheck.requireText(acceptance, Resources.acceptanceField, reader);
37
38
  for (const child of children)
38
39
  FieldCheck.requirePositive(child, Resources.childrenField, reader);
@@ -41,7 +42,7 @@ export class HostWorkItemDetail {
41
42
  FieldCheck.requireCount(commits, Resources.commitsField, reader);
42
43
  for (const branch of branches)
43
44
  FieldCheck.requireText(branch, Resources.branchesField, reader);
44
- if (account !== null)
45
+ if (!Object.isNull(account))
45
46
  FieldCheck.requireText(account, Resources.accountField, reader);
46
47
  this.item = item;
47
48
  this.points = points;
@@ -60,7 +61,7 @@ export class HostWorkItemDetail {
60
61
  const reader = JsonReader.fromValue(value, path);
61
62
  FieldCheck.refuseUnknownFields(reader, HostWorkItemDetail.FIELDS);
62
63
  const item = reader.readObject(Resources.itemField);
63
- return new HostWorkItemDetail(HostWorkItem.fromJson(item.toJson(), item.path), HostWorkItemDetail.readAmount(reader, Resources.pointsField), HostWorkItemDetail.readAmount(reader, Resources.remainingField), HostWorkItemDetail.readAmount(reader, Resources.completedField), HostWorkItemDetail.readAmount(reader, Resources.orderField), reader.readNullableString(Resources.acceptanceField), reader.readNumberArray(Resources.childrenField), reader.readObjectArray(Resources.pullRequestsField).map(t => HostReference.fromJson(t.toJson(), t.path)), reader.readInteger(Resources.commitsField), reader.readStringArray(Resources.branchesField), reader.readValue(Resources.isWaitingField) === null ? null : reader.readBoolean(Resources.isWaitingField), reader.hasField(Resources.accountField) ? reader.readNullableString(Resources.accountField) : null, reader);
64
+ return new HostWorkItemDetail(HostWorkItem.fromJson(item.toJson(), item.path), HostWorkItemDetail.readAmount(reader, Resources.pointsField), HostWorkItemDetail.readAmount(reader, Resources.remainingField), HostWorkItemDetail.readAmount(reader, Resources.completedField), HostWorkItemDetail.readAmount(reader, Resources.orderField), reader.readNullableString(Resources.acceptanceField), reader.readNumberArray(Resources.childrenField), reader.readObjectArray(Resources.pullRequestsField).map(t => HostReference.fromJson(t.toJson(), t.path)), reader.readInteger(Resources.commitsField), reader.readStringArray(Resources.branchesField), Object.isNull(reader.readValue(Resources.isWaitingField)) ? null : reader.readBoolean(Resources.isWaitingField), reader.hasField(Resources.accountField) ? reader.readNullableString(Resources.accountField) : null, reader);
64
65
  }
65
66
  toJson() {
66
67
  return {
@@ -75,14 +76,14 @@ export class HostWorkItemDetail {
75
76
  [Resources.commitsField]: this.commits,
76
77
  [Resources.branchesField]: [...this.branches],
77
78
  [Resources.isWaitingField]: this.isWaiting,
78
- ...(this.account === null ? {} : { [Resources.accountField]: this.account })
79
+ ...(Object.isNull(this.account) ? {} : { [Resources.accountField]: this.account })
79
80
  };
80
81
  }
81
82
  static requireAmount(value, field, reader) {
82
- if (value !== null && (!Number.isFinite(value) || value < 0))
83
+ if (!Object.isNull(value) && (!Number.isFinite(value) || value < 0))
83
84
  FieldCheck.fail(field, Resources.amountExpected, reader);
84
85
  }
85
86
  static readAmount(reader, field) {
86
- return reader.readValue(field) === null ? null : reader.readNumber(field);
87
+ return Object.isNull(reader.readValue(field)) ? null : reader.readNumber(field);
87
88
  }
88
89
  }
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -19,7 +20,7 @@ export class HostWorkItemType {
19
20
  if (!Resources.colorPattern.test(color))
20
21
  FieldCheck.fail(Resources.colorField, Resources.colorExpected, reader);
21
22
  FieldCheck.requireName(icon, Resources.iconField, reader);
22
- if (image !== null && (image.length > Resources.maximumImageLength || !Resources.svgPattern.test(image)))
23
+ if (!Object.isNull(image) && (image.length > Resources.maximumImageLength || !Resources.svgPattern.test(image)))
23
24
  FieldCheck.fail(Resources.imageField, Resources.imageExpected, reader);
24
25
  this.name = name;
25
26
  this.color = color;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { WorkItemCategory } from "../enums/work-item-category.js";
10
11
  import { Resources } from "../resources.js";
@@ -38,16 +39,16 @@ export class HostWorkItem {
38
39
  FieldCheck.requireText(title, Resources.titleField, reader);
39
40
  FieldCheck.requireText(state, Resources.stateField, reader);
40
41
  FieldCheck.requireHttps(url, Resources.urlField, reader);
41
- if (iteration !== null)
42
+ if (!Object.isNull(iteration))
42
43
  FieldCheck.requireText(iteration, Resources.iterationField, reader);
43
- if (area !== null)
44
+ if (!Object.isNull(area))
44
45
  FieldCheck.requireText(area, Resources.areaField, reader);
45
- if (parent !== null) {
46
+ if (!Object.isNull(parent)) {
46
47
  FieldCheck.requirePositive(parent, Resources.parentField, reader);
47
48
  if (parent === id)
48
49
  FieldCheck.fail(Resources.parentField, Resources.parentExpected, reader);
49
50
  }
50
- if (changedAt !== null)
51
+ if (!Object.isNull(changedAt))
51
52
  FieldCheck.requirePositive(changedAt, Resources.changedAtField, reader);
52
53
  this.host = host;
53
54
  this.organization = organization;
@@ -31,6 +31,7 @@ export class HostingNames {
31
31
  static updateWorkItemMethod = "updateWorkItem";
32
32
  static readPullRequestsMethod = "readPullRequests";
33
33
  static readReviewRequestsMethod = "readReviewRequests";
34
+ static readRepositoriesMethod = "readRepositories";
34
35
  static readCommitCommentsMethod = "readCommitComments";
35
36
  static readPullRequestThreadsMethod = "readPullRequestThreads";
36
37
  static rateLimitedUntilDetail = "rateLimitedUntil";
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -13,9 +14,9 @@ export class RepositoryAccount {
13
14
  account;
14
15
  isNamedByRemote;
15
16
  constructor(account, reader, isNamedByRemote = false) {
16
- if (account !== null)
17
+ if (!Object.isNull(account))
17
18
  FieldCheck.requirePositive(account, Resources.accountField, reader);
18
- if (account === null && isNamedByRemote)
19
+ if (Object.isNull(account) && isNamedByRemote)
19
20
  FieldCheck.fail(Resources.isNamedByRemoteField, Resources.namedAccountExpected, reader);
20
21
  this.account = account;
21
22
  this.isNamedByRemote = isNamedByRemote;
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import "@noldova/context.core";
8
9
  import { JsonReader } from "@noldova/context.json";
9
10
  import { Resources } from "../resources.js";
10
11
  import { FieldCheck } from "./field-check.js";
@@ -20,7 +21,7 @@ export class WorkItemUpdate {
20
21
  FieldCheck.requireName(host, Resources.hostField, reader);
21
22
  FieldCheck.requireName(organization, Resources.organizationField, reader);
22
23
  FieldCheck.requirePositive(id, Resources.idField, reader);
23
- if (state !== null)
24
+ if (!Object.isNull(state))
24
25
  FieldCheck.requireText(state, Resources.stateField, reader);
25
26
  else if (!assignToMe)
26
27
  FieldCheck.fail(Resources.stateField, Resources.changeExpected, reader);
package/src/resources.js CHANGED
@@ -56,6 +56,9 @@ export class Resources {
56
56
  static maximumReviewRequestRows = 100;
57
57
  static reviewRequestRowsExpected = "at most 100 review requests, and none while signed out";
58
58
  static reviewRequestsMoreExpected = "more only while signed in";
59
+ static maximumRepositoryRows = 300;
60
+ static repositoryRowsExpected = "at most 300 repositories, and none while signed out";
61
+ static repositoriesMoreExpected = "more only while signed in";
59
62
  static maximumPullRequestCommits = 250;
60
63
  static pullRequestCommitsExpected = "at most 250 commits";
61
64
  static pullRequestCommitsMoreExpected = "more only after 250 commits";
@@ -133,6 +136,8 @@ export class Resources {
133
136
  static reviewDecisionField = "reviewDecision";
134
137
  static bodyField = "body";
135
138
  static isDraftField = "isDraft";
139
+ static isPrivateField = "isPrivate";
140
+ static pushedAtField = "pushedAt";
136
141
  static capabilitiesField = "capabilities";
137
142
  static personField = "person";
138
143
  static voteField = "vote";