@noldova/git.hosting.protocol 0.0.6 → 0.0.8

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,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
+ export class WorkItemUpdate {
12
+ static FIELDS = [Resources.hostField, Resources.organizationField, Resources.idField, Resources.stateField,
13
+ Resources.assignToMeField];
14
+ host;
15
+ organization;
16
+ id;
17
+ state;
18
+ assignToMe;
19
+ constructor(host, organization, id, state, assignToMe, reader) {
20
+ FieldCheck.requireName(host, Resources.hostField, reader);
21
+ FieldCheck.requireName(organization, Resources.organizationField, reader);
22
+ FieldCheck.requirePositive(id, Resources.idField, reader);
23
+ if (state !== null)
24
+ FieldCheck.requireText(state, Resources.stateField, reader);
25
+ else if (!assignToMe)
26
+ FieldCheck.fail(Resources.stateField, Resources.changeExpected, reader);
27
+ this.host = host;
28
+ this.organization = organization;
29
+ this.id = id;
30
+ this.state = state;
31
+ this.assignToMe = assignToMe;
32
+ }
33
+ static fromJson(value, path) {
34
+ const reader = JsonReader.fromValue(value, path);
35
+ FieldCheck.refuseUnknownFields(reader, WorkItemUpdate.FIELDS);
36
+ return new WorkItemUpdate(reader.readString(Resources.hostField), reader.readString(Resources.organizationField), reader.readInteger(Resources.idField), reader.readNullableString(Resources.stateField), reader.readBoolean(Resources.assignToMeField), reader);
37
+ }
38
+ toJson() {
39
+ return {
40
+ [Resources.hostField]: this.host,
41
+ [Resources.organizationField]: this.organization,
42
+ [Resources.idField]: this.id,
43
+ [Resources.stateField]: this.state,
44
+ [Resources.assignToMeField]: this.assignToMe
45
+ };
46
+ }
47
+ }
@@ -0,0 +1,49 @@
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 { WorkItemScope } from "../enums/work-item-scope.js";
10
+ import { Resources } from "../resources.js";
11
+ import { FieldCheck } from "./field-check.js";
12
+ export class WorkItemsQuery {
13
+ static FIELDS = [Resources.hostField, Resources.organizationField, Resources.projectField, Resources.scopeField,
14
+ Resources.idsField];
15
+ static SCOPES = Object.values(WorkItemScope);
16
+ host;
17
+ organization;
18
+ project;
19
+ scope;
20
+ ids;
21
+ constructor(host, organization, project, scope, ids, reader) {
22
+ FieldCheck.requireName(host, Resources.hostField, reader);
23
+ FieldCheck.requireName(organization, Resources.organizationField, reader);
24
+ FieldCheck.requireText(project, Resources.projectField, reader);
25
+ if ((ids.length > 0) !== (scope === WorkItemScope.Ids) || new Set(ids).size !== ids.length)
26
+ FieldCheck.fail(Resources.idsField, Resources.idsScopeExpected, reader);
27
+ for (const id of ids)
28
+ FieldCheck.requirePositive(id, Resources.idsField, reader);
29
+ this.host = host;
30
+ this.organization = organization;
31
+ this.project = project;
32
+ this.scope = scope;
33
+ this.ids = [...ids];
34
+ }
35
+ static fromJson(value, path) {
36
+ const reader = JsonReader.fromValue(value, path);
37
+ FieldCheck.refuseUnknownFields(reader, WorkItemsQuery.FIELDS);
38
+ return new WorkItemsQuery(reader.readString(Resources.hostField), reader.readString(Resources.organizationField), reader.readString(Resources.projectField), reader.readOneOf(Resources.scopeField, WorkItemsQuery.SCOPES), reader.readNumberArray(Resources.idsField), reader);
39
+ }
40
+ toJson() {
41
+ return {
42
+ [Resources.hostField]: this.host,
43
+ [Resources.organizationField]: this.organization,
44
+ [Resources.projectField]: this.project,
45
+ [Resources.scopeField]: this.scope,
46
+ [Resources.idsField]: [...this.ids]
47
+ };
48
+ }
49
+ }
package/src/resources.js CHANGED
@@ -12,15 +12,16 @@ export class Resources {
12
12
  static positiveExpected = "a whole number above zero";
13
13
  static countExpected = "a whole number, zero or more";
14
14
  static nameExpected = "a name of letters, digits, '.', '_' and '-', other than '.' and '..'";
15
- static pathExpected = "names of letters, digits, '.', '_' and '-' joined by '/', none of them '.' or '..'";
15
+ static pathExpected = "names of letters, digits, '.', '_', '-' and percent escapes such as '%20' but not of '/' or '\\' joined by '/', none of them '.' or '..', '%2e' counting as a dot";
16
16
  static namePattern = /^(?!\.\.?$)[A-Za-z0-9._-]+$/;
17
- static pathPattern = /^(?!\.\.?(?:\/|$))[A-Za-z0-9._-]+(?:\/(?!\.\.?(?:\/|$))[A-Za-z0-9._-]+)*$/;
17
+ static pathPattern = /^(?!(?:\.|%2[Ee]){1,2}(?:\/|$))(?:[A-Za-z0-9._-]|%(?!2[Ff]|5[Cc])[0-9A-Fa-f]{2})+(?:\/(?!(?:\.|%2[Ee]){1,2}(?:\/|$))(?:[A-Za-z0-9._-]|%(?!2[Ff]|5[Cc])[0-9A-Fa-f]{2})+)*$/;
18
18
  static commitExpected = "a full commit hash, 40 or 64 lowercase hexadecimal digits";
19
19
  static pullRequestStateExpected = "Open, Draft, Merged or Closed, the states of a pull request";
20
20
  static issueStateExpected = "Open, ClosedDone or ClosedNotPlanned, the states of an issue";
21
21
  static changesExpected = "changes exactly for a pull request";
22
22
  static pullRequestExpected = "a pull request";
23
23
  static checksExpected = "no checks, since there is no pull request";
24
+ static approvalsExpected = "no approvals, since there is no pull request";
24
25
  static reviewDecisionExpected = "a review decision exactly for a pull request";
25
26
  static otherBranchExpected = "a branch other than the head branch";
26
27
  static commitPattern = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
@@ -28,11 +29,59 @@ export class Resources {
28
29
  static avatarPattern = /^data:image\/(?:png|jpeg|gif|webp);base64,((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)$/;
29
30
  static maximumAvatarLength = 87_384;
30
31
  static closedAtExpected = "a time exactly when the item is merged or closed";
31
- static deviceCodeExpected = "a device code exactly while the sign-in waits for the person";
32
+ static deviceCodeExpected = "either a device code or an address to open in the browser, exactly while the sign-in waits for the person";
32
33
  static accountExpected = "an account exactly while signed in";
33
34
  static failureExpected = "null, since only a sign-out has a failure";
35
+ static eachOnceExpected = "each capability at most once";
36
+ static voteExpected = "a number from -1 to 1";
37
+ static finishedAtExpected = "a finish time exactly when the build has finished, no earlier than its start";
38
+ static colorExpected = "a color of six hexadecimal digits";
39
+ static colorPattern = /^[0-9A-Fa-f]{6}$/;
40
+ static imageExpected = "an SVG image of at most 65536 characters";
41
+ static svgPattern = /^\s*(?:<\?xml[^>]*\?>\s*)?<svg[\s>]/u;
42
+ static maximumImageLength = 65_536;
43
+ static parentExpected = "a parent other than the work item itself";
44
+ static idsScopeExpected = "work item ids, each once, exactly for the Ids scope";
45
+ static amountExpected = "a number, zero or more";
46
+ static finiteExpected = "a number";
47
+ static childrenExpected = "children, each once and none the work item itself";
48
+ static changeExpected = "a new state, an assignment to the signed-in person, or both";
49
+ static maximumPullRequestRows = 20;
50
+ static rowsExpected = "at most 20 pull requests, and none while signed out";
51
+ static hasMoreExpected = "more only after 20 pull requests";
52
+ static maximumPullRequestHeads = 100;
53
+ static pullRequestHeadsExpected = "at most 100 pull requests, and none while signed out";
54
+ static pullRequestHeadsMoreExpected = "more only after 100 pull requests";
55
+ static maximumReviewRequestRows = 100;
56
+ static reviewRequestRowsExpected = "at most 100 review requests, and none while signed out";
57
+ static reviewRequestsMoreExpected = "more only while signed in";
58
+ static maximumPullRequestCommits = 250;
59
+ static pullRequestCommitsExpected = "at most 250 commits";
60
+ static pullRequestCommitsMoreExpected = "more only after 250 commits";
61
+ static maximumPullRequestUpdates = 100;
62
+ static pullRequestUpdatesExpected = "at most 100 updates";
63
+ static pullRequestUpdatesMoreExpected = "more only after 100 updates";
64
+ static maximumPullRequestFiles = 5000;
65
+ static pullRequestFilesExpected = "at most 5000 files";
66
+ static pullRequestFilesCommitExpected = "a head commit for a common commit, files or more";
67
+ static previousPathExpected = "a previous path for a moved file only";
68
+ static maximumPullRequestConflicts = 100;
69
+ static pullRequestConflictsExpected = "at most 100 conflicts";
70
+ static pullRequestConflictsMoreExpected = "more only after 100 conflicts";
71
+ static filesField = "files";
72
+ static pathsField = "paths";
73
+ static previousPathField = "previousPath";
74
+ static maximumCommitComments = 100;
75
+ static commitCommentsExpected = "at most 100 comments";
76
+ static commitCommentsCappedExpected = "capped only with comments";
77
+ static commitCommentsUrlExpected = "a page exactly when there are comments";
78
+ static countsExpected = "zero counts when the host doesn't count them";
79
+ static commentParentExpected = "a parent other than the comment itself";
80
+ static lineExpected = "a line only on a thread that names a file";
81
+ static commentsExpected = "at least one comment";
34
82
  static stateField = "state";
35
83
  static deviceCodeField = "deviceCode";
84
+ static addressField = "address";
36
85
  static accountField = "account";
37
86
  static failureField = "failure";
38
87
  static userCodeField = "userCode";
@@ -55,6 +104,8 @@ export class Resources {
55
104
  static createdAtField = "createdAt";
56
105
  static closedAtField = "closedAt";
57
106
  static commentsField = "comments";
107
+ static countField = "count";
108
+ static isCappedField = "isCapped";
58
109
  static changesField = "changes";
59
110
  static additionsField = "additions";
60
111
  static deletionsField = "deletions";
@@ -62,13 +113,78 @@ export class Resources {
62
113
  static headBranchField = "headBranch";
63
114
  static baseBranchField = "baseBranch";
64
115
  static headCommitField = "headCommit";
116
+ static isCountedField = "isCounted";
65
117
  static pathField = "path";
66
118
  static branchField = "branch";
119
+ static emailField = "email";
120
+ static commitField = "commit";
67
121
  static pullRequestField = "pullRequest";
68
122
  static checksField = "checks";
69
123
  static reviewDecisionField = "reviewDecision";
70
124
  static bodyField = "body";
71
125
  static isDraftField = "isDraft";
126
+ static capabilitiesField = "capabilities";
127
+ static personField = "person";
128
+ static voteField = "vote";
129
+ static voteLabelField = "voteLabel";
130
+ static isRequiredField = "isRequired";
131
+ static isBlockingField = "isBlocking";
132
+ static startedAtField = "startedAt";
133
+ static finishedAtField = "finishedAt";
134
+ static buildNumberField = "buildNumber";
135
+ static itemField = "item";
136
+ static reviewersField = "reviewers";
137
+ static policiesField = "policies";
138
+ static buildsField = "builds";
139
+ static isAutoCompleteField = "isAutoComplete";
140
+ static descriptionField = "description";
141
+ static commitCountField = "commitCount";
142
+ static workItemsField = "workItems";
143
+ static autoCompleteMergeTypeField = "autoCompleteMergeType";
144
+ static hasConflictsField = "hasConflicts";
145
+ static colorField = "color";
146
+ static iconField = "icon";
147
+ static imageField = "image";
148
+ static organizationField = "organization";
149
+ static projectField = "project";
150
+ static idField = "id";
151
+ static typeField = "type";
152
+ static categoryField = "category";
153
+ static assigneeField = "assignee";
154
+ static iterationField = "iteration";
155
+ static areaField = "area";
156
+ static parentField = "parent";
157
+ static changedAtField = "changedAt";
158
+ static scopeField = "scope";
159
+ static idsField = "ids";
160
+ static pointsField = "points";
161
+ static remainingField = "remaining";
162
+ static completedField = "completed";
163
+ static orderField = "order";
164
+ static acceptanceField = "acceptance";
165
+ static childrenField = "children";
166
+ static pullRequestsField = "pullRequests";
167
+ static commitsField = "commits";
168
+ static branchesField = "branches";
169
+ static isWaitingField = "isWaiting";
170
+ static assignToMeField = "assignToMe";
171
+ static approvalsField = "approvals";
172
+ static passedField = "passed";
173
+ static failingField = "failing";
174
+ static pendingField = "pending";
175
+ static rowsField = "rows";
176
+ static hasMoreField = "hasMore";
177
+ static threadsField = "threads";
178
+ static subjectField = "subject";
179
+ static authoredAtField = "authoredAt";
180
+ static sourceCommitField = "sourceCommit";
181
+ static commonCommitField = "commonCommit";
182
+ static updatesField = "updates";
183
+ static isSignedInField = "isSignedIn";
184
+ static itemsField = "items";
185
+ static isTruncatedField = "isTruncated";
186
+ static lineField = "line";
187
+ static publishedAtField = "publishedAt";
72
188
  static formatFieldPath(parent, field) {
73
189
  return `${parent}.${field}`;
74
190
  }
@@ -78,6 +194,9 @@ export class Resources {
78
194
  static formatInvalidArgument(parameterName, expectation) {
79
195
  return `The argument ${parameterName} is invalid: expected ${expectation}.`;
80
196
  }
197
+ static formatMemberExpected(members) {
198
+ return `one of ${members.join(", ")}`;
199
+ }
81
200
  static formatMemberName(moduleId, member) {
82
201
  return `${moduleId}.${member}`;
83
202
  }