@noldova/git.hosting.protocol 0.0.8 → 0.0.9
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/README.md +3 -0
- package/package.json +3 -3
- package/src/api/index.d.ts +495 -4
- package/src/api/index.js +6 -0
- package/src/enums/sign-in-failure.js +2 -1
- package/src/models/account-pick.js +32 -0
- package/src/models/account-query.js +26 -0
- package/src/models/field-check.js +4 -0
- package/src/models/folder-query.js +29 -0
- package/src/models/host-account-entry.js +37 -0
- package/src/models/host-account-list.js +28 -0
- package/src/models/host-reference.js +9 -4
- package/src/models/host-review-request.js +9 -4
- package/src/models/host-work-item-detail.js +9 -4
- package/src/models/hosting-names.js +7 -0
- package/src/models/repository-account.js +31 -0
- package/src/resources.js +10 -0
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
What every host module of Git shares: a reference to an issue or pull request on a host, the item and its checks, a branch's pull request, a pull request draft, and the sign-in's account and device code.
|
|
4
4
|
|
|
5
|
+
`SignInFailure.AlreadyKept`, added with several accounts per host, says an added account signed in as an account the module already keeps; JSON from earlier versions reads the same, and a consumer's `Record` over `SignInFailure`, such as a window's failure titles, must cover it.
|
|
6
|
+
`HostAccountEntry.place`, added with it, names where an account signs in, for any host with more than one place, such as `dev.azure.com/fabrikam` for an Azure DevOps organization or `github.example.com` for a GitHub Enterprise server; it is written only when it isn't null, so JSON from earlier versions reads the same, and a module whose host has one place leaves it null.
|
|
7
|
+
|
|
5
8
|
A host module, such as [`@noldova/git.github`](https://github.com/noldova-com/git/tree/main/src/noldova.git.github), implements it: its runtime part reads the host into these models, and its window part shows them.
|
|
6
9
|
[documents/ARCHITECTURE.md](https://github.com/noldova-com/git/blob/main/documents/ARCHITECTURE.md) says how the parts talk, and the [README](https://github.com/noldova-com/git#readme) how to build and test it.
|
|
7
10
|
It is licensed under the [MIT License](https://github.com/noldova-com/git/blob/main/LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/git.hosting.protocol",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
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,8 @@
|
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@noldova/context.exceptions": ">=0.0.
|
|
33
|
+
"@noldova/context.exceptions": ">=0.0.18 <0.1.0",
|
|
34
34
|
"@noldova/context.json": ">=0.0.12 <0.1.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "9f5500a19b8eb3c3a4da847dc487d553243402f3"
|
|
37
37
|
}
|
package/src/api/index.d.ts
CHANGED
|
@@ -88,6 +88,11 @@ export declare const SignInFailure: {
|
|
|
88
88
|
* The person signed out, but the token couldn't be removed from the module's secrets on this computer, so a later start may restore it.
|
|
89
89
|
*/
|
|
90
90
|
readonly Unforgotten: "Unforgotten";
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* An added account signed in as an account the module already keeps, so its token was forgotten and the account isn't added twice.
|
|
94
|
+
*/
|
|
95
|
+
readonly AlreadyKept: "AlreadyKept";
|
|
91
96
|
};
|
|
92
97
|
|
|
93
98
|
/**
|
|
@@ -741,11 +746,13 @@ export declare class HostingNames {
|
|
|
741
746
|
|
|
742
747
|
/**
|
|
743
748
|
* The method that starts a sign-in, or leaves one that waits or is signed in as it is, and answers the sign-in.
|
|
749
|
+
* It takes nothing for the first account, or `AccountQuery` JSON for another, on a module that keeps several.
|
|
744
750
|
*/
|
|
745
751
|
public static readonly startSignInMethod: string;
|
|
746
752
|
|
|
747
753
|
/**
|
|
748
754
|
* The method that stops a sign-in that waits, and answers the sign-in.
|
|
755
|
+
* It takes nothing for the first account, or `AccountQuery` JSON for another, on a module that keeps several.
|
|
749
756
|
*/
|
|
750
757
|
public static readonly cancelSignInMethod: string;
|
|
751
758
|
|
|
@@ -757,6 +764,8 @@ export declare class HostingNames {
|
|
|
757
764
|
|
|
758
765
|
/**
|
|
759
766
|
* The method that forgets the kept token on this computer, and answers the sign-in.
|
|
767
|
+
* It takes nothing for the first account, or `AccountQuery` JSON for another, on a module that keeps several; a signed-out account other than
|
|
768
|
+
* the first leaves the list.
|
|
760
769
|
*/
|
|
761
770
|
public static readonly signOutMethod: string;
|
|
762
771
|
|
|
@@ -765,6 +774,40 @@ export declare class HostingNames {
|
|
|
765
774
|
*/
|
|
766
775
|
public static readonly signInChangedEvent: string;
|
|
767
776
|
|
|
777
|
+
/**
|
|
778
|
+
* The method that answers every account kept on this computer as `HostAccountList` JSON, the first account first, on a module that keeps
|
|
779
|
+
* several.
|
|
780
|
+
*/
|
|
781
|
+
public static readonly readAccountsMethod: string;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* The method that starts a sign-in for a new account and answers it as `HostAccountEntry` JSON, its sign-in waiting.
|
|
785
|
+
*/
|
|
786
|
+
public static readonly addAccountMethod: string;
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* The method that takes a `RepositoryQuery` as JSON and answers the account the module reads that repository with, as `RepositoryAccount` JSON.
|
|
790
|
+
*/
|
|
791
|
+
public static readonly readRepositoryAccountMethod: string;
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* The method that takes an `AccountPick` as JSON, remembers the account for that repository on this computer, and answers it as
|
|
795
|
+
* `RepositoryAccount` JSON.
|
|
796
|
+
*/
|
|
797
|
+
public static readonly pickAccountMethod: string;
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* The method that takes a `FolderQuery` as JSON: the module's main process reads that folder's remote, its host, path and user name, keeps the
|
|
801
|
+
* user name for that host and path while the app runs, so an account whose login is that user name reads the repository first, and answers
|
|
802
|
+
* the account it now reads the repository with as `RepositoryAccount` JSON. A window sends it before its first read for that remote.
|
|
803
|
+
*/
|
|
804
|
+
public static readonly useFolderMethod: string;
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* The event that carries every account as `HostAccountList` JSON each time one is added, signs in, signs out or leaves.
|
|
808
|
+
*/
|
|
809
|
+
public static readonly accountsChangedEvent: string;
|
|
810
|
+
|
|
768
811
|
/**
|
|
769
812
|
* The method that takes a `HostReference` as JSON and answers the pull request or issue as `HostItem` JSON, or null when the module can't
|
|
770
813
|
* show it.
|
|
@@ -847,6 +890,13 @@ export declare class HostingNames {
|
|
|
847
890
|
*/
|
|
848
891
|
public static readonly readPullRequestThreadsMethod: string;
|
|
849
892
|
|
|
893
|
+
/**
|
|
894
|
+
* The field of a method failure's `details` that holds, as milliseconds since the epoch, when the host's rate limit for the account resets, on a
|
|
895
|
+
* failure because that limit is used up. A window writes that time by the person's time and date format settings; the failure's message names it
|
|
896
|
+
* too, for logs and agent tools.
|
|
897
|
+
*/
|
|
898
|
+
public static readonly rateLimitedUntilDetail: string;
|
|
899
|
+
|
|
850
900
|
/**
|
|
851
901
|
* A member's full name in a module.
|
|
852
902
|
*
|
|
@@ -896,6 +946,12 @@ export declare class HostReference {
|
|
|
896
946
|
*/
|
|
897
947
|
public readonly number: number;
|
|
898
948
|
|
|
949
|
+
/**
|
|
950
|
+
* The server the repository is on, as `HostAccountEntry.place` names it, such as `github.example.com` for a GitHub Enterprise server; null for a
|
|
951
|
+
* host with one place, such as github.com. JSON holds it only when it isn't null.
|
|
952
|
+
*/
|
|
953
|
+
public readonly place: string | null;
|
|
954
|
+
|
|
899
955
|
/**
|
|
900
956
|
* Makes a reference from its parts.
|
|
901
957
|
*
|
|
@@ -904,6 +960,7 @@ export declare class HostReference {
|
|
|
904
960
|
* @param repository The repository's name on the host: letters, digits, `.`, `_` and `-`, other than `.` and `..`.
|
|
905
961
|
* @param number The issue's or pull request's number in its repository, a whole number above zero.
|
|
906
962
|
* @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.
|
|
963
|
+
* @param place The server the repository is on, checked as `HostAccountEntry`'s place is, or null, the default, for a host with one place.
|
|
907
964
|
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `number`.
|
|
908
965
|
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.number`.
|
|
909
966
|
* @example
|
|
@@ -911,9 +968,10 @@ export declare class HostReference {
|
|
|
911
968
|
* import { HostReference } from "@noldova/git.hosting.protocol";
|
|
912
969
|
*
|
|
913
970
|
* const reference = new HostReference("git-github", "team", "repo", 7);
|
|
971
|
+
* const enterprise = new HostReference("git-github", "team", "repo", 7, undefined, "github.example.com");
|
|
914
972
|
* ```
|
|
915
973
|
*/
|
|
916
|
-
public constructor(host: string, owner: string, repository: string, number: number, reader?: JsonReader);
|
|
974
|
+
public constructor(host: string, owner: string, repository: string, number: number, reader?: JsonReader, place?: string | null);
|
|
917
975
|
|
|
918
976
|
/**
|
|
919
977
|
* The reference as a person writes it: the owner, a slash, the repository, a number sign and the number.
|
|
@@ -2375,6 +2433,11 @@ export declare class HostWorkItemDetail {
|
|
|
2375
2433
|
*/
|
|
2376
2434
|
public readonly isWaiting: boolean | null;
|
|
2377
2435
|
|
|
2436
|
+
/**
|
|
2437
|
+
* The login of the account the work item was listed for, when the module keeps several accounts and more than one is signed in; null otherwise.
|
|
2438
|
+
*/
|
|
2439
|
+
public readonly account: string | null;
|
|
2440
|
+
|
|
2378
2441
|
/**
|
|
2379
2442
|
* Makes a work item's detail from its parts.
|
|
2380
2443
|
*
|
|
@@ -2389,6 +2452,7 @@ export declare class HostWorkItemDetail {
|
|
|
2389
2452
|
* @param commits How many commits are linked, a whole number, zero or more.
|
|
2390
2453
|
* @param branches The linked branches' names, texts that aren't blank.
|
|
2391
2454
|
* @param isWaiting Whether a linked pull request waits on review, or null, the default, when that isn't known.
|
|
2455
|
+
* @param account The login of the account the work item was listed for, not blank, or null, the default, when only one account is signed in.
|
|
2392
2456
|
* @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.
|
|
2393
2457
|
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `children`.
|
|
2394
2458
|
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.children`.
|
|
@@ -2402,7 +2466,7 @@ export declare class HostWorkItemDetail {
|
|
|
2402
2466
|
*/
|
|
2403
2467
|
public constructor(item: HostWorkItem, points: number | null, remaining: number | null, completed: number | null, order: number | null,
|
|
2404
2468
|
acceptance: string | null, children: readonly number[], pullRequests: readonly HostReference[], commits: number, branches: readonly string[],
|
|
2405
|
-
isWaiting?: boolean | null, reader?: JsonReader);
|
|
2469
|
+
isWaiting?: boolean | null, account?: string | null, reader?: JsonReader);
|
|
2406
2470
|
|
|
2407
2471
|
/**
|
|
2408
2472
|
* Reads a work item's detail from its JSON.
|
|
@@ -4858,6 +4922,12 @@ export declare class HostReviewRequest {
|
|
|
4858
4922
|
*/
|
|
4859
4923
|
public readonly createdAt: number;
|
|
4860
4924
|
|
|
4925
|
+
/**
|
|
4926
|
+
* The login of the account the request is for, from a module that keeps several accounts, which may name it only while more than one is signed
|
|
4927
|
+
* in; null otherwise.
|
|
4928
|
+
*/
|
|
4929
|
+
public readonly account: string | null;
|
|
4930
|
+
|
|
4861
4931
|
/**
|
|
4862
4932
|
* Makes a review request from its parts.
|
|
4863
4933
|
*
|
|
@@ -4866,6 +4936,7 @@ export declare class HostReviewRequest {
|
|
|
4866
4936
|
* @param url Its page, an https address.
|
|
4867
4937
|
* @param isDraft Whether it is a draft.
|
|
4868
4938
|
* @param createdAt When it was opened, a positive whole number of milliseconds since the Unix epoch.
|
|
4939
|
+
* @param account The login of the account the request is for, not blank, or null, the default, when only one account is signed in.
|
|
4869
4940
|
* @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.
|
|
4870
4941
|
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `title`.
|
|
4871
4942
|
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.title`.
|
|
@@ -4877,7 +4948,7 @@ export declare class HostReviewRequest {
|
|
|
4877
4948
|
* "https://github.com/octocat/hello-world/pull/533", false, Date.parse("2026-11-20T09:00:00Z"));
|
|
4878
4949
|
* ```
|
|
4879
4950
|
*/
|
|
4880
|
-
public constructor(reference: HostReference, title: string, url: string, isDraft: boolean, createdAt: number, reader?: JsonReader);
|
|
4951
|
+
public constructor(reference: HostReference, title: string, url: string, isDraft: boolean, createdAt: number, account?: string | null, reader?: JsonReader);
|
|
4881
4952
|
|
|
4882
4953
|
/**
|
|
4883
4954
|
* Reads a review request from its JSON.
|
|
@@ -4897,7 +4968,7 @@ export declare class HostReviewRequest {
|
|
|
4897
4968
|
public static fromJson(value: unknown, path?: string): HostReviewRequest;
|
|
4898
4969
|
|
|
4899
4970
|
/**
|
|
4900
|
-
* Writes the review request as JSON: `reference`, `title`, `url`, `isDraft` and `createdAt
|
|
4971
|
+
* Writes the review request as JSON: `reference`, `title`, `url`, `isDraft` and `createdAt`, and `account` when it isn't null.
|
|
4901
4972
|
*
|
|
4902
4973
|
* @returns The JSON.
|
|
4903
4974
|
* @example
|
|
@@ -5087,3 +5158,423 @@ export declare class HostReviewRequestList {
|
|
|
5087
5158
|
*/
|
|
5088
5159
|
public toJson(): JsonObject;
|
|
5089
5160
|
}
|
|
5161
|
+
|
|
5162
|
+
/**
|
|
5163
|
+
* One of the accounts a module keeps, by its id, for a sign-in method that acts on one account.
|
|
5164
|
+
*
|
|
5165
|
+
* @example
|
|
5166
|
+
* ```ts
|
|
5167
|
+
* import { AccountQuery } from "@noldova/git.hosting.protocol";
|
|
5168
|
+
*
|
|
5169
|
+
* const query = new AccountQuery(2);
|
|
5170
|
+
* ```
|
|
5171
|
+
*/
|
|
5172
|
+
export declare class AccountQuery {
|
|
5173
|
+
/**
|
|
5174
|
+
* The account's id, which the module gave it when it was added; the first account is 1.
|
|
5175
|
+
*/
|
|
5176
|
+
public readonly account: number;
|
|
5177
|
+
|
|
5178
|
+
/**
|
|
5179
|
+
* Makes the query from its parts.
|
|
5180
|
+
*
|
|
5181
|
+
* @param account The account's id, a positive whole number.
|
|
5182
|
+
* @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.
|
|
5183
|
+
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `account`.
|
|
5184
|
+
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.account`.
|
|
5185
|
+
* @example
|
|
5186
|
+
* ```ts
|
|
5187
|
+
* import { AccountQuery } from "@noldova/git.hosting.protocol";
|
|
5188
|
+
*
|
|
5189
|
+
* const query = new AccountQuery(1);
|
|
5190
|
+
* ```
|
|
5191
|
+
*/
|
|
5192
|
+
public constructor(account: number, reader?: JsonReader);
|
|
5193
|
+
|
|
5194
|
+
/**
|
|
5195
|
+
* Reads it from its JSON.
|
|
5196
|
+
*
|
|
5197
|
+
* @param value The JSON, with exactly the fields `toJson` writes.
|
|
5198
|
+
* @param path The JSON's path, `$` by default.
|
|
5199
|
+
* @returns The query.
|
|
5200
|
+
* @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`.
|
|
5201
|
+
* @throws {HostingFieldException} When the value holds an unknown field, or a field is out of its range.
|
|
5202
|
+
* @example
|
|
5203
|
+
* ```ts
|
|
5204
|
+
* import { AccountQuery } from "@noldova/git.hosting.protocol";
|
|
5205
|
+
*
|
|
5206
|
+
* const query = AccountQuery.fromJson({ account: 2 });
|
|
5207
|
+
* ```
|
|
5208
|
+
*/
|
|
5209
|
+
public static fromJson(value: unknown, path?: string): AccountQuery;
|
|
5210
|
+
|
|
5211
|
+
/**
|
|
5212
|
+
* Writes it as JSON: `account`.
|
|
5213
|
+
*
|
|
5214
|
+
* @returns The JSON.
|
|
5215
|
+
* @example
|
|
5216
|
+
* ```ts
|
|
5217
|
+
* import { AccountQuery } from "@noldova/git.hosting.protocol";
|
|
5218
|
+
*
|
|
5219
|
+
* console.log(AccountQuery.fromJson({ account: 2 }).toJson());
|
|
5220
|
+
* ```
|
|
5221
|
+
*/
|
|
5222
|
+
public toJson(): JsonObject;
|
|
5223
|
+
}
|
|
5224
|
+
|
|
5225
|
+
/**
|
|
5226
|
+
* One account a module keeps: its id, its sign-in and, for a host that has several, where it signs in.
|
|
5227
|
+
*
|
|
5228
|
+
* @example
|
|
5229
|
+
* ```ts
|
|
5230
|
+
* import { HostAccountEntry, HostSignIn } from "@noldova/git.hosting.protocol";
|
|
5231
|
+
*
|
|
5232
|
+
* const entry = new HostAccountEntry(2, HostSignIn.signedOut());
|
|
5233
|
+
* ```
|
|
5234
|
+
*/
|
|
5235
|
+
export declare class HostAccountEntry {
|
|
5236
|
+
/**
|
|
5237
|
+
* The account's id, which the module gave it when it was added; the first account is 1.
|
|
5238
|
+
*/
|
|
5239
|
+
public readonly id: number;
|
|
5240
|
+
|
|
5241
|
+
/**
|
|
5242
|
+
* The account's sign-in: waiting with its device code, signed in with its login, or signed out.
|
|
5243
|
+
*/
|
|
5244
|
+
public readonly signIn: HostSignIn;
|
|
5245
|
+
|
|
5246
|
+
/**
|
|
5247
|
+
* Where the account signs in, as a remote's address is matched against it: a lowercase host name, with its port or a path if it has one, and no
|
|
5248
|
+
* scheme, user name or trailing `/`, such as `dev.azure.com/fabrikam` for an Azure DevOps organization or `github.example.com` for a GitHub
|
|
5249
|
+
* Enterprise server; null for a host with one place, such as github.com. It never holds a token or a user name.
|
|
5250
|
+
*/
|
|
5251
|
+
public readonly place: string | null;
|
|
5252
|
+
|
|
5253
|
+
/**
|
|
5254
|
+
* Makes the entry from its parts.
|
|
5255
|
+
*
|
|
5256
|
+
* @param id The account's id, a positive whole number.
|
|
5257
|
+
* @param signIn The account's sign-in.
|
|
5258
|
+
* @param place Where the account signs in, or null, the default, for a host with one place.
|
|
5259
|
+
* @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.
|
|
5260
|
+
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `account`.
|
|
5261
|
+
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.account`.
|
|
5262
|
+
* @example
|
|
5263
|
+
* ```ts
|
|
5264
|
+
* import { HostAccount, HostAccountEntry, HostSignIn } from "@noldova/git.hosting.protocol";
|
|
5265
|
+
*
|
|
5266
|
+
* const entry = new HostAccountEntry(1, HostSignIn.signedIn(new HostAccount("octocat", null, null, ["repo"])));
|
|
5267
|
+
* ```
|
|
5268
|
+
*/
|
|
5269
|
+
public constructor(id: number, signIn: HostSignIn, place?: string | null, reader?: JsonReader);
|
|
5270
|
+
|
|
5271
|
+
/**
|
|
5272
|
+
* Reads it from its JSON.
|
|
5273
|
+
*
|
|
5274
|
+
* @param value The JSON, with exactly the fields `toJson` writes.
|
|
5275
|
+
* @param path The JSON's path, `$` by default.
|
|
5276
|
+
* @returns The entry.
|
|
5277
|
+
* @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`.
|
|
5278
|
+
* @throws {HostingFieldException} When the value holds an unknown field, or a field is out of its range.
|
|
5279
|
+
* @example
|
|
5280
|
+
* ```ts
|
|
5281
|
+
* import { HostAccountEntry } from "@noldova/git.hosting.protocol";
|
|
5282
|
+
*
|
|
5283
|
+
* const entry = HostAccountEntry.fromJson({ id: 2, signIn: { state: "SignedOut", deviceCode: null, account: null, failure: null } });
|
|
5284
|
+
* ```
|
|
5285
|
+
*/
|
|
5286
|
+
public static fromJson(value: unknown, path?: string): HostAccountEntry;
|
|
5287
|
+
|
|
5288
|
+
/**
|
|
5289
|
+
* Writes it as JSON: `id` and `signIn`, and `place` when it isn't null.
|
|
5290
|
+
*
|
|
5291
|
+
* @returns The JSON.
|
|
5292
|
+
* @example
|
|
5293
|
+
* ```ts
|
|
5294
|
+
* import { HostAccountEntry } from "@noldova/git.hosting.protocol";
|
|
5295
|
+
*
|
|
5296
|
+
* console.log(HostAccountEntry.fromJson({ id: 2, signIn: { state: "SignedOut", deviceCode: null, account: null, failure: null } }).toJson());
|
|
5297
|
+
* ```
|
|
5298
|
+
*/
|
|
5299
|
+
public toJson(): JsonObject;
|
|
5300
|
+
}
|
|
5301
|
+
|
|
5302
|
+
/**
|
|
5303
|
+
* Every account a module keeps on this computer, the first account first.
|
|
5304
|
+
*
|
|
5305
|
+
* @example
|
|
5306
|
+
* ```ts
|
|
5307
|
+
* import { HostAccountList } from "@noldova/git.hosting.protocol";
|
|
5308
|
+
*
|
|
5309
|
+
* const list = new HostAccountList([]);
|
|
5310
|
+
* ```
|
|
5311
|
+
*/
|
|
5312
|
+
export declare class HostAccountList {
|
|
5313
|
+
/**
|
|
5314
|
+
* The accounts, each id once, the first account first and the others in the order they were added.
|
|
5315
|
+
*/
|
|
5316
|
+
public readonly accounts: readonly HostAccountEntry[];
|
|
5317
|
+
|
|
5318
|
+
/**
|
|
5319
|
+
* Makes the list from its parts.
|
|
5320
|
+
*
|
|
5321
|
+
* @param accounts The accounts, each id once.
|
|
5322
|
+
* @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.
|
|
5323
|
+
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `account`.
|
|
5324
|
+
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.account`.
|
|
5325
|
+
* @example
|
|
5326
|
+
* ```ts
|
|
5327
|
+
* import { HostAccountEntry, HostAccountList, HostSignIn } from "@noldova/git.hosting.protocol";
|
|
5328
|
+
*
|
|
5329
|
+
* const list = new HostAccountList([new HostAccountEntry(1, HostSignIn.signedOut())]);
|
|
5330
|
+
* ```
|
|
5331
|
+
*/
|
|
5332
|
+
public constructor(accounts: readonly HostAccountEntry[], reader?: JsonReader);
|
|
5333
|
+
|
|
5334
|
+
/**
|
|
5335
|
+
* Reads it from its JSON.
|
|
5336
|
+
*
|
|
5337
|
+
* @param value The JSON, with exactly the fields `toJson` writes.
|
|
5338
|
+
* @param path The JSON's path, `$` by default.
|
|
5339
|
+
* @returns The list.
|
|
5340
|
+
* @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`.
|
|
5341
|
+
* @throws {HostingFieldException} When the value holds an unknown field, or a field is out of its range.
|
|
5342
|
+
* @example
|
|
5343
|
+
* ```ts
|
|
5344
|
+
* import { HostAccountList } from "@noldova/git.hosting.protocol";
|
|
5345
|
+
*
|
|
5346
|
+
* const list = HostAccountList.fromJson({ accounts: [] });
|
|
5347
|
+
* ```
|
|
5348
|
+
*/
|
|
5349
|
+
public static fromJson(value: unknown, path?: string): HostAccountList;
|
|
5350
|
+
|
|
5351
|
+
/**
|
|
5352
|
+
* Writes it as JSON: `accounts`.
|
|
5353
|
+
*
|
|
5354
|
+
* @returns The JSON.
|
|
5355
|
+
* @example
|
|
5356
|
+
* ```ts
|
|
5357
|
+
* import { HostAccountList } from "@noldova/git.hosting.protocol";
|
|
5358
|
+
*
|
|
5359
|
+
* console.log(HostAccountList.fromJson({ accounts: [] }).toJson());
|
|
5360
|
+
* ```
|
|
5361
|
+
*/
|
|
5362
|
+
public toJson(): JsonObject;
|
|
5363
|
+
}
|
|
5364
|
+
|
|
5365
|
+
/**
|
|
5366
|
+
* The account a person chose for a repository, which the module remembers on this computer.
|
|
5367
|
+
*
|
|
5368
|
+
* @example
|
|
5369
|
+
* ```ts
|
|
5370
|
+
* import { AccountPick } from "@noldova/git.hosting.protocol";
|
|
5371
|
+
*
|
|
5372
|
+
* const pick = new AccountPick("github.com", "octocat/hello-world", 2);
|
|
5373
|
+
* ```
|
|
5374
|
+
*/
|
|
5375
|
+
export declare class AccountPick {
|
|
5376
|
+
/**
|
|
5377
|
+
* The host the repository is on, such as `github.com`.
|
|
5378
|
+
*/
|
|
5379
|
+
public readonly host: string;
|
|
5380
|
+
|
|
5381
|
+
/**
|
|
5382
|
+
* The repository's path on the host, such as `octocat/hello-world`.
|
|
5383
|
+
*/
|
|
5384
|
+
public readonly path: string;
|
|
5385
|
+
|
|
5386
|
+
/**
|
|
5387
|
+
* The chosen account's id.
|
|
5388
|
+
*/
|
|
5389
|
+
public readonly account: number;
|
|
5390
|
+
|
|
5391
|
+
/**
|
|
5392
|
+
* Makes the pick from its parts.
|
|
5393
|
+
*
|
|
5394
|
+
* @param host The host, which isn't blank.
|
|
5395
|
+
* @param path The repository's path, as `RepositoryQuery` takes it.
|
|
5396
|
+
* @param account The account's id, a positive whole number.
|
|
5397
|
+
* @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.
|
|
5398
|
+
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `account`.
|
|
5399
|
+
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.account`.
|
|
5400
|
+
* @example
|
|
5401
|
+
* ```ts
|
|
5402
|
+
* import { AccountPick } from "@noldova/git.hosting.protocol";
|
|
5403
|
+
*
|
|
5404
|
+
* const pick = new AccountPick("github.com", "octocat/hello-world", 1);
|
|
5405
|
+
* ```
|
|
5406
|
+
*/
|
|
5407
|
+
public constructor(host: string, path: string, account: number, reader?: JsonReader);
|
|
5408
|
+
|
|
5409
|
+
/**
|
|
5410
|
+
* Reads it from its JSON.
|
|
5411
|
+
*
|
|
5412
|
+
* @param value The JSON, with exactly the fields `toJson` writes.
|
|
5413
|
+
* @param path The JSON's path, `$` by default.
|
|
5414
|
+
* @returns The pick.
|
|
5415
|
+
* @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`.
|
|
5416
|
+
* @throws {HostingFieldException} When the value holds an unknown field, or a field is out of its range.
|
|
5417
|
+
* @example
|
|
5418
|
+
* ```ts
|
|
5419
|
+
* import { AccountPick } from "@noldova/git.hosting.protocol";
|
|
5420
|
+
*
|
|
5421
|
+
* const pick = AccountPick.fromJson({ host: "github.com", path: "octocat/hello-world", account: 2 });
|
|
5422
|
+
* ```
|
|
5423
|
+
*/
|
|
5424
|
+
public static fromJson(value: unknown, path?: string): AccountPick;
|
|
5425
|
+
|
|
5426
|
+
/**
|
|
5427
|
+
* Writes it as JSON: `host`, `path` and `account`.
|
|
5428
|
+
*
|
|
5429
|
+
* @returns The JSON.
|
|
5430
|
+
* @example
|
|
5431
|
+
* ```ts
|
|
5432
|
+
* import { AccountPick } from "@noldova/git.hosting.protocol";
|
|
5433
|
+
*
|
|
5434
|
+
* console.log(AccountPick.fromJson({ host: "github.com", path: "octocat/hello-world", account: 2 }).toJson());
|
|
5435
|
+
* ```
|
|
5436
|
+
*/
|
|
5437
|
+
public toJson(): JsonObject;
|
|
5438
|
+
}
|
|
5439
|
+
|
|
5440
|
+
/**
|
|
5441
|
+
* A repository folder and the name of the remote a window shows for it, which a window sends a host module once, before its first read for
|
|
5442
|
+
* that remote, so the module's main process can read the remote's user name there and choose the account by it. The user name itself never
|
|
5443
|
+
* leaves the main process: it is in no model, answer or log.
|
|
5444
|
+
*
|
|
5445
|
+
* @example
|
|
5446
|
+
* ```ts
|
|
5447
|
+
* import { FolderQuery } from "@noldova/git.hosting.protocol";
|
|
5448
|
+
*
|
|
5449
|
+
* const query = new FolderQuery("/work/hello-world", "origin");
|
|
5450
|
+
* ```
|
|
5451
|
+
*/
|
|
5452
|
+
export declare class FolderQuery {
|
|
5453
|
+
/**
|
|
5454
|
+
* The repository's folder, as the Git module names it; untrusted.
|
|
5455
|
+
*/
|
|
5456
|
+
public readonly folder: string;
|
|
5457
|
+
|
|
5458
|
+
/**
|
|
5459
|
+
* The name of the remote, such as `origin`; untrusted.
|
|
5460
|
+
*/
|
|
5461
|
+
public readonly remote: string;
|
|
5462
|
+
|
|
5463
|
+
/**
|
|
5464
|
+
* Makes the query from its parts.
|
|
5465
|
+
*
|
|
5466
|
+
* @param folder The repository's folder, not blank.
|
|
5467
|
+
* @param remote The remote's name, not blank.
|
|
5468
|
+
* @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.
|
|
5469
|
+
* @throws {HostingArgumentException} Without a reader, when a part is blank, naming the field as the parameter, such as `folder`.
|
|
5470
|
+
* @throws {HostingFieldException} With a reader, when a part is blank, naming the field by its path, such as `$.remote`.
|
|
5471
|
+
* @example
|
|
5472
|
+
* ```ts
|
|
5473
|
+
* import { FolderQuery } from "@noldova/git.hosting.protocol";
|
|
5474
|
+
*
|
|
5475
|
+
* const query = new FolderQuery("/work/hello-world", "upstream");
|
|
5476
|
+
* ```
|
|
5477
|
+
*/
|
|
5478
|
+
public constructor(folder: string, remote: string, reader?: JsonReader);
|
|
5479
|
+
|
|
5480
|
+
/**
|
|
5481
|
+
* Reads it from its JSON.
|
|
5482
|
+
*
|
|
5483
|
+
* @param value The JSON, with exactly the fields `toJson` writes.
|
|
5484
|
+
* @param path The JSON's path, `$` by default.
|
|
5485
|
+
* @returns The query.
|
|
5486
|
+
* @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`.
|
|
5487
|
+
* @throws {HostingFieldException} When the value holds an unknown field, or a field is blank.
|
|
5488
|
+
* @example
|
|
5489
|
+
* ```ts
|
|
5490
|
+
* import { FolderQuery } from "@noldova/git.hosting.protocol";
|
|
5491
|
+
*
|
|
5492
|
+
* const query = FolderQuery.fromJson({ folder: "/work/hello-world", remote: "origin" });
|
|
5493
|
+
* ```
|
|
5494
|
+
*/
|
|
5495
|
+
public static fromJson(value: unknown, path?: string): FolderQuery;
|
|
5496
|
+
|
|
5497
|
+
/**
|
|
5498
|
+
* Writes it as JSON: `folder` and `remote`.
|
|
5499
|
+
*
|
|
5500
|
+
* @returns The JSON.
|
|
5501
|
+
* @example
|
|
5502
|
+
* ```ts
|
|
5503
|
+
* import { FolderQuery } from "@noldova/git.hosting.protocol";
|
|
5504
|
+
*
|
|
5505
|
+
* console.log(new FolderQuery("/work/hello-world", "origin").toJson());
|
|
5506
|
+
* ```
|
|
5507
|
+
*/
|
|
5508
|
+
public toJson(): JsonObject;
|
|
5509
|
+
}
|
|
5510
|
+
|
|
5511
|
+
/**
|
|
5512
|
+
* The account a module reads a repository with, or none when no account kept is signed in.
|
|
5513
|
+
*
|
|
5514
|
+
* @example
|
|
5515
|
+
* ```ts
|
|
5516
|
+
* import { RepositoryAccount } from "@noldova/git.hosting.protocol";
|
|
5517
|
+
*
|
|
5518
|
+
* const none = new RepositoryAccount(null);
|
|
5519
|
+
* ```
|
|
5520
|
+
*/
|
|
5521
|
+
export declare class RepositoryAccount {
|
|
5522
|
+
/**
|
|
5523
|
+
* The account's id, or null when no account kept is signed in.
|
|
5524
|
+
*/
|
|
5525
|
+
public readonly account: number | null;
|
|
5526
|
+
|
|
5527
|
+
/**
|
|
5528
|
+
* Whether the user name in the repository's remote address chose the account, so picking another one for that repository changes nothing.
|
|
5529
|
+
* It never carries the user name.
|
|
5530
|
+
*/
|
|
5531
|
+
public readonly isNamedByRemote: boolean;
|
|
5532
|
+
|
|
5533
|
+
/**
|
|
5534
|
+
* Makes the answer from its parts.
|
|
5535
|
+
*
|
|
5536
|
+
* @param account The account's id, a positive whole number, or null.
|
|
5537
|
+
* @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.
|
|
5538
|
+
* @param isNamedByRemote Whether the remote's user name chose the account, false by default; true needs an account.
|
|
5539
|
+
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `account`.
|
|
5540
|
+
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.account`.
|
|
5541
|
+
* @example
|
|
5542
|
+
* ```ts
|
|
5543
|
+
* import { RepositoryAccount } from "@noldova/git.hosting.protocol";
|
|
5544
|
+
*
|
|
5545
|
+
* const answer = new RepositoryAccount(2);
|
|
5546
|
+
* const named = new RepositoryAccount(2, undefined, true);
|
|
5547
|
+
* ```
|
|
5548
|
+
*/
|
|
5549
|
+
public constructor(account: number | null, reader?: JsonReader, isNamedByRemote?: boolean);
|
|
5550
|
+
|
|
5551
|
+
/**
|
|
5552
|
+
* Reads it from its JSON.
|
|
5553
|
+
*
|
|
5554
|
+
* @param value The JSON, with exactly the fields `toJson` writes.
|
|
5555
|
+
* @param path The JSON's path, `$` by default.
|
|
5556
|
+
* @returns The answer.
|
|
5557
|
+
* @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`.
|
|
5558
|
+
* @throws {HostingFieldException} When the value holds an unknown field, or a field is out of its range.
|
|
5559
|
+
* @example
|
|
5560
|
+
* ```ts
|
|
5561
|
+
* import { RepositoryAccount } from "@noldova/git.hosting.protocol";
|
|
5562
|
+
*
|
|
5563
|
+
* const answer = RepositoryAccount.fromJson({ account: 1 });
|
|
5564
|
+
* ```
|
|
5565
|
+
*/
|
|
5566
|
+
public static fromJson(value: unknown, path?: string): RepositoryAccount;
|
|
5567
|
+
|
|
5568
|
+
/**
|
|
5569
|
+
* Writes it as JSON: `account`.
|
|
5570
|
+
*
|
|
5571
|
+
* @returns The JSON.
|
|
5572
|
+
* @example
|
|
5573
|
+
* ```ts
|
|
5574
|
+
* import { RepositoryAccount } from "@noldova/git.hosting.protocol";
|
|
5575
|
+
*
|
|
5576
|
+
* console.log(RepositoryAccount.fromJson({ account: 1 }).toJson());
|
|
5577
|
+
* ```
|
|
5578
|
+
*/
|
|
5579
|
+
public toJson(): JsonObject;
|
|
5580
|
+
}
|
package/src/api/index.js
CHANGED
|
@@ -21,12 +21,17 @@ export { WorkItemScope } from "../enums/work-item-scope.js";
|
|
|
21
21
|
export { HostingArgumentException } from "../exceptions/hosting-argument.exception.js";
|
|
22
22
|
export { HostingFieldException } from "../exceptions/hosting-field.exception.js";
|
|
23
23
|
export { HostingProtocolException } from "../exceptions/hosting-protocol.exception.js";
|
|
24
|
+
export { AccountPick } from "../models/account-pick.js";
|
|
25
|
+
export { AccountQuery } from "../models/account-query.js";
|
|
24
26
|
export { AuthorQuery } from "../models/author-query.js";
|
|
25
27
|
export { BranchPullRequest } from "../models/branch-pull-request.js";
|
|
26
28
|
export { BranchQuery } from "../models/branch-query.js";
|
|
27
29
|
export { CommitQuery } from "../models/commit-query.js";
|
|
28
30
|
export { DeviceCode } from "../models/device-code.js";
|
|
31
|
+
export { FolderQuery } from "../models/folder-query.js";
|
|
29
32
|
export { HostAccount } from "../models/host-account.js";
|
|
33
|
+
export { HostAccountEntry } from "../models/host-account-entry.js";
|
|
34
|
+
export { HostAccountList } from "../models/host-account-list.js";
|
|
30
35
|
export { HostAvatar } from "../models/host-avatar.js";
|
|
31
36
|
export { HostBuild } from "../models/host-build.js";
|
|
32
37
|
export { HostCapabilities } from "../models/host-capabilities.js";
|
|
@@ -64,6 +69,7 @@ export { HostWorkItem } from "../models/host-work-item.js";
|
|
|
64
69
|
export { HostingNames } from "../models/hosting-names.js";
|
|
65
70
|
export { PersonQuery } from "../models/person-query.js";
|
|
66
71
|
export { PullRequestDraft } from "../models/pull-request-draft.js";
|
|
72
|
+
export { RepositoryAccount } from "../models/repository-account.js";
|
|
67
73
|
export { RepositoryQuery } from "../models/repository-query.js";
|
|
68
74
|
export { WorkItemQuery } from "../models/work-item-query.js";
|
|
69
75
|
export { WorkItemUpdate } from "../models/work-item-update.js";
|
|
@@ -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 AccountPick {
|
|
12
|
+
static FIELDS = [Resources.hostField, Resources.pathField, Resources.accountField];
|
|
13
|
+
host;
|
|
14
|
+
path;
|
|
15
|
+
account;
|
|
16
|
+
constructor(host, path, account, reader) {
|
|
17
|
+
FieldCheck.requireText(host, Resources.hostField, reader);
|
|
18
|
+
FieldCheck.requirePath(path, Resources.pathField, reader);
|
|
19
|
+
FieldCheck.requirePositive(account, Resources.accountField, reader);
|
|
20
|
+
this.host = host;
|
|
21
|
+
this.path = path;
|
|
22
|
+
this.account = account;
|
|
23
|
+
}
|
|
24
|
+
static fromJson(value, path) {
|
|
25
|
+
const reader = JsonReader.fromValue(value, path);
|
|
26
|
+
FieldCheck.refuseUnknownFields(reader, AccountPick.FIELDS);
|
|
27
|
+
return new AccountPick(reader.readString(Resources.hostField), reader.readString(Resources.pathField), reader.readInteger(Resources.accountField), reader);
|
|
28
|
+
}
|
|
29
|
+
toJson() {
|
|
30
|
+
return { [Resources.hostField]: this.host, [Resources.pathField]: this.path, [Resources.accountField]: this.account };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 AccountQuery {
|
|
12
|
+
static FIELDS = [Resources.accountField];
|
|
13
|
+
account;
|
|
14
|
+
constructor(account, reader) {
|
|
15
|
+
FieldCheck.requirePositive(account, Resources.accountField, reader);
|
|
16
|
+
this.account = account;
|
|
17
|
+
}
|
|
18
|
+
static fromJson(value, path) {
|
|
19
|
+
const reader = JsonReader.fromValue(value, path);
|
|
20
|
+
FieldCheck.refuseUnknownFields(reader, AccountQuery.FIELDS);
|
|
21
|
+
return new AccountQuery(reader.readInteger(Resources.accountField), reader);
|
|
22
|
+
}
|
|
23
|
+
toJson() {
|
|
24
|
+
return { [Resources.accountField]: this.account };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -61,6 +61,10 @@ export class FieldCheck {
|
|
|
61
61
|
if (payload === undefined || payload.length === 0 || payload.length > Resources.maximumAvatarLength)
|
|
62
62
|
FieldCheck.fail(field, Resources.avatarExpected, reader);
|
|
63
63
|
}
|
|
64
|
+
static requirePlace(value, field, reader) {
|
|
65
|
+
if (!Resources.placePattern.test(value))
|
|
66
|
+
FieldCheck.fail(field, Resources.placeExpected, reader);
|
|
67
|
+
}
|
|
64
68
|
static requireHttps(value, field, reader) {
|
|
65
69
|
const url = URL.parse(value);
|
|
66
70
|
if (url === null || url.protocol !== Resources.httpsProtocol || url.username.length > 0 || url.password.length > 0)
|
|
@@ -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 FolderQuery {
|
|
12
|
+
static FIELDS = [Resources.folderField, Resources.remoteField];
|
|
13
|
+
folder;
|
|
14
|
+
remote;
|
|
15
|
+
constructor(folder, remote, reader) {
|
|
16
|
+
FieldCheck.requireText(folder, Resources.folderField, reader);
|
|
17
|
+
FieldCheck.requireText(remote, Resources.remoteField, reader);
|
|
18
|
+
this.folder = folder;
|
|
19
|
+
this.remote = remote;
|
|
20
|
+
}
|
|
21
|
+
static fromJson(value, path) {
|
|
22
|
+
const reader = JsonReader.fromValue(value, path);
|
|
23
|
+
FieldCheck.refuseUnknownFields(reader, FolderQuery.FIELDS);
|
|
24
|
+
return new FolderQuery(reader.readString(Resources.folderField), reader.readString(Resources.remoteField), reader);
|
|
25
|
+
}
|
|
26
|
+
toJson() {
|
|
27
|
+
return { [Resources.folderField]: this.folder, [Resources.remoteField]: this.remote };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -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
|
+
import { HostSignIn } from "./host-sign-in.js";
|
|
12
|
+
export class HostAccountEntry {
|
|
13
|
+
static FIELDS = [Resources.idField, Resources.signInField, Resources.placeField];
|
|
14
|
+
id;
|
|
15
|
+
signIn;
|
|
16
|
+
place;
|
|
17
|
+
constructor(id, signIn, place = null, reader) {
|
|
18
|
+
FieldCheck.requirePositive(id, Resources.idField, reader);
|
|
19
|
+
if (place !== null)
|
|
20
|
+
FieldCheck.requirePlace(place, Resources.placeField, reader);
|
|
21
|
+
this.id = id;
|
|
22
|
+
this.signIn = signIn;
|
|
23
|
+
this.place = place;
|
|
24
|
+
}
|
|
25
|
+
static fromJson(value, path) {
|
|
26
|
+
const reader = JsonReader.fromValue(value, path);
|
|
27
|
+
FieldCheck.refuseUnknownFields(reader, HostAccountEntry.FIELDS);
|
|
28
|
+
const signIn = reader.readObject(Resources.signInField);
|
|
29
|
+
return new HostAccountEntry(reader.readInteger(Resources.idField), HostSignIn.fromJson(signIn.toJson(), signIn.path), reader.hasField(Resources.placeField) ? reader.readNullableString(Resources.placeField) : null, reader);
|
|
30
|
+
}
|
|
31
|
+
toJson() {
|
|
32
|
+
return {
|
|
33
|
+
[Resources.idField]: this.id, [Resources.signInField]: this.signIn.toJson(),
|
|
34
|
+
...(this.place === null ? {} : { [Resources.placeField]: this.place })
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -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 { HostAccountEntry } from "./host-account-entry.js";
|
|
12
|
+
export class HostAccountList {
|
|
13
|
+
static FIELDS = [Resources.accountsField];
|
|
14
|
+
accounts;
|
|
15
|
+
constructor(accounts, reader) {
|
|
16
|
+
if (new Set(accounts.map(t => t.id)).size !== accounts.length)
|
|
17
|
+
FieldCheck.fail(Resources.accountsField, Resources.accountIdsExpected, reader);
|
|
18
|
+
this.accounts = [...accounts];
|
|
19
|
+
}
|
|
20
|
+
static fromJson(value, path) {
|
|
21
|
+
const reader = JsonReader.fromValue(value, path);
|
|
22
|
+
FieldCheck.refuseUnknownFields(reader, HostAccountList.FIELDS);
|
|
23
|
+
return new HostAccountList(reader.readObjectArray(Resources.accountsField).map(t => HostAccountEntry.fromJson(t.toJson(), t.path)), reader);
|
|
24
|
+
}
|
|
25
|
+
toJson() {
|
|
26
|
+
return { [Resources.accountsField]: this.accounts.map(t => t.toJson()) };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -9,20 +9,24 @@ import { JsonReader } from "@noldova/context.json";
|
|
|
9
9
|
import { Resources } from "../resources.js";
|
|
10
10
|
import { FieldCheck } from "./field-check.js";
|
|
11
11
|
export class HostReference {
|
|
12
|
-
static FIELDS = [Resources.hostField, Resources.ownerField, Resources.repositoryField, Resources.numberField];
|
|
12
|
+
static FIELDS = [Resources.hostField, Resources.ownerField, Resources.repositoryField, Resources.numberField, Resources.placeField];
|
|
13
13
|
host;
|
|
14
14
|
owner;
|
|
15
15
|
repository;
|
|
16
16
|
number;
|
|
17
|
-
|
|
17
|
+
place;
|
|
18
|
+
constructor(host, owner, repository, number, reader, place = null) {
|
|
18
19
|
FieldCheck.requireText(host, Resources.hostField, reader);
|
|
19
20
|
FieldCheck.requirePath(owner, Resources.ownerField, reader);
|
|
20
21
|
FieldCheck.requireName(repository, Resources.repositoryField, reader);
|
|
21
22
|
FieldCheck.requirePositive(number, Resources.numberField, reader);
|
|
23
|
+
if (place !== null)
|
|
24
|
+
FieldCheck.requirePlace(place, Resources.placeField, reader);
|
|
22
25
|
this.host = host;
|
|
23
26
|
this.owner = owner;
|
|
24
27
|
this.repository = repository;
|
|
25
28
|
this.number = number;
|
|
29
|
+
this.place = place;
|
|
26
30
|
}
|
|
27
31
|
get text() {
|
|
28
32
|
return Resources.formatReference(this.owner, this.repository, this.number);
|
|
@@ -30,14 +34,15 @@ export class HostReference {
|
|
|
30
34
|
static fromJson(value, path) {
|
|
31
35
|
const reader = JsonReader.fromValue(value, path);
|
|
32
36
|
FieldCheck.refuseUnknownFields(reader, HostReference.FIELDS);
|
|
33
|
-
return new HostReference(reader.readString(Resources.hostField), reader.readString(Resources.ownerField), reader.readString(Resources.repositoryField), reader.readInteger(Resources.numberField), reader);
|
|
37
|
+
return new HostReference(reader.readString(Resources.hostField), reader.readString(Resources.ownerField), reader.readString(Resources.repositoryField), reader.readInteger(Resources.numberField), reader, reader.hasField(Resources.placeField) ? reader.readNullableString(Resources.placeField) : null);
|
|
34
38
|
}
|
|
35
39
|
toJson() {
|
|
36
40
|
return {
|
|
37
41
|
[Resources.hostField]: this.host,
|
|
38
42
|
[Resources.ownerField]: this.owner,
|
|
39
43
|
[Resources.repositoryField]: this.repository,
|
|
40
|
-
[Resources.numberField]: this.number
|
|
44
|
+
[Resources.numberField]: this.number,
|
|
45
|
+
...(this.place === null ? {} : { [Resources.placeField]: this.place })
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
}
|
|
@@ -11,27 +11,31 @@ import { FieldCheck } from "./field-check.js";
|
|
|
11
11
|
import { HostReference } from "./host-reference.js";
|
|
12
12
|
export class HostReviewRequest {
|
|
13
13
|
static FIELDS = [Resources.referenceField, Resources.titleField, Resources.urlField, Resources.isDraftField,
|
|
14
|
-
Resources.createdAtField];
|
|
14
|
+
Resources.createdAtField, Resources.accountField];
|
|
15
15
|
reference;
|
|
16
16
|
title;
|
|
17
17
|
url;
|
|
18
18
|
isDraft;
|
|
19
19
|
createdAt;
|
|
20
|
-
|
|
20
|
+
account;
|
|
21
|
+
constructor(reference, title, url, isDraft, createdAt, account = null, reader) {
|
|
21
22
|
FieldCheck.requireText(title, Resources.titleField, reader);
|
|
22
23
|
FieldCheck.requireHttps(url, Resources.urlField, reader);
|
|
23
24
|
FieldCheck.requirePositive(createdAt, Resources.createdAtField, reader);
|
|
25
|
+
if (account !== null)
|
|
26
|
+
FieldCheck.requireText(account, Resources.accountField, reader);
|
|
24
27
|
this.reference = reference;
|
|
25
28
|
this.title = title;
|
|
26
29
|
this.url = url;
|
|
27
30
|
this.isDraft = isDraft;
|
|
28
31
|
this.createdAt = createdAt;
|
|
32
|
+
this.account = account;
|
|
29
33
|
}
|
|
30
34
|
static fromJson(value, path) {
|
|
31
35
|
const reader = JsonReader.fromValue(value, path);
|
|
32
36
|
FieldCheck.refuseUnknownFields(reader, HostReviewRequest.FIELDS);
|
|
33
37
|
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);
|
|
38
|
+
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.hasField(Resources.accountField) ? reader.readNullableString(Resources.accountField) : null, reader);
|
|
35
39
|
}
|
|
36
40
|
toJson() {
|
|
37
41
|
return {
|
|
@@ -39,7 +43,8 @@ export class HostReviewRequest {
|
|
|
39
43
|
[Resources.titleField]: this.title,
|
|
40
44
|
[Resources.urlField]: this.url,
|
|
41
45
|
[Resources.isDraftField]: this.isDraft,
|
|
42
|
-
[Resources.createdAtField]: this.createdAt
|
|
46
|
+
[Resources.createdAtField]: this.createdAt,
|
|
47
|
+
...(this.account === null ? {} : { [Resources.accountField]: this.account })
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
}
|
|
@@ -13,7 +13,7 @@ import { HostWorkItem } from "./host-work-item.js";
|
|
|
13
13
|
export class HostWorkItemDetail {
|
|
14
14
|
static FIELDS = [Resources.itemField, Resources.pointsField, Resources.remainingField, Resources.completedField,
|
|
15
15
|
Resources.orderField, Resources.acceptanceField, Resources.childrenField, Resources.pullRequestsField, Resources.commitsField, Resources.branchesField,
|
|
16
|
-
Resources.isWaitingField];
|
|
16
|
+
Resources.isWaitingField, Resources.accountField];
|
|
17
17
|
item;
|
|
18
18
|
points;
|
|
19
19
|
remaining;
|
|
@@ -25,7 +25,8 @@ export class HostWorkItemDetail {
|
|
|
25
25
|
commits;
|
|
26
26
|
branches;
|
|
27
27
|
isWaiting;
|
|
28
|
-
|
|
28
|
+
account;
|
|
29
|
+
constructor(item, points, remaining, completed, order, acceptance, children, pullRequests, commits, branches, isWaiting = null, account = null, reader) {
|
|
29
30
|
HostWorkItemDetail.requireAmount(points, Resources.pointsField, reader);
|
|
30
31
|
HostWorkItemDetail.requireAmount(remaining, Resources.remainingField, reader);
|
|
31
32
|
HostWorkItemDetail.requireAmount(completed, Resources.completedField, reader);
|
|
@@ -40,6 +41,8 @@ export class HostWorkItemDetail {
|
|
|
40
41
|
FieldCheck.requireCount(commits, Resources.commitsField, reader);
|
|
41
42
|
for (const branch of branches)
|
|
42
43
|
FieldCheck.requireText(branch, Resources.branchesField, reader);
|
|
44
|
+
if (account !== null)
|
|
45
|
+
FieldCheck.requireText(account, Resources.accountField, reader);
|
|
43
46
|
this.item = item;
|
|
44
47
|
this.points = points;
|
|
45
48
|
this.remaining = remaining;
|
|
@@ -51,12 +54,13 @@ export class HostWorkItemDetail {
|
|
|
51
54
|
this.commits = commits;
|
|
52
55
|
this.branches = [...branches];
|
|
53
56
|
this.isWaiting = isWaiting;
|
|
57
|
+
this.account = account;
|
|
54
58
|
}
|
|
55
59
|
static fromJson(value, path) {
|
|
56
60
|
const reader = JsonReader.fromValue(value, path);
|
|
57
61
|
FieldCheck.refuseUnknownFields(reader, HostWorkItemDetail.FIELDS);
|
|
58
62
|
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);
|
|
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);
|
|
60
64
|
}
|
|
61
65
|
toJson() {
|
|
62
66
|
return {
|
|
@@ -70,7 +74,8 @@ export class HostWorkItemDetail {
|
|
|
70
74
|
[Resources.pullRequestsField]: this.pullRequests.map(t => t.toJson()),
|
|
71
75
|
[Resources.commitsField]: this.commits,
|
|
72
76
|
[Resources.branchesField]: [...this.branches],
|
|
73
|
-
[Resources.isWaitingField]: this.isWaiting
|
|
77
|
+
[Resources.isWaitingField]: this.isWaiting,
|
|
78
|
+
...(this.account === null ? {} : { [Resources.accountField]: this.account })
|
|
74
79
|
};
|
|
75
80
|
}
|
|
76
81
|
static requireAmount(value, field, reader) {
|
|
@@ -13,6 +13,12 @@ export class HostingNames {
|
|
|
13
13
|
static signInWithTokenMethod = "signInWithToken";
|
|
14
14
|
static signOutMethod = "signOut";
|
|
15
15
|
static signInChangedEvent = "signInChanged";
|
|
16
|
+
static readAccountsMethod = "readAccounts";
|
|
17
|
+
static addAccountMethod = "addAccount";
|
|
18
|
+
static readRepositoryAccountMethod = "readRepositoryAccount";
|
|
19
|
+
static pickAccountMethod = "pickAccount";
|
|
20
|
+
static useFolderMethod = "useFolder";
|
|
21
|
+
static accountsChangedEvent = "accountsChanged";
|
|
16
22
|
static readReferenceMethod = "readReference";
|
|
17
23
|
static readBranchPullRequestMethod = "readBranchPullRequest";
|
|
18
24
|
static readCommitPullRequestMethod = "readCommitPullRequest";
|
|
@@ -27,6 +33,7 @@ export class HostingNames {
|
|
|
27
33
|
static readReviewRequestsMethod = "readReviewRequests";
|
|
28
34
|
static readCommitCommentsMethod = "readCommitComments";
|
|
29
35
|
static readPullRequestThreadsMethod = "readPullRequestThreads";
|
|
36
|
+
static rateLimitedUntilDetail = "rateLimitedUntil";
|
|
30
37
|
static nameOf(moduleId, member) {
|
|
31
38
|
return Resources.formatMemberName(moduleId, member);
|
|
32
39
|
}
|
|
@@ -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
|
+
export class RepositoryAccount {
|
|
12
|
+
static FIELDS = [Resources.accountField, Resources.isNamedByRemoteField];
|
|
13
|
+
account;
|
|
14
|
+
isNamedByRemote;
|
|
15
|
+
constructor(account, reader, isNamedByRemote = false) {
|
|
16
|
+
if (account !== null)
|
|
17
|
+
FieldCheck.requirePositive(account, Resources.accountField, reader);
|
|
18
|
+
if (account === null && isNamedByRemote)
|
|
19
|
+
FieldCheck.fail(Resources.isNamedByRemoteField, Resources.namedAccountExpected, reader);
|
|
20
|
+
this.account = account;
|
|
21
|
+
this.isNamedByRemote = isNamedByRemote;
|
|
22
|
+
}
|
|
23
|
+
static fromJson(value, path) {
|
|
24
|
+
const reader = JsonReader.fromValue(value, path);
|
|
25
|
+
FieldCheck.refuseUnknownFields(reader, RepositoryAccount.FIELDS);
|
|
26
|
+
return new RepositoryAccount(reader.readNullableInteger(Resources.accountField), reader, reader.hasField(Resources.isNamedByRemoteField) && reader.readBoolean(Resources.isNamedByRemoteField));
|
|
27
|
+
}
|
|
28
|
+
toJson() {
|
|
29
|
+
return this.isNamedByRemote ? { [Resources.accountField]: this.account, [Resources.isNamedByRemoteField]: true } : { [Resources.accountField]: this.account };
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/resources.js
CHANGED
|
@@ -11,6 +11,7 @@ export class Resources {
|
|
|
11
11
|
static httpsAddressExpected = "an https address with no user name or password";
|
|
12
12
|
static positiveExpected = "a whole number above zero";
|
|
13
13
|
static countExpected = "a whole number, zero or more";
|
|
14
|
+
static namedAccountExpected = "false while there is no account";
|
|
14
15
|
static nameExpected = "a name of letters, digits, '.', '_' and '-', other than '.' and '..'";
|
|
15
16
|
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
17
|
static namePattern = /^(?!\.\.?$)[A-Za-z0-9._-]+$/;
|
|
@@ -76,6 +77,9 @@ export class Resources {
|
|
|
76
77
|
static commitCommentsCappedExpected = "capped only with comments";
|
|
77
78
|
static commitCommentsUrlExpected = "a page exactly when there are comments";
|
|
78
79
|
static countsExpected = "zero counts when the host doesn't count them";
|
|
80
|
+
static accountIdsExpected = "accounts with each id once";
|
|
81
|
+
static placeExpected = "a lowercase host name, with its port or a path if it has one, and no scheme, user name or trailing '/'";
|
|
82
|
+
static placePattern = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*(?::[0-9]+)?(?:\/[a-z0-9._-]+)*$/;
|
|
79
83
|
static commentParentExpected = "a parent other than the comment itself";
|
|
80
84
|
static lineExpected = "a line only on a thread that names a file";
|
|
81
85
|
static commentsExpected = "at least one comment";
|
|
@@ -83,6 +87,12 @@ export class Resources {
|
|
|
83
87
|
static deviceCodeField = "deviceCode";
|
|
84
88
|
static addressField = "address";
|
|
85
89
|
static accountField = "account";
|
|
90
|
+
static isNamedByRemoteField = "isNamedByRemote";
|
|
91
|
+
static folderField = "folder";
|
|
92
|
+
static remoteField = "remote";
|
|
93
|
+
static accountsField = "accounts";
|
|
94
|
+
static signInField = "signIn";
|
|
95
|
+
static placeField = "place";
|
|
86
96
|
static failureField = "failure";
|
|
87
97
|
static userCodeField = "userCode";
|
|
88
98
|
static verificationUriField = "verificationUri";
|