@wtfalch/foundry 0.37.0 → 0.39.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.
Files changed (39) hide show
  1. package/dist/bootstrap/versions.d.ts +3 -2
  2. package/dist/index.d.ts +1 -1
  3. package/dist/plan/backup-gate.d.ts +19 -3
  4. package/dist/plan/backup-gate.js +49 -4
  5. package/dist/plan/company-backups.d.ts +7 -2
  6. package/dist/plan/company-backups.js +25 -6
  7. package/dist/plan/diff.d.ts +4 -0
  8. package/dist/plan/diff.js +19 -1
  9. package/dist/plan/executor.d.ts +13 -0
  10. package/dist/plan/executor.js +56 -13
  11. package/dist/plan/index.d.ts +2 -1
  12. package/dist/plan/index.js +1 -0
  13. package/dist/plan/mail-store.d.ts +34 -0
  14. package/dist/plan/mail-store.js +49 -0
  15. package/dist/plan/own-diff.d.ts +26 -0
  16. package/dist/plan/own-diff.js +74 -6
  17. package/dist/plan/own-services.d.ts +11 -0
  18. package/dist/plan/own-services.js +12 -0
  19. package/dist/plan/plan-apply.d.ts +4 -0
  20. package/dist/plan/plan-apply.js +30 -4
  21. package/dist/plan/platform-diff.d.ts +30 -0
  22. package/dist/plan/platform-diff.js +62 -7
  23. package/dist/plan/platform-org.d.ts +15 -0
  24. package/dist/plan/platform-org.js +17 -1
  25. package/dist/plan/platform-providers.d.ts +69 -2
  26. package/dist/plan/platform-providers.js +255 -41
  27. package/dist/plan/signin-db-backup.d.ts +105 -0
  28. package/dist/plan/signin-db-backup.js +193 -0
  29. package/dist/plan/signin-db-move.d.ts +68 -0
  30. package/dist/plan/signin-db-move.js +338 -0
  31. package/dist/plan/signin-db-tls.d.ts +69 -0
  32. package/dist/plan/signin-db-tls.js +255 -0
  33. package/dist/plan/signin-db.d.ts +114 -0
  34. package/dist/plan/signin-db.js +255 -0
  35. package/dist/plan/uptime-worker.d.ts +20 -1
  36. package/dist/plan/uptime-worker.js +121 -3
  37. package/package.json +1 -1
  38. package/versions.digests.json +2 -1
  39. package/versions.json +2 -1
@@ -17,6 +17,7 @@ import { type FilesKeysMinted, type ProjectSource, type ServiceNetwork, type Ser
17
17
  import type { PlatformDriftedSteps, PlatformStepExecutionContext, PlatformStepExecutor } from './plan-apply.js';
18
18
  import { type BrokerDeployRecord, PLATFORM_ZITADEL_ORG_SCOPE_KEY } from './platform-diff.js';
19
19
  import type { PlatformOwnerInput } from './platform-org.js';
20
+ import type { SigninDbBackupPort } from './signin-db-backup.js';
20
21
  export { PLATFORM_ZITADEL_ORG_SCOPE_KEY };
21
22
  import { type CallsSfuPlatformDeps } from './platform-sfu.js';
22
23
  import { type PlatformUptimeDeps } from './uptime-worker.js';
@@ -132,7 +133,9 @@ export interface PlatformAuthSmtp {
132
133
  export interface PlatformAuthDeps {
133
134
  /** Overrides the Lettermint SMTP relay ZITADEL is given. Absent, Lettermint exactly as before. */
134
135
  smtp?: PlatformAuthSmtp;
135
- coolify: Pick<CoolifyPort, 'findProjectByName' | 'createProject' | 'findOrCreateEnvironment' | 'listServers' | 'findApplicationByName' | 'getApplication' | 'requireGithubApp' | 'createGithubAppApplication' | 'createDockerImageApplication' | 'createDockerfileApplication' | 'createPostgresDatabase' | 'getDatabase' | 'bulkUpsertEnvs' | 'listEnvs' | 'updateApplication' | 'deploy' | 'raw'>;
136
+ coolify: Pick<CoolifyPort, 'findProjectByName' | 'createProject' | 'findOrCreateEnvironment' | 'listServers' | 'findApplicationByName' | 'getApplication' | 'requireGithubApp' | 'createGithubAppApplication' | 'createDockerImageApplication' | 'createDockerfileApplication' | 'createPostgresDatabase' | 'getDatabase' | 'bulkUpsertEnvs' | 'listEnvs' | 'updateApplication' | 'deploy' | 'raw'> &
137
+ /** An own org's sign-in database needs a volume and the CA file mount (#746); the platform's does not. */
138
+ Partial<Pick<CoolifyPort, 'listStorages' | 'createPersistentStorage' | 'createFileStorage'>>;
136
139
  /** F4.dns: every DNS record call, through edge at its recorded address (see {@link PlatformDnsFactory}). */
137
140
  dns: PlatformDnsFactory;
138
141
  /** F4.tunnels: every tunnel call, through edge at its recorded address (see {@link PlatformTunnelsFactory}). */
@@ -172,7 +175,16 @@ export interface PlatformAuthDeps {
172
175
  */
173
176
  heldKeys?: {
174
177
  resolve(ref: string): Promise<string | null>;
178
+ /** An own org's sign-in database CA and certificate are stored through this (#746). Without it a new company's sign-in step is blocked. */
179
+ put?(ref: string, value: string): Promise<void>;
175
180
  };
181
+ /**
182
+ * The bucket and storage key ports a company's sign-in database backup uses (#746): its own bucket and
183
+ * a key scoped to it. For an own org the executor fills this from the files host's `r2Buckets` and
184
+ * `r2Keys`; the platform's backup key is never used. Without it a company's sign-in database is not
185
+ * created and an existing one is not moved.
186
+ */
187
+ signinDbBackup?: SigninDbBackupPort;
176
188
  /** Clock, sleep and fetch for the readiness wait and delivery retries; real ones by default. */
177
189
  runtime?: PlatformAuthRuntime;
178
190
  }
@@ -190,6 +202,14 @@ export interface PlatformAuthRuntime {
190
202
  readyRequestTimeoutMs?: number;
191
203
  /** Told of every secret the sign-in step reads or mints, so the host can scrub it from logs and audit rows. */
192
204
  onSecret?: (value: string) => void;
205
+ /** How long a new or redeployed sign-in database may take to report healthy (default 5 minutes). */
206
+ signinDbTimeoutMs?: number;
207
+ /** How long ZITADEL may take to report stopped before a sign-in database move copies (default 2 minutes). */
208
+ signinDbStopTimeoutMs?: number;
209
+ /** How long the copy job of a sign-in database move may run (default 30 minutes). */
210
+ signinDbMoveTimeoutMs?: number;
211
+ /** Pause between polls of the copy job (default 10 seconds). */
212
+ signinDbMovePollMs?: number;
193
213
  }
194
214
  /**
195
215
  * An own org's scheduler only: the app's uuid, recorded and persisted before
@@ -354,6 +374,10 @@ export declare class FoundryPlatformStepExecutor implements PlatformStepExecutor
354
374
  access: boolean;
355
375
  vars: string;
356
376
  };
377
+ uptimeChat?: {
378
+ pending: boolean;
379
+ blocked?: string;
380
+ };
357
381
  archonRunsInsideApp?: boolean;
358
382
  archonDeployRunning?: string;
359
383
  archonIdTokenUserinfo?: boolean;
@@ -454,6 +478,7 @@ export declare const AUTH_LOGIN_PORT = "3000";
454
478
  * everything else, including the root).
455
479
  */
456
480
  export declare const AUTH_ZITADEL_PATH_PATTERN = "^/(oidc|oauth|saml|management|admin|system|auth|assets|debug/healthz|ui/console|\\.well-known|v2|v2beta|zitadel\\.[A-Za-z0-9.]+)(/|$)";
481
+ export declare const PLATFORM_AUTH_DB_SCOPE_KEY = "coolify_platform_auth_database";
457
482
  export declare const PLATFORM_AUTH_ZITADEL_SCOPE_KEY = "coolify_platform_auth_zitadel_app";
458
483
  export declare const PLATFORM_AUTH_LOGIN_SCOPE_KEY = "coolify_platform_auth_login_app";
459
484
  /**
@@ -606,6 +631,16 @@ export interface PlatformMailAdminPort {
606
631
  issuerUrl: string;
607
632
  audience: string;
608
633
  };
634
+ /**
635
+ * Where Stalwart keeps its data: a Postgres reached at `host:port`. The password is not here:
636
+ * Stalwart reads it from the env var {@link MAIL_DATABASE_PASSWORD_ENV}.
637
+ */
638
+ dataStore: {
639
+ host: string;
640
+ port: number;
641
+ database: string;
642
+ user: string;
643
+ };
609
644
  }): Promise<'restart' | undefined>;
610
645
  /**
611
646
  * `StalwartClient.createApiKey`'s own signature. The key belongs to a real
@@ -642,7 +677,7 @@ export declare function defaultStalwartForInstance(input: {
642
677
  * own shape.
643
678
  */
644
679
  export interface PlatformMailDeps {
645
- coolify: Pick<CoolifyPort, 'findProjectByName' | 'createProject' | 'findOrCreateEnvironment' | 'listServers' | 'findApplicationByName' | 'getApplication' | 'createDockerImageApplication' | 'createDockerfileApplication' | 'raw' | 'listStorages' | 'createPersistentStorage' | 'bulkUpsertEnvs' | 'listEnvs' | 'updateApplication' | 'deploy' | 'deployAndWait' | 'restart' | 'getDeployment'>;
680
+ coolify: Pick<CoolifyPort, 'findProjectByName' | 'createProject' | 'findOrCreateEnvironment' | 'listServers' | 'findApplicationByName' | 'getApplication' | 'createDockerImageApplication' | 'createDockerfileApplication' | 'createPostgresDatabase' | 'getDatabase' | 'listDatabases' | 'deleteApplication' | 'raw' | 'listStorages' | 'createPersistentStorage' | 'bulkUpsertEnvs' | 'listEnvs' | 'updateApplication' | 'deploy' | 'deployAndWait' | 'restart' | 'getDeployment'>;
646
681
  /** F4.dns: every DNS record call, through edge at its recorded address (see {@link PlatformDnsFactory}). */
647
682
  dns: PlatformDnsFactory;
648
683
  /** F4.tunnels: every tunnel call, through edge at its recorded address (see {@link PlatformTunnelsFactory}). */
@@ -684,6 +719,8 @@ export interface PlatformMailRuntime {
684
719
  readyIntervalMs?: number;
685
720
  /** Tries at handing the admin key to the host (default 3). */
686
721
  deliverAttempts?: number;
722
+ /** Called with the mail database's password, so the host can keep it out of every message it writes. */
723
+ onSecret?: (value: string) => void;
687
724
  }
688
725
  /**
689
726
  * What {@link provisionMailServer} reads besides the target's names: the
@@ -701,6 +738,12 @@ export interface MailServerInput {
701
738
  mailHost: string;
702
739
  /** The Stalwart image tag. */
703
740
  imageTag: string;
741
+ /**
742
+ * The plan's confirmed switch of a volume-backed server to Postgres: delete the Stalwart app and its
743
+ * volume, clear the ids that describe it, then provision as usual. Without it a server still on its
744
+ * volume is refused before any write.
745
+ */
746
+ switchStore?: boolean;
704
747
  /** `host:container` list; empty publishes no host port. */
705
748
  hostPorts: string;
706
749
  /** The sign-in the server's directory trusts; its `mail` project's id is the audience. */
@@ -1150,6 +1193,25 @@ export declare function createAiManagementKeyMinter(options: {
1150
1193
  fetchImpl?: typeof fetch;
1151
1194
  now?: () => number;
1152
1195
  }): AiManagementKeyMinter;
1196
+ export declare function resolvePlatformServer(coolify: Pick<CoolifyPort, 'listServers'>): Promise<{
1197
+ uuid: string;
1198
+ ip?: string;
1199
+ }>;
1200
+ /**
1201
+ * `executor.ts`'s `coolifyCalls`/`findOrCreateCallsApp`, restated here rather
1202
+ * than imported: that method is private to `FoundryStepExecutor`, and this
1203
+ * file holds no instance of that class to call it on. `running` says whether
1204
+ * the app was already running or starting; the caller deploys it when not.
1205
+ */
1206
+ export declare function findOrCreatePlatformApp(coolify: Pick<CoolifyPort, 'findApplicationByName' | 'getApplication'>, name: string, environment: {
1207
+ id: number;
1208
+ }, create: () => Promise<{
1209
+ uuid: string;
1210
+ }>): Promise<{
1211
+ appId: string;
1212
+ justCreated: boolean;
1213
+ running: boolean;
1214
+ }>;
1153
1215
  /**
1154
1216
  * #211: names of the envs the platform's sign-in broker (`wtfalch/auth`'s
1155
1217
  * `broker/server.ts`) refuses to start without -- `ZITADEL_SERVICE_USER_TOKEN`/
@@ -1196,6 +1258,11 @@ export declare function brokerDeployNeeded(missingInputs: readonly string[], bro
1196
1258
  * wrote there. Paired with {@link brokerDeployNeeded}, which reads it back.
1197
1259
  */
1198
1260
  export declare function brokerDeployRecordValue(brokerAppId: string, authAppsRaw: string | undefined): string;
1261
+ /** Whether any desired env is missing from the app, or set to another value. */
1262
+ export declare function envsDiffer(coolify: Pick<CoolifyPort, 'listEnvs'>, appId: string, desired: Array<{
1263
+ key: string;
1264
+ value: string;
1265
+ }>): Promise<boolean>;
1199
1266
  /**
1200
1267
  * #171: everything {@link provisionPlatformFiles} needs beyond
1201
1268
  * {@link PlatformStepExecutionContext}, bundled for the same reason as