@ts-cloud/core 0.9.4 → 0.10.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/dist/types.d.ts CHANGED
@@ -1132,6 +1132,11 @@ export interface SiteConfig {
1132
1132
  * A release is a fresh directory, so anything the app WRITES and must keep
1133
1133
  * has to be listed here or the next deploy silently starts it from empty.
1134
1134
  *
1135
+ * A SQLite database is the one exception, added for you: when the site's
1136
+ * resolved env says `DB_CONNECTION=sqlite` and `DB_DATABASE` names a path
1137
+ * inside the release, the deploy shares that file without being asked. An
1138
+ * env that says SQLite but not WHERE is warned about rather than guessed at.
1139
+ *
1135
1140
  * An entry may instead be a {@link SharedPathSpec} naming an absolute
1136
1141
  * `target`, which is how SEVERAL sites of one project point at ONE file —
1137
1142
  * an app and its API sharing a single SQLite database, say. Each site
@@ -3141,6 +3146,238 @@ export interface ComputeServicesConfig {
3141
3146
  meilisearch?: boolean | {
3142
3147
  version?: string;
3143
3148
  };
3149
+ /**
3150
+ * Provision the **mail server** on this box - `mail`, the Zig SMTP/IMAP
3151
+ * server (`github.com/mail-os/mail`), with its own webmail UI.
3152
+ *
3153
+ * `true` picks a mode from the environment rather than making you say it:
3154
+ * a production environment gets `'server'` (a real MTA that sends and
3155
+ * receives), anything else gets `'catcher'` (accepts everything, delivers
3156
+ * nowhere, shows it in the webmail UI). See {@link MailServiceConfig.mode}.
3157
+ *
3158
+ * ## Why this exists rather than a mailpit container
3159
+ *
3160
+ * Development mail traps and production mail servers are conventionally two
3161
+ * different programs, and that difference is where mail breaks. A message
3162
+ * that renders in mailpit has been through a parser nothing in production
3163
+ * will ever run; a `From` that mailpit accepts is one no MTA would. The bugs
3164
+ * that costs are the ones nobody can reproduce locally, which is the worst
3165
+ * kind.
3166
+ *
3167
+ * The two modes here are one binary with one parser, one authentication
3168
+ * path, one Maildir, and one UI. What development sees is what production
3169
+ * does, minus the delivery.
3170
+ */
3171
+ mail?: boolean | MailServiceConfig;
3172
+ }
3173
+ /**
3174
+ * What the on-box mail server is for. See {@link MailServiceConfig.mode}.
3175
+ *
3176
+ * - `'server'` - a real MTA. Receives on 25, submits on 587/465, serves IMAP,
3177
+ * signs with DKIM, and delivers outbound mail (directly or through a relay).
3178
+ * - `'catcher'` - accepts every message addressed to anywhere, delivers none
3179
+ * of them onward, and shows them in the webmail UI. The replacement for
3180
+ * mailpit/Mailhog, on the ports those tools use so nothing has to be
3181
+ * reconfigured to adopt it.
3182
+ */
3183
+ export type MailServiceMode = 'server' | 'catcher';
3184
+ /**
3185
+ * On-box mail server (`mail`). See {@link ComputeServicesConfig.mail}.
3186
+ *
3187
+ * Every field is optional; the defaults are a working server for the
3188
+ * environment's mode. What has no safe default - the hostname the server
3189
+ * announces, and therefore what its MX record must point at - is derived from
3190
+ * the project's own domain and can be overridden here.
3191
+ */
3192
+ export interface MailServiceConfig {
3193
+ /**
3194
+ * Real MTA or local trap. Defaults to `'server'` in a production
3195
+ * environment and `'catcher'` everywhere else.
3196
+ */
3197
+ mode?: MailServiceMode;
3198
+ /** Pin the mail server version. @default latest release */
3199
+ version?: string;
3200
+ /**
3201
+ * The FQDN this server announces in HELO/EHLO and signs mail as, e.g.
3202
+ * `mail.example.com`. It is also what an MX record has to resolve to, so it
3203
+ * must be a name you control and that resolves to this box.
3204
+ *
3205
+ * @default `mail.<the project's primary site domain>`, or `localhost` for a
3206
+ * catcher, which announces a name nobody has to resolve.
3207
+ */
3208
+ hostname?: string;
3209
+ /**
3210
+ * Additional domains delivered to mailboxes on this server, beyond
3211
+ * {@link hostname} and its parent (`mail.example.com` already covers
3212
+ * `example.com`). One server, several domains' mailboxes.
3213
+ */
3214
+ domains?: string[];
3215
+ /** Listening ports. Every one has a default; see {@link MailPortsConfig}. */
3216
+ ports?: MailPortsConfig;
3217
+ /**
3218
+ * TLS for SMTP/IMAP. Defaults to ACME (Let's Encrypt) for a `'server'` on a
3219
+ * real hostname, and off for a `'catcher'`, which is loopback-only.
3220
+ */
3221
+ tls?: MailTlsConfig;
3222
+ /**
3223
+ * DKIM signing. `true` generates a key per {@link domains} entry on first
3224
+ * provision and prints the DNS record to publish; the private key stays on
3225
+ * the box and is never rewritten once it exists.
3226
+ *
3227
+ * On by default for a `'server'`, off for a `'catcher'` - a trap signing
3228
+ * mail is signing mail nobody will ever verify.
3229
+ */
3230
+ dkim?: boolean | MailDkimConfig;
3231
+ /**
3232
+ * The webmail UI - the browser client the mail server serves itself, and
3233
+ * the thing you look at instead of mailpit's inbox.
3234
+ *
3235
+ * On by default. A catcher serves it on 8025 (mailpit's port, so a bookmark
3236
+ * or a `docker-compose` port mapping carries over); a server serves it on
3237
+ * 8080 behind the gateway.
3238
+ */
3239
+ webmail?: boolean | MailWebmailConfig;
3240
+ /**
3241
+ * Mailboxes to create on first provision. Idempotent: an account that
3242
+ * already exists has its password reset to what is declared here, so this
3243
+ * stays the source of truth rather than drifting after the first boot.
3244
+ *
3245
+ * Passwords belong in the environment, not in a committed config - write
3246
+ * `password: process.env.MAIL_ADMIN_PASSWORD!` rather than a literal.
3247
+ */
3248
+ accounts?: MailAccountConfig[];
3249
+ /**
3250
+ * How outbound mail leaves the box.
3251
+ *
3252
+ * - `'direct'` - talk to the recipient's MX on port 25. The right answer for
3253
+ * a box whose provider does not block outbound 25 and whose IP has
3254
+ * reverse DNS. Note that most providers block outbound 25 on new accounts
3255
+ * and unblock it on request; check before choosing this.
3256
+ * - `'ses'` - relay through AWS SES in {@link sesRegion}, which is what to
3257
+ * use while port 25 is blocked.
3258
+ * - `'none'` - accept and deliver locally, never send. What a catcher does.
3259
+ *
3260
+ * There is deliberately no generic smarthost option: the mail server has no
3261
+ * authenticated-relay path yet, so a `relay: { host, username, password }`
3262
+ * here would be a credential written to a box and then ignored, and mail
3263
+ * that appears to be configured and silently goes nowhere is worse than mail
3264
+ * that was never configured.
3265
+ *
3266
+ * @default `'direct'` for a server, `'none'` for a catcher.
3267
+ */
3268
+ delivery?: 'direct' | 'ses' | 'none';
3269
+ /** SES region for `delivery: 'ses'`. @default 'us-east-1' */
3270
+ sesRegion?: string;
3271
+ /** Where mailboxes, the database and DKIM keys live. @default '/var/lib/mail' */
3272
+ storagePath?: string;
3273
+ /** Largest message accepted, in bytes. @default 26214400 (25 MB) */
3274
+ maxMessageSize?: number;
3275
+ /** Inbound spam handling. Advisory by default; see {@link MailSpamConfig}. */
3276
+ spam?: MailSpamConfig;
3277
+ /** POST every received message to this URL. Off unless set. */
3278
+ webhookUrl?: string;
3279
+ /**
3280
+ * Open the mail ports to the internet.
3281
+ *
3282
+ * A `'server'` has to be reachable to receive mail, so this defaults to
3283
+ * true for it and the ports join the host firewall's allow list. A
3284
+ * `'catcher'` defaults to false and binds loopback only - a machine that
3285
+ * accepts every message for every recipient and shows them in a UI with no
3286
+ * password is an open relay and an open inbox, and it must never be
3287
+ * reachable from anywhere but the box itself.
3288
+ */
3289
+ expose?: boolean;
3290
+ }
3291
+ /**
3292
+ * Which ports the mail server listens on. The defaults are the standard ones
3293
+ * for a server, and mailpit's for a catcher, so adopting a catcher needs no
3294
+ * change to anything that was pointed at mailpit.
3295
+ */
3296
+ export interface MailPortsConfig {
3297
+ /** Inbound SMTP from other servers. @default 25 (server) / 1025 (catcher) */
3298
+ smtp?: number;
3299
+ /** Message submission (STARTTLS). @default 587; off for a catcher. */
3300
+ submission?: number;
3301
+ /** Implicit-TLS submission. @default 465; off for a catcher. */
3302
+ submissions?: number;
3303
+ /** IMAP. @default 143; off for a catcher. */
3304
+ imap?: number;
3305
+ /** IMAP over TLS. @default 993; off for a catcher. */
3306
+ imaps?: number;
3307
+ /** The webmail UI. @default 8080 (server) / 8025 (catcher) */
3308
+ webmail?: number;
3309
+ /** ManageSieve, when {@link MailServiceConfig} enables filtering. @default 4190 */
3310
+ managesieve?: number;
3311
+ }
3312
+ /** TLS for the mail server's SMTP/IMAP listeners. */
3313
+ export interface MailTlsConfig {
3314
+ /** Serve TLS at all. @default true for a server, false for a catcher. */
3315
+ enabled?: boolean;
3316
+ /**
3317
+ * Obtain and renew the certificate over ACME (Let's Encrypt) for
3318
+ * {@link MailServiceConfig.hostname}. @default true when TLS is enabled and
3319
+ * no explicit paths are given.
3320
+ */
3321
+ acme?: boolean;
3322
+ /** Contact address ACME registers. @default the first configured account. */
3323
+ acmeEmail?: string;
3324
+ /** Certificate path, when you supply the certificate yourself. */
3325
+ certPath?: string;
3326
+ /** Private key path, when you supply the certificate yourself. */
3327
+ keyPath?: string;
3328
+ /**
3329
+ * Refuse AUTH until the connection is encrypted. On by default for a
3330
+ * server: an SMTP AUTH over cleartext is a password on the wire.
3331
+ */
3332
+ requireForAuth?: boolean;
3333
+ }
3334
+ /** DKIM signing. See {@link MailServiceConfig.dkim}. */
3335
+ export interface MailDkimConfig {
3336
+ /** Selector published as `<selector>._domainkey.<domain>`. @default 'default' */
3337
+ selector?: string;
3338
+ /** Rotate the key on a schedule. Off by default. */
3339
+ rotate?: boolean;
3340
+ /** Days between rotations when {@link rotate} is on. @default 90 */
3341
+ rotateIntervalDays?: number;
3342
+ }
3343
+ /** The webmail UI. See {@link MailServiceConfig.webmail}. */
3344
+ export interface MailWebmailConfig {
3345
+ /** Serve it. @default true */
3346
+ enabled?: boolean;
3347
+ /** Port. @default 8080 (server) / 8025 (catcher) */
3348
+ port?: number;
3349
+ /**
3350
+ * Hostname to route to the UI through the box's gateway, e.g.
3351
+ * `mail.example.com`. Without one the UI is reachable on its port only,
3352
+ * which for a catcher is exactly right.
3353
+ */
3354
+ domain?: string;
3355
+ }
3356
+ /** A mailbox created on first provision. See {@link MailServiceConfig.accounts}. */
3357
+ export interface MailAccountConfig {
3358
+ /** Full address, e.g. `postmaster@example.com`. */
3359
+ address: string;
3360
+ /** The password. Read it from the environment; never commit one. */
3361
+ password: string;
3362
+ }
3363
+ /** Inbound spam handling. See {@link MailServiceConfig.spam}. */
3364
+ export interface MailSpamConfig {
3365
+ /** Score inbound mail and file it into Junk. @default true for a server. */
3366
+ enabled?: boolean;
3367
+ /**
3368
+ * Reject mail that fails DMARC outright rather than recording the verdict
3369
+ * in `Authentication-Results` and delivering it. Off by default: a policy
3370
+ * that bounces mail is one somebody has to be ready to hear about.
3371
+ */
3372
+ enforce?: boolean;
3373
+ /** Score at which mail is filed into Junk. @default 5 */
3374
+ junkScore?: number;
3375
+ /** Score at which mail is refused at SMTP time. @default 12 */
3376
+ rejectScore?: number;
3377
+ /** Consult DNS blocklists. @default true for a server. */
3378
+ dnsbl?: boolean;
3379
+ /** Greylist unknown senders. Off by default - it delays first contact. */
3380
+ greylist?: boolean;
3144
3381
  }
3145
3382
  /**
3146
3383
  * Reverse-proxy gateway provisioning for a compute box. The gateway is
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
3
  "type": "module",
4
- "version": "0.9.4",
4
+ "version": "0.10.0",
5
5
  "description": "Core CloudFormation generation library for ts-cloud",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@ts-cloud/aws-types": "0.9.4"
34
+ "@ts-cloud/aws-types": "0.10.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^7.0.2"