@hatk/hatk 0.0.1-alpha.27 → 0.0.1-alpha.29
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/main.js +7 -1
- package/dist/resolve-hatk.d.ts +6 -0
- package/dist/resolve-hatk.d.ts.map +1 -0
- package/dist/resolve-hatk.js +20 -0
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +2 -15
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -9,6 +9,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
9
9
|
};
|
|
10
10
|
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
|
11
11
|
import { dirname, resolve } from 'node:path';
|
|
12
|
+
import { registerHatkResolveHook } from "./resolve-hatk.js";
|
|
12
13
|
import { log } from "./logger.js";
|
|
13
14
|
import { loadConfig } from "./config.js";
|
|
14
15
|
import { loadLexicons, storeLexicons, discoverCollections, buildSchemas } from "./database/schema.js";
|
|
@@ -18,7 +19,7 @@ import { createAdapter } from "./database/adapter-factory.js";
|
|
|
18
19
|
import { getDialect } from "./database/dialect.js";
|
|
19
20
|
import { setSearchPort } from "./database/fts.js";
|
|
20
21
|
import { initFeeds, listFeeds } from "./feeds.js";
|
|
21
|
-
import { initXrpc, listXrpc, configureRelay } from "./xrpc.js";
|
|
22
|
+
import { initXrpc, listXrpc, configureRelay, callXrpc } from "./xrpc.js";
|
|
22
23
|
import { initOpengraph } from "./opengraph.js";
|
|
23
24
|
import { initLabels, getLabelDefinitions } from "./labels.js";
|
|
24
25
|
import { startIndexer } from "./indexer.js";
|
|
@@ -29,6 +30,7 @@ import { validateLexicons } from '@bigmoves/lexicon';
|
|
|
29
30
|
import { relayHttpUrl } from "./config.js";
|
|
30
31
|
import { runBackfill } from "./backfill.js";
|
|
31
32
|
import { initOAuth } from "./oauth/server.js";
|
|
33
|
+
import { parseSessionCookie, getSessionCookieName } from "./oauth/session.js";
|
|
32
34
|
import { loadOnLoginHook } from "./hooks.js";
|
|
33
35
|
import { initSetup } from "./setup.js";
|
|
34
36
|
import { initServer } from "./server-init.js";
|
|
@@ -38,6 +40,7 @@ function logMemory(phase) {
|
|
|
38
40
|
}
|
|
39
41
|
const configPath = process.argv[2] || 'hatk.config.ts';
|
|
40
42
|
const configDir = dirname(resolve(configPath));
|
|
43
|
+
registerHatkResolveHook();
|
|
41
44
|
logMemory('startup');
|
|
42
45
|
// 1. Load config
|
|
43
46
|
const config = await loadConfig(configPath);
|
|
@@ -166,6 +169,9 @@ const handler = createHandler({
|
|
|
166
169
|
admins: config.admins,
|
|
167
170
|
onResync: runBackfillAndRestart,
|
|
168
171
|
});
|
|
172
|
+
globalThis.__hatk_callXrpc = callXrpc;
|
|
173
|
+
globalThis.__hatk_parseSessionCookie = parseSessionCookie;
|
|
174
|
+
globalThis.__hatk_sessionCookieName = getSessionCookieName();
|
|
169
175
|
// Detect SvelteKit build output and use it as fallback handler
|
|
170
176
|
let fallback = undefined;
|
|
171
177
|
const sveltekitHandler = resolve(configDir, 'build', 'handler.js');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-hatk.d.ts","sourceRoot":"","sources":["../src/resolve-hatk.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAU9C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { registerHooks } from 'node:module';
|
|
4
|
+
/**
|
|
5
|
+
* Register a Node.js module resolve hook so dynamic import() of server files
|
|
6
|
+
* can resolve the $hatk alias to the generated entry points.
|
|
7
|
+
*/
|
|
8
|
+
export function registerHatkResolveHook() {
|
|
9
|
+
const hatkUrl = pathToFileURL(resolve('hatk.generated.ts')).href;
|
|
10
|
+
const hatkClientUrl = pathToFileURL(resolve('hatk.generated.client.ts')).href;
|
|
11
|
+
registerHooks({
|
|
12
|
+
resolve(specifier, context, nextResolve) {
|
|
13
|
+
if (specifier === '$hatk/client')
|
|
14
|
+
return { url: hatkClientUrl, shortCircuit: true };
|
|
15
|
+
if (specifier === '$hatk')
|
|
16
|
+
return { url: hatkUrl, shortCircuit: true };
|
|
17
|
+
return nextResolve(specifier, context);
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
package/dist/test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAkBzD,OAAO,EAAE,IAAI,IAAI,iBAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,WAAW,WAAW;IAC1B,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;KACpD,CAAA;IACD,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;KAAE,CAAA;IAC5E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,OAAO,EAAE,CAAC,GAAG,EAAE,G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|
1
1
|
import { resolve, dirname } from 'node:path';
|
|
2
|
-
import { pathToFileURL } from 'node:url';
|
|
3
|
-
import { registerHooks } from 'node:module';
|
|
4
2
|
import { readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { registerHatkResolveHook } from "./resolve-hatk.js";
|
|
5
4
|
import YAML from 'yaml';
|
|
6
5
|
import { loadConfig } from "./config.js";
|
|
7
6
|
import { loadLexicons, storeLexicons, discoverCollections, generateTableSchema, generateCreateTableSQL, } from "./database/schema.js";
|
|
@@ -36,19 +35,7 @@ function findConfigPath() {
|
|
|
36
35
|
* but it will NOT work with --pool=threads (multiple tests sharing a process).
|
|
37
36
|
*/
|
|
38
37
|
export async function createTestContext() {
|
|
39
|
-
|
|
40
|
-
// can resolve the $hatk alias to the generated entry points.
|
|
41
|
-
const hatkUrl = pathToFileURL(resolve('hatk.generated.ts')).href;
|
|
42
|
-
const hatkClientUrl = pathToFileURL(resolve('hatk.generated.client.ts')).href;
|
|
43
|
-
registerHooks({
|
|
44
|
-
resolve(specifier, context, nextResolve) {
|
|
45
|
-
if (specifier === '$hatk/client')
|
|
46
|
-
return { url: hatkClientUrl, shortCircuit: true };
|
|
47
|
-
if (specifier === '$hatk')
|
|
48
|
-
return { url: hatkUrl, shortCircuit: true };
|
|
49
|
-
return nextResolve(specifier, context);
|
|
50
|
-
},
|
|
51
|
-
});
|
|
38
|
+
registerHatkResolveHook();
|
|
52
39
|
const configPath = findConfigPath();
|
|
53
40
|
const config = await loadConfig(configPath);
|
|
54
41
|
const configDir = dirname(resolve(configPath));
|