@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.
- package/package.json +4 -4
- package/src/api/index.d.ts +3697 -122
- package/src/api/index.js +42 -0
- package/src/enums/file-change-kind.js +13 -0
- package/src/enums/host-capability.js +23 -0
- package/src/enums/policy-state.js +14 -0
- package/src/enums/pull-request-status.js +13 -0
- package/src/enums/thread-status.js +16 -0
- package/src/enums/work-item-category.js +14 -0
- package/src/enums/work-item-scope.js +11 -0
- package/src/models/author-query.js +40 -0
- package/src/models/branch-pull-request.js +11 -4
- package/src/models/commit-query.js +32 -0
- package/src/models/field-check.js +6 -0
- package/src/models/host-avatar.js +27 -0
- package/src/models/host-build.js +60 -0
- package/src/models/host-capabilities.js +33 -0
- package/src/models/host-changes.js +12 -4
- package/src/models/host-comment.js +50 -0
- package/src/models/host-commit-comments.js +42 -0
- package/src/models/host-person.js +9 -4
- package/src/models/host-policy.js +43 -0
- package/src/models/host-pull-request-commit.js +34 -0
- package/src/models/host-pull-request-commits.js +33 -0
- package/src/models/host-pull-request-conflicts.js +34 -0
- package/src/models/host-pull-request-file.js +36 -0
- package/src/models/host-pull-request-files.js +46 -0
- package/src/models/host-pull-request-head.js +47 -0
- package/src/models/host-pull-request-heads.js +42 -0
- package/src/models/host-pull-request-list.js +42 -0
- package/src/models/host-pull-request-row.js +79 -0
- package/src/models/host-pull-request-threads.js +28 -0
- package/src/models/host-pull-request-update.js +46 -0
- package/src/models/host-pull-request-updates.js +33 -0
- package/src/models/host-pull-request.js +69 -0
- package/src/models/host-review-request-list.js +42 -0
- package/src/models/host-review-request.js +45 -0
- package/src/models/host-reviewer.js +41 -0
- package/src/models/host-sign-in.js +17 -6
- package/src/models/host-thread.js +53 -0
- package/src/models/host-work-item-detail.js +83 -0
- package/src/models/host-work-item-link.js +51 -0
- package/src/models/host-work-item-list.js +31 -0
- package/src/models/host-work-item-type.js +37 -0
- package/src/models/host-work-item.js +91 -0
- package/src/models/hosting-names.js +12 -0
- package/src/models/person-query.js +36 -0
- package/src/models/repository-query.js +29 -0
- package/src/models/work-item-query.js +32 -0
- package/src/models/work-item-update.js +47 -0
- package/src/models/work-items-query.js +49 -0
- package/src/resources.js +122 -3
|
@@ -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 { HostReviewRequest } from "./host-review-request.js";
|
|
12
|
+
export class HostReviewRequestList {
|
|
13
|
+
static maximumRows = Resources.maximumReviewRequestRows;
|
|
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.maximumReviewRequestRows || (!isSignedIn && rows.length > 0))
|
|
20
|
+
FieldCheck.fail(Resources.rowsField, Resources.reviewRequestRowsExpected, reader);
|
|
21
|
+
if (hasMore && !isSignedIn)
|
|
22
|
+
FieldCheck.fail(Resources.hasMoreField, Resources.reviewRequestsMoreExpected, reader);
|
|
23
|
+
this.rows = [...rows];
|
|
24
|
+
this.hasMore = hasMore;
|
|
25
|
+
this.isSignedIn = isSignedIn;
|
|
26
|
+
}
|
|
27
|
+
static signedOut() {
|
|
28
|
+
return new HostReviewRequestList([], false, false);
|
|
29
|
+
}
|
|
30
|
+
static fromJson(value, path) {
|
|
31
|
+
const reader = JsonReader.fromValue(value, path);
|
|
32
|
+
FieldCheck.refuseUnknownFields(reader, HostReviewRequestList.FIELDS);
|
|
33
|
+
return new HostReviewRequestList(reader.readObjectArray(Resources.rowsField).map(t => HostReviewRequest.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,45 @@
|
|
|
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 HostReviewRequest {
|
|
13
|
+
static FIELDS = [Resources.referenceField, Resources.titleField, Resources.urlField, Resources.isDraftField,
|
|
14
|
+
Resources.createdAtField];
|
|
15
|
+
reference;
|
|
16
|
+
title;
|
|
17
|
+
url;
|
|
18
|
+
isDraft;
|
|
19
|
+
createdAt;
|
|
20
|
+
constructor(reference, title, url, isDraft, createdAt, reader) {
|
|
21
|
+
FieldCheck.requireText(title, Resources.titleField, reader);
|
|
22
|
+
FieldCheck.requireHttps(url, Resources.urlField, reader);
|
|
23
|
+
FieldCheck.requirePositive(createdAt, Resources.createdAtField, reader);
|
|
24
|
+
this.reference = reference;
|
|
25
|
+
this.title = title;
|
|
26
|
+
this.url = url;
|
|
27
|
+
this.isDraft = isDraft;
|
|
28
|
+
this.createdAt = createdAt;
|
|
29
|
+
}
|
|
30
|
+
static fromJson(value, path) {
|
|
31
|
+
const reader = JsonReader.fromValue(value, path);
|
|
32
|
+
FieldCheck.refuseUnknownFields(reader, HostReviewRequest.FIELDS);
|
|
33
|
+
const reference = reader.readObject(Resources.referenceField);
|
|
34
|
+
return new HostReviewRequest(HostReference.fromJson(reference.toJson(), reference.path), reader.readString(Resources.titleField), reader.readString(Resources.urlField), reader.readBoolean(Resources.isDraftField), reader.readInteger(Resources.createdAtField), reader);
|
|
35
|
+
}
|
|
36
|
+
toJson() {
|
|
37
|
+
return {
|
|
38
|
+
[Resources.referenceField]: this.reference.toJson(),
|
|
39
|
+
[Resources.titleField]: this.title,
|
|
40
|
+
[Resources.urlField]: this.url,
|
|
41
|
+
[Resources.isDraftField]: this.isDraft,
|
|
42
|
+
[Resources.createdAtField]: this.createdAt
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -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 { 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 HostReviewer {
|
|
13
|
+
static FIELDS = [Resources.personField, Resources.voteField, Resources.voteLabelField, Resources.isRequiredField];
|
|
14
|
+
person;
|
|
15
|
+
vote;
|
|
16
|
+
voteLabel;
|
|
17
|
+
isRequired;
|
|
18
|
+
constructor(person, vote, voteLabel, isRequired, reader) {
|
|
19
|
+
if (!Number.isFinite(vote) || vote < -1 || vote > 1)
|
|
20
|
+
FieldCheck.fail(Resources.voteField, Resources.voteExpected, reader);
|
|
21
|
+
FieldCheck.requireText(voteLabel, Resources.voteLabelField, reader);
|
|
22
|
+
this.person = person;
|
|
23
|
+
this.vote = vote;
|
|
24
|
+
this.voteLabel = voteLabel;
|
|
25
|
+
this.isRequired = isRequired;
|
|
26
|
+
}
|
|
27
|
+
static fromJson(value, path) {
|
|
28
|
+
const reader = JsonReader.fromValue(value, path);
|
|
29
|
+
FieldCheck.refuseUnknownFields(reader, HostReviewer.FIELDS);
|
|
30
|
+
const person = reader.readObject(Resources.personField);
|
|
31
|
+
return new HostReviewer(HostPerson.fromJson(person.toJson(), person.path), reader.readNumber(Resources.voteField), reader.readString(Resources.voteLabelField), reader.readBoolean(Resources.isRequiredField), reader);
|
|
32
|
+
}
|
|
33
|
+
toJson() {
|
|
34
|
+
return {
|
|
35
|
+
[Resources.personField]: this.person.toJson(),
|
|
36
|
+
[Resources.voteField]: this.vote,
|
|
37
|
+
[Resources.voteLabelField]: this.voteLabel,
|
|
38
|
+
[Resources.isRequiredField]: this.isRequired
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -13,22 +13,29 @@ import { DeviceCode } from "./device-code.js";
|
|
|
13
13
|
import { FieldCheck } from "./field-check.js";
|
|
14
14
|
import { HostAccount } from "./host-account.js";
|
|
15
15
|
export class HostSignIn {
|
|
16
|
-
static FIELDS = [Resources.stateField, Resources.deviceCodeField, Resources.
|
|
16
|
+
static FIELDS = [Resources.stateField, Resources.deviceCodeField, Resources.addressField, Resources.accountField,
|
|
17
|
+
Resources.failureField];
|
|
17
18
|
static STATES = Object.values(SignInState);
|
|
18
19
|
static FAILURES = Object.values(SignInFailure);
|
|
19
20
|
state;
|
|
20
21
|
deviceCode;
|
|
22
|
+
address;
|
|
21
23
|
account;
|
|
22
24
|
failure;
|
|
23
|
-
constructor(state, deviceCode, account, failure, reader) {
|
|
24
|
-
if ((state === SignInState.Waiting) !== (deviceCode !== null))
|
|
25
|
-
FieldCheck.fail(Resources.deviceCodeField, Resources.deviceCodeExpected, reader);
|
|
25
|
+
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)
|
|
29
|
+
FieldCheck.fail(Resources.addressField, Resources.deviceCodeExpected, reader);
|
|
30
|
+
if (address !== null)
|
|
31
|
+
FieldCheck.requireHttps(address, Resources.addressField, reader);
|
|
26
32
|
if ((state === SignInState.SignedIn) !== (account !== null))
|
|
27
33
|
FieldCheck.fail(Resources.accountField, Resources.accountExpected, reader);
|
|
28
34
|
if (state !== SignInState.SignedOut && failure !== null)
|
|
29
35
|
FieldCheck.fail(Resources.failureField, Resources.failureExpected, reader);
|
|
30
36
|
this.state = state;
|
|
31
37
|
this.deviceCode = deviceCode;
|
|
38
|
+
this.address = address;
|
|
32
39
|
this.account = account;
|
|
33
40
|
this.failure = failure;
|
|
34
41
|
}
|
|
@@ -38,20 +45,24 @@ export class HostSignIn {
|
|
|
38
45
|
static waiting(deviceCode) {
|
|
39
46
|
return new HostSignIn(SignInState.Waiting, deviceCode, null, null);
|
|
40
47
|
}
|
|
48
|
+
static waitingInBrowser(address) {
|
|
49
|
+
return new HostSignIn(SignInState.Waiting, null, null, null, undefined, address);
|
|
50
|
+
}
|
|
41
51
|
static signedIn(account) {
|
|
42
52
|
return new HostSignIn(SignInState.SignedIn, null, account, null);
|
|
43
53
|
}
|
|
44
54
|
static fromJson(value, path) {
|
|
45
55
|
const reader = JsonReader.fromValue(value, path);
|
|
46
56
|
FieldCheck.refuseUnknownFields(reader, HostSignIn.FIELDS);
|
|
47
|
-
return new HostSignIn(reader.readOneOf(Resources.stateField, HostSignIn.STATES), FieldCheck.readNullableModel(reader, Resources.deviceCodeField, DeviceCode.fromJson), FieldCheck.readNullableModel(reader, Resources.accountField, HostAccount.fromJson), FieldCheck.readNullableMember(reader, Resources.failureField, HostSignIn.FAILURES), reader);
|
|
57
|
+
return new HostSignIn(reader.readOneOf(Resources.stateField, HostSignIn.STATES), FieldCheck.readNullableModel(reader, Resources.deviceCodeField, DeviceCode.fromJson), FieldCheck.readNullableModel(reader, Resources.accountField, HostAccount.fromJson), FieldCheck.readNullableMember(reader, Resources.failureField, HostSignIn.FAILURES), reader, reader.hasField(Resources.addressField) ? reader.readNullableString(Resources.addressField) : null);
|
|
48
58
|
}
|
|
49
59
|
toJson() {
|
|
50
60
|
return {
|
|
51
61
|
[Resources.stateField]: this.state,
|
|
52
62
|
[Resources.deviceCodeField]: this.deviceCode?.toJson() ?? null,
|
|
53
63
|
[Resources.accountField]: this.account?.toJson() ?? null,
|
|
54
|
-
[Resources.failureField]: this.failure
|
|
64
|
+
[Resources.failureField]: this.failure,
|
|
65
|
+
...this.address === null ? {} : { [Resources.addressField]: this.address }
|
|
55
66
|
};
|
|
56
67
|
}
|
|
57
68
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { ThreadStatus } from "../enums/thread-status.js";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
import { FieldCheck } from "./field-check.js";
|
|
12
|
+
import { HostComment } from "./host-comment.js";
|
|
13
|
+
export class HostThread {
|
|
14
|
+
static FIELDS = [Resources.idField, Resources.stateField, Resources.pathField, Resources.lineField,
|
|
15
|
+
Resources.commentsField];
|
|
16
|
+
static STATES = Object.values(ThreadStatus);
|
|
17
|
+
id;
|
|
18
|
+
state;
|
|
19
|
+
path;
|
|
20
|
+
line;
|
|
21
|
+
comments;
|
|
22
|
+
constructor(id, state, path, line, comments, reader) {
|
|
23
|
+
FieldCheck.requirePositive(id, Resources.idField, reader);
|
|
24
|
+
if (path !== null)
|
|
25
|
+
FieldCheck.requireText(path, Resources.pathField, reader);
|
|
26
|
+
if (line !== null) {
|
|
27
|
+
if (path === null)
|
|
28
|
+
FieldCheck.fail(Resources.lineField, Resources.lineExpected, reader);
|
|
29
|
+
FieldCheck.requirePositive(line, Resources.lineField, reader);
|
|
30
|
+
}
|
|
31
|
+
if (comments.length === 0)
|
|
32
|
+
FieldCheck.fail(Resources.commentsField, Resources.commentsExpected, reader);
|
|
33
|
+
this.id = id;
|
|
34
|
+
this.state = state;
|
|
35
|
+
this.path = path;
|
|
36
|
+
this.line = line;
|
|
37
|
+
this.comments = [...comments];
|
|
38
|
+
}
|
|
39
|
+
static fromJson(value, path) {
|
|
40
|
+
const reader = JsonReader.fromValue(value, path);
|
|
41
|
+
FieldCheck.refuseUnknownFields(reader, HostThread.FIELDS);
|
|
42
|
+
return new HostThread(reader.readInteger(Resources.idField), reader.readOneOf(Resources.stateField, HostThread.STATES), reader.readNullableString(Resources.pathField), reader.readNullableInteger(Resources.lineField), reader.readObjectArray(Resources.commentsField).map(t => HostComment.fromJson(t.toJson(), t.path)), reader);
|
|
43
|
+
}
|
|
44
|
+
toJson() {
|
|
45
|
+
return {
|
|
46
|
+
[Resources.idField]: this.id,
|
|
47
|
+
[Resources.stateField]: this.state,
|
|
48
|
+
[Resources.pathField]: this.path,
|
|
49
|
+
[Resources.lineField]: this.line,
|
|
50
|
+
[Resources.commentsField]: this.comments.map(t => t.toJson())
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
import { HostWorkItem } from "./host-work-item.js";
|
|
13
|
+
export class HostWorkItemDetail {
|
|
14
|
+
static FIELDS = [Resources.itemField, Resources.pointsField, Resources.remainingField, Resources.completedField,
|
|
15
|
+
Resources.orderField, Resources.acceptanceField, Resources.childrenField, Resources.pullRequestsField, Resources.commitsField, Resources.branchesField,
|
|
16
|
+
Resources.isWaitingField];
|
|
17
|
+
item;
|
|
18
|
+
points;
|
|
19
|
+
remaining;
|
|
20
|
+
completed;
|
|
21
|
+
order;
|
|
22
|
+
acceptance;
|
|
23
|
+
children;
|
|
24
|
+
pullRequests;
|
|
25
|
+
commits;
|
|
26
|
+
branches;
|
|
27
|
+
isWaiting;
|
|
28
|
+
constructor(item, points, remaining, completed, order, acceptance, children, pullRequests, commits, branches, isWaiting = null, reader) {
|
|
29
|
+
HostWorkItemDetail.requireAmount(points, Resources.pointsField, reader);
|
|
30
|
+
HostWorkItemDetail.requireAmount(remaining, Resources.remainingField, reader);
|
|
31
|
+
HostWorkItemDetail.requireAmount(completed, Resources.completedField, reader);
|
|
32
|
+
if (order !== null && !Number.isFinite(order))
|
|
33
|
+
FieldCheck.fail(Resources.orderField, Resources.finiteExpected, reader);
|
|
34
|
+
if (acceptance !== null)
|
|
35
|
+
FieldCheck.requireText(acceptance, Resources.acceptanceField, reader);
|
|
36
|
+
for (const child of children)
|
|
37
|
+
FieldCheck.requirePositive(child, Resources.childrenField, reader);
|
|
38
|
+
if (new Set(children).size !== children.length || children.includes(item.id))
|
|
39
|
+
FieldCheck.fail(Resources.childrenField, Resources.childrenExpected, reader);
|
|
40
|
+
FieldCheck.requireCount(commits, Resources.commitsField, reader);
|
|
41
|
+
for (const branch of branches)
|
|
42
|
+
FieldCheck.requireText(branch, Resources.branchesField, reader);
|
|
43
|
+
this.item = item;
|
|
44
|
+
this.points = points;
|
|
45
|
+
this.remaining = remaining;
|
|
46
|
+
this.completed = completed;
|
|
47
|
+
this.order = order;
|
|
48
|
+
this.acceptance = acceptance;
|
|
49
|
+
this.children = [...children];
|
|
50
|
+
this.pullRequests = [...pullRequests];
|
|
51
|
+
this.commits = commits;
|
|
52
|
+
this.branches = [...branches];
|
|
53
|
+
this.isWaiting = isWaiting;
|
|
54
|
+
}
|
|
55
|
+
static fromJson(value, path) {
|
|
56
|
+
const reader = JsonReader.fromValue(value, path);
|
|
57
|
+
FieldCheck.refuseUnknownFields(reader, HostWorkItemDetail.FIELDS);
|
|
58
|
+
const item = reader.readObject(Resources.itemField);
|
|
59
|
+
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);
|
|
60
|
+
}
|
|
61
|
+
toJson() {
|
|
62
|
+
return {
|
|
63
|
+
[Resources.itemField]: this.item.toJson(),
|
|
64
|
+
[Resources.pointsField]: this.points,
|
|
65
|
+
[Resources.remainingField]: this.remaining,
|
|
66
|
+
[Resources.completedField]: this.completed,
|
|
67
|
+
[Resources.orderField]: this.order,
|
|
68
|
+
[Resources.acceptanceField]: this.acceptance,
|
|
69
|
+
[Resources.childrenField]: [...this.children],
|
|
70
|
+
[Resources.pullRequestsField]: this.pullRequests.map(t => t.toJson()),
|
|
71
|
+
[Resources.commitsField]: this.commits,
|
|
72
|
+
[Resources.branchesField]: [...this.branches],
|
|
73
|
+
[Resources.isWaitingField]: this.isWaiting
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
static requireAmount(value, field, reader) {
|
|
77
|
+
if (value !== null && (!Number.isFinite(value) || value < 0))
|
|
78
|
+
FieldCheck.fail(field, Resources.amountExpected, reader);
|
|
79
|
+
}
|
|
80
|
+
static readAmount(reader, field) {
|
|
81
|
+
return reader.readValue(field) === null ? null : reader.readNumber(field);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { WorkItemCategory } from "../enums/work-item-category.js";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
import { FieldCheck } from "./field-check.js";
|
|
12
|
+
import { HostWorkItemType } from "./host-work-item-type.js";
|
|
13
|
+
export class HostWorkItemLink {
|
|
14
|
+
static FIELDS = [Resources.idField, Resources.titleField, Resources.typeField, Resources.stateField, Resources.categoryField,
|
|
15
|
+
Resources.urlField];
|
|
16
|
+
static CATEGORIES = Object.values(WorkItemCategory);
|
|
17
|
+
id;
|
|
18
|
+
title;
|
|
19
|
+
type;
|
|
20
|
+
state;
|
|
21
|
+
category;
|
|
22
|
+
url;
|
|
23
|
+
constructor(id, title, type, state, category, url, reader) {
|
|
24
|
+
FieldCheck.requirePositive(id, Resources.idField, reader);
|
|
25
|
+
FieldCheck.requireText(title, Resources.titleField, reader);
|
|
26
|
+
FieldCheck.requireText(state, Resources.stateField, reader);
|
|
27
|
+
FieldCheck.requireHttps(url, Resources.urlField, reader);
|
|
28
|
+
this.id = id;
|
|
29
|
+
this.title = title;
|
|
30
|
+
this.type = type;
|
|
31
|
+
this.state = state;
|
|
32
|
+
this.category = category;
|
|
33
|
+
this.url = url;
|
|
34
|
+
}
|
|
35
|
+
static fromJson(value, path) {
|
|
36
|
+
const reader = JsonReader.fromValue(value, path);
|
|
37
|
+
FieldCheck.refuseUnknownFields(reader, HostWorkItemLink.FIELDS);
|
|
38
|
+
const type = reader.readObject(Resources.typeField);
|
|
39
|
+
return new HostWorkItemLink(reader.readInteger(Resources.idField), reader.readString(Resources.titleField), HostWorkItemType.fromJson(type.toJson(), type.path), reader.readString(Resources.stateField), reader.readOneOf(Resources.categoryField, HostWorkItemLink.CATEGORIES), reader.readString(Resources.urlField), reader);
|
|
40
|
+
}
|
|
41
|
+
toJson() {
|
|
42
|
+
return {
|
|
43
|
+
[Resources.idField]: this.id,
|
|
44
|
+
[Resources.titleField]: this.title,
|
|
45
|
+
[Resources.typeField]: this.type.toJson(),
|
|
46
|
+
[Resources.stateField]: this.state,
|
|
47
|
+
[Resources.categoryField]: this.category,
|
|
48
|
+
[Resources.urlField]: this.url
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { HostWorkItemDetail } from "./host-work-item-detail.js";
|
|
12
|
+
export class HostWorkItemList {
|
|
13
|
+
static FIELDS = [Resources.itemsField, Resources.isTruncatedField];
|
|
14
|
+
items;
|
|
15
|
+
isTruncated;
|
|
16
|
+
constructor(items, isTruncated) {
|
|
17
|
+
this.items = [...items];
|
|
18
|
+
this.isTruncated = isTruncated;
|
|
19
|
+
}
|
|
20
|
+
static fromJson(value, path) {
|
|
21
|
+
const reader = JsonReader.fromValue(value, path);
|
|
22
|
+
FieldCheck.refuseUnknownFields(reader, HostWorkItemList.FIELDS);
|
|
23
|
+
return new HostWorkItemList(reader.readObjectArray(Resources.itemsField).map(t => HostWorkItemDetail.fromJson(t.toJson(), t.path)), reader.readBoolean(Resources.isTruncatedField));
|
|
24
|
+
}
|
|
25
|
+
toJson() {
|
|
26
|
+
return {
|
|
27
|
+
[Resources.itemsField]: this.items.map(t => t.toJson()),
|
|
28
|
+
[Resources.isTruncatedField]: this.isTruncated
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 HostWorkItemType {
|
|
12
|
+
static FIELDS = [Resources.nameField, Resources.colorField, Resources.iconField, Resources.imageField];
|
|
13
|
+
name;
|
|
14
|
+
color;
|
|
15
|
+
icon;
|
|
16
|
+
image;
|
|
17
|
+
constructor(name, color, icon, image = null, reader) {
|
|
18
|
+
FieldCheck.requireText(name, Resources.nameField, reader);
|
|
19
|
+
if (!Resources.colorPattern.test(color))
|
|
20
|
+
FieldCheck.fail(Resources.colorField, Resources.colorExpected, reader);
|
|
21
|
+
FieldCheck.requireName(icon, Resources.iconField, reader);
|
|
22
|
+
if (image !== null && (image.length > Resources.maximumImageLength || !Resources.svgPattern.test(image)))
|
|
23
|
+
FieldCheck.fail(Resources.imageField, Resources.imageExpected, reader);
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.color = color;
|
|
26
|
+
this.icon = icon;
|
|
27
|
+
this.image = image;
|
|
28
|
+
}
|
|
29
|
+
static fromJson(value, path) {
|
|
30
|
+
const reader = JsonReader.fromValue(value, path);
|
|
31
|
+
FieldCheck.refuseUnknownFields(reader, HostWorkItemType.FIELDS);
|
|
32
|
+
return new HostWorkItemType(reader.readString(Resources.nameField), reader.readString(Resources.colorField), reader.readString(Resources.iconField), reader.hasField(Resources.imageField) ? reader.readNullableString(Resources.imageField) : null, reader);
|
|
33
|
+
}
|
|
34
|
+
toJson() {
|
|
35
|
+
return { [Resources.nameField]: this.name, [Resources.colorField]: this.color, [Resources.iconField]: this.icon, [Resources.imageField]: this.image };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { WorkItemCategory } from "../enums/work-item-category.js";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
import { FieldCheck } from "./field-check.js";
|
|
12
|
+
import { HostPerson } from "./host-person.js";
|
|
13
|
+
import { HostWorkItemType } from "./host-work-item-type.js";
|
|
14
|
+
export class HostWorkItem {
|
|
15
|
+
static FIELDS = [Resources.hostField, Resources.organizationField, Resources.projectField, Resources.idField,
|
|
16
|
+
Resources.typeField, Resources.titleField, Resources.stateField, Resources.categoryField, Resources.urlField, Resources.assigneeField,
|
|
17
|
+
Resources.iterationField, Resources.areaField, Resources.parentField, Resources.changedAtField];
|
|
18
|
+
static CATEGORIES = Object.values(WorkItemCategory);
|
|
19
|
+
host;
|
|
20
|
+
organization;
|
|
21
|
+
project;
|
|
22
|
+
id;
|
|
23
|
+
type;
|
|
24
|
+
title;
|
|
25
|
+
state;
|
|
26
|
+
category;
|
|
27
|
+
url;
|
|
28
|
+
assignee;
|
|
29
|
+
iteration;
|
|
30
|
+
area;
|
|
31
|
+
parent;
|
|
32
|
+
changedAt;
|
|
33
|
+
constructor(host, organization, project, id, type, title, state, category, url, assignee, iteration, area, parent, changedAt = null, reader) {
|
|
34
|
+
FieldCheck.requireName(host, Resources.hostField, reader);
|
|
35
|
+
FieldCheck.requireName(organization, Resources.organizationField, reader);
|
|
36
|
+
FieldCheck.requireText(project, Resources.projectField, reader);
|
|
37
|
+
FieldCheck.requirePositive(id, Resources.idField, reader);
|
|
38
|
+
FieldCheck.requireText(title, Resources.titleField, reader);
|
|
39
|
+
FieldCheck.requireText(state, Resources.stateField, reader);
|
|
40
|
+
FieldCheck.requireHttps(url, Resources.urlField, reader);
|
|
41
|
+
if (iteration !== null)
|
|
42
|
+
FieldCheck.requireText(iteration, Resources.iterationField, reader);
|
|
43
|
+
if (area !== null)
|
|
44
|
+
FieldCheck.requireText(area, Resources.areaField, reader);
|
|
45
|
+
if (parent !== null) {
|
|
46
|
+
FieldCheck.requirePositive(parent, Resources.parentField, reader);
|
|
47
|
+
if (parent === id)
|
|
48
|
+
FieldCheck.fail(Resources.parentField, Resources.parentExpected, reader);
|
|
49
|
+
}
|
|
50
|
+
if (changedAt !== null)
|
|
51
|
+
FieldCheck.requirePositive(changedAt, Resources.changedAtField, reader);
|
|
52
|
+
this.host = host;
|
|
53
|
+
this.organization = organization;
|
|
54
|
+
this.project = project;
|
|
55
|
+
this.id = id;
|
|
56
|
+
this.type = type;
|
|
57
|
+
this.title = title;
|
|
58
|
+
this.state = state;
|
|
59
|
+
this.category = category;
|
|
60
|
+
this.url = url;
|
|
61
|
+
this.assignee = assignee;
|
|
62
|
+
this.iteration = iteration;
|
|
63
|
+
this.area = area;
|
|
64
|
+
this.parent = parent;
|
|
65
|
+
this.changedAt = changedAt;
|
|
66
|
+
}
|
|
67
|
+
static fromJson(value, path) {
|
|
68
|
+
const reader = JsonReader.fromValue(value, path);
|
|
69
|
+
FieldCheck.refuseUnknownFields(reader, HostWorkItem.FIELDS);
|
|
70
|
+
const type = reader.readObject(Resources.typeField);
|
|
71
|
+
return new HostWorkItem(reader.readString(Resources.hostField), reader.readString(Resources.organizationField), reader.readString(Resources.projectField), reader.readInteger(Resources.idField), HostWorkItemType.fromJson(type.toJson(), type.path), reader.readString(Resources.titleField), reader.readString(Resources.stateField), reader.readOneOf(Resources.categoryField, HostWorkItem.CATEGORIES), reader.readString(Resources.urlField), FieldCheck.readNullableModel(reader, Resources.assigneeField, HostPerson.fromJson), reader.readNullableString(Resources.iterationField), reader.readNullableString(Resources.areaField), reader.readNullableInteger(Resources.parentField), reader.hasField(Resources.changedAtField) ? reader.readNullableInteger(Resources.changedAtField) : null, reader);
|
|
72
|
+
}
|
|
73
|
+
toJson() {
|
|
74
|
+
return {
|
|
75
|
+
[Resources.hostField]: this.host,
|
|
76
|
+
[Resources.organizationField]: this.organization,
|
|
77
|
+
[Resources.projectField]: this.project,
|
|
78
|
+
[Resources.idField]: this.id,
|
|
79
|
+
[Resources.typeField]: this.type.toJson(),
|
|
80
|
+
[Resources.titleField]: this.title,
|
|
81
|
+
[Resources.stateField]: this.state,
|
|
82
|
+
[Resources.categoryField]: this.category,
|
|
83
|
+
[Resources.urlField]: this.url,
|
|
84
|
+
[Resources.assigneeField]: this.assignee?.toJson() ?? null,
|
|
85
|
+
[Resources.iterationField]: this.iteration,
|
|
86
|
+
[Resources.areaField]: this.area,
|
|
87
|
+
[Resources.parentField]: this.parent,
|
|
88
|
+
[Resources.changedAtField]: this.changedAt
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -10,11 +10,23 @@ export class HostingNames {
|
|
|
10
10
|
static readSignInMethod = "readSignIn";
|
|
11
11
|
static startSignInMethod = "startSignIn";
|
|
12
12
|
static cancelSignInMethod = "cancelSignIn";
|
|
13
|
+
static signInWithTokenMethod = "signInWithToken";
|
|
13
14
|
static signOutMethod = "signOut";
|
|
14
15
|
static signInChangedEvent = "signInChanged";
|
|
15
16
|
static readReferenceMethod = "readReference";
|
|
16
17
|
static readBranchPullRequestMethod = "readBranchPullRequest";
|
|
18
|
+
static readCommitPullRequestMethod = "readCommitPullRequest";
|
|
19
|
+
static readPullRequestMethod = "readPullRequest";
|
|
17
20
|
static createPullRequestMethod = "createPullRequest";
|
|
21
|
+
static readAuthorAvatarMethod = "readAuthorAvatar";
|
|
22
|
+
static readPersonAvatarMethod = "readPersonAvatar";
|
|
23
|
+
static readWorkItemMethod = "readWorkItem";
|
|
24
|
+
static readWorkItemsMethod = "readWorkItems";
|
|
25
|
+
static updateWorkItemMethod = "updateWorkItem";
|
|
26
|
+
static readPullRequestsMethod = "readPullRequests";
|
|
27
|
+
static readReviewRequestsMethod = "readReviewRequests";
|
|
28
|
+
static readCommitCommentsMethod = "readCommitComments";
|
|
29
|
+
static readPullRequestThreadsMethod = "readPullRequestThreads";
|
|
18
30
|
static nameOf(moduleId, member) {
|
|
19
31
|
return Resources.formatMemberName(moduleId, member);
|
|
20
32
|
}
|
|
@@ -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 { Resources } from "../resources.js";
|
|
10
|
+
import { FieldCheck } from "./field-check.js";
|
|
11
|
+
export class PersonQuery {
|
|
12
|
+
static FIELDS = [Resources.hostField, Resources.pathField, Resources.loginField];
|
|
13
|
+
host;
|
|
14
|
+
path;
|
|
15
|
+
login;
|
|
16
|
+
constructor(host, path, login, reader) {
|
|
17
|
+
FieldCheck.requireText(host, Resources.hostField, reader);
|
|
18
|
+
FieldCheck.requirePath(path, Resources.pathField, reader);
|
|
19
|
+
FieldCheck.requireText(login, Resources.loginField, reader);
|
|
20
|
+
this.host = host;
|
|
21
|
+
this.path = path;
|
|
22
|
+
this.login = login;
|
|
23
|
+
}
|
|
24
|
+
static fromJson(value, path) {
|
|
25
|
+
const reader = JsonReader.fromValue(value, path);
|
|
26
|
+
FieldCheck.refuseUnknownFields(reader, PersonQuery.FIELDS);
|
|
27
|
+
return new PersonQuery(reader.readString(Resources.hostField), reader.readString(Resources.pathField), reader.readString(Resources.loginField), reader);
|
|
28
|
+
}
|
|
29
|
+
toJson() {
|
|
30
|
+
return {
|
|
31
|
+
[Resources.hostField]: this.host,
|
|
32
|
+
[Resources.pathField]: this.path,
|
|
33
|
+
[Resources.loginField]: this.login
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 RepositoryQuery {
|
|
12
|
+
static FIELDS = [Resources.hostField, Resources.pathField];
|
|
13
|
+
host;
|
|
14
|
+
path;
|
|
15
|
+
constructor(host, path, reader) {
|
|
16
|
+
FieldCheck.requireText(host, Resources.hostField, reader);
|
|
17
|
+
FieldCheck.requirePath(path, Resources.pathField, reader);
|
|
18
|
+
this.host = host;
|
|
19
|
+
this.path = path;
|
|
20
|
+
}
|
|
21
|
+
static fromJson(value, path) {
|
|
22
|
+
const reader = JsonReader.fromValue(value, path);
|
|
23
|
+
FieldCheck.refuseUnknownFields(reader, RepositoryQuery.FIELDS);
|
|
24
|
+
return new RepositoryQuery(reader.readString(Resources.hostField), reader.readString(Resources.pathField), reader);
|
|
25
|
+
}
|
|
26
|
+
toJson() {
|
|
27
|
+
return { [Resources.hostField]: this.host, [Resources.pathField]: this.path };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 WorkItemQuery {
|
|
12
|
+
static FIELDS = [Resources.hostField, Resources.organizationField, Resources.idField];
|
|
13
|
+
host;
|
|
14
|
+
organization;
|
|
15
|
+
id;
|
|
16
|
+
constructor(host, organization, id, reader) {
|
|
17
|
+
FieldCheck.requireName(host, Resources.hostField, reader);
|
|
18
|
+
FieldCheck.requireName(organization, Resources.organizationField, reader);
|
|
19
|
+
FieldCheck.requirePositive(id, Resources.idField, reader);
|
|
20
|
+
this.host = host;
|
|
21
|
+
this.organization = organization;
|
|
22
|
+
this.id = id;
|
|
23
|
+
}
|
|
24
|
+
static fromJson(value, path) {
|
|
25
|
+
const reader = JsonReader.fromValue(value, path);
|
|
26
|
+
FieldCheck.refuseUnknownFields(reader, WorkItemQuery.FIELDS);
|
|
27
|
+
return new WorkItemQuery(reader.readString(Resources.hostField), reader.readString(Resources.organizationField), reader.readInteger(Resources.idField), reader);
|
|
28
|
+
}
|
|
29
|
+
toJson() {
|
|
30
|
+
return { [Resources.hostField]: this.host, [Resources.organizationField]: this.organization, [Resources.idField]: this.id };
|
|
31
|
+
}
|
|
32
|
+
}
|