@drfed/drfed 0.0.0-stage → 0.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +1198 -2
- package/bin/drfed-account.mjs +20 -0
- package/bin/drfed-migrate.mjs +20 -0
- package/bin/drfed-server.mjs +20 -0
- package/bin/drfed-web.mjs +20 -0
- package/completions/bash/drfed-account +219 -0
- package/completions/bash/drfed-migrate +219 -0
- package/completions/bash/drfed-server +219 -0
- package/completions/bash/drfed-web +219 -0
- package/completions/fish/drfed-account.fish +264 -0
- package/completions/fish/drfed-migrate.fish +264 -0
- package/completions/fish/drfed-server.fish +264 -0
- package/completions/fish/drfed-web.fish +264 -0
- package/completions/nu/drfed-account.nu +293 -0
- package/completions/nu/drfed-migrate.nu +293 -0
- package/completions/nu/drfed-server.nu +293 -0
- package/completions/nu/drfed-web.nu +293 -0
- package/completions/pwsh/drfed-account.ps1 +183 -0
- package/completions/pwsh/drfed-migrate.ps1 +183 -0
- package/completions/pwsh/drfed-server.ps1 +183 -0
- package/completions/pwsh/drfed-web.ps1 +183 -0
- package/completions/zsh/_drfed-account +145 -0
- package/completions/zsh/_drfed-migrate +145 -0
- package/completions/zsh/_drfed-server +145 -0
- package/completions/zsh/_drfed-web +145 -0
- package/dist/api-mail-parser.d.mts +106 -0
- package/dist/api-mail-parser.d.mts.map +1 -0
- package/dist/api-mail-parser.mjs +145 -0
- package/dist/api-mail-parser.mjs.map +1 -0
- package/dist/api-mail-settings-BcGaqQ9f.d.mts +142 -0
- package/dist/api-mail-settings-BcGaqQ9f.d.mts.map +1 -0
- package/dist/api-mail-settings.d.mts +2 -0
- package/dist/api-mail-settings.mjs +272 -0
- package/dist/api-mail-settings.mjs.map +1 -0
- package/dist/bounded-mail-runtime.d.mts +9 -0
- package/dist/bounded-mail-runtime.d.mts.map +1 -0
- package/dist/bounded-mail-runtime.mjs +66 -0
- package/dist/bounded-mail-runtime.mjs.map +1 -0
- package/dist/commands/account-create.d.mts +37 -0
- package/dist/commands/account-create.d.mts.map +1 -0
- package/dist/commands/account-create.mjs +87 -0
- package/dist/commands/account-create.mjs.map +1 -0
- package/dist/commands/account-program.d.mts +223 -0
- package/dist/commands/account-program.d.mts.map +1 -0
- package/dist/commands/account-program.mjs +116 -0
- package/dist/commands/account-program.mjs.map +1 -0
- package/dist/commands/account.d.mts +6 -0
- package/dist/commands/account.d.mts.map +1 -0
- package/dist/commands/account.mjs +91 -0
- package/dist/commands/account.mjs.map +1 -0
- package/dist/commands/migrate-program.d.mts +219 -0
- package/dist/commands/migrate-program.d.mts.map +1 -0
- package/dist/commands/migrate-program.mjs +116 -0
- package/dist/commands/migrate-program.mjs.map +1 -0
- package/dist/commands/migrate.d.mts +6 -0
- package/dist/commands/migrate.d.mts.map +1 -0
- package/dist/commands/migrate.mjs +85 -0
- package/dist/commands/migrate.mjs.map +1 -0
- package/dist/commands/web-program.d.mts +213 -0
- package/dist/commands/web-program.d.mts.map +1 -0
- package/dist/commands/web-program.mjs +112 -0
- package/dist/commands/web-program.mjs.map +1 -0
- package/dist/commands/web.d.mts +6 -0
- package/dist/commands/web.d.mts.map +1 -0
- package/dist/commands/web.mjs +184 -0
- package/dist/commands/web.mjs.map +1 -0
- package/dist/configuration-DVVF7xNv.d.mts +432 -0
- package/dist/configuration-DVVF7xNv.d.mts.map +1 -0
- package/dist/configuration.d.mts +2 -0
- package/dist/configuration.mjs +469 -0
- package/dist/configuration.mjs.map +1 -0
- package/dist/data-path.d.mts +9 -0
- package/dist/data-path.d.mts.map +1 -0
- package/dist/data-path.mjs +21 -0
- package/dist/data-path.mjs.map +1 -0
- package/dist/database-runtime.d.mts +26 -0
- package/dist/database-runtime.d.mts.map +1 -0
- package/dist/database-runtime.mjs +92 -0
- package/dist/database-runtime.mjs.map +1 -0
- package/dist/database-settings.d.mts +36 -0
- package/dist/database-settings.d.mts.map +1 -0
- package/dist/database-settings.mjs +67 -0
- package/dist/database-settings.mjs.map +1 -0
- package/dist/diagnostics.d.mts +29 -0
- package/dist/diagnostics.d.mts.map +1 -0
- package/dist/diagnostics.mjs +61 -0
- package/dist/diagnostics.mjs.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +344 -0
- package/dist/index.mjs.map +1 -0
- package/dist/jmap-parser.d.mts +35 -0
- package/dist/jmap-parser.d.mts.map +1 -0
- package/dist/jmap-parser.mjs +42 -0
- package/dist/jmap-parser.mjs.map +1 -0
- package/dist/jmap-runtime.d.mts +10 -0
- package/dist/jmap-runtime.d.mts.map +1 -0
- package/dist/jmap-runtime.mjs +17 -0
- package/dist/jmap-runtime.mjs.map +1 -0
- package/dist/jmap-settings-BXNAF1ep.d.mts +41 -0
- package/dist/jmap-settings-BXNAF1ep.d.mts.map +1 -0
- package/dist/jmap-settings.d.mts +2 -0
- package/dist/jmap-settings.mjs +104 -0
- package/dist/jmap-settings.mjs.map +1 -0
- package/dist/logging.d.mts +33 -0
- package/dist/logging.d.mts.map +1 -0
- package/dist/logging.mjs +56 -0
- package/dist/logging.mjs.map +1 -0
- package/dist/mail-parser-DyI4wuQp.d.mts +246 -0
- package/dist/mail-parser-DyI4wuQp.d.mts.map +1 -0
- package/dist/mail-parser.d.mts +2 -0
- package/dist/mail-parser.mjs +100 -0
- package/dist/mail-parser.mjs.map +1 -0
- package/dist/mail-runtime-YROIQ8up.mjs +314 -0
- package/dist/mail-runtime-YROIQ8up.mjs.map +1 -0
- package/dist/mail-runtime.d.mts +68 -0
- package/dist/mail-runtime.d.mts.map +1 -0
- package/dist/mail-runtime.mjs +2 -0
- package/dist/mail-settings-BD1TQ0rt.mjs +427 -0
- package/dist/mail-settings-BD1TQ0rt.mjs.map +1 -0
- package/dist/mail-settings-DjWMAUaE.d.mts +80 -0
- package/dist/mail-settings-DjWMAUaE.d.mts.map +1 -0
- package/dist/mail-settings.d.mts +2 -0
- package/dist/mail-settings.mjs +2 -0
- package/dist/operations.d.mts +32 -0
- package/dist/operations.d.mts.map +1 -0
- package/dist/operations.mjs +55 -0
- package/dist/operations.mjs.map +1 -0
- package/dist/package-7FOUqcPO.mjs +6 -0
- package/dist/package-7FOUqcPO.mjs.map +1 -0
- package/dist/parser-DGIQTgS7.mjs +178 -0
- package/dist/parser-DGIQTgS7.mjs.map +1 -0
- package/dist/parser-TANGHRjL.d.mts +305 -0
- package/dist/parser-TANGHRjL.d.mts.map +1 -0
- package/dist/postgres-settings.d.mts +20 -0
- package/dist/postgres-settings.d.mts.map +1 -0
- package/dist/postgres-settings.mjs +60 -0
- package/dist/postgres-settings.mjs.map +1 -0
- package/dist/query-logger.d.mts +9 -0
- package/dist/query-logger.d.mts.map +1 -0
- package/dist/query-logger.mjs +17 -0
- package/dist/query-logger.mjs.map +1 -0
- package/dist/resources.d.mts +20 -0
- package/dist/resources.d.mts.map +1 -0
- package/dist/resources.mjs +34 -0
- package/dist/resources.mjs.map +1 -0
- package/dist/secret-source-BeZx72Ue.d.mts +21 -0
- package/dist/secret-source-BeZx72Ue.d.mts.map +1 -0
- package/dist/secret-source.d.mts +2 -0
- package/dist/secret-source.mjs +58 -0
- package/dist/secret-source.mjs.map +1 -0
- package/dist/serving.d.mts +82 -0
- package/dist/serving.d.mts.map +1 -0
- package/dist/serving.mjs +138 -0
- package/dist/serving.mjs.map +1 -0
- package/dist/smtp-settings.d.mts +11 -0
- package/dist/smtp-settings.d.mts.map +1 -0
- package/dist/smtp-settings.mjs +38 -0
- package/dist/smtp-settings.mjs.map +1 -0
- package/dist/valueparser.d.mts +46 -0
- package/dist/valueparser.d.mts.map +1 -0
- package/dist/valueparser.mjs +121 -0
- package/dist/valueparser.mjs.map +1 -0
- package/package.json +275 -3
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { t as version } from "./package-7FOUqcPO.mjs";
|
|
2
|
+
import { createConfigurationBindings } from "./configuration.mjs";
|
|
3
|
+
import { describeServerConfiguration } from "./diagnostics.mjs";
|
|
4
|
+
import { OperationRegistry } from "./operations.mjs";
|
|
5
|
+
import { n as resolveOptions, r as valueOptionNames, t as createParser } from "./parser-DGIQTgS7.mjs";
|
|
6
|
+
import { ResourceOwner } from "./resources.mjs";
|
|
7
|
+
import { openDatabaseRuntime } from "./database-runtime.mjs";
|
|
8
|
+
import { n as prepareMail, t as createMailRuntime } from "./mail-runtime-YROIQ8up.mjs";
|
|
9
|
+
import { createControlSurface, createFetchHandler, getIngressMetadata, warnAboutStrandedInstances } from "./serving.mjs";
|
|
10
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
+
import { writeFile } from "node:fs/promises";
|
|
12
|
+
import process from "node:process";
|
|
13
|
+
import createFederation, { createInboundRecorder } from "@drfed/federation";
|
|
14
|
+
import { KeyGenerationQueue } from "@drfed/federation/task-queue";
|
|
15
|
+
import { createYogaServer } from "@drfed/graphql";
|
|
16
|
+
import { createWebRuntime } from "@drfed/web";
|
|
17
|
+
import { PgliteKvStore } from "@fedify/pglite";
|
|
18
|
+
import { PostgresKvStore } from "@fedify/postgres";
|
|
19
|
+
import { configure, dispose, getConsoleSink, getLogger } from "@logtape/logtape";
|
|
20
|
+
import { message, text } from "@optique/core/message";
|
|
21
|
+
import { createLoggingConfig } from "@optique/logtape";
|
|
22
|
+
import { printError, run } from "@optique/run";
|
|
23
|
+
import { serve } from "srvx";
|
|
24
|
+
import { multiple } from "@optique/core/modifiers";
|
|
25
|
+
import { string } from "@optique/core/valueparser";
|
|
26
|
+
import { object } from "@optique/core/constructs";
|
|
27
|
+
import { argument, option, passThrough } from "@optique/core/primitives";
|
|
28
|
+
import { parse } from "@optique/core/parser";
|
|
29
|
+
import { MigrationPreparationError, schema } from "@drfed/models";
|
|
30
|
+
//#region src/program.ts
|
|
31
|
+
/**
|
|
32
|
+
* Select operational vs schema bindings through a resource-free Optique pass.
|
|
33
|
+
* The final parser still strictly validates every token. This pass consumes no
|
|
34
|
+
* environment/config values and honors Optique's option terminator semantics.
|
|
35
|
+
* @returns The mode whose setting bindings the complete invocation needs.
|
|
36
|
+
*/
|
|
37
|
+
function selectInvocationMode(args) {
|
|
38
|
+
const [first, ...aliases] = Object.values(valueOptionNames).flat();
|
|
39
|
+
if (first === void 0) throw new Error("Missing CLI value-option definitions.");
|
|
40
|
+
const selected = parse(object({
|
|
41
|
+
schema: option("--generate-graphql-schema"),
|
|
42
|
+
optionValues: multiple(option(first, ...aliases, string())),
|
|
43
|
+
extra: passThrough({ format: "nextToken" }),
|
|
44
|
+
values: multiple(argument(string()))
|
|
45
|
+
}), args);
|
|
46
|
+
return selected.success && selected.value.schema ? "schema" : "server";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create independent CLI bindings for one invocation.
|
|
50
|
+
* @returns The program, its source contexts and explicit configuration loader.
|
|
51
|
+
*/
|
|
52
|
+
function createProgram(options = {}) {
|
|
53
|
+
const bindings = createConfigurationBindings(options);
|
|
54
|
+
const parser = createParser(bindings, options.mode);
|
|
55
|
+
return {
|
|
56
|
+
program: {
|
|
57
|
+
metadata: {
|
|
58
|
+
description: message`Run a DrFed server.`,
|
|
59
|
+
name: "drfed-server"
|
|
60
|
+
},
|
|
61
|
+
parser
|
|
62
|
+
},
|
|
63
|
+
contexts: bindings.contexts,
|
|
64
|
+
load: bindings.load
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/runtime-options.ts
|
|
69
|
+
/**
|
|
70
|
+
* Create resources only after the server command has been parsed successfully.
|
|
71
|
+
* @returns Runtime resources owned by the selected server command.
|
|
72
|
+
*/
|
|
73
|
+
async function createServerRuntime(options, owner, signal) {
|
|
74
|
+
const preparedMail = await prepareMail(options.mail, signal);
|
|
75
|
+
const database = await openDatabaseRuntime(options.drizzle, owner, options.drizzle.migrate ? "apply" : "inspect", signal);
|
|
76
|
+
if (database.state.status !== "ready") throw new MigrationPreparationError("incompatible-history", database.state);
|
|
77
|
+
if (signal?.aborted) throw new MigrationPreparationError("aborted");
|
|
78
|
+
const mail = createMailRuntime(preparedMail);
|
|
79
|
+
owner.register(mail, (runtime) => runtime.close(), { owned: true });
|
|
80
|
+
return {
|
|
81
|
+
...options,
|
|
82
|
+
drizzle: {
|
|
83
|
+
...database,
|
|
84
|
+
migrate: options.drizzle.migrate
|
|
85
|
+
},
|
|
86
|
+
mailer: mail.transport
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/seed.ts
|
|
91
|
+
async function seedData(db) {
|
|
92
|
+
await db.transaction(async (tx) => {
|
|
93
|
+
await seedAccounts(tx);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const sessionId = "00000000-0000-4000-8000-000000000000";
|
|
97
|
+
const accountId = "00000000-0000-4000-8000-000000000001";
|
|
98
|
+
const memberId = "00000000-0000-4000-8000-000000000002";
|
|
99
|
+
const pendingMemberId = "00000000-0000-4000-8000-000000000003";
|
|
100
|
+
const created = Temporal.Instant.from("2026-06-24T00:00:00.000Z");
|
|
101
|
+
const tokenHash = "dev-token-hash";
|
|
102
|
+
async function seedAccounts(db) {
|
|
103
|
+
await db.insert(schema.accounts).values([
|
|
104
|
+
{
|
|
105
|
+
id: accountId,
|
|
106
|
+
email: "owner@example.com",
|
|
107
|
+
name: "Owner",
|
|
108
|
+
created
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: memberId,
|
|
112
|
+
email: "member@example.com",
|
|
113
|
+
name: "Member",
|
|
114
|
+
created
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: pendingMemberId,
|
|
118
|
+
email: "pending@example.com",
|
|
119
|
+
name: "Pending",
|
|
120
|
+
created
|
|
121
|
+
}
|
|
122
|
+
]).onConflictDoNothing();
|
|
123
|
+
await db.insert(schema.sessions).values([{
|
|
124
|
+
id: sessionId,
|
|
125
|
+
accountId,
|
|
126
|
+
tokenHash
|
|
127
|
+
}]).onConflictDoUpdate({
|
|
128
|
+
target: schema.sessions.id,
|
|
129
|
+
set: { tokenHash }
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/index.ts
|
|
134
|
+
async function runServer(configuration) {
|
|
135
|
+
const owner = new ResourceOwner();
|
|
136
|
+
const operations = new OperationRegistry();
|
|
137
|
+
owner.register(null, () => dispose(), { owned: true });
|
|
138
|
+
let server;
|
|
139
|
+
let closing;
|
|
140
|
+
let signalled = false;
|
|
141
|
+
async function cleanup() {
|
|
142
|
+
operations.abort();
|
|
143
|
+
const errors = [];
|
|
144
|
+
let forced;
|
|
145
|
+
const forceTimer = setTimeout(() => {
|
|
146
|
+
if (server == null) return;
|
|
147
|
+
const currentServer = server;
|
|
148
|
+
forced = (async () => {
|
|
149
|
+
try {
|
|
150
|
+
await currentServer.close(true);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
errors.push(error);
|
|
153
|
+
}
|
|
154
|
+
})();
|
|
155
|
+
}, 5e3);
|
|
156
|
+
try {
|
|
157
|
+
const results = await Promise.allSettled([server?.close(), operations.drain()]);
|
|
158
|
+
for (const result of results) if (result.status === "rejected") errors.push(result.reason);
|
|
159
|
+
if (forced != null) await forced;
|
|
160
|
+
} finally {
|
|
161
|
+
clearTimeout(forceTimer);
|
|
162
|
+
try {
|
|
163
|
+
await owner.close();
|
|
164
|
+
} catch (error) {
|
|
165
|
+
errors.push(error);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (errors.length > 0) throw new AggregateError(errors, "Server cleanup failed.");
|
|
169
|
+
}
|
|
170
|
+
function stop() {
|
|
171
|
+
return closing ??= Promise.resolve().then(cleanup);
|
|
172
|
+
}
|
|
173
|
+
function shutdown() {
|
|
174
|
+
if (signalled) process.exit(1);
|
|
175
|
+
signalled = true;
|
|
176
|
+
const deadline = setTimeout(() => process.exit(1), 1e4);
|
|
177
|
+
stop().then(() => {
|
|
178
|
+
clearTimeout(deadline);
|
|
179
|
+
process.exit(0);
|
|
180
|
+
}, () => process.exit(1));
|
|
181
|
+
}
|
|
182
|
+
process.on("SIGINT", shutdown);
|
|
183
|
+
process.on("SIGTERM", shutdown);
|
|
184
|
+
try {
|
|
185
|
+
const options = await operations.run((signal) => createServerRuntime(configuration, owner, signal));
|
|
186
|
+
const { credentials, db } = options.drizzle;
|
|
187
|
+
if (options.seed) await operations.run(() => seedData(db));
|
|
188
|
+
const kv = "driver" in credentials ? new PgliteKvStore(credentials.client) : new PostgresKvStore(credentials.client);
|
|
189
|
+
const federation = await operations.run(() => createFederation(db, {
|
|
190
|
+
kv,
|
|
191
|
+
queue: { task: new KeyGenerationQueue() },
|
|
192
|
+
taskQueueResolution: "strict",
|
|
193
|
+
manuallyStartQueue: true,
|
|
194
|
+
allowPrivateAddress: true
|
|
195
|
+
}));
|
|
196
|
+
(async () => {
|
|
197
|
+
try {
|
|
198
|
+
await operations.run((signal) => federation.startQueue(void 0, {
|
|
199
|
+
queue: "task",
|
|
200
|
+
signal
|
|
201
|
+
}));
|
|
202
|
+
} catch {
|
|
203
|
+
if (!operations.signal.aborted) getLogger(["drfed", "server"]).error("Actor key worker stopped unexpectedly.");
|
|
204
|
+
}
|
|
205
|
+
})();
|
|
206
|
+
const { emailFrom, mailer, rootOrigin, loginOrigins } = options;
|
|
207
|
+
const yogaServer = createYogaServer(db, federation, {
|
|
208
|
+
rootOrigin,
|
|
209
|
+
emailFrom,
|
|
210
|
+
mailer,
|
|
211
|
+
loginOrigins,
|
|
212
|
+
trackOperation: (operation) => operations.track(operation),
|
|
213
|
+
shutdownSignal: operations.signal
|
|
214
|
+
});
|
|
215
|
+
await operations.run(() => warnAboutStrandedInstances(db, rootOrigin));
|
|
216
|
+
let web;
|
|
217
|
+
if (options.web) {
|
|
218
|
+
const { publicOrigin } = options;
|
|
219
|
+
if (publicOrigin === void 0) throw new Error("Missing public web origin.");
|
|
220
|
+
web = await operations.run(async (signal) => {
|
|
221
|
+
const runtime = owner.register(await createWebRuntime({
|
|
222
|
+
publicOrigin,
|
|
223
|
+
graphqlFetch: (request) => operations.track(() => yogaServer.fetch(request))
|
|
224
|
+
}), (resource) => resource.close(), { owned: true });
|
|
225
|
+
signal.throwIfAborted();
|
|
226
|
+
return runtime;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
const fetchHandler = createFetchHandler({
|
|
230
|
+
federation: createInboundRecorder({
|
|
231
|
+
db,
|
|
232
|
+
federation,
|
|
233
|
+
rootOrigin,
|
|
234
|
+
ingressMetadata: getIngressMetadata
|
|
235
|
+
}),
|
|
236
|
+
rootOrigin,
|
|
237
|
+
serveControlSurface: createControlSurface({
|
|
238
|
+
graphql: yogaServer.fetch,
|
|
239
|
+
...web === void 0 ? {} : { web: web.fetch }
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
const ownedServer = owner.register(serve({
|
|
243
|
+
async fetch(request) {
|
|
244
|
+
if (operations.signal.aborted) return new Response("Server is stopping.", { status: 503 });
|
|
245
|
+
try {
|
|
246
|
+
return await operations.run(() => fetchHandler(request));
|
|
247
|
+
} catch (error) {
|
|
248
|
+
if (operations.signal.aborted) return new Response("Server is stopping.", { status: 503 });
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
hostname: options.address.host,
|
|
253
|
+
manual: true,
|
|
254
|
+
gracefulShutdown: false,
|
|
255
|
+
port: options.address.port
|
|
256
|
+
}), (resource) => resource.close(true), { owned: true });
|
|
257
|
+
server = ownedServer;
|
|
258
|
+
await operations.run(async () => {
|
|
259
|
+
await ownedServer.serve();
|
|
260
|
+
});
|
|
261
|
+
if (options.publicOrigin !== void 0) getLogger(["drfed", "server"]).info("Web frontend is available at {origin}.", { origin: options.publicOrigin.origin });
|
|
262
|
+
} catch (error) {
|
|
263
|
+
process.off("SIGINT", shutdown);
|
|
264
|
+
process.off("SIGTERM", shutdown);
|
|
265
|
+
const deadline = Promise.withResolvers();
|
|
266
|
+
const timeout = setTimeout(() => deadline.reject(/* @__PURE__ */ new Error("Startup cleanup timed out.")), 1e4);
|
|
267
|
+
try {
|
|
268
|
+
await Promise.race([stop(), deadline.promise]);
|
|
269
|
+
} catch {
|
|
270
|
+
throw new Error("Database cleanup after startup failure failed.", { cause: error });
|
|
271
|
+
} finally {
|
|
272
|
+
clearTimeout(timeout);
|
|
273
|
+
}
|
|
274
|
+
throw new Error("Could not start the server.", { cause: error });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
async function runSchemaGenerator(options) {
|
|
278
|
+
const [{ schema }, { printSchema }] = await Promise.all([import("@drfed/graphql/schema"), import("graphql")]);
|
|
279
|
+
const schemaCode = printSchema(schema);
|
|
280
|
+
if (options.outputFile === "-") {
|
|
281
|
+
console.log(schemaCode);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
await writeFile(options.outputFile, schemaCode, { encoding: "utf-8" });
|
|
285
|
+
}
|
|
286
|
+
async function main() {
|
|
287
|
+
const invocation = createProgram({ mode: selectInvocationMode(process.argv.slice(2)) });
|
|
288
|
+
let options;
|
|
289
|
+
try {
|
|
290
|
+
options = resolveOptions(await run(invocation.program, {
|
|
291
|
+
contexts: invocation.contexts,
|
|
292
|
+
contextOptions: { load: (parsed) => parsed.mode[0] === "schema" ? void 0 : invocation.load(parsed) },
|
|
293
|
+
help: "option",
|
|
294
|
+
completion: "both",
|
|
295
|
+
showChoices: true,
|
|
296
|
+
showDefault: true,
|
|
297
|
+
version: {
|
|
298
|
+
option: true,
|
|
299
|
+
value: version
|
|
300
|
+
}
|
|
301
|
+
}));
|
|
302
|
+
} catch (error) {
|
|
303
|
+
printError([text(error instanceof Error ? error.message : "Could not resolve configuration.")]);
|
|
304
|
+
process.exitCode = 1;
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if ("generateGraphqlSchema" in options) {
|
|
308
|
+
await runSchemaGenerator(options);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (options.printConfig) {
|
|
312
|
+
console.log(JSON.stringify(describeServerConfiguration(options), null, 2));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
let loggingConfig;
|
|
316
|
+
try {
|
|
317
|
+
loggingConfig = await createLoggingConfig(options.logging, {}, {
|
|
318
|
+
contextLocalStorage: new AsyncLocalStorage(),
|
|
319
|
+
sinks: { stderr: getConsoleSink({ levelMap: {
|
|
320
|
+
trace: "error",
|
|
321
|
+
debug: "error",
|
|
322
|
+
info: "error",
|
|
323
|
+
warning: "error",
|
|
324
|
+
error: "error",
|
|
325
|
+
fatal: "error"
|
|
326
|
+
} }) },
|
|
327
|
+
loggers: [{
|
|
328
|
+
category: ["logtape", "meta"],
|
|
329
|
+
lowestLevel: "warning",
|
|
330
|
+
sinks: ["stderr"]
|
|
331
|
+
}]
|
|
332
|
+
});
|
|
333
|
+
} catch {
|
|
334
|
+
printError([text("Could not initialize logging; check the log output path.")]);
|
|
335
|
+
process.exitCode = 1;
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
await configure(loggingConfig);
|
|
339
|
+
await runServer(options);
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
export { main };
|
|
343
|
+
|
|
344
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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,YAA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ACd,WAAW,CACT,KACE,iBAAiB,QACb,MAAM,UACN,kCACN,CACF,CAAC;EACD,QAAQ,WAAW;EACnB;CACF;CACA,IAAI,2BAA2B,SAAS;EACtC,MAAM,mBAAmB,OAAO;EAChC;CACF;CACA,IAAI,QAAQ,aAAa;EACvB,QAAQ,IAAI,KAAK,UAAU,4BAA4B,OAAO,GAAG,MAAM,CAAC,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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { m as createConfigurationBindings, s as Sourced } from "./configuration-DVVF7xNv.mjs";
|
|
2
|
+
//#region src/jmap-parser.d.ts
|
|
3
|
+
/** JMAP value options also used by pure metadata argument handling. */
|
|
4
|
+
declare const jmapValueOptionNames: {
|
|
5
|
+
readonly jmapSessionUrl: readonly ["--jmap-session-url"];
|
|
6
|
+
readonly jmapBearerToken: readonly ["--jmap-bearer-token"];
|
|
7
|
+
readonly jmapBearerTokenFile: readonly ["--jmap-bearer-token-file"];
|
|
8
|
+
readonly jmapUser: readonly ["--jmap-user"];
|
|
9
|
+
readonly jmapPassword: readonly ["--jmap-password"];
|
|
10
|
+
readonly jmapPasswordFile: readonly ["--jmap-password-file"];
|
|
11
|
+
readonly jmapAccountId: readonly ["--jmap-account-id"];
|
|
12
|
+
readonly jmapIdentityId: readonly ["--jmap-identity-id"];
|
|
13
|
+
readonly jmapBaseUrl: readonly ["--jmap-base-url"];
|
|
14
|
+
readonly jmapTimeout: readonly ["--jmap-timeout"];
|
|
15
|
+
readonly jmapSessionCacheTtl: readonly ["--jmap-session-cache-ttl"];
|
|
16
|
+
};
|
|
17
|
+
/** Source-tagged fields; provider validation and file reads happen later.
|
|
18
|
+
* @returns Fields for composition into the common mail parser.
|
|
19
|
+
*/
|
|
20
|
+
declare function createJmapFields(bindings: ReturnType<typeof createConfigurationBindings>): {
|
|
21
|
+
jmapSessionUrl: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
22
|
+
jmapBearerToken: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
23
|
+
jmapBearerTokenFile: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
24
|
+
jmapUser: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
25
|
+
jmapPassword: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
26
|
+
jmapPasswordFile: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
27
|
+
jmapAccountId: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
28
|
+
jmapIdentityId: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
29
|
+
jmapBaseUrl: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
30
|
+
jmapTimeout: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
31
|
+
jmapSessionCacheTtl: import("@optique/core/modifiers").FluentParser<"sync", Sourced<string | undefined> | undefined, import("@optique/core/valueparser").ValueParserResult<string> | undefined>;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { createJmapFields, jmapValueOptionNames };
|
|
35
|
+
//# sourceMappingURL=jmap-parser.d.mts.map
|
|
@@ -0,0 +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,qBAHN,6EAGM;EAUd,mDAAe,qBAVD,6EAUC;EAUf,uDAAmB,qBAVJ,6EAUI;EAQnB,4CAAQ,qBARW,6EAQX;EAQR,gDAAY,qBARJ,6EAQI;EAUZ,oDAAgB,qBAVJ,6EAUI;EAQhB,iDAAa,qBARG,6EAQH;EAYb,kDAAc,qBAZD,6EAYC;EAYd,+CAAW,qBAZG,6EAYH;EAYX,+CAAW,qBAZA,6EAYA;EAUX,uDAAmB,qBAVR,6EAUQ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { configurationSettings } from "./configuration.mjs";
|
|
2
|
+
import { suggestedPath } from "./valueparser.mjs";
|
|
3
|
+
import { message } from "@optique/core/message";
|
|
4
|
+
import { string } from "@optique/core/valueparser";
|
|
5
|
+
import { option } from "@optique/core/primitives";
|
|
6
|
+
//#region src/jmap-parser.ts
|
|
7
|
+
/** JMAP value options also used by pure metadata argument handling. */
|
|
8
|
+
const jmapValueOptionNames = {
|
|
9
|
+
jmapSessionUrl: ["--jmap-session-url"],
|
|
10
|
+
jmapBearerToken: ["--jmap-bearer-token"],
|
|
11
|
+
jmapBearerTokenFile: ["--jmap-bearer-token-file"],
|
|
12
|
+
jmapUser: ["--jmap-user"],
|
|
13
|
+
jmapPassword: ["--jmap-password"],
|
|
14
|
+
jmapPasswordFile: ["--jmap-password-file"],
|
|
15
|
+
jmapAccountId: ["--jmap-account-id"],
|
|
16
|
+
jmapIdentityId: ["--jmap-identity-id"],
|
|
17
|
+
jmapBaseUrl: ["--jmap-base-url"],
|
|
18
|
+
jmapTimeout: ["--jmap-timeout"],
|
|
19
|
+
jmapSessionCacheTtl: ["--jmap-session-cache-ttl"]
|
|
20
|
+
};
|
|
21
|
+
/** Source-tagged fields; provider validation and file reads happen later.
|
|
22
|
+
* @returns Fields for composition into the common mail parser.
|
|
23
|
+
*/
|
|
24
|
+
function createJmapFields(bindings) {
|
|
25
|
+
return {
|
|
26
|
+
jmapSessionUrl: bindings.bind(option(...jmapValueOptionNames.jmapSessionUrl, string({ metavar: "VALUE" }), { description: message`JMAP session discovery URL.` }), configurationSettings.jmapSessionUrl, string(), String),
|
|
27
|
+
jmapBearerToken: bindings.bind(option(...jmapValueOptionNames.jmapBearerToken, string({ metavar: "VALUE" }), { description: message`JMAP bearer token.` }), configurationSettings.jmapBearerToken, string(), String),
|
|
28
|
+
jmapBearerTokenFile: bindings.bind(option(...jmapValueOptionNames.jmapBearerTokenFile, suggestedPath(), { description: message`File containing the JMAP bearer token.` }), configurationSettings.jmapBearerTokenFile, string(), String),
|
|
29
|
+
jmapUser: bindings.bind(option(...jmapValueOptionNames.jmapUser, string({ metavar: "VALUE" }), { description: message`JMAP basic authentication username.` }), configurationSettings.jmapUser, string(), String),
|
|
30
|
+
jmapPassword: bindings.bind(option(...jmapValueOptionNames.jmapPassword, string({ metavar: "VALUE" }), { description: message`JMAP basic authentication password.` }), configurationSettings.jmapPassword, string(), String),
|
|
31
|
+
jmapPasswordFile: bindings.bind(option(...jmapValueOptionNames.jmapPasswordFile, suggestedPath(), { description: message`File containing the JMAP password.` }), configurationSettings.jmapPasswordFile, string(), String),
|
|
32
|
+
jmapAccountId: bindings.bind(option(...jmapValueOptionNames.jmapAccountId, string({ metavar: "VALUE" }), { description: message`JMAP account ID; automatically discovered when absent.` }), configurationSettings.jmapAccountId, string(), String),
|
|
33
|
+
jmapIdentityId: bindings.bind(option(...jmapValueOptionNames.jmapIdentityId, string({ metavar: "VALUE" }), { description: message`JMAP sender identity ID; automatically discovered when absent.` }), configurationSettings.jmapIdentityId, string(), String),
|
|
34
|
+
jmapBaseUrl: bindings.bind(option(...jmapValueOptionNames.jmapBaseUrl, string({ metavar: "VALUE" }), { description: message`JMAP base origin for rewriting discovered endpoints.` }), configurationSettings.jmapBaseUrl, string(), String),
|
|
35
|
+
jmapTimeout: bindings.bind(option(...jmapValueOptionNames.jmapTimeout, string({ metavar: "VALUE" }), { description: message`JMAP HTTP request timeout in milliseconds.` }), configurationSettings.jmapTimeout, string(), String),
|
|
36
|
+
jmapSessionCacheTtl: bindings.bind(option(...jmapValueOptionNames.jmapSessionCacheTtl, string({ metavar: "VALUE" }), { description: message`JMAP session cache lifetime in milliseconds.` }), configurationSettings.jmapSessionCacheTtl, string(), String)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { createJmapFields, jmapValueOptionNames };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=jmap-parser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jmap-parser.mjs","names":["settings"],"sources":["../src/jmap-parser.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 { message } from \"@optique/core/message\";\nimport { option } from \"@optique/core/primitives\";\nimport { string } from \"@optique/core/valueparser\";\n\nimport {\n type createConfigurationBindings,\n configurationSettings as settings,\n} from \"./configuration.ts\";\nimport { suggestedPath } from \"./valueparser.ts\";\n\n/** JMAP value options also used by pure metadata argument handling. */\nexport const jmapValueOptionNames = {\n jmapSessionUrl: [\"--jmap-session-url\"],\n jmapBearerToken: [\"--jmap-bearer-token\"],\n jmapBearerTokenFile: [\"--jmap-bearer-token-file\"],\n jmapUser: [\"--jmap-user\"],\n jmapPassword: [\"--jmap-password\"],\n jmapPasswordFile: [\"--jmap-password-file\"],\n jmapAccountId: [\"--jmap-account-id\"],\n jmapIdentityId: [\"--jmap-identity-id\"],\n jmapBaseUrl: [\"--jmap-base-url\"],\n jmapTimeout: [\"--jmap-timeout\"],\n jmapSessionCacheTtl: [\"--jmap-session-cache-ttl\"],\n} as const;\n\n/** Source-tagged fields; provider validation and file reads happen later.\n * @returns Fields for composition into the common mail parser.\n */\nexport function createJmapFields(\n bindings: ReturnType<typeof createConfigurationBindings>,\n) {\n return {\n jmapSessionUrl: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapSessionUrl,\n string({ metavar: \"VALUE\" }),\n { description: message`JMAP session discovery URL.` },\n ),\n settings.jmapSessionUrl,\n string(),\n String,\n ),\n jmapBearerToken: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapBearerToken,\n string({ metavar: \"VALUE\" }),\n { description: message`JMAP bearer token.` },\n ),\n settings.jmapBearerToken,\n string(),\n String,\n ),\n jmapBearerTokenFile: bindings.bind(\n option(...jmapValueOptionNames.jmapBearerTokenFile, suggestedPath(), {\n description: message`File containing the JMAP bearer token.`,\n }),\n settings.jmapBearerTokenFile,\n string(),\n String,\n ),\n jmapUser: bindings.bind(\n option(...jmapValueOptionNames.jmapUser, string({ metavar: \"VALUE\" }), {\n description: message`JMAP basic authentication username.`,\n }),\n settings.jmapUser,\n string(),\n String,\n ),\n jmapPassword: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapPassword,\n string({ metavar: \"VALUE\" }),\n { description: message`JMAP basic authentication password.` },\n ),\n settings.jmapPassword,\n string(),\n String,\n ),\n jmapPasswordFile: bindings.bind(\n option(...jmapValueOptionNames.jmapPasswordFile, suggestedPath(), {\n description: message`File containing the JMAP password.`,\n }),\n settings.jmapPasswordFile,\n string(),\n String,\n ),\n jmapAccountId: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapAccountId,\n string({ metavar: \"VALUE\" }),\n {\n description: message`JMAP account ID; automatically discovered when absent.`,\n },\n ),\n settings.jmapAccountId,\n string(),\n String,\n ),\n jmapIdentityId: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapIdentityId,\n string({ metavar: \"VALUE\" }),\n {\n description: message`JMAP sender identity ID; automatically discovered when absent.`,\n },\n ),\n settings.jmapIdentityId,\n string(),\n String,\n ),\n jmapBaseUrl: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapBaseUrl,\n string({ metavar: \"VALUE\" }),\n {\n description: message`JMAP base origin for rewriting discovered endpoints.`,\n },\n ),\n settings.jmapBaseUrl,\n string(),\n String,\n ),\n jmapTimeout: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapTimeout,\n string({ metavar: \"VALUE\" }),\n { description: message`JMAP HTTP request timeout in milliseconds.` },\n ),\n settings.jmapTimeout,\n string(),\n String,\n ),\n jmapSessionCacheTtl: bindings.bind(\n option(\n ...jmapValueOptionNames.jmapSessionCacheTtl,\n string({ metavar: \"VALUE\" }),\n { description: message`JMAP session cache lifetime in milliseconds.` },\n ),\n settings.jmapSessionCacheTtl,\n string(),\n String,\n ),\n };\n}\n"],"mappings":";;;;;;;AA2BA,MAAa,uBAAuB;CAClC,gBAAgB,CAAC,oBAA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tB,OACE,GAAG,qBAAqB,eACxB,OAAO,EAAE,SAAS,QAAQ,CAAC,GAC3B,EACE,aAAa,OAAO,yDACtB,CACF,GACAA,sBAAS,eACT,OAAO,GACP,MACF;EACA,gBAAgB,SAAS,KACvB,OACE,GAAG,qBAAqB,gBACxB,OAAO,EAAE,SAAS,QAAQ,CAAC,GAC3B,EACE,aAAa,OAAO,iEACtB,CACF,GACAA,sBAAS,gBACT,OAAO,GACP,MACF;EACA,aAAa,SAAS,KACpB,OACE,GAAG,qBAAqB,aACxB,OAAO,EAAE,SAAS,QAAQ,CAAC,GAC3B,EACE,aAAa,OAAO,uDACtB,CACF,GACAA,sBAAS,aACT,OAAO,GACP,MACF;EACA,aAAa,SAAS,KACpB,OACE,GAAG,qBAAqB,aACxB,OAAO,EAAE,SAAS,QAAQ,CAAC,GAC3B,EAAE,aAAa,OAAO,6CAA6C,CACrE,GACAA,sBAAS,aACT,OAAO,GACP,MACF;EACA,qBAAqB,SAAS,KAC5B,OACE,GAAG,qBAAqB,qBACxB,OAAO,EAAE,SAAS,QAAQ,CAAC,GAC3B,EAAE,aAAa,OAAO,+CAA+C,CACvE,GACAA,sBAAS,qBACT,OAAO,GACP,MACF;CACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Transport } from "@upyo/core";
|
|
2
|
+
import { JmapConfig } from "@upyo/jmap";
|
|
3
|
+
//#region src/jmap-runtime.d.ts
|
|
4
|
+
/** Bound JMAP delivery and prevent replaying uncertain submissions.
|
|
5
|
+
* @returns An owned transport with whole-send deadlines and draining cleanup.
|
|
6
|
+
*/
|
|
7
|
+
declare function createJmapTransport(config: JmapConfig): Transport<"jmap"> & AsyncDisposable;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createJmapTransport };
|
|
10
|
+
//# sourceMappingURL=jmap-runtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jmap-runtime.d.mts","names":[],"sources":["../src/jmap-runtime.ts"],"mappings":";;;;;;iBAwBgB,oBACd,QAAQ,aACP,oBAAoB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createBoundedTransport } from "./bounded-mail-runtime.mjs";
|
|
2
|
+
import "@upyo/core";
|
|
3
|
+
import { JmapTransport } from "@upyo/jmap";
|
|
4
|
+
//#region src/jmap-runtime.ts
|
|
5
|
+
/** Bound JMAP delivery and prevent replaying uncertain submissions.
|
|
6
|
+
* @returns An owned transport with whole-send deadlines and draining cleanup.
|
|
7
|
+
*/
|
|
8
|
+
function createJmapTransport(config) {
|
|
9
|
+
return createBoundedTransport(new JmapTransport({
|
|
10
|
+
...config,
|
|
11
|
+
retries: 0
|
|
12
|
+
}), config.timeout ?? 3e4, "JMAP");
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { createJmapTransport };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=jmap-runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jmap-runtime.mjs","names":[],"sources":["../src/jmap-runtime.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 { type Transport } from \"@upyo/core\";\nimport { type JmapConfig, JmapTransport } from \"@upyo/jmap\";\n\nimport { createBoundedTransport } from \"./bounded-mail-runtime.ts\";\n\n/** Bound JMAP delivery and prevent replaying uncertain submissions.\n * @returns An owned transport with whole-send deadlines and draining cleanup.\n */\nexport function createJmapTransport(\n config: JmapConfig,\n): Transport<\"jmap\"> & AsyncDisposable {\n return createBoundedTransport(\n new JmapTransport({ ...config, retries: 0 }),\n config.timeout ?? 30_000,\n \"JMAP\",\n );\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,oBACd,QACqC;CACrC,OAAO,uBACL,IAAI,cAAc;EAAE,GAAG;EAAQ,SAAS;CAAE,CAAC,GAC3C,OAAO,WAAW,KAClB,MACF;AACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { s as Sourced } from "./configuration-DVVF7xNv.mjs";
|
|
2
|
+
import { t as RawMailOptions } from "./mail-parser-DyI4wuQp.mjs";
|
|
3
|
+
import { t as SecretSource } from "./secret-source-BeZx72Ue.mjs";
|
|
4
|
+
import { JmapConfig } from "@upyo/jmap";
|
|
5
|
+
//#region src/jmap-settings.d.ts
|
|
6
|
+
/** JMAP connection with selected but unopened credential files. */
|
|
7
|
+
interface JmapSettings {
|
|
8
|
+
readonly transport: "jmap";
|
|
9
|
+
readonly connection: Omit<JmapConfig, "bearerToken" | "basicAuth" | "headers">;
|
|
10
|
+
readonly authentication: {
|
|
11
|
+
readonly type: "bearer" | "basic";
|
|
12
|
+
readonly secret: SecretSource;
|
|
13
|
+
readonly user?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Validate credentials without including their contents in error messages. */
|
|
17
|
+
declare function validateJmapCredential(type: "bearer" | "basic", credential: string, user?: string): void;
|
|
18
|
+
/** Resolve only the selected JMAP branch, retaining safe source metadata.
|
|
19
|
+
* @returns Provider settings and safe diagnostic values/source tags.
|
|
20
|
+
*/
|
|
21
|
+
declare function resolveJmapSettings(raw: RawMailOptions, cwd: string): {
|
|
22
|
+
mail: JmapSettings;
|
|
23
|
+
values: {
|
|
24
|
+
jmapSessionUrl: string;
|
|
25
|
+
jmapBaseUrl: string | undefined;
|
|
26
|
+
jmapAccountId: string | undefined;
|
|
27
|
+
jmapIdentityId: string | undefined;
|
|
28
|
+
jmapTimeout: number;
|
|
29
|
+
jmapSessionCacheTtl: number;
|
|
30
|
+
};
|
|
31
|
+
sources: {
|
|
32
|
+
jmapUser: Sourced<string | undefined> | undefined;
|
|
33
|
+
jmapBearerToken: Sourced<string | undefined> | undefined;
|
|
34
|
+
jmapBearerTokenFile: Sourced<string | undefined> | undefined;
|
|
35
|
+
jmapPassword: Sourced<string | undefined> | undefined;
|
|
36
|
+
jmapPasswordFile: Sourced<string | undefined> | undefined;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { resolveJmapSettings as n, validateJmapCredential as r, JmapSettings as t };
|
|
41
|
+
//# sourceMappingURL=jmap-settings-BXNAF1ep.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jmap-settings-BXNAF1ep.d.mts","names":[],"sources":["../src/jmap-settings.ts"],"mappings":";;;;;;UAuBiB;WACN;WACA,YAAY,KACnB;WAGO;aACE;aACA,QAAQ;aACR;;;;iBAyDG,uBACd,0BACA,oBACA;;;;iBAgFc,oBAAoB,KAAK,gBAAgB"}
|