@noldova/git.hosting.protocol 0.0.26 → 0.0.27
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 +5 -5
- package/src/api/index.d.ts +9 -3
- package/src/models/branch-query.js +8 -4
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.27",
|
|
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,9 +30,9 @@
|
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@noldova/context.core": ">=0.0.
|
|
34
|
-
"@noldova/context.exceptions": ">=0.0.
|
|
35
|
-
"@noldova/context.json": ">=0.0.
|
|
33
|
+
"@noldova/context.core": ">=0.0.20 <0.1.0",
|
|
34
|
+
"@noldova/context.exceptions": ">=0.0.20 <0.1.0",
|
|
35
|
+
"@noldova/context.json": ">=0.0.20 <0.1.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "c0b1373fd9906acc48fde089b119ed744d18316b"
|
|
38
38
|
}
|
package/src/api/index.d.ts
CHANGED
|
@@ -1714,6 +1714,11 @@ export declare class BranchQuery {
|
|
|
1714
1714
|
*/
|
|
1715
1715
|
public readonly headCommit: string | null;
|
|
1716
1716
|
|
|
1717
|
+
/**
|
|
1718
|
+
* Whether the module reads the pull request and its checks from the host even when it holds a recent answer, as while its checks run; the host may still answer that nothing changed.
|
|
1719
|
+
*/
|
|
1720
|
+
public readonly isFresh: boolean;
|
|
1721
|
+
|
|
1717
1722
|
/**
|
|
1718
1723
|
* Makes a query from its parts.
|
|
1719
1724
|
*
|
|
@@ -1721,6 +1726,7 @@ export declare class BranchQuery {
|
|
|
1721
1726
|
* @param path The repository's path: 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.
|
|
1722
1727
|
* @param branch The branch, which isn't blank.
|
|
1723
1728
|
* @param headCommit The commit, a full hash of 40 or 64 lowercase hexadecimal digits, or null.
|
|
1729
|
+
* @param isFresh Whether the module reads from the host even when it holds a recent answer; false by default.
|
|
1724
1730
|
* @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.
|
|
1725
1731
|
* @throws {HostingArgumentException} Without a reader, when a part is out of its range, naming the field as the parameter, such as `headCommit`.
|
|
1726
1732
|
* @throws {HostingFieldException} With a reader, when a part is out of its range, naming the field by its path, such as `$.headCommit`.
|
|
@@ -1731,12 +1737,12 @@ export declare class BranchQuery {
|
|
|
1731
1737
|
* const query = new BranchQuery("github.com", "octocat/hello-world", "monalisa/fix", null);
|
|
1732
1738
|
* ```
|
|
1733
1739
|
*/
|
|
1734
|
-
public constructor(host: string, path: string, branch: string, headCommit: string | null, reader?: JsonReader);
|
|
1740
|
+
public constructor(host: string, path: string, branch: string, headCommit: string | null, isFresh?: boolean, reader?: JsonReader);
|
|
1735
1741
|
|
|
1736
1742
|
/**
|
|
1737
1743
|
* Reads a query from its JSON.
|
|
1738
1744
|
*
|
|
1739
|
-
* @param value The JSON, with
|
|
1745
|
+
* @param value The JSON, with the fields `toJson` writes; without `isFresh`, the query isn't fresh.
|
|
1740
1746
|
* @param path The JSON's path, `$` by default.
|
|
1741
1747
|
* @returns The query.
|
|
1742
1748
|
* @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`.
|
|
@@ -1751,7 +1757,7 @@ export declare class BranchQuery {
|
|
|
1751
1757
|
public static fromJson(value: unknown, path?: string): BranchQuery;
|
|
1752
1758
|
|
|
1753
1759
|
/**
|
|
1754
|
-
* Writes the query as JSON: `host`, `path`, `branch
|
|
1760
|
+
* Writes the query as JSON: `host`, `path`, `branch`, `headCommit`, null when there is none, and `isFresh`.
|
|
1755
1761
|
*
|
|
1756
1762
|
* @returns The JSON.
|
|
1757
1763
|
* @example
|
|
@@ -10,12 +10,14 @@ import { JsonReader } from "@noldova/context.json";
|
|
|
10
10
|
import { Resources } from "../resources.js";
|
|
11
11
|
import { FieldCheck } from "./field-check.js";
|
|
12
12
|
export class BranchQuery {
|
|
13
|
-
static FIELDS = [Resources.hostField, Resources.pathField, Resources.branchField, Resources.headCommitField
|
|
13
|
+
static FIELDS = [Resources.hostField, Resources.pathField, Resources.branchField, Resources.headCommitField,
|
|
14
|
+
Resources.isFreshField];
|
|
14
15
|
host;
|
|
15
16
|
path;
|
|
16
17
|
branch;
|
|
17
18
|
headCommit;
|
|
18
|
-
|
|
19
|
+
isFresh;
|
|
20
|
+
constructor(host, path, branch, headCommit, isFresh = false, reader) {
|
|
19
21
|
FieldCheck.requireText(host, Resources.hostField, reader);
|
|
20
22
|
FieldCheck.requirePath(path, Resources.pathField, reader);
|
|
21
23
|
FieldCheck.requireText(branch, Resources.branchField, reader);
|
|
@@ -25,18 +27,20 @@ export class BranchQuery {
|
|
|
25
27
|
this.path = path;
|
|
26
28
|
this.branch = branch;
|
|
27
29
|
this.headCommit = headCommit;
|
|
30
|
+
this.isFresh = isFresh;
|
|
28
31
|
}
|
|
29
32
|
static fromJson(value, path) {
|
|
30
33
|
const reader = JsonReader.fromValue(value, path);
|
|
31
34
|
FieldCheck.refuseUnknownFields(reader, BranchQuery.FIELDS);
|
|
32
|
-
return new BranchQuery(reader.readString(Resources.hostField), reader.readString(Resources.pathField), reader.readString(Resources.branchField), reader.readNullableString(Resources.headCommitField), reader);
|
|
35
|
+
return new BranchQuery(reader.readString(Resources.hostField), reader.readString(Resources.pathField), reader.readString(Resources.branchField), reader.readNullableString(Resources.headCommitField), reader.hasField(Resources.isFreshField) && reader.readBoolean(Resources.isFreshField), reader);
|
|
33
36
|
}
|
|
34
37
|
toJson() {
|
|
35
38
|
return {
|
|
36
39
|
[Resources.hostField]: this.host,
|
|
37
40
|
[Resources.pathField]: this.path,
|
|
38
41
|
[Resources.branchField]: this.branch,
|
|
39
|
-
[Resources.headCommitField]: this.headCommit
|
|
42
|
+
[Resources.headCommitField]: this.headCommit,
|
|
43
|
+
[Resources.isFreshField]: this.isFresh
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
46
|
}
|