@milesroxas/design-hub 0.12.0 → 0.14.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 (92) hide show
  1. package/README.md +5 -5
  2. package/core/prototype.test.ts +12 -1
  3. package/core/prototype.ts +21 -2
  4. package/core/review/model.ts +71 -6
  5. package/core/review/service.test.ts +575 -39
  6. package/core/review/service.ts +452 -25
  7. package/core/review/store.ts +47 -6
  8. package/core/review/suite-kv.ts +17 -0
  9. package/dist/core/prototype.d.ts +20 -2
  10. package/dist/core/prototype.js +17 -2
  11. package/dist/core/review/model.d.ts +42 -3
  12. package/dist/core/review/model.js +52 -3
  13. package/dist/core/review/service.d.ts +81 -7
  14. package/dist/core/review/service.js +407 -23
  15. package/dist/core/review/store.d.ts +29 -2
  16. package/dist/core/review/store.js +6 -2
  17. package/dist/core/review/suite-kv.d.ts +7 -0
  18. package/dist/core/review/suite-kv.js +12 -0
  19. package/dist/scripts/client.d.ts +1 -1
  20. package/dist/scripts/client.js +4 -4
  21. package/dist/scripts/lib/cli.js +5 -0
  22. package/dist/scripts/lib/dns.d.ts +16 -2
  23. package/dist/scripts/lib/dns.js +66 -3
  24. package/dist/scripts/lib/fake-host.d.ts +17 -3
  25. package/dist/scripts/lib/fake-host.js +56 -10
  26. package/dist/scripts/lib/host.d.ts +15 -25
  27. package/dist/scripts/lib/host.js +15 -324
  28. package/dist/scripts/lib/resend.d.ts +36 -0
  29. package/dist/scripts/lib/resend.js +66 -0
  30. package/dist/scripts/lib/studio-deps.d.ts +23 -0
  31. package/dist/scripts/lib/studio-deps.js +46 -16
  32. package/dist/scripts/lib/studios.d.ts +16 -6
  33. package/dist/scripts/lib/studios.js +28 -10
  34. package/dist/scripts/lib/vercel-host.d.ts +17 -0
  35. package/dist/scripts/lib/vercel-host.js +416 -0
  36. package/dist/scripts/people.d.ts +16 -4
  37. package/dist/scripts/people.js +67 -17
  38. package/dist/scripts/share.js +3 -2
  39. package/dist/scripts/studio.d.ts +26 -4
  40. package/dist/scripts/studio.js +364 -19
  41. package/dist/server/api.d.ts +20 -7
  42. package/dist/server/api.js +83 -27
  43. package/dist/server/dev.js +21 -1
  44. package/dist/server/gate.d.ts +120 -0
  45. package/dist/server/gate.js +808 -0
  46. package/dist/server/mailer.d.ts +60 -0
  47. package/dist/server/mailer.js +104 -0
  48. package/dist/server/mailers/fake.d.ts +8 -0
  49. package/dist/server/mailers/fake.js +16 -0
  50. package/dist/server/mailers/resend.d.ts +21 -0
  51. package/dist/server/mailers/resend.js +49 -0
  52. package/dist/server/mark.d.ts +17 -0
  53. package/dist/server/mark.js +46 -1
  54. package/dist/server/session.d.ts +2 -1
  55. package/dist/server/session.js +6 -3
  56. package/dist/server/stores/backends.d.ts +22 -0
  57. package/dist/server/stores/backends.js +96 -0
  58. package/dist/server/{fake-upstash.js → stores/fake-upstash.js} +1 -1
  59. package/dist/server/stores/index.d.ts +41 -0
  60. package/dist/server/stores/index.js +63 -0
  61. package/dist/server/stores/pglite.d.ts +16 -0
  62. package/dist/server/stores/pglite.js +98 -0
  63. package/dist/server/stores/postgres.d.ts +63 -0
  64. package/dist/server/stores/postgres.js +153 -0
  65. package/dist/server/{upstash.d.ts → stores/upstash.d.ts} +1 -1
  66. package/dist/vercel/files.js +1 -1
  67. package/dist/vercel/proxy.d.ts +6 -82
  68. package/dist/vercel/proxy.js +24 -524
  69. package/dist/vite/plugin.js +4 -2
  70. package/kit/ui/Menu.tsx +29 -18
  71. package/kit/ui/layer.ts +41 -0
  72. package/package.json +3 -1
  73. package/shell/review/Bar.tsx +1 -0
  74. package/shell/review/Card.tsx +17 -7
  75. package/shell/review/People.tsx +908 -134
  76. package/shell/review/Review.tsx +2 -2
  77. package/shell/review/anchor.ts +6 -1
  78. package/shell/review/client.ts +41 -7
  79. package/shell/review/menu-place.test.ts +41 -0
  80. package/shell/review/place.test.ts +26 -1
  81. package/shell/review/place.ts +17 -0
  82. package/shell/review/review.css +97 -11
  83. package/shell/review/view.test.ts +115 -1
  84. package/shell/review/view.ts +92 -2
  85. package/shell/studio/StudioHub.tsx +1 -0
  86. package/shell/studio/hub.css +99 -13
  87. package/skills/miles-deploy/SKILL.md +26 -4
  88. package/templates/studio/.env.example +9 -0
  89. package/templates/studio/README.md +13 -0
  90. package/templates/studio/package.json +1 -1
  91. /package/dist/server/{fake-upstash.d.ts → stores/fake-upstash.d.ts} +0 -0
  92. /package/dist/server/{upstash.js → stores/upstash.js} +0 -0
@@ -4,8 +4,9 @@ import { isAdded, STUDIO_SITE, } from '../core/review/model.js';
4
4
  import { createReview, NO_PROJECT, ReviewError, } from '../core/review/service.js';
5
5
  import { jevTriager } from '../core/review/triage.js';
6
6
  import { hostOf } from './hosts.js';
7
+ import { chooseMailer, sendInvite } from './mailer.js';
7
8
  import { clearedCookie, PERSON_COOKIE, readCookie, readGate, readPersonToken, sameOrigin, studioGate, } from './session.js';
8
- import { storeConfig, upstashKV } from './upstash.js';
9
+ import { chooseStore } from './stores/index.js';
9
10
  export const API_PATH = '/api/review';
10
11
  const MAX_BODY_BYTES = 64 * 1024;
11
12
  const STORE_DOWN = 'The review store did not answer. Try again.';
@@ -36,7 +37,8 @@ function projectScope(scope) {
36
37
  }
37
38
  /** What a client's hub shows of a project: its slug, for the link, and its name. */
38
39
  const listed = ({ slug, name }) => ({ slug, name });
39
- async function query(op, params, { review, actor, scope }) {
40
+ async function query(op, params, ctx) {
41
+ const { review, actor, scope } = ctx;
40
42
  switch (op) {
41
43
  case 'me':
42
44
  // The client is this request's: the page judges its controls in it, as the service does every op.
@@ -57,19 +59,49 @@ async function query(op, params, { review, actor, scope }) {
57
59
  return { projects: (await review.listProjects(scope, actor)).map(listed) };
58
60
  case 'people':
59
61
  return { people: (await review.listPeople(scope, actor)).map(visible) };
60
- case 'access':
61
- return { access: await review.defaultAccess(scope, actor) };
62
+ case 'access': {
63
+ // The default first: it refuses anyone but Studio, so a Client never learns how mail stands.
64
+ const access = await review.defaultAccess(scope, actor);
65
+ return { access, mail: ctx.mailUnknown ? null : await mailState(review, ctx.mailer ?? null) };
66
+ }
62
67
  default:
63
68
  return undefined;
64
69
  }
65
70
  }
71
+ /** How sign-in mail stands, for Studio: off with no mailer, failing while the last failed send is newer than the last that went (email.md, "When mail breaks"). */
72
+ async function mailState(review, mailer) {
73
+ if (!mailer)
74
+ return 'off';
75
+ const { okAt, failedAt } = await review.mailRecord();
76
+ return failedAt !== null && (okAt === null || failedAt > okAt) ? 'failing' : 'on';
77
+ }
66
78
  /** A link as a client's host answers it: at its own root, where its gate answers it. */
67
79
  const link = (r) => ({ person: visible(r.person), link: `/invite/${r.token}` });
80
+ /**
81
+ * Mails a new person their invite (email.md, E10), unless Studio said not to
82
+ * (`mail: false`), they have no address, the studio has no mailer, or there
83
+ * is no host to name (sendInvite).
84
+ */
85
+ async function invite(review, { mailer, homeOf }, issued, wanted) {
86
+ const { person, token } = issued;
87
+ const home = wanted === false ? null : homeOf(person);
88
+ if (!mailer || !home || !person.email)
89
+ return 'off';
90
+ return sendInvite(mailer, review, { ...person, email: person.email }, token, home);
91
+ }
68
92
  /** Studio's commands over people, their links and how long they keep access. */
69
- async function peopleCommand(op, b, { review, actor, at, link }) {
93
+ async function peopleCommand(op, b, { review, actor, at, link, invites }) {
70
94
  switch (op) {
71
- case 'people.add':
72
- return link(await review.addPerson(at, actor, { name: b.name, team: b.team, kind: b.kind, access: b.access }));
95
+ case 'people.add': {
96
+ const issued = await review.addPerson(at, actor, {
97
+ name: b.name,
98
+ team: b.team,
99
+ kind: b.kind,
100
+ access: b.access,
101
+ email: b.email,
102
+ });
103
+ return { ...link(issued), mailed: await invite(review, invites, issued, b.mail) };
104
+ }
73
105
  case 'people.link':
74
106
  return link(await review.newLink(at, actor, str(b.id)));
75
107
  case 'people.signOut':
@@ -78,6 +110,9 @@ async function peopleCommand(op, b, { review, actor, at, link }) {
78
110
  return { person: visible(await review.revoke(at, actor, str(b.id))) };
79
111
  case 'people.access':
80
112
  return { person: visible(await review.setAccess(at, actor, str(b.id), b.access)) };
113
+ case 'people.email':
114
+ // `email` must be sent: an address sets or changes it, null or empty clears it.
115
+ return { person: visible(await review.setEmail(at, actor, str(b.id), b.email)) };
81
116
  default:
82
117
  return undefined;
83
118
  }
@@ -93,12 +128,22 @@ const PROJECT_COMMANDS = [
93
128
  'prototype.audience',
94
129
  'control.audience',
95
130
  ];
131
+ /**
132
+ * Invites where a client's people are added: a Client's names the host the
133
+ * context gives, their client's own. A Studio person signs in by email on
134
+ * the studio's own host, which a client's host does not know, so none is
135
+ * mailed here; the studio hub mails them.
136
+ */
137
+ const clientInvites = ({ mailer = null, host = null }) => ({
138
+ mailer,
139
+ homeOf: (p) => (p.client === null ? null : host),
140
+ });
96
141
  async function command(op, b, ctx) {
97
142
  const { review, actor } = ctx;
98
143
  if (op === 'access.set')
99
144
  return { access: await review.setDefaultAccess(ctx.scope, actor, b.access) };
100
145
  if (!PROJECT_COMMANDS.includes(op))
101
- return peopleCommand(op, b, { review, actor, at: ctx.scope, link });
146
+ return peopleCommand(op, b, { review, actor, at: ctx.scope, link, invites: clientInvites(ctx) });
102
147
  const scope = projectScope(ctx.scope);
103
148
  const at = () => ({ prototype: prototypeOf(b.prototype), id: str(b.id) });
104
149
  switch (op) {
@@ -212,6 +257,7 @@ const PEOPLE_COMMANDS = [
212
257
  'people.signOut',
213
258
  'people.revoke',
214
259
  'people.access',
260
+ 'people.email',
215
261
  ];
216
262
  /**
217
263
  * The review API on the studio's own host, for a Studio person signed in
@@ -224,7 +270,7 @@ const PEOPLE_COMMANDS = [
224
270
  * No client's host has any of this: there `clients` is an unknown query, and
225
271
  * a `client` parameter is never read (S10).
226
272
  */
227
- const studioOps = (review, actor, host) => {
273
+ const studioOps = (review, actor, host, mailer) => {
228
274
  const where = async (client) => {
229
275
  if (client === undefined || client === null)
230
276
  return { at: STUDIO_SITE, host };
@@ -233,14 +279,14 @@ const studioOps = (review, actor, host) => {
233
279
  };
234
280
  const people = async (client) => {
235
281
  const w = await where(client);
282
+ // The host a person signs in on: a Client's from their client's record, never this request's; a Studio person's this one.
283
+ const homeOf = (p) => (p.client === null ? host : w.host);
236
284
  return {
237
285
  review,
238
286
  actor,
239
287
  at: w.at,
240
- link: (r) => ({
241
- person: visible(r.person),
242
- link: `https://${r.person.client === null ? host : w.host}/invite/${r.token}`,
243
- }),
288
+ link: (r) => ({ person: visible(r.person), link: `https://${homeOf(r.person)}/invite/${r.token}` }),
289
+ invites: { mailer, homeOf },
244
290
  };
245
291
  };
246
292
  return {
@@ -257,6 +303,7 @@ const studioOps = (review, actor, host) => {
257
303
  if (op === 'access')
258
304
  return {
259
305
  access: at === STUDIO_SITE ? await review.studioAccess(actor) : await review.defaultAccess(at, actor),
306
+ mail: await mailState(review, mailer),
260
307
  };
261
308
  // A client's section lists its own people; the Studio people have a section of their own.
262
309
  const listed = await review.listPeople(at, actor);
@@ -275,23 +322,27 @@ export async function actorFrom(request, review, gate, at) {
275
322
  /** What a studio site says when it is not set up: every client host sees it, so it names no command, studio or client. */
276
323
  const SITE_NOT_SET_UP = 'This site is not set up yet.';
277
324
  /**
278
- * A studio site's review service: Upstash for the store, Jev for triage
279
- * when its key is set and `checks` is given. `now` is the clock, so the gate
280
- * and the service it asks run on one (the gate's tests move it). Without the
281
- * gate's secret or the store, the cause goes to the site's log and a visitor
282
- * gets SITE_NOT_SET_UP.
325
+ * A studio site's review service: the store its env names (chooseStore:
326
+ * Upstash or Postgres, never a guess between them), Jev for triage when its
327
+ * key is set and `checks` is given. `now` is the clock, so the gate and the
328
+ * service it asks run on one (the gate's tests move it). Without the gate's
329
+ * secret or one store, the cause goes to the site's log and a visitor gets
330
+ * SITE_NOT_SET_UP.
283
331
  */
284
332
  export function studioReview(env, checks = null, now) {
285
333
  const keys = readGate(env);
286
- const store = storeConfig(env);
287
- if (!keys || !store) {
288
- console.error('[studio]', keys ? 'The review store is not configured.' : 'GATE_SECRET is missing or short.');
334
+ const store = chooseStore(env);
335
+ if (!keys || !store || 'error' in store) {
336
+ const why = !store ? 'The review store is not configured.' : 'error' in store ? store.error : '';
337
+ console.error('[studio]', keys ? why : 'GATE_SECRET is missing or short.');
289
338
  return { error: SITE_NOT_SET_UP };
290
339
  }
291
340
  return {
292
341
  keys,
293
- review: createReview(upstashKV(store), {
342
+ review: createReview(store.open(), {
294
343
  triage: jevTriager(env.TYPESAFE_API_KEY ?? '', checks),
344
+ // Sign-in codes are kept as an HMAC under the gate's secret (email.md, section 4).
345
+ codeKey: keys.secret,
295
346
  ...(now ? { now } : {}),
296
347
  }),
297
348
  };
@@ -328,30 +379,35 @@ const signedOut = (request) => json(401, { error: 'Sign in with the link the stu
328
379
  * signed out, or signed in for another client, gets one answer whatever
329
380
  * project the request names.
330
381
  */
331
- async function opsFor(request, { review, keys }, { host, site }) {
382
+ async function opsFor(request, { review, keys, mailer }, { host, site }) {
332
383
  if (site === STUDIO_SITE) {
333
384
  const actor = await actorFrom(request, review, studioGate(keys), STUDIO_SITE);
334
- return actor ? studioOps(review, actor, host) : signedOut(request);
385
+ return actor ? studioOps(review, actor, host, mailer) : signedOut(request);
335
386
  }
336
387
  const client = site.slug;
337
388
  const actor = await actorFrom(request, review, { ...keys, client, since: site.createdAt }, { client });
338
389
  if (!actor)
339
390
  return signedOut(request);
340
391
  const scope = await studioScope(request, review, client);
341
- return scope ? clientOps({ review, actor, scope }) : json(404, { error: 'Not found.' });
392
+ // An invite names the client's host from its record, as its links are on it (S9: a codename host too).
393
+ return scope
394
+ ? clientOps({ review, actor, scope, mailer, host: site.host })
395
+ : json(404, { error: 'Not found.' });
342
396
  }
343
397
  /**
344
398
  * A studio site's review function: the host's client is the scope, and the
345
399
  * gate's client, of every op; the studio's own host has the studio hub's.
400
+ * `mailer` is the studio's, chosen from the env as the gate chooses it
401
+ * (chooseMailer), unless a test gives one or null.
346
402
  */
347
- export async function studioHandler(request, checks, hosts) {
403
+ export async function studioHandler(request, checks, hosts, mailer = chooseMailer(process.env)) {
348
404
  const setup = studioReview(process.env, checks);
349
405
  if ('error' in setup)
350
406
  return json(503, { error: setup.error });
351
407
  let ops;
352
408
  try {
353
409
  const found = await hostSite(request, setup.review, hosts);
354
- ops = found ? await opsFor(request, setup, found) : json(404, { error: 'Not found.' });
410
+ ops = found ? await opsFor(request, { ...setup, mailer }, found) : json(404, { error: 'Not found.' });
355
411
  }
356
412
  catch (error) {
357
413
  console.error('[review]', error);
@@ -6,6 +6,7 @@ import { checks } from './checks.js';
6
6
  import { readEnv } from './env.js';
7
7
  import { fileKV } from './file-kv.js';
8
8
  import { LOCAL_SCOPE, LOCAL_STORE, localStudio } from './local.js';
9
+ import { fakeMailer } from './mailers/fake.js';
9
10
  import { ROOT } from './paths.js';
10
11
  // Connect strips the mount path from req.url; originalUrl keeps the query the handler reads.
11
12
  async function toRequest(req) {
@@ -30,6 +31,24 @@ async function send(res, response) {
30
31
  });
31
32
  res.end(Buffer.from(await response.arrayBuffer()));
32
33
  }
34
+ /**
35
+ * A mailer that keeps mail in memory, for seeing the People tab's mail lines
36
+ * in dev: `DESIGN_HUB_DEV_MAIL=on` sends, `failing` refuses, each recorded
37
+ * once at start so the tab opens in that state, and `off` has none. Unset,
38
+ * there is none and the tab shows no sign-in line: dev cannot know how the
39
+ * project's studio sends mail. Nothing leaves the machine.
40
+ */
41
+ function devMailer(review) {
42
+ const mode = process.env.DESIGN_HUB_DEV_MAIL;
43
+ if (mode !== 'on' && mode !== 'failing')
44
+ return null;
45
+ const mailer = fakeMailer('Dev Studio');
46
+ mailer.answer = mode === 'on' ? 'sent' : 'refused';
47
+ void review.recordMail(mailer.answer);
48
+ return mailer;
49
+ }
50
+ /** Unset, dev says nothing of sign-in mail; `off`, `on` and `failing` show each state. */
51
+ const mailUnknown = () => !['off', 'on', 'failing'].includes(process.env.DESIGN_HUB_DEV_MAIL ?? '');
33
52
  export function devReview() {
34
53
  return {
35
54
  name: 'dev-review',
@@ -41,11 +60,12 @@ export function devReview() {
41
60
  triage: jevTriager(readEnv(ROOT).TYPESAFE_API_KEY ?? '', checks),
42
61
  });
43
62
  const actor = localStudio();
63
+ const mailer = devMailer(review);
44
64
  // The local Studio person is in the people list like anyone else, so the people panel shows them.
45
65
  void kv.hset(keyOf('studio', 'people'), actor.id, JSON.stringify(actor));
46
66
  server.middlewares.use(API_PATH, (req, res, nextMiddleware) => {
47
67
  toRequest(req)
48
- .then((request) => handleReview(request, { review, actor, scope: LOCAL_SCOPE }))
68
+ .then((request) => handleReview(request, { review, actor, scope: LOCAL_SCOPE, mailer, mailUnknown: mailUnknown() }))
49
69
  .then((response) => send(res, response))
50
70
  .catch(nextMiddleware);
51
71
  });
@@ -0,0 +1,120 @@
1
+ import { GATE_FONT, type Route } from '../core/prototype.ts';
2
+ import { type Client, type Person, type PersonKind, type Project, type Scope } from '../core/review/model.ts';
3
+ import { type Review } from '../core/review/service.ts';
4
+ import { type HostLookup } from './hosts.ts';
5
+ import { type Mailer } from './mailer.ts';
6
+ import { type Gate } from './session.ts';
7
+ export declare const DEFAULT_SITE_NAME = "Prototypes";
8
+ /**
9
+ * What the gate decides for one request, for a host's adapter to carry out:
10
+ * a Response the gate made itself (a gate page, a refusal, a redirect), or
11
+ * the request let through, on to what the site serves at its own path
12
+ * (`next`) or to another URL of the site (`rewrite`, a function), each with
13
+ * the headers to add to the answer.
14
+ */
15
+ export type Decision = Response | Later | {
16
+ pass: 'next';
17
+ headers?: Record<string, string>;
18
+ } | {
19
+ pass: 'rewrite';
20
+ to: URL;
21
+ headers: Record<string, string>;
22
+ };
23
+ /**
24
+ * A Response with work to finish after it is sent (a code's mail): the
25
+ * adapter answers at once and keeps the work running (on Vercel, waitUntil).
26
+ * The work never rejects, and the answer never waits for it (E7).
27
+ */
28
+ export type Later = {
29
+ answer: Response;
30
+ after: Promise<void>;
31
+ };
32
+ export { GATE_FONT };
33
+ export declare function gatePreview(page: string | null, siteName?: string): Promise<{
34
+ html: string;
35
+ csp: string;
36
+ }>;
37
+ export declare const isRead: (request: Request) => boolean;
38
+ type Extra = {
39
+ cookie?: string;
40
+ allow?: string;
41
+ referrer?: 'no-referrer' | 'same-origin';
42
+ /** Seconds, on a 503 that passes (a store that did not answer), so the review panel retries instead of switching off. */
43
+ retryAfter?: number;
44
+ };
45
+ export declare const plain: (request: Request, status: number, text: string, extra?: Extra) => Response;
46
+ /** One answer for a prototype a Client may not have, whether it is internal or not there at all. */
47
+ export declare const notFound: (request: Request) => Response;
48
+ /** The store did not answer: a 503 that passes, so it says when to try again. */
49
+ export declare const storeDown: (request: Request) => Response;
50
+ /**
51
+ * One request at one moment: `at` is the gate's clock, so freshness is tested
52
+ * without waiting. `mailer`: the studio's, or none (no email sign-in).
53
+ * `address`: the network address the host's adapter gives, never a header
54
+ * the gate reads itself; none is not counted against the cap.
55
+ */
56
+ export type Ctx = {
57
+ siteName: string;
58
+ request: Request;
59
+ at: Date;
60
+ mailer?: Mailer | null;
61
+ address?: string | null;
62
+ };
63
+ export type ProxyOptions = {
64
+ /** The gate pages' title, the same on every client's host. */
65
+ siteName?: string;
66
+ /** The gate's clock; tests move it instead of waiting. */
67
+ now?: () => Date;
68
+ /** The studio's mailer, or null for none; absent, it is chosen from the env on each request (chooseMailer). */
69
+ mailer?: Mailer | null;
70
+ };
71
+ /** What the host's adapter knows of a request that no header the caller sends can say: its network address. */
72
+ export type From = {
73
+ address?: string | null;
74
+ };
75
+ /** Who a request's host is: its client, and the gate and the client's scope built from that one lookup. */
76
+ export type Place = {
77
+ client: Client;
78
+ gate: Gate;
79
+ scope: Scope;
80
+ };
81
+ /** A request on a studio site that names a known client. */
82
+ export type Found = {
83
+ review: Review;
84
+ place: Place;
85
+ route: Route;
86
+ };
87
+ /** Why a studio request ends before it is served; `refuse` answers each one the same wherever it is met. */
88
+ export type Refusal = {
89
+ refused: 'not-found';
90
+ } | {
91
+ refused: 'store-down';
92
+ } | {
93
+ refused: 'unavailable';
94
+ error: string;
95
+ } | {
96
+ refused: 'signed-out';
97
+ stale: boolean;
98
+ };
99
+ /**
100
+ * The client `pathname` is asked of on the request's host, or why there is
101
+ * none: an unknown host is the plain 404, and so is the studio's own host,
102
+ * which serves no client's anything.
103
+ */
104
+ export declare function findPlace(request: Request, pathname: string, hosts: HostLookup, at: Date): Promise<Found | Refusal>;
105
+ /** A request that may go on: who asks, the person to re-issue a cookie for, and the project it is for. */
106
+ export type Admitted = Found & {
107
+ kind: PersonKind;
108
+ current: Person | null;
109
+ project: Project | null;
110
+ };
111
+ /**
112
+ * The checks every studio request passes, in the gate and again in the files
113
+ * function: a session signed to this host's client (asked of the store again
114
+ * once its stamp is stale), then the boundary.
115
+ */
116
+ export declare function admit(found: Found, request: Request, at: Date): Promise<Admitted | Refusal>;
117
+ /** The answer for a refusal: the same from the gate and from the files function. */
118
+ export declare function refuse(ctx: Ctx, refusal: Refusal): Promise<Response> | Response;
119
+ /** The gate a host's adapter runs on every request (vercel/proxy.ts on Vercel). Its sign-in page names no client (S10). */
120
+ export declare function createGate(options?: ProxyOptions): (request: Request, { address }?: From) => Promise<Decision>;