@hatk/hatk 0.0.1-alpha.11 → 0.0.1-alpha.111

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 (224) hide show
  1. package/dist/adapter.d.ts +19 -0
  2. package/dist/adapter.d.ts.map +1 -0
  3. package/dist/adapter.js +113 -0
  4. package/dist/backfill.d.ts +36 -2
  5. package/dist/backfill.d.ts.map +1 -1
  6. package/dist/backfill.js +153 -37
  7. package/dist/car.js +1 -1
  8. package/dist/classifiers.d.ts +228 -0
  9. package/dist/classifiers.d.ts.map +1 -0
  10. package/dist/classifiers.js +688 -0
  11. package/dist/cli.js +248 -1043
  12. package/dist/config.d.ts +179 -1
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js +78 -8
  15. package/dist/database/adapter-factory.d.ts +6 -0
  16. package/dist/database/adapter-factory.d.ts.map +1 -0
  17. package/dist/database/adapter-factory.js +20 -0
  18. package/dist/database/adapters/duckdb-search.d.ts +12 -0
  19. package/dist/database/adapters/duckdb-search.d.ts.map +1 -0
  20. package/dist/database/adapters/duckdb-search.js +27 -0
  21. package/dist/database/adapters/duckdb.d.ts +25 -0
  22. package/dist/database/adapters/duckdb.d.ts.map +1 -0
  23. package/dist/database/adapters/duckdb.js +161 -0
  24. package/dist/database/adapters/sqlite-search.d.ts +16 -0
  25. package/dist/database/adapters/sqlite-search.d.ts.map +1 -0
  26. package/dist/database/adapters/sqlite-search.js +76 -0
  27. package/dist/database/adapters/sqlite.d.ts +18 -0
  28. package/dist/database/adapters/sqlite.d.ts.map +1 -0
  29. package/dist/database/adapters/sqlite.js +88 -0
  30. package/dist/database/db.d.ts +290 -0
  31. package/dist/database/db.d.ts.map +1 -0
  32. package/dist/database/db.js +2073 -0
  33. package/dist/database/dialect.d.ts +45 -0
  34. package/dist/database/dialect.d.ts.map +1 -0
  35. package/dist/database/dialect.js +72 -0
  36. package/dist/{fts.d.ts → database/fts.d.ts} +7 -0
  37. package/dist/database/fts.d.ts.map +1 -0
  38. package/dist/{fts.js → database/fts.js} +122 -34
  39. package/dist/database/index.d.ts +7 -0
  40. package/dist/database/index.d.ts.map +1 -0
  41. package/dist/database/index.js +6 -0
  42. package/dist/database/ports.d.ts +50 -0
  43. package/dist/database/ports.d.ts.map +1 -0
  44. package/dist/database/ports.js +1 -0
  45. package/dist/database/schema.d.ts +91 -0
  46. package/dist/database/schema.d.ts.map +1 -0
  47. package/dist/{schema.js → database/schema.js} +153 -54
  48. package/dist/dev-entry.d.ts +8 -0
  49. package/dist/dev-entry.d.ts.map +1 -0
  50. package/dist/dev-entry.js +131 -0
  51. package/dist/feeds.d.ts +26 -8
  52. package/dist/feeds.d.ts.map +1 -1
  53. package/dist/feeds.js +72 -16
  54. package/dist/hooks.d.ts +102 -0
  55. package/dist/hooks.d.ts.map +1 -0
  56. package/dist/hooks.js +186 -0
  57. package/dist/hydrate.d.ts +55 -6
  58. package/dist/hydrate.d.ts.map +1 -1
  59. package/dist/hydrate.js +21 -20
  60. package/dist/indexer.d.ts +194 -3
  61. package/dist/indexer.d.ts.map +1 -1
  62. package/dist/indexer.js +627 -92
  63. package/dist/jetstream.d.ts +118 -0
  64. package/dist/jetstream.d.ts.map +1 -0
  65. package/dist/jetstream.js +238 -0
  66. package/dist/labels.d.ts +36 -0
  67. package/dist/labels.d.ts.map +1 -1
  68. package/dist/labels.js +71 -6
  69. package/dist/lex-types.d.ts +2 -0
  70. package/dist/lex-types.d.ts.map +1 -1
  71. package/dist/lexicon-resolve.d.ts.map +1 -1
  72. package/dist/lexicon-resolve.js +27 -112
  73. package/dist/lexicons/com/atproto/label/defs.json +75 -0
  74. package/dist/lexicons/com/atproto/moderation/defs.json +30 -0
  75. package/dist/lexicons/com/atproto/repo/strongRef.json +21 -0
  76. package/dist/lexicons/dev/hatk/applyWrites.json +87 -0
  77. package/dist/lexicons/dev/hatk/createRecord.json +40 -0
  78. package/dist/lexicons/dev/hatk/createReport.json +48 -0
  79. package/dist/lexicons/dev/hatk/deleteRecord.json +25 -0
  80. package/dist/lexicons/dev/hatk/describeCollections.json +41 -0
  81. package/dist/lexicons/dev/hatk/describeFeeds.json +29 -0
  82. package/dist/lexicons/dev/hatk/describeLabels.json +45 -0
  83. package/dist/lexicons/dev/hatk/getFeed.json +30 -0
  84. package/dist/lexicons/dev/hatk/getPreferences.json +19 -0
  85. package/dist/lexicons/dev/hatk/getRecord.json +26 -0
  86. package/dist/lexicons/dev/hatk/getRecords.json +32 -0
  87. package/dist/lexicons/dev/hatk/putPreference.json +28 -0
  88. package/dist/lexicons/dev/hatk/putRecord.json +41 -0
  89. package/dist/lexicons/dev/hatk/searchRecords.json +32 -0
  90. package/dist/lexicons/dev/hatk/uploadBlob.json +23 -0
  91. package/dist/logger.d.ts +29 -0
  92. package/dist/logger.d.ts.map +1 -1
  93. package/dist/logger.js +29 -0
  94. package/dist/main.js +212 -75
  95. package/dist/mst.d.ts +15 -0
  96. package/dist/mst.d.ts.map +1 -1
  97. package/dist/mst.js +13 -0
  98. package/dist/oauth/db.d.ts +27 -1
  99. package/dist/oauth/db.d.ts.map +1 -1
  100. package/dist/oauth/db.js +80 -19
  101. package/dist/oauth/discovery.d.ts +10 -0
  102. package/dist/oauth/discovery.d.ts.map +1 -1
  103. package/dist/oauth/discovery.js +54 -2
  104. package/dist/oauth/server.d.ts +131 -1
  105. package/dist/oauth/server.d.ts.map +1 -1
  106. package/dist/oauth/server.js +504 -39
  107. package/dist/oauth/service-describe.d.ts +42 -0
  108. package/dist/oauth/service-describe.d.ts.map +1 -0
  109. package/dist/oauth/service-describe.js +108 -0
  110. package/dist/oauth/session.d.ts +32 -0
  111. package/dist/oauth/session.d.ts.map +1 -0
  112. package/dist/oauth/session.js +131 -0
  113. package/dist/opengraph.d.ts +10 -0
  114. package/dist/opengraph.d.ts.map +1 -1
  115. package/dist/opengraph.js +94 -42
  116. package/dist/pds-proxy.d.ts +92 -0
  117. package/dist/pds-proxy.d.ts.map +1 -0
  118. package/dist/pds-proxy.js +396 -0
  119. package/dist/private-collections.d.ts +13 -0
  120. package/dist/private-collections.d.ts.map +1 -0
  121. package/dist/private-collections.js +27 -0
  122. package/dist/push.d.ts +54 -0
  123. package/dist/push.d.ts.map +1 -0
  124. package/dist/push.js +367 -0
  125. package/dist/renderer.d.ts +27 -0
  126. package/dist/renderer.d.ts.map +1 -0
  127. package/dist/renderer.js +46 -0
  128. package/dist/resolve-hatk.d.ts +6 -0
  129. package/dist/resolve-hatk.d.ts.map +1 -0
  130. package/dist/resolve-hatk.js +20 -0
  131. package/dist/response.d.ts +16 -0
  132. package/dist/response.d.ts.map +1 -0
  133. package/dist/response.js +69 -0
  134. package/dist/scanner.d.ts +22 -0
  135. package/dist/scanner.d.ts.map +1 -0
  136. package/dist/scanner.js +92 -0
  137. package/dist/seed.d.ts +19 -0
  138. package/dist/seed.d.ts.map +1 -1
  139. package/dist/seed.js +43 -4
  140. package/dist/server-init.d.ts +8 -0
  141. package/dist/server-init.d.ts.map +1 -0
  142. package/dist/server-init.js +75 -0
  143. package/dist/server.d.ts +46 -3
  144. package/dist/server.d.ts.map +1 -1
  145. package/dist/server.js +1137 -649
  146. package/dist/setup.d.ts +28 -1
  147. package/dist/setup.d.ts.map +1 -1
  148. package/dist/setup.js +50 -3
  149. package/dist/spaces/blob.d.ts +112 -0
  150. package/dist/spaces/blob.d.ts.map +1 -0
  151. package/dist/spaces/blob.js +460 -0
  152. package/dist/spaces/credential.d.ts +82 -0
  153. package/dist/spaces/credential.d.ts.map +1 -0
  154. package/dist/spaces/credential.js +220 -0
  155. package/dist/spaces/engine.d.ts +97 -0
  156. package/dist/spaces/engine.d.ts.map +1 -0
  157. package/dist/spaces/engine.js +563 -0
  158. package/dist/spaces/guard.d.ts +41 -0
  159. package/dist/spaces/guard.d.ts.map +1 -0
  160. package/dist/spaces/guard.js +79 -0
  161. package/dist/spaces/identity.d.ts +37 -0
  162. package/dist/spaces/identity.d.ts.map +1 -0
  163. package/dist/spaces/identity.js +93 -0
  164. package/dist/spaces/index.d.ts +56 -0
  165. package/dist/spaces/index.d.ts.map +1 -0
  166. package/dist/spaces/index.js +134 -0
  167. package/dist/spaces/notify.d.ts +60 -0
  168. package/dist/spaces/notify.d.ts.map +1 -0
  169. package/dist/spaces/notify.js +128 -0
  170. package/dist/spaces/records.d.ts +37 -0
  171. package/dist/spaces/records.d.ts.map +1 -0
  172. package/dist/spaces/records.js +63 -0
  173. package/dist/spaces/signature.d.ts +36 -0
  174. package/dist/spaces/signature.d.ts.map +1 -0
  175. package/dist/spaces/signature.js +83 -0
  176. package/dist/spaces/store.d.ts +51 -0
  177. package/dist/spaces/store.d.ts.map +1 -0
  178. package/dist/spaces/store.js +99 -0
  179. package/dist/spaces/uri.d.ts +60 -0
  180. package/dist/spaces/uri.d.ts.map +1 -0
  181. package/dist/spaces/uri.js +97 -0
  182. package/dist/spaces/verify.d.ts +46 -0
  183. package/dist/spaces/verify.d.ts.map +1 -0
  184. package/dist/spaces/verify.js +94 -0
  185. package/dist/spaces/viewer.d.ts +51 -0
  186. package/dist/spaces/viewer.d.ts.map +1 -0
  187. package/dist/spaces/viewer.js +167 -0
  188. package/dist/spaces/visibility.d.ts +57 -0
  189. package/dist/spaces/visibility.d.ts.map +1 -0
  190. package/dist/spaces/visibility.js +81 -0
  191. package/dist/templates/feed.tpl +18 -0
  192. package/dist/templates/hook.tpl +5 -0
  193. package/dist/templates/label.tpl +15 -0
  194. package/dist/templates/og.tpl +17 -0
  195. package/dist/templates/seed.tpl +11 -0
  196. package/dist/templates/setup.tpl +5 -0
  197. package/dist/templates/test-feed.tpl +19 -0
  198. package/dist/templates/test-xrpc.tpl +19 -0
  199. package/dist/templates/xrpc.tpl +53 -0
  200. package/dist/test.d.ts +3 -1
  201. package/dist/test.d.ts.map +1 -1
  202. package/dist/test.js +60 -36
  203. package/dist/views.js +1 -1
  204. package/dist/vite-plugin.d.ts +1 -1
  205. package/dist/vite-plugin.d.ts.map +1 -1
  206. package/dist/vite-plugin.js +254 -66
  207. package/dist/xrpc.d.ts +143 -12
  208. package/dist/xrpc.d.ts.map +1 -1
  209. package/dist/xrpc.js +282 -55
  210. package/package.json +29 -9
  211. package/public/admin-auth.js +271 -306
  212. package/public/admin.html +652 -61
  213. package/dist/db.d.ts +0 -135
  214. package/dist/db.d.ts.map +0 -1
  215. package/dist/db.js +0 -1365
  216. package/dist/fts.d.ts.map +0 -1
  217. package/dist/oauth/hooks.d.ts +0 -10
  218. package/dist/oauth/hooks.d.ts.map +0 -1
  219. package/dist/oauth/hooks.js +0 -40
  220. package/dist/schema.d.ts +0 -51
  221. package/dist/schema.d.ts.map +0 -1
  222. package/dist/test-browser.d.ts +0 -14
  223. package/dist/test-browser.d.ts.map +0 -1
  224. package/dist/test-browser.js +0 -26
package/dist/setup.d.ts CHANGED
@@ -1,8 +1,35 @@
1
+ import type { BulkInserter } from './database/ports.ts';
2
+ /** Context passed to each setup script's handler function. */
1
3
  export interface SetupContext {
2
4
  db: {
3
5
  query: (sql: string, params?: any[]) => Promise<any[]>;
4
- run: (sql: string, ...params: any[]) => Promise<void>;
6
+ run: (sql: string, params?: any[]) => Promise<void>;
7
+ runBatch: (operations: Array<{
8
+ sql: string;
9
+ params: any[];
10
+ }>) => Promise<void>;
11
+ createBulkInserter: (table: string, columns: string[], options?: {
12
+ onConflict?: 'ignore' | 'replace';
13
+ batchSize?: number;
14
+ }) => Promise<BulkInserter>;
5
15
  };
6
16
  }
17
+ export type SetupHandler = (ctx: SetupContext) => Promise<void>;
18
+ export declare function defineSetup(handler: SetupHandler): {
19
+ __type: "setup";
20
+ handler: SetupHandler;
21
+ };
22
+ /**
23
+ * Run all setup scripts in the given directory on server boot.
24
+ *
25
+ * Each script should export a default handler function (or `{ handler }`) that
26
+ * receives a {@link SetupContext} with database access. Scripts run in sorted
27
+ * filename order — prefix with numbers (e.g. `01-create-tables.ts`) to control
28
+ * execution order. Files starting with `_` are ignored.
29
+ *
30
+ * @param setupDir - Absolute path to the `setup/` directory
31
+ */
7
32
  export declare function initSetup(setupDir: string): Promise<void>;
33
+ /** Run a single setup handler with a SetupContext. */
34
+ export declare function runSetupHandler(name: string, handler: SetupHandler): Promise<void>;
8
35
  //# sourceMappingURL=setup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE;QACF,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QACtD,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KACtD,CAAA;CACF;AAiBD,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB/D"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE;QACF,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QACtD,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QACnD,QAAQ,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,GAAG,EAAE,CAAA;SAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9E,kBAAkB,EAAE,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE;YAAE,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,KAChE,OAAO,CAAC,YAAY,CAAC,CAAA;KAC3B,CAAA;CACF;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAE/D,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY;;;EAEhD;AAkBD;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB/D;AAED,sDAAsD;AACtD,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxF"}
package/dist/setup.js CHANGED
@@ -6,10 +6,38 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
6
6
  }
7
7
  return path;
8
8
  };
9
+ /**
10
+ * Setup scripts that run once on server boot for initializing custom tables,
11
+ * views, or other database state.
12
+ *
13
+ * Place scripts in the `setup/` directory. Each module default-exports a handler
14
+ * function (or `{ handler }`) that receives a {@link SetupContext} with database
15
+ * access. Scripts run in sorted filename order — prefix with numbers to control
16
+ * execution order. Files starting with `_` are ignored.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // setup/01-leaderboard.ts
21
+ * import type { SetupContext } from '@hatk/hatk/setup'
22
+ *
23
+ * export default async function (ctx: SetupContext) {
24
+ * await ctx.db.run(`
25
+ * CREATE TABLE IF NOT EXISTS leaderboard (
26
+ * did TEXT PRIMARY KEY,
27
+ * score INTEGER DEFAULT 0
28
+ * )
29
+ * `)
30
+ * }
31
+ * ```
32
+ */
9
33
  import { resolve, relative } from 'node:path';
10
34
  import { readdirSync, statSync } from 'node:fs';
11
35
  import { log } from "./logger.js";
12
- import { querySQL, runSQL } from "./db.js";
36
+ import { querySQL, runSQL, runBatch, createBulkInserterSQL } from "./database/db.js";
37
+ export function defineSetup(handler) {
38
+ return { __type: 'setup', handler };
39
+ }
40
+ /** Recursively collect .ts/.js files in a directory, skipping files prefixed with `_`. */
13
41
  function walkDir(dir) {
14
42
  const results = [];
15
43
  try {
@@ -26,23 +54,42 @@ function walkDir(dir) {
26
54
  catch { }
27
55
  return results.sort();
28
56
  }
57
+ /**
58
+ * Run all setup scripts in the given directory on server boot.
59
+ *
60
+ * Each script should export a default handler function (or `{ handler }`) that
61
+ * receives a {@link SetupContext} with database access. Scripts run in sorted
62
+ * filename order — prefix with numbers (e.g. `01-create-tables.ts`) to control
63
+ * execution order. Files starting with `_` are ignored.
64
+ *
65
+ * @param setupDir - Absolute path to the `setup/` directory
66
+ */
29
67
  export async function initSetup(setupDir) {
30
68
  const files = walkDir(setupDir);
31
69
  if (files.length === 0)
32
70
  return;
33
71
  for (const scriptPath of files) {
34
72
  const name = relative(setupDir, scriptPath).replace(/\.(ts|js)$/, '');
35
- const mod = await import(__rewriteRelativeImportExtension(scriptPath));
73
+ const mod = await import(__rewriteRelativeImportExtension(/* @vite-ignore */ `${scriptPath}?t=${Date.now()}`));
36
74
  const handler = mod.default?.handler || mod.default;
37
75
  if (typeof handler !== 'function') {
38
76
  console.warn(`[setup] ${name}: no handler function found, skipping`);
39
77
  continue;
40
78
  }
41
79
  const ctx = {
42
- db: { query: querySQL, run: runSQL },
80
+ db: { query: querySQL, run: runSQL, runBatch, createBulkInserter: createBulkInserterSQL },
43
81
  };
44
82
  log(`[setup] running: ${name}`);
45
83
  await handler(ctx);
46
84
  log(`[setup] done: ${name}`);
47
85
  }
48
86
  }
87
+ /** Run a single setup handler with a SetupContext. */
88
+ export async function runSetupHandler(name, handler) {
89
+ const ctx = {
90
+ db: { query: querySQL, run: runSQL, runBatch, createBulkInserter: createBulkInserterSQL },
91
+ };
92
+ log(`[setup] running: ${name}`);
93
+ await handler(ctx);
94
+ log(`[setup] done: ${name}`);
95
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Serving a blob that lives in a permissioned space.
3
+ *
4
+ * Every other image hatk hands out has a public URL — a CDN path, or the
5
+ * repo's own `com.atproto.sync.getBlob`. A space's blob has neither, by
6
+ * design: `com.atproto.space.getBlob` serves it only to a credential holder,
7
+ * and only for a space the blob is actually referenced from. Giving one a
8
+ * public URL would turn that URL into the capability the credential exists to
9
+ * replace.
10
+ *
11
+ * So the bytes come through here, and every request is authorized before any
12
+ * of them move: the viewer's credential for the space, or the same 404 a
13
+ * missing blob gets. What that authorization guards is served two ways —
14
+ * `private` so the viewer's own browser may hold it and no shared cache may,
15
+ * and out of a bounded in-memory cache so the same photo is fetched from its
16
+ * repo once rather than once per member looking at it.
17
+ */
18
+ import type { OAuthConfig } from '../config.ts';
19
+ /**
20
+ * The sizes a space blob is served at.
21
+ *
22
+ * The same words hatk's public path uses for imgproxy, with the same numbers,
23
+ * so an app naming a size says it once and means it either side of the line
24
+ * between a public blob and a permissioned one. What differs is who resizes:
25
+ * a space blob may not pass through an image CDN, so it happens here.
26
+ *
27
+ * A request naming none gets the original, which is what every caller written
28
+ * before presets existed asks for.
29
+ */
30
+ declare const PRESETS: {
31
+ readonly avatar: {
32
+ readonly width: 1000;
33
+ readonly height: 1000;
34
+ readonly fit: "cover";
35
+ readonly quality: 85;
36
+ };
37
+ readonly avatar_thumbnail: {
38
+ readonly width: 128;
39
+ readonly height: 128;
40
+ readonly fit: "cover";
41
+ readonly quality: 70;
42
+ };
43
+ readonly feed_thumbnail: {
44
+ readonly width: 1000;
45
+ readonly fit: "inside";
46
+ readonly quality: 70;
47
+ };
48
+ readonly feed_fullsize: {
49
+ readonly quality: 90;
50
+ };
51
+ readonly banner: {
52
+ readonly width: 3000;
53
+ readonly height: 1000;
54
+ readonly fit: "cover";
55
+ readonly quality: 85;
56
+ };
57
+ };
58
+ export type SpaceBlobPreset = keyof typeof PRESETS;
59
+ /**
60
+ * Only a name from that list is a preset.
61
+ *
62
+ * Free-form dimensions would let anyone mint unlimited distinct cache keys and
63
+ * evict everything real, and would put the cost of an arbitrary resize behind
64
+ * a URL. An unrecognised name is treated as none rather than refused: a broken
65
+ * image is a worse answer than a large one.
66
+ */
67
+ export declare function asPreset(name: string | null | undefined): SpaceBlobPreset | undefined;
68
+ /**
69
+ * The URL this appview serves a space blob at, for whoever is asking.
70
+ *
71
+ * Built here rather than by the app, because the route is hatk's: a blob in a
72
+ * space has no public address by design, and this is the one address it does
73
+ * have — answered only to a viewer who may read the space it names.
74
+ */
75
+ export declare function spaceBlobUrl(space: string, repo: string, cid: string, preset?: SpaceBlobPreset): string;
76
+ /**
77
+ * The CID a blob reference names, in whichever spelling the read used.
78
+ *
79
+ * A repo read gives the lexicon's `{ ref: { $link } }`; a space read comes
80
+ * back through a lex client that decodes the same field into a CID object
81
+ * whose `/` is the string. One blob, two spellings, and no caller should have
82
+ * to know which it got.
83
+ */
84
+ export declare function blobCid(blob: unknown): string | undefined;
85
+ export interface SpaceBlobRequest {
86
+ space: string;
87
+ /** The repo holding the blob — the writer's, not the authority's. */
88
+ repo: string;
89
+ cid: string;
90
+ /** The size to serve it at. Absent means the original. */
91
+ preset?: SpaceBlobPreset;
92
+ }
93
+ export declare function parseSpaceBlobRequest(params: URLSearchParams): SpaceBlobRequest | null;
94
+ /** Drop everything held. For tests, and for an operator who wants it gone. */
95
+ export declare function resetSpaceBlobCache(): void;
96
+ /**
97
+ * Fetch a space blob as this viewer, or answer why not.
98
+ *
99
+ * A viewer who cannot read the space gets the same 404 as a blob that is not
100
+ * there. The distinction between "you may not" and "it does not exist" is
101
+ * itself information about a private space, and the space host draws the line
102
+ * the same way when it reports a non-member's repo as simply absent.
103
+ *
104
+ * The credential is checked on every request, including the ones answered from
105
+ * the cache and the ones answered with a 304. Nothing here is ever served to
106
+ * somebody the authority has not just said yes to.
107
+ */
108
+ export declare function serveSpaceBlob(oauth: OAuthConfig | null, viewer: {
109
+ did: string;
110
+ } | null, request: SpaceBlobRequest, ifNoneMatch?: string | null): Promise<Response>;
111
+ export {};
112
+ //# sourceMappingURL=blob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/spaces/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AA6C/C;;;;;;;;;;GAUG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMsG,CAAA;AAEnH,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,OAAO,CAAA;AAElD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,CAErF;AAKD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAIvG;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMzD;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,0DAA0D;IAC1D,MAAM,CAAC,EAAE,eAAe,CAAA;CACzB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI,CAQtF;AA0DD,8EAA8E;AAC9E,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C;AAuDD;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EAC9B,OAAO,EAAE,gBAAgB,EACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAC1B,OAAO,CAAC,QAAQ,CAAC,CA+BnB"}