ovr 6.2.4 → 7.0.0-next.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 (136) hide show
  1. package/README.md +3 -1
  2. package/dist/app/index.d.ts +51 -7
  3. package/dist/app/index.d.ts.map +1 -1
  4. package/dist/app/index.js +163 -28
  5. package/dist/auth/auth-data.d.ts +26 -0
  6. package/dist/auth/auth-data.d.ts.map +1 -0
  7. package/dist/auth/auth-data.js +42 -0
  8. package/dist/auth/cbor.d.ts +50 -0
  9. package/dist/auth/cbor.d.ts.map +1 -0
  10. package/dist/auth/cbor.js +200 -0
  11. package/dist/auth/client-source.d.ts +3 -0
  12. package/dist/auth/client-source.d.ts.map +1 -0
  13. package/dist/auth/client-source.js +3 -0
  14. package/dist/auth/client.d.ts +3 -0
  15. package/dist/auth/client.d.ts.map +1 -0
  16. package/dist/auth/client.js +186 -0
  17. package/dist/auth/configure.d.ts +28 -0
  18. package/dist/auth/configure.d.ts.map +1 -0
  19. package/dist/auth/configure.js +228 -0
  20. package/dist/auth/der.d.ts +6 -0
  21. package/dist/auth/der.d.ts.map +1 -0
  22. package/dist/auth/der.js +36 -0
  23. package/dist/auth/index.d.ts +242 -0
  24. package/dist/auth/index.d.ts.map +1 -0
  25. package/dist/auth/index.js +152 -0
  26. package/dist/auth/issue.d.ts +36 -0
  27. package/dist/auth/issue.d.ts.map +1 -0
  28. package/dist/auth/issue.js +47 -0
  29. package/dist/auth/metadata.d.ts +22 -0
  30. package/dist/auth/metadata.d.ts.map +1 -0
  31. package/dist/auth/metadata.js +134 -0
  32. package/dist/auth/oauth.d.ts +29 -0
  33. package/dist/auth/oauth.d.ts.map +1 -0
  34. package/dist/auth/oauth.js +724 -0
  35. package/dist/auth/passkey.d.ts +101 -0
  36. package/dist/auth/passkey.d.ts.map +1 -0
  37. package/dist/auth/passkey.js +393 -0
  38. package/dist/auth/state.d.ts +49 -0
  39. package/dist/auth/state.d.ts.map +1 -0
  40. package/dist/auth/state.js +184 -0
  41. package/dist/auth/storage.d.ts +193 -0
  42. package/dist/auth/storage.d.ts.map +1 -0
  43. package/dist/auth/storage.js +410 -0
  44. package/dist/auth/token.d.ts +12 -0
  45. package/dist/auth/token.d.ts.map +1 -0
  46. package/dist/auth/token.js +39 -0
  47. package/dist/context/index.d.ts +86 -16
  48. package/dist/context/index.d.ts.map +1 -1
  49. package/dist/context/index.js +166 -42
  50. package/dist/cookie/index.d.ts +3 -0
  51. package/dist/cookie/index.d.ts.map +1 -1
  52. package/dist/cookie/index.js +1 -0
  53. package/dist/database/index.d.ts +262 -0
  54. package/dist/database/index.d.ts.map +1 -0
  55. package/dist/database/index.js +807 -0
  56. package/dist/form/index.d.ts +699 -0
  57. package/dist/form/index.d.ts.map +1 -0
  58. package/dist/form/index.js +901 -0
  59. package/dist/index.d.ts +10 -3
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +9 -3
  62. package/dist/jsx/elements.d.ts +28 -2
  63. package/dist/jsx/elements.d.ts.map +1 -1
  64. package/dist/jsx/index.d.ts +20 -4
  65. package/dist/jsx/index.d.ts.map +1 -1
  66. package/dist/jsx/index.js +6 -65
  67. package/dist/limiter/index.d.ts +65 -0
  68. package/dist/limiter/index.d.ts.map +1 -0
  69. package/dist/limiter/index.js +157 -0
  70. package/dist/markdown/index.d.ts +61 -0
  71. package/dist/markdown/index.d.ts.map +1 -0
  72. package/dist/markdown/index.js +1160 -0
  73. package/dist/markup/index.d.ts +188 -0
  74. package/dist/markup/index.d.ts.map +1 -0
  75. package/dist/markup/index.js +718 -0
  76. package/dist/mcp/index.d.ts +73 -0
  77. package/dist/mcp/index.d.ts.map +1 -0
  78. package/dist/mcp/index.js +988 -0
  79. package/dist/middleware/index.d.ts +3 -4
  80. package/dist/middleware/index.d.ts.map +1 -1
  81. package/dist/multipart/index.d.ts +53 -7
  82. package/dist/multipart/index.d.ts.map +1 -1
  83. package/dist/multipart/index.js +332 -124
  84. package/dist/route/index.d.ts +226 -80
  85. package/dist/route/index.d.ts.map +1 -1
  86. package/dist/route/index.js +239 -99
  87. package/dist/schema/index.d.ts +307 -734
  88. package/dist/schema/index.d.ts.map +1 -1
  89. package/dist/schema/index.js +783 -1050
  90. package/dist/table/index.d.ts +132 -0
  91. package/dist/table/index.d.ts.map +1 -0
  92. package/dist/table/index.js +188 -0
  93. package/dist/trie/index.js +4 -4
  94. package/dist/util/index.d.ts +37 -5
  95. package/dist/util/index.d.ts.map +1 -1
  96. package/dist/util/index.js +156 -41
  97. package/package.json +11 -4
  98. package/src/app/index.ts +230 -42
  99. package/src/auth/auth-data.ts +56 -0
  100. package/src/auth/cbor.ts +231 -0
  101. package/src/auth/client-source.ts +3 -0
  102. package/src/auth/client.ts +205 -0
  103. package/src/auth/configure.ts +279 -0
  104. package/src/auth/der.ts +35 -0
  105. package/src/auth/index.ts +387 -0
  106. package/src/auth/issue.ts +52 -0
  107. package/src/auth/metadata.ts +149 -0
  108. package/src/auth/oauth.ts +882 -0
  109. package/src/auth/passkey.ts +556 -0
  110. package/src/auth/state.ts +213 -0
  111. package/src/auth/storage.ts +572 -0
  112. package/src/auth/token.ts +67 -0
  113. package/src/context/index.ts +240 -65
  114. package/src/cookie/index.ts +3 -0
  115. package/src/database/index.ts +1193 -0
  116. package/src/form/index.ts +1720 -0
  117. package/src/index.ts +10 -3
  118. package/src/jsx/elements.ts +45 -25
  119. package/src/jsx/index.ts +24 -69
  120. package/src/limiter/index.ts +221 -0
  121. package/src/markdown/index.ts +1322 -0
  122. package/src/markup/index.ts +853 -0
  123. package/src/mcp/conformance.2025-11-25.yml +39 -0
  124. package/src/mcp/conformance.2026-07-28.yml +56 -0
  125. package/src/mcp/index.ts +1262 -0
  126. package/src/middleware/index.ts +5 -6
  127. package/src/multipart/index.ts +410 -158
  128. package/src/route/index.ts +559 -278
  129. package/src/schema/index.ts +1542 -2256
  130. package/src/table/index.ts +387 -0
  131. package/src/trie/index.ts +4 -4
  132. package/src/util/index.ts +163 -49
  133. package/dist/render/index.d.ts +0 -79
  134. package/dist/render/index.d.ts.map +0 -1
  135. package/dist/render/index.js +0 -257
  136. package/src/render/index.ts +0 -314
@@ -1,9 +1,16 @@
1
1
  import { Cookie } from "../cookie/index.js";
2
+ import { Form as FormSchema, forms } from "../form/index.js";
3
+ import { Markdown, tools } from "../markdown/index.js";
4
+ import { Markup } from "../markup/index.js";
2
5
  import { Multipart } from "../multipart/index.js";
3
- import { Render } from "../render/index.js";
4
6
  import { Route } from "../route/index.js";
5
- import { Form as FormSchema } from "../schema/index.js";
6
7
  import { Checksum, Header, Method, Mime } from "../util/index.js";
8
+ /**
9
+ * Requests an agent makes through an MCP tool, with the session its token
10
+ * authorizes. `c.data()` adds the form's issues, which the MCP endpoint
11
+ * returns to the agent instead of following the handler's redirect.
12
+ */
13
+ export const agent = new WeakMap();
7
14
  /** Properties to build the final `Response` with once middleware has run. */
8
15
  class PreparedResponse {
9
16
  /**
@@ -25,6 +32,8 @@ class PreparedResponse {
25
32
  */
26
33
  headers = new Headers();
27
34
  }
35
+ /** Reads a request's session, set by a mounted `Auth` */
36
+ export const sessions = Symbol("sessions");
28
37
  /**
29
38
  * Request context.
30
39
  *
@@ -38,6 +47,8 @@ export class Context {
38
47
  * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
39
48
  */
40
49
  req;
50
+ /** Trusted client IP supplied by the server through App.fetch; never inferred from request headers. */
51
+ ip;
41
52
  /**
42
53
  * Parsed `URL` created from `req.url`.
43
54
  *
@@ -50,19 +61,24 @@ export class Context {
50
61
  route;
51
62
  /** Contains the arguments to used create the final `Response` */
52
63
  res = new PreparedResponse();
53
- /** Get, set, and delete cookies. */
64
+ /** Get and set cookies, a cookie set with `maxAge: 0` is deleted. */
54
65
  cookie = new Cookie(this);
55
66
  /** Forwarded app options */
56
67
  #options;
68
+ /** `Vary: Accept` is set */
69
+ #varied = false;
57
70
  /** Cached result from `data()` to avoid re-reading request bodies. */
58
71
  #parsed;
72
+ /** Session reader, set by `app.use(auth)` */
73
+ [sessions];
59
74
  /**
60
75
  * Creates a new `Context` with the current `Request`.
61
76
  *
62
77
  * @param req Request
63
78
  */
64
- constructor(req, options) {
79
+ constructor(req, options, ip) {
65
80
  this.req = req;
81
+ this.ip = ip;
66
82
  this.url = new URL(req.url);
67
83
  this.#options = options;
68
84
  }
@@ -73,20 +89,17 @@ export class Context {
73
89
  * @param status [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
74
90
  */
75
91
  html(body, status) {
76
- this.res.body = body;
77
- this.res.status = status;
78
- this.res.headers.set(Header.name.type, Header.utf8(Mime.type.html));
92
+ this.#respond(body, status, Header.utf8(Mime.type.html));
79
93
  }
80
94
  /**
81
95
  * Creates a JSON response.
82
96
  *
97
+ * @template D Data, not a `bigint`, which JSON cannot represent
83
98
  * @param data passed into JSON.stringify to create the body
84
99
  * @param status [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
85
100
  */
86
101
  json(data, status) {
87
- this.res.body = JSON.stringify(data);
88
- this.res.status = status;
89
- this.res.headers.set(Header.name.type, Mime.type.json);
102
+ this.#respond(JSON.stringify(data), status, Mime.type.json);
90
103
  }
91
104
  /**
92
105
  * Creates a plain text response.
@@ -95,13 +108,43 @@ export class Context {
95
108
  * @param status [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
96
109
  */
97
110
  text(body, status) {
111
+ this.#respond(body, status, Header.utf8(Mime.type.text));
112
+ }
113
+ /**
114
+ * Responds with Markdown when the request asks for Markdown, such as an
115
+ * agent's, instead of the Markdown written from the page. Use it for a page
116
+ * that is a Markdown document, so agents read its source.
117
+ *
118
+ * ```tsx
119
+ * if (c.md(post.body)) return;
120
+ *
121
+ * return <Post post={post} />;
122
+ * ```
123
+ *
124
+ * @param body Markdown body
125
+ * @param status [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
126
+ * @returns `true` if it responded, otherwise the page renders for the browser
127
+ */
128
+ md(body, status) {
129
+ if (!this.#markdown())
130
+ return false;
131
+ this.#respond(body, status, Header.utf8(Mime.type.md));
132
+ return true;
133
+ }
134
+ /**
135
+ * @param body Response body
136
+ * @param status HTTP response status code
137
+ * @param type `Content-Type` of the body
138
+ */
139
+ #respond(body, status, type) {
98
140
  this.res.body = body;
99
141
  this.res.status = status;
100
- this.res.headers.set(Header.name.type, Header.utf8(Mime.type.text));
142
+ this.res.headers.set(Header.name.type, type);
101
143
  }
102
144
  /**
103
145
  * Creates a redirect response.
104
146
  *
147
+ * @template L Location: a URL, or a route without parameters
105
148
  * @param location redirect `Location` header
106
149
  * @param status HTTP status code
107
150
  *
@@ -111,10 +154,12 @@ export class Context {
111
154
  * - [307 Temporary Redirect](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307)
112
155
  * - [308 Permanent Redirect](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308)
113
156
  */
114
- redirect(location, status = 302) {
157
+ redirect(
158
+ // a route with parameters needs values, which only route.url() is given
159
+ location, status = 302) {
115
160
  this.res.body = null;
116
161
  this.res.status = status;
117
- this.res.headers.set(Header.name.loc, location instanceof Route ? location.pathname() : String(location));
162
+ this.res.headers.set(Header.name.loc, location instanceof Route ? location.url() : String(location));
118
163
  }
119
164
  /**
120
165
  * Generates an etag from a checksum of the string provided.
@@ -147,8 +192,8 @@ export class Context {
147
192
  * ```ts
148
193
  * import { Route } from "ovr";
149
194
  *
150
- * const post = Route.post(async (c) => {
151
- * for await (const part of c.form()) {
195
+ * const post = Route.post("/posts").use(async (c) => {
196
+ * for await (const part of c.multipart()) {
152
197
  * if (part.name === "email") {
153
198
  * // ...
154
199
  * }
@@ -156,26 +201,50 @@ export class Context {
156
201
  * })
157
202
  * ```
158
203
  */
159
- form(options) {
160
- return new Multipart(this.req, { ...this.#options.form, ...options });
204
+ multipart(options) {
205
+ return new Multipart(this.req, { ...this.#options.multipart, ...options });
161
206
  }
162
207
  /**
163
- * Parse route form data from search params or multipart requests.
208
+ * Read the signed-in user's session before returning JSX, or `null` when
209
+ * nobody is signed in. In an agent's tool call, it is the session of the
210
+ * user who approved the agent. Requires `app.use(auth)`.
211
+ *
212
+ * ```ts
213
+ * const session = await c.session();
214
+ * if (!session) return c.redirect("/login", 303);
215
+ * ```
164
216
  *
165
- * @param options Multipart options for POST requests
217
+ * @returns The session, or `null`
218
+ */
219
+ session() {
220
+ if (!this[sessions])
221
+ throw new TypeError("Mount Auth with app.use(auth) to read sessions");
222
+ return this[sessions]();
223
+ }
224
+ /**
225
+ * Parse route form data: from the search params of a GET or HEAD request,
226
+ * and from the multipart body of any other.
227
+ *
228
+ * @param options Multipart options for requests with a body
166
229
  * @returns Parsed form data with possible invalid redirect URL state
167
230
  */
168
231
  async data(options) {
169
232
  return (this.#parsed ??= (async () => {
170
- const post = this.req.method === Method.post;
171
- const form = this.route;
172
- if (!form?.parse)
233
+ // GET and HEAD carry their fields in the URL, every other method in its body
234
+ const post = this.req.method !== Method.get && this.req.method !== Method.head;
235
+ const form = this.route && forms.get(this.route);
236
+ if (!form)
173
237
  return null;
238
+ // a body too large or not form data throws, for the handler to answer
174
239
  const result = await form.parse(post
175
- ? this.form({ parts: form.parts, ...options })
240
+ ? this.multipart({ parts: form.parts, ...options })
176
241
  : this.url.searchParams);
177
- if (result.issues) {
178
- // create encoded URL state with invalid fields
242
+ /**
243
+ * Add the URL to return to with the encoded invalid state.
244
+ *
245
+ * @template R Parse result, with its search parameters
246
+ */
247
+ const invalid = (result) => {
179
248
  let url = new URL(this.url);
180
249
  if (post) {
181
250
  const returnParam = url.searchParams.get(FormSchema.params[0]);
@@ -195,10 +264,35 @@ export class Context {
195
264
  if (result.search)
196
265
  url.searchParams.set(...result.search[0]);
197
266
  return Object.assign(result, { url });
267
+ };
268
+ if (result.issues) {
269
+ this.#agentIssues(result.issues);
270
+ return invalid(result);
198
271
  }
199
- return result;
272
+ const create = result.invalid;
273
+ return Object.assign(result, {
274
+ invalid: (messages) => {
275
+ const result = create(messages);
276
+ this.#agentIssues(result.issues);
277
+ return invalid(result);
278
+ },
279
+ });
200
280
  })());
201
281
  }
282
+ /**
283
+ * Agents get the issues directly instead of a redirect to the form.
284
+ *
285
+ * @param issues Parse issues
286
+ */
287
+ #agentIssues(issues) {
288
+ const call = agent.get(this.req);
289
+ if (!call)
290
+ return;
291
+ call.issues = issues.map((issue) => ({
292
+ path: issue.path.map(String).join("."),
293
+ message: issue.message,
294
+ }));
295
+ }
202
296
  /**
203
297
  * Dispatches the stack of `middleware` provided.
204
298
  *
@@ -210,32 +304,61 @@ export class Context {
210
304
  const mw = middleware[i];
211
305
  if (!mw)
212
306
  return; // end of stack
213
- const r = await mw(this, // c
214
- () => this.#run(middleware, i + 1));
307
+ const r = await mw(this, () => this.#run(middleware, i + 1));
308
+ const { res } = this;
215
309
  // resolve the return value
216
310
  if (r instanceof Response) {
217
311
  // overwrite
218
- this.res.body = r.body;
219
- this.res.status = r.status;
220
- // merge
312
+ res.body = r.body;
313
+ res.status = r.status;
314
+ // merge, each cookie is its own header, added to ones already set
221
315
  for (const [name, header] of r.headers) {
222
- this.res.headers.set(name, header);
316
+ if (name !== Header.name.set)
317
+ res.headers.set(name, header);
223
318
  }
319
+ for (const cookie of r.headers.getSetCookie())
320
+ res.headers.append(Header.name.set, cookie);
224
321
  }
225
322
  else if (r !== undefined) {
226
323
  // something to stream
227
- const [mime] = Header.shift(this.res.headers.get(Header.name.type));
228
- this.res.body = Render.stream(r, {
229
- // other defined types are safe
230
- safe: Boolean(mime && !Mime.markup(mime)),
324
+ const [mime] = Header.shift(res.headers.get(Header.name.type));
325
+ if (!mime || mime === Mime.type.html) {
326
+ // pages are HTML for browsers and Markdown for agents that ask for it
327
+ if (this.#markdown()) {
328
+ res.body = Markdown.stream(r, {
329
+ base: this.url,
330
+ [tools]: agent.get(this.req)?.tool,
331
+ });
332
+ res.headers.set(Header.name.type, Header.utf8(Mime.type.md));
333
+ return;
334
+ }
335
+ }
336
+ res.body = Markup.stream(r, {
337
+ // other defined types are not markup, so they are not escaped
338
+ raw: Boolean(mime && !Mime.markup(mime)),
231
339
  });
232
340
  if (!mime) {
233
341
  // default to HTML
234
- this.res.headers.set(Header.name.type, Header.utf8(Mime.type.html));
342
+ res.headers.set(Header.name.type, Header.utf8(Mime.type.html));
235
343
  }
236
344
  // do not overwrite/remove status - that way user can set it before returning
237
345
  }
238
346
  }
347
+ /**
348
+ * The response depends on `Accept` once this is asked, so it varies by it.
349
+ *
350
+ * @returns `true` if the request asks for Markdown over HTML
351
+ */
352
+ #markdown() {
353
+ if (!this.#varied) {
354
+ this.#varied = true;
355
+ this.res.headers.append(Header.name.vary, "Accept");
356
+ }
357
+ const accept = this.req.headers.get(Header.name.accept);
358
+ // only an explicit request, browsers accept */*
359
+ const markdown = Header.quality(accept, Mime.type.md, true);
360
+ return markdown > 0 && markdown >= Header.quality(accept, Mime.type.html);
361
+ }
239
362
  /**
240
363
  * Composes a stack of `middleware` into a `Response`.
241
364
  *
@@ -245,16 +368,17 @@ export class Context {
245
368
  */
246
369
  static async compose(c, middleware) {
247
370
  await c.#run(middleware);
371
+ const { res } = c;
248
372
  if (c.req.method === Method.head) {
249
- if (c.res.body instanceof ReadableStream) {
373
+ if (res.body instanceof ReadableStream) {
250
374
  // cancel unused stream to prevent leaks
251
- await c.res.body.cancel(Method.head);
375
+ await res.body.cancel(Method.head);
252
376
  }
253
- c.res.body = null;
377
+ res.body = null;
254
378
  }
255
- return new Response(c.res.body,
379
+ return new Response(res.body,
256
380
  // prevents users from setting the response during the stream
257
381
  // `Response` treats an explicitly undefined status as omitted
258
- Object.freeze(c.res));
382
+ Object.freeze(res));
259
383
  }
260
384
  }
@@ -89,6 +89,8 @@ export declare namespace Cookie {
89
89
  * Configuration options for setting a cookie.
90
90
  *
91
91
  * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
92
+ *
93
+ * @template Name Cookie name, whose `__Host-` or `__Secure-` prefix requires options
92
94
  */
93
95
  export type Options<Name extends string = string> = Name extends `__${"host" | "secure"}-${string}` ? never : Name extends `__Host-${string}` ? HostPrefixOptions : Name extends `__Secure-${string}` ? SecurePrefixOptions : SecureOptions | InsecureOptions;
94
96
  export {};
@@ -112,6 +114,7 @@ export declare class Cookie {
112
114
  /**
113
115
  * Sets a cookie on the response using the `Set-Cookie` header.
114
116
  *
117
+ * @template Name Cookie name, whose prefix selects the options it requires
115
118
  * @param name Name of the cookie
116
119
  * @param value Value to store
117
120
  * @param options Options configuration
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cookie/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,yBAAiB,MAAM,CAAC;IACvB,KAAK,WAAW,GAAG;QAClB;;;WAGG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAEzB;;;WAGG;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;QAExB;;;WAGG;QACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAE5B;;;WAGG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAEzB;;;;;WAKG;QACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAEvB,2EAA2E;QAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;KAC9C,CAAC;IAEF,KAAK,iBAAiB,GAAG,WAAW,GAAG;QACtC;;;WAGG;QACH,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;QAEtB;;;WAGG;QACH,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;QAEpB;;;WAGG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;QAExB,oEAAoE;QACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GA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AiB,GACjB,IAAI,SAAS,YAAY,MAAM,EAAE,GAChC,mBAAmB,GACnB,aAAa,GAAG,eAAe,CAAC;;CACtC;AAED,0BAA0B;AAC1B,qBAAa,MAAM;;IAOlB;;;;OAIG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,EAE1C;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,sBAIf;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,IAAI,SAAS,MAAM,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EACb,GAAG,CACF,OAAO,EACP,EAAE,IAAI,SAAS,KAAK,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,IAAI,MAAM,EAAE,GACnE,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAC/B,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAoBnC;CACD"}
@@ -25,6 +25,7 @@ export class Cookie {
25
25
  /**
26
26
  * Sets a cookie on the response using the `Set-Cookie` header.
27
27
  *
28
+ * @template Name Cookie name, whose prefix selects the options it requires
28
29
  * @param name Name of the cookie
29
30
  * @param value Value to store
30
31
  * @param options Options configuration
@@ -0,0 +1,262 @@
1
+ import { Schema } from "../schema/index.js";
2
+ import { Table } from "../table/index.js";
3
+ export declare namespace Database {
4
+ /** Query capability of a pg-compatible client. */
5
+ interface Client {
6
+ query(text: string, values?: unknown[]): Promise<Result>;
7
+ }
8
+ /** Query result of a pg-compatible client. */
9
+ interface Result {
10
+ readonly rows: unknown[];
11
+ /** Returned columns, used to decode `int8`, `numeric`, and JSON values. */
12
+ readonly fields?: readonly Field[];
13
+ }
14
+ /** Returned column with its Postgres type ID. */
15
+ interface Field {
16
+ readonly name: string;
17
+ readonly dataTypeID: number;
18
+ }
19
+ /** pg-compatible pool; `connect` checks out one client for a transaction, `sql(fn)`. */
20
+ interface Pool extends Client {
21
+ connect(): Promise<Client & {
22
+ release(error?: Error | boolean): void;
23
+ }>;
24
+ }
25
+ /** SQL migration applied by `migrate`. */
26
+ interface Migration {
27
+ /** Unique ID, migrations are applied in ID order. */
28
+ readonly id: string;
29
+ /** Trusted SQL, may contain several statements but not `BEGIN`, `COMMIT`, or `ROLLBACK`, since it runs in a transaction. */
30
+ readonly sql: string;
31
+ }
32
+ /**
33
+ * Tables accessible by name on the database, none when names are unknown so any database is a `Database`.
34
+ *
35
+ * @template T Tables of the database
36
+ */
37
+ type Tables<T extends readonly Table.Any[]> = string extends T[number]["name"] ? {} : {
38
+ readonly [K in T[number] as K["name"]]: K;
39
+ };
40
+ /** Names used by database members, tables cannot use them. */
41
+ type Reserved = "sql" | "migrate" | "check";
42
+ /**
43
+ * Tables with reserved names, or a name another table has, are rejected.
44
+ *
45
+ * @template T Tables to check
46
+ */
47
+ type Valid<T extends readonly Table.Any[]> = {
48
+ readonly [I in keyof T]: T[I] extends {
49
+ name: Reserved;
50
+ } ? never : string extends T[I]["name"] ? T[I] : T[I]["name"] extends {
51
+ [J in keyof T]: J extends I ? never : T[J]["name"];
52
+ }[number] ? never : T[I];
53
+ };
54
+ /** SQL template tag and helpers bound to a pool or transaction. */
55
+ interface Tag {
56
+ /**
57
+ * Build a query, run when awaited.
58
+ *
59
+ * Tables and columns become quoted identifiers, nested fragments are
60
+ * inlined, and every other value becomes a bound parameter.
61
+ */
62
+ (strings: TemplateStringsArray, ...values: unknown[]): Sql;
63
+ /**
64
+ * Validate rows and build the `(columns) VALUES (...)` of an insert.
65
+ * Omitted columns use their SQL default.
66
+ *
67
+ * @template T Table to insert into
68
+ * @param table Table to insert into
69
+ * @param rows One row or several, an empty list throws
70
+ * @returns Columns and values
71
+ */
72
+ values<T extends Table.Any>(table: T, rows: Insert<T> | readonly Insert<T>[]): Sql;
73
+ /**
74
+ * Validate values and build the assignments of an update.
75
+ *
76
+ * @template T Table to update
77
+ * @param table Table to update
78
+ * @param values Columns to change
79
+ * @returns Assignments
80
+ */
81
+ set<T extends Table.Any>(table: T, values: Update<T>): Sql;
82
+ }
83
+ /**
84
+ * Insert values of a table.
85
+ *
86
+ * @template T Table
87
+ */
88
+ type Insert<T extends Table.Any> = T extends Table<string, infer S, infer O> ? Table.Insert<S, O> : never;
89
+ /**
90
+ * Update values of a table.
91
+ *
92
+ * @template T Table
93
+ */
94
+ type Update<T extends Table.Any> = T extends Table<string, infer S, any> ? Table.Update<S> : never;
95
+ /** Scope passed to `database.sql(fn)`. */
96
+ interface Transaction {
97
+ /** SQL tag that runs in the transaction. */
98
+ readonly sql: Tag;
99
+ }
100
+ }
101
+ /**
102
+ * SQL fragment, a lazy promise that runs once on its client when awaited.
103
+ *
104
+ * @template Row Row type
105
+ */
106
+ export declare class Sql<Row = unknown> implements Promise<Row[]> {
107
+ #private;
108
+ readonly [Symbol.toStringTag] = "Sql";
109
+ /**
110
+ * @param strings Text segments, one more than values
111
+ * @param values Interpolated values
112
+ * @param client Client used when awaited
113
+ * @param schema Schema validating each returned row
114
+ * @param execution Query result shared with the source fragment
115
+ */
116
+ constructor(strings: readonly string[], values: readonly unknown[], client: Database.Client, schema?: Schema<Row>, execution?: {
117
+ result?: Promise<Database.Result>;
118
+ });
119
+ /**
120
+ * Parse each returned row with a schema, throwing the issues if any fail.
121
+ * The query still runs once, however many fragments `parse` returns.
122
+ *
123
+ * @template O Row type
124
+ * @param schema Row schema, for example a table
125
+ * @returns Fragment returning parsed rows
126
+ */
127
+ parse<O>(schema: Schema<O>): Sql<O>;
128
+ /**
129
+ * Compile to parameterized text.
130
+ *
131
+ * @returns Query text and parameter values
132
+ */
133
+ toQuery(): {
134
+ text: string;
135
+ values: unknown[];
136
+ };
137
+ /**
138
+ * Run the query once, the first time the result is requested.
139
+ *
140
+ * @template A Result of `resolve`
141
+ * @template B Result of `reject`
142
+ * @param resolve Receives the rows
143
+ * @param reject Receives the query or validation error
144
+ * @returns Promise of the callback result
145
+ */
146
+ then<A = Row[], B = never>(resolve?: ((rows: Row[]) => A | PromiseLike<A>) | null, reject?: ((reason: unknown) => B | PromiseLike<B>) | null): Promise<A | B>;
147
+ /**
148
+ * @template B Result of `reject`
149
+ * @param reject Receives the query or validation error
150
+ * @returns Promise of the rows or the callback result
151
+ */
152
+ catch<B = never>(reject?: ((reason: unknown) => B | PromiseLike<B>) | null): Promise<B | Row[]>;
153
+ /**
154
+ * @param fn Called when the query settles
155
+ * @returns Promise of the rows
156
+ */
157
+ finally(fn?: (() => void) | null): Promise<Row[]>;
158
+ }
159
+ /**
160
+ * Migrations a library's tables bring, by table. Tables of one library share
161
+ * one list, applied by `database.migrate` in the order it lists them, before the application's.
162
+ */
163
+ export declare const owned: WeakMap<Table.Any, readonly Database.Migration[]>;
164
+ /**
165
+ * Columns of a library's tables that must reference the `id` of a table the
166
+ * application chooses, with `ON DELETE CASCADE`, and the library that chooses
167
+ * it, for `database.check`.
168
+ */
169
+ export declare const referenced: WeakMap<Table.Any, {
170
+ readonly column: string;
171
+ readonly by: string;
172
+ }>;
173
+ /**
174
+ * The table each such column references, per database, set by the library
175
+ * when it is configured with that database.
176
+ */
177
+ export declare const references: WeakMap<object, Map<Table.Any, Table.Any>>;
178
+ /**
179
+ * Database members, tables are added by name.
180
+ *
181
+ * @template T Tables of the database
182
+ */
183
+ declare class Base<T extends readonly Table.Any[]> {
184
+ #private;
185
+ /** SQL tag, queries run on the pool when awaited. */
186
+ readonly sql: Database.Tag & {
187
+ /**
188
+ * Run a callback's queries as one transaction, on one connection.
189
+ * Commits when the callback resolves and rolls back when it throws.
190
+ *
191
+ * @template R Callback result
192
+ * @param fn Callback, query with `t.sql`
193
+ * @returns Callback result
194
+ */
195
+ <R>(fn: (t: Database.Transaction) => Promise<R>): Promise<R>;
196
+ };
197
+ /**
198
+ * @param pool pg-compatible pool, owned by the application
199
+ * @param tables Tables, accessible by name
200
+ */
201
+ constructor(pool: Database.Pool, tables: T);
202
+ /**
203
+ * Apply pending migrations in ID order. Libraries' tables, such as
204
+ * `Auth.tables`, bring their own migrations, applied first in their own
205
+ * order, so a migration of yours can reference their tables.
206
+ *
207
+ * Each migration and its history record commit together while holding a
208
+ * transaction-level advisory lock, so concurrent runs apply each once.
209
+ *
210
+ * @param migrations Every migration of yours, including applied ones
211
+ * @returns IDs applied by this call
212
+ */
213
+ readonly migrate: (migrations: readonly Database.Migration[]) => Promise<string[]>;
214
+ /**
215
+ * Check that the live database can store and return the tables' rows.
216
+ *
217
+ * Reports missing tables and columns, incompatible types, nullability, and
218
+ * missing defaults, without changing anything. Keys, constraints, and indexes
219
+ * are left to migrations, except the foreign keys a library's tables need,
220
+ * such as Auth's to the users table.
221
+ *
222
+ * @returns One line per difference, empty when they match
223
+ */
224
+ readonly check: () => Promise<string[]>;
225
+ /**
226
+ * Check whether an error is a unique constraint violation, for example to
227
+ * show it as a form error.
228
+ *
229
+ * ```ts
230
+ * if (Database.unique(error, "users_email_key")) {
231
+ * const invalid = result.invalid({ email: "Already registered" });
232
+ * return c.redirect(invalid.url, 303);
233
+ * }
234
+ * ```
235
+ *
236
+ * @param error Caught error
237
+ * @param constraint Constraint name, any unique constraint when omitted
238
+ * @returns `true` for a matching unique violation
239
+ */
240
+ static unique(error: unknown, constraint?: string): boolean;
241
+ }
242
+ /**
243
+ * Postgres database with tables, accessed through an application-owned,
244
+ * pg-compatible pool.
245
+ *
246
+ * ```ts
247
+ * const database = new Database(pool, [users, posts]);
248
+ *
249
+ * const rows = await database.sql`SELECT * FROM ${database.users}`.parse(database.users);
250
+ * ```
251
+ *
252
+ * @template T Tables of the database, each available by name
253
+ */
254
+ export declare const Database: Omit<typeof Base, "prototype"> & (new <const T extends readonly Table.Any[]>(pool: Database.Pool, tables: T & Database.Valid<T>) => Database<T>);
255
+ /**
256
+ * Postgres database with its tables accessible by name.
257
+ *
258
+ * @template T Tables of the database
259
+ */
260
+ export type Database<T extends readonly Table.Any[] = readonly Table.Any[]> = Base<T> & Database.Tables<T>;
261
+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