@ts-cloud/core 0.16.39 → 0.16.41

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 +118 -0
  2. package/package.json +2 -2
package/dist/types.d.ts CHANGED
@@ -562,6 +562,28 @@ export interface InfrastructureConfig {
562
562
  */
563
563
  realtime?: RealtimeConfig;
564
564
  dns?: DnsConfig;
565
+ /**
566
+ * Cloudflare R2 buckets, reconciled through Cloudflare's account API on
567
+ * `cloud deploy` (see `reconcileR2Buckets`).
568
+ *
569
+ * R2 sits outside AWS entirely, so nothing here touches CloudFormation; the
570
+ * deploy needs `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in the env.
571
+ *
572
+ * @example
573
+ * r2: {
574
+ * buckets: {
575
+ * tiles: {
576
+ * name: 'my-app-tiles',
577
+ * locationHint: 'wnam',
578
+ * customDomains: ['tiles.example.com'],
579
+ * cors: [{ allowed: { origins: ['https://example.com'], methods: ['GET', 'HEAD'] }, maxAgeSeconds: 3600 }],
580
+ * lifecycle: [{ id: 'expire-tmp', prefix: 'tmp/', expireAfterDays: 7 }],
581
+ * cache: { edgeTtl: 86400, browserTtl: 3600 },
582
+ * },
583
+ * },
584
+ * }
585
+ */
586
+ r2?: R2Config;
565
587
  security?: SecurityConfig;
566
588
  monitoring?: MonitoringConfig;
567
589
  api?: ApiConfig;
@@ -2171,6 +2193,102 @@ export interface AlarmItemConfig {
2171
2193
  */
2172
2194
  service?: string;
2173
2195
  }
2196
+ /** Cloudflare R2 location hints. A hint, not a guarantee: R2 may place the bucket elsewhere. */
2197
+ export type R2LocationHint = 'wnam' | 'enam' | 'weur' | 'eeur' | 'apac' | 'oc';
2198
+ /**
2199
+ * Cloudflare R2 jurisdictions. A bucket created in one is only reachable with
2200
+ * the matching `cf-r2-jurisdiction` header, so this must stay set for the
2201
+ * bucket's whole life.
2202
+ */
2203
+ export type R2Jurisdiction = 'default' | 'eu' | 'us' | 'fedramp' | 'fedramp-high';
2204
+ /** Minimum TLS version Cloudflare accepts on an R2 custom domain. */
2205
+ export type R2MinTls = '1.0' | '1.1' | '1.2' | '1.3';
2206
+ /**
2207
+ * One CORS rule, in exactly the shape Cloudflare's R2 API takes, so a rule can
2208
+ * be copied straight from Cloudflare's docs or the dashboard's JSON view.
2209
+ */
2210
+ export interface R2CorsRule {
2211
+ /** Optional identifier, echoed back by the API. */
2212
+ id?: string;
2213
+ allowed: {
2214
+ /** Origins allowed to make cross-origin requests, e.g. `https://example.com` or `*`. */
2215
+ origins: string[];
2216
+ methods: Array<'GET' | 'PUT' | 'POST' | 'DELETE' | 'HEAD'>;
2217
+ /** Request headers a preflight may ask for. */
2218
+ headers?: string[];
2219
+ };
2220
+ /** Response headers a browser script may read. */
2221
+ exposeHeaders?: string[];
2222
+ /** How long a browser may cache the preflight answer, in seconds. */
2223
+ maxAgeSeconds?: number;
2224
+ }
2225
+ /**
2226
+ * One object lifecycle rule. Flattened from Cloudflare's nested transition
2227
+ * shape: each field below becomes the matching `*Transition` with an `Age`
2228
+ * (or `Date`) condition.
2229
+ */
2230
+ export interface R2LifecycleRule {
2231
+ /** Unique id within the bucket. */
2232
+ id: string;
2233
+ /** Only objects under this key prefix. @default '' (the whole bucket) */
2234
+ prefix?: string;
2235
+ /** @default true */
2236
+ enabled?: boolean;
2237
+ /** Delete objects this many days after upload. */
2238
+ expireAfterDays?: number;
2239
+ /** Delete objects on this date instead (ISO 8601). */
2240
+ expireOn?: string;
2241
+ /** Abort incomplete multipart uploads this many days after they start. */
2242
+ abortMultipartUploadsAfterDays?: number;
2243
+ /** Move objects to Infrequent Access this many days after upload. */
2244
+ infrequentAccessAfterDays?: number;
2245
+ }
2246
+ export interface R2CustomDomainConfig {
2247
+ /** Hostname served from the bucket, e.g. `tiles.example.com`. Its zone must be on the same Cloudflare account. */
2248
+ domain: string;
2249
+ /** @default '1.2' */
2250
+ minTLS?: R2MinTls;
2251
+ }
2252
+ export interface R2BucketConfig {
2253
+ /** Bucket name (3-63 chars, lowercase letters, digits and hyphens). */
2254
+ name: string;
2255
+ /** Where R2 should try to place the bucket. Only honoured at creation. */
2256
+ locationHint?: R2LocationHint;
2257
+ /** Data-residency jurisdiction. Only honoured at creation. @default 'default' */
2258
+ jurisdiction?: R2Jurisdiction;
2259
+ /**
2260
+ * Hostnames that serve the bucket publicly. Cloudflare creates the proxied
2261
+ * DNS record itself; a hostname that already has a record must have it
2262
+ * removed first. Declared domains are attached, never detached: removing one
2263
+ * from config leaves it attached until removed in the dashboard.
2264
+ */
2265
+ customDomains?: Array<string | R2CustomDomainConfig>;
2266
+ /** Bucket CORS policy. Omit to leave whatever is set alone; `[]` removes it. */
2267
+ cors?: R2CorsRule[];
2268
+ /**
2269
+ * Object lifecycle rules. Omit to leave whatever is set alone. When set, the
2270
+ * list REPLACES the bucket's rules, including the multipart-abort rule R2
2271
+ * adds to new buckets; re-declare it if you want to keep it.
2272
+ */
2273
+ lifecycle?: R2LifecycleRule[];
2274
+ /** Serve the bucket on its public `*.r2.dev` URL. Rate-limited; meant for development. @default false */
2275
+ publicDevUrl?: boolean;
2276
+ /**
2277
+ * Cache the custom domains at Cloudflare's edge. Written as one managed cache
2278
+ * rule (tagged `[ts-cloud]`) scoped to the bucket's custom domains, merged
2279
+ * into the zone's existing rules rather than replacing them.
2280
+ */
2281
+ cache?: {
2282
+ /** Edge TTL in seconds (overrides the origin's Cache-Control). */
2283
+ edgeTtl?: number;
2284
+ /** Browser TTL in seconds (overrides the origin's Cache-Control). */
2285
+ browserTtl?: number;
2286
+ };
2287
+ }
2288
+ export interface R2Config {
2289
+ /** Buckets keyed by a logical name (the key is not the bucket name; `name` is). */
2290
+ buckets: Record<string, R2BucketConfig>;
2291
+ }
2174
2292
  export interface StorageItemConfig {
2175
2293
  /**
2176
2294
  * Physical S3 bucket name. When omitted, defaults to `{slug}-{environment}-{key}`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
3
  "type": "module",
4
- "version": "0.16.39",
4
+ "version": "0.16.41",
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.16.39"
34
+ "@ts-cloud/aws-types": "0.16.41"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^7.0.2"