@noldova/git.hosting.protocol 0.0.5 → 0.0.7

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 (52) hide show
  1. package/package.json +4 -4
  2. package/src/api/index.d.ts +3697 -122
  3. package/src/api/index.js +42 -0
  4. package/src/enums/file-change-kind.js +13 -0
  5. package/src/enums/host-capability.js +23 -0
  6. package/src/enums/policy-state.js +14 -0
  7. package/src/enums/pull-request-status.js +13 -0
  8. package/src/enums/thread-status.js +16 -0
  9. package/src/enums/work-item-category.js +14 -0
  10. package/src/enums/work-item-scope.js +11 -0
  11. package/src/models/author-query.js +40 -0
  12. package/src/models/branch-pull-request.js +11 -4
  13. package/src/models/commit-query.js +32 -0
  14. package/src/models/field-check.js +6 -0
  15. package/src/models/host-avatar.js +27 -0
  16. package/src/models/host-build.js +60 -0
  17. package/src/models/host-capabilities.js +33 -0
  18. package/src/models/host-changes.js +12 -4
  19. package/src/models/host-comment.js +50 -0
  20. package/src/models/host-commit-comments.js +42 -0
  21. package/src/models/host-person.js +9 -4
  22. package/src/models/host-policy.js +43 -0
  23. package/src/models/host-pull-request-commit.js +34 -0
  24. package/src/models/host-pull-request-commits.js +33 -0
  25. package/src/models/host-pull-request-conflicts.js +34 -0
  26. package/src/models/host-pull-request-file.js +36 -0
  27. package/src/models/host-pull-request-files.js +46 -0
  28. package/src/models/host-pull-request-head.js +47 -0
  29. package/src/models/host-pull-request-heads.js +42 -0
  30. package/src/models/host-pull-request-list.js +42 -0
  31. package/src/models/host-pull-request-row.js +79 -0
  32. package/src/models/host-pull-request-threads.js +28 -0
  33. package/src/models/host-pull-request-update.js +46 -0
  34. package/src/models/host-pull-request-updates.js +33 -0
  35. package/src/models/host-pull-request.js +69 -0
  36. package/src/models/host-review-request-list.js +42 -0
  37. package/src/models/host-review-request.js +45 -0
  38. package/src/models/host-reviewer.js +41 -0
  39. package/src/models/host-sign-in.js +17 -6
  40. package/src/models/host-thread.js +53 -0
  41. package/src/models/host-work-item-detail.js +83 -0
  42. package/src/models/host-work-item-link.js +51 -0
  43. package/src/models/host-work-item-list.js +31 -0
  44. package/src/models/host-work-item-type.js +37 -0
  45. package/src/models/host-work-item.js +91 -0
  46. package/src/models/hosting-names.js +12 -0
  47. package/src/models/person-query.js +36 -0
  48. package/src/models/repository-query.js +29 -0
  49. package/src/models/work-item-query.js +32 -0
  50. package/src/models/work-item-update.js +47 -0
  51. package/src/models/work-items-query.js +49 -0
  52. package/src/resources.js +122 -3
@@ -0,0 +1,43 @@
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 { PolicyState } from "../enums/policy-state.js";
10
+ import { Resources } from "../resources.js";
11
+ import { FieldCheck } from "./field-check.js";
12
+ export class HostPolicy {
13
+ static FIELDS = [Resources.nameField, Resources.stateField, Resources.isBlockingField, Resources.urlField, Resources.buildNumberField];
14
+ static STATES = Object.values(PolicyState);
15
+ name;
16
+ state;
17
+ isBlocking;
18
+ url;
19
+ buildNumber;
20
+ constructor(name, state, isBlocking, url, buildNumber = null, reader) {
21
+ FieldCheck.requireText(name, Resources.nameField, reader);
22
+ if (url !== null)
23
+ FieldCheck.requireHttps(url, Resources.urlField, reader);
24
+ if (buildNumber !== null)
25
+ FieldCheck.requireText(buildNumber, Resources.buildNumberField, reader);
26
+ this.name = name;
27
+ this.state = state;
28
+ this.isBlocking = isBlocking;
29
+ this.url = url;
30
+ this.buildNumber = buildNumber;
31
+ }
32
+ static fromJson(value, path) {
33
+ const reader = JsonReader.fromValue(value, path);
34
+ FieldCheck.refuseUnknownFields(reader, HostPolicy.FIELDS);
35
+ return new HostPolicy(reader.readString(Resources.nameField), reader.readOneOf(Resources.stateField, HostPolicy.STATES), reader.readBoolean(Resources.isBlockingField), reader.readNullableString(Resources.urlField), reader.hasField(Resources.buildNumberField) ? reader.readNullableString(Resources.buildNumberField) : null, reader);
36
+ }
37
+ toJson() {
38
+ return {
39
+ [Resources.nameField]: this.name, [Resources.stateField]: this.state, [Resources.isBlockingField]: this.isBlocking, [Resources.urlField]: this.url,
40
+ [Resources.buildNumberField]: this.buildNumber
41
+ };
42
+ }
43
+ }
@@ -0,0 +1,34 @@
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
+ export class HostPullRequestCommit {
12
+ static FIELDS = [Resources.idField, Resources.subjectField, Resources.authorField, Resources.authoredAtField];
13
+ id;
14
+ subject;
15
+ author;
16
+ authoredAt;
17
+ constructor(id, subject, author, authoredAt, reader) {
18
+ FieldCheck.requireCommit(id, Resources.idField, reader);
19
+ FieldCheck.requireText(author, Resources.authorField, reader);
20
+ FieldCheck.requirePositive(authoredAt, Resources.authoredAtField, reader);
21
+ this.id = id;
22
+ this.subject = subject;
23
+ this.author = author;
24
+ this.authoredAt = authoredAt;
25
+ }
26
+ static fromJson(value, path) {
27
+ const reader = JsonReader.fromValue(value, path);
28
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestCommit.FIELDS);
29
+ return new HostPullRequestCommit(reader.readString(Resources.idField), reader.readString(Resources.subjectField), reader.readString(Resources.authorField), reader.readInteger(Resources.authoredAtField), reader);
30
+ }
31
+ toJson() {
32
+ return { [Resources.idField]: this.id, [Resources.subjectField]: this.subject, [Resources.authorField]: this.author, [Resources.authoredAtField]: this.authoredAt };
33
+ }
34
+ }
@@ -0,0 +1,33 @@
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 { HostPullRequestCommit } from "./host-pull-request-commit.js";
12
+ export class HostPullRequestCommits {
13
+ static maximumCount = Resources.maximumPullRequestCommits;
14
+ static FIELDS = [Resources.commitsField, Resources.hasMoreField];
15
+ commits;
16
+ hasMore;
17
+ constructor(commits, hasMore, reader) {
18
+ if (commits.length > Resources.maximumPullRequestCommits)
19
+ FieldCheck.fail(Resources.commitsField, Resources.pullRequestCommitsExpected, reader);
20
+ if (hasMore && commits.length < Resources.maximumPullRequestCommits)
21
+ FieldCheck.fail(Resources.hasMoreField, Resources.pullRequestCommitsMoreExpected, reader);
22
+ this.commits = [...commits];
23
+ this.hasMore = hasMore;
24
+ }
25
+ static fromJson(value, path) {
26
+ const reader = JsonReader.fromValue(value, path);
27
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestCommits.FIELDS);
28
+ return new HostPullRequestCommits(reader.readObjectArray(Resources.commitsField).map(t => HostPullRequestCommit.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.hasMoreField), reader);
29
+ }
30
+ toJson() {
31
+ return { [Resources.commitsField]: this.commits.map(t => t.toJson()), [Resources.hasMoreField]: this.hasMore };
32
+ }
33
+ }
@@ -0,0 +1,34 @@
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
+ export class HostPullRequestConflicts {
12
+ static maximumCount = Resources.maximumPullRequestConflicts;
13
+ static FIELDS = [Resources.pathsField, Resources.hasMoreField];
14
+ paths;
15
+ hasMore;
16
+ constructor(paths, hasMore, reader) {
17
+ for (const path of paths)
18
+ FieldCheck.requireText(path, Resources.pathsField, reader);
19
+ if (paths.length > Resources.maximumPullRequestConflicts)
20
+ FieldCheck.fail(Resources.pathsField, Resources.pullRequestConflictsExpected, reader);
21
+ if (hasMore && paths.length < Resources.maximumPullRequestConflicts)
22
+ FieldCheck.fail(Resources.hasMoreField, Resources.pullRequestConflictsMoreExpected, reader);
23
+ this.paths = [...paths];
24
+ this.hasMore = hasMore;
25
+ }
26
+ static fromJson(value, path) {
27
+ const reader = JsonReader.fromValue(value, path);
28
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestConflicts.FIELDS);
29
+ return new HostPullRequestConflicts(reader.readStringArray(Resources.pathsField), reader.readBoolean(Resources.hasMoreField), reader);
30
+ }
31
+ toJson() {
32
+ return { [Resources.pathsField]: [...this.paths], [Resources.hasMoreField]: this.hasMore };
33
+ }
34
+ }
@@ -0,0 +1,36 @@
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 { FileChangeKind } from "../enums/file-change-kind.js";
10
+ import { Resources } from "../resources.js";
11
+ import { FieldCheck } from "./field-check.js";
12
+ export class HostPullRequestFile {
13
+ static FIELDS = [Resources.pathField, Resources.kindField, Resources.previousPathField];
14
+ static KINDS = Object.values(FileChangeKind);
15
+ path;
16
+ kind;
17
+ previousPath;
18
+ constructor(path, kind, previousPath, reader) {
19
+ FieldCheck.requireText(path, Resources.pathField, reader);
20
+ if (previousPath !== null)
21
+ FieldCheck.requireText(previousPath, Resources.previousPathField, reader);
22
+ if ((previousPath !== null) !== (kind === FileChangeKind.Renamed))
23
+ FieldCheck.fail(Resources.previousPathField, Resources.previousPathExpected, reader);
24
+ this.path = path;
25
+ this.kind = kind;
26
+ this.previousPath = previousPath;
27
+ }
28
+ static fromJson(value, path) {
29
+ const reader = JsonReader.fromValue(value, path);
30
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestFile.FIELDS);
31
+ return new HostPullRequestFile(reader.readString(Resources.pathField), reader.readOneOf(Resources.kindField, HostPullRequestFile.KINDS), reader.readNullableString(Resources.previousPathField), reader);
32
+ }
33
+ toJson() {
34
+ return { [Resources.pathField]: this.path, [Resources.kindField]: this.kind, [Resources.previousPathField]: this.previousPath };
35
+ }
36
+ }
@@ -0,0 +1,46 @@
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 { HostPullRequestFile } from "./host-pull-request-file.js";
12
+ export class HostPullRequestFiles {
13
+ static maximumCount = Resources.maximumPullRequestFiles;
14
+ static FIELDS = [Resources.sourceCommitField, Resources.commonCommitField, Resources.filesField, Resources.hasMoreField];
15
+ sourceCommit;
16
+ commonCommit;
17
+ files;
18
+ hasMore;
19
+ constructor(sourceCommit, commonCommit, files, hasMore, reader) {
20
+ if (sourceCommit !== null)
21
+ FieldCheck.requireCommit(sourceCommit, Resources.sourceCommitField, reader);
22
+ if (commonCommit !== null)
23
+ FieldCheck.requireCommit(commonCommit, Resources.commonCommitField, reader);
24
+ if (sourceCommit === null && (commonCommit !== null || files.length > 0 || hasMore))
25
+ FieldCheck.fail(Resources.sourceCommitField, Resources.pullRequestFilesCommitExpected, reader);
26
+ if (files.length > Resources.maximumPullRequestFiles)
27
+ FieldCheck.fail(Resources.filesField, Resources.pullRequestFilesExpected, reader);
28
+ this.sourceCommit = sourceCommit;
29
+ this.commonCommit = commonCommit;
30
+ this.files = [...files];
31
+ this.hasMore = hasMore;
32
+ }
33
+ static fromJson(value, path) {
34
+ const reader = JsonReader.fromValue(value, path);
35
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestFiles.FIELDS);
36
+ return new HostPullRequestFiles(reader.readNullableString(Resources.sourceCommitField), reader.readNullableString(Resources.commonCommitField), reader.readObjectArray(Resources.filesField).map(t => HostPullRequestFile.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.hasMoreField), reader);
37
+ }
38
+ toJson() {
39
+ return {
40
+ [Resources.sourceCommitField]: this.sourceCommit,
41
+ [Resources.commonCommitField]: this.commonCommit,
42
+ [Resources.filesField]: this.files.map(t => t.toJson()),
43
+ [Resources.hasMoreField]: this.hasMore
44
+ };
45
+ }
46
+ }
@@ -0,0 +1,47 @@
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 { HostReference } from "./host-reference.js";
12
+ export class HostPullRequestHead {
13
+ static FIELDS = [Resources.referenceField, Resources.titleField, Resources.urlField, Resources.headBranchField,
14
+ Resources.baseBranchField];
15
+ reference;
16
+ title;
17
+ url;
18
+ headBranch;
19
+ baseBranch;
20
+ constructor(reference, title, url, headBranch, baseBranch, reader) {
21
+ FieldCheck.requireText(title, Resources.titleField, reader);
22
+ FieldCheck.requireHttps(url, Resources.urlField, reader);
23
+ FieldCheck.requireText(headBranch, Resources.headBranchField, reader);
24
+ if (baseBranch !== null)
25
+ FieldCheck.requireText(baseBranch, Resources.baseBranchField, reader);
26
+ this.reference = reference;
27
+ this.title = title;
28
+ this.url = url;
29
+ this.headBranch = headBranch;
30
+ this.baseBranch = baseBranch;
31
+ }
32
+ static fromJson(value, path) {
33
+ const reader = JsonReader.fromValue(value, path);
34
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestHead.FIELDS);
35
+ const reference = reader.readObject(Resources.referenceField);
36
+ return new HostPullRequestHead(HostReference.fromJson(reference.toJson(), reference.path), reader.readString(Resources.titleField), reader.readString(Resources.urlField), reader.readString(Resources.headBranchField), reader.readNullableString(Resources.baseBranchField), reader);
37
+ }
38
+ toJson() {
39
+ return {
40
+ [Resources.referenceField]: this.reference.toJson(),
41
+ [Resources.titleField]: this.title,
42
+ [Resources.urlField]: this.url,
43
+ [Resources.headBranchField]: this.headBranch,
44
+ [Resources.baseBranchField]: this.baseBranch
45
+ };
46
+ }
47
+ }
@@ -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 { HostPullRequestHead } from "./host-pull-request-head.js";
12
+ export class HostPullRequestHeads {
13
+ static maximumRows = Resources.maximumPullRequestHeads;
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.maximumPullRequestHeads || (!isSignedIn && rows.length > 0))
20
+ FieldCheck.fail(Resources.rowsField, Resources.pullRequestHeadsExpected, reader);
21
+ if (hasMore && rows.length < Resources.maximumPullRequestHeads)
22
+ FieldCheck.fail(Resources.hasMoreField, Resources.pullRequestHeadsMoreExpected, reader);
23
+ this.rows = [...rows];
24
+ this.hasMore = hasMore;
25
+ this.isSignedIn = isSignedIn;
26
+ }
27
+ static signedOut() {
28
+ return new HostPullRequestHeads([], false, false);
29
+ }
30
+ static fromJson(value, path) {
31
+ const reader = JsonReader.fromValue(value, path);
32
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestHeads.FIELDS);
33
+ return new HostPullRequestHeads(reader.readObjectArray(Resources.rowsField).map(t => HostPullRequestHead.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,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 { HostPullRequestRow } from "./host-pull-request-row.js";
12
+ export class HostPullRequestList {
13
+ static maximumRows = Resources.maximumPullRequestRows;
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.maximumPullRequestRows || (!isSignedIn && rows.length > 0))
20
+ FieldCheck.fail(Resources.rowsField, Resources.rowsExpected, reader);
21
+ if (hasMore && rows.length < Resources.maximumPullRequestRows)
22
+ FieldCheck.fail(Resources.hasMoreField, Resources.hasMoreExpected, reader);
23
+ this.rows = [...rows];
24
+ this.hasMore = hasMore;
25
+ this.isSignedIn = isSignedIn;
26
+ }
27
+ static signedOut() {
28
+ return new HostPullRequestList([], false, false);
29
+ }
30
+ static fromJson(value, path) {
31
+ const reader = JsonReader.fromValue(value, path);
32
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestList.FIELDS);
33
+ return new HostPullRequestList(reader.readObjectArray(Resources.rowsField).map(t => HostPullRequestRow.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,79 @@
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 { CheckState } from "../enums/check-state.js";
10
+ import { PullRequestStatus } from "../enums/pull-request-status.js";
11
+ import { Resources } from "../resources.js";
12
+ import { FieldCheck } from "./field-check.js";
13
+ import { HostReference } from "./host-reference.js";
14
+ export class HostPullRequestRow {
15
+ static FIELDS = [Resources.referenceField, Resources.titleField, Resources.urlField, Resources.isDraftField,
16
+ Resources.approvalsField, Resources.passedField, Resources.failingField, Resources.pendingField, Resources.headBranchField, Resources.baseBranchField];
17
+ reference;
18
+ title;
19
+ url;
20
+ isDraft;
21
+ approvals;
22
+ passed;
23
+ failing;
24
+ pending;
25
+ headBranch;
26
+ baseBranch;
27
+ constructor(reference, title, url, isDraft, approvals, passed, failing, pending, headBranch, baseBranch = null, reader) {
28
+ FieldCheck.requireText(title, Resources.titleField, reader);
29
+ FieldCheck.requireHttps(url, Resources.urlField, reader);
30
+ FieldCheck.requireCount(approvals, Resources.approvalsField, reader);
31
+ FieldCheck.requireCount(passed, Resources.passedField, reader);
32
+ FieldCheck.requireCount(failing, Resources.failingField, reader);
33
+ FieldCheck.requireCount(pending, Resources.pendingField, reader);
34
+ FieldCheck.requireText(headBranch, Resources.headBranchField, reader);
35
+ if (baseBranch !== null)
36
+ FieldCheck.requireText(baseBranch, Resources.baseBranchField, reader);
37
+ this.reference = reference;
38
+ this.title = title;
39
+ this.url = url;
40
+ this.isDraft = isDraft;
41
+ this.approvals = approvals;
42
+ this.passed = passed;
43
+ this.failing = failing;
44
+ this.pending = pending;
45
+ this.headBranch = headBranch;
46
+ this.baseBranch = baseBranch;
47
+ }
48
+ get status() {
49
+ if (this.failing > 0)
50
+ return PullRequestStatus.Failed;
51
+ if (this.pending > 0)
52
+ return PullRequestStatus.Pending;
53
+ return this.passed > 0 ? PullRequestStatus.Succeeded : PullRequestStatus.None;
54
+ }
55
+ static of(reference, title, url, isDraft, approvals, checks, headBranch, baseBranch = null) {
56
+ const count = (...states) => checks.filter(t => states.includes(t.state)).length;
57
+ return new HostPullRequestRow(reference, title, url, isDraft, approvals, count(CheckState.Succeeded), count(CheckState.Failed), count(CheckState.Queued, CheckState.Running), headBranch, baseBranch);
58
+ }
59
+ static fromJson(value, path) {
60
+ const reader = JsonReader.fromValue(value, path);
61
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestRow.FIELDS);
62
+ const reference = reader.readObject(Resources.referenceField);
63
+ return new HostPullRequestRow(HostReference.fromJson(reference.toJson(), reference.path), reader.readString(Resources.titleField), reader.readString(Resources.urlField), reader.readBoolean(Resources.isDraftField), reader.readInteger(Resources.approvalsField), reader.readInteger(Resources.passedField), reader.readInteger(Resources.failingField), reader.readInteger(Resources.pendingField), reader.readString(Resources.headBranchField), reader.readNullableString(Resources.baseBranchField), reader);
64
+ }
65
+ toJson() {
66
+ return {
67
+ [Resources.referenceField]: this.reference.toJson(),
68
+ [Resources.titleField]: this.title,
69
+ [Resources.urlField]: this.url,
70
+ [Resources.isDraftField]: this.isDraft,
71
+ [Resources.approvalsField]: this.approvals,
72
+ [Resources.passedField]: this.passed,
73
+ [Resources.failingField]: this.failing,
74
+ [Resources.pendingField]: this.pending,
75
+ [Resources.headBranchField]: this.headBranch,
76
+ [Resources.baseBranchField]: this.baseBranch
77
+ };
78
+ }
79
+ }
@@ -0,0 +1,28 @@
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 { HostThread } from "./host-thread.js";
12
+ export class HostPullRequestThreads {
13
+ static FIELDS = [Resources.threadsField, Resources.hasMoreField];
14
+ threads;
15
+ hasMore;
16
+ constructor(threads, hasMore) {
17
+ this.threads = [...threads];
18
+ this.hasMore = hasMore;
19
+ }
20
+ static fromJson(value, path) {
21
+ const reader = JsonReader.fromValue(value, path);
22
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestThreads.FIELDS);
23
+ return new HostPullRequestThreads(reader.readObjectArray(Resources.threadsField).map(t => HostThread.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.hasMoreField));
24
+ }
25
+ toJson() {
26
+ return { [Resources.threadsField]: this.threads.map(t => t.toJson()), [Resources.hasMoreField]: this.hasMore };
27
+ }
28
+ }
@@ -0,0 +1,46 @@
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 { HostPerson } from "./host-person.js";
12
+ export class HostPullRequestUpdate {
13
+ static FIELDS = [Resources.numberField, Resources.authorField, Resources.createdAtField, Resources.sourceCommitField,
14
+ Resources.commonCommitField];
15
+ number;
16
+ author;
17
+ createdAt;
18
+ sourceCommit;
19
+ commonCommit;
20
+ constructor(number, author, createdAt, sourceCommit, commonCommit, reader) {
21
+ FieldCheck.requirePositive(number, Resources.numberField, reader);
22
+ FieldCheck.requirePositive(createdAt, Resources.createdAtField, reader);
23
+ FieldCheck.requireCommit(sourceCommit, Resources.sourceCommitField, reader);
24
+ if (commonCommit !== null)
25
+ FieldCheck.requireCommit(commonCommit, Resources.commonCommitField, reader);
26
+ this.number = number;
27
+ this.author = author;
28
+ this.createdAt = createdAt;
29
+ this.sourceCommit = sourceCommit;
30
+ this.commonCommit = commonCommit;
31
+ }
32
+ static fromJson(value, path) {
33
+ const reader = JsonReader.fromValue(value, path);
34
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestUpdate.FIELDS);
35
+ return new HostPullRequestUpdate(reader.readInteger(Resources.numberField), FieldCheck.readNullableModel(reader, Resources.authorField, HostPerson.fromJson), reader.readInteger(Resources.createdAtField), reader.readString(Resources.sourceCommitField), reader.readNullableString(Resources.commonCommitField), reader);
36
+ }
37
+ toJson() {
38
+ return {
39
+ [Resources.numberField]: this.number,
40
+ [Resources.authorField]: this.author?.toJson() ?? null,
41
+ [Resources.createdAtField]: this.createdAt,
42
+ [Resources.sourceCommitField]: this.sourceCommit,
43
+ [Resources.commonCommitField]: this.commonCommit
44
+ };
45
+ }
46
+ }
@@ -0,0 +1,33 @@
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 { HostPullRequestUpdate } from "./host-pull-request-update.js";
12
+ export class HostPullRequestUpdates {
13
+ static maximumCount = Resources.maximumPullRequestUpdates;
14
+ static FIELDS = [Resources.updatesField, Resources.hasMoreField];
15
+ updates;
16
+ hasMore;
17
+ constructor(updates, hasMore, reader) {
18
+ if (updates.length > Resources.maximumPullRequestUpdates)
19
+ FieldCheck.fail(Resources.updatesField, Resources.pullRequestUpdatesExpected, reader);
20
+ if (hasMore && updates.length < Resources.maximumPullRequestUpdates)
21
+ FieldCheck.fail(Resources.hasMoreField, Resources.pullRequestUpdatesMoreExpected, reader);
22
+ this.updates = [...updates];
23
+ this.hasMore = hasMore;
24
+ }
25
+ static fromJson(value, path) {
26
+ const reader = JsonReader.fromValue(value, path);
27
+ FieldCheck.refuseUnknownFields(reader, HostPullRequestUpdates.FIELDS);
28
+ return new HostPullRequestUpdates(reader.readObjectArray(Resources.updatesField).map(t => HostPullRequestUpdate.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.hasMoreField), reader);
29
+ }
30
+ toJson() {
31
+ return { [Resources.updatesField]: this.updates.map(t => t.toJson()), [Resources.hasMoreField]: this.hasMore };
32
+ }
33
+ }
@@ -0,0 +1,69 @@
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 { ReferenceKind } from "../enums/reference-kind.js";
10
+ import { Resources } from "../resources.js";
11
+ import { FieldCheck } from "./field-check.js";
12
+ import { HostBuild } from "./host-build.js";
13
+ import { HostItem } from "./host-item.js";
14
+ import { HostPolicy } from "./host-policy.js";
15
+ import { HostReviewer } from "./host-reviewer.js";
16
+ import { HostWorkItemLink } from "./host-work-item-link.js";
17
+ export class HostPullRequest {
18
+ static FIELDS = [Resources.itemField, Resources.reviewersField, Resources.policiesField, Resources.buildsField,
19
+ Resources.isAutoCompleteField, Resources.descriptionField, Resources.commitCountField, Resources.workItemsField, Resources.autoCompleteMergeTypeField,
20
+ Resources.hasConflictsField];
21
+ item;
22
+ reviewers;
23
+ policies;
24
+ builds;
25
+ isAutoComplete;
26
+ description;
27
+ commitCount;
28
+ workItems;
29
+ autoCompleteMergeType;
30
+ hasConflicts;
31
+ constructor(item, reviewers, policies, builds, isAutoComplete, description, commitCount, workItems, autoCompleteMergeType = null, hasConflicts = null, reader) {
32
+ if (item.kind !== ReferenceKind.PullRequest)
33
+ FieldCheck.fail(Resources.itemField, Resources.pullRequestExpected, reader);
34
+ if (commitCount !== null)
35
+ FieldCheck.requireCount(commitCount, Resources.commitCountField, reader);
36
+ if (autoCompleteMergeType !== null)
37
+ FieldCheck.requireText(autoCompleteMergeType, Resources.autoCompleteMergeTypeField, reader);
38
+ this.item = item;
39
+ this.reviewers = [...reviewers];
40
+ this.policies = [...policies];
41
+ this.builds = [...builds];
42
+ this.isAutoComplete = isAutoComplete;
43
+ this.description = description;
44
+ this.commitCount = commitCount;
45
+ this.workItems = [...workItems];
46
+ this.autoCompleteMergeType = autoCompleteMergeType;
47
+ this.hasConflicts = hasConflicts;
48
+ }
49
+ static fromJson(value, path) {
50
+ const reader = JsonReader.fromValue(value, path);
51
+ FieldCheck.refuseUnknownFields(reader, HostPullRequest.FIELDS);
52
+ 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
+ }
55
+ toJson() {
56
+ return {
57
+ [Resources.itemField]: this.item.toJson(),
58
+ [Resources.reviewersField]: this.reviewers.map(t => t.toJson()),
59
+ [Resources.policiesField]: this.policies.map(t => t.toJson()),
60
+ [Resources.buildsField]: this.builds.map(t => t.toJson()),
61
+ [Resources.isAutoCompleteField]: this.isAutoComplete,
62
+ [Resources.descriptionField]: this.description,
63
+ [Resources.commitCountField]: this.commitCount,
64
+ [Resources.workItemsField]: this.workItems.map(t => t.toJson()),
65
+ [Resources.autoCompleteMergeTypeField]: this.autoCompleteMergeType,
66
+ [Resources.hasConflictsField]: this.hasConflicts
67
+ };
68
+ }
69
+ }