@storyshelf/storage 0.0.0 → 0.15.1
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/LICENSE +21 -0
- package/README.md +253 -1
- package/dist/azure/client.mjs +38 -0
- package/dist/azure/errors.mjs +38 -0
- package/dist/azure/index.d.mts +13 -0
- package/dist/azure/index.mjs +55 -0
- package/dist/azure/keys.d.mts +6 -0
- package/dist/azure/keys.mjs +14 -0
- package/dist/azure/lifecycle.mjs +33 -0
- package/dist/azure/operations.mjs +51 -0
- package/dist/azure/streams.mjs +43 -0
- package/dist/azure/types.d.mts +31 -0
- package/dist/gcs/client.mjs +24 -0
- package/dist/gcs/errors.mjs +13 -0
- package/dist/gcs/index.d.mts +13 -0
- package/dist/gcs/index.mjs +50 -0
- package/dist/gcs/keys.d.mts +6 -0
- package/dist/gcs/keys.mjs +14 -0
- package/dist/gcs/lifecycle.mjs +27 -0
- package/dist/gcs/operations.mjs +48 -0
- package/dist/gcs/streams.mjs +27 -0
- package/dist/gcs/types.d.mts +21 -0
- package/dist/local/index.d.mts +4 -0
- package/dist/local/index.mjs +4 -0
- package/dist/s3/client.mjs +23 -0
- package/dist/s3/errors.mjs +15 -0
- package/dist/s3/index.d.mts +13 -0
- package/dist/s3/index.mjs +51 -0
- package/dist/s3/keys.d.mts +6 -0
- package/dist/s3/keys.mjs +14 -0
- package/dist/s3/lifecycle.mjs +35 -0
- package/dist/s3/operations.mjs +62 -0
- package/dist/s3/streams.mjs +43 -0
- package/dist/s3/types.d.mts +17 -0
- package/package.json +106 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Siddhant Gupta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,255 @@
|
|
|
1
1
|
# @storyshelf/storage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Storage adapters for StoryShelf, one subpath per backend: S3-compatible stores (`/s3`), Google Cloud Storage (`/gcs`), Azure Blob Storage (`/azure`) and local disk (`/local`).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Install the package and **only the SDK of the backend you use**. The cloud SDKs are optional peer dependencies, and a subpath loads only its own, so a server that uses `/s3` never has the Google or Azure SDK in `node_modules`.
|
|
8
|
+
|
|
9
|
+
| Subpath | Install next to `@storyshelf/storage` |
|
|
10
|
+
| --------------------- | ------------------------------------------------------ |
|
|
11
|
+
| `@storyshelf/storage/s3` | `@aws-sdk/client-s3` and `@aws-sdk/lib-storage` |
|
|
12
|
+
| `@storyshelf/storage/gcs` | `@google-cloud/storage` |
|
|
13
|
+
| `@storyshelf/storage/azure` | `@azure/storage-blob` and `@azure/identity` |
|
|
14
|
+
| `@storyshelf/storage/local` | nothing |
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
nub add @storyshelf/storage @aws-sdk/client-s3 @aws-sdk/lib-storage
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
or
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm install @storyshelf/storage @aws-sdk/client-s3 @aws-sdk/lib-storage
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`create-storyshelf` adds the right SDK for the storage you choose. The SDKs supply credentials (environment, IRSA and workload identity, the metadata servers, managed identity), request signing, retries and multipart uploads, which is why StoryShelf uses them instead of calling the REST APIs itself.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
Every backend is one import. Switching from local disk to S3 changes the import path and nothing else:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { createShelfApp } from "@storyshelf/app";
|
|
34
|
+
import { createLocalStorage } from "@storyshelf/storage/local"; // same as @storyshelf/core/storage/local
|
|
35
|
+
import { createS3Storage } from "@storyshelf/storage/s3";
|
|
36
|
+
import { createGcsStorage } from "@storyshelf/storage/gcs";
|
|
37
|
+
import { createAzureStorage } from "@storyshelf/storage/azure";
|
|
38
|
+
|
|
39
|
+
const app = createShelfApp({ database, storage: createS3Storage({ bucket: "my-shelf" }) });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`/local` re-exports core's built-in local storage and adds no dependency. The implementation stays in `@storyshelf/core/storage/local`, so a server that never installs this package still has local storage.
|
|
43
|
+
|
|
44
|
+
## S3-compatible stores (`/s3`)
|
|
45
|
+
|
|
46
|
+
AWS S3, Cloudflare R2, MinIO, Backblaze B2, Wasabi, DigitalOcean Spaces and Tigris all use `/s3`; point `endpoint` at the service.
|
|
47
|
+
|
|
48
|
+
### Usage
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createS3Storage } from "@storyshelf/storage/s3";
|
|
52
|
+
import { createShelfApp } from "@storyshelf/app";
|
|
53
|
+
|
|
54
|
+
const storage = createS3Storage({
|
|
55
|
+
bucket: "my-shelf",
|
|
56
|
+
prefix: "storyshelf",
|
|
57
|
+
endpoint: process.env.S3_ENDPOINT, // optional, e.g. for MinIO/R2
|
|
58
|
+
region: "us-east-1", // optional
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const app = createShelfApp({ database, storage });
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### API
|
|
65
|
+
|
|
66
|
+
#### `S3StorageOptions`
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
interface S3StorageOptions {
|
|
70
|
+
bucket: string; // required bucket name
|
|
71
|
+
prefix?: string; // optional key prefix, defaults to ""
|
|
72
|
+
endpoint?: string; // optional custom endpoint (MinIO, R2, etc.)
|
|
73
|
+
region?: string; // optional region, defaults to "us-east-1"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### `createS3Storage(options: S3StorageOptions): StorageAdapter`
|
|
78
|
+
|
|
79
|
+
Creates an S3 client (with `forcePathStyle` enabled for compatibility with MinIO/R2) and returns a `StorageAdapter`. The returned adapter implements every method of the `StorageAdapter` interface (`read`, `write`, `delete`, `exists`, `list(prefix)`).
|
|
80
|
+
|
|
81
|
+
#### `s3Key(prefix: string, path: string): string`
|
|
82
|
+
|
|
83
|
+
Helper that joins a storage prefix with a relative path into an object key.
|
|
84
|
+
|
|
85
|
+
## Google Cloud Storage (`/gcs`)
|
|
86
|
+
|
|
87
|
+
### Usage
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { createGcsStorage } from "@storyshelf/storage/gcs";
|
|
91
|
+
import { createShelfApp } from "@storyshelf/app";
|
|
92
|
+
|
|
93
|
+
const storage = createGcsStorage({
|
|
94
|
+
bucket: "my-shelf",
|
|
95
|
+
prefix: "storyshelf", // optional
|
|
96
|
+
projectId: "my-gcp-project", // optional, defaults to ADC
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const app = createShelfApp({ database, storage });
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For local emulators or custom endpoints:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
const storage = createGcsStorage({
|
|
106
|
+
bucket: "my-shelf",
|
|
107
|
+
apiEndpoint: "http://localhost:9090",
|
|
108
|
+
projectId: "test-project",
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Inject a pre-configured client (tests / IAM-rotation):
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { Storage } from "@google-cloud/storage";
|
|
116
|
+
|
|
117
|
+
const client = new Storage({ projectId: "my-project" });
|
|
118
|
+
const storage = createGcsStorage({ bucket: "my-shelf", client });
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### API
|
|
122
|
+
|
|
123
|
+
#### `GcsStorageOptions`
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
interface GcsStorageOptions {
|
|
127
|
+
bucket: string; // required GCS bucket name
|
|
128
|
+
prefix?: string; // optional key prefix, defaults to ""
|
|
129
|
+
client?: Storage; // optional pre-configured @google-cloud/storage client
|
|
130
|
+
projectId?: string; // optional GCP project id
|
|
131
|
+
keyFilename?: string; // optional path to service-account JSON
|
|
132
|
+
credentials?: object; // optional service-account credentials object
|
|
133
|
+
apiEndpoint?: string; // optional custom endpoint (emulator)
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Options at a glance:
|
|
138
|
+
|
|
139
|
+
| Option | Required | Notes |
|
|
140
|
+
| ------------- | -------- | -------------------------------------------------------- |
|
|
141
|
+
| `bucket` | yes | GCS bucket name |
|
|
142
|
+
| `prefix` | no | Key prefix for every object |
|
|
143
|
+
| `client` | no | Pre-built `Storage` client (tests, custom endpoint) |
|
|
144
|
+
| `projectId` | no | GCP project ID (defaults to ADC) |
|
|
145
|
+
| `keyFilename` | no | Path to service-account JSON |
|
|
146
|
+
| `credentials` | no | Inline service-account object |
|
|
147
|
+
| `apiEndpoint` | no | Custom endpoint (emulator, e.g. `http://localhost:9090`) |
|
|
148
|
+
|
|
149
|
+
Auth otherwise uses Application Default Credentials.
|
|
150
|
+
|
|
151
|
+
#### `createGcsStorage(options: GcsStorageOptions): StorageAdapter`
|
|
152
|
+
|
|
153
|
+
Creates a `StorageAdapter` backed by the configured GCS bucket. The returned adapter implements every method of the `StorageAdapter` interface (`read`, `write`, `delete`, `exists`, `list(prefix)`, `readStream`, `writeStream`).
|
|
154
|
+
|
|
155
|
+
#### `gcsKey(prefix: string, path: string): string`
|
|
156
|
+
|
|
157
|
+
Helper that joins a storage prefix with a relative path into an object key.
|
|
158
|
+
|
|
159
|
+
## Azure Blob Storage (`/azure`)
|
|
160
|
+
|
|
161
|
+
### Usage
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import { createAzureStorage } from "@storyshelf/storage/azure";
|
|
165
|
+
import { createShelfApp } from "@storyshelf/app";
|
|
166
|
+
|
|
167
|
+
// Via connection string (recommended for local / Azurite)
|
|
168
|
+
const storage = createAzureStorage({
|
|
169
|
+
container: "storyshelf",
|
|
170
|
+
prefix: "storyshelf", // optional
|
|
171
|
+
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// Via account name + key
|
|
175
|
+
const storage2 = createAzureStorage({
|
|
176
|
+
container: "storyshelf",
|
|
177
|
+
accountName: "myaccount",
|
|
178
|
+
accountKey: process.env.AZURE_STORAGE_KEY,
|
|
179
|
+
accountUrl: "https://myaccount.blob.core.windows.net", // optional, derived from accountName if omitted
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const app = createShelfApp({ database, storage });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Inject a pre-configured client (tests / custom credential rotation):
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { BlobServiceClient } from "@azure/storage-blob";
|
|
189
|
+
|
|
190
|
+
const service = BlobServiceClient.fromConnectionString(connStr);
|
|
191
|
+
const containerClient = service.getContainerClient("storyshelf");
|
|
192
|
+
const storage = createAzureStorage({ container: "storyshelf", client: containerClient });
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Azurite (local emulator):
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const storage = createAzureStorage({
|
|
199
|
+
container: "storyshelf",
|
|
200
|
+
connectionString:
|
|
201
|
+
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;",
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### API
|
|
206
|
+
|
|
207
|
+
#### `AzureStorageOptions`
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
interface AzureStorageOptions {
|
|
211
|
+
container: string; // required container name
|
|
212
|
+
prefix?: string; // optional blob prefix, defaults to ""
|
|
213
|
+
client?: ContainerClient; // optional pre-configured container client
|
|
214
|
+
connectionString?: string; // optional Azure connection string
|
|
215
|
+
accountName?: string; // optional storage account name
|
|
216
|
+
accountKey?: string; // optional storage account key
|
|
217
|
+
accountUrl?: string; // optional blob service URL (e.g. https://myaccount.blob.core.windows.net)
|
|
218
|
+
sasToken?: string; // optional SAS token (without leading ? OK)
|
|
219
|
+
credential?: TokenCredential; // optional Entra credential; default DefaultAzureCredential
|
|
220
|
+
managedIdentityClientId?: string; // client id of a user-assigned managed identity
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Options at a glance:
|
|
225
|
+
|
|
226
|
+
| Option | Required | Notes |
|
|
227
|
+
| ---------------------------- | -------- | ------------------------------------------------------ |
|
|
228
|
+
| `container` | yes | Blob container name |
|
|
229
|
+
| `prefix` | no | Key prefix applied to every object |
|
|
230
|
+
| `client` | no | Pre-built `ContainerClient`; skips client construction |
|
|
231
|
+
| `connectionString` | no\* | Storage connection string |
|
|
232
|
+
| `accountName` / `accountKey` | no\* | Explicit credentials pair |
|
|
233
|
+
| `accountUrl` / `sasToken` | no\* | URL + SAS form (emulator, fine-grained SAS) |
|
|
234
|
+
| `accountName` alone | no\* | Entra: `DefaultAzureCredential` (managed identity) |
|
|
235
|
+
| `managedIdentityClientId` | no | Picks a user-assigned identity for the default |
|
|
236
|
+
| `credential` | no | Your own `TokenCredential`, instead of the default |
|
|
237
|
+
|
|
238
|
+
`*` One auth form is needed unless `client` is supplied. With only an account name or URL (no key,
|
|
239
|
+
SAS token or connection string) the adapter signs in with `DefaultAzureCredential`: a managed
|
|
240
|
+
identity on Azure, `az login` locally. The identity needs `Storage Blob Data Contributor` on the
|
|
241
|
+
container. An anonymous (public) container is no longer the fallback; give a `client` for that.
|
|
242
|
+
|
|
243
|
+
#### `createAzureStorage(options: AzureStorageOptions): StorageAdapter`
|
|
244
|
+
|
|
245
|
+
Creates a `StorageAdapter` backed by the configured Azure container. The returned adapter implements every method of the `StorageAdapter` interface (`read`, `write`, `delete`, `exists`, `list(prefix)`, `readStream`, `writeStream`).
|
|
246
|
+
|
|
247
|
+
#### `azureKey(prefix: string, path: string): string`
|
|
248
|
+
|
|
249
|
+
Helper that joins a storage prefix with a relative path into a blob name.
|
|
250
|
+
|
|
251
|
+
## How it fits in
|
|
252
|
+
|
|
253
|
+
Each factory returns a `StorageAdapter`, the `storage` option of `createShelfApp`, so backends are interchangeable. `StorageAdapter` is an open extension point: write your own against `@storyshelf/core/adapter/storage`.
|
|
254
|
+
|
|
255
|
+
See `docs/architecture/storage.md` and ADR 0003.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
5
|
+
import { BlobServiceClient, StorageSharedKeyCredential } from "@azure/storage-blob";
|
|
6
|
+
// src/azure/client.ts
|
|
7
|
+
/** Resolve the container client for the configured credentials. */
|
|
8
|
+
function resolveContainerClient(options, containerName) {
|
|
9
|
+
if (options.client) return options.client;
|
|
10
|
+
if (options.connectionString) return BlobServiceClient.fromConnectionString(options.connectionString).getContainerClient(containerName);
|
|
11
|
+
return resolveFromAccount(options, containerName);
|
|
12
|
+
}
|
|
13
|
+
function resolveFromAccount(options, containerName) {
|
|
14
|
+
const url = options.accountUrl ?? buildAccountUrl(options.accountName);
|
|
15
|
+
if (!url) throw new Error("createAzureStorage: provide `client`, `connectionString`, or `accountName`/`accountUrl`");
|
|
16
|
+
if (options.accountName && options.accountKey) {
|
|
17
|
+
const cred = new StorageSharedKeyCredential(options.accountName, options.accountKey);
|
|
18
|
+
return new BlobServiceClient(url, cred).getContainerClient(containerName);
|
|
19
|
+
}
|
|
20
|
+
if (options.sasToken) {
|
|
21
|
+
const token = options.sasToken.replace(/^\?/u, "");
|
|
22
|
+
return new BlobServiceClient(`${url}?${token}`).getContainerClient(containerName);
|
|
23
|
+
}
|
|
24
|
+
return new BlobServiceClient(url, credentialFor(options)).getContainerClient(containerName);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The Entra credential for an account with no key or SAS token: the one given, else
|
|
28
|
+
* `DefaultAzureCredential` (managed identity on Azure, `az login` locally). `managedIdentityClientId`
|
|
29
|
+
* picks a user-assigned identity. The credential never appears in a message or a log.
|
|
30
|
+
*/
|
|
31
|
+
function credentialFor(options) {
|
|
32
|
+
return options.credential ?? new DefaultAzureCredential(options.managedIdentityClientId === void 0 ? {} : { managedIdentityClientId: options.managedIdentityClientId });
|
|
33
|
+
}
|
|
34
|
+
function buildAccountUrl(accountName) {
|
|
35
|
+
if (!accountName) return;
|
|
36
|
+
return `https://${accountName}.blob.core.windows.net`;
|
|
37
|
+
}
|
|
38
|
+
export { resolveContainerClient };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import "node:stream";
|
|
5
|
+
// src/azure/errors.ts
|
|
6
|
+
/** Not-found guards and stream/collect helpers for Azure blob I/O. */
|
|
7
|
+
/** True when an Azure SDK error means the blob (or container) is missing. */
|
|
8
|
+
function isNotFound(error) {
|
|
9
|
+
const err = error;
|
|
10
|
+
if (err.statusCode === 404) return true;
|
|
11
|
+
return err.code === "BlobNotFound" || err.code === "ContainerNotFound" || err.code === "404";
|
|
12
|
+
}
|
|
13
|
+
/** Download a blob through the `download()` response stream. */
|
|
14
|
+
async function collectDownload(blob) {
|
|
15
|
+
const body = (await blob.download()).readableStreamBody;
|
|
16
|
+
if (!body) return Buffer.alloc(0);
|
|
17
|
+
const chunks = [];
|
|
18
|
+
for await (const chunk of body) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : Buffer.from(chunk));
|
|
19
|
+
return Buffer.concat(chunks);
|
|
20
|
+
}
|
|
21
|
+
/** Buffer an incoming readable into a single Buffer. */
|
|
22
|
+
async function collectStream(stream) {
|
|
23
|
+
const chunks = [];
|
|
24
|
+
for await (const chunk of stream) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : Buffer.from(chunk));
|
|
25
|
+
return Buffer.concat(chunks);
|
|
26
|
+
}
|
|
27
|
+
/** Best-effort blob delete used to clean up after failed stream uploads. */
|
|
28
|
+
async function deleteBlobQuiet(blob) {
|
|
29
|
+
try {
|
|
30
|
+
const withDelete = blob;
|
|
31
|
+
if (typeof withDelete.deleteIfExists === "function") {
|
|
32
|
+
await withDelete.deleteIfExists();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
await withDelete.delete?.();
|
|
36
|
+
} catch {}
|
|
37
|
+
}
|
|
38
|
+
export { collectDownload, collectStream, deleteBlobQuiet, isNotFound };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { AzureStorageOptions } from "./types.mjs";
|
|
4
|
+
import { azureKey } from "./keys.mjs";
|
|
5
|
+
import { StorageAdapter } from "@storyshelf/core/adapter/storage";
|
|
6
|
+
/**
|
|
7
|
+
* Create an Azure Blob Storage-backed StorageAdapter.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Azure configuration options.
|
|
10
|
+
* @returns A StorageAdapter backed by the configured Azure container.
|
|
11
|
+
*/
|
|
12
|
+
declare function createAzureStorage(options: AzureStorageOptions): StorageAdapter;
|
|
13
|
+
export { type AzureStorageOptions, azureKey, createAzureStorage };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { resolveContainerClient } from "./client.mjs";
|
|
5
|
+
import { buildAzureLifecycle } from "./lifecycle.mjs";
|
|
6
|
+
import { azureKey } from "./keys.mjs";
|
|
7
|
+
import { azureDelete, azureExists, azureList, azureRead, azureWrite } from "./operations.mjs";
|
|
8
|
+
import { azureReadStream, azureWriteStream } from "./streams.mjs";
|
|
9
|
+
// src/azure/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* Create an Azure Blob Storage-backed StorageAdapter.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Azure configuration options.
|
|
14
|
+
* @returns A StorageAdapter backed by the configured Azure container.
|
|
15
|
+
*/
|
|
16
|
+
function createAzureStorage(options) {
|
|
17
|
+
const { container: containerName, prefix = "" } = options;
|
|
18
|
+
const container = resolveContainerClient(options, containerName);
|
|
19
|
+
const ctx = {
|
|
20
|
+
container,
|
|
21
|
+
prefix
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
metadata: {
|
|
25
|
+
name: "Azure Blob Storage",
|
|
26
|
+
version: "0.15.1",
|
|
27
|
+
description: "Azure Blob Storage adapter",
|
|
28
|
+
kind: "azure",
|
|
29
|
+
category: "storage"
|
|
30
|
+
},
|
|
31
|
+
lifecycle: buildAzureLifecycle(container, containerName),
|
|
32
|
+
async read(path) {
|
|
33
|
+
return await azureRead(ctx, path);
|
|
34
|
+
},
|
|
35
|
+
async write(path, data) {
|
|
36
|
+
await azureWrite(ctx, path, data);
|
|
37
|
+
},
|
|
38
|
+
async delete(path) {
|
|
39
|
+
await azureDelete(ctx, path);
|
|
40
|
+
},
|
|
41
|
+
async exists(path) {
|
|
42
|
+
return await azureExists(ctx, path);
|
|
43
|
+
},
|
|
44
|
+
async list(listPrefix) {
|
|
45
|
+
return await azureList(ctx, listPrefix);
|
|
46
|
+
},
|
|
47
|
+
async writeStream(path, stream) {
|
|
48
|
+
await azureWriteStream(ctx, path, stream);
|
|
49
|
+
},
|
|
50
|
+
async readStream(path) {
|
|
51
|
+
return await azureReadStream(ctx, path);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export { azureKey, createAzureStorage };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
/** Key join/split for Azure blob names. */
|
|
4
|
+
/** Join an optional prefix with a storage path. */
|
|
5
|
+
declare function azureKey(prefix: string, path: string): string;
|
|
6
|
+
export { azureKey };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
// src/azure/keys.ts
|
|
5
|
+
/** Key join/split for Azure blob names. */
|
|
6
|
+
/** Join an optional prefix with a storage path. */
|
|
7
|
+
function azureKey(prefix, path) {
|
|
8
|
+
return prefix === "" ? path : `${prefix}/${path}`;
|
|
9
|
+
}
|
|
10
|
+
/** Strip a storage prefix back off a blob name. */
|
|
11
|
+
function azureRel(prefix, key) {
|
|
12
|
+
return prefix === "" ? key : key.slice(prefix.length + 1);
|
|
13
|
+
}
|
|
14
|
+
export { azureKey, azureRel };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
// src/azure/lifecycle.ts
|
|
5
|
+
/** Build the setup/health/teardown lifecycle for an Azure container. */
|
|
6
|
+
function buildAzureLifecycle(container, containerName) {
|
|
7
|
+
return {
|
|
8
|
+
setup: async () => {
|
|
9
|
+
await containerExists(container, containerName);
|
|
10
|
+
},
|
|
11
|
+
teardown: async () => {
|
|
12
|
+
await Promise.resolve();
|
|
13
|
+
},
|
|
14
|
+
health: async () => {
|
|
15
|
+
await containerExists(container, containerName);
|
|
16
|
+
return { ok: true };
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function containerExists(container, containerName) {
|
|
21
|
+
const exists = container.exists;
|
|
22
|
+
if (typeof exists === "function") {
|
|
23
|
+
if (!await exists.call(container)) throw new Error(`Container not found: ${containerName}`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const iterator = container.listBlobsFlat({ prefix: "" })[Symbol.asyncIterator]();
|
|
27
|
+
try {
|
|
28
|
+
await iterator.next();
|
|
29
|
+
} finally {
|
|
30
|
+
await iterator.return?.();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export { buildAzureLifecycle };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { collectDownload, isNotFound } from "./errors.mjs";
|
|
5
|
+
import { azureKey, azureRel } from "./keys.mjs";
|
|
6
|
+
// src/azure/operations.ts
|
|
7
|
+
/** Buffered Azure blob CRUD with SDK-version duck-typing and async-iterator list. */
|
|
8
|
+
/** Download a blob, preferring `downloadToBuffer` when the SDK offers it. */
|
|
9
|
+
async function azureRead(ctx, path) {
|
|
10
|
+
const blob = ctx.container.getBlockBlobClient(azureKey(ctx.prefix, path));
|
|
11
|
+
if (typeof blob.downloadToBuffer === "function") return await blob.downloadToBuffer();
|
|
12
|
+
return await collectDownload(blob);
|
|
13
|
+
}
|
|
14
|
+
/** Upload a buffer, accepting either `uploadData` or `upload` SDK shapes. */
|
|
15
|
+
async function azureWrite(ctx, path, data) {
|
|
16
|
+
const withData = ctx.container.getBlockBlobClient(azureKey(ctx.prefix, path));
|
|
17
|
+
if (typeof withData.uploadData === "function") {
|
|
18
|
+
await withData.uploadData(data);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (typeof withData.upload === "function") {
|
|
22
|
+
await withData.upload(data, data.length);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Azure Blob client does not support upload");
|
|
26
|
+
}
|
|
27
|
+
/** Delete a blob, treating missing blobs as success. */
|
|
28
|
+
async function azureDelete(ctx, path) {
|
|
29
|
+
const withDelete = ctx.container.getBlockBlobClient(azureKey(ctx.prefix, path));
|
|
30
|
+
if (typeof withDelete.deleteIfExists === "function") {
|
|
31
|
+
await withDelete.deleteIfExists();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
await withDelete.delete?.();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (!isNotFound(error)) throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Check whether a blob exists. */
|
|
41
|
+
async function azureExists(ctx, path) {
|
|
42
|
+
return await ctx.container.getBlockBlobClient(azureKey(ctx.prefix, path)).exists();
|
|
43
|
+
}
|
|
44
|
+
/** List blob names under a prefix, with the storage prefix stripped. */
|
|
45
|
+
async function azureList(ctx, listPrefix) {
|
|
46
|
+
const prefix = azureKey(ctx.prefix, listPrefix);
|
|
47
|
+
const blobs = [];
|
|
48
|
+
for await (const item of ctx.container.listBlobsFlat(prefix === "" ? void 0 : { prefix })) blobs.push(azureRel(ctx.prefix, item.name));
|
|
49
|
+
return blobs;
|
|
50
|
+
}
|
|
51
|
+
export { azureDelete, azureExists, azureList, azureRead, azureWrite };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { collectStream, deleteBlobQuiet } from "./errors.mjs";
|
|
5
|
+
import { azureKey } from "./keys.mjs";
|
|
6
|
+
import { azureExists, azureWrite } from "./operations.mjs";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
8
|
+
// src/azure/streams.ts
|
|
9
|
+
/** Streamed Azure blob reads and writes, with failure cleanup. */
|
|
10
|
+
/** Upload a readable, streaming when the SDK supports it and buffering otherwise. */
|
|
11
|
+
async function azureWriteStream(ctx, path, stream) {
|
|
12
|
+
const blob = ctx.container.getBlockBlobClient(azureKey(ctx.prefix, path));
|
|
13
|
+
if (await tryAzureStreamUpload(blob, stream)) return;
|
|
14
|
+
await writeStreamBuffered(ctx, path, stream, blob);
|
|
15
|
+
}
|
|
16
|
+
/** Download a blob as a readable, rejecting when the blob is missing. */
|
|
17
|
+
async function azureReadStream(ctx, path) {
|
|
18
|
+
if (!await azureExists(ctx, path)) throw new Error(`No object at "${path}"`);
|
|
19
|
+
const body = (await ctx.container.getBlockBlobClient(azureKey(ctx.prefix, path)).download()).readableStreamBody;
|
|
20
|
+
if (!body) return Readable.from([]);
|
|
21
|
+
return body;
|
|
22
|
+
}
|
|
23
|
+
async function tryAzureStreamUpload(blob, stream) {
|
|
24
|
+
const withStream = blob;
|
|
25
|
+
if (typeof withStream.uploadStream !== "function") return false;
|
|
26
|
+
try {
|
|
27
|
+
await withStream.uploadStream(stream);
|
|
28
|
+
return true;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
await deleteBlobQuiet(blob);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function writeStreamBuffered(ctx, path, stream, blob) {
|
|
35
|
+
try {
|
|
36
|
+
const data = await collectStream(stream);
|
|
37
|
+
await azureWrite(ctx, path, data);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
await deleteBlobQuiet(blob);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export { azureReadStream, azureWriteStream };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { TokenCredential } from "@azure/identity";
|
|
4
|
+
import { ContainerClient } from "@azure/storage-blob";
|
|
5
|
+
/** Options for configuring an Azure Blob Storage adapter. */
|
|
6
|
+
interface AzureStorageOptions {
|
|
7
|
+
/** Azure container name. */
|
|
8
|
+
container: string;
|
|
9
|
+
/** Optional blob prefix applied to all stored objects. */
|
|
10
|
+
prefix?: string;
|
|
11
|
+
/** Pre-configured container client. */
|
|
12
|
+
client?: ContainerClient;
|
|
13
|
+
/** Azure Storage connection string. */
|
|
14
|
+
connectionString?: string;
|
|
15
|
+
/** Storage account name. */
|
|
16
|
+
accountName?: string;
|
|
17
|
+
/** Storage account key. */
|
|
18
|
+
accountKey?: string;
|
|
19
|
+
/** Blob service URL (e.g. https://myaccount.blob.core.windows.net). */
|
|
20
|
+
accountUrl?: string;
|
|
21
|
+
/** SAS token (with or without leading `?`). */
|
|
22
|
+
sasToken?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Entra credential for an account with no key or SAS token. Defaults to `DefaultAzureCredential`
|
|
25
|
+
* (managed identity on Azure), so an account name alone reads and writes with the host's identity.
|
|
26
|
+
*/
|
|
27
|
+
credential?: TokenCredential;
|
|
28
|
+
/** Client id of a user-assigned managed identity, for the default credential. */
|
|
29
|
+
managedIdentityClientId?: string;
|
|
30
|
+
}
|
|
31
|
+
export { AzureStorageOptions };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { Storage } from "@google-cloud/storage";
|
|
5
|
+
// src/gcs/client.ts
|
|
6
|
+
/** GCS Storage client construction and shared operation context. */
|
|
7
|
+
/** Build the bucket handle plus key prefix every GCS operation threads through. */
|
|
8
|
+
function createGcsContext(options) {
|
|
9
|
+
const { bucket: bucketName, prefix = "", client: injectedClient } = options;
|
|
10
|
+
return {
|
|
11
|
+
bucket: (injectedClient ?? new Storage(resolveClientOptions(options))).bucket(bucketName),
|
|
12
|
+
prefix
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Translate adapter options into @google-cloud/storage constructor options. */
|
|
16
|
+
function resolveClientOptions(options) {
|
|
17
|
+
const config = {};
|
|
18
|
+
if (options.projectId !== void 0) config.projectId = options.projectId;
|
|
19
|
+
if (options.keyFilename !== void 0) config.keyFilename = options.keyFilename;
|
|
20
|
+
if (options.credentials !== void 0) config.credentials = options.credentials;
|
|
21
|
+
if (options.apiEndpoint !== void 0) config.apiEndpoint = options.apiEndpoint;
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
export { createGcsContext, resolveClientOptions };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
// src/gcs/errors.ts
|
|
5
|
+
/** Not-found guard for GCS API errors. */
|
|
6
|
+
/** Return whether a GCS error signals a missing object. */
|
|
7
|
+
function isNotFound(error) {
|
|
8
|
+
const err = error;
|
|
9
|
+
if (err.code === 404 || err.code === "404" || err.code === "notFound") return true;
|
|
10
|
+
if (err.statusCode === 404) return true;
|
|
11
|
+
return err.errors?.[0]?.reason === "notFound";
|
|
12
|
+
}
|
|
13
|
+
export { isNotFound };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { GcsStorageOptions } from "./types.mjs";
|
|
4
|
+
import { gcsKey } from "./keys.mjs";
|
|
5
|
+
import { StorageAdapter } from "@storyshelf/core/adapter/storage";
|
|
6
|
+
/**
|
|
7
|
+
* Create a Google Cloud Storage (GCS) StorageAdapter.
|
|
8
|
+
*
|
|
9
|
+
* @param options - GCS configuration options.
|
|
10
|
+
* @returns A StorageAdapter backed by the configured GCS bucket.
|
|
11
|
+
*/
|
|
12
|
+
declare function createGcsStorage(options: GcsStorageOptions): StorageAdapter;
|
|
13
|
+
export { type GcsStorageOptions, createGcsStorage, gcsKey };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { createGcsContext } from "./client.mjs";
|
|
5
|
+
import { createGcsLifecycle } from "./lifecycle.mjs";
|
|
6
|
+
import { gcsKey } from "./keys.mjs";
|
|
7
|
+
import { gcsDelete, gcsExists, gcsList, gcsRead, gcsWrite } from "./operations.mjs";
|
|
8
|
+
import { gcsReadStream, gcsWriteStream } from "./streams.mjs";
|
|
9
|
+
// src/gcs/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* Create a Google Cloud Storage (GCS) StorageAdapter.
|
|
12
|
+
*
|
|
13
|
+
* @param options - GCS configuration options.
|
|
14
|
+
* @returns A StorageAdapter backed by the configured GCS bucket.
|
|
15
|
+
*/
|
|
16
|
+
function createGcsStorage(options) {
|
|
17
|
+
const ctx = createGcsContext(options);
|
|
18
|
+
return {
|
|
19
|
+
metadata: {
|
|
20
|
+
name: "GCS Storage",
|
|
21
|
+
version: "0.15.1",
|
|
22
|
+
description: "Google Cloud Storage adapter",
|
|
23
|
+
kind: "gcs",
|
|
24
|
+
category: "storage"
|
|
25
|
+
},
|
|
26
|
+
lifecycle: createGcsLifecycle(ctx),
|
|
27
|
+
async read(path) {
|
|
28
|
+
return await gcsRead(ctx, path);
|
|
29
|
+
},
|
|
30
|
+
async write(path, data) {
|
|
31
|
+
await gcsWrite(ctx, path, data);
|
|
32
|
+
},
|
|
33
|
+
async delete(path) {
|
|
34
|
+
await gcsDelete(ctx, path);
|
|
35
|
+
},
|
|
36
|
+
async exists(path) {
|
|
37
|
+
return await gcsExists(ctx, path);
|
|
38
|
+
},
|
|
39
|
+
async list(listPrefix) {
|
|
40
|
+
return await gcsList(ctx, listPrefix);
|
|
41
|
+
},
|
|
42
|
+
async writeStream(path, stream) {
|
|
43
|
+
await gcsWriteStream(ctx, path, stream);
|
|
44
|
+
},
|
|
45
|
+
async readStream(path) {
|
|
46
|
+
return await gcsReadStream(ctx, path);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export { createGcsStorage, gcsKey };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
/** Key join/split for GCS object keys. */
|
|
4
|
+
/** Join an optional key prefix with a storage path. */
|
|
5
|
+
declare function gcsKey(prefix: string, path: string): string;
|
|
6
|
+
export { gcsKey };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
// src/gcs/keys.ts
|
|
5
|
+
/** Key join/split for GCS object keys. */
|
|
6
|
+
/** Join an optional key prefix with a storage path. */
|
|
7
|
+
function gcsKey(prefix, path) {
|
|
8
|
+
return prefix === "" ? path : `${prefix}/${path}`;
|
|
9
|
+
}
|
|
10
|
+
/** Strip a key prefix from a full GCS object name (inverse of gcsKey). */
|
|
11
|
+
function gcsRel(prefix, key) {
|
|
12
|
+
return prefix === "" ? key : key.slice(prefix.length + 1);
|
|
13
|
+
}
|
|
14
|
+
export { gcsKey, gcsRel };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
// src/gcs/lifecycle.ts
|
|
5
|
+
/** Build the setup/health/teardown hooks probing a GCS bucket. */
|
|
6
|
+
function createGcsLifecycle(ctx) {
|
|
7
|
+
return {
|
|
8
|
+
setup: async () => {
|
|
9
|
+
await ctx.bucket.getFiles(gcsHealthQuery(ctx.prefix));
|
|
10
|
+
},
|
|
11
|
+
teardown: async () => {
|
|
12
|
+
await Promise.resolve();
|
|
13
|
+
},
|
|
14
|
+
health: async () => {
|
|
15
|
+
await ctx.bucket.getFiles(gcsHealthQuery(ctx.prefix));
|
|
16
|
+
return { ok: true };
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Single-object probe query scoped to the configured prefix. */
|
|
21
|
+
function gcsHealthQuery(prefix) {
|
|
22
|
+
return prefix === "" ? { maxResults: 1 } : {
|
|
23
|
+
prefix: `${prefix}/`,
|
|
24
|
+
maxResults: 1
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export { createGcsLifecycle, gcsHealthQuery };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { isNotFound } from "./errors.mjs";
|
|
5
|
+
import { gcsKey, gcsRel } from "./keys.mjs";
|
|
6
|
+
// src/gcs/operations.ts
|
|
7
|
+
/** Download the full bytes stored at `path`. */
|
|
8
|
+
async function gcsRead(ctx, path) {
|
|
9
|
+
const [data] = await ctx.bucket.file(gcsKey(ctx.prefix, path)).download();
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
/** Save `data` at `path`, overwriting any existing object. */
|
|
13
|
+
async function gcsWrite(ctx, path, data) {
|
|
14
|
+
await ctx.bucket.file(gcsKey(ctx.prefix, path)).save(data);
|
|
15
|
+
}
|
|
16
|
+
/** Delete the object at `path`, ignoring not-found errors. */
|
|
17
|
+
async function gcsDelete(ctx, path) {
|
|
18
|
+
try {
|
|
19
|
+
await ctx.bucket.file(gcsKey(ctx.prefix, path)).delete();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (!isNotFound(error)) throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Return whether an object exists at `path`. */
|
|
25
|
+
async function gcsExists(ctx, path) {
|
|
26
|
+
const [exists] = await ctx.bucket.file(gcsKey(ctx.prefix, path)).exists();
|
|
27
|
+
return exists;
|
|
28
|
+
}
|
|
29
|
+
/** List paths under `listPrefix`, following pagination to exhaustion. */
|
|
30
|
+
async function gcsList(ctx, listPrefix) {
|
|
31
|
+
const prefix = gcsKey(ctx.prefix, listPrefix);
|
|
32
|
+
const results = [];
|
|
33
|
+
let query = prefix === "" ? { autoPaginate: false } : {
|
|
34
|
+
prefix,
|
|
35
|
+
autoPaginate: false
|
|
36
|
+
};
|
|
37
|
+
while (query !== void 0) {
|
|
38
|
+
const [files, nextQuery] = await ctx.bucket.getFiles(query);
|
|
39
|
+
for (const file of files) results.push(gcsRel(ctx.prefix, file.name));
|
|
40
|
+
query = nextQueryQuery(nextQuery);
|
|
41
|
+
}
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
function nextQueryQuery(nextQuery) {
|
|
45
|
+
if (!nextQuery || typeof nextQuery !== "object") return;
|
|
46
|
+
return nextQuery.pageToken ? nextQuery : void 0;
|
|
47
|
+
}
|
|
48
|
+
export { gcsDelete, gcsExists, gcsList, gcsRead, gcsWrite };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { gcsKey } from "./keys.mjs";
|
|
5
|
+
import { pipeline } from "node:stream/promises";
|
|
6
|
+
// src/gcs/streams.ts
|
|
7
|
+
/** Stream `stream` to `path`, deleting the partial object when the pipeline fails. */
|
|
8
|
+
async function gcsWriteStream(ctx, path, stream) {
|
|
9
|
+
const file = ctx.bucket.file(gcsKey(ctx.prefix, path));
|
|
10
|
+
const dest = file.createWriteStream({ resumable: false });
|
|
11
|
+
try {
|
|
12
|
+
await pipeline(stream, dest);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
try {
|
|
15
|
+
await file.delete({ ignoreNotFound: true });
|
|
16
|
+
} catch {}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Open a readable for the bytes at `path`; rejects when the object is missing. */
|
|
21
|
+
async function gcsReadStream(ctx, path) {
|
|
22
|
+
const file = ctx.bucket.file(gcsKey(ctx.prefix, path));
|
|
23
|
+
const [exists] = await file.exists();
|
|
24
|
+
if (!exists) throw new Error(`No object at "${path}"`);
|
|
25
|
+
return file.createReadStream();
|
|
26
|
+
}
|
|
27
|
+
export { gcsReadStream, gcsWriteStream };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { Storage } from "@google-cloud/storage";
|
|
4
|
+
/** Options for configuring a GCS storage adapter. */
|
|
5
|
+
interface GcsStorageOptions {
|
|
6
|
+
/** GCS bucket name. */
|
|
7
|
+
bucket: string;
|
|
8
|
+
/** Optional key prefix applied to all stored objects. */
|
|
9
|
+
prefix?: string;
|
|
10
|
+
/** Pre-configured GCS client. Defaults to a client built from the other options. */
|
|
11
|
+
client?: Storage;
|
|
12
|
+
/** GCP project ID (defaults to ADC). */
|
|
13
|
+
projectId?: string;
|
|
14
|
+
/** Path to service-account JSON key file. */
|
|
15
|
+
keyFilename?: string;
|
|
16
|
+
/** Service-account credentials object. */
|
|
17
|
+
credentials?: Record<string, unknown>;
|
|
18
|
+
/** Custom API endpoint (e.g. emulator: http://localhost:9090). */
|
|
19
|
+
apiEndpoint?: string;
|
|
20
|
+
}
|
|
21
|
+
export { GcsStorageOptions };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
5
|
+
// src/s3/client.ts
|
|
6
|
+
/** S3 client construction/injection and shared request context. */
|
|
7
|
+
/** Resolve the effective client, bucket, and prefix for one storage instance. */
|
|
8
|
+
function resolveS3Context(options) {
|
|
9
|
+
const { bucket, prefix = "", endpoint, region = "us-east-1", client: injectedClient } = options;
|
|
10
|
+
return {
|
|
11
|
+
ctx: {
|
|
12
|
+
client: injectedClient ?? new S3Client({
|
|
13
|
+
endpoint,
|
|
14
|
+
region,
|
|
15
|
+
forcePathStyle: true
|
|
16
|
+
}),
|
|
17
|
+
bucket,
|
|
18
|
+
prefix
|
|
19
|
+
},
|
|
20
|
+
ownsClient: injectedClient === void 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { resolveS3Context };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { S3ServiceException } from "@aws-sdk/client-s3";
|
|
5
|
+
// src/s3/errors.ts
|
|
6
|
+
/** Not-found and stream type guards for S3 responses. */
|
|
7
|
+
/** True when the error is an S3 404 (missing object). */
|
|
8
|
+
function isNotFound(error) {
|
|
9
|
+
return error instanceof S3ServiceException && error.$metadata.httpStatusCode === 404;
|
|
10
|
+
}
|
|
11
|
+
/** True when an S3 `Body` is a WHATWG web stream rather than a Node stream. */
|
|
12
|
+
function isWebStream(body) {
|
|
13
|
+
return typeof body === "object" && body !== null && typeof body.getReader === "function";
|
|
14
|
+
}
|
|
15
|
+
export { isNotFound, isWebStream };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { S3StorageOptions } from "./types.mjs";
|
|
4
|
+
import { s3Key } from "./keys.mjs";
|
|
5
|
+
import { StorageAdapter } from "@storyshelf/core/adapter/storage";
|
|
6
|
+
/**
|
|
7
|
+
* Create an S3-compatible StorageAdapter (AWS S3, R2, MinIO, etc.).
|
|
8
|
+
*
|
|
9
|
+
* @param options - S3 configuration options.
|
|
10
|
+
* @returns A StorageAdapter backed by the configured S3 bucket.
|
|
11
|
+
*/
|
|
12
|
+
declare function createS3Storage(options: S3StorageOptions): StorageAdapter;
|
|
13
|
+
export { type S3StorageOptions, createS3Storage, s3Key };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { resolveS3Context } from "./client.mjs";
|
|
5
|
+
import { buildS3Lifecycle } from "./lifecycle.mjs";
|
|
6
|
+
import { s3Key } from "./keys.mjs";
|
|
7
|
+
import { s3Delete, s3Exists, s3List, s3Read, s3Write } from "./operations.mjs";
|
|
8
|
+
import { s3ReadStream, s3WriteStream } from "./streams.mjs";
|
|
9
|
+
// src/s3/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* Create an S3-compatible StorageAdapter (AWS S3, R2, MinIO, etc.).
|
|
12
|
+
*
|
|
13
|
+
* @param options - S3 configuration options.
|
|
14
|
+
* @returns A StorageAdapter backed by the configured S3 bucket.
|
|
15
|
+
*/
|
|
16
|
+
function createS3Storage(options) {
|
|
17
|
+
const { ctx, ownsClient } = resolveS3Context(options);
|
|
18
|
+
const { client, bucket, prefix } = ctx;
|
|
19
|
+
return {
|
|
20
|
+
metadata: {
|
|
21
|
+
name: "S3 Storage",
|
|
22
|
+
version: "0.15.1",
|
|
23
|
+
description: "S3-compatible storage adapter",
|
|
24
|
+
kind: "s3",
|
|
25
|
+
category: "storage"
|
|
26
|
+
},
|
|
27
|
+
lifecycle: buildS3Lifecycle(client, ownsClient, bucket, prefix),
|
|
28
|
+
async read(path) {
|
|
29
|
+
return await s3Read(ctx, path);
|
|
30
|
+
},
|
|
31
|
+
async write(path, data) {
|
|
32
|
+
await s3Write(ctx, path, data);
|
|
33
|
+
},
|
|
34
|
+
async delete(path) {
|
|
35
|
+
await s3Delete(ctx, path);
|
|
36
|
+
},
|
|
37
|
+
async exists(path) {
|
|
38
|
+
return await s3Exists(ctx, path);
|
|
39
|
+
},
|
|
40
|
+
async list(listPrefix) {
|
|
41
|
+
return await s3List(ctx, listPrefix);
|
|
42
|
+
},
|
|
43
|
+
async writeStream(path, stream) {
|
|
44
|
+
await s3WriteStream(ctx, path, stream);
|
|
45
|
+
},
|
|
46
|
+
async readStream(path) {
|
|
47
|
+
return await s3ReadStream(ctx, path);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export { createS3Storage, s3Key };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
/** Key join/split for S3 object keys under an optional prefix. */
|
|
4
|
+
/** Join an optional key prefix with a storage path. */
|
|
5
|
+
declare function s3Key(prefix: string, path: string): string;
|
|
6
|
+
export { s3Key };
|
package/dist/s3/keys.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
// src/s3/keys.ts
|
|
5
|
+
/** Key join/split for S3 object keys under an optional prefix. */
|
|
6
|
+
/** Join an optional key prefix with a storage path. */
|
|
7
|
+
function s3Key(prefix, path) {
|
|
8
|
+
return prefix === "" ? path : `${prefix}/${path}`;
|
|
9
|
+
}
|
|
10
|
+
/** Strip the configured prefix back off a listed S3 key. */
|
|
11
|
+
function s3Rel(prefix, key) {
|
|
12
|
+
return prefix === "" ? key : key.slice(prefix.length + 1);
|
|
13
|
+
}
|
|
14
|
+
export { s3Key, s3Rel };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { ListObjectsV2Command } from "@aws-sdk/client-s3";
|
|
5
|
+
// src/s3/lifecycle.ts
|
|
6
|
+
/** S3 bucket probe lifecycle: setup, health, and teardown. */
|
|
7
|
+
/** All-or-nothing lifecycle: probe bucket access, destroy owned clients. */
|
|
8
|
+
function buildS3Lifecycle(client, ownsClient, bucket, prefix) {
|
|
9
|
+
let destroyed = false;
|
|
10
|
+
return {
|
|
11
|
+
setup: async () => {
|
|
12
|
+
await client.send(new ListObjectsV2Command({
|
|
13
|
+
Bucket: bucket,
|
|
14
|
+
Prefix: prefix,
|
|
15
|
+
MaxKeys: 1
|
|
16
|
+
}));
|
|
17
|
+
},
|
|
18
|
+
teardown: async () => {
|
|
19
|
+
if (ownsClient && !destroyed) {
|
|
20
|
+
destroyed = true;
|
|
21
|
+
client.destroy();
|
|
22
|
+
}
|
|
23
|
+
await Promise.resolve();
|
|
24
|
+
},
|
|
25
|
+
health: async () => {
|
|
26
|
+
await client.send(new ListObjectsV2Command({
|
|
27
|
+
Bucket: bucket,
|
|
28
|
+
Prefix: prefix,
|
|
29
|
+
MaxKeys: 1
|
|
30
|
+
}));
|
|
31
|
+
return { ok: true };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export { buildS3Lifecycle };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { isNotFound } from "./errors.mjs";
|
|
5
|
+
import { s3Key, s3Rel } from "./keys.mjs";
|
|
6
|
+
import { DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, ListObjectsV2Command, PutObjectCommand } from "@aws-sdk/client-s3";
|
|
7
|
+
// src/s3/operations.ts
|
|
8
|
+
/** Buffered CRUD and paginated listing for S3 objects. */
|
|
9
|
+
/** Read one object fully into a buffer (empty when the body is missing). */
|
|
10
|
+
async function s3Read(ctx, path) {
|
|
11
|
+
const body = (await ctx.client.send(new GetObjectCommand({
|
|
12
|
+
Bucket: ctx.bucket,
|
|
13
|
+
Key: s3Key(ctx.prefix, path)
|
|
14
|
+
}))).Body;
|
|
15
|
+
if (body === void 0) return Buffer.alloc(0);
|
|
16
|
+
return Buffer.from(await body.transformToByteArray());
|
|
17
|
+
}
|
|
18
|
+
/** Write one object from a buffer. */
|
|
19
|
+
async function s3Write(ctx, path, data) {
|
|
20
|
+
await ctx.client.send(new PutObjectCommand({
|
|
21
|
+
Bucket: ctx.bucket,
|
|
22
|
+
Key: s3Key(ctx.prefix, path),
|
|
23
|
+
Body: data
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
/** Delete one object. */
|
|
27
|
+
async function s3Delete(ctx, path) {
|
|
28
|
+
await ctx.client.send(new DeleteObjectCommand({
|
|
29
|
+
Bucket: ctx.bucket,
|
|
30
|
+
Key: s3Key(ctx.prefix, path)
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
/** True when the object exists; false on S3 404, rethrowing other errors. */
|
|
34
|
+
async function s3Exists(ctx, path) {
|
|
35
|
+
try {
|
|
36
|
+
await ctx.client.send(new HeadObjectCommand({
|
|
37
|
+
Bucket: ctx.bucket,
|
|
38
|
+
Key: s3Key(ctx.prefix, path)
|
|
39
|
+
}));
|
|
40
|
+
return true;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (isNotFound(error)) return false;
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** List paths under a prefix, stripping the configured bucket prefix. */
|
|
47
|
+
async function s3List(ctx, listPrefix) {
|
|
48
|
+
const prefix = s3Key(ctx.prefix, listPrefix);
|
|
49
|
+
const results = [];
|
|
50
|
+
let token;
|
|
51
|
+
do {
|
|
52
|
+
const response = await ctx.client.send(new ListObjectsV2Command({
|
|
53
|
+
Bucket: ctx.bucket,
|
|
54
|
+
Prefix: prefix,
|
|
55
|
+
ContinuationToken: token
|
|
56
|
+
}));
|
|
57
|
+
for (const item of response.Contents ?? []) if (item.Key !== void 0) results.push(s3Rel(ctx.prefix, item.Key));
|
|
58
|
+
token = response.IsTruncated ? response.NextContinuationToken : void 0;
|
|
59
|
+
} while (token !== void 0);
|
|
60
|
+
return results;
|
|
61
|
+
}
|
|
62
|
+
export { s3Delete, s3Exists, s3List, s3Read, s3Write };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { isWebStream } from "./errors.mjs";
|
|
5
|
+
import { s3Key } from "./keys.mjs";
|
|
6
|
+
import { Readable } from "node:stream";
|
|
7
|
+
import { DeleteObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
|
|
8
|
+
import { Upload } from "@aws-sdk/lib-storage";
|
|
9
|
+
// src/s3/streams.ts
|
|
10
|
+
/** Streaming reads and writes for S3 objects, with failure cleanup. */
|
|
11
|
+
/** Multipart-upload a Node stream, deleting the partial key on failure. */
|
|
12
|
+
async function s3WriteStream(ctx, path, stream) {
|
|
13
|
+
const upload = new Upload({
|
|
14
|
+
client: ctx.client,
|
|
15
|
+
params: {
|
|
16
|
+
Bucket: ctx.bucket,
|
|
17
|
+
Key: s3Key(ctx.prefix, path),
|
|
18
|
+
Body: stream
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
await upload.done();
|
|
23
|
+
} catch (error) {
|
|
24
|
+
try {
|
|
25
|
+
await ctx.client.send(new DeleteObjectCommand({
|
|
26
|
+
Bucket: ctx.bucket,
|
|
27
|
+
Key: s3Key(ctx.prefix, path)
|
|
28
|
+
}));
|
|
29
|
+
} catch {}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Open an object as a Node stream, converting web-stream bodies. */
|
|
34
|
+
async function s3ReadStream(ctx, path) {
|
|
35
|
+
const body = (await ctx.client.send(new GetObjectCommand({
|
|
36
|
+
Bucket: ctx.bucket,
|
|
37
|
+
Key: s3Key(ctx.prefix, path)
|
|
38
|
+
}))).Body;
|
|
39
|
+
if (body instanceof Readable) return body;
|
|
40
|
+
if (isWebStream(body)) return Readable.fromWeb(body);
|
|
41
|
+
throw new Error(`No object at "${path}"`);
|
|
42
|
+
}
|
|
43
|
+
export { s3ReadStream, s3WriteStream };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
4
|
+
/** Options for configuring an S3-compatible storage adapter. */
|
|
5
|
+
interface S3StorageOptions {
|
|
6
|
+
/** S3 bucket name. */
|
|
7
|
+
bucket: string;
|
|
8
|
+
/** Optional key prefix applied to all stored objects. */
|
|
9
|
+
prefix?: string;
|
|
10
|
+
/** Custom endpoint for S3-compatible services (e.g. MinIO, R2). */
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
/** AWS region. Defaults to `us-east-1`. */
|
|
13
|
+
region?: string;
|
|
14
|
+
/** Pre-configured S3 client. Defaults to a client built from the other options. */
|
|
15
|
+
client?: S3Client;
|
|
16
|
+
}
|
|
17
|
+
export { S3StorageOptions };
|
package/package.json
CHANGED
|
@@ -1,14 +1,114 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyshelf/storage",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.15.1",
|
|
4
|
+
"description": "Storage adapters for StoryShelf: S3-compatible, Google Cloud Storage, Azure Blob Storage and local disk, one subpath each.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"azure",
|
|
7
|
+
"gcs",
|
|
8
|
+
"r2",
|
|
9
|
+
"s3",
|
|
10
|
+
"self-hosted",
|
|
11
|
+
"storage",
|
|
12
|
+
"storybook"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/GuptaSiddhant/StoryShelf#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/GuptaSiddhant/StoryShelf/issues"
|
|
17
|
+
},
|
|
5
18
|
"license": "MIT",
|
|
6
|
-
"
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "Siddhant Gupta",
|
|
21
|
+
"url": "https://guptasiddhant.com"
|
|
22
|
+
},
|
|
7
23
|
"repository": {
|
|
8
24
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/GuptaSiddhant/StoryShelf.git"
|
|
25
|
+
"url": "git+https://github.com/GuptaSiddhant/StoryShelf.git",
|
|
26
|
+
"directory": "packages/storage"
|
|
10
27
|
},
|
|
11
28
|
"files": [
|
|
12
|
-
"
|
|
13
|
-
]
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"exports": {
|
|
34
|
+
"./azure": "./dist/azure/index.mjs",
|
|
35
|
+
"./gcs": "./dist/gcs/index.mjs",
|
|
36
|
+
"./local": "./dist/local/index.mjs",
|
|
37
|
+
"./s3": "./dist/s3/index.mjs",
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsdown",
|
|
45
|
+
"dev": "tsdown -w",
|
|
46
|
+
"fmt": "oxfmt ./src",
|
|
47
|
+
"lint": "oxlint --type-aware --type-check ./src",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"prepublishOnly": "nub run build"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@aws-sdk/client-s3": "^3.700.0",
|
|
53
|
+
"@aws-sdk/lib-storage": "3.700.0",
|
|
54
|
+
"@azure/identity": "^4.14.1",
|
|
55
|
+
"@azure/storage-blob": "^12.26.0",
|
|
56
|
+
"@google-cloud/storage": "^7.13.0",
|
|
57
|
+
"@storyshelf/core": "0.15.1",
|
|
58
|
+
"@types/node": "^26.0.0",
|
|
59
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
60
|
+
"oxfmt": "^0.65.0",
|
|
61
|
+
"oxlint": "^1.80.0",
|
|
62
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
63
|
+
"tsdown": "^0.22.14",
|
|
64
|
+
"typescript": "^7.0.2",
|
|
65
|
+
"vitest": "^5.0.5"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"@aws-sdk/client-s3": "^3.700.0",
|
|
69
|
+
"@aws-sdk/lib-storage": "^3.700.0",
|
|
70
|
+
"@azure/identity": "^4.14.1",
|
|
71
|
+
"@azure/storage-blob": "^12.26.0",
|
|
72
|
+
"@google-cloud/storage": "^7.13.0",
|
|
73
|
+
"@storyshelf/core": "0.15.1"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"@aws-sdk/client-s3": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"@aws-sdk/lib-storage": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@azure/identity": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"@azure/storage-blob": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"@google-cloud/storage": {
|
|
89
|
+
"optional": true
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"engines": {
|
|
93
|
+
"node": ">=24"
|
|
94
|
+
},
|
|
95
|
+
"storyshelf": {
|
|
96
|
+
"peerSubpaths": {
|
|
97
|
+
"@aws-sdk/client-s3": [
|
|
98
|
+
"./s3"
|
|
99
|
+
],
|
|
100
|
+
"@aws-sdk/lib-storage": [
|
|
101
|
+
"./s3"
|
|
102
|
+
],
|
|
103
|
+
"@azure/identity": [
|
|
104
|
+
"./azure"
|
|
105
|
+
],
|
|
106
|
+
"@azure/storage-blob": [
|
|
107
|
+
"./azure"
|
|
108
|
+
],
|
|
109
|
+
"@google-cloud/storage": [
|
|
110
|
+
"./gcs"
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
14
114
|
}
|