@1agh/maude 0.35.0 → 0.36.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.
@@ -22,6 +22,7 @@ import {
22
22
  gitCreateBranch,
23
23
  gitDiff,
24
24
  gitDiscard,
25
+ gitFetchRemote,
25
26
  gitFoldDraft,
26
27
  gitListBranches,
27
28
  gitLog,
@@ -76,6 +77,8 @@ export interface GitEndpoints {
76
77
  checkout(body: unknown): Promise<GitEndpointResult>;
77
78
  // "Add this draft to the Shared version" — token-bearing (it publishes).
78
79
  fold(body: unknown): Promise<GitEndpointResult>;
80
+ // "Refresh drafts" — token-bearing fetch so new remote drafts surface.
81
+ fetchRemote(body: unknown): Promise<GitEndpointResult>;
79
82
  }
80
83
 
81
84
  export function createGitEndpoints(ctx: Context): GitEndpoints {
@@ -296,6 +299,19 @@ export function createGitEndpoints(ctx: Context): GitEndpoints {
296
299
  return { status: 502, json: { ok: false, error: res.error ?? 'Could not add the draft.' } };
297
300
  }
298
301
 
302
+ async function fetchRemote(body: unknown): Promise<GitEndpointResult> {
303
+ // Token resolution mirrors fold/pull: body token → keychain bridge → undefined
304
+ // → authRequired. Explicit user gesture only (the UI "Refresh drafts" button).
305
+ const token = readToken(body) ?? (await getGithubToken()) ?? undefined;
306
+ const b = (body ?? {}) as { remote?: unknown };
307
+ if (b.remote != null && safeRemoteArg(b.remote) === undefined) return bad('Invalid remote.');
308
+ const res = await gitFetchRemote(dir, token, { remote: safeRemoteArg(b.remote) });
309
+ if (res.ok) return { status: 200, json: { ok: true, fetchedAt: res.fetchedAt } };
310
+ if (res.authRequired)
311
+ return { status: 401, json: { ok: false, authRequired: true, error: res.error } };
312
+ return { status: 502, json: { ok: false, error: res.error ?? 'Could not refresh drafts.' } };
313
+ }
314
+
299
315
  return {
300
316
  status,
301
317
  commit,
@@ -309,6 +325,7 @@ export function createGitEndpoints(ctx: Context): GitEndpoints {
309
325
  createBranch,
310
326
  checkout,
311
327
  fold,
328
+ fetchRemote,
312
329
  };
313
330
  }
314
331