@drfed/drfed 0.2.0-dev.567 → 0.2.0-dev.608
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/completions/bash/drfed-account +529 -30
- package/completions/bash/drfed-migrate +529 -30
- package/completions/bash/drfed-server +529 -30
- package/completions/bash/drfed-web +529 -30
- package/completions/fish/drfed-account.fish +137 -49
- package/completions/fish/drfed-migrate.fish +137 -49
- package/completions/fish/drfed-server.fish +137 -49
- package/completions/fish/drfed-web.fish +137 -49
- package/completions/nu/drfed-account.nu +303 -73
- package/completions/nu/drfed-migrate.nu +303 -73
- package/completions/nu/drfed-server.nu +303 -73
- package/completions/nu/drfed-web.nu +303 -73
- package/completions/pwsh/drfed-account.ps1 +153 -34
- package/completions/pwsh/drfed-migrate.ps1 +153 -34
- package/completions/pwsh/drfed-server.ps1 +153 -34
- package/completions/pwsh/drfed-web.ps1 +153 -34
- package/completions/zsh/_drfed-account +532 -34
- package/completions/zsh/_drfed-migrate +532 -34
- package/completions/zsh/_drfed-server +532 -34
- package/completions/zsh/_drfed-web +532 -34
- package/dist/api-mail-parser.d.mts.map +1 -1
- package/dist/commands/account-program.d.mts.map +1 -1
- package/dist/commands/account.mjs +6 -4
- package/dist/commands/account.mjs.map +1 -1
- package/dist/commands/migrate-program.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +6 -4
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/web-program.d.mts.map +1 -1
- package/dist/commands/web.mjs +7 -5
- package/dist/commands/web.mjs.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/jmap-parser.d.mts.map +1 -1
- package/dist/logging.d.mts.map +1 -1
- package/dist/mail-parser-DyI4wuQp.d.mts.map +1 -1
- package/dist/mail-runtime.mjs +1 -2
- package/dist/mail-settings-DjWMAUaE.d.mts.map +1 -1
- package/dist/mail-settings.mjs +1 -2
- package/dist/operations.mjs.map +1 -1
- package/dist/package-91KEch3P.mjs +6 -0
- package/dist/package-91KEch3P.mjs.map +1 -0
- package/dist/parser-TANGHRjL.d.mts.map +1 -1
- package/dist/resources.mjs.map +1 -1
- package/package.json +15 -15
- package/dist/package-CaLSz3rX.mjs +0 -6
- package/dist/package-CaLSz3rX.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-program.d.mts","names":[],"sources":["../../src/commands/account-program.ts"],"mappings":";;;;;;;iBAuCgB,qBACd,UAAS,kBAAkB;;;MAyFrB;MACA,6CAAW;;;
|
|
1
|
+
{"version":3,"file":"account-program.d.mts","names":["_$___configuration_ts0.Sourced","_$___configuration_ts0.ConfigurationFile","_$___configuration_ts0.ConfigurationSource"],"sources":["../../src/commands/account-program.ts"],"mappings":";;;;;;;iBAuCgB,qBACd,UAAS,kBAAkB;;;MAyFrB;MACA,6CAAW;;;2BA1FRA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmGN,oBAAoB,WACvB,kBAAkB;;;;;iBAOJ,sBACd,KAAK,mBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCc,6BACd,SAAS,kBAAkB;EAmBzB;EACA;EACA;;cArBOE;;;;;EAoCP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../package-
|
|
1
|
+
import { t as version } from "../package-91KEch3P.mjs";
|
|
2
2
|
import { OperationRegistry } from "../operations.mjs";
|
|
3
3
|
import { ResourceOwner } from "../resources.mjs";
|
|
4
4
|
import { openDatabaseRuntime } from "../database-runtime.mjs";
|
|
@@ -14,7 +14,7 @@ async function main() {
|
|
|
14
14
|
const invocation = createAccountProgram();
|
|
15
15
|
let options;
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
const raw = await run(invocation.program, {
|
|
18
18
|
contexts: invocation.contexts,
|
|
19
19
|
contextOptions: { load: (parsed) => invocation.load(parsed) },
|
|
20
20
|
help: "option",
|
|
@@ -25,7 +25,8 @@ async function main() {
|
|
|
25
25
|
option: true,
|
|
26
26
|
value: version
|
|
27
27
|
}
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
|
+
options = resolveAccountOptions(raw);
|
|
29
30
|
} catch (error) {
|
|
30
31
|
printError([text(error instanceof Error ? error.message : "Could not resolve configuration.")]);
|
|
31
32
|
process.exitCode = 1;
|
|
@@ -67,7 +68,8 @@ async function main() {
|
|
|
67
68
|
}, null, 2));
|
|
68
69
|
} catch (error) {
|
|
69
70
|
if (!(interrupted && (error === operations.signal.reason || error instanceof MigrationPreparationError && error.code === "aborted" && !error.cleanupFailed))) {
|
|
70
|
-
|
|
71
|
+
const message = error instanceof MigrationPreparationError || error instanceof PgliteStoreError ? `${error.code}: ${error.message}` : "Could not create the account.";
|
|
72
|
+
printError([text(message)]);
|
|
71
73
|
failed = true;
|
|
72
74
|
}
|
|
73
75
|
} finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.mjs","names":["metadata.version"],"sources":["../../src/commands/account.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport process from \"node:process\";\n\nimport { MigrationPreparationError, PgliteStoreError } from \"@drfed/models\";\nimport { text } from \"@optique/core/message\";\nimport { printError, run } from \"@optique/run\";\n\nimport metadata from \"../../package.json\" with { type: \"json\" };\nimport { openDatabaseRuntime } from \"../database-runtime.ts\";\nimport { OperationRegistry } from \"../operations.ts\";\nimport { ResourceOwner } from \"../resources.ts\";\nimport { createAccount } from \"./account-create.ts\";\nimport {\n createAccountProgram,\n describeAccountConfiguration,\n resolveAccountOptions,\n} from \"./account-program.ts\";\n\n/** Run the installed account creation command without server resources. */\nexport async function main(): Promise<void> {\n const invocation = createAccountProgram();\n let options: ReturnType<typeof resolveAccountOptions>;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: { load: (parsed) => invocation.load(parsed) },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: { option: true, value: metadata.version },\n });\n options = resolveAccountOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeAccountConfiguration(options), null, 2));\n return;\n }\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n let interrupted = false;\n let failed = false;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n const abort = () => {\n if (interrupted) process.exit(1);\n interrupted = true;\n failed = true;\n operations.abort();\n deadline = setTimeout(() => process.exit(1), 10_000);\n deadline.unref();\n };\n process.on(\"SIGINT\", abort);\n process.on(\"SIGTERM\", abort);\n try {\n const result = await operations.run(async (signal) => {\n const database = await openDatabaseRuntime(\n options.database,\n owner,\n options.database.migrate ? \"apply\" : \"inspect\",\n signal,\n );\n if (database.state.status !== \"ready\") {\n throw new MigrationPreparationError(\n \"incompatible-history\",\n database.state,\n );\n }\n signal.throwIfAborted();\n return await createAccount(database.db, {\n email: options.email,\n name: options.name,\n });\n });\n console.log(\n JSON.stringify(\n { command: \"account\", action: \"create\", ...result },\n null,\n 2,\n ),\n );\n } catch (error) {\n const cleanAbort =\n interrupted &&\n (error === operations.signal.reason ||\n (error instanceof MigrationPreparationError &&\n error.code === \"aborted\" &&\n !error.cleanupFailed));\n if (!cleanAbort) {\n const message =\n error instanceof MigrationPreparationError ||\n error instanceof PgliteStoreError\n ? `${error.code}: ${error.message}`\n : \"Could not create the account.\";\n printError([text(message)]);\n failed = true;\n }\n } finally {\n operations.abort();\n await operations.drain();\n try {\n await owner.close();\n } catch {\n printError([text(\"Could not cleanly close the database.\")]);\n failed = true;\n }\n if (deadline !== undefined) clearTimeout(deadline);\n process.off(\"SIGINT\", abort);\n process.off(\"SIGTERM\", abort);\n }\n process.exitCode = failed ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,eAAsB,OAAsB;CAC1C,MAAM,aAAa,qBAAqB;CACxC,IAAI;CACJ,IAAI;
|
|
1
|
+
{"version":3,"file":"account.mjs","names":["metadata.version"],"sources":["../../src/commands/account.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport process from \"node:process\";\n\nimport { MigrationPreparationError, PgliteStoreError } from \"@drfed/models\";\nimport { text } from \"@optique/core/message\";\nimport { printError, run } from \"@optique/run\";\n\nimport metadata from \"../../package.json\" with { type: \"json\" };\nimport { openDatabaseRuntime } from \"../database-runtime.ts\";\nimport { OperationRegistry } from \"../operations.ts\";\nimport { ResourceOwner } from \"../resources.ts\";\nimport { createAccount } from \"./account-create.ts\";\nimport {\n createAccountProgram,\n describeAccountConfiguration,\n resolveAccountOptions,\n} from \"./account-program.ts\";\n\n/** Run the installed account creation command without server resources. */\nexport async function main(): Promise<void> {\n const invocation = createAccountProgram();\n let options: ReturnType<typeof resolveAccountOptions>;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: { load: (parsed) => invocation.load(parsed) },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: { option: true, value: metadata.version },\n });\n options = resolveAccountOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeAccountConfiguration(options), null, 2));\n return;\n }\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n let interrupted = false;\n let failed = false;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n const abort = () => {\n if (interrupted) process.exit(1);\n interrupted = true;\n failed = true;\n operations.abort();\n deadline = setTimeout(() => process.exit(1), 10_000);\n deadline.unref();\n };\n process.on(\"SIGINT\", abort);\n process.on(\"SIGTERM\", abort);\n try {\n const result = await operations.run(async (signal) => {\n const database = await openDatabaseRuntime(\n options.database,\n owner,\n options.database.migrate ? \"apply\" : \"inspect\",\n signal,\n );\n if (database.state.status !== \"ready\") {\n throw new MigrationPreparationError(\n \"incompatible-history\",\n database.state,\n );\n }\n signal.throwIfAborted();\n return await createAccount(database.db, {\n email: options.email,\n name: options.name,\n });\n });\n console.log(\n JSON.stringify(\n { command: \"account\", action: \"create\", ...result },\n null,\n 2,\n ),\n );\n } catch (error) {\n const cleanAbort =\n interrupted &&\n (error === operations.signal.reason ||\n (error instanceof MigrationPreparationError &&\n error.code === \"aborted\" &&\n !error.cleanupFailed));\n if (!cleanAbort) {\n const message =\n error instanceof MigrationPreparationError ||\n error instanceof PgliteStoreError\n ? `${error.code}: ${error.message}`\n : \"Could not create the account.\";\n printError([text(message)]);\n failed = true;\n }\n } finally {\n operations.abort();\n await operations.drain();\n try {\n await owner.close();\n } catch {\n printError([text(\"Could not cleanly close the database.\")]);\n failed = true;\n }\n if (deadline !== undefined) clearTimeout(deadline);\n process.off(\"SIGINT\", abort);\n process.off(\"SIGTERM\", abort);\n }\n process.exitCode = failed ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,eAAsB,OAAsB;CAC1C,MAAM,aAAa,qBAAqB;CACxC,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,MAAM,IAAI,WAAW,SAAS;GACxC,UAAU,WAAW;GACrB,gBAAgB,EAAE,OAAO,WAAW,WAAW,KAAK,MAAM,EAAE;GAC5D,MAAM;GACN,YAAY;GACZ,aAAa;GACb,aAAa;GACb,SAAS;IAAE,QAAQ;IAAM,OAAOA;GAAiB;EACnD,CAAC;EACD,UAAU,sBAAsB,GAAG;CACrC,SAAS,OAAO;EACd,WAAW,CACT,KACE,iBAAiB,QACb,MAAM,UACN,kCACN,CACF,CAAC;EACD,QAAQ,WAAW;EACnB;CACF;CACA,IAAI,QAAQ,aAAa;EACvB,QAAQ,IAAI,KAAK,UAAU,6BAA6B,OAAO,GAAG,MAAM,CAAC,CAAC;EAC1E;CACF;CACA,MAAM,QAAQ,IAAI,cAAc;CAChC,MAAM,aAAa,IAAI,kBAAkB;CACzC,IAAI,cAAc;CAClB,IAAI,SAAS;CACb,IAAI;CACJ,MAAM,cAAc;EAClB,IAAI,aAAa,QAAQ,KAAK,CAAC;EAC/B,cAAc;EACd,SAAS;EACT,WAAW,MAAM;EACjB,WAAW,iBAAiB,QAAQ,KAAK,CAAC,GAAG,GAAM;EACnD,SAAS,MAAM;CACjB;CACA,QAAQ,GAAG,UAAU,KAAK;CAC1B,QAAQ,GAAG,WAAW,KAAK;CAC3B,IAAI;EACF,MAAM,SAAS,MAAM,WAAW,IAAI,OAAO,WAAW;GACpD,MAAM,WAAW,MAAM,oBACrB,QAAQ,UACR,OACA,QAAQ,SAAS,UAAU,UAAU,WACrC,MACF;GACA,IAAI,SAAS,MAAM,WAAW,SAC5B,MAAM,IAAI,0BACR,wBACA,SAAS,KACX;GAEF,OAAO,eAAe;GACtB,OAAO,MAAM,cAAc,SAAS,IAAI;IACtC,OAAO,QAAQ;IACf,MAAM,QAAQ;GAChB,CAAC;EACH,CAAC;EACD,QAAQ,IACN,KAAK,UACH;GAAE,SAAS;GAAW,QAAQ;GAAU,GAAG;EAAO,GAClD,MACA,CACF,CACF;CACF,SAAS,OAAO;EAOd,IAAI,EALF,gBACC,UAAU,WAAW,OAAO,UAC1B,iBAAiB,6BAChB,MAAM,SAAS,aACf,CAAC,MAAM,iBACI;GACf,MAAM,UACJ,iBAAiB,6BACjB,iBAAiB,mBACb,GAAG,MAAM,KAAK,IAAI,MAAM,YACxB;GACN,WAAW,CAAC,KAAK,OAAO,CAAC,CAAC;GAC1B,SAAS;EACX;CACF,UAAU;EACR,WAAW,MAAM;EACjB,MAAM,WAAW,MAAM;EACvB,IAAI;GACF,MAAM,MAAM,MAAM;EACpB,QAAQ;GACN,WAAW,CAAC,KAAK,uCAAuC,CAAC,CAAC;GAC1D,SAAS;EACX;EACA,IAAI,aAAa,KAAA,GAAW,aAAa,QAAQ;EACjD,QAAQ,IAAI,UAAU,KAAK;EAC3B,QAAQ,IAAI,WAAW,KAAK;CAC9B;CACA,QAAQ,WAAW,SAAS,IAAI;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-program.d.mts","names":[],"sources":["../../src/commands/migrate-program.ts"],"mappings":";;;;;;;iBAqCgB,uBACd,UAAS,kBAAkB;;;MAqErB;MACA,6CAAW;;;
|
|
1
|
+
{"version":3,"file":"migrate-program.d.mts","names":["_$___configuration_ts0.Sourced","_$___configuration_ts0.ConfigurationFile","_$___configuration_ts0.ConfigurationSource"],"sources":["../../src/commands/migrate-program.ts"],"mappings":";;;;;;;iBAqCgB,uBACd,UAAS,kBAAkB;;;MAqErB;MACA,6CAAW;;;2BAtERA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+EN,sBAAsB,WACzB,kBAAkB;;;;;iBAOJ,wBACd,KAAK,qBACL;EAcE;;;;;;;;;;;EACA;EACA;EACA;;;;EACA;;;;;;;;;;;iBAYY,+BACd,SAAS,kBAAkB;EAkBhB;;;;cAlBFE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../package-
|
|
1
|
+
import { t as version } from "../package-91KEch3P.mjs";
|
|
2
2
|
import { OperationRegistry } from "../operations.mjs";
|
|
3
3
|
import { ResourceOwner } from "../resources.mjs";
|
|
4
4
|
import { openDatabaseRuntime } from "../database-runtime.mjs";
|
|
@@ -13,7 +13,7 @@ async function main() {
|
|
|
13
13
|
const invocation = createMigrationProgram();
|
|
14
14
|
let options;
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
const raw = await run(invocation.program, {
|
|
17
17
|
contexts: invocation.contexts,
|
|
18
18
|
contextOptions: { load: (parsed) => invocation.load(parsed) },
|
|
19
19
|
help: "option",
|
|
@@ -24,7 +24,8 @@ async function main() {
|
|
|
24
24
|
option: true,
|
|
25
25
|
value: version
|
|
26
26
|
}
|
|
27
|
-
})
|
|
27
|
+
});
|
|
28
|
+
options = resolveMigrationOptions(raw);
|
|
28
29
|
} catch (error) {
|
|
29
30
|
printError([text(error instanceof Error ? error.message : "Could not resolve configuration.")]);
|
|
30
31
|
process.exitCode = 1;
|
|
@@ -61,7 +62,8 @@ async function main() {
|
|
|
61
62
|
if (database.state.status !== "ready") failed = true;
|
|
62
63
|
} catch (error) {
|
|
63
64
|
if (!(interrupted && (error === operations.signal.reason || error instanceof MigrationPreparationError && error.code === "aborted" && !error.cleanupFailed))) {
|
|
64
|
-
|
|
65
|
+
const message = error instanceof MigrationPreparationError || error instanceof PgliteStoreError ? `${error.code}: ${error.message}` : "Could not prepare or inspect the database.";
|
|
66
|
+
printError([text(message)]);
|
|
65
67
|
failed = true;
|
|
66
68
|
}
|
|
67
69
|
} finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.mjs","names":["metadata.version"],"sources":["../../src/commands/migrate.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport process from \"node:process\";\n\nimport { MigrationPreparationError, PgliteStoreError } from \"@drfed/models\";\nimport { text } from \"@optique/core/message\";\nimport { printError, run } from \"@optique/run\";\n\nimport metadata from \"../../package.json\" with { type: \"json\" };\nimport { openDatabaseRuntime } from \"../database-runtime.ts\";\nimport { OperationRegistry } from \"../operations.ts\";\nimport { ResourceOwner } from \"../resources.ts\";\nimport {\n createMigrationProgram,\n describeMigrationConfiguration,\n resolveMigrationOptions,\n} from \"./migrate-program.ts\";\n\n/** Run the installed database preparation command without server resources. */\nexport async function main(): Promise<void> {\n const invocation = createMigrationProgram();\n let options: ReturnType<typeof resolveMigrationOptions>;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: { load: (parsed) => invocation.load(parsed) },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: { option: true, value: metadata.version },\n });\n options = resolveMigrationOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (options.printConfig) {\n console.log(\n JSON.stringify(describeMigrationConfiguration(options), null, 2),\n );\n return;\n }\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n let interrupted = false;\n let failed = false;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n const abort = () => {\n if (interrupted) process.exit(1);\n interrupted = true;\n failed = true;\n operations.abort();\n deadline = setTimeout(() => process.exit(1), 10_000);\n deadline.unref();\n };\n process.on(\"SIGINT\", abort);\n process.on(\"SIGTERM\", abort);\n try {\n const database = await operations.run((signal) =>\n openDatabaseRuntime(\n { ...options.database, migrate: !options.check },\n owner,\n options.check ? \"inspect\" : \"apply\",\n signal,\n ),\n );\n console.log(\n JSON.stringify({ command: \"migrate\", ...database.state }, null, 2),\n );\n if (database.state.status !== \"ready\") failed = true;\n } catch (error) {\n const cleanAbort =\n interrupted &&\n (error === operations.signal.reason ||\n (error instanceof MigrationPreparationError &&\n error.code === \"aborted\" &&\n !error.cleanupFailed));\n if (!cleanAbort) {\n const message =\n error instanceof MigrationPreparationError ||\n error instanceof PgliteStoreError\n ? `${error.code}: ${error.message}`\n : \"Could not prepare or inspect the database.\";\n printError([text(message)]);\n failed = true;\n }\n } finally {\n operations.abort();\n await operations.drain();\n try {\n await owner.close();\n } catch {\n printError([text(\"Could not cleanly close the database.\")]);\n failed = true;\n }\n if (deadline !== undefined) clearTimeout(deadline);\n process.off(\"SIGINT\", abort);\n process.off(\"SIGTERM\", abort);\n }\n process.exitCode = failed ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;;;AAiCA,eAAsB,OAAsB;CAC1C,MAAM,aAAa,uBAAuB;CAC1C,IAAI;CACJ,IAAI;
|
|
1
|
+
{"version":3,"file":"migrate.mjs","names":["metadata.version"],"sources":["../../src/commands/migrate.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport process from \"node:process\";\n\nimport { MigrationPreparationError, PgliteStoreError } from \"@drfed/models\";\nimport { text } from \"@optique/core/message\";\nimport { printError, run } from \"@optique/run\";\n\nimport metadata from \"../../package.json\" with { type: \"json\" };\nimport { openDatabaseRuntime } from \"../database-runtime.ts\";\nimport { OperationRegistry } from \"../operations.ts\";\nimport { ResourceOwner } from \"../resources.ts\";\nimport {\n createMigrationProgram,\n describeMigrationConfiguration,\n resolveMigrationOptions,\n} from \"./migrate-program.ts\";\n\n/** Run the installed database preparation command without server resources. */\nexport async function main(): Promise<void> {\n const invocation = createMigrationProgram();\n let options: ReturnType<typeof resolveMigrationOptions>;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: { load: (parsed) => invocation.load(parsed) },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: { option: true, value: metadata.version },\n });\n options = resolveMigrationOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (options.printConfig) {\n console.log(\n JSON.stringify(describeMigrationConfiguration(options), null, 2),\n );\n return;\n }\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n let interrupted = false;\n let failed = false;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n const abort = () => {\n if (interrupted) process.exit(1);\n interrupted = true;\n failed = true;\n operations.abort();\n deadline = setTimeout(() => process.exit(1), 10_000);\n deadline.unref();\n };\n process.on(\"SIGINT\", abort);\n process.on(\"SIGTERM\", abort);\n try {\n const database = await operations.run((signal) =>\n openDatabaseRuntime(\n { ...options.database, migrate: !options.check },\n owner,\n options.check ? \"inspect\" : \"apply\",\n signal,\n ),\n );\n console.log(\n JSON.stringify({ command: \"migrate\", ...database.state }, null, 2),\n );\n if (database.state.status !== \"ready\") failed = true;\n } catch (error) {\n const cleanAbort =\n interrupted &&\n (error === operations.signal.reason ||\n (error instanceof MigrationPreparationError &&\n error.code === \"aborted\" &&\n !error.cleanupFailed));\n if (!cleanAbort) {\n const message =\n error instanceof MigrationPreparationError ||\n error instanceof PgliteStoreError\n ? `${error.code}: ${error.message}`\n : \"Could not prepare or inspect the database.\";\n printError([text(message)]);\n failed = true;\n }\n } finally {\n operations.abort();\n await operations.drain();\n try {\n await owner.close();\n } catch {\n printError([text(\"Could not cleanly close the database.\")]);\n failed = true;\n }\n if (deadline !== undefined) clearTimeout(deadline);\n process.off(\"SIGINT\", abort);\n process.off(\"SIGTERM\", abort);\n }\n process.exitCode = failed ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;;;AAiCA,eAAsB,OAAsB;CAC1C,MAAM,aAAa,uBAAuB;CAC1C,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,MAAM,IAAI,WAAW,SAAS;GACxC,UAAU,WAAW;GACrB,gBAAgB,EAAE,OAAO,WAAW,WAAW,KAAK,MAAM,EAAE;GAC5D,MAAM;GACN,YAAY;GACZ,aAAa;GACb,aAAa;GACb,SAAS;IAAE,QAAQ;IAAM,OAAOA;GAAiB;EACnD,CAAC;EACD,UAAU,wBAAwB,GAAG;CACvC,SAAS,OAAO;EACd,WAAW,CACT,KACE,iBAAiB,QACb,MAAM,UACN,kCACN,CACF,CAAC;EACD,QAAQ,WAAW;EACnB;CACF;CACA,IAAI,QAAQ,aAAa;EACvB,QAAQ,IACN,KAAK,UAAU,+BAA+B,OAAO,GAAG,MAAM,CAAC,CACjE;EACA;CACF;CACA,MAAM,QAAQ,IAAI,cAAc;CAChC,MAAM,aAAa,IAAI,kBAAkB;CACzC,IAAI,cAAc;CAClB,IAAI,SAAS;CACb,IAAI;CACJ,MAAM,cAAc;EAClB,IA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
+
{"version":3,"file":"web-program.d.mts","names":["_$___configuration_ts0.Sourced","_$___configuration_ts0.ConfigurationFile","_$___configuration_ts0.ConfigurationSource"],"sources":["../../src/commands/web-program.ts"],"mappings":";;;;;;iBAuCgB,iBACd,UAAS,kBAAkB;;;MAmErB;MACA,6CAAW;;;2BApERA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6EN,gBAAgB,WACnB,kBAAkB;;;;iBAMJ,kBAAkB,KAAK,eAAe;;;;;;;;;;;;;;;;;;KAgD1C,aAAa,kBAAkB;;;;iBAK3B,yBAAyB,SAAS;EAgB9C;EACA;;eAjB8CE;;;;;EAuB9C"}
|
package/dist/commands/web.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../package-
|
|
1
|
+
import { t as version } from "../package-91KEch3P.mjs";
|
|
2
2
|
import { OperationRegistry } from "../operations.mjs";
|
|
3
3
|
import { ResourceOwner } from "../resources.mjs";
|
|
4
4
|
import { createWebProgram, describeWebConfiguration, resolveWebOptions } from "./web-program.mjs";
|
|
@@ -132,7 +132,7 @@ async function main() {
|
|
|
132
132
|
const invocation = createWebProgram();
|
|
133
133
|
let options;
|
|
134
134
|
try {
|
|
135
|
-
|
|
135
|
+
const raw = await run(invocation.program, {
|
|
136
136
|
contexts: invocation.contexts,
|
|
137
137
|
contextOptions: { load: invocation.load },
|
|
138
138
|
help: "option",
|
|
@@ -143,7 +143,8 @@ async function main() {
|
|
|
143
143
|
option: true,
|
|
144
144
|
value: version
|
|
145
145
|
}
|
|
146
|
-
})
|
|
146
|
+
});
|
|
147
|
+
options = resolveWebOptions(raw);
|
|
147
148
|
} catch (error) {
|
|
148
149
|
printError([text(error instanceof Error ? error.message : "Could not resolve web configuration.")]);
|
|
149
150
|
process.exitCode = 1;
|
|
@@ -155,7 +156,7 @@ async function main() {
|
|
|
155
156
|
}
|
|
156
157
|
let startupStage = "logging";
|
|
157
158
|
try {
|
|
158
|
-
|
|
159
|
+
const config = await createLoggingConfig(options.logging, {}, {
|
|
159
160
|
contextLocalStorage: new AsyncLocalStorage(),
|
|
160
161
|
sinks: { stderr: getConsoleSink({ levelMap: {
|
|
161
162
|
trace: "error",
|
|
@@ -170,7 +171,8 @@ async function main() {
|
|
|
170
171
|
lowestLevel: "warning",
|
|
171
172
|
sinks: ["stderr"]
|
|
172
173
|
}]
|
|
173
|
-
})
|
|
174
|
+
});
|
|
175
|
+
await configure(config);
|
|
174
176
|
startupStage = "web frontend";
|
|
175
177
|
await startWeb(options);
|
|
176
178
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.mjs","names":["metadata.version"],"sources":["../../src/commands/web.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport process from \"node:process\";\n\nimport { type WebRuntime, createWebRuntime } from \"@drfed/web\";\nimport {\n configure,\n dispose,\n getConsoleSink,\n getLogger,\n} from \"@logtape/logtape\";\nimport { text } from \"@optique/core/message\";\nimport { createLoggingConfig } from \"@optique/logtape\";\nimport { printError, run } from \"@optique/run\";\nimport { serve } from \"srvx\";\n\nimport metadata from \"../../package.json\" with { type: \"json\" };\nimport { OperationRegistry } from \"../operations.ts\";\nimport { ResourceOwner } from \"../resources.ts\";\nimport {\n type WebOptions,\n createWebProgram,\n describeWebConfiguration,\n resolveWebOptions,\n} from \"./web-program.ts\";\n\nfunction startupFailure(stage: string, error: unknown): string {\n const knownCodes = [\n \"EADDRINUSE\",\n \"EACCES\",\n \"ENOENT\",\n \"ENOTDIR\",\n \"ERR_MODULE_NOT_FOUND\",\n ];\n const code =\n error != null && typeof error === \"object\" && \"code\" in error\n ? error.code\n : undefined;\n return typeof code === \"string\" && knownCodes.includes(code)\n ? `${stage} (${code})`\n : stage;\n}\n\nasync function startWeb(options: WebOptions): Promise<void> {\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n owner.register(null, () => dispose(), { owned: true });\n let server: ReturnType<typeof serve> | undefined;\n let closing: Promise<void> | undefined;\n let signalled = false;\n let startupStage = \"web runtime\";\n\n async function cleanup(): Promise<void> {\n operations.abort();\n const errors: unknown[] = [];\n let forced: Promise<void> | undefined;\n const timer = setTimeout(() => {\n if (server === undefined) return;\n const active = server;\n forced = (async () => {\n try {\n await active.close(true);\n } catch (error) {\n errors.push(error);\n }\n })();\n }, 5_000);\n try {\n const settled = await Promise.allSettled([\n server?.close(),\n operations.drain(),\n ]);\n for (const result of settled) {\n if (result.status === \"rejected\") errors.push(result.reason);\n }\n if (forced !== undefined) await forced;\n } finally {\n clearTimeout(timer);\n try {\n await owner.close();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Web cleanup failed.\");\n }\n }\n function stop(): Promise<void> {\n // Assign before cancellation callbacks can request cleanup again.\n // oxlint-disable-next-line promise/prefer-await-to-then\n return (closing ??= Promise.resolve().then(cleanup));\n }\n function shutdown(): void {\n if (signalled) process.exit(1);\n signalled = true;\n const deadline = setTimeout(() => process.exit(1), 10_000);\n // oxlint-disable promise/prefer-await-to-then\n void stop().then(\n () => {\n clearTimeout(deadline);\n process.exit(0);\n },\n () => process.exit(1),\n );\n // oxlint-enable promise/prefer-await-to-then\n }\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n try {\n if (options.insecureBackend) {\n getLogger([\"drfed\", \"web\"]).warning(\n \"HTTP backend explicitly allowed on a trusted internal network; session tokens are sent without encryption.\",\n );\n }\n const web: WebRuntime = await operations.run(async (signal) => {\n const runtime = owner.register(\n await createWebRuntime({\n publicOrigin: options.publicOrigin,\n graphqlFetch(request) {\n return operations.track((operationSignal) =>\n fetch(new URL(\"/graphql\", options.backendUrl), {\n method: request.method,\n headers: request.headers,\n body: request.body,\n duplex: \"half\",\n redirect: \"error\",\n signal: AbortSignal.any([request.signal, operationSignal]),\n } as RequestInit & { duplex: \"half\" }),\n );\n },\n }),\n (resource) => resource.close(),\n { owned: true },\n );\n signal.throwIfAborted();\n return runtime;\n });\n startupStage = \"HTTP listener\";\n const listener = owner.register(\n serve({\n async fetch(request) {\n if (operations.signal.aborted) {\n return new Response(\"Web server is stopping.\", { status: 503 });\n }\n try {\n return await operations.run(() => web.fetch(request));\n } catch (error) {\n if (operations.signal.aborted) {\n return new Response(\"Web server is stopping.\", { status: 503 });\n }\n throw error;\n }\n },\n hostname: options.address.host,\n port: options.address.port,\n manual: true,\n gracefulShutdown: false,\n }),\n (resource) => resource.close(true),\n { owned: true },\n );\n server = listener;\n await operations.run(async () => {\n await listener.serve();\n });\n getLogger([\"drfed\", \"web\"]).info(\"Web frontend is available at {origin}.\", {\n origin: options.publicOrigin.origin,\n });\n } catch (error) {\n getLogger([\"drfed\", \"web\"]).error(\n \"Web frontend startup failed during {failure}.\",\n {\n failure: startupFailure(startupStage, error),\n },\n );\n process.off(\"SIGINT\", shutdown);\n process.off(\"SIGTERM\", shutdown);\n const deadline = Promise.withResolvers<never>();\n const timer = setTimeout(\n () => deadline.reject(new Error(\"Web startup cleanup timed out.\")),\n 10_000,\n );\n try {\n await Promise.race([stop(), deadline.promise]);\n } finally {\n clearTimeout(timer);\n }\n throw error;\n }\n}\n\n/** Run the installed standalone web command with resource-free preflight. */\nexport async function main(): Promise<void> {\n const invocation = createWebProgram();\n let options: WebOptions;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: { load: invocation.load },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: { option: true, value: metadata.version },\n });\n options = resolveWebOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve web configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeWebConfiguration(options), null, 2));\n return;\n }\n let startupStage = \"logging\";\n try {\n const config = await createLoggingConfig(\n options.logging,\n {},\n {\n contextLocalStorage: new AsyncLocalStorage(),\n sinks: {\n stderr: getConsoleSink({\n levelMap: {\n trace: \"error\",\n debug: \"error\",\n info: \"error\",\n warning: \"error\",\n error: \"error\",\n fatal: \"error\",\n },\n }),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n lowestLevel: \"warning\",\n sinks: [\"stderr\"],\n },\n ],\n },\n );\n await configure(config);\n startupStage = \"web frontend\";\n await startWeb(options);\n } catch (error) {\n printError([\n text(\n `Could not start ${startupFailure(startupStage, error)}; check the listen address, logging output and installed files.`,\n ),\n ]);\n process.exitCode = 1;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAS,eAAe,OAAe,OAAwB;CAC7D,MAAM,aAAa;EACjB;EACA;EACA;EACA;EACA;CACF;CACA,MAAM,OACJ,SAAS,QAAQ,OAAO,UAAU,YAAY,UAAU,QACpD,MAAM,OACN,KAAA;CACN,OAAO,OAAO,SAAS,YAAY,WAAW,SAAS,IAAI,IACvD,GAAG,MAAM,IAAI,KAAK,KAClB;AACN;AAEA,eAAe,SAAS,SAAoC;CAC1D,MAAM,QAAQ,IAAI,cAAc;CAChC,MAAM,aAAa,IAAI,kBAAkB;CACzC,MAAM,SAAS,YAAY,QAAQ,GAAG,EAAE,OAAO,KAAK,CA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AAO;EACd,WAAW,CACT,KACE,mBAAmB,eAAe,cAAc,KAAK,EAAE,gEACzD,CACF,CAAC;EACD,QAAQ,WAAW;CACrB;AACF"}
|
|
1
|
+
{"version":3,"file":"web.mjs","names":["metadata.version"],"sources":["../../src/commands/web.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport process from \"node:process\";\n\nimport { type WebRuntime, createWebRuntime } from \"@drfed/web\";\nimport {\n configure,\n dispose,\n getConsoleSink,\n getLogger,\n} from \"@logtape/logtape\";\nimport { text } from \"@optique/core/message\";\nimport { createLoggingConfig } from \"@optique/logtape\";\nimport { printError, run } from \"@optique/run\";\nimport { serve } from \"srvx\";\n\nimport metadata from \"../../package.json\" with { type: \"json\" };\nimport { OperationRegistry } from \"../operations.ts\";\nimport { ResourceOwner } from \"../resources.ts\";\nimport {\n type WebOptions,\n createWebProgram,\n describeWebConfiguration,\n resolveWebOptions,\n} from \"./web-program.ts\";\n\nfunction startupFailure(stage: string, error: unknown): string {\n const knownCodes = [\n \"EADDRINUSE\",\n \"EACCES\",\n \"ENOENT\",\n \"ENOTDIR\",\n \"ERR_MODULE_NOT_FOUND\",\n ];\n const code =\n error != null && typeof error === \"object\" && \"code\" in error\n ? error.code\n : undefined;\n return typeof code === \"string\" && knownCodes.includes(code)\n ? `${stage} (${code})`\n : stage;\n}\n\nasync function startWeb(options: WebOptions): Promise<void> {\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n owner.register(null, () => dispose(), { owned: true });\n let server: ReturnType<typeof serve> | undefined;\n let closing: Promise<void> | undefined;\n let signalled = false;\n let startupStage = \"web runtime\";\n\n async function cleanup(): Promise<void> {\n operations.abort();\n const errors: unknown[] = [];\n let forced: Promise<void> | undefined;\n const timer = setTimeout(() => {\n if (server === undefined) return;\n const active = server;\n forced = (async () => {\n try {\n await active.close(true);\n } catch (error) {\n errors.push(error);\n }\n })();\n }, 5_000);\n try {\n const settled = await Promise.allSettled([\n server?.close(),\n operations.drain(),\n ]);\n for (const result of settled) {\n if (result.status === \"rejected\") errors.push(result.reason);\n }\n if (forced !== undefined) await forced;\n } finally {\n clearTimeout(timer);\n try {\n await owner.close();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Web cleanup failed.\");\n }\n }\n function stop(): Promise<void> {\n // Assign before cancellation callbacks can request cleanup again.\n // oxlint-disable-next-line promise/prefer-await-to-then\n return (closing ??= Promise.resolve().then(cleanup));\n }\n function shutdown(): void {\n if (signalled) process.exit(1);\n signalled = true;\n const deadline = setTimeout(() => process.exit(1), 10_000);\n // oxlint-disable promise/prefer-await-to-then\n void stop().then(\n () => {\n clearTimeout(deadline);\n process.exit(0);\n },\n () => process.exit(1),\n );\n // oxlint-enable promise/prefer-await-to-then\n }\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n try {\n if (options.insecureBackend) {\n getLogger([\"drfed\", \"web\"]).warning(\n \"HTTP backend explicitly allowed on a trusted internal network; session tokens are sent without encryption.\",\n );\n }\n const web: WebRuntime = await operations.run(async (signal) => {\n const runtime = owner.register(\n await createWebRuntime({\n publicOrigin: options.publicOrigin,\n graphqlFetch(request) {\n return operations.track((operationSignal) =>\n fetch(new URL(\"/graphql\", options.backendUrl), {\n method: request.method,\n headers: request.headers,\n body: request.body,\n duplex: \"half\",\n redirect: \"error\",\n signal: AbortSignal.any([request.signal, operationSignal]),\n } as RequestInit & { duplex: \"half\" }),\n );\n },\n }),\n (resource) => resource.close(),\n { owned: true },\n );\n signal.throwIfAborted();\n return runtime;\n });\n startupStage = \"HTTP listener\";\n const listener = owner.register(\n serve({\n async fetch(request) {\n if (operations.signal.aborted) {\n return new Response(\"Web server is stopping.\", { status: 503 });\n }\n try {\n return await operations.run(() => web.fetch(request));\n } catch (error) {\n if (operations.signal.aborted) {\n return new Response(\"Web server is stopping.\", { status: 503 });\n }\n throw error;\n }\n },\n hostname: options.address.host,\n port: options.address.port,\n manual: true,\n gracefulShutdown: false,\n }),\n (resource) => resource.close(true),\n { owned: true },\n );\n server = listener;\n await operations.run(async () => {\n await listener.serve();\n });\n getLogger([\"drfed\", \"web\"]).info(\"Web frontend is available at {origin}.\", {\n origin: options.publicOrigin.origin,\n });\n } catch (error) {\n getLogger([\"drfed\", \"web\"]).error(\n \"Web frontend startup failed during {failure}.\",\n {\n failure: startupFailure(startupStage, error),\n },\n );\n process.off(\"SIGINT\", shutdown);\n process.off(\"SIGTERM\", shutdown);\n const deadline = Promise.withResolvers<never>();\n const timer = setTimeout(\n () => deadline.reject(new Error(\"Web startup cleanup timed out.\")),\n 10_000,\n );\n try {\n await Promise.race([stop(), deadline.promise]);\n } finally {\n clearTimeout(timer);\n }\n throw error;\n }\n}\n\n/** Run the installed standalone web command with resource-free preflight. */\nexport async function main(): Promise<void> {\n const invocation = createWebProgram();\n let options: WebOptions;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: { load: invocation.load },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: { option: true, value: metadata.version },\n });\n options = resolveWebOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve web configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeWebConfiguration(options), null, 2));\n return;\n }\n let startupStage = \"logging\";\n try {\n const config = await createLoggingConfig(\n options.logging,\n {},\n {\n contextLocalStorage: new AsyncLocalStorage(),\n sinks: {\n stderr: getConsoleSink({\n levelMap: {\n trace: \"error\",\n debug: \"error\",\n info: \"error\",\n warning: \"error\",\n error: \"error\",\n fatal: \"error\",\n },\n }),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n lowestLevel: \"warning\",\n sinks: [\"stderr\"],\n },\n ],\n },\n );\n await configure(config);\n startupStage = \"web frontend\";\n await startWeb(options);\n } catch (error) {\n printError([\n text(\n `Could not start ${startupFailure(startupStage, error)}; check the listen address, logging output and installed files.`,\n ),\n ]);\n process.exitCode = 1;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAS,eAAe,OAAe,OAAwB;CAC7D,MAAM,aAAa;EACjB;EACA;EACA;EACA;EACA;CACF;CACA,MAAM,OACJ,SAAS,QAAQ,OAAO,UAAU,YAAY,UAAU,QACpD,MAAM,OACN,KAAA;CACN,OAAO,OAAO,SAAS,YAAY,WAAW,SAAS,IAAI,IACvD,GAAG,MAAM,IAAI,KAAK,KAClB;AACN;AAEA,eAAe,SAAS,SAAoC;CAC1D,MAAM,QAAQ,IAAI,cAAc;CAChC,MAAM,aAAa,IAAI,kBAAkB;CACzC,MAAM,SAAS,YAAY,QAAQ,GAAG,EAAE,OAAO,KAAK,CAAC;CACrD,IAAI;CACJ,IAAI;CACJ,IAAI,YAAY;CAChB,IAAI,eAAe;CAEnB,eAAe,UAAyB;EACtC,WAAW,MAAM;EACjB,MAAM,SAAoB,CAAC;EAC3B,IAAI;EACJ,MAAM,QAAQ,iBAAiB;GAC7B,IAAI,WAAW,KAAA,GAAW;GAC1B,MAAM,SAAS;GACf,UAAU,YAAY;IACpB,IAAI;KACF,MAAM,OAAO,MAAM,IAAI;IACzB,SAAS,OAAO;KACd,OAAO,KAAK,KAAK;IACnB;GACF,EAAA,CAAG;EACL,GAAG,GAAK;EACR,IAAI;GACF,MAAM,UAAU,MAAM,QAAQ,WAAW,CACvC,QA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ACF,MAAM,MAAM,MAAM,IAAI,WAAW,SAAS;GACxC,UAAU,WAAW;GACrB,gBAAgB,EAAE,MAAM,WAAW,KAAK;GACxC,MAAM;GACN,YAAY;GACZ,aAAa;GACb,aAAa;GACb,SAAS;IAAE,QAAQ;IAAM,OAAOA;GAAiB;EACnD,CAAC;EACD,UAAU,kBAAkB,GAAG;CACjC,SAAS,OAAO;EACd,WAAW,CACT,KACE,iBAAiB,QACb,MAAM,UACN,sCACN,CACF,CAAC;EACD,QAAQ,WAAW;EACnB;CACF;CACA,IAAI,QAAQ,aAAa;EACvB,QAAQ,IAAI,KAAK,UAAU,yBAAyB,OAAO,GAAG,MAAM,CAAC,CAAC;EACtE;CACF;CACA,IAAI,eAAe;CACnB,IAAI;EACF,MAAM,SAAS,MAAM,oBACnB,QAAQ,SACR,CAAC,GACD;GACE,qBAAqB,IAAI,kBAAkB;GAC3C,OAAO,EACL,QAAQ,eAAe,EACrB,UAAU;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;GACT,EACF,CAAC,EACH;GACA,SAAS,CACP;IACE,UAAU,CAAC,WAAW,MAAM;IAC5B,aAAa;IACb,OAAO,CAAC,QAAQ;GAClB,CACF;EACF,CACF;EACA,MAAM,UAAU,MAAM;EACtB,eAAe;EACf,MAAM,SAAS,OAAO;CACxB,SAAS,OAAO;EACd,WAAW,CACT,KACE,mBAAmB,eAAe,cAAc,KAAK,EAAE,gEACzD,CACF,CAAC;EACD,QAAQ,WAAW;CACrB;AACF"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-91KEch3P.mjs";
|
|
2
2
|
import { createConfigurationBindings } from "./configuration.mjs";
|
|
3
3
|
import { describeServerConfiguration } from "./diagnostics.mjs";
|
|
4
4
|
import { OperationRegistry } from "./operations.mjs";
|
|
@@ -287,7 +287,7 @@ async function main() {
|
|
|
287
287
|
const invocation = createProgram({ mode: selectInvocationMode(process.argv.slice(2)) });
|
|
288
288
|
let options;
|
|
289
289
|
try {
|
|
290
|
-
|
|
290
|
+
const raw = await run(invocation.program, {
|
|
291
291
|
contexts: invocation.contexts,
|
|
292
292
|
contextOptions: { load: (parsed) => parsed.mode[0] === "schema" ? void 0 : invocation.load(parsed) },
|
|
293
293
|
help: "option",
|
|
@@ -298,7 +298,8 @@ async function main() {
|
|
|
298
298
|
option: true,
|
|
299
299
|
value: version
|
|
300
300
|
}
|
|
301
|
-
})
|
|
301
|
+
});
|
|
302
|
+
options = resolveOptions(raw);
|
|
302
303
|
} catch (error) {
|
|
303
304
|
printError([text(error instanceof Error ? error.message : "Could not resolve configuration.")]);
|
|
304
305
|
process.exitCode = 1;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["metadata.version"],"sources":["../src/program.ts","../src/runtime-options.ts","../src/seed.ts","../src/index.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { object } from \"@optique/core/constructs\";\nimport { message } from \"@optique/core/message\";\nimport { multiple } from \"@optique/core/modifiers\";\nimport { type InferValue, parse } from \"@optique/core/parser\";\nimport { argument, option, passThrough } from \"@optique/core/primitives\";\nimport type { Program } from \"@optique/core/program\";\nimport { string } from \"@optique/core/valueparser\";\n\nimport { createConfigurationBindings } from \"./configuration.ts\";\nimport { createParser, valueOptionNames } from \"./parser.ts\";\n\n/**\n * Select operational vs schema bindings through a resource-free Optique pass.\n * The final parser still strictly validates every token. This pass consumes no\n * environment/config values and honors Optique's option terminator semantics.\n * @returns The mode whose setting bindings the complete invocation needs.\n */\nexport function selectInvocationMode(\n args: readonly string[],\n): \"server\" | \"schema\" {\n const [first, ...aliases] = Object.values(valueOptionNames).flat();\n if (first === undefined) {\n throw new Error(\"Missing CLI value-option definitions.\");\n }\n const selected = parse(\n object({\n schema: option(\"--generate-graphql-schema\"),\n optionValues: multiple(option(first, ...aliases, string())),\n extra: passThrough({ format: \"nextToken\" }),\n values: multiple(argument(string())),\n }),\n args,\n );\n return selected.success && selected.value.schema ? \"schema\" : \"server\";\n}\n\n/**\n * Create independent CLI bindings for one invocation.\n * @returns The program, its source contexts and explicit configuration loader.\n */\nexport function createProgram(\n options: Parameters<typeof createConfigurationBindings>[0] & {\n readonly mode?: \"server\" | \"schema\";\n } = {},\n) {\n const bindings = createConfigurationBindings(options);\n const parser = createParser(bindings, options.mode);\n const program: Program<\"sync\", InferValue<typeof parser>> = {\n metadata: {\n description: message`Run a DrFed server.`,\n name: \"drfed-server\",\n },\n parser,\n };\n return { program, contexts: bindings.contexts, load: bindings.load };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { MigrationPreparationError } from \"@drfed/models\";\nimport type { Transport } from \"@upyo/core\";\n\nimport {\n type DatabaseRuntime,\n openDatabaseRuntime,\n} from \"./database-runtime.ts\";\nimport { createMailRuntime, prepareMail } from \"./mail-runtime.ts\";\nimport type { ServerOptions } from \"./parser.ts\";\nimport type { ResourceOwner } from \"./resources.ts\";\n\ninterface ServerRuntime extends Omit<ServerOptions, \"drizzle\"> {\n readonly drizzle: DatabaseRuntime & { readonly migrate: boolean };\n readonly mailer: Transport;\n}\n\n/**\n * Create resources only after the server command has been parsed successfully.\n * @returns Runtime resources owned by the selected server command.\n */\nexport async function createServerRuntime(\n options: ServerOptions,\n owner: ResourceOwner,\n signal?: AbortSignal,\n): Promise<ServerRuntime> {\n const preparedMail = await prepareMail(options.mail, signal);\n const database = await openDatabaseRuntime(\n options.drizzle,\n owner,\n options.drizzle.migrate ? \"apply\" : \"inspect\",\n signal,\n );\n if (database.state.status !== \"ready\") {\n throw new MigrationPreparationError(\"incompatible-history\", database.state);\n }\n if (signal?.aborted) throw new MigrationPreparationError(\"aborted\");\n const mail = createMailRuntime(preparedMail);\n owner.register(mail, (runtime) => runtime.close(), { owned: true });\n return {\n ...options,\n drizzle: { ...database, migrate: options.drizzle.migrate },\n mailer: mail.transport,\n };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { type Database, schema } from \"@drfed/models\";\n\nexport default async function seedData(db: Database): Promise<void> {\n await db.transaction(async (tx) => {\n await seedAccounts(tx);\n });\n}\n\nconst sessionId = \"00000000-0000-4000-8000-000000000000\";\nconst accountId = \"00000000-0000-4000-8000-000000000001\";\nconst memberId = \"00000000-0000-4000-8000-000000000002\";\nconst pendingMemberId = \"00000000-0000-4000-8000-000000000003\";\nconst created = Temporal.Instant.from(\"2026-06-24T00:00:00.000Z\");\nconst tokenHash = \"dev-token-hash\";\n\nasync function seedAccounts(db: Database): Promise<void> {\n await db\n .insert(schema.accounts)\n .values([\n {\n id: accountId,\n email: \"owner@example.com\",\n name: \"Owner\",\n created,\n },\n {\n id: memberId,\n email: \"member@example.com\",\n name: \"Member\",\n created,\n },\n {\n id: pendingMemberId,\n email: \"pending@example.com\",\n name: \"Pending\",\n created,\n },\n ])\n .onConflictDoNothing();\n await db\n .insert(schema.sessions)\n .values([\n {\n id: sessionId,\n accountId,\n tokenHash,\n },\n ])\n .onConflictDoUpdate({\n target: schema.sessions.id,\n set: { tokenHash },\n });\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { writeFile } from \"node:fs/promises\";\nimport process from \"node:process\";\n\nimport createFederation, { createInboundRecorder } from \"@drfed/federation\";\nimport { KeyGenerationQueue } from \"@drfed/federation/task-queue\";\nimport { createYogaServer } from \"@drfed/graphql\";\nimport { type WebRuntime, createWebRuntime } from \"@drfed/web\";\nimport { PgliteKvStore } from \"@fedify/pglite\";\nimport { PostgresKvStore } from \"@fedify/postgres\";\nimport {\n configure,\n dispose,\n getConsoleSink,\n getLogger,\n} from \"@logtape/logtape\";\nimport { text } from \"@optique/core/message\";\nimport { createLoggingConfig } from \"@optique/logtape\";\nimport { printError, run } from \"@optique/run\";\nimport { serve } from \"srvx\";\n\nimport metadata from \"../package.json\" with { type: \"json\" };\nimport { describeServerConfiguration } from \"./diagnostics.ts\";\nimport { OperationRegistry } from \"./operations.ts\";\nimport {\n type Options,\n type SchemaGeneratorOptions,\n type ServerOptions,\n resolveOptions,\n} from \"./parser.ts\";\nimport { createProgram, selectInvocationMode } from \"./program.ts\";\nimport { ResourceOwner } from \"./resources.ts\";\nimport { createServerRuntime } from \"./runtime-options.ts\";\nimport seedData from \"./seed.ts\";\nimport {\n createControlSurface,\n createFetchHandler,\n getIngressMetadata,\n warnAboutStrandedInstances,\n} from \"./serving.ts\";\n\nasync function runServer(configuration: ServerOptions) {\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n owner.register(null, () => dispose(), { owned: true });\n let server: ReturnType<typeof serve> | undefined;\n let closing: Promise<void> | undefined;\n let signalled = false;\n\n async function cleanup(): Promise<void> {\n operations.abort();\n const errors: unknown[] = [];\n let forced: Promise<void> | undefined;\n const forceTimer = setTimeout(() => {\n if (server == null) return;\n const currentServer = server;\n forced = (async () => {\n try {\n await currentServer.close(true);\n } catch (error) {\n errors.push(error);\n }\n })();\n }, 5000);\n try {\n const results = await Promise.allSettled([\n server?.close(),\n operations.drain(),\n ]);\n for (const result of results) {\n if (result.status === \"rejected\") errors.push(result.reason);\n }\n if (forced != null) await forced;\n } finally {\n clearTimeout(forceTimer);\n try {\n await owner.close();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Server cleanup failed.\");\n }\n }\n\n function stop(): Promise<void> {\n // Assign before invoking abort callbacks so reentrant cleanup is shared.\n // oxlint-disable-next-line promise/prefer-await-to-then\n return (closing ??= Promise.resolve().then(cleanup));\n }\n\n function shutdown(): void {\n if (signalled) process.exit(1);\n signalled = true;\n const deadline = setTimeout(() => process.exit(1), 10_000);\n // oxlint-disable promise/prefer-await-to-then\n void stop().then(\n () => {\n clearTimeout(deadline);\n process.exit(0);\n },\n () => process.exit(1),\n );\n // oxlint-enable promise/prefer-await-to-then\n }\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n try {\n const options = await operations.run((signal) =>\n createServerRuntime(configuration, owner, signal),\n );\n const { credentials, db } = options.drizzle;\n if (options.seed) await operations.run(() => seedData(db));\n const kv =\n \"driver\" in credentials\n ? new PgliteKvStore(credentials.client)\n : new PostgresKvStore(credentials.client);\n const federation = await operations.run(() =>\n createFederation(db, {\n kv,\n queue: { task: new KeyGenerationQueue() },\n taskQueueResolution: \"strict\",\n manuallyStartQueue: true,\n allowPrivateAddress: true,\n }),\n );\n // The registry drains the worker before owned database cleanup.\n void (async () => {\n try {\n await operations.run((signal) =>\n federation.startQueue(undefined, { queue: \"task\", signal }),\n );\n } catch {\n if (!operations.signal.aborted) {\n getLogger([\"drfed\", \"server\"]).error(\n \"Actor key worker stopped unexpectedly.\",\n );\n }\n }\n })();\n const { emailFrom, mailer, rootOrigin, loginOrigins } = options;\n const yogaServer = createYogaServer(db, federation, {\n rootOrigin,\n emailFrom,\n mailer,\n loginOrigins,\n trackOperation: (operation) => operations.track(operation),\n shutdownSignal: operations.signal,\n });\n await operations.run(() => warnAboutStrandedInstances(db, rootOrigin));\n let web: WebRuntime | undefined;\n if (options.web) {\n const { publicOrigin } = options;\n if (publicOrigin === undefined) {\n throw new Error(\"Missing public web origin.\");\n }\n web = await operations.run(async (signal) => {\n const runtime = owner.register(\n await createWebRuntime({\n publicOrigin,\n graphqlFetch: (request) =>\n operations.track(() => yogaServer.fetch(request)),\n }),\n (resource) => resource.close(),\n { owned: true },\n );\n signal.throwIfAborted();\n return runtime;\n });\n }\n const fetchHandler = createFetchHandler({\n federation: createInboundRecorder({\n db,\n federation,\n rootOrigin,\n ingressMetadata: getIngressMetadata,\n }),\n rootOrigin,\n serveControlSurface: createControlSurface({\n graphql: yogaServer.fetch,\n ...(web === undefined ? {} : { web: web.fetch }),\n }),\n });\n const ownedServer = owner.register(\n serve({\n async fetch(request) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n try {\n return await operations.run(() => fetchHandler(request));\n } catch (error) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n throw error;\n }\n },\n hostname: options.address.host,\n manual: true,\n gracefulShutdown: false,\n port: options.address.port,\n }),\n (resource) => resource.close(true),\n { owned: true },\n );\n server = ownedServer;\n await operations.run(async () => {\n await ownedServer.serve();\n });\n if (options.publicOrigin !== undefined) {\n getLogger([\"drfed\", \"server\"]).info(\n \"Web frontend is available at {origin}.\",\n { origin: options.publicOrigin.origin },\n );\n }\n } catch (error) {\n process.off(\"SIGINT\", shutdown);\n process.off(\"SIGTERM\", shutdown);\n const deadline = Promise.withResolvers<never>();\n const timeout = setTimeout(\n () => deadline.reject(new Error(\"Startup cleanup timed out.\")),\n 10_000,\n );\n try {\n await Promise.race([stop(), deadline.promise]);\n } catch {\n throw new Error(\"Database cleanup after startup failure failed.\", {\n cause: error,\n });\n } finally {\n clearTimeout(timeout);\n }\n throw new Error(\"Could not start the server.\", { cause: error });\n }\n}\n\nasync function runSchemaGenerator(\n options: SchemaGeneratorOptions,\n): Promise<void> {\n const [{ schema }, { printSchema }] = await Promise.all([\n import(\"@drfed/graphql/schema\"),\n import(\"graphql\"),\n ]);\n const schemaCode = printSchema(schema);\n if (options.outputFile === \"-\") {\n // oxlint-disable-next-line no-console\n console.log(schemaCode);\n return;\n }\n await writeFile(options.outputFile, schemaCode, { encoding: \"utf-8\" });\n}\n\nexport async function main(): Promise<void> {\n const invocation = createProgram({\n mode: selectInvocationMode(process.argv.slice(2)),\n });\n let options: Options;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: {\n load: (parsed) =>\n parsed.mode[0] === \"schema\" ? undefined : invocation.load(parsed),\n },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: {\n option: true,\n value: metadata.version,\n },\n });\n options = resolveOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (\"generateGraphqlSchema\" in options) {\n await runSchemaGenerator(options);\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeServerConfiguration(options), null, 2));\n return;\n }\n let loggingConfig: Awaited<ReturnType<typeof createLoggingConfig>>;\n try {\n loggingConfig = await createLoggingConfig(\n options.logging,\n {},\n {\n contextLocalStorage: new AsyncLocalStorage(),\n sinks: {\n stderr: getConsoleSink({\n levelMap: {\n trace: \"error\",\n debug: \"error\",\n info: \"error\",\n warning: \"error\",\n error: \"error\",\n fatal: \"error\",\n },\n }),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n lowestLevel: \"warning\",\n sinks: [\"stderr\"],\n },\n ],\n },\n );\n } catch {\n printError([\n text(\"Could not initialize logging; check the log output path.\"),\n ]);\n process.exitCode = 1;\n return;\n }\n await configure(loggingConfig);\n\n await runServer(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,qBACd,MACqB;CACrB,MAAM,CAAC,OAAO,GAAG,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KAAK;CACjE,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,uCAAuC;CAEzD,MAAM,WAAW,MACf,OAAO;EACL,QAAQ,OAAO,2BAA2B;EAC1C,cAAc,SAAS,OAAO,OAAO,GAAG,SAAS,OAAO,CAAC,CAAC;EAC1D,OAAO,YAAY,EAAE,QAAQ,YAAY,CAAC;EAC1C,QAAQ,SAAS,SAAS,OAAO,CAAC,CAAC;CACrC,CAAC,GACD,IACF;CACA,OAAO,SAAS,WAAW,SAAS,MAAM,SAAS,WAAW;AAChE;;;;;AAMA,SAAgB,cACd,UAEI,CAAC,GACL;CACA,MAAM,WAAW,4BAA4B,OAAO;CACpD,MAAM,SAAS,aAAa,UAAU,QAAQ,I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C,CAAC;EACzE;CACF;CACA,IAAI;CACJ,IAAI;EACF,gBAAgB,MAAM,oBACpB,QAAQ,SACR,CAAC,GACD;GACE,qBAAqB,IAAI,kBAAkB;GAC3C,OAAO,EACL,QAAQ,eAAe,EACrB,UAAU;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;GACT,EACF,CAAC,EACH;GACA,SAAS,CACP;IACE,UAAU,CAAC,WAAW,MAAM;IAC5B,aAAa;IACb,OAAO,CAAC,QAAQ;GAClB,CACF;EACF,CACF;CACF,QAAQ;EACN,WAAW,CACT,KAAK,0DAA0D,CACjE,CAAC;EACD,QAAQ,WAAW;EACnB;CACF;CACA,MAAM,UAAU,aAAa;CAE7B,MAAM,UAAU,OAAO;AACzB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["metadata.version"],"sources":["../src/program.ts","../src/runtime-options.ts","../src/seed.ts","../src/index.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { object } from \"@optique/core/constructs\";\nimport { message } from \"@optique/core/message\";\nimport { multiple } from \"@optique/core/modifiers\";\nimport { type InferValue, parse } from \"@optique/core/parser\";\nimport { argument, option, passThrough } from \"@optique/core/primitives\";\nimport type { Program } from \"@optique/core/program\";\nimport { string } from \"@optique/core/valueparser\";\n\nimport { createConfigurationBindings } from \"./configuration.ts\";\nimport { createParser, valueOptionNames } from \"./parser.ts\";\n\n/**\n * Select operational vs schema bindings through a resource-free Optique pass.\n * The final parser still strictly validates every token. This pass consumes no\n * environment/config values and honors Optique's option terminator semantics.\n * @returns The mode whose setting bindings the complete invocation needs.\n */\nexport function selectInvocationMode(\n args: readonly string[],\n): \"server\" | \"schema\" {\n const [first, ...aliases] = Object.values(valueOptionNames).flat();\n if (first === undefined) {\n throw new Error(\"Missing CLI value-option definitions.\");\n }\n const selected = parse(\n object({\n schema: option(\"--generate-graphql-schema\"),\n optionValues: multiple(option(first, ...aliases, string())),\n extra: passThrough({ format: \"nextToken\" }),\n values: multiple(argument(string())),\n }),\n args,\n );\n return selected.success && selected.value.schema ? \"schema\" : \"server\";\n}\n\n/**\n * Create independent CLI bindings for one invocation.\n * @returns The program, its source contexts and explicit configuration loader.\n */\nexport function createProgram(\n options: Parameters<typeof createConfigurationBindings>[0] & {\n readonly mode?: \"server\" | \"schema\";\n } = {},\n) {\n const bindings = createConfigurationBindings(options);\n const parser = createParser(bindings, options.mode);\n const program: Program<\"sync\", InferValue<typeof parser>> = {\n metadata: {\n description: message`Run a DrFed server.`,\n name: \"drfed-server\",\n },\n parser,\n };\n return { program, contexts: bindings.contexts, load: bindings.load };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { MigrationPreparationError } from \"@drfed/models\";\nimport type { Transport } from \"@upyo/core\";\n\nimport {\n type DatabaseRuntime,\n openDatabaseRuntime,\n} from \"./database-runtime.ts\";\nimport { createMailRuntime, prepareMail } from \"./mail-runtime.ts\";\nimport type { ServerOptions } from \"./parser.ts\";\nimport type { ResourceOwner } from \"./resources.ts\";\n\ninterface ServerRuntime extends Omit<ServerOptions, \"drizzle\"> {\n readonly drizzle: DatabaseRuntime & { readonly migrate: boolean };\n readonly mailer: Transport;\n}\n\n/**\n * Create resources only after the server command has been parsed successfully.\n * @returns Runtime resources owned by the selected server command.\n */\nexport async function createServerRuntime(\n options: ServerOptions,\n owner: ResourceOwner,\n signal?: AbortSignal,\n): Promise<ServerRuntime> {\n const preparedMail = await prepareMail(options.mail, signal);\n const database = await openDatabaseRuntime(\n options.drizzle,\n owner,\n options.drizzle.migrate ? \"apply\" : \"inspect\",\n signal,\n );\n if (database.state.status !== \"ready\") {\n throw new MigrationPreparationError(\"incompatible-history\", database.state);\n }\n if (signal?.aborted) throw new MigrationPreparationError(\"aborted\");\n const mail = createMailRuntime(preparedMail);\n owner.register(mail, (runtime) => runtime.close(), { owned: true });\n return {\n ...options,\n drizzle: { ...database, migrate: options.drizzle.migrate },\n mailer: mail.transport,\n };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { type Database, schema } from \"@drfed/models\";\n\nexport default async function seedData(db: Database): Promise<void> {\n await db.transaction(async (tx) => {\n await seedAccounts(tx);\n });\n}\n\nconst sessionId = \"00000000-0000-4000-8000-000000000000\";\nconst accountId = \"00000000-0000-4000-8000-000000000001\";\nconst memberId = \"00000000-0000-4000-8000-000000000002\";\nconst pendingMemberId = \"00000000-0000-4000-8000-000000000003\";\nconst created = Temporal.Instant.from(\"2026-06-24T00:00:00.000Z\");\nconst tokenHash = \"dev-token-hash\";\n\nasync function seedAccounts(db: Database): Promise<void> {\n await db\n .insert(schema.accounts)\n .values([\n {\n id: accountId,\n email: \"owner@example.com\",\n name: \"Owner\",\n created,\n },\n {\n id: memberId,\n email: \"member@example.com\",\n name: \"Member\",\n created,\n },\n {\n id: pendingMemberId,\n email: \"pending@example.com\",\n name: \"Pending\",\n created,\n },\n ])\n .onConflictDoNothing();\n await db\n .insert(schema.sessions)\n .values([\n {\n id: sessionId,\n accountId,\n tokenHash,\n },\n ])\n .onConflictDoUpdate({\n target: schema.sessions.id,\n set: { tokenHash },\n });\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { writeFile } from \"node:fs/promises\";\nimport process from \"node:process\";\n\nimport createFederation, { createInboundRecorder } from \"@drfed/federation\";\nimport { KeyGenerationQueue } from \"@drfed/federation/task-queue\";\nimport { createYogaServer } from \"@drfed/graphql\";\nimport { type WebRuntime, createWebRuntime } from \"@drfed/web\";\nimport { PgliteKvStore } from \"@fedify/pglite\";\nimport { PostgresKvStore } from \"@fedify/postgres\";\nimport {\n configure,\n dispose,\n getConsoleSink,\n getLogger,\n} from \"@logtape/logtape\";\nimport { text } from \"@optique/core/message\";\nimport { createLoggingConfig } from \"@optique/logtape\";\nimport { printError, run } from \"@optique/run\";\nimport { serve } from \"srvx\";\n\nimport metadata from \"../package.json\" with { type: \"json\" };\nimport { describeServerConfiguration } from \"./diagnostics.ts\";\nimport { OperationRegistry } from \"./operations.ts\";\nimport {\n type Options,\n type SchemaGeneratorOptions,\n type ServerOptions,\n resolveOptions,\n} from \"./parser.ts\";\nimport { createProgram, selectInvocationMode } from \"./program.ts\";\nimport { ResourceOwner } from \"./resources.ts\";\nimport { createServerRuntime } from \"./runtime-options.ts\";\nimport seedData from \"./seed.ts\";\nimport {\n createControlSurface,\n createFetchHandler,\n getIngressMetadata,\n warnAboutStrandedInstances,\n} from \"./serving.ts\";\n\nasync function runServer(configuration: ServerOptions) {\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n owner.register(null, () => dispose(), { owned: true });\n let server: ReturnType<typeof serve> | undefined;\n let closing: Promise<void> | undefined;\n let signalled = false;\n\n async function cleanup(): Promise<void> {\n operations.abort();\n const errors: unknown[] = [];\n let forced: Promise<void> | undefined;\n const forceTimer = setTimeout(() => {\n if (server == null) return;\n const currentServer = server;\n forced = (async () => {\n try {\n await currentServer.close(true);\n } catch (error) {\n errors.push(error);\n }\n })();\n }, 5000);\n try {\n const results = await Promise.allSettled([\n server?.close(),\n operations.drain(),\n ]);\n for (const result of results) {\n if (result.status === \"rejected\") errors.push(result.reason);\n }\n if (forced != null) await forced;\n } finally {\n clearTimeout(forceTimer);\n try {\n await owner.close();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Server cleanup failed.\");\n }\n }\n\n function stop(): Promise<void> {\n // Assign before invoking abort callbacks so reentrant cleanup is shared.\n // oxlint-disable-next-line promise/prefer-await-to-then\n return (closing ??= Promise.resolve().then(cleanup));\n }\n\n function shutdown(): void {\n if (signalled) process.exit(1);\n signalled = true;\n const deadline = setTimeout(() => process.exit(1), 10_000);\n // oxlint-disable promise/prefer-await-to-then\n void stop().then(\n () => {\n clearTimeout(deadline);\n process.exit(0);\n },\n () => process.exit(1),\n );\n // oxlint-enable promise/prefer-await-to-then\n }\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n try {\n const options = await operations.run((signal) =>\n createServerRuntime(configuration, owner, signal),\n );\n const { credentials, db } = options.drizzle;\n if (options.seed) await operations.run(() => seedData(db));\n const kv =\n \"driver\" in credentials\n ? new PgliteKvStore(credentials.client)\n : new PostgresKvStore(credentials.client);\n const federation = await operations.run(() =>\n createFederation(db, {\n kv,\n queue: { task: new KeyGenerationQueue() },\n taskQueueResolution: \"strict\",\n manuallyStartQueue: true,\n allowPrivateAddress: true,\n }),\n );\n // The registry drains the worker before owned database cleanup.\n void (async () => {\n try {\n await operations.run((signal) =>\n federation.startQueue(undefined, { queue: \"task\", signal }),\n );\n } catch {\n if (!operations.signal.aborted) {\n getLogger([\"drfed\", \"server\"]).error(\n \"Actor key worker stopped unexpectedly.\",\n );\n }\n }\n })();\n const { emailFrom, mailer, rootOrigin, loginOrigins } = options;\n const yogaServer = createYogaServer(db, federation, {\n rootOrigin,\n emailFrom,\n mailer,\n loginOrigins,\n trackOperation: (operation) => operations.track(operation),\n shutdownSignal: operations.signal,\n });\n await operations.run(() => warnAboutStrandedInstances(db, rootOrigin));\n let web: WebRuntime | undefined;\n if (options.web) {\n const { publicOrigin } = options;\n if (publicOrigin === undefined) {\n throw new Error(\"Missing public web origin.\");\n }\n web = await operations.run(async (signal) => {\n const runtime = owner.register(\n await createWebRuntime({\n publicOrigin,\n graphqlFetch: (request) =>\n operations.track(() => yogaServer.fetch(request)),\n }),\n (resource) => resource.close(),\n { owned: true },\n );\n signal.throwIfAborted();\n return runtime;\n });\n }\n const fetchHandler = createFetchHandler({\n federation: createInboundRecorder({\n db,\n federation,\n rootOrigin,\n ingressMetadata: getIngressMetadata,\n }),\n rootOrigin,\n serveControlSurface: createControlSurface({\n graphql: yogaServer.fetch,\n ...(web === undefined ? {} : { web: web.fetch }),\n }),\n });\n const ownedServer = owner.register(\n serve({\n async fetch(request) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n try {\n return await operations.run(() => fetchHandler(request));\n } catch (error) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n throw error;\n }\n },\n hostname: options.address.host,\n manual: true,\n gracefulShutdown: false,\n port: options.address.port,\n }),\n (resource) => resource.close(true),\n { owned: true },\n );\n server = ownedServer;\n await operations.run(async () => {\n await ownedServer.serve();\n });\n if (options.publicOrigin !== undefined) {\n getLogger([\"drfed\", \"server\"]).info(\n \"Web frontend is available at {origin}.\",\n { origin: options.publicOrigin.origin },\n );\n }\n } catch (error) {\n process.off(\"SIGINT\", shutdown);\n process.off(\"SIGTERM\", shutdown);\n const deadline = Promise.withResolvers<never>();\n const timeout = setTimeout(\n () => deadline.reject(new Error(\"Startup cleanup timed out.\")),\n 10_000,\n );\n try {\n await Promise.race([stop(), deadline.promise]);\n } catch {\n throw new Error(\"Database cleanup after startup failure failed.\", {\n cause: error,\n });\n } finally {\n clearTimeout(timeout);\n }\n throw new Error(\"Could not start the server.\", { cause: error });\n }\n}\n\nasync function runSchemaGenerator(\n options: SchemaGeneratorOptions,\n): Promise<void> {\n const [{ schema }, { printSchema }] = await Promise.all([\n import(\"@drfed/graphql/schema\"),\n import(\"graphql\"),\n ]);\n const schemaCode = printSchema(schema);\n if (options.outputFile === \"-\") {\n // oxlint-disable-next-line no-console\n console.log(schemaCode);\n return;\n }\n await writeFile(options.outputFile, schemaCode, { encoding: \"utf-8\" });\n}\n\nexport async function main(): Promise<void> {\n const invocation = createProgram({\n mode: selectInvocationMode(process.argv.slice(2)),\n });\n let options: Options;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: {\n load: (parsed) =>\n parsed.mode[0] === \"schema\" ? undefined : invocation.load(parsed),\n },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: {\n option: true,\n value: metadata.version,\n },\n });\n options = resolveOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (\"generateGraphqlSchema\" in options) {\n await runSchemaGenerator(options);\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeServerConfiguration(options), null, 2));\n return;\n }\n let loggingConfig: Awaited<ReturnType<typeof createLoggingConfig>>;\n try {\n loggingConfig = await createLoggingConfig(\n options.logging,\n {},\n {\n contextLocalStorage: new AsyncLocalStorage(),\n sinks: {\n stderr: getConsoleSink({\n levelMap: {\n trace: \"error\",\n debug: \"error\",\n info: \"error\",\n warning: \"error\",\n error: \"error\",\n fatal: \"error\",\n },\n }),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n lowestLevel: \"warning\",\n sinks: [\"stderr\"],\n },\n ],\n },\n );\n } catch {\n printError([\n text(\"Could not initialize logging; check the log output path.\"),\n ]);\n process.exitCode = 1;\n return;\n }\n await configure(loggingConfig);\n\n await runServer(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,qBACd,MACqB;CACrB,MAAM,CAAC,OAAO,GAAG,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KAAK;CACjE,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,uCAAuC;CAEzD,MAAM,WAAW,MACf,OAAO;EACL,QAAQ,OAAO,2BAA2B;EAC1C,cAAc,SAAS,OAAO,OAAO,GAAG,SAAS,OAAO,CAAC,CAAC;EAC1D,OAAO,YAAY,EAAE,QAAQ,YAAY,CAAC;EAC1C,QAAQ,SAAS,SAAS,OAAO,CAAC,CAAC;CACrC,CAAC,GACD,IACF;CACA,OAAO,SAAS,WAAW,SAAS,MAAM,SAAS,WAAW;AAChE;;;;;AAMA,SAAgB,cACd,UAEI,CAAC,GACL;CACA,MAAM,WAAW,4BAA4B,OAAO;CACpD,MAAM,SAAS,aAAa,UAAU,QAAQ,IAAI;CAQlD,OAAO;EAAE,SAAA;G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;CACA,IAAI;CACJ,IAAI;EACF,gBAAgB,MAAM,oBACpB,QAAQ,SACR,CAAC,GACD;GACE,qBAAqB,IAAI,kBAAkB;GAC3C,OAAO,EACL,QAAQ,eAAe,EACrB,UAAU;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;GACT,EACF,CAAC,EACH;GACA,SAAS,CACP;IACE,UAAU,CAAC,WAAW,MAAM;IAC5B,aAAa;IACb,OAAO,CAAC,QAAQ;GAClB,CACF;EACF,CACF;CACF,QAAQ;EACN,WAAW,CACT,KAAK,0DAA0D,CACjE,CAAC;EACD,QAAQ,WAAW;EACnB;CACF;CACA,MAAM,UAAU,aAAa;CAE7B,MAAM,UAAU,OAAO;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jmap-parser.d.mts","names":[],"sources":["../src/jmap-parser.ts"],"mappings":";;;cA2Ba;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;iBAMc,iBACd,UAAU,kBAAkB;EAG1B,kDAAc,
|
|
1
|
+
{"version":3,"file":"jmap-parser.d.mts","names":["_$__configuration_ts0.Sourced"],"sources":["../src/jmap-parser.ts"],"mappings":";;;cA2Ba;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;iBAMc,iBACd,UAAU,kBAAkB;EAG1B,kDAAc,qBAHNA,6EAGM;EAUd,mDAAe,qBAVDA,6EAUC;EAUf,uDAAmB,qBAVJA,6EAUI;EAQnB,4CAAQ,qBARWA,6EAQX;EAQR,gDAAY,qBARJA,6EAQI;EAUZ,oDAAgB,qBAVJA,6EAUI;EAQhB,iDAAa,qBARGA,6EAQH;EAYb,kDAAc,qBAZDA,6EAYC;EAYd,+CAAW,qBAZGA,6EAYH;EAYX,+CAAW,qBAZAA,6EAYA;EAUX,uDAAmB,qBAVRA,6EAUQ"}
|
package/dist/logging.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.mts","names":[],"sources":["../src/logging.ts"],"mappings":";;;;;cA+Ba;WACX;WACA;WACA;;;;;iBAMc,oBACd,UAAU,kBAAkB,iEAA4B;
|
|
1
|
+
{"version":3,"file":"logging.d.mts","names":["_$__configuration_ts0.Sourced"],"sources":["../src/logging.ts"],"mappings":";;;;;cA+Ba;WACX;WACA;WACA;;;;;iBAMc,oBACd,UAAU,kBAAkB,iEAA4B;kBAA9CA;;;;;;;;KAoCP,oBAAoB,WAAW,kBAAkB;;;;iBAKtC,eAAe,KAAK,mBAAmB;;aAAnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail-parser-DyI4wuQp.d.mts","names":[],"sources":["../src/mail-parser.ts"],"mappings":";;;;cAmCa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAGK;WACN;WACC;WACA;WACD;WACC;WACI;WACI;WACF;WACC;WACI;WACE;WACJ;WACL;WACC;WACH;WACE;WACD;;;;;iBAMA,iBACd,UAAU,kBAAkB,iEAA4B;
|
|
1
|
+
{"version":3,"file":"mail-parser-DyI4wuQp.d.mts","names":["_$__configuration_ts0.Sourced"],"sources":["../src/mail-parser.ts"],"mappings":";;;;cAmCa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAGK;WACN;WACC;WACA;WACD;WACC;WACI;WACI;WACF;WACC;WACI;WACE;WACJ;WACL;WACC;WACH;WACE;WACD;;;;;iBAMA,iBACd,UAAU,kBAAkB,iEAA4B;uBAA9CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkOA,iBAAiB,WAAW,kBAAkB"}
|
package/dist/mail-runtime.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createMailRuntime, prepareMail };
|
|
1
|
+
export { t as createMailRuntime, n as prepareMail } from "./mail-runtime-YROIQ8up.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail-settings-DjWMAUaE.d.mts","names":[],"sources":["../src/ses-settings.ts","../src/mail-settings.ts"],"mappings":";;;;;;;;;UA4BiB;WACN;WACA,YAAY,KACnB;WAGO;aACE,aAAa;aACb,iBAAiB;;aAEb;;aACA;aAA0B,cAAc;;;;;;KCH7C;WAEG;WACA;WACA,QAAQ;WACR;;WAGA;WACA;WACA,QAAQ;WACR;;;KAIH,eACR,kBACA,eACA;WACW;WAA+B;;WAE/B;WACA,YAAY,KAAK;WACjB,gBAAgB;WAChB;aACE,IAAI;aACJ,MAAM;aACN,KAAK;;;;iBA4KN,qBAAqB,cAAc;;iBAWnC,kBAAkB,cAAc;;;;iBAqYhC,oBAAoB,KAAK,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"mail-settings-DjWMAUaE.d.mts","names":["_$__configuration_ts0.ConfigurationSource"],"sources":["../src/ses-settings.ts","../src/mail-settings.ts"],"mappings":";;;;;;;;;UA4BiB;WACN;WACA,YAAY,KACnB;WAGO;aACE,aAAa;aACb,iBAAiB;;aAEb;;aACA;aAA0B,cAAc;;;;;;KCH7C;WAEG;WACA;WACA,QAAQ;WACR;;WAGA;WACA;WACA,QAAQ;WACR;;;KAIH,eACR,kBACA,eACA;WACW;WAA+B;;WAE/B;WACA,YAAY,KAAK;WACjB,gBAAgB;WAChB;aACE,IAAI;aACJ,MAAM;aACN,KAAK;;;;iBA4KN,qBAAqB,cAAc;;iBAWnC,kBAAkB,cAAc;;;;iBAqYhC,oBAAoB,KAAK,gBAAgB"}
|
package/dist/mail-settings.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { resolveMailSettings, validateSmtpOAuth, validateSmtpPassword };
|
|
1
|
+
export { t as resolveMailSettings, n as validateSmtpOAuth, r as validateSmtpPassword } from "./mail-settings-BD1TQ0rt.mjs";
|
package/dist/operations.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.mjs","names":[
|
|
1
|
+
{"version":3,"file":"operations.mjs","names":[],"sources":["../src/operations.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\n/** Track asynchronous work so shutdown can refuse new work and await existing work. */\nexport class OperationRegistry {\n readonly #abort = new AbortController();\n readonly #active = new Set<Promise<unknown>>();\n\n /**\n * A shared cancellation signal for operations owned by this registry.\n * @returns The cancellation signal shared by registered operations.\n */\n get signal(): AbortSignal {\n return this.#abort.signal;\n }\n\n /**\n * Register before invoking an operation, including operations that reject.\n * @returns The operation's result; the caller remains responsible for errors.\n */\n run<T>(operation: (signal: AbortSignal) => T | Promise<T>): Promise<T> {\n if (this.signal.aborted) return Promise.reject(this.signal.reason);\n return this.track((signal) => {\n signal.throwIfAborted();\n return operation(signal);\n });\n }\n\n /**\n * Track a continuation of work already admitted by the runtime.\n * The caller must prevent new requests and stop background producers before\n * draining. Continuations remain allowed so accepted requests can finish.\n * @returns The continuation's result; the caller remains responsible for errors.\n */\n track<T>(operation: (signal: AbortSignal) => T | Promise<T>): Promise<T> {\n // Register first so reentrant shutdown cannot miss the operation.\n // oxlint-disable-next-line promise/prefer-await-to-then\n const task = Promise.resolve().then(() => operation(this.signal));\n this.#active.add(task);\n const forget = () => {\n this.#active.delete(task);\n };\n // Both handlers resolve; tracking must not create an unhandled rejection.\n // oxlint-disable-next-line promise/prefer-await-to-then\n void task.then(forget, forget);\n return task;\n }\n\n /** Refuse new work and signal existing operations to stop. */\n abort(): void {\n this.#abort.abort();\n }\n\n /**\n * Abort and await all registered work, even if an operation rejected.\n * @returns Completion after every active operation has settled.\n */\n async drain(): Promise<void> {\n this.abort();\n // Existing requests may register their next resolver while draining.\n // oxlint-disable-next-line no-unmodified-loop-condition\n while (this.#active.size > 0) {\n // oxlint-disable-next-line no-await-in-loop\n await Promise.allSettled([...this.#active]);\n }\n }\n}\n"],"mappings":";;AAiBA,IAAa,oBAAb,MAA+B;CAC7B,SAAkB,IAAI,gBAAgB;CACtC,0BAAmB,IAAI,IAAsB;;;;;CAM7C,IAAI,SAAsB;EACxB,OAAO,KAAK,OAAO;CACrB;;;;;CAMA,IAAO,WAAgE;EACrE,IAAI,KAAK,OAAO,SAAS,OAAO,QAAQ,OAAO,KAAK,OAAO,MAAM;EACjE,OAAO,KAAK,OAAO,WAAW;GAC5B,OAAO,eAAe;GACtB,OAAO,UAAU,MAAM;EACzB,CAAC;CACH;;;;;;;CAQA,MAAS,WAAgE;EAGvE,MAAM,OAAO,QAAQ,QAAQ,CAAC,CAAC,WAAW,UAAU,KAAK,MAAM,CAAC;EAChE,KAAK,QAAQ,IAAI,IAAI;EACrB,MAAM,eAAe;GACnB,KAAK,QAAQ,OAAO,IAAI;EAC1B;EAGA,KAAU,KAAK,QAAQ,MAAM;EAC7B,OAAO;CACT;;CAGA,QAAc;EACZ,KAAK,OAAO,MAAM;CACpB;;;;;CAMA,MAAM,QAAuB;EAC3B,KAAK,MAAM;EAGX,OAAO,KAAK,QAAQ,OAAO,GAEzB,MAAM,QAAQ,WAAW,CAAC,GAAG,KAAK,OAAO,CAAC;CAE9C;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-91KEch3P.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser-TANGHRjL.d.mts","names":[],"sources":["../src/parser.ts"],"mappings":";;;;KAoEK,WAAW,kBAAkB;;;;;iBAOlB,aACd,UAAU,UACV,4DAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyNrC;KAEI,aAAa,WAAW,kBAAkB;KACnC;WACD;WACA;;;;;;iBAeK,eAAe,SAAS,YAAY,eAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2G3D,UAAU,kBAAkB;KAC5B,gBAAgB,QAC1B;EACE"}
|
|
1
|
+
{"version":3,"file":"parser-TANGHRjL.d.mts","names":["_$__mail_settings_ts0.MailSettings","_$__configuration_ts0.ConfigurationSource"],"sources":["../src/parser.ts"],"mappings":";;;;KAoEK,WAAW,kBAAkB;;;;;iBAOlB,aACd,UAAU,UACV,4DAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyNrC;KAEI,aAAa,WAAW,kBAAkB;KACnC;WACD;WACA;;;;;;iBAeK,eAAe,SAAS,YAAY,eAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2G3D,UAAU,kBAAkB;KAC5B,gBAAgB,QAC1B;EACE"}
|
package/dist/resources.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.mjs","names":[
|
|
1
|
+
{"version":3,"file":"resources.mjs","names":[],"sources":["../src/resources.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\n/** Own cleanup callbacks independently of the resources a caller borrows. */\nexport class ResourceOwner {\n readonly #cleanups: (() => void | Promise<void>)[] = [];\n #closing: Promise<void> | undefined;\n\n /**\n * Register a resource immediately after acquisition.\n * @returns The same resource, with cleanup registered only when owned.\n */\n register<T>(\n resource: T,\n dispose: (resource: T) => void | Promise<void>,\n options: { readonly owned: boolean },\n ): T {\n if (this.#closing != null) {\n throw new Error(\"Cannot register resources during cleanup.\");\n }\n if (options.owned) this.#cleanups.push(() => dispose(resource));\n return resource;\n }\n\n /**\n * Close owned resources in reverse acquisition order, attempting every cleanup.\n * @returns One shared completion promise; cleanup failures are aggregated.\n */\n close(): Promise<void> {\n // Defer callbacks until the shared promise is assigned, including reentrancy.\n // oxlint-disable-next-line promise/prefer-await-to-then\n return (this.#closing ??= Promise.resolve().then(async () => {\n const errors: unknown[] = [];\n for (const dispose of this.#cleanups.splice(0).reverse()) {\n try {\n // oxlint-disable-next-line no-await-in-loop\n await dispose();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Resource cleanup failed.\");\n }\n return undefined;\n }));\n }\n}\n"],"mappings":";;AAiBA,IAAa,gBAAb,MAA2B;CACzB,YAAqD,CAAC;CACtD;;;;;CAMA,SACE,UACA,SACA,SACG;EACH,IAAI,KAAK,YAAY,MACnB,MAAM,IAAI,MAAM,2CAA2C;EAE7D,IAAI,QAAQ,OAAO,KAAK,UAAU,WAAW,QAAQ,QAAQ,CAAC;EAC9D,OAAO;CACT;;;;;CAMA,QAAuB;EAGrB,OAAQ,KAAK,aAAa,QAAQ,QAAQ,CAAC,CAAC,KAAK,YAAY;GAC3D,MAAM,SAAoB,CAAC;GAC3B,KAAK,MAAM,WAAW,KAAK,UAAU,OAAO,CAAC,CAAC,CAAC,QAAQ,GACrD,IAAI;IAEF,MAAM,QAAQ;GAChB,SAAS,OAAO;IACd,OAAO,KAAK,KAAK;GACnB;GAEF,IAAI,OAAO,SAAS,GAClB,MAAM,IAAI,eAAe,QAAQ,0BAA0B;EAG/D,CAAC;CACH;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drfed/drfed",
|
|
3
|
-
"version": "0.2.0-dev.
|
|
3
|
+
"version": "0.2.0-dev.608",
|
|
4
4
|
"description": "The main entrypoint program for DrFed.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ActivityPub",
|
|
@@ -227,10 +227,10 @@
|
|
|
227
227
|
"typescript": "^7.0.2"
|
|
228
228
|
},
|
|
229
229
|
"dependencies": {
|
|
230
|
-
"@drfed/federation": "0.2.0-dev.
|
|
231
|
-
"@drfed/graphql": "0.2.0-dev.
|
|
232
|
-
"@drfed/models": "0.2.0-dev.
|
|
233
|
-
"@drfed/web": "0.2.0-dev.
|
|
230
|
+
"@drfed/federation": "0.2.0-dev.608",
|
|
231
|
+
"@drfed/graphql": "0.2.0-dev.608",
|
|
232
|
+
"@drfed/models": "0.2.0-dev.608",
|
|
233
|
+
"@drfed/web": "0.2.0-dev.608",
|
|
234
234
|
"@electric-sql/pglite": "^0.5.3",
|
|
235
235
|
"@fedify/fedify": "2.4.3",
|
|
236
236
|
"@fedify/pglite": "2.4.3",
|
|
@@ -238,11 +238,11 @@
|
|
|
238
238
|
"@logtape/drizzle-orm": "^2.2.2",
|
|
239
239
|
"@logtape/file": "2.3.0-dev.840",
|
|
240
240
|
"@logtape/logtape": "2.3.0-dev.840",
|
|
241
|
-
"@optique/config": "1.3.
|
|
242
|
-
"@optique/core": "
|
|
243
|
-
"@optique/env": "1.3.
|
|
244
|
-
"@optique/logtape": "
|
|
245
|
-
"@optique/run": "
|
|
241
|
+
"@optique/config": "1.3.6",
|
|
242
|
+
"@optique/core": "1.3.6",
|
|
243
|
+
"@optique/env": "1.3.6",
|
|
244
|
+
"@optique/logtape": "1.3.6",
|
|
245
|
+
"@optique/run": "1.3.6",
|
|
246
246
|
"@upyo/core": "0.6.0",
|
|
247
247
|
"@upyo/jmap": "0.6.0",
|
|
248
248
|
"@upyo/lettermint": "0.6.0",
|
|
@@ -273,13 +273,13 @@
|
|
|
273
273
|
},
|
|
274
274
|
"drfedBuild": {
|
|
275
275
|
"enabled": true,
|
|
276
|
-
"version": "0.2.0-dev.
|
|
277
|
-
"fullVersion": "0.2.0-dev.
|
|
276
|
+
"version": "0.2.0-dev.608",
|
|
277
|
+
"fullVersion": "0.2.0-dev.608+6b717604",
|
|
278
278
|
"baseVersion": "0.2.0",
|
|
279
279
|
"channel": "dev",
|
|
280
|
-
"sha": "
|
|
281
|
-
"runNumber": "
|
|
282
|
-
"runId": "
|
|
280
|
+
"sha": "6b717604088bc8705ca82e47e03b27aa05bed43d",
|
|
281
|
+
"runNumber": "608",
|
|
282
|
+
"runId": "40172563060",
|
|
283
283
|
"ref": "refs/heads/main",
|
|
284
284
|
"workflow": ".github/workflows/main.yaml"
|
|
285
285
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-CaLSz3rX.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|