gitd-client 0.7.0 → 0.9.0

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/dist/gitd.d.ts CHANGED
@@ -1,16 +1,36 @@
1
1
  import { type Transport } from "@connectrpc/connect";
2
- import type { AuditEntry, AuditOptions, CheckoutOptions, Description, Info, PrepareOptions, Probe, Published, UpdateOptions, Workspace } from "./types.js";
2
+ import { Credentials } from "./credentials.js";
3
+ import { Endpoint } from "./endpoint.js";
4
+ import { Publishing } from "./publishing.js";
5
+ import type { PublishOptions } from "./publishing-types.js";
6
+ import type { AuditEntry, AuditOptions, Changes, CheckoutOptions, CompareOptions, Comparison, Conflict, Description, Diff, DiffOptions, Info, PrepareOptions, Probe, Published, Side, WorkspaceEvent, UpdateOptions, WarmLayer, Workspace } from "./types.js";
3
7
  export interface GitdOptions {
4
8
  /** gitd's Unix socket; default $GITD_SOCKET, then /run/gitd/gitd.sock. */
5
9
  socket?: string;
10
+ /**
11
+ * A gitd on the network instead, e.g. `https://gitd.internal:9420` (or http:// on a private
12
+ * network); default $GITD_URL.
13
+ */
14
+ url?: string;
15
+ /** The key naming your tenant; default the file $GITD_KEY_FILE names, then $GITD_KEY. */
16
+ key?: string;
17
+ /** The PEM of a certificate authority the system does not trust; default $GITD_CA_FILE's. */
18
+ ca?: string;
6
19
  /** A transport of your own instead, e.g. for tests. */
7
20
  transport?: Transport;
8
21
  }
9
22
  /**
10
- * A gitd on its Unix socket. No call takes a credential: gitd reads and publishes with the
11
- * ones it keeps.
23
+ * A gitd on its Unix socket. No call on workspaces takes a credential: gitd reads and
24
+ * publishes with the ones it keeps, which a platform manages through `credentials`, and
25
+ * publishing follows the rules it sets through `publishing`.
12
26
  */
13
27
  export declare class Gitd {
28
+ /** The credentials gitd keeps, and connecting GitHub. */
29
+ readonly credentials: Credentials;
30
+ /** The rules publishing follows, per repository prefix. */
31
+ readonly publishing: Publishing;
32
+ /** Tokens of gitd's endpoint, for sandboxes elsewhere. */
33
+ readonly endpoint: Endpoint;
14
34
  private readonly workspaces;
15
35
  private readonly repositories;
16
36
  private readonly server;
@@ -27,10 +47,31 @@ export declare class Gitd {
27
47
  checkout(path: string, commit: string, options?: CheckoutOptions): Promise<Workspace>;
28
48
  /** What a workspace is on disk, without the network. */
29
49
  describe(path: string): Promise<Description>;
30
- /** Pushes what was committed in a workspace to a new branch, with the token gitd keeps. */
31
- publish(path: string, branch: string): Promise<Published>;
50
+ /**
51
+ * Pushes what was committed in a workspace to a new branch, with the credential gitd
52
+ * keeps, and opens its pull request when the publishing settings or the options say so.
53
+ */
54
+ publish(path: string, branch: string, options?: PublishOptions): Promise<Published>;
32
55
  /** The audit log: every publish, done or refused, newest first. */
33
56
  audit(options?: AuditOptions): Promise<AuditEntry[]>;
57
+ /** What was changed in a workspace since gitd put it on its commit, committed or not. */
58
+ changes(path: string, includeIgnored?: boolean): Promise<Changes>;
59
+ /** The unified diff of a workspace's changes, of some files or all, cut short at a size. */
60
+ diff(path: string, options?: DiffOptions): Promise<Diff>;
61
+ /** How two works of one repository differ, from first to second. */
62
+ compare(first: Side, second: Side, options?: CompareOptions): Promise<Comparison>;
63
+ /** Which pairs of works do not merge cleanly; a workspace stands for what it committed. */
64
+ conflicts(sides: Side[], url?: string): Promise<Conflict[]>;
65
+ /** What happens to the workspaces at paths, or to every one, as it happens. */
66
+ watch(paths?: string[], signal?: AbortSignal): AsyncGenerator<WorkspaceEvent>;
67
+ /**
68
+ * Seals what was installed in an overlay workspace as the warm layer `name` of its
69
+ * repository, for workspaces made later at the same commit to stand on. The layer is
70
+ * moved, not copied: the workspace is removed.
71
+ */
72
+ seal(path: string, name: string): Promise<WarmLayer>;
73
+ /** The warm layers of a repository. */
74
+ warmLayers(url: string): Promise<WarmLayer[]>;
34
75
  /** Deletes a workspace; its pool stays. */
35
76
  remove(path: string): Promise<void>;
36
77
  }
package/dist/gitd.js CHANGED
@@ -1,23 +1,41 @@
1
1
  import { timestampFromDate } from "@bufbuild/protobuf/wkt";
2
2
  import { createClient } from "@connectrpc/connect";
3
+ import { readFileSync } from "node:fs";
3
4
  import { createConnectTransport } from "@connectrpc/connect-node";
4
- import { RepositoryService, ServerService, WorkspaceService } from "./gen/gitd/v1/gitd_pb.js";
5
+ import { ConnectionService, EndpointService, PublishingService, RepositoryService, ServerService, WorkspaceService, } from "./gen/gitd/v1/gitd_pb.js";
5
6
  import { call, drain } from "./calls.js";
6
- import { accessName, pushedOf, revisionOf, strategyName, strategyProto, toAuditEntry, toWorkspace, } from "./convert.js";
7
+ import { sideProto, toEvent, toSide } from "./compare-convert.js";
8
+ import { toWarmLayer } from "./warm-convert.js";
9
+ import { refusal } from "./errors.js";
10
+ import { Credentials } from "./credentials.js";
11
+ import { Endpoint } from "./endpoint.js";
12
+ import { pullRequestOptionsProto } from "./publishing-convert.js";
13
+ import { Publishing } from "./publishing.js";
14
+ import { accessName, publishedOf, revisionOf, strategyName, strategyProto, toAuditEntry, toChangedFiles, toChanges, toWorkspace, } from "./convert.js";
7
15
  const defaultSocket = "/run/gitd/gitd.sock";
8
16
  /**
9
- * A gitd on its Unix socket. No call takes a credential: gitd reads and publishes with the
10
- * ones it keeps.
17
+ * A gitd on its Unix socket. No call on workspaces takes a credential: gitd reads and
18
+ * publishes with the ones it keeps, which a platform manages through `credentials`, and
19
+ * publishing follows the rules it sets through `publishing`.
11
20
  */
12
21
  export class Gitd {
22
+ /** The credentials gitd keeps, and connecting GitHub. */
23
+ credentials;
24
+ /** The rules publishing follows, per repository prefix. */
25
+ publishing;
26
+ /** Tokens of gitd's endpoint, for sandboxes elsewhere. */
27
+ endpoint;
13
28
  workspaces;
14
29
  repositories;
15
30
  server;
16
31
  constructor(options = {}) {
17
- const transport = options.transport ?? socketTransport(options.socket);
32
+ const transport = options.transport ?? transportFor(options);
18
33
  this.workspaces = createClient(WorkspaceService, transport);
19
34
  this.repositories = createClient(RepositoryService, transport);
20
35
  this.server = createClient(ServerService, transport);
36
+ this.credentials = new Credentials(createClient(ConnectionService, transport));
37
+ this.publishing = new Publishing(createClient(PublishingService, transport));
38
+ this.endpoint = new Endpoint(createClient(EndpointService, transport));
21
39
  }
22
40
  /** Which gitd answers, and how it makes workspaces here and why. */
23
41
  async info() {
@@ -52,6 +70,7 @@ export class Gitd {
52
70
  withSubmodules: options.submodules ?? false,
53
71
  fullHistory: options.fullHistory ?? false,
54
72
  strategy: strategyProto(options.strategy),
73
+ warm: options.warm ?? "",
55
74
  };
56
75
  const stream = this.workspaces.prepare(request, { signal: options.signal });
57
76
  return toWorkspace(options.path, await drain(stream, options.onProgress));
@@ -86,10 +105,25 @@ export class Gitd {
86
105
  lfsPatterns: answer.lfsPatterns,
87
106
  };
88
107
  }
89
- /** Pushes what was committed in a workspace to a new branch, with the token gitd keeps. */
90
- async publish(path, branch) {
91
- const answer = await call(() => this.workspaces.publish({ path, branch }));
92
- return { branch: answer.branch, repositories: pushedOf(answer.repository, answer.submodules) };
108
+ /**
109
+ * Pushes what was committed in a workspace to a new branch, with the credential gitd
110
+ * keeps, and opens its pull request when the publishing settings or the options say so.
111
+ */
112
+ async publish(path, branch, options = {}) {
113
+ const answer = await call(() => this.workspaces.publish({
114
+ path,
115
+ branch,
116
+ requestedBy: options.requestedBy ?? "",
117
+ sandbox: options.sandbox ?? "",
118
+ pullRequest: pullRequestOptionsProto(options.pullRequest),
119
+ provenance: options.provenance && {
120
+ agent: options.provenance.agent ?? "",
121
+ model: options.provenance.model ?? "",
122
+ session: options.provenance.session ?? "",
123
+ taskUrl: options.provenance.taskUrl ?? "",
124
+ },
125
+ }));
126
+ return publishedOf(answer);
93
127
  }
94
128
  /** The audit log: every publish, done or refused, newest first. */
95
129
  async audit(options = {}) {
@@ -101,15 +135,107 @@ export class Gitd {
101
135
  const answer = await call(() => this.server.audit(request));
102
136
  return answer.entries.map(toAuditEntry);
103
137
  }
138
+ /** What was changed in a workspace since gitd put it on its commit, committed or not. */
139
+ async changes(path, includeIgnored = false) {
140
+ return toChanges(await call(() => this.workspaces.changes({ path, includeIgnored })));
141
+ }
142
+ /** The unified diff of a workspace's changes, of some files or all, cut short at a size. */
143
+ async diff(path, options = {}) {
144
+ const answer = await call(() => this.workspaces.diff({
145
+ path,
146
+ files: options.files ?? [],
147
+ maxBytes: BigInt(options.maxBytes ?? 0),
148
+ includeIgnored: options.includeIgnored ?? false,
149
+ }));
150
+ return { base: answer.base, diff: answer.diff, truncated: answer.truncated };
151
+ }
152
+ /** How two works of one repository differ, from first to second. */
153
+ async compare(first, second, options = {}) {
154
+ const answer = await call(() => this.workspaces.compare({
155
+ first: sideProto(first),
156
+ second: sideProto(second),
157
+ url: options.url ?? "",
158
+ withDiff: options.withDiff ?? false,
159
+ maxBytes: BigInt(options.maxBytes ?? 0),
160
+ includeIgnored: options.includeIgnored ?? false,
161
+ }));
162
+ return { files: toChangedFiles(answer.files), diff: answer.diff, truncated: answer.truncated };
163
+ }
164
+ /** Which pairs of works do not merge cleanly; a workspace stands for what it committed. */
165
+ async conflicts(sides, url = "") {
166
+ const answer = await call(() => this.workspaces.conflicts({ sides: sides.map(sideProto), url }));
167
+ return answer.conflicts.map((conflict) => ({
168
+ first: toSide(conflict.first),
169
+ second: toSide(conflict.second),
170
+ paths: conflict.paths,
171
+ }));
172
+ }
173
+ /** What happens to the workspaces at paths, or to every one, as it happens. */
174
+ async *watch(paths = [], signal) {
175
+ try {
176
+ for await (const event of this.workspaces.watch({ paths }, { signal })) {
177
+ yield toEvent(event);
178
+ }
179
+ }
180
+ catch (error) {
181
+ if (signal?.aborted) {
182
+ return;
183
+ }
184
+ throw refusal(error);
185
+ }
186
+ }
187
+ /**
188
+ * Seals what was installed in an overlay workspace as the warm layer `name` of its
189
+ * repository, for workspaces made later at the same commit to stand on. The layer is
190
+ * moved, not copied: the workspace is removed.
191
+ */
192
+ async seal(path, name) {
193
+ const answer = await call(() => this.workspaces.seal({ path, name }));
194
+ return toWarmLayer(answer.warm);
195
+ }
196
+ /** The warm layers of a repository. */
197
+ async warmLayers(url) {
198
+ const answer = await call(() => this.workspaces.listWarm({ url }));
199
+ return answer.warm.map(toWarmLayer);
200
+ }
104
201
  /** Deletes a workspace; its pool stays. */
105
202
  async remove(path) {
106
203
  await call(() => this.workspaces.remove({ path }));
107
204
  }
108
205
  }
109
- function socketTransport(socket) {
206
+ /** The way to the gitd options name: its network address, else its socket, with the key. */
207
+ function transportFor(options) {
208
+ const key = options.key ?? keyFromEnvironment();
209
+ const interceptors = key
210
+ ? [
211
+ (next) => async (request) => {
212
+ request.header.set("Authorization", `Bearer ${key}`);
213
+ return next(request);
214
+ },
215
+ ]
216
+ : [];
217
+ const url = options.url ?? process.env.GITD_URL;
218
+ if (url) {
219
+ const caFile = process.env.GITD_CA_FILE;
220
+ const ca = options.ca ?? (caFile ? readFileSync(caFile, "utf8") : undefined);
221
+ return createConnectTransport({
222
+ baseUrl: url.replace(/\/$/, ""),
223
+ httpVersion: "1.1",
224
+ interceptors,
225
+ nodeOptions: ca ? { ca } : {},
226
+ });
227
+ }
110
228
  return createConnectTransport({
111
229
  baseUrl: "http://gitd",
112
230
  httpVersion: "1.1",
113
- nodeOptions: { socketPath: socket ?? process.env.GITD_SOCKET ?? defaultSocket },
231
+ interceptors,
232
+ nodeOptions: { socketPath: options.socket ?? process.env.GITD_SOCKET ?? defaultSocket },
114
233
  });
115
234
  }
235
+ function keyFromEnvironment() {
236
+ const file = process.env.GITD_KEY_FILE;
237
+ if (file) {
238
+ return readFileSync(file, "utf8").trim();
239
+ }
240
+ return process.env.GITD_KEY?.trim() || undefined;
241
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  export { Gitd, type GitdOptions } from "./gitd.js";
2
2
  export { GitdError } from "./errors.js";
3
+ export { Credentials } from "./credentials.js";
4
+ export { Publishing } from "./publishing.js";
5
+ export { Endpoint } from "./endpoint.js";
6
+ export type * from "./endpoint-types.js";
3
7
  export type * from "./types.js";
8
+ export type * from "./credential-types.js";
9
+ export type * from "./publishing-types.js";
4
10
  export * as proto from "./gen/gitd/v1/gitd_pb.js";
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
1
  export { Gitd } from "./gitd.js";
2
2
  export { GitdError } from "./errors.js";
3
+ export { Credentials } from "./credentials.js";
4
+ export { Publishing } from "./publishing.js";
5
+ export { Endpoint } from "./endpoint.js";
3
6
  export * as proto from "./gen/gitd/v1/gitd_pb.js";
@@ -0,0 +1,8 @@
1
+ import type { MessageInitShape } from "@bufbuild/protobuf";
2
+ import { type Preset as PresetMessage, type PresetSchema, type PublishSettings as PublishSettingsMessage, type PublishSettingsSchema, type PullRequestOptionsSchema } from "./gen/gitd/v1/gitd_pb.js";
3
+ import type { Preset, PublishSettings, PullRequestOptions } from "./publishing-types.js";
4
+ export declare function toPublishSettings(settings: PublishSettingsMessage | undefined): PublishSettings;
5
+ export declare function publishSettingsProto(settings: PublishSettings): MessageInitShape<typeof PublishSettingsSchema>;
6
+ export declare function pullRequestOptionsProto(options: PullRequestOptions | undefined): MessageInitShape<typeof PullRequestOptionsSchema> | undefined;
7
+ export declare function toPreset(preset: PresetMessage | undefined): Preset;
8
+ export declare function presetProto(preset: Preset): MessageInitShape<typeof PresetSchema>;
@@ -0,0 +1,74 @@
1
+ import { Preset_Origin, PullRequestSettings_Open, } from "./gen/gitd/v1/gitd_pb.js";
2
+ export function toPublishSettings(settings) {
3
+ const pullRequests = settings?.pullRequests;
4
+ return {
5
+ urlPrefix: settings?.urlPrefix ?? "",
6
+ preset: settings?.preset || undefined,
7
+ protectedPaths: settings?.protectedPaths ?? [],
8
+ keptPaths: settings?.keptPaths ?? [],
9
+ allowedPaths: settings?.allowedPaths ?? [],
10
+ maxChangedFiles: settings?.maxChangedFiles,
11
+ branchPrefix: settings?.branchPrefix ?? "",
12
+ pullRequests: pullRequests && {
13
+ opening: pullRequests.open === PullRequestSettings_Open.ALWAYS ? "always" : "when_asked",
14
+ draft: pullRequests.draft,
15
+ labels: pullRequests.labels,
16
+ requestReviewFromRequester: pullRequests.requestReviewFromRequester,
17
+ },
18
+ fromFile: settings?.fromFile ?? false,
19
+ };
20
+ }
21
+ export function publishSettingsProto(settings) {
22
+ const pullRequests = settings.pullRequests;
23
+ return {
24
+ urlPrefix: settings.urlPrefix,
25
+ preset: settings.preset ?? "",
26
+ protectedPaths: settings.protectedPaths ?? [],
27
+ keptPaths: settings.keptPaths ?? [],
28
+ allowedPaths: settings.allowedPaths ?? [],
29
+ maxChangedFiles: settings.maxChangedFiles,
30
+ branchPrefix: settings.branchPrefix ?? "",
31
+ pullRequests: pullRequests && {
32
+ open: pullRequests.opening === "always" ? PullRequestSettings_Open.ALWAYS : PullRequestSettings_Open.WHEN_ASKED,
33
+ draft: pullRequests.draft ?? false,
34
+ labels: pullRequests.labels ?? [],
35
+ requestReviewFromRequester: pullRequests.requestReviewFromRequester ?? false,
36
+ },
37
+ };
38
+ }
39
+ export function pullRequestOptionsProto(options) {
40
+ return (options && {
41
+ open: options.open ?? false,
42
+ title: options.title ?? "",
43
+ body: options.body ?? "",
44
+ base: options.base ?? "",
45
+ draft: options.draft,
46
+ });
47
+ }
48
+ export function toPreset(preset) {
49
+ return {
50
+ name: preset?.name ?? "",
51
+ protectedPaths: preset?.protectedPaths ?? [],
52
+ keptPaths: preset?.keptPaths ?? [],
53
+ maxChangedFiles: preset?.maxChangedFiles,
54
+ origin: originName(preset?.origin ?? Preset_Origin.UNSPECIFIED),
55
+ };
56
+ }
57
+ export function presetProto(preset) {
58
+ return {
59
+ name: preset.name,
60
+ protectedPaths: preset.protectedPaths ?? [],
61
+ keptPaths: preset.keptPaths ?? [],
62
+ maxChangedFiles: preset.maxChangedFiles,
63
+ };
64
+ }
65
+ function originName(origin) {
66
+ switch (origin) {
67
+ case Preset_Origin.BUILT_IN:
68
+ return "built_in";
69
+ case Preset_Origin.FILE:
70
+ return "file";
71
+ default:
72
+ return "api";
73
+ }
74
+ }
@@ -0,0 +1,72 @@
1
+ /** When publishes open pull requests: only when a publish asks, or always. */
2
+ export type Opening = "when_asked" | "always";
3
+ /** How publishes open pull requests. */
4
+ export interface PullRequestSettings {
5
+ opening: Opening;
6
+ draft?: boolean;
7
+ labels?: string[];
8
+ /** Ask the person a publish names as requester to review it. */
9
+ requestReviewFromRequester?: boolean;
10
+ }
11
+ /** The rules of the repositories whose address starts with urlPrefix ("" for every one). */
12
+ export interface PublishSettings {
13
+ urlPrefix: string;
14
+ /** The name of a preset whose rules these take; `recommended` is gitd's own. */
15
+ preset?: string;
16
+ /** Paths a publish may not change, as git's glob pathspecs, e.g. `.github/workflows/**`. */
17
+ protectedPaths?: string[];
18
+ /** Paths a publish may change but not delete or rename away. */
19
+ keptPaths?: string[];
20
+ /** Paths these settings' own rules leave free, e.g. `.gitmodules` under `recommended`. */
21
+ allowedPaths?: string[];
22
+ maxChangedFiles?: number;
23
+ /** What every published branch must start with, e.g. `agents/`. */
24
+ branchPrefix?: string;
25
+ pullRequests?: PullRequestSettings;
26
+ /** Declared in gitd.toml: shown, never changed through the API. */
27
+ fromFile?: boolean;
28
+ }
29
+ /** Where a preset comes from: gitd's own, gitd.toml, or the API. */
30
+ export type PresetOrigin = "built_in" | "file" | "api";
31
+ /** A named set of rules settings take; one named `recommended` replaces gitd's own. */
32
+ export interface Preset {
33
+ name: string;
34
+ protectedPaths?: string[];
35
+ keptPaths?: string[];
36
+ maxChangedFiles?: number;
37
+ /** Read from gitd, never sent. */
38
+ origin?: PresetOrigin;
39
+ }
40
+ /** A publish's own say on its pull request. */
41
+ export interface PullRequestOptions {
42
+ /** Open one even when the settings open them only when asked. */
43
+ open?: boolean;
44
+ /** Default: the newest commit's subject. */
45
+ title?: string;
46
+ /** Text that comes before what gitd checked. */
47
+ body?: string;
48
+ /** The branch it merges into; default: the repository's default branch. */
49
+ base?: string;
50
+ draft?: boolean;
51
+ }
52
+ /** Where a publish's work came from, as the platform says; gitd records it as told. */
53
+ export interface Provenance {
54
+ agent?: string;
55
+ model?: string;
56
+ session?: string;
57
+ /** An https address: an issue, a ticket. */
58
+ taskUrl?: string;
59
+ }
60
+ export interface PublishOptions {
61
+ /** Who asked for the work, as their account on the host. */
62
+ requestedBy?: string;
63
+ pullRequest?: PullRequestOptions;
64
+ provenance?: Provenance;
65
+ /** Publish what a sandbox pushed through the endpoint instead of a workspace; path is then "". */
66
+ sandbox?: string;
67
+ }
68
+ /** A pull request gitd opened. */
69
+ export interface OpenedPullRequest {
70
+ url: string;
71
+ number: number;
72
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { Client } from "@connectrpc/connect";
2
+ import type { PublishingService } from "./gen/gitd/v1/gitd_pb.js";
3
+ import type { Preset, PublishSettings } from "./publishing-types.js";
4
+ /**
5
+ * The rules publishing follows, per repository prefix, as `gitd.publishing`: for a
6
+ * platform's own pages, never for an agent.
7
+ */
8
+ export declare class Publishing {
9
+ private readonly publishing;
10
+ constructor(publishing: Client<typeof PublishingService>);
11
+ /** Every setting, gitd.toml's included. */
12
+ settings(): Promise<PublishSettings[]>;
13
+ /** Keeps the settings of a prefix, replacing those it had, as gitd checked them. */
14
+ set(settings: PublishSettings): Promise<PublishSettings>;
15
+ /** Forgets the settings of a prefix set through the API. */
16
+ remove(urlPrefix: string): Promise<void>;
17
+ /** Every preset as it applies: gitd's own, gitd.toml's and those set through the API. */
18
+ presets(): Promise<Preset[]>;
19
+ /** Keeps a preset, replacing one of the same name; `recommended` replaces gitd's own. */
20
+ setPreset(preset: Preset): Promise<Preset>;
21
+ /** Forgets a preset set through the API; refused while settings take it. */
22
+ removePreset(name: string): Promise<void>;
23
+ }
@@ -0,0 +1,40 @@
1
+ import { call } from "./calls.js";
2
+ import { presetProto, publishSettingsProto, toPreset, toPublishSettings } from "./publishing-convert.js";
3
+ /**
4
+ * The rules publishing follows, per repository prefix, as `gitd.publishing`: for a
5
+ * platform's own pages, never for an agent.
6
+ */
7
+ export class Publishing {
8
+ publishing;
9
+ constructor(publishing) {
10
+ this.publishing = publishing;
11
+ }
12
+ /** Every setting, gitd.toml's included. */
13
+ async settings() {
14
+ const answer = await call(() => this.publishing.getSettings({}));
15
+ return answer.settings.map(toPublishSettings);
16
+ }
17
+ /** Keeps the settings of a prefix, replacing those it had, as gitd checked them. */
18
+ async set(settings) {
19
+ const answer = await call(() => this.publishing.setSettings({ settings: publishSettingsProto(settings) }));
20
+ return toPublishSettings(answer.settings);
21
+ }
22
+ /** Forgets the settings of a prefix set through the API. */
23
+ async remove(urlPrefix) {
24
+ await call(() => this.publishing.removeSettings({ urlPrefix }));
25
+ }
26
+ /** Every preset as it applies: gitd's own, gitd.toml's and those set through the API. */
27
+ async presets() {
28
+ const answer = await call(() => this.publishing.listPresets({}));
29
+ return answer.presets.map(toPreset);
30
+ }
31
+ /** Keeps a preset, replacing one of the same name; `recommended` replaces gitd's own. */
32
+ async setPreset(preset) {
33
+ const answer = await call(() => this.publishing.setPreset({ preset: presetProto(preset) }));
34
+ return toPreset(answer.preset);
35
+ }
36
+ /** Forgets a preset set through the API; refused while settings take it. */
37
+ async removePreset(name) {
38
+ await call(() => this.publishing.removePreset({ name }));
39
+ }
40
+ }