@storyshelf/storage-azure 0.6.2 → 0.8.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/README.md +13 -0
- package/dist/client.mjs +1 -2
- package/dist/errors.mjs +1 -2
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +1 -1
- package/dist/keys.d.mts +0 -2
- package/dist/keys.mjs +1 -2
- package/dist/lifecycle.mjs +1 -2
- package/dist/operations.mjs +1 -2
- package/dist/streams.mjs +1 -2
- package/dist/types.d.mts +0 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -75,6 +75,19 @@ interface AzureStorageOptions {
|
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
Options at a glance:
|
|
79
|
+
|
|
80
|
+
| Option | Required | Notes |
|
|
81
|
+
| ---------------------------- | -------- | ------------------------------------------------------ |
|
|
82
|
+
| `container` | yes | Blob container name |
|
|
83
|
+
| `prefix` | no | Key prefix applied to every object |
|
|
84
|
+
| `client` | no | Pre-built `ContainerClient`; skips client construction |
|
|
85
|
+
| `connectionString` | no\* | Storage connection string |
|
|
86
|
+
| `accountName` / `accountKey` | no\* | Explicit credentials pair |
|
|
87
|
+
| `accountUrl` / `sasToken` | no\* | URL + SAS form (emulator, fine-grained SAS) |
|
|
88
|
+
|
|
89
|
+
`*` At least one auth form is needed unless `client` is supplied.
|
|
90
|
+
|
|
78
91
|
### `createAzureStorage(options: AzureStorageOptions): StorageAdapter`
|
|
79
92
|
|
|
80
93
|
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`).
|
package/dist/client.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import "node:path";
|
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
4
|
import { BlobServiceClient, StorageSharedKeyCredential } from "@azure/storage-blob";
|
|
5
|
-
|
|
5
|
+
// src/client.ts
|
|
6
6
|
/** Resolve the container client for the configured credentials. */
|
|
7
7
|
function resolveContainerClient(options, containerName) {
|
|
8
8
|
if (options.client) return options.client;
|
|
@@ -26,7 +26,6 @@ function buildAccountUrl(accountName) {
|
|
|
26
26
|
if (!accountName) return;
|
|
27
27
|
return `https://${accountName}.blob.core.windows.net`;
|
|
28
28
|
}
|
|
29
|
-
//#endregion
|
|
30
29
|
export { resolveContainerClient };
|
|
31
30
|
|
|
32
31
|
//# sourceMappingURL=client.mjs.map
|
package/dist/errors.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import "node:path";
|
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
4
|
import "node:stream";
|
|
5
|
-
|
|
5
|
+
// src/errors.ts
|
|
6
6
|
/** Not-found guards and stream/collect helpers for Azure blob I/O. */
|
|
7
7
|
/** True when an Azure SDK error means the blob (or container) is missing. */
|
|
8
8
|
function isNotFound(error) {
|
|
@@ -35,7 +35,6 @@ async function deleteBlobQuiet(blob) {
|
|
|
35
35
|
await withDelete.delete?.();
|
|
36
36
|
} catch {}
|
|
37
37
|
}
|
|
38
|
-
//#endregion
|
|
39
38
|
export { collectDownload, collectStream, deleteBlobQuiet, isNotFound };
|
|
40
39
|
|
|
41
40
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ import __tsdown_shims_url from 'node:url';
|
|
|
3
3
|
import { AzureStorageOptions } from "./types.mjs";
|
|
4
4
|
import { azureKey } from "./keys.mjs";
|
|
5
5
|
import { StorageAdapter } from "@storyshelf/core/adapter/storage";
|
|
6
|
-
//#region src/index.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Create an Azure Blob Storage-backed StorageAdapter.
|
|
9
8
|
*
|
|
@@ -11,6 +10,5 @@ import { StorageAdapter } from "@storyshelf/core/adapter/storage";
|
|
|
11
10
|
* @returns A StorageAdapter backed by the configured Azure container.
|
|
12
11
|
*/
|
|
13
12
|
declare function createAzureStorage(options: AzureStorageOptions): StorageAdapter;
|
|
14
|
-
//#endregion
|
|
15
13
|
export { type AzureStorageOptions, azureKey, createAzureStorage };
|
|
16
14
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { buildAzureLifecycle } from "./lifecycle.mjs";
|
|
|
6
6
|
import { azureKey } from "./keys.mjs";
|
|
7
7
|
import { azureDelete, azureExists, azureList, azureRead, azureWrite } from "./operations.mjs";
|
|
8
8
|
import { azureReadStream, azureWriteStream } from "./streams.mjs";
|
|
9
|
-
|
|
9
|
+
// src/index.ts
|
|
10
10
|
/**
|
|
11
11
|
* Create an Azure Blob Storage-backed StorageAdapter.
|
|
12
12
|
*
|
|
@@ -23,7 +23,7 @@ function createAzureStorage(options) {
|
|
|
23
23
|
return {
|
|
24
24
|
metadata: {
|
|
25
25
|
name: "Azure Blob Storage",
|
|
26
|
-
version:
|
|
26
|
+
version: "0.8.0",
|
|
27
27
|
description: "Azure Blob Storage adapter",
|
|
28
28
|
kind: "azure",
|
|
29
29
|
category: "storage"
|
|
@@ -52,7 +52,6 @@ function createAzureStorage(options) {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
//#endregion
|
|
56
55
|
export { azureKey, createAzureStorage };
|
|
57
56
|
|
|
58
57
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Azure Blob Storage adapter for StoryShelf.\n *\n * Persists captured screenshots and diff overlays in an Azure Blob container.\n * The CLI uploads the built Storybook; the server renders stories with\n * Playwright and stores the resulting blobs here.\n */\nimport type { StorageAdapter } from \"@storyshelf/core/adapter/storage\";\nimport { resolveContainerClient, type AzureContext } from \"./client.ts\";\nimport { buildAzureLifecycle } from \"./lifecycle.ts\";\nimport { azureDelete, azureExists, azureList, azureRead, azureWrite } from \"./operations.ts\";\nimport { azureReadStream, azureWriteStream } from \"./streams.ts\";\nimport type { AzureStorageOptions } from \"./types.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\n/**\n * Create an Azure Blob Storage-backed StorageAdapter.\n *\n * @param options - Azure configuration options.\n * @returns A StorageAdapter backed by the configured Azure container.\n */\nexport function createAzureStorage(options: AzureStorageOptions): StorageAdapter {\n const { container: containerName, prefix = \"\" } = options;\n const container = resolveContainerClient(options, containerName);\n const ctx: AzureContext = { container, prefix };\n\n return {\n metadata: {\n name: \"Azure Blob Storage\",\n version:
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Azure Blob Storage adapter for StoryShelf.\n *\n * Persists captured screenshots and diff overlays in an Azure Blob container.\n * The CLI uploads the built Storybook; the server renders stories with\n * Playwright and stores the resulting blobs here.\n */\nimport type { StorageAdapter } from \"@storyshelf/core/adapter/storage\";\nimport { resolveContainerClient, type AzureContext } from \"./client.ts\";\nimport { buildAzureLifecycle } from \"./lifecycle.ts\";\nimport { azureDelete, azureExists, azureList, azureRead, azureWrite } from \"./operations.ts\";\nimport { azureReadStream, azureWriteStream } from \"./streams.ts\";\nimport type { AzureStorageOptions } from \"./types.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\n/**\n * Create an Azure Blob Storage-backed StorageAdapter.\n *\n * @param options - Azure configuration options.\n * @returns A StorageAdapter backed by the configured Azure container.\n */\nexport function createAzureStorage(options: AzureStorageOptions): StorageAdapter {\n const { container: containerName, prefix = \"\" } = options;\n const container = resolveContainerClient(options, containerName);\n const ctx: AzureContext = { container, prefix };\n\n return {\n metadata: {\n name: \"Azure Blob Storage\",\n version: typeof __PKG_VERSION__ === \"string\" ? __PKG_VERSION__ : \"0.0.0\",\n description: \"Azure Blob Storage adapter\",\n kind: \"azure\",\n category: \"storage\",\n },\n lifecycle: buildAzureLifecycle(container, containerName),\n async read(path) {\n return await azureRead(ctx, path);\n },\n async write(path, data) {\n await azureWrite(ctx, path, data);\n },\n async delete(path) {\n await azureDelete(ctx, path);\n },\n async exists(path) {\n return await azureExists(ctx, path);\n },\n async list(listPrefix) {\n return await azureList(ctx, listPrefix);\n },\n async writeStream(path, stream) {\n await azureWriteStream(ctx, path, stream);\n },\n async readStream(path) {\n return await azureReadStream(ctx, path);\n },\n };\n}\n\nexport type { AzureStorageOptions } from \"./types.ts\";\nexport { azureKey } from \"./keys.ts\";\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAAgB,mBAAmB,SAA8C;CAC/E,MAAM,EAAE,WAAW,eAAe,SAAS,OAAO;CAClD,MAAM,YAAY,uBAAuB,SAAS,aAAa;CAC/D,MAAM,MAAoB;EAAE;EAAW;CAAO;CAE9C,OAAO;EACL,UAAU;GACR,MAAM;GACN,SAAA;GACA,aAAa;GACb,MAAM;GACN,UAAU;EACZ;EACA,WAAW,oBAAoB,WAAW,aAAa;EACvD,MAAM,KAAK,MAAM;GACf,OAAO,MAAM,UAAU,KAAK,IAAI;EAClC;EACA,MAAM,MAAM,MAAM,MAAM;GACtB,MAAM,WAAW,KAAK,MAAM,IAAI;EAClC;EACA,MAAM,OAAO,MAAM;GACjB,MAAM,YAAY,KAAK,IAAI;EAC7B;EACA,MAAM,OAAO,MAAM;GACjB,OAAO,MAAM,YAAY,KAAK,IAAI;EACpC;EACA,MAAM,KAAK,YAAY;GACrB,OAAO,MAAM,UAAU,KAAK,UAAU;EACxC;EACA,MAAM,YAAY,MAAM,QAAQ;GAC9B,MAAM,iBAAiB,KAAK,MAAM,MAAM;EAC1C;EACA,MAAM,WAAW,MAAM;GACrB,OAAO,MAAM,gBAAgB,KAAK,IAAI;EACxC;CACF;AACF"}
|
package/dist/keys.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
//#region src/keys.d.ts
|
|
4
3
|
/** Key join/split for Azure blob names. */
|
|
5
4
|
/** Join an optional prefix with a storage path. */
|
|
6
5
|
declare function azureKey(prefix: string, path: string): string;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { azureKey };
|
|
9
7
|
//# sourceMappingURL=keys.d.mts.map
|
package/dist/keys.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:path";
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
|
-
|
|
4
|
+
// src/keys.ts
|
|
5
5
|
/** Key join/split for Azure blob names. */
|
|
6
6
|
/** Join an optional prefix with a storage path. */
|
|
7
7
|
function azureKey(prefix, path) {
|
|
@@ -11,7 +11,6 @@ function azureKey(prefix, path) {
|
|
|
11
11
|
function azureRel(prefix, key) {
|
|
12
12
|
return prefix === "" ? key : key.slice(prefix.length + 1);
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { azureKey, azureRel };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=keys.mjs.map
|
package/dist/lifecycle.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:path";
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
|
-
|
|
4
|
+
// src/lifecycle.ts
|
|
5
5
|
/** Build the setup/health/teardown lifecycle for an Azure container. */
|
|
6
6
|
function buildAzureLifecycle(container, containerName) {
|
|
7
7
|
return {
|
|
@@ -30,7 +30,6 @@ async function containerExists(container, containerName) {
|
|
|
30
30
|
await iterator.return?.();
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
//#endregion
|
|
34
33
|
export { buildAzureLifecycle };
|
|
35
34
|
|
|
36
35
|
//# sourceMappingURL=lifecycle.mjs.map
|
package/dist/operations.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import "node:url";
|
|
|
3
3
|
import.meta.url;
|
|
4
4
|
import { collectDownload, isNotFound } from "./errors.mjs";
|
|
5
5
|
import { azureKey, azureRel } from "./keys.mjs";
|
|
6
|
-
|
|
6
|
+
// src/operations.ts
|
|
7
7
|
/** Buffered Azure blob CRUD with SDK-version duck-typing and async-iterator list. */
|
|
8
8
|
/** Download a blob, preferring `downloadToBuffer` when the SDK offers it. */
|
|
9
9
|
async function azureRead(ctx, path) {
|
|
@@ -48,7 +48,6 @@ async function azureList(ctx, listPrefix) {
|
|
|
48
48
|
for await (const item of ctx.container.listBlobsFlat(prefix === "" ? void 0 : { prefix })) blobs.push(azureRel(ctx.prefix, item.name));
|
|
49
49
|
return blobs;
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
51
|
export { azureDelete, azureExists, azureList, azureRead, azureWrite };
|
|
53
52
|
|
|
54
53
|
//# sourceMappingURL=operations.mjs.map
|
package/dist/streams.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { collectStream, deleteBlobQuiet } from "./errors.mjs";
|
|
|
5
5
|
import { azureKey } from "./keys.mjs";
|
|
6
6
|
import { azureExists, azureWrite } from "./operations.mjs";
|
|
7
7
|
import { Readable } from "node:stream";
|
|
8
|
-
|
|
8
|
+
// src/streams.ts
|
|
9
9
|
/** Streamed Azure blob reads and writes, with failure cleanup. */
|
|
10
10
|
/** Upload a readable, streaming when the SDK supports it and buffering otherwise. */
|
|
11
11
|
async function azureWriteStream(ctx, path, stream) {
|
|
@@ -40,7 +40,6 @@ async function writeStreamBuffered(ctx, path, stream, blob) {
|
|
|
40
40
|
throw error;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
//#endregion
|
|
44
43
|
export { azureReadStream, azureWriteStream };
|
|
45
44
|
|
|
46
45
|
//# sourceMappingURL=streams.mjs.map
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
3
|
import { ContainerClient } from "@azure/storage-blob";
|
|
4
|
-
//#region src/types.d.ts
|
|
5
4
|
/** Options for configuring an Azure Blob Storage adapter. */
|
|
6
5
|
interface AzureStorageOptions {
|
|
7
6
|
/** Azure container name. */
|
|
@@ -21,6 +20,5 @@ interface AzureStorageOptions {
|
|
|
21
20
|
/** SAS token (with or without leading `?`). */
|
|
22
21
|
sasToken?: string;
|
|
23
22
|
}
|
|
24
|
-
//#endregion
|
|
25
23
|
export { AzureStorageOptions };
|
|
26
24
|
//# sourceMappingURL=types.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyshelf/storage-azure",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Azure Blob Storage adapter for StoryShelf.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"azure",
|
|
@@ -27,9 +27,6 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"type": "module",
|
|
30
|
-
"engines": {
|
|
31
|
-
"node": ">=24"
|
|
32
|
-
},
|
|
33
30
|
"sideEffects": false,
|
|
34
31
|
"types": "./dist/index.d.mts",
|
|
35
32
|
"exports": {
|
|
@@ -56,7 +53,7 @@
|
|
|
56
53
|
},
|
|
57
54
|
"dependencies": {
|
|
58
55
|
"@azure/storage-blob": "^12.26.0",
|
|
59
|
-
"@storyshelf/core": "0.
|
|
56
|
+
"@storyshelf/core": "0.8.0"
|
|
60
57
|
},
|
|
61
58
|
"devDependencies": {
|
|
62
59
|
"@types/node": "^26.0.0",
|
|
@@ -66,7 +63,10 @@
|
|
|
66
63
|
"oxlint-tsgolint": "^7.0.2001",
|
|
67
64
|
"tsdown": "^0.22.14",
|
|
68
65
|
"typescript": "^7.0.2",
|
|
69
|
-
"vitest": "^5.0.
|
|
66
|
+
"vitest": "^5.0.5"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=24"
|
|
70
70
|
},
|
|
71
71
|
"jsr": {
|
|
72
72
|
"runtimeCompat": {
|