@stacksjs/ts-cloud 0.2.15 → 0.2.16

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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Multi-provider object storage.
3
+ *
4
+ * AWS S3, Backblaze B2 and Hetzner Object Storage all speak the S3 API and
5
+ * authenticate with AWS Signature V4, so a single {@link S3Client} drives all
6
+ * three — the only differences are the endpoint host, the addressing style and
7
+ * where the credentials come from. This module resolves those differences from
8
+ * a small config object (or environment variables) and hands back a ready
9
+ * {@link S3Client}.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // Backblaze B2 from explicit config
14
+ * const s3 = createObjectStorageClient({
15
+ * provider: 'backblaze',
16
+ * region: 'us-west-004',
17
+ * credentials: { accessKeyId: keyId, secretAccessKey: appKey },
18
+ * })
19
+ * await s3.putObject({ bucket: 'my-bucket', key: 'a.txt', body: 'hi' })
20
+ *
21
+ * // Or entirely from env (OBJECT_STORAGE_PROVIDER=backblaze, B2_* vars set)
22
+ * const s3 = createObjectStorageClient()
23
+ * ```
24
+ */
25
+ import { S3Client } from '../aws/s3';
26
+ export type ObjectStorageProvider = 'aws' | 'backblaze' | 'hetzner';
27
+ export interface ObjectStorageCredentials {
28
+ accessKeyId: string;
29
+ secretAccessKey: string;
30
+ sessionToken?: string;
31
+ }
32
+ export interface ObjectStorageConfig {
33
+ /** Storage provider. Defaults to `OBJECT_STORAGE_PROVIDER`/`STORAGE_PROVIDER` env, then `'aws'`. */
34
+ provider?: ObjectStorageProvider;
35
+ /** Region / location slug. Provider-specific default if omitted (see {@link resolveObjectStorage}). */
36
+ region?: string;
37
+ /** Endpoint host override (no scheme). Defaults to the provider's standard endpoint for the region. */
38
+ endpoint?: string;
39
+ /** Force path-style addressing. Defaults to virtual-hosted, which all three providers support. */
40
+ forcePathStyle?: boolean;
41
+ /** Explicit credentials. When omitted, resolved from provider-specific env vars (see below). */
42
+ credentials?: ObjectStorageCredentials;
43
+ /** AWS named profile (AWS provider only) — ignored by B2/Hetzner. */
44
+ profile?: string;
45
+ }
46
+ export interface ResolvedObjectStorage {
47
+ provider: ObjectStorageProvider;
48
+ region: string;
49
+ /** Endpoint host (no scheme), or undefined for AWS S3 (uses the default AWS endpoint). */
50
+ endpoint?: string;
51
+ forcePathStyle: boolean;
52
+ credentials?: ObjectStorageCredentials;
53
+ profile?: string;
54
+ /** Public HTTPS base URL for a bucket (no trailing slash). */
55
+ publicBaseUrl: (bucket: string) => string;
56
+ }
57
+ /** Standard endpoint host for a provider+region (undefined ⇒ use AWS default). */
58
+ export declare function providerEndpoint(provider: ObjectStorageProvider, region: string): string | undefined;
59
+ /**
60
+ * Resolve a full object-storage configuration from explicit values + environment.
61
+ * Pure and side-effect free — useful for diagnostics and for building both the
62
+ * client and the public URLs consistently.
63
+ */
64
+ export declare function resolveObjectStorage(config?: ObjectStorageConfig): ResolvedObjectStorage;
65
+ /**
66
+ * Create an {@link S3Client} for any supported provider. AWS S3 with no config
67
+ * behaves exactly as `new S3Client()` did before.
68
+ */
69
+ export declare function createObjectStorageClient(config?: ObjectStorageConfig): S3Client;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/ts-cloud",
3
3
  "type": "module",
4
- "version": "0.2.15",
4
+ "version": "0.2.16",
5
5
  "description": "A lightweight, performant infrastructure-as-code library and CLI for deploying both server-based (EC2) and serverless applications.",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
7
7
  "license": "MIT",
@@ -42,6 +42,10 @@
42
42
  "types": "./dist/dns/index.d.ts",
43
43
  "import": "./dist/dns/index.js"
44
44
  },
45
+ "./drivers": {
46
+ "types": "./dist/drivers/index.d.ts",
47
+ "import": "./dist/drivers/index.js"
48
+ },
45
49
  "./push": {
46
50
  "types": "./dist/push/index.d.ts",
47
51
  "import": "./dist/push/index.js"
@@ -85,8 +89,8 @@
85
89
  "test": "bun test"
86
90
  },
87
91
  "dependencies": {
88
- "@ts-cloud/aws-types": "0.2.15",
89
- "@ts-cloud/core": "0.2.15",
92
+ "@ts-cloud/aws-types": "0.2.16",
93
+ "@ts-cloud/core": "0.2.16",
90
94
  "@stacksjs/ts-xml": "^0.1.0"
91
95
  },
92
96
  "devDependencies": {