ref0-git 0.14.0 → 0.25.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.
Files changed (45) hide show
  1. package/app/apps/github/generated/git-rest.ts +170 -3
  2. package/app/apps/github/generated/routeTree.gen.ts +42 -21
  3. package/app/apps/github/src/clients/host-calls.ts +59 -34
  4. package/app/apps/github/src/components/states/states.tsx +1 -19
  5. package/app/apps/github/src/components/view-tabs.tsx +6 -2
  6. package/app/apps/github/src/context/context.ts +7 -4
  7. package/app/apps/github/src/context/host.ts +72 -36
  8. package/app/apps/github/src/issues/issue-list.tsx +11 -3
  9. package/app/apps/github/src/issues/issues.ts +11 -8
  10. package/app/apps/github/src/lists/across-list.tsx +358 -0
  11. package/app/apps/github/src/lists/across.ts +239 -0
  12. package/app/apps/github/src/names/owners.ts +3 -1
  13. package/app/apps/github/src/palette/targets.ts +3 -2
  14. package/app/apps/github/src/policy.ts +23 -30
  15. package/app/apps/github/src/private-repos.ts +24 -24
  16. package/app/apps/github/src/pulls/pulls.ts +2 -1
  17. package/app/apps/github/src/routes/-nav.tsx +40 -12
  18. package/app/apps/github/src/routes/issues.tsx +15 -0
  19. package/app/apps/github/src/routes/orgs/$owner/-org-list.ts +31 -0
  20. package/app/apps/github/src/routes/orgs/$owner/issues.tsx +10 -3
  21. package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +10 -3
  22. package/app/apps/github/src/routes/pulls.tsx +15 -0
  23. package/app/apps/github/src/seed/seed.ts +104 -52
  24. package/app/apps/github/src/server.ts +17 -7
  25. package/app/apps/github/src/signin/approval.ts +24 -16
  26. package/app/apps/github/src/signin/attempts.ts +1 -1
  27. package/app/apps/github/src/signin/auth.ts +27 -19
  28. package/app/apps/github/src/signin/device-prompt.ts +1 -2
  29. package/app/apps/github/src/signin/revoke.ts +9 -17
  30. package/app/apps/github/src/signin/unborn.ts +33 -20
  31. package/app/pnpm-workspace.yaml +2 -2
  32. package/dist/cli/setup.mjs +3 -3
  33. package/dist/cli/sign-in.mjs +2 -3
  34. package/dist/init/app.mjs +5 -4
  35. package/dist/init/cloudflare.mjs +14 -8
  36. package/dist/init/create.mjs +1 -1
  37. package/dist/init/git-module.mjs +13 -5
  38. package/dist/init/metadata.mjs +1 -1
  39. package/dist/init/node.mjs +1 -1
  40. package/dist/init/stores.mjs +1 -1
  41. package/dist/init/template.mjs +3 -0
  42. package/dist/init/templates.mjs +34 -21
  43. package/dist/init/versions.mjs +1 -1
  44. package/package.json +5 -5
  45. package/app/apps/github/src/routes/orgs/$owner/releases.tsx +0 -8
@@ -1,4 +1,5 @@
1
- import type { TokenCalls } from '@ref0/git';
1
+ import type { Tokens } from '@ref0/git';
2
+ import * as Effect from 'effect/Effect';
2
3
  import { sql } from 'kysely';
3
4
 
4
5
  import type { AuthDatabase } from './auth.ts';
@@ -7,9 +8,9 @@ import { withPersonLocked } from './person-lock.ts';
7
8
  /** What forgetting a failed sign-up's person reads and writes: their rows, and Git's records. */
8
9
  export interface UnbornCalls {
9
10
  readonly database: AuthDatabase;
10
- readonly tokens: Pick<TokenCalls, 'list'>;
11
+ readonly tokens: Pick<Tokens.Tokens['Service'], 'list'>;
11
12
  /** Whether Git holds a repo under `<login>/`, or couldn't say. */
12
- readonly ownsRepos: (login: string) => Promise<boolean>;
13
+ readonly ownsRepos: (login: string) => Effect.Effect<boolean>;
13
14
  }
14
15
 
15
16
  /** A person a passkey sign-up made, before its passkey and session were written. */
@@ -38,21 +39,32 @@ export type Forgotten =
38
39
  * at `''`, so this reads a page per 200 of the host's sessions, Git's largest. The 3 tries a 10 s
39
40
  * of passkey sign-up bound it, and a list by subject would read one.
40
41
  */
41
- const holdsToken = async (
42
- tokens: UnbornCalls['tokens'],
43
- login: string,
44
- after?: string,
45
- ): Promise<boolean> => {
46
- const page = await tokens.list(
47
- { prefix: '' },
48
- { state: 'all', page: after === undefined ? { limit: 200 } : { limit: 200, after } },
49
- );
50
- if (page.kind !== 'success') return true;
51
-
52
- if (page.value.items.some((token) => token.subject.id === login)) return true;
53
-
54
- return page.value.next === undefined ? false : holdsToken(tokens, login, page.value.next);
55
- };
42
+ const holdsToken = Effect.fnUntraced(
43
+ function* (tokens: UnbornCalls['tokens'], login: string) {
44
+ let after: string | undefined;
45
+
46
+ do {
47
+ const page = yield* tokens.list(
48
+ { prefix: '' },
49
+ { state: 'all', page: after === undefined ? { limit: 200 } : { limit: 200, after } },
50
+ );
51
+ if (page.items.some((token) => token.subject.id === login)) return true;
52
+
53
+ after = page.next;
54
+ } while (after !== undefined);
55
+
56
+ return false;
57
+ },
58
+ Effect.orElseSucceed(() => true),
59
+ );
60
+
61
+ /** What Git holds for `login`, a token before a repo, or `undefined` for neither. */
62
+ const gitHolds = (calls: UnbornCalls, login: string) =>
63
+ Effect.gen(function* () {
64
+ if (yield* holdsToken(calls.tokens, login)) return 'token' as const;
65
+
66
+ return (yield* calls.ownsRepos(login)) ? ('repo' as const) : undefined;
67
+ });
56
68
 
57
69
  /**
58
70
  * Whether an org names the person: a `member` row, or a pending `invitation` to their email. Both
@@ -88,9 +100,10 @@ export const forgetUnborn = async (calls: UnbornCalls, person: Unborn): Promise<
88
100
 
89
101
  return { kind: 'kept', reason } as const;
90
102
  };
91
- if (await holdsToken(calls.tokens, person.login)) return kept('token');
92
103
 
93
- if (await calls.ownsRepos(person.login)) return kept('repo');
104
+ // Better Auth's hook is the edge, where Git's reads run.
105
+ const holds = await Effect.runPromise(gitHolds(calls, person.login));
106
+ if (holds !== undefined) return kept(holds);
94
107
 
95
108
  const outcome = await withPersonLocked(calls.database, person.id, async (write) => {
96
109
  if ((await write(orgHolds(person.id))) > 0) return 'org';
@@ -67,7 +67,7 @@ catalog:
67
67
  # The app's Markdown renderer: words, a WebAssembly parser, with hooks for GitHub's alerts,
68
68
  # anchors, references and URLs (Q213). Apache-2.0.
69
69
  '@pierre/words': 0.3.0
70
- '@ref0/workspace': 0.13.0
70
+ '@ref0/workspace': 0.17.0
71
71
  '@tailwindcss/vite': 4.3.5
72
72
  # The app's stack: TanStack Start, its router and Query, and React, as spike F ran them, at the
73
73
  # newest releases past pnpm's minimum release age.
@@ -221,4 +221,4 @@ allowBuilds:
221
221
  workerd: true
222
222
 
223
223
  minimumReleaseAgeExclude:
224
- - '@ref0/workspace@0.13.0'
224
+ - '@ref0/workspace@0.17.0'
@@ -138,9 +138,9 @@ const filesUnder = /* @__PURE__ */ Effect.fnUntraced(function* (folder, keep, un
138
138
  const found = [];
139
139
  for (const entry of yield* fs.readDirectory(`${folder}/${under}`)) {
140
140
  const path = `${under}${entry}`;
141
- if ((yield* fs.stat(`${folder}/${path}`)).type === "Directory") {
142
- if (entered(path)) found.push(...yield* filesUnder(folder, keep, `${path}/`));
143
- } else if (keep(path)) found.push(path);
141
+ if (!entered(path) || /\.test\.tsx?$/.test(entry)) continue;
142
+ if ((yield* fs.stat(`${folder}/${path}`)).type === "Directory") found.push(...yield* filesUnder(folder, keep, `${path}/`));
143
+ else if (keep(path)) found.push(path);
144
144
  }
145
145
  return found;
146
146
  });
@@ -14,13 +14,12 @@ import * as Schema from "effect/Schema";
14
14
  import * as Duration from "effect/Duration";
15
15
  import * as DateTime from "effect/DateTime";
16
16
  import * as Flag from "effect/cli/Flag";
17
- import { RestClient } from "@ref0/git";
17
+ import { RestClient, deviceGrant, ghClientId, ghWriteScope, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths } from "@ref0/git";
18
18
  import * as Argument from "effect/cli/Argument";
19
19
  import * as Clock from "effect/Clock";
20
20
  import * as HttpClient from "effect/http/HttpClient";
21
21
  import * as HttpClientRequest from "effect/http/HttpClientRequest";
22
22
  import * as Result from "effect/Result";
23
- import { deviceGrant, ghClientId, ghWriteScope, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths } from "@ref0/git/auth";
24
23
  // src/cli/sign-in.ts
25
24
  /**
26
25
  * `login`, `logout` and `whoami`. A token reaches Git's helpers through `git credential approve`
@@ -42,7 +41,7 @@ const pollMissesMost = 5;
42
41
  const tooManyRequests = 429;
43
42
  /**
44
43
  * A form POST to the host's sign-in, at its origin's root whatever its base path, as GitHub's is,
45
- * with its status and its JSON read by `read`, as `@ref0/git/auth` reads the server's answer, or
44
+ * with its status and its JSON read by `read`, as `@ref0/git` reads the server's answer, or
46
45
  * `undefined`, within `within` ms. It follows no redirect, which could send the device code, and
47
46
  * the token, elsewhere.
48
47
  */
package/dist/init/app.mjs CHANGED
@@ -2,7 +2,7 @@ import { bucketLine, bucketName, devVars, limitsLine, looseInfraImport, mergePac
2
2
  import { ignoring, importLine, lines, listed, withCli } from "./files.mjs";
3
3
  import { bucketLines, firstImports, infraImports, partsOf, storeLines } from "./node.mjs";
4
4
  import { specOf } from "./versions.mjs";
5
- import { lfsLines, looseSays, writtenCpu } from "./git-module.mjs";
5
+ import { lfsLines, looseSays, workerStoreLines, writtenCpu } from "./git-module.mjs";
6
6
  import { jsonString, manifestText } from "./jsonc.mjs";
7
7
  import { filled, platforms, templates, unless } from "./template.mjs";
8
8
  import { blockOf, catalogOf } from "./workspace.mjs";
@@ -93,7 +93,7 @@ const gitImport = (choices) => importLine([
93
93
  "Merges",
94
94
  choices.queue === "on" && "MergeQueue",
95
95
  "Objects",
96
- "RepoRecords",
96
+ "Repos",
97
97
  "Rest",
98
98
  "SignIn",
99
99
  "Tokens"
@@ -104,6 +104,7 @@ const githubImport = (choices) => importLine([
104
104
  "Deployments",
105
105
  "GitHub",
106
106
  "Inbox",
107
+ "IssueLists",
107
108
  choices.objects === "packs" && "Releases",
108
109
  "RepoGrants",
109
110
  "Search",
@@ -134,7 +135,7 @@ const cloudflareGit = (choices) => {
134
135
  effectImport: unless(packs, ""),
135
136
  safety: unless(packs, "binds the objects, and D1"),
136
137
  bucket: unless(packs, ""),
137
- adapter: unless(packs, "/** The records and job objects. */\nconst adapter = layer({ records: env.RECORDS, jobs: env.JOBS });"),
138
+ adapter: unless(packs, `/** The records and job objects. */\n${workerStoreLines(writtenCpu)}\n\nconst adapter = store;`),
138
139
  uploads: unless(packs, ""),
139
140
  lfs: packs ? `${lfsLines(" ", writtenCpu)}\n` : "",
140
141
  ...bodySlots(choices)
@@ -158,7 +159,7 @@ const dialectOn = {
158
159
  const nodeHead = (choices) => {
159
160
  const queue = choices.queue === "on";
160
161
  const dialect = dialectOn[choices.records];
161
- return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`, gitImport(choices), queue && "import type { MergeInput, MergePlan } from '@ref0/git';", githubImport(choices), "import * as Collaborators from '@ref0/github/collaborators';", "import * as Languages from '@ref0/github/languages';", infraImports(choices), "import { xdiff } from '@ref0/xdiff-wasm/node';", "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "import * as ManagedRuntime from 'effect/ManagedRuntime';", "", "import { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';", "import { repoGrantsDropped } from './context/repo-grants.ts';", "import { repoIcons } from './context/repo-icons.ts';", `import { env${partsOf(choices).length > 0 ? ", need" : ""} } from './env.ts';`, "import {", " admin,", " approvalPage,", " type GrantsPolicy,", " hostPolicy,", " hostRules,", " type Identify,", "} from './policy.ts';", "import { privateReposOf } from './private-repos.ts';", "import { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';", "import { avatars } from './signin/avatars.ts';", "import { clientIpHeader } from './signin/client-ip.ts';", "import { appAuth } from './signin/host-session.ts';", "import { orgsOver } from './signin/orgs.ts';", "import { grantsOver } from './signin/repo-grants.ts';", "import { sealKey } from './signin/seal.ts';", "", "/** What the app reads from `.env`, as the server's entry reads it here. */", "export { env };", "", storeLines(choices), bucketLines(choices), "", peopleOn[choices.records], "");
162
+ return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`, gitImport(choices), queue && "import type { MergeInput, MergePlan } from '@ref0/git';", githubImport(choices), "import * as Collaborators from '@ref0/github/collaborators';", "import * as Languages from '@ref0/github/languages';", infraImports(choices), "import { xdiff } from '@ref0/xdiff-wasm/node';", "import * as Effect from 'effect/Effect';", "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "", "import {", " hostLayer,", " onHost,", " type OnHost,", " peopleOver,", " repoRecordsOn,", " tokensOn,", "} from './context/host.ts';", "import { repoGrantsDropped } from './context/repo-grants.ts';", "import { repoIcons } from './context/repo-icons.ts';", `import { env${partsOf(choices).length > 0 ? ", need" : ""} } from './env.ts';`, "import {", " admin,", " approvalPage,", " type GrantsPolicy,", " hostPolicy,", " hostRules,", " type Identify,", "} from './policy.ts';", "import { privateReposOf } from './private-repos.ts';", "import { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';", "import { avatars } from './signin/avatars.ts';", "import { clientIpHeader } from './signin/client-ip.ts';", "import { appAuth } from './signin/host-session.ts';", "import { orgsOver } from './signin/orgs.ts';", "import { grantsOver } from './signin/repo-grants.ts';", "import { sealKey } from './signin/seal.ts';", "", "/** What the app reads from `.env`, as the server's entry reads it here. */", "export { env };", "", storeLines(choices), bucketLines(choices), "", peopleOn[choices.records], "");
162
163
  };
163
164
  /** The app's `src/git.ts` on Node: `apps/github`'s own past its head, Node's head and parts in Cloudflare's place. */
164
165
  const nodeGit = (choices) => filled(templates.appGitNode, {
@@ -1,5 +1,5 @@
1
1
  import { fitted, ignoring, lines, withCli, withDependencies, withLines } from "./files.mjs";
2
- import { effectImports, featuresLines, gitDependencies, gitImports, gitPackages, header, runtimeLines, writtenCpu } from "./git-module.mjs";
2
+ import { effectImports, featuresLines, gitDependencies, gitImports, gitPackages, header, runtimeLines, workerStoreLines, writtenCpu } from "./git-module.mjs";
3
3
  import { itemsAt, jsonString, manifestText, nodeAt, parseJsonc, stringAt, withEntries, withValue } from "./jsonc.mjs";
4
4
  import { filled, templates, unless } from "./template.mjs";
5
5
  import { catalog } from "./metadata.mjs";
@@ -31,8 +31,6 @@ const gitClasses = [{
31
31
  }];
32
32
  /** The infra import of a `src/git.ts` with no bucket. */
33
33
  const looseInfraImport = "import { layer, toJobObject, toRecordsObject } from '@ref0/infra/cloudflare';";
34
- /** The adapter of a `src/git.ts` with no bucket: the records and jobs' Layer alone. */
35
- const looseAdapter = lines("/** The records and job objects. */", "const adapter = layer({ records: env.RECORDS, jobs: env.JOBS });", "", "");
36
34
  /** A push's pack upload, once the bucket signs parts: `signed` only with R2's S3 credentials. */
37
35
  const uploads = lines(" // A push past 64 MiB may upload its pack, once the bucket signs parts.", " signed === undefined", " ? Layer.empty", " : Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), signed),");
38
36
  /** `src/git.ts`: `examples/git-worker`'s own, with what it serves, the store and the queue as chosen. */
@@ -45,7 +43,10 @@ const gitModule = (choices, envFile, cpu) => {
45
43
  effectImports: `${effectImports(choices, true)}\n`,
46
44
  envFile: `'${envFile}'`,
47
45
  safety: unless(packs, "binds the objects"),
48
- bucket: unless(packs, looseAdapter),
46
+ bucket: unless(packs, ""),
47
+ storeAbout: unless(packs, "/** The records and job objects. */\n"),
48
+ store: workerStoreLines(cpu),
49
+ adapter: unless(packs, "const adapter = store;\n\n"),
49
50
  merge: unless(choices.queue === "on", ""),
50
51
  features: `${featuresLines(choices, {
51
52
  admins: true,
@@ -225,9 +226,9 @@ const devVars = (names, secret) => ({
225
226
  merge: (current) => withLines(current, names.map((name) => `${name}=${Redacted.value(secret())}`), (line) => line.split("=")[0] ?? "")
226
227
  });
227
228
  /**
228
- * The packs' bucket's rule that aborts an upload a day after it began: one a crashed merge left,
229
- * which no row names, ends no other way (#2226). Alchemy clears every rule its bucket doesn't
230
- * declare, so it goes in the bucket's line, as `examples/git-alchemy` has it.
229
+ * The packs' bucket's lifecycle rules: abort incomplete uploads after 1 day and expire crash-left
230
+ * `uploads/` sidecars after 2 days (strictly longer than the abort age so live sidecars outlive
231
+ * their upload). Alchemy clears undeclared rules, so both go here, as in `examples/git-alchemy`.
231
232
  */
232
233
  const abortUploads = [
233
234
  " lifecycleRules: [",
@@ -235,6 +236,11 @@ const abortUploads = [
235
236
  " id: \"abort-uploads\",",
236
237
  " abortMultipartUploadsTransition: { condition: { type: \"Age\", maxAge: 86_400 } },",
237
238
  " },",
239
+ " {",
240
+ " id: \"expire-upload-sidecars\",",
241
+ " prefix: \"uploads/\",",
242
+ " deleteObjectsTransition: { condition: { type: \"Age\", maxAge: 172_800 } },",
243
+ " },",
238
244
  " ],"
239
245
  ];
240
246
  /** Alchemy's lines for Git's part of a Worker's `env`, as the Alchemy guide gives them. */
@@ -373,4 +379,4 @@ const cloudflareOutput = (choices, project, secret, vendor) => {
373
379
  next: "Check it, then deploy it"
374
380
  };
375
381
  };
376
- export { adminsVar, bucketLine, bucketName, cloudflareOutput, configCpu, configParts, devVars, gitClasses, gitModule, gitSecrets, limitsLine, looseAdapter, looseInfraImport, mergePackage, mergeWrangler, secretFiles };
382
+ export { adminsVar, bucketLine, bucketName, cloudflareOutput, configCpu, configParts, devVars, gitClasses, gitModule, gitSecrets, limitsLine, looseInfraImport, mergePackage, mergeWrangler, secretFiles };
@@ -8,7 +8,7 @@ import * as Schema from "effect/Schema";
8
8
  // src/init/create.ts
9
9
  /** The create commands' packages, at the versions each was run at on 20 Nov, as `init.md` lists. */
10
10
  const creators = {
11
- next: "create-next-app@16.4.6",
11
+ next: "create-next-app@16.5.0",
12
12
  sveltekit: "sv@1.7.1",
13
13
  nuxt: "create-nuxt@4.1.1"
14
14
  };
@@ -73,7 +73,7 @@ const gitImports = (choices, admins = false) => lines(namedImport(gitNames(choic
73
73
  * Effect's imports, which the composition is written in, and with `admins` what a Worker's policy
74
74
  * over its `ADMINS` reads the host's tokens with.
75
75
  */
76
- const effectImports = (choices, admins = false) => lines(admins && "import * as Context from 'effect/Context';", admins && "import * as Effect from 'effect/Effect';", choices.serve === "github" && "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "import * as ManagedRuntime from 'effect/ManagedRuntime';", admins && "import * as Option from 'effect/Option';", "import * as Redacted from 'effect/Redacted';");
76
+ const effectImports = (choices, admins = false) => lines(admins && "import * as Context from 'effect/Context';", admins && "import * as Effect from 'effect/Effect';", choices.serve === "github" && "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", admins && "import * as Option from 'effect/Option';", "import * as Redacted from 'effect/Redacted';");
77
77
  /** Who `ADMIN_TOKEN` signs in as. */
78
78
  const adminLines = lines("/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */", "const admin = { id: '_admin' };", "");
79
79
  /** How the queue writes an entry onto `main`, when there's a queue. */
@@ -88,17 +88,25 @@ const mergeLines = (choices) => choices.queue === "on" && lines("/** How the que
88
88
  */
89
89
  const policyLines = lines("/**", " * Who may do what: a visitor signs in first, and the admin makes repos and tokens but never", " * pushes.", " */", "const policy = Policy.make(({ caller: { actor }, operation }) => {", " if (actor.anonymous === true) return Policy.reject({ message: 'Sign in first' });", "", " if (actor.id === admin.id && operation.kind === 'push') {", " return Policy.reject({", " message: \"The admin token can't push\",", " hint: 'Make a write token for yourself: npx ref0-git tokens create --help',", " });", " }", "", " return Policy.accept();", "});", "");
90
90
  /** What one push may carry into `Objects.layerRecords()`, as `@ref0/git` holds it. */
91
- const looseSays = `up to ${looseLimits.objects.toLocaleString("en-US")} objects and ${looseLimits.bytes / 1024 / 1024} MiB a push`;
91
+ const looseSays = `up to ${looseLimits.objects.toLocaleString("en-US")} objects and ${looseLimits.bytes / 1024 / 1024} MiB a push, and ${looseLimits.fileBytes / 1024 / 1024} MiB a file`;
92
92
  /** What a Worker `init` writes its config whole for: `workerCpuMs`, in `wrangler.jsonc`. */
93
93
  const writtenCpu = {
94
94
  ms: workerCpuMs,
95
95
  file: "wrangler.jsonc"
96
96
  };
97
+ /** `cpu`'s milliseconds as a TypeScript literal, `300_000`. */
98
+ const cpuMsText = (cpu) => cpu.ms.toLocaleString("en-US").replaceAll(",", "_");
97
99
  /**
98
100
  * `Lfs.layer`'s line at `indent`, with its comment: on a Worker whose config sets `limits.cpu_ms`,
99
101
  * its uploads held to that `cpu`, and elsewhere to what the adapter says its platform gives.
100
102
  */
101
- const lfsLines = (indent, cpu) => cpu === void 0 ? `${indent}// Git LFS, its objects in the bucket beside the packs.\n${indent}Lfs.layer(),` : lines(`${indent}// Git LFS, its objects in the bucket beside the packs. An upload through the Worker may use`, `${indent}// \`limits.cpu_ms\` from ${cpu.file}: raise both together.`, `${indent}Lfs.layer({ cpuMs: ${cpu.ms.toLocaleString("en-US").replaceAll(",", "_")} }),`);
103
+ const lfsLines = (indent, cpu) => cpu === void 0 ? `${indent}// Git LFS, its objects in the bucket beside the packs.\n${indent}Lfs.layer(),` : lines(`${indent}// Git LFS, its objects in the bucket beside the packs. An upload through the Worker may use`, `${indent}// \`limits.cpu_ms\` from ${cpu.file}: raise both together.`, `${indent}Lfs.layer({ cpuMs: ${cpuMsText(cpu)} }),`);
104
+ /**
105
+ * A Worker's records and job objects, its `store`: on a Worker whose config sets `limits.cpu_ms`,
106
+ * a job object chains its tries within one alarm up to that `cpu`, and elsewhere within Workers'
107
+ * default.
108
+ */
109
+ const workerStoreLines = (cpu) => cpu === void 0 ? "const store = layer({ records: env.RECORDS, jobs: env.JOBS });" : lines("const store = layer({", " records: env.RECORDS,", " jobs: env.JOBS,", ` // \`limits.cpu_ms\` from ${cpu.file}, so a job object chains its tries within one alarm:`, " // raise both together.", ` requestLimits: { cpuMs: ${cpuMsText(cpu)} },`, "});");
102
110
  /**
103
111
  * The queue's line: under the drop-in, a pull request's key merges once, so a push to it after its
104
112
  * merge isn't queued again before the drop-in sees the merge.
@@ -137,5 +145,5 @@ const gitOptions = (choices, maxDuration) => {
137
145
  * The admin's sign-in, then `export const runtime`: the whole host, Git with its features over the
138
146
  * adapter, one runtime that every entry, object and job runner takes.
139
147
  */
140
- const runtimeLines = (choices, parts) => lines(parts.bootstrap === true ? lines("/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */", "const auth =", ` ${parts.token} === undefined || ${parts.token} === ''`, " ? Layer.empty", ` : Auth.layer(Auth.bearer({ token: Redacted.make(${parts.token}), actor: bootstrap }));`) : lines("/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */", `const auth = Auth.bearer({ token: Redacted.make(${parts.token}), actor: admin });`), "", "/**", " * The whole host, one runtime that every request and job shares: Git and its features over the", ` * adapter, deciding with \`policy\`, and the ${parts.bootstrap === true ? "bootstrap" : "admin"} signing in with \`auth\`.`, parts.jobs !== void 0 && ` * ${parts.jobs}`, " */", "export const runtime = ManagedRuntime.make(", parts.maxDuration !== void 0 && lines(" // The functions' `maxDuration`, from `vercel.json`: a clone that would outrun it ends first,", " // with Git's own message."), ` Git.layer(${gitOptions(choices, parts.maxDuration)}, ${choices.serve === "github" ? "github" : "features"}).pipe(`, " Layer.provide(Policy.layer(policy)),", parts.bootstrap === true ? " Layer.provide(auth)," : " Layer.provide(Auth.layer(auth)),", choices.objects === "packs" ? " Layer.provide(Objects.layer())," : ` // Each object a row in its push's commit: no bucket, ${looseSays}.\n Layer.provide(Objects.layerRecords()),`, ` Layer.provideMerge(${parts.adapter}),`, " ),", ");", "");
141
- export { adminLines, effectImports, featuresLines, gitDependencies, gitImports, gitPackages, header, lfsLines, looseSays, mergeLines, policyLines, queueLine, repoHint, runtimeLines, writtenCpu };
148
+ const runtimeLines = (choices, parts) => lines(parts.bootstrap === true ? lines("/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */", "const auth =", ` ${parts.token} === undefined || ${parts.token} === ''`, " ? Layer.empty", ` : Auth.layer(Auth.bearer({ token: Redacted.make(${parts.token}), actor: bootstrap }));`) : lines("/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */", `const auth = Auth.bearer({ token: Redacted.make(${parts.token}), actor: admin });`), "", "/**", " * The whole host, one runtime that every request and job shares: Git and its features over the", ` * adapter, deciding with \`policy\`, and the ${parts.bootstrap === true ? "bootstrap" : "admin"} signing in with \`auth\`.`, parts.jobs !== void 0 && ` * ${parts.jobs}`, " */", "export const runtime = Git.runtime(", parts.maxDuration !== void 0 && lines(" // The functions' `maxDuration`, from `vercel.json`: a clone that would outrun it ends first,", " // with Git's own message."), ` Git.layer(${gitOptions(choices, parts.maxDuration)}, ${choices.serve === "github" ? "github" : "features"}).pipe(`, " Layer.provide(Policy.layer(policy)),", parts.bootstrap === true ? " Layer.provide(auth)," : " Layer.provide(Auth.layer(auth)),", choices.objects === "packs" ? " Layer.provide(Objects.layer())," : ` // Each object a row in its push's commit: no bucket, ${looseSays}.\n Layer.provide(Objects.layerRecords()),`, ` Layer.provideMerge(${parts.adapter}),`, " ),", ");", "");
149
+ export { adminLines, effectImports, featuresLines, gitDependencies, gitImports, gitPackages, header, lfsLines, looseSays, mergeLines, policyLines, queueLine, repoHint, runtimeLines, workerStoreLines, writtenCpu };
@@ -1,6 +1,6 @@
1
1
  // src/init/metadata.ts
2
2
  /** The version `ref0-git`, `create-ref0-git` and Git's packages release at, all at once (Q738). */
3
- const release = "0.14.0";
3
+ const release = "0.25.0";
4
4
  /** The packages the app depends on, by their folder in a checkout's `packages/`. */
5
5
  const appPackages = [
6
6
  "infra",
@@ -88,7 +88,7 @@ const nodeModule = (choices, jobs) => {
88
88
  /** A stop waits this long for the responses still open, such as one a reader stopped reading. */
89
89
  const stopGrace = 1e4;
90
90
  /** The lines in `src/main.ts` that start the jobs and serve Git. */
91
- const serveLines = lines("const stop = Node.toJobRunner(runtime);", "", "const handler = toNodeHandler(runtime);");
91
+ const serveLines = lines("const stop = Node.toJobRunner(runtime);", "", "// Behind a proxy that ends TLS, set ORIGIN to the origin it serves, such as", "// https://git.example.com, which Git's links are built from. Unset, each request's connection's.", "const handler = toNodeHandler(runtime, { origin: process.env.ORIGIN });");
92
92
  /** Where `src/main.ts` serves Git when `PORT` is unset. */
93
93
  const mainOrigin = "http://localhost:8080";
94
94
  const mainPort = new URL(mainOrigin).port;
@@ -5,7 +5,7 @@ import { storePackages } from "./metadata.mjs";
5
5
  const recordsPart = (records) => records === "postgres" ? {
6
6
  external: ["import pg from 'pg';"],
7
7
  infra: "import * as Postgres from '@ref0/infra/postgres';",
8
- code: lines("const store = Postgres.layer({", " pool: new pg.Pool({ connectionString: need('DATABASE_URL') }),", " wake,", "});"),
8
+ code: lines("const store = Postgres.layer({", " // A call waits at most 10 s for one of the pool's connections, then fails, never hangs.", " pool: new pg.Pool({ connectionString: need('DATABASE_URL'), connectionTimeoutMillis: 10_000 }),", " wake,", "});"),
9
9
  variables: ["DATABASE_URL"],
10
10
  dependencies: [["pg", storePackages.pg]],
11
11
  devDependencies: [["@types/pg", storePackages["@types/pg"]]]
@@ -64,6 +64,9 @@ const workerGitSlots = [
64
64
  "envFile",
65
65
  "safety",
66
66
  "bucket",
67
+ "storeAbout",
68
+ "store",
69
+ "adapter",
67
70
  "merge",
68
71
  "features",
69
72
  "runtime"