@ts-cloud/core 0.8.2 → 0.9.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 (2) hide show
  1. package/dist/types.d.ts +135 -3
  2. package/package.json +2 -2
package/dist/types.d.ts CHANGED
@@ -3201,13 +3201,34 @@ export interface RpxLoadBalancerConfig {
3201
3201
  }
3202
3202
  /** CDN-in-front-of-gateway configuration (see {@link ComputeProxyConfig.cdn}). */
3203
3203
  export interface CdnFrontConfig {
3204
+ /**
3205
+ * Which CDN sits in front of the gateway. @default 'cloudfront'
3206
+ *
3207
+ * The two work differently enough that it changes what this config means:
3208
+ * CloudFront is a distribution you point at an origin hostname, while
3209
+ * Cloudflare's proxy *is* the DNS record — see {@link originDomain}.
3210
+ */
3211
+ provider?: 'cloudfront' | 'cloudflare';
3204
3212
  /**
3205
3213
  * Hostname the CDN connects to (e.g. `origin.example.com`). MUST resolve to
3206
3214
  * this box and MUST NOT be one of {@link frontedHosts} (else the CDN loops).
3215
+ *
3216
+ * Required for CloudFront. **Not used by Cloudflare**, and supplying one there
3217
+ * is a mistake worth understanding: Cloudflare forwards to the address stored
3218
+ * in the proxied record itself, so the apex fronts its own origin without
3219
+ * looping, and a separate publicly-resolvable origin hostname would only serve
3220
+ * as a documented way around the edge.
3221
+ */
3222
+ originDomain?: string;
3223
+ /**
3224
+ * Public hosts served through the CDN (its aliases) — locked down when
3225
+ * {@link secret} is set.
3226
+ *
3227
+ * Optional: defaults to every hostname the gateway answers for, which is the
3228
+ * same set DNS publishes. List them explicitly only when some of the box's
3229
+ * names should stay off the edge.
3207
3230
  */
3208
- originDomain: string;
3209
- /** Public hosts served through the CDN (its aliases) — locked down when {@link secret} is set. */
3210
- frontedHosts: string[];
3231
+ frontedHosts?: string[];
3211
3232
  /** Shared secret the CDN injects on the origin hop; the gateway enforces it on {@link frontedHosts}. */
3212
3233
  secret?: string;
3213
3234
  /** Header name carrying {@link secret}. @default 'X-Origin-Verify' */
@@ -3216,6 +3237,117 @@ export interface CdnFrontConfig {
3216
3237
  originShield?: boolean;
3217
3238
  /** AWS region used by Origin Shield. Required when {@link originShield} is enabled. */
3218
3239
  originShieldRegion?: string;
3240
+ /** Cloudflare-specific tuning. Ignored unless {@link provider} is `'cloudflare'`. */
3241
+ cloudflare?: CloudflareCdnConfig;
3242
+ }
3243
+ /**
3244
+ * Cloudflare proxy-CDN configuration.
3245
+ *
3246
+ * Everything here is optional: with `provider: 'cloudflare'` and nothing else,
3247
+ * ts-cloud proxies the fronted hosts, applies the static-site zone settings, and
3248
+ * writes cache rules — which is the whole point of the integration.
3249
+ */
3250
+ export interface CloudflareCdnConfig {
3251
+ /**
3252
+ * Zone id. Falls back to `CLOUDFLARE_ZONE_ID`.
3253
+ *
3254
+ * Supplying it is what allows a single-zone API token: zone lookup by name
3255
+ * goes through an account-level listing that a zone-scoped token cannot read.
3256
+ */
3257
+ zoneId?: string;
3258
+ /** Account id. Falls back to `CLOUDFLARE_ACCOUNT_ID`. Only needed for account-scoped resources. */
3259
+ accountId?: string;
3260
+ /**
3261
+ * Serve the fronted hosts through the proxy (the "orange cloud"). @default true
3262
+ *
3263
+ * `false` keeps the records DNS-only — Cloudflare answers with the origin
3264
+ * address and no edge is involved, which also disables every other option
3265
+ * here, since they all configure the edge.
3266
+ */
3267
+ proxied?: boolean;
3268
+ /** Zone settings to reconcile. Defaults to ts-cloud's static-site profile. */
3269
+ settings?: CloudflareZoneSettingsConfig;
3270
+ /** Cache-rule tuning for the fronted hosts. */
3271
+ cache?: CloudflareCacheRulesConfig;
3272
+ /** Purge the edge cache at the end of a deploy. @default true */
3273
+ purgeOnDeploy?: boolean;
3274
+ /**
3275
+ * Skip the origin TLS probe and proxy the records immediately. @default false
3276
+ *
3277
+ * The probe exists because a box issues its certificate over ACME HTTP-01,
3278
+ * which needs the hostname to reach the box directly — proxying before that
3279
+ * happens can strand the name with no certificate. Skip it only when the
3280
+ * origin certificate already exists.
3281
+ */
3282
+ skipOriginProbe?: boolean;
3283
+ }
3284
+ /** HSTS settings for a Cloudflare zone. */
3285
+ export interface CloudflareHstsConfig {
3286
+ enabled: boolean;
3287
+ /** Lifetime in seconds. @default 31536000 (1 year) */
3288
+ maxAge?: number;
3289
+ /** Apply to every subdomain. @default false */
3290
+ includeSubdomains?: boolean;
3291
+ /** Submit to browser preload lists — effectively irreversible. @default false */
3292
+ preload?: boolean;
3293
+ /** Send `X-Content-Type-Options: nosniff`. @default true */
3294
+ noSniff?: boolean;
3295
+ }
3296
+ /**
3297
+ * Zone-level Cloudflare settings ts-cloud reconciles. Anything left undefined is
3298
+ * not touched, so a zone keeps settings this deploy has no opinion about.
3299
+ */
3300
+ export interface CloudflareZoneSettingsConfig {
3301
+ /**
3302
+ * How Cloudflare reaches the origin. `strict` (Full (strict)) is the only mode
3303
+ * that verifies the origin certificate, and the right answer for a ts-cloud
3304
+ * box, which holds a real one. `flexible` sends plaintext to the origin and
3305
+ * loops against a gateway that redirects HTTP to HTTPS.
3306
+ */
3307
+ ssl?: 'off' | 'flexible' | 'full' | 'strict';
3308
+ /** Redirect HTTP to HTTPS at the edge. */
3309
+ alwaysUseHttps?: boolean;
3310
+ /** Rewrite http:// references in HTML to https://. */
3311
+ automaticHttpsRewrites?: boolean;
3312
+ /** Minimum TLS version accepted from visitors. */
3313
+ minTlsVersion?: '1.0' | '1.1' | '1.2' | '1.3';
3314
+ /** Offer TLS 1.3. */
3315
+ tls13?: boolean;
3316
+ /** Brotli-compress responses. */
3317
+ brotli?: boolean;
3318
+ /** Offer HTTP/3 (QUIC). */
3319
+ http3?: boolean;
3320
+ /** TLS 1.3 0-RTT resumption. */
3321
+ zeroRtt?: boolean;
3322
+ /** Send 103 Early Hints. */
3323
+ earlyHints?: boolean;
3324
+ /** HSTS. */
3325
+ hsts?: CloudflareHstsConfig;
3326
+ /** Default browser cache TTL in seconds; `0` respects the origin's headers. */
3327
+ browserCacheTtl?: number;
3328
+ /** Serve a cached copy when the origin is unreachable. */
3329
+ alwaysOnline?: boolean;
3330
+ /** Proxy WebSocket upgrades. */
3331
+ websockets?: boolean;
3332
+ /** Raw Cloudflare setting ids, merged last. */
3333
+ raw?: Record<string, unknown>;
3334
+ }
3335
+ /** Cache-rule tuning for a Cloudflare-fronted static site. */
3336
+ export interface CloudflareCacheRulesConfig {
3337
+ /** Generate cache rules at all. @default true */
3338
+ enabled?: boolean;
3339
+ /** Extensions treated as immutable, fingerprinted build output. */
3340
+ assetExtensions?: string[];
3341
+ /** Edge TTL for those assets, in seconds. @default 2592000 (30 days) */
3342
+ assetEdgeTtl?: number;
3343
+ /** Browser TTL for those assets, in seconds. @default 31536000 (1 year) */
3344
+ assetBrowserTtl?: number;
3345
+ /** Edge TTL for HTML documents, in seconds. @default 3600 */
3346
+ documentEdgeTtl?: number;
3347
+ /** Browser TTL for HTML documents, in seconds. @default 0 (revalidate) */
3348
+ documentBrowserTtl?: number;
3349
+ /** Path prefixes that must never be cached, matched with `starts_with`. */
3350
+ bypassPaths?: string[];
3219
3351
  }
3220
3352
  export interface DatabaseItemConfig {
3221
3353
  engine?: 'dynamodb' | 'postgres' | 'mysql';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
3
  "type": "module",
4
- "version": "0.8.2",
4
+ "version": "0.9.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.8.2"
34
+ "@ts-cloud/aws-types": "0.9.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^7.0.2"