@hatk/hatk 0.0.1-alpha.24 → 0.0.1-alpha.25
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.
- package/dist/adapter.d.ts +19 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +94 -0
- package/dist/cli.js +186 -66
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +5 -1
- package/dist/dev-entry.d.ts +8 -0
- package/dist/dev-entry.d.ts.map +1 -0
- package/dist/dev-entry.js +109 -0
- package/dist/feeds.d.ts +4 -0
- package/dist/feeds.d.ts.map +1 -1
- package/dist/feeds.js +41 -2
- package/dist/hooks.d.ts +7 -0
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +11 -1
- package/dist/labels.d.ts +14 -0
- package/dist/labels.d.ts.map +1 -1
- package/dist/labels.js +13 -1
- package/dist/main.js +49 -17
- package/dist/oauth/server.d.ts +2 -0
- package/dist/oauth/server.d.ts.map +1 -1
- package/dist/oauth/server.js +91 -1
- package/dist/oauth/session.d.ts +9 -0
- package/dist/oauth/session.d.ts.map +1 -0
- package/dist/oauth/session.js +65 -0
- package/dist/opengraph.d.ts +10 -0
- package/dist/opengraph.d.ts.map +1 -1
- package/dist/opengraph.js +102 -4
- package/dist/pds-proxy.d.ts +39 -0
- package/dist/pds-proxy.d.ts.map +1 -0
- package/dist/pds-proxy.js +173 -0
- package/dist/renderer.d.ts +27 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +46 -0
- package/dist/response.d.ts +16 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +69 -0
- package/dist/scanner.d.ts +21 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +88 -0
- package/dist/server-init.d.ts +8 -0
- package/dist/server-init.d.ts.map +1 -0
- package/dist/server-init.js +59 -0
- package/dist/server.d.ts +26 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +473 -616
- package/dist/setup.d.ts +7 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +13 -1
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +12 -22
- package/dist/vite-plugin.d.ts +1 -1
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +245 -75
- package/dist/xrpc.d.ts +13 -0
- package/dist/xrpc.d.ts.map +1 -1
- package/dist/xrpc.js +87 -1
- package/package.json +8 -5
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type IncomingMessage, type ServerResponse } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a Node.js IncomingMessage to a Web Standard Request.
|
|
4
|
+
*/
|
|
5
|
+
export declare function toRequest(req: IncomingMessage, base: string): Request;
|
|
6
|
+
/**
|
|
7
|
+
* Pipe a Web Standard Response back to a Node.js ServerResponse.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sendResponse(res: ServerResponse, response: Response): Promise<void>;
|
|
10
|
+
/** Routes handled by hatk — everything else can fall through to a framework handler. */
|
|
11
|
+
export declare const HATK_ROUTES: string[];
|
|
12
|
+
export declare function isHatkRoute(pathname: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Create a Node.js HTTP server from a Web Standard fetch handler.
|
|
15
|
+
* If a fallback Node middleware is provided, non-hatk routes are sent to it
|
|
16
|
+
* (e.g. SvelteKit's handler from build/handler.js).
|
|
17
|
+
*/
|
|
18
|
+
export declare function serve(handler: (request: Request) => Promise<Response>, port: number, base?: string, fallback?: (req: IncomingMessage, res: ServerResponse, next: () => void) => void): import("node:http").Server<typeof IncomingMessage, typeof ServerResponse>;
|
|
19
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAgB,MAAM,WAAW,CAAA;AAEnF;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA0BrE;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBzF;AAED,wFAAwF;AACxF,eAAO,MAAM,WAAW,UAAqI,CAAA;AAE7J,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAChD,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,6EA4BjF"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a Node.js IncomingMessage to a Web Standard Request.
|
|
4
|
+
*/
|
|
5
|
+
export function toRequest(req, base) {
|
|
6
|
+
const url = new URL(req.url, base);
|
|
7
|
+
const headers = new Headers();
|
|
8
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
9
|
+
if (value) {
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
for (const v of value)
|
|
12
|
+
headers.append(key, v);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
headers.set(key, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const init = {
|
|
20
|
+
method: req.method,
|
|
21
|
+
headers,
|
|
22
|
+
};
|
|
23
|
+
// GET and HEAD requests cannot have a body
|
|
24
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
25
|
+
// @ts-expect-error — Node.js streams are valid body sources
|
|
26
|
+
init.body = req;
|
|
27
|
+
init.duplex = 'half';
|
|
28
|
+
}
|
|
29
|
+
return new Request(url.href, init);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Pipe a Web Standard Response back to a Node.js ServerResponse.
|
|
33
|
+
*/
|
|
34
|
+
export async function sendResponse(res, response) {
|
|
35
|
+
const rawHeaders = [];
|
|
36
|
+
response.headers.forEach((value, name) => {
|
|
37
|
+
rawHeaders.push(name, value);
|
|
38
|
+
});
|
|
39
|
+
res.writeHead(response.status, rawHeaders);
|
|
40
|
+
if (!response.body) {
|
|
41
|
+
res.end();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const reader = response.body.getReader();
|
|
45
|
+
try {
|
|
46
|
+
while (true) {
|
|
47
|
+
const { done, value } = await reader.read();
|
|
48
|
+
if (done)
|
|
49
|
+
break;
|
|
50
|
+
res.write(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
reader.releaseLock();
|
|
55
|
+
res.end();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Routes handled by hatk — everything else can fall through to a framework handler. */
|
|
59
|
+
export const HATK_ROUTES = ['/xrpc/', '/oauth/', '/.well-known/', '/og/', '/admin', '/repos', '/info/', '/_health', '/robots.txt', '/auth/logout', '/__dev/'];
|
|
60
|
+
export function isHatkRoute(pathname) {
|
|
61
|
+
return HATK_ROUTES.some(r => pathname.startsWith(r) || pathname === r);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a Node.js HTTP server from a Web Standard fetch handler.
|
|
65
|
+
* If a fallback Node middleware is provided, non-hatk routes are sent to it
|
|
66
|
+
* (e.g. SvelteKit's handler from build/handler.js).
|
|
67
|
+
*/
|
|
68
|
+
export function serve(handler, port, base, fallback) {
|
|
69
|
+
const origin = base || `http://localhost:${port}`;
|
|
70
|
+
const server = createServer(async (req, res) => {
|
|
71
|
+
try {
|
|
72
|
+
const url = new URL(req.url, origin);
|
|
73
|
+
// If we have a fallback (e.g. SvelteKit) and this isn't a hatk route, skip hatk
|
|
74
|
+
if (fallback && !isHatkRoute(url.pathname)) {
|
|
75
|
+
fallback(req, res, () => {
|
|
76
|
+
res.writeHead(404);
|
|
77
|
+
res.end('Not found');
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const request = toRequest(req, origin);
|
|
82
|
+
const response = await handler(request);
|
|
83
|
+
await sendResponse(res, response);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
if (!res.headersSent) {
|
|
87
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
88
|
+
}
|
|
89
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
server.listen(port);
|
|
93
|
+
return server;
|
|
94
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -96,6 +96,8 @@ function usage() {
|
|
|
96
96
|
generate label <name> Generate a label definition
|
|
97
97
|
generate og <name> Generate an OpenGraph route
|
|
98
98
|
generate job <name> Generate a periodic job
|
|
99
|
+
generate hook <name> Generate a lifecycle hook
|
|
100
|
+
generate setup <name> Generate a setup script
|
|
99
101
|
generate types Regenerate TypeScript types from lexicons
|
|
100
102
|
destroy <type> <name> Remove a generated file
|
|
101
103
|
|
|
@@ -123,7 +125,7 @@ export default defineFeed({
|
|
|
123
125
|
},
|
|
124
126
|
})
|
|
125
127
|
`,
|
|
126
|
-
xrpc: (name) => `import { defineQuery } from '
|
|
128
|
+
xrpc: (name) => `import { defineQuery } from '../hatk.generated.ts'
|
|
127
129
|
|
|
128
130
|
export default defineQuery('${name}', async (ctx) => {
|
|
129
131
|
const { ok, db, params, packCursor, unpackCursor } = ctx
|
|
@@ -200,16 +202,20 @@ export default {
|
|
|
200
202
|
// Periodic task logic here
|
|
201
203
|
},
|
|
202
204
|
}
|
|
205
|
+
`,
|
|
206
|
+
hook: (name) => `import { defineHook } from '../hatk.generated.ts'
|
|
207
|
+
|
|
208
|
+
export default defineHook('${name}', async (ctx) => {
|
|
209
|
+
// Hook logic here
|
|
210
|
+
})
|
|
211
|
+
`,
|
|
212
|
+
setup: (_name) => `import { defineSetup } from '../hatk.generated.ts'
|
|
213
|
+
|
|
214
|
+
export default defineSetup(async (ctx) => {
|
|
215
|
+
// Setup logic here — runs before the server starts
|
|
216
|
+
})
|
|
203
217
|
`,
|
|
204
218
|
};
|
|
205
|
-
// Compute relative import path from xrpc/ns/id/method.ts back to hatk.generated.ts
|
|
206
|
-
// e.g. fm.teal.getStats → xrpc/fm/teal/getStats.ts → needs ../../../hatk.generated.ts
|
|
207
|
-
// Parts: [fm, teal, getStats] → 2 namespace dirs + xrpc/ dir = 3 levels up
|
|
208
|
-
function xrpcImportPath(nsid) {
|
|
209
|
-
const parts = nsid.split('.');
|
|
210
|
-
const namespaceDirs = parts.length - 1; // dirs created from namespace segments
|
|
211
|
-
return '../'.repeat(namespaceDirs + 1) + 'hatk.generated.ts'; // +1 for xrpc/ dir itself
|
|
212
|
-
}
|
|
213
219
|
const testTemplates = {
|
|
214
220
|
feed: (name) => `import { describe, test, expect, beforeAll, afterAll } from 'vitest'
|
|
215
221
|
import { createTestContext } from '@hatk/hatk/test'
|
|
@@ -318,11 +324,13 @@ const lexiconTemplates = {
|
|
|
318
324
|
}),
|
|
319
325
|
};
|
|
320
326
|
const dirs = {
|
|
321
|
-
feed: '
|
|
322
|
-
xrpc: '
|
|
323
|
-
label: '
|
|
324
|
-
og: '
|
|
325
|
-
job: '
|
|
327
|
+
feed: 'server',
|
|
328
|
+
xrpc: 'server',
|
|
329
|
+
label: 'server',
|
|
330
|
+
og: 'server',
|
|
331
|
+
job: 'server',
|
|
332
|
+
hook: 'server',
|
|
333
|
+
setup: 'server',
|
|
326
334
|
};
|
|
327
335
|
// --- Commands ---
|
|
328
336
|
if (command === 'new') {
|
|
@@ -371,17 +379,11 @@ if (command === 'new') {
|
|
|
371
379
|
mkdirSync(dir);
|
|
372
380
|
const subs = [
|
|
373
381
|
'lexicons',
|
|
374
|
-
'
|
|
375
|
-
'xrpc',
|
|
376
|
-
'og',
|
|
377
|
-
'labels',
|
|
378
|
-
'jobs',
|
|
382
|
+
'server',
|
|
379
383
|
'seeds',
|
|
380
|
-
'setup',
|
|
381
384
|
'public',
|
|
382
385
|
'test',
|
|
383
|
-
'test/
|
|
384
|
-
'test/xrpc',
|
|
386
|
+
'test/server',
|
|
385
387
|
'test/integration',
|
|
386
388
|
'test/browser',
|
|
387
389
|
'test/fixtures',
|
|
@@ -944,7 +946,7 @@ CMD ["node", "--experimental-strip-types", "--max-old-space-size=512", "node_mod
|
|
|
944
946
|
allowImportingTsExtensions: true,
|
|
945
947
|
resolveJsonModule: true,
|
|
946
948
|
},
|
|
947
|
-
include: ['
|
|
949
|
+
include: ['server', 'seeds', 'hatk.generated.ts', 'hatk.config.ts'],
|
|
948
950
|
}, null, 2) + '\n');
|
|
949
951
|
writeFileSync(join(dir, 'playwright.config.ts'), `import { defineConfig } from '@playwright/test'
|
|
950
952
|
|
|
@@ -1140,14 +1142,8 @@ Types are generated from lexicons into \`hatk.generated.ts\` — never edit this
|
|
|
1140
1142
|
| Directory | Purpose |
|
|
1141
1143
|
|-------------|------------------------------------------------------|
|
|
1142
1144
|
| \`lexicons/\` | AT Protocol lexicon schemas (JSON). Defines collections and XRPC methods |
|
|
1143
|
-
| \`
|
|
1144
|
-
| \`xrpc/\` | XRPC method handlers — directory nesting maps to NSID segments |
|
|
1145
|
-
| \`labels/\` | Label definitions and rules for moderation |
|
|
1146
|
-
| \`setup/\` | Boot-time scripts (run before server starts). Prefix with numbers for ordering |
|
|
1145
|
+
| \`server/\` | All server-side code: feeds, XRPC handlers, hooks, labels, OG routes, jobs, setup scripts |
|
|
1147
1146
|
| \`seeds/\` | Test data seeding scripts for local development |
|
|
1148
|
-
| \`hooks/\` | Lifecycle hooks (e.g. \`on-login.ts\`) |
|
|
1149
|
-
| \`og/\` | OpenGraph image routes |
|
|
1150
|
-
| \`jobs/\` | Periodic background tasks |
|
|
1151
1147
|
| \`test/\` | Test files (vitest). Run with \`hatk test\` |
|
|
1152
1148
|
| \`public/\` | Static files served at the root |
|
|
1153
1149
|
|
|
@@ -1169,13 +1165,8 @@ After modifying lexicons, always run \`npx hatk generate types\` to update the g
|
|
|
1169
1165
|
console.log(`Created ${name}/`);
|
|
1170
1166
|
console.log(` hatk.config.ts`);
|
|
1171
1167
|
console.log(` lexicons/ — lexicon JSON files (core + your own)`);
|
|
1172
|
-
console.log(`
|
|
1173
|
-
console.log(` xrpc/ — XRPC method handlers`);
|
|
1174
|
-
console.log(` og/ — OpenGraph image routes`);
|
|
1175
|
-
console.log(` labels/ — label definitions + rules`);
|
|
1176
|
-
console.log(` jobs/ — periodic tasks`);
|
|
1168
|
+
console.log(` server/ — feeds, XRPC handlers, hooks, labels, OG routes, jobs, setup`);
|
|
1177
1169
|
console.log(` seeds/ — seed fixture data (hatk seed)`);
|
|
1178
|
-
console.log(` setup/ — boot-time setup scripts (run before server starts)`);
|
|
1179
1170
|
console.log(` test/ — test files (hatk test)`);
|
|
1180
1171
|
console.log(` public/ — static files`);
|
|
1181
1172
|
console.log(` docker-compose.yml — local PDS for development`);
|
|
@@ -1214,6 +1205,21 @@ else if (command === 'generate') {
|
|
|
1214
1205
|
}
|
|
1215
1206
|
}
|
|
1216
1207
|
entries.sort((a, b) => a.nsid.localeCompare(b.nsid));
|
|
1208
|
+
// Collect procedure nsids and blob-input nsids for client callXrpc
|
|
1209
|
+
const procedureNsids = [];
|
|
1210
|
+
const blobInputNsids = [];
|
|
1211
|
+
for (const { nsid, defType } of entries) {
|
|
1212
|
+
if (defType === 'procedure') {
|
|
1213
|
+
const lex = lexicons.get(nsid);
|
|
1214
|
+
const inputEncoding = lex?.defs?.main?.input?.encoding;
|
|
1215
|
+
if (inputEncoding === '*/*') {
|
|
1216
|
+
blobInputNsids.push(nsid);
|
|
1217
|
+
}
|
|
1218
|
+
else {
|
|
1219
|
+
procedureNsids.push(nsid);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1217
1223
|
if (entries.length === 0) {
|
|
1218
1224
|
console.error('No lexicons found');
|
|
1219
1225
|
process.exit(1);
|
|
@@ -1261,6 +1267,7 @@ else if (command === 'generate') {
|
|
|
1261
1267
|
let out = '// Auto-generated from lexicons. Do not edit.\n';
|
|
1262
1268
|
out += `import type { ${[...usedWrappers].sort().join(', ')}, LexServerParams, Checked, Prettify, StrictArg } from '@hatk/hatk/lex-types'\n`;
|
|
1263
1269
|
out += `import type { XrpcContext } from '@hatk/hatk/xrpc'\n`;
|
|
1270
|
+
out += `import { callXrpc as _callXrpc } from '@hatk/hatk/xrpc'\n`;
|
|
1264
1271
|
out += `import { defineFeed as _defineFeed, type FeedResult, type FeedContext, type HydrateContext } from '@hatk/hatk/feeds'\n`;
|
|
1265
1272
|
out += `import { seed as _seed, type SeedOpts } from '@hatk/hatk/seed'\n`;
|
|
1266
1273
|
// Emit ALL lexicons as `const ... = {...} as const` (including defs-only)
|
|
@@ -1419,6 +1426,11 @@ else if (command === 'generate') {
|
|
|
1419
1426
|
out += `\n// ─── XRPC Helpers ───────────────────────────────────────────────────\n\n`;
|
|
1420
1427
|
out += `export type { HydrateContext } from '@hatk/hatk/feeds'\n`;
|
|
1421
1428
|
out += `export { InvalidRequestError, NotFoundError } from '@hatk/hatk/xrpc'\n`;
|
|
1429
|
+
out += `export { defineSetup } from '@hatk/hatk/setup'\n`;
|
|
1430
|
+
out += `export { defineHook } from '@hatk/hatk/hooks'\n`;
|
|
1431
|
+
out += `export { defineLabels } from '@hatk/hatk/labels'\n`;
|
|
1432
|
+
out += `export { defineOG } from '@hatk/hatk/opengraph'\n`;
|
|
1433
|
+
out += `export { defineRenderer } from '@hatk/hatk/renderer'\n`;
|
|
1422
1434
|
out += `export type Ctx<K extends keyof XrpcSchema & keyof Registry> = XrpcContext<\n`;
|
|
1423
1435
|
out += ` LexServerParams<Registry[K], Registry>,\n`;
|
|
1424
1436
|
out += ` RecordRegistry,\n`;
|
|
@@ -1431,13 +1443,21 @@ else if (command === 'generate') {
|
|
|
1431
1443
|
out += ` nsid: K,\n`;
|
|
1432
1444
|
out += ` handler: (ctx: Ctx<K> & { ok: <T extends OutputOf<K>>(value: StrictArg<T, OutputOf<K>>) => Checked<OutputOf<K>> }) => Promise<Checked<OutputOf<K>>>,\n`;
|
|
1433
1445
|
out += `) {\n`;
|
|
1434
|
-
out += ` return { handler: (ctx: any) => handler({ ...ctx, ok: (v: any) => v }) }\n`;
|
|
1446
|
+
out += ` return { __type: 'query' as const, nsid, handler: (ctx: any) => handler({ ...ctx, ok: (v: any) => v }) }\n`;
|
|
1435
1447
|
out += `}\n\n`;
|
|
1436
1448
|
out += `export function defineProcedure<K extends keyof XrpcSchema & string>(\n`;
|
|
1437
1449
|
out += ` nsid: K,\n`;
|
|
1438
1450
|
out += ` handler: (ctx: Ctx<K> & { ok: <T extends OutputOf<K>>(value: StrictArg<T, OutputOf<K>>) => Checked<OutputOf<K>> }) => Promise<Checked<OutputOf<K>>>,\n`;
|
|
1439
1451
|
out += `) {\n`;
|
|
1440
|
-
out += ` return { handler: (ctx: any) => handler({ ...ctx, ok: (v: any) => v }) }\n`;
|
|
1452
|
+
out += ` return { __type: 'procedure' as const, nsid, handler: (ctx: any) => handler({ ...ctx, ok: (v: any) => v }) }\n`;
|
|
1453
|
+
out += `}\n\n`;
|
|
1454
|
+
out += `// ─── Server-side XRPC Caller ────────────────────────────────────────\n\n`;
|
|
1455
|
+
out += `type ExtractParams<T> = T extends { params: infer P } ? P : Record<string, unknown>\n`;
|
|
1456
|
+
out += `export async function callXrpc<K extends keyof XrpcSchema & string>(\n`;
|
|
1457
|
+
out += ` nsid: K,\n`;
|
|
1458
|
+
out += ` params?: ExtractParams<XrpcSchema[K]>,\n`;
|
|
1459
|
+
out += `): Promise<OutputOf<K>> {\n`;
|
|
1460
|
+
out += ` return _callXrpc(nsid, params as any) as Promise<OutputOf<K>>\n`;
|
|
1441
1461
|
out += `}\n\n`;
|
|
1442
1462
|
out += `// ─── Feed & Seed Helpers ────────────────────────────────────────────\n\n`;
|
|
1443
1463
|
out += `type FeedGenerate = (ctx: FeedContext & { ok: (value: FeedResult) => Checked<FeedResult> }) => Promise<Checked<FeedResult>>\n`;
|
|
@@ -1468,7 +1488,125 @@ else if (command === 'generate') {
|
|
|
1468
1488
|
out = out.replace(/import type \{ ([^}]+) \} from '@hatk\/hatk\/lex-types'/, `import type { ${[...usedWrappers].sort().join(', ')}, LexServerParams, Checked, Prettify, StrictArg } from '@hatk/hatk/lex-types'`);
|
|
1469
1489
|
}
|
|
1470
1490
|
writeFileSync(outPath, out);
|
|
1491
|
+
// Generate client-safe version (types + callXrpc only, no server module re-exports)
|
|
1492
|
+
// Types use `export type` from main file (erased at compile time, no runtime import).
|
|
1493
|
+
// callXrpc imports from @hatk/hatk/xrpc directly to avoid pulling in server deps.
|
|
1494
|
+
let clientOut = '// Auto-generated client-safe subset. Do not edit.\n';
|
|
1495
|
+
clientOut += `// Import this in app components instead of hatk.generated.ts\n`;
|
|
1496
|
+
clientOut += `// to avoid pulling in server-only dependencies.\n`;
|
|
1497
|
+
clientOut += `export type { XrpcSchema } from './hatk.generated.ts'\n`;
|
|
1498
|
+
clientOut += `import type { XrpcSchema } from './hatk.generated.ts'\n`;
|
|
1499
|
+
// Re-export all types
|
|
1500
|
+
const typeExports = [];
|
|
1501
|
+
for (const { nsid, defType } of entries) {
|
|
1502
|
+
if (!defType)
|
|
1503
|
+
continue;
|
|
1504
|
+
if (nsid === 'dev.hatk.createRecord' || nsid === 'dev.hatk.deleteRecord' || nsid === 'dev.hatk.putRecord')
|
|
1505
|
+
continue;
|
|
1506
|
+
typeExports.push(capitalize(varNames.get(nsid)));
|
|
1507
|
+
}
|
|
1508
|
+
if (recordEntries.length > 0) {
|
|
1509
|
+
typeExports.push('RecordRegistry', 'CreateRecord', 'DeleteRecord', 'PutRecord');
|
|
1510
|
+
}
|
|
1511
|
+
// Named defs (views, objects) — collect from emittedDefNames minus main types
|
|
1512
|
+
const mainTypeNames = new Set(entries.filter(e => e.defType).map(e => capitalize(varNames.get(e.nsid))));
|
|
1513
|
+
for (const name of emittedDefNames) {
|
|
1514
|
+
if (!mainTypeNames.has(name) && !typeExports.includes(name)) {
|
|
1515
|
+
typeExports.push(name);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
if (typeExports.length > 0) {
|
|
1519
|
+
clientOut += `export type { ${typeExports.join(', ')} } from './hatk.generated.ts'\n`;
|
|
1520
|
+
}
|
|
1521
|
+
// Typed callXrpc — environment-aware:
|
|
1522
|
+
// SSR: uses globalThis.__hatk_callXrpc bridge (direct handler invocation)
|
|
1523
|
+
// Client: fetches via HTTP (GET for queries, POST for procedures, raw POST for blobs)
|
|
1524
|
+
if (procedureNsids.length > 0) {
|
|
1525
|
+
clientOut += `\nconst _procedures = new Set([${procedureNsids.map(n => `'${n}'`).join(', ')}])\n`;
|
|
1526
|
+
}
|
|
1527
|
+
if (blobInputNsids.length > 0) {
|
|
1528
|
+
clientOut += `const _blobInputs = new Set([${blobInputNsids.map(n => `'${n}'`).join(', ')}])\n`;
|
|
1529
|
+
}
|
|
1530
|
+
clientOut += `\ntype CallArg<K extends keyof XrpcSchema> =\n`;
|
|
1531
|
+
clientOut += ` XrpcSchema[K] extends { input: infer I } ? I :\n`;
|
|
1532
|
+
clientOut += ` XrpcSchema[K] extends { params: infer P } ? P :\n`;
|
|
1533
|
+
clientOut += ` Record<string, unknown>\n`;
|
|
1534
|
+
clientOut += `type OutputOf<K extends keyof XrpcSchema> = XrpcSchema[K]['output']\n\n`;
|
|
1535
|
+
clientOut += `export async function callXrpc<K extends keyof XrpcSchema & string>(\n`;
|
|
1536
|
+
clientOut += ` nsid: K,\n`;
|
|
1537
|
+
clientOut += ` arg?: CallArg<K>,\n`;
|
|
1538
|
+
clientOut += `): Promise<OutputOf<K>> {\n`;
|
|
1539
|
+
// Server-side bridge
|
|
1540
|
+
clientOut += ` if (typeof window === 'undefined') {\n`;
|
|
1541
|
+
clientOut += ` const bridge = (globalThis as any).__hatk_callXrpc\n`;
|
|
1542
|
+
clientOut += ` if (!bridge) throw new Error('callXrpc: server bridge not available — is hatk initialized?')\n`;
|
|
1543
|
+
if (procedureNsids.length > 0 || blobInputNsids.length > 0) {
|
|
1544
|
+
const checks = [];
|
|
1545
|
+
if (procedureNsids.length > 0)
|
|
1546
|
+
checks.push('_procedures.has(nsid)');
|
|
1547
|
+
if (blobInputNsids.length > 0)
|
|
1548
|
+
checks.push('_blobInputs.has(nsid)');
|
|
1549
|
+
clientOut += ` if (${checks.join(' || ')}) return bridge(nsid, {}, arg) as Promise<OutputOf<K>>\n`;
|
|
1550
|
+
}
|
|
1551
|
+
clientOut += ` return bridge(nsid, arg) as Promise<OutputOf<K>>\n`;
|
|
1552
|
+
clientOut += ` }\n`;
|
|
1553
|
+
// Client-side fetch
|
|
1554
|
+
clientOut += ` const url = new URL(\`/xrpc/\${nsid}\`, window.location.origin)\n`;
|
|
1555
|
+
if (blobInputNsids.length > 0) {
|
|
1556
|
+
clientOut += ` if (_blobInputs.has(nsid)) {\n`;
|
|
1557
|
+
clientOut += ` const blob = arg as Blob | ArrayBuffer\n`;
|
|
1558
|
+
clientOut += ` const ct = blob instanceof Blob ? blob.type : 'application/octet-stream'\n`;
|
|
1559
|
+
clientOut += ` const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': ct }, body: blob })\n`;
|
|
1560
|
+
clientOut += ` if (!res.ok) throw new Error(\`XRPC \${nsid} failed: \${res.status}\`)\n`;
|
|
1561
|
+
clientOut += ` return res.json() as Promise<OutputOf<K>>\n`;
|
|
1562
|
+
clientOut += ` }\n`;
|
|
1563
|
+
}
|
|
1564
|
+
if (procedureNsids.length > 0) {
|
|
1565
|
+
clientOut += ` if (_procedures.has(nsid)) {\n`;
|
|
1566
|
+
clientOut += ` const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(arg) })\n`;
|
|
1567
|
+
clientOut += ` if (!res.ok) throw new Error(\`XRPC \${nsid} failed: \${res.status}\`)\n`;
|
|
1568
|
+
clientOut += ` return res.json() as Promise<OutputOf<K>>\n`;
|
|
1569
|
+
clientOut += ` }\n`;
|
|
1570
|
+
}
|
|
1571
|
+
clientOut += ` for (const [k, v] of Object.entries(arg || {})) {\n`;
|
|
1572
|
+
clientOut += ` if (v != null) url.searchParams.set(k, String(v))\n`;
|
|
1573
|
+
clientOut += ` }\n`;
|
|
1574
|
+
clientOut += ` const res = await fetch(url)\n`;
|
|
1575
|
+
clientOut += ` if (!res.ok) throw new Error(\`XRPC \${nsid} failed: \${res.status}\`)\n`;
|
|
1576
|
+
clientOut += ` return res.json() as Promise<OutputOf<K>>\n`;
|
|
1577
|
+
clientOut += `}\n`;
|
|
1578
|
+
// getViewer — async, resolves from cookies on server via getRequestEvent()
|
|
1579
|
+
clientOut += `\nexport async function getViewer(): Promise<{ did: string } | null> {\n`;
|
|
1580
|
+
clientOut += ` if (typeof window === 'undefined') {\n`;
|
|
1581
|
+
clientOut += ` try {\n`;
|
|
1582
|
+
clientOut += ` const parse = (globalThis as any).__hatk_parseSessionCookie\n`;
|
|
1583
|
+
clientOut += ` if (parse) {\n`;
|
|
1584
|
+
clientOut += ` const { getRequestEvent } = await import('$app/server')\n`;
|
|
1585
|
+
clientOut += ` const event = getRequestEvent()\n`;
|
|
1586
|
+
clientOut += ` const cookieName = (globalThis as any).__hatk_sessionCookieName ?? '__hatk_session'\n`;
|
|
1587
|
+
clientOut += ` const cookieValue = event.cookies.get(cookieName)\n`;
|
|
1588
|
+
clientOut += ` if (cookieValue) {\n`;
|
|
1589
|
+
clientOut += ` const request = new Request('http://localhost', {\n`;
|
|
1590
|
+
clientOut += ` headers: { cookie: \`\${cookieName}=\${cookieValue}\` },\n`;
|
|
1591
|
+
clientOut += ` })\n`;
|
|
1592
|
+
clientOut += ` return parse(request)\n`;
|
|
1593
|
+
clientOut += ` }\n`;
|
|
1594
|
+
clientOut += ` }\n`;
|
|
1595
|
+
clientOut += ` } catch {}\n`;
|
|
1596
|
+
clientOut += ` return (globalThis as any).__hatk_viewer ?? null\n`;
|
|
1597
|
+
clientOut += ` }\n`;
|
|
1598
|
+
clientOut += ` try {\n`;
|
|
1599
|
+
clientOut += ` const mod = (globalThis as any).__hatk_auth\n`;
|
|
1600
|
+
clientOut += ` if (mod?.viewerDid) {\n`;
|
|
1601
|
+
clientOut += ` const did = mod.viewerDid()\n`;
|
|
1602
|
+
clientOut += ` if (did) return { did }\n`;
|
|
1603
|
+
clientOut += ` }\n`;
|
|
1604
|
+
clientOut += ` } catch {}\n`;
|
|
1605
|
+
clientOut += ` return (globalThis as any).__hatk_viewer ?? null\n`;
|
|
1606
|
+
clientOut += `}\n`;
|
|
1607
|
+
writeFileSync('./hatk.generated.client.ts', clientOut);
|
|
1471
1608
|
console.log(`Generated ${outPath} with ${entries.length} types: ${entries.map((e) => capitalize(varNames.get(e.nsid))).join(', ')}`);
|
|
1609
|
+
console.log(`Generated ./hatk.generated.client.ts (client-safe subset)`);
|
|
1472
1610
|
}
|
|
1473
1611
|
else if (lexiconTemplates[type]) {
|
|
1474
1612
|
const nsid = args[2];
|
|
@@ -1496,18 +1634,9 @@ else if (command === 'generate') {
|
|
|
1496
1634
|
process.exit(1);
|
|
1497
1635
|
}
|
|
1498
1636
|
const baseDir = dirs[type];
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
const parts = name.split('.');
|
|
1503
|
-
const subDir = join(baseDir, ...parts.slice(0, -1));
|
|
1504
|
-
mkdirSync(subDir, { recursive: true });
|
|
1505
|
-
filePath = join(subDir, `${parts[parts.length - 1]}.ts`);
|
|
1506
|
-
}
|
|
1507
|
-
else {
|
|
1508
|
-
mkdirSync(baseDir, { recursive: true });
|
|
1509
|
-
filePath = join(baseDir, `${name}.ts`);
|
|
1510
|
-
}
|
|
1637
|
+
mkdirSync(baseDir, { recursive: true });
|
|
1638
|
+
const fileName = type === 'xrpc' ? name.split('.').pop() : name;
|
|
1639
|
+
const filePath = join(baseDir, `${fileName}.ts`);
|
|
1511
1640
|
if (existsSync(filePath)) {
|
|
1512
1641
|
console.error(`${filePath} already exists`);
|
|
1513
1642
|
process.exit(1);
|
|
@@ -1517,7 +1646,7 @@ else if (command === 'generate') {
|
|
|
1517
1646
|
// Scaffold test file if template exists
|
|
1518
1647
|
const testTemplate = testTemplates[type];
|
|
1519
1648
|
if (testTemplate) {
|
|
1520
|
-
const testDir =
|
|
1649
|
+
const testDir = 'test/server';
|
|
1521
1650
|
mkdirSync(testDir, { recursive: true });
|
|
1522
1651
|
const testName = type === 'xrpc' ? name.split('.').pop() : name;
|
|
1523
1652
|
const testPath = join(testDir, `${testName}.test.ts`);
|
|
@@ -1536,18 +1665,9 @@ else if (command === 'destroy') {
|
|
|
1536
1665
|
process.exit(1);
|
|
1537
1666
|
}
|
|
1538
1667
|
const baseDir = dirs[type];
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const leaf = parts[parts.length - 1];
|
|
1543
|
-
const subDir = join(baseDir, ...parts.slice(0, -1));
|
|
1544
|
-
tsPath = join(subDir, `${leaf}.ts`);
|
|
1545
|
-
jsPath = join(subDir, `${leaf}.js`);
|
|
1546
|
-
}
|
|
1547
|
-
else {
|
|
1548
|
-
tsPath = join(baseDir, `${name}.ts`);
|
|
1549
|
-
jsPath = join(baseDir, `${name}.js`);
|
|
1550
|
-
}
|
|
1668
|
+
const fileName = type === 'xrpc' ? name.split('.').pop() : name;
|
|
1669
|
+
const tsPath = join(baseDir, `${fileName}.ts`);
|
|
1670
|
+
const jsPath = join(baseDir, `${fileName}.js`);
|
|
1551
1671
|
const filePath = existsSync(tsPath) ? tsPath : existsSync(jsPath) ? jsPath : null;
|
|
1552
1672
|
if (!filePath) {
|
|
1553
1673
|
console.error(`No file found for ${type} "${name}"`);
|
|
@@ -1556,7 +1676,7 @@ else if (command === 'destroy') {
|
|
|
1556
1676
|
unlinkSync(filePath);
|
|
1557
1677
|
console.log(`Removed ${filePath}`);
|
|
1558
1678
|
// Clean up test file
|
|
1559
|
-
const testDir =
|
|
1679
|
+
const testDir = 'test/server';
|
|
1560
1680
|
const testName = type === 'xrpc' ? name.split('.').pop() : name;
|
|
1561
1681
|
const testFile = join(testDir, `${testName}.test.ts`);
|
|
1562
1682
|
if (existsSync(testFile)) {
|
|
@@ -1570,8 +1690,8 @@ else if (command === 'destroy') {
|
|
|
1570
1690
|
else if (command === 'dev') {
|
|
1571
1691
|
await ensurePds();
|
|
1572
1692
|
runSeed();
|
|
1573
|
-
if (existsSync(resolve('
|
|
1574
|
-
//
|
|
1693
|
+
if (existsSync(resolve('vite.config.ts')) || existsSync(resolve('vite.config.js'))) {
|
|
1694
|
+
// Vite project — vite dev starts the hatk server via the plugin
|
|
1575
1695
|
await spawnForward('npx', ['vite', 'dev']);
|
|
1576
1696
|
}
|
|
1577
1697
|
else {
|
package/dist/config.d.ts
CHANGED
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACrC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;IACnC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;IAC1C,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;C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A;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,QAAQ,GAAG,QAAQ,CAAA;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,QAAQ,EAAE,cAAc,CAAA;IACxB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC,GAAG;IAC9E,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG;QAAE,OAAO,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC,GAAG,IAAI,CAAA;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CACnC,CAAA;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAErE;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAwDxE"}
|
package/dist/config.js
CHANGED
|
@@ -27,7 +27,7 @@ export async function loadConfig(configPath) {
|
|
|
27
27
|
const configDir = dirname(resolved);
|
|
28
28
|
let mod;
|
|
29
29
|
try {
|
|
30
|
-
mod = await import(__rewriteRelativeImportExtension(resolved));
|
|
30
|
+
mod = await import(__rewriteRelativeImportExtension(/* @vite-ignore */ resolved));
|
|
31
31
|
}
|
|
32
32
|
catch (err) {
|
|
33
33
|
console.error(`Failed to load config file: ${resolved}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/database/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAI1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAM1D,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AACD,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAMD,wBAAsB,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAc/F;AAMD,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,WAAW,EAAE,EAC3B,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,IAAI,CAAC,CA0Ef;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAA;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAoED,wBAAsB,aAAa,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA6F3F;AA0CD,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,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AAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASpF;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAIlE;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAKtF;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxE;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAO3E;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGlE;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAW9E;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAOvF;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAK9E"}
|
package/dist/database/db.js
CHANGED
|
@@ -385,10 +385,14 @@ export async function getSchemaDump() {
|
|
|
385
385
|
// SQLite: use sqlite_master, skip FTS shadow/internal tables
|
|
386
386
|
rows = await all(`SELECT sql FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_fts_%' AND sql IS NOT NULL ORDER BY name`);
|
|
387
387
|
}
|
|
388
|
-
// Normalize indentation
|
|
388
|
+
// Normalize indentation and formatting
|
|
389
389
|
return rows
|
|
390
390
|
.map((r) => {
|
|
391
391
|
let sql = r.sql.trim();
|
|
392
|
+
// Remove quotes around column names (SQLite adds them for some columns)
|
|
393
|
+
sql = sql.replace(/\n\s*"(\w+)"/g, '\n$1');
|
|
394
|
+
// Ensure closing paren is on its own line
|
|
395
|
+
sql = sql.replace(/([^(\s])\)$/, '$1\n)');
|
|
392
396
|
// Split into lines and re-indent consistently
|
|
393
397
|
const lines = sql.split('\n').map((l) => l.trim());
|
|
394
398
|
sql = lines
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const handler: (request: Request) => Promise<Response>;
|
|
2
|
+
/** Re-scan server/ directory to pick up changed handlers in dev mode. */
|
|
3
|
+
export declare function reloadServer(): Promise<void>;
|
|
4
|
+
export { renderPage } from './renderer.ts';
|
|
5
|
+
export { getRenderer } from './renderer.ts';
|
|
6
|
+
export { callXrpc } from './xrpc.ts';
|
|
7
|
+
export { parseSessionCookie, getSessionCookieName } from './oauth/session.ts';
|
|
8
|
+
//# sourceMappingURL=dev-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-entry.d.ts","sourceRoot":"","sources":["../src/dev-entry.ts"],"names":[],"mappings":"AA0GA,eAAO,MAAM,OAAO,yCAKlB,CAAA;AAEF,yEAAyE;AACzE,wBAAsB,YAAY,kBAEjC;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA"}
|