@drfed/drfed 0.0.0-stage → 0.1.0-dev.561
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-D1pbtLwn.mjs +6 -0
- package/dist/package-D1pbtLwn.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 +287 -3
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { m as createConfigurationBindings, o as ConfigurationSource, r as ConfigurationFile, s as Sourced } from "../configuration-DVVF7xNv.mjs";
|
|
2
|
+
import { InferValue } from "@optique/core/parser";
|
|
3
|
+
//#region src/commands/migrate-program.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Construct an independent database-only command using shared source bindings.
|
|
6
|
+
* @returns Pure program metadata, contexts and the explicit TOML loader.
|
|
7
|
+
*/
|
|
8
|
+
declare function createMigrationProgram(options?: Parameters<typeof createConfigurationBindings>[0]): {
|
|
9
|
+
program: {
|
|
10
|
+
metadata: {
|
|
11
|
+
name: string;
|
|
12
|
+
description: import("@optique/core/message").Message;
|
|
13
|
+
};
|
|
14
|
+
parser: import("@optique/core/modifiers").FluentParser<"sync", {
|
|
15
|
+
readonly configPath: Sourced<string> | undefined;
|
|
16
|
+
readonly dataPath: Sourced<string | undefined> | undefined;
|
|
17
|
+
readonly postgresUrl: Sourced<string | undefined> | undefined;
|
|
18
|
+
readonly migrationLockTimeout: Sourced<number | undefined> | undefined;
|
|
19
|
+
readonly check: boolean;
|
|
20
|
+
readonly printConfig: boolean;
|
|
21
|
+
}, {
|
|
22
|
+
readonly configPath: [import("@optique/core/valueparser").ValueParserResult<string> | undefined] | undefined;
|
|
23
|
+
readonly dataPath: import("@optique/core/valueparser").ValueParserResult<string> | undefined;
|
|
24
|
+
readonly postgresUrl: import("@optique/core/valueparser").ValueParserResult<URL> | undefined;
|
|
25
|
+
readonly migrationLockTimeout: import("@optique/core/valueparser").ValueParserResult<number> | undefined;
|
|
26
|
+
readonly check: [import("@optique/core/valueparser").ValueParserResult<true> | undefined] | undefined;
|
|
27
|
+
readonly printConfig: [import("@optique/core/valueparser").ValueParserResult<true> | undefined] | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
contexts: readonly [import("@optique/env").EnvContext, import("@optique/config").ConfigContext<{
|
|
31
|
+
server?: {
|
|
32
|
+
root_origin?: string | undefined;
|
|
33
|
+
listen?: string | undefined;
|
|
34
|
+
login_origins?: string[] | undefined;
|
|
35
|
+
web?: boolean | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
web?: {
|
|
38
|
+
public_origin?: string | undefined;
|
|
39
|
+
listen?: string | undefined;
|
|
40
|
+
backend_url?: string | undefined;
|
|
41
|
+
allow_insecure_backend?: boolean | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
database?: {
|
|
44
|
+
data_path?: string | undefined;
|
|
45
|
+
url?: string | undefined;
|
|
46
|
+
migrate?: boolean | undefined;
|
|
47
|
+
lock_timeout_ms?: number | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
telemetry?: {
|
|
50
|
+
log_level?: string | undefined;
|
|
51
|
+
log_format?: string | undefined;
|
|
52
|
+
log_output?: string | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
mail?: {
|
|
55
|
+
from?: string | undefined;
|
|
56
|
+
transport?: string | undefined;
|
|
57
|
+
api_key?: string | undefined;
|
|
58
|
+
api_key_file?: string | undefined;
|
|
59
|
+
plunk?: {
|
|
60
|
+
api_key?: string | undefined;
|
|
61
|
+
api_key_file?: string | undefined;
|
|
62
|
+
base_url?: string | undefined;
|
|
63
|
+
timeout_ms?: number | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
resend?: {
|
|
66
|
+
api_key?: string | undefined;
|
|
67
|
+
api_key_file?: string | undefined;
|
|
68
|
+
base_url?: string | undefined;
|
|
69
|
+
timeout_ms?: number | undefined;
|
|
70
|
+
retries?: number | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
ses?: {
|
|
73
|
+
auth?: string | undefined;
|
|
74
|
+
access_key_id?: string | undefined;
|
|
75
|
+
access_key_id_file?: string | undefined;
|
|
76
|
+
secret_access_key?: string | undefined;
|
|
77
|
+
secret_access_key_file?: string | undefined;
|
|
78
|
+
session_token?: string | undefined;
|
|
79
|
+
session_token_file?: string | undefined;
|
|
80
|
+
region?: string | undefined;
|
|
81
|
+
timeout_ms?: number | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
sendgrid?: {
|
|
84
|
+
api_key?: string | undefined;
|
|
85
|
+
api_key_file?: string | undefined;
|
|
86
|
+
base_url?: string | undefined;
|
|
87
|
+
timeout_ms?: number | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
mailgun?: {
|
|
90
|
+
api_key?: string | undefined;
|
|
91
|
+
api_key_file?: string | undefined;
|
|
92
|
+
domain?: string | undefined;
|
|
93
|
+
region?: string | undefined;
|
|
94
|
+
base_url?: string | undefined;
|
|
95
|
+
timeout_ms?: number | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
mailtrap?: {
|
|
98
|
+
api_token?: string | undefined;
|
|
99
|
+
api_token_file?: string | undefined;
|
|
100
|
+
sandbox?: boolean | undefined;
|
|
101
|
+
inbox_id?: string | undefined;
|
|
102
|
+
send_base_url?: string | undefined;
|
|
103
|
+
sandbox_base_url?: string | undefined;
|
|
104
|
+
timeout_ms?: number | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
maileroo?: {
|
|
107
|
+
api_key?: string | undefined;
|
|
108
|
+
api_key_file?: string | undefined;
|
|
109
|
+
base_url?: string | undefined;
|
|
110
|
+
timeout_ms?: number | undefined;
|
|
111
|
+
} | undefined;
|
|
112
|
+
lettermint?: {
|
|
113
|
+
api_token?: string | undefined;
|
|
114
|
+
api_token_file?: string | undefined;
|
|
115
|
+
base_url?: string | undefined;
|
|
116
|
+
route?: string | undefined;
|
|
117
|
+
timeout_ms?: number | undefined;
|
|
118
|
+
retries?: number | undefined;
|
|
119
|
+
} | undefined;
|
|
120
|
+
jmap?: {
|
|
121
|
+
session_url?: string | undefined;
|
|
122
|
+
bearer_token?: string | undefined;
|
|
123
|
+
bearer_token_file?: string | undefined;
|
|
124
|
+
user?: string | undefined;
|
|
125
|
+
password?: string | undefined;
|
|
126
|
+
password_file?: string | undefined;
|
|
127
|
+
account_id?: string | undefined;
|
|
128
|
+
identity_id?: string | undefined;
|
|
129
|
+
base_url?: string | undefined;
|
|
130
|
+
timeout_ms?: number | undefined;
|
|
131
|
+
session_cache_ttl_ms?: number | undefined;
|
|
132
|
+
} | undefined;
|
|
133
|
+
smtp?: {
|
|
134
|
+
url?: string | undefined;
|
|
135
|
+
host?: string | undefined;
|
|
136
|
+
port?: number | undefined;
|
|
137
|
+
tls?: string | undefined;
|
|
138
|
+
user?: string | undefined;
|
|
139
|
+
password?: string | undefined;
|
|
140
|
+
password_file?: string | undefined;
|
|
141
|
+
auth_method?: string | undefined;
|
|
142
|
+
access_token?: string | undefined;
|
|
143
|
+
access_token_file?: string | undefined;
|
|
144
|
+
connection_timeout_ms?: number | undefined;
|
|
145
|
+
socket_timeout_ms?: number | undefined;
|
|
146
|
+
pool_size?: number | undefined;
|
|
147
|
+
local_name?: string | undefined;
|
|
148
|
+
ca_file?: string | undefined;
|
|
149
|
+
cert_file?: string | undefined;
|
|
150
|
+
key_file?: string | undefined;
|
|
151
|
+
} | undefined;
|
|
152
|
+
log_content?: boolean | undefined;
|
|
153
|
+
} | undefined;
|
|
154
|
+
}, import("@optique/config").ConfigMeta>];
|
|
155
|
+
load: (parsed: {
|
|
156
|
+
readonly configPath?: Sourced<string> | undefined;
|
|
157
|
+
}) => Promise<{
|
|
158
|
+
config: ConfigurationFile;
|
|
159
|
+
meta: import("@optique/config").ConfigMeta;
|
|
160
|
+
} | undefined>;
|
|
161
|
+
};
|
|
162
|
+
type RawMigrationOptions = InferValue<ReturnType<typeof createMigrationProgram>["program"]["parser"]>;
|
|
163
|
+
/**
|
|
164
|
+
* Select the winning database and retain source-only diagnostic metadata.
|
|
165
|
+
* @returns Validated command settings without acquiring runtime resources.
|
|
166
|
+
*/
|
|
167
|
+
declare function resolveMigrationOptions(raw: RawMigrationOptions, cwd?: string): {
|
|
168
|
+
database: {
|
|
169
|
+
driver: "postgres";
|
|
170
|
+
databaseUrl: URL;
|
|
171
|
+
dataPath?: never;
|
|
172
|
+
lockTimeoutMs: number;
|
|
173
|
+
} | {
|
|
174
|
+
databaseUrl?: never;
|
|
175
|
+
driver: "pglite";
|
|
176
|
+
dataPath: string;
|
|
177
|
+
lockTimeoutMs: number;
|
|
178
|
+
};
|
|
179
|
+
check: boolean;
|
|
180
|
+
printConfig: boolean;
|
|
181
|
+
ignored: {
|
|
182
|
+
field: string;
|
|
183
|
+
source: ConfigurationSource;
|
|
184
|
+
}[];
|
|
185
|
+
provenance: {
|
|
186
|
+
[k: string]: {
|
|
187
|
+
source: ConfigurationSource;
|
|
188
|
+
configPath?: string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Describe database-only settings and their sources without opening resources.
|
|
194
|
+
* @returns Redacted settings and ignored configuration areas for diagnostics.
|
|
195
|
+
*/
|
|
196
|
+
declare function describeMigrationConfiguration(options: ReturnType<typeof resolveMigrationOptions>): {
|
|
197
|
+
command: "migrate";
|
|
198
|
+
mode: string;
|
|
199
|
+
settings: {
|
|
200
|
+
[k: string]: {
|
|
201
|
+
source: ConfigurationSource;
|
|
202
|
+
configPath?: string;
|
|
203
|
+
value: string | number | undefined;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
ignored: ({
|
|
207
|
+
field: string;
|
|
208
|
+
source: ConfigurationSource;
|
|
209
|
+
} | {
|
|
210
|
+
field: string;
|
|
211
|
+
reason: string;
|
|
212
|
+
} | {
|
|
213
|
+
area: "database" | "mail" | "server" | "telemetry" | "web";
|
|
214
|
+
reason: string;
|
|
215
|
+
})[];
|
|
216
|
+
};
|
|
217
|
+
//#endregion
|
|
218
|
+
export { createMigrationProgram, describeMigrationConfiguration, resolveMigrationOptions };
|
|
219
|
+
//# sourceMappingURL=migrate-program.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-program.d.mts","names":[],"sources":["../../src/commands/migrate-program.ts"],"mappings":";;;;;;;iBAqCgB,uBACd,UAAS,kBAAkB;;;MAqErB;MACA,6CAAW;;;2BAtER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+EN,sBAAsB,WACzB,kBAAkB;;;;;iBAOJ,wBACd,KAAK,qBACL;EAcE;;;;;;;;;;;EACA;EACA;EACA;;;;EACA;;;;;;;;;;;iBAYY,+BACd,SAAS,kBAAkB;EAkBhB;;;;cAlBF"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { configurationProjection, configurationProvenance, configurationSettings, createConfigurationBindings } from "../configuration.mjs";
|
|
2
|
+
import { resolveDatabaseSettings } from "../database-settings.mjs";
|
|
3
|
+
import { r as valueOptionNames } from "../parser-DGIQTgS7.mjs";
|
|
4
|
+
import { message } from "@optique/core/message";
|
|
5
|
+
import { map, optional, withDefault } from "@optique/core/modifiers";
|
|
6
|
+
import { integer, string, url } from "@optique/core/valueparser";
|
|
7
|
+
import { object } from "@optique/core/constructs";
|
|
8
|
+
import { flag, option } from "@optique/core/primitives";
|
|
9
|
+
import { path } from "@optique/run/valueparser";
|
|
10
|
+
//#region src/commands/migrate-program.ts
|
|
11
|
+
/**
|
|
12
|
+
* Construct an independent database-only command using shared source bindings.
|
|
13
|
+
* @returns Pure program metadata, contexts and the explicit TOML loader.
|
|
14
|
+
*/
|
|
15
|
+
function createMigrationProgram(options = {}) {
|
|
16
|
+
const bindings = createConfigurationBindings(options);
|
|
17
|
+
const { bind } = bindings;
|
|
18
|
+
const lockTimeout = integer({
|
|
19
|
+
min: 1,
|
|
20
|
+
max: 2147483647,
|
|
21
|
+
metavar: "MILLISECONDS"
|
|
22
|
+
});
|
|
23
|
+
const parser = object({
|
|
24
|
+
configPath: optional(bindings.bindConfigPath(option("--config", path({
|
|
25
|
+
metavar: "FILE",
|
|
26
|
+
type: "file"
|
|
27
|
+
}), { description: message`Read the shared DrFed TOML configuration file.` }))),
|
|
28
|
+
dataPath: bind(option(...valueOptionNames.dataPath, path({
|
|
29
|
+
metavar: "DIRECTORY",
|
|
30
|
+
type: "directory"
|
|
31
|
+
}), { description: message`Persistent PGlite directory; defaults to the OS data location.` }), configurationSettings.dataPath, string(), String),
|
|
32
|
+
postgresUrl: bind(map(option(...valueOptionNames.postgresUrl, url({ allowedProtocols: ["postgres:", "postgresql:"] }), { description: message`PostgreSQL connection URL.` }), (value) => value.href), configurationSettings.postgresUrl, string(), String),
|
|
33
|
+
migrationLockTimeout: bind(option(...valueOptionNames.migrationLockTimeout, lockTimeout, { description: message`Maximum connection and migration lock wait in milliseconds.` }), configurationSettings.migrationLockTimeout, lockTimeout, String, 3e4),
|
|
34
|
+
check: withDefault(flag("--check", { description: message`Inspect history without applying SQL or upgrading metadata. Exit 0 when ready, or 1 when preparation is needed or an error occurs.` }), false),
|
|
35
|
+
printConfig: withDefault(flag("--print-config", { description: message`Print effective settings and provenance with credentials redacted, then exit without opening runtime resources.` }), false)
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
program: {
|
|
39
|
+
metadata: {
|
|
40
|
+
name: "drfed-migrate",
|
|
41
|
+
description: message`Prepare the DrFed database or inspect migration history.`
|
|
42
|
+
},
|
|
43
|
+
parser
|
|
44
|
+
},
|
|
45
|
+
contexts: bindings.contexts,
|
|
46
|
+
load: bindings.load
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Select the winning database and retain source-only diagnostic metadata.
|
|
51
|
+
* @returns Validated command settings without acquiring runtime resources.
|
|
52
|
+
*/
|
|
53
|
+
function resolveMigrationOptions(raw, cwd = process.cwd()) {
|
|
54
|
+
const selected = resolveDatabaseSettings({
|
|
55
|
+
dataPath: raw.dataPath,
|
|
56
|
+
postgresUrl: raw.postgresUrl
|
|
57
|
+
}, cwd);
|
|
58
|
+
const lockTimeoutMs = raw.migrationLockTimeout?.value;
|
|
59
|
+
if (lockTimeoutMs === void 0) throw new Error("Missing migration lock timeout.");
|
|
60
|
+
return {
|
|
61
|
+
database: {
|
|
62
|
+
...selected.database,
|
|
63
|
+
lockTimeoutMs
|
|
64
|
+
},
|
|
65
|
+
check: raw.check,
|
|
66
|
+
printConfig: raw.printConfig,
|
|
67
|
+
ignored: selected.ignored,
|
|
68
|
+
provenance: configurationProvenance({
|
|
69
|
+
dataPath: raw.dataPath,
|
|
70
|
+
postgresUrl: raw.postgresUrl,
|
|
71
|
+
migrationLockTimeout: raw.migrationLockTimeout
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Describe database-only settings and their sources without opening resources.
|
|
77
|
+
* @returns Redacted settings and ignored configuration areas for diagnostics.
|
|
78
|
+
*/
|
|
79
|
+
function describeMigrationConfiguration(options) {
|
|
80
|
+
const values = {
|
|
81
|
+
databaseDriver: options.database.driver,
|
|
82
|
+
dataPath: options.database.driver === "pglite" ? options.database.dataPath : void 0,
|
|
83
|
+
postgresUrl: options.database.driver === "postgres" ? "<redacted>" : void 0,
|
|
84
|
+
migrationLockTimeout: options.database.lockTimeoutMs
|
|
85
|
+
};
|
|
86
|
+
const rank = {
|
|
87
|
+
default: 0,
|
|
88
|
+
config: 1,
|
|
89
|
+
env: 2,
|
|
90
|
+
cli: 3
|
|
91
|
+
};
|
|
92
|
+
const selected = ["dataPath", "postgresUrl"].map((key) => options.provenance[key]).filter((value) => value !== void 0).sort((left, right) => rank[right.source] - rank[left.source])[0];
|
|
93
|
+
return {
|
|
94
|
+
command: "migrate",
|
|
95
|
+
mode: options.check ? "check" : "apply",
|
|
96
|
+
settings: Object.fromEntries(Object.entries(values).filter(([, value]) => value !== void 0).map(([key, value]) => [key === "databaseDriver" ? "database.driver" : configurationSettings[key].toml, {
|
|
97
|
+
value,
|
|
98
|
+
...(key === "databaseDriver" ? selected : options.provenance[key]) ?? { source: "default" }
|
|
99
|
+
}])),
|
|
100
|
+
ignored: [
|
|
101
|
+
...options.ignored,
|
|
102
|
+
{
|
|
103
|
+
field: "database.migrate",
|
|
104
|
+
reason: "explicit apply/check mode"
|
|
105
|
+
},
|
|
106
|
+
...configurationProjection("migrate").unusedAreas.map((area) => ({
|
|
107
|
+
area,
|
|
108
|
+
reason: "unused by this command"
|
|
109
|
+
}))
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export { createMigrationProgram, describeMigrationConfiguration, resolveMigrationOptions };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=migrate-program.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-program.mjs","names":["settings"],"sources":["../../src/commands/migrate-program.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 { object } from \"@optique/core/constructs\";\nimport { message } from \"@optique/core/message\";\nimport { map, optional, withDefault } from \"@optique/core/modifiers\";\nimport type { InferValue } from \"@optique/core/parser\";\nimport { flag, option } from \"@optique/core/primitives\";\nimport { integer, string, url } from \"@optique/core/valueparser\";\nimport { path } from \"@optique/run/valueparser\";\n\nimport {\n configurationProjection,\n configurationProvenance,\n createConfigurationBindings,\n configurationSettings as settings,\n} from \"../configuration.ts\";\nimport { resolveDatabaseSettings } from \"../database-settings.ts\";\nimport { valueOptionNames } from \"../parser.ts\";\n\n/**\n * Construct an independent database-only command using shared source bindings.\n * @returns Pure program metadata, contexts and the explicit TOML loader.\n */\nexport function createMigrationProgram(\n options: Parameters<typeof createConfigurationBindings>[0] = {},\n) {\n const bindings = createConfigurationBindings(options);\n const { bind } = bindings;\n const lockTimeout = integer({\n min: 1,\n max: 2_147_483_647,\n metavar: \"MILLISECONDS\",\n });\n const parser = object({\n configPath: optional(\n bindings.bindConfigPath(\n option(\"--config\", path({ metavar: \"FILE\", type: \"file\" }), {\n description: message`Read the shared DrFed TOML configuration file.`,\n }),\n ),\n ),\n dataPath: bind(\n option(\n ...valueOptionNames.dataPath,\n path({ metavar: \"DIRECTORY\", type: \"directory\" }),\n {\n description: message`Persistent PGlite directory; defaults to the OS data location.`,\n },\n ),\n settings.dataPath,\n string(),\n String,\n ),\n postgresUrl: bind(\n map(\n option(\n ...valueOptionNames.postgresUrl,\n url({ allowedProtocols: [\"postgres:\", \"postgresql:\"] }),\n {\n description: message`PostgreSQL connection URL.`,\n },\n ),\n (value) => value.href,\n ),\n settings.postgresUrl,\n string(),\n String,\n ),\n migrationLockTimeout: bind(\n option(...valueOptionNames.migrationLockTimeout, lockTimeout, {\n description: message`Maximum connection and migration lock wait in milliseconds.`,\n }),\n settings.migrationLockTimeout,\n lockTimeout,\n String,\n 30_000,\n ),\n check: withDefault(\n flag(\"--check\", {\n description: message`Inspect history without applying SQL or upgrading metadata. Exit 0 when ready, or 1 when preparation is needed or an error occurs.`,\n }),\n false,\n ),\n printConfig: withDefault(\n flag(\"--print-config\", {\n description: message`Print effective settings and provenance with credentials redacted, then exit without opening runtime resources.`,\n }),\n false,\n ),\n });\n return {\n program: {\n metadata: {\n name: \"drfed-migrate\",\n description: message`Prepare the DrFed database or inspect migration history.`,\n },\n parser,\n },\n contexts: bindings.contexts,\n load: bindings.load,\n };\n}\n\ntype RawMigrationOptions = InferValue<\n ReturnType<typeof createMigrationProgram>[\"program\"][\"parser\"]\n>;\n\n/**\n * Select the winning database and retain source-only diagnostic metadata.\n * @returns Validated command settings without acquiring runtime resources.\n */\nexport function resolveMigrationOptions(\n raw: RawMigrationOptions,\n cwd = process.cwd(),\n) {\n const selected = resolveDatabaseSettings(\n {\n dataPath: raw.dataPath,\n postgresUrl: raw.postgresUrl,\n },\n cwd,\n );\n const lockTimeoutMs = raw.migrationLockTimeout?.value;\n if (lockTimeoutMs === undefined) {\n throw new Error(\"Missing migration lock timeout.\");\n }\n return {\n database: { ...selected.database, lockTimeoutMs },\n check: raw.check,\n printConfig: raw.printConfig,\n ignored: selected.ignored,\n provenance: configurationProvenance({\n dataPath: raw.dataPath,\n postgresUrl: raw.postgresUrl,\n migrationLockTimeout: raw.migrationLockTimeout,\n }),\n };\n}\n\n/**\n * Describe database-only settings and their sources without opening resources.\n * @returns Redacted settings and ignored configuration areas for diagnostics.\n */\nexport function describeMigrationConfiguration(\n options: ReturnType<typeof resolveMigrationOptions>,\n) {\n const values = {\n databaseDriver: options.database.driver,\n dataPath:\n options.database.driver === \"pglite\"\n ? options.database.dataPath\n : undefined,\n postgresUrl:\n options.database.driver === \"postgres\" ? \"<redacted>\" : undefined,\n migrationLockTimeout: options.database.lockTimeoutMs,\n };\n const rank = { default: 0, config: 1, env: 2, cli: 3 };\n const selected = [\"dataPath\", \"postgresUrl\"]\n .map((key) => options.provenance[key])\n .filter((value) => value !== undefined)\n .sort((left, right) => rank[right.source] - rank[left.source])[0];\n return {\n command: \"migrate\" as const,\n mode: options.check ? \"check\" : \"apply\",\n settings: Object.fromEntries(\n Object.entries(values)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => [\n key === \"databaseDriver\"\n ? \"database.driver\"\n : settings[key as keyof typeof settings].toml,\n {\n value,\n ...((key === \"databaseDriver\"\n ? selected\n : options.provenance[key]) ?? { source: \"default\" as const }),\n },\n ]),\n ),\n ignored: [\n ...options.ignored,\n { field: \"database.migrate\", reason: \"explicit apply/check mode\" },\n ...configurationProjection(\"migrate\").unusedAreas.map((area) => ({\n area,\n reason: \"unused by this command\",\n })),\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAqCA,SAAgB,uBACd,UAA6D,CAAC,GAC9D;CACA,MAAM,WAAW,4BAA4B,OAAO;CACpD,MAAM,EAAE,SAAS;CACjB,MAAM,cAAc,QAAQ;EAC1B,KAAK;EACL,K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,85 @@
|
|
|
1
|
+
import { t as version } from "../package-D1pbtLwn.mjs";
|
|
2
|
+
import { OperationRegistry } from "../operations.mjs";
|
|
3
|
+
import { ResourceOwner } from "../resources.mjs";
|
|
4
|
+
import { openDatabaseRuntime } from "../database-runtime.mjs";
|
|
5
|
+
import { createMigrationProgram, describeMigrationConfiguration, resolveMigrationOptions } from "./migrate-program.mjs";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { text } from "@optique/core/message";
|
|
8
|
+
import { printError, run } from "@optique/run";
|
|
9
|
+
import { MigrationPreparationError, PgliteStoreError } from "@drfed/models";
|
|
10
|
+
//#region src/commands/migrate.ts
|
|
11
|
+
/** Run the installed database preparation command without server resources. */
|
|
12
|
+
async function main() {
|
|
13
|
+
const invocation = createMigrationProgram();
|
|
14
|
+
let options;
|
|
15
|
+
try {
|
|
16
|
+
options = resolveMigrationOptions(await run(invocation.program, {
|
|
17
|
+
contexts: invocation.contexts,
|
|
18
|
+
contextOptions: { load: (parsed) => invocation.load(parsed) },
|
|
19
|
+
help: "option",
|
|
20
|
+
completion: "both",
|
|
21
|
+
showChoices: true,
|
|
22
|
+
showDefault: true,
|
|
23
|
+
version: {
|
|
24
|
+
option: true,
|
|
25
|
+
value: version
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
printError([text(error instanceof Error ? error.message : "Could not resolve configuration.")]);
|
|
30
|
+
process.exitCode = 1;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (options.printConfig) {
|
|
34
|
+
console.log(JSON.stringify(describeMigrationConfiguration(options), null, 2));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const owner = new ResourceOwner();
|
|
38
|
+
const operations = new OperationRegistry();
|
|
39
|
+
let interrupted = false;
|
|
40
|
+
let failed = false;
|
|
41
|
+
let deadline;
|
|
42
|
+
const abort = () => {
|
|
43
|
+
if (interrupted) process.exit(1);
|
|
44
|
+
interrupted = true;
|
|
45
|
+
failed = true;
|
|
46
|
+
operations.abort();
|
|
47
|
+
deadline = setTimeout(() => process.exit(1), 1e4);
|
|
48
|
+
deadline.unref();
|
|
49
|
+
};
|
|
50
|
+
process.on("SIGINT", abort);
|
|
51
|
+
process.on("SIGTERM", abort);
|
|
52
|
+
try {
|
|
53
|
+
const database = await operations.run((signal) => openDatabaseRuntime({
|
|
54
|
+
...options.database,
|
|
55
|
+
migrate: !options.check
|
|
56
|
+
}, owner, options.check ? "inspect" : "apply", signal));
|
|
57
|
+
console.log(JSON.stringify({
|
|
58
|
+
command: "migrate",
|
|
59
|
+
...database.state
|
|
60
|
+
}, null, 2));
|
|
61
|
+
if (database.state.status !== "ready") failed = true;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (!(interrupted && (error === operations.signal.reason || error instanceof MigrationPreparationError && error.code === "aborted" && !error.cleanupFailed))) {
|
|
64
|
+
printError([text(error instanceof MigrationPreparationError || error instanceof PgliteStoreError ? `${error.code}: ${error.message}` : "Could not prepare or inspect the database.")]);
|
|
65
|
+
failed = true;
|
|
66
|
+
}
|
|
67
|
+
} finally {
|
|
68
|
+
operations.abort();
|
|
69
|
+
await operations.drain();
|
|
70
|
+
try {
|
|
71
|
+
await owner.close();
|
|
72
|
+
} catch {
|
|
73
|
+
printError([text("Could not cleanly close the database.")]);
|
|
74
|
+
failed = true;
|
|
75
|
+
}
|
|
76
|
+
if (deadline !== void 0) clearTimeout(deadline);
|
|
77
|
+
process.off("SIGINT", abort);
|
|
78
|
+
process.off("SIGTERM", abort);
|
|
79
|
+
}
|
|
80
|
+
process.exitCode = failed ? 1 : 0;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { main };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=migrate.mjs.map
|
|
@@ -0,0 +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;EAUF,UAAU,wBAAwB,MAThB,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,CACoC;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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