@storyshelf/storage-gcs 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 CHANGED
@@ -64,6 +64,20 @@ interface GcsStorageOptions {
64
64
  }
65
65
  ```
66
66
 
67
+ Options at a glance:
68
+
69
+ | Option | Required | Notes |
70
+ | ------------- | -------- | -------------------------------------------------------- |
71
+ | `bucket` | yes | GCS bucket name |
72
+ | `prefix` | no | Key prefix for every object |
73
+ | `client` | no | Pre-built `Storage` client (tests, custom endpoint) |
74
+ | `projectId` | no | GCP project ID (defaults to ADC) |
75
+ | `keyFilename` | no | Path to service-account JSON |
76
+ | `credentials` | no | Inline service-account object |
77
+ | `apiEndpoint` | no | Custom endpoint (emulator, e.g. `http://localhost:9090`) |
78
+
79
+ Auth otherwise uses Application Default Credentials.
80
+
67
81
  ### `createGcsStorage(options: GcsStorageOptions): StorageAdapter`
68
82
 
69
83
  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`).
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 { Storage } from "@google-cloud/storage";
5
- //#region src/client.ts
5
+ // src/client.ts
6
6
  /** GCS Storage client construction and shared operation context. */
7
7
  /** Build the bucket handle plus key prefix every GCS operation threads through. */
8
8
  function createGcsContext(options) {
@@ -21,7 +21,6 @@ function resolveClientOptions(options) {
21
21
  if (options.apiEndpoint !== void 0) config.apiEndpoint = options.apiEndpoint;
22
22
  return config;
23
23
  }
24
- //#endregion
25
24
  export { createGcsContext, resolveClientOptions };
26
25
 
27
26
  //# sourceMappingURL=client.mjs.map
package/dist/errors.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
- //#region src/errors.ts
4
+ // src/errors.ts
5
5
  /** Not-found guard for GCS API errors. */
6
6
  /** Return whether a GCS error signals a missing object. */
7
7
  function isNotFound(error) {
@@ -10,7 +10,6 @@ function isNotFound(error) {
10
10
  if (err.statusCode === 404) return true;
11
11
  return err.errors?.[0]?.reason === "notFound";
12
12
  }
13
- //#endregion
14
13
  export { isNotFound };
15
14
 
16
15
  //# sourceMappingURL=errors.mjs.map
package/dist/index.d.mts CHANGED
@@ -3,7 +3,6 @@ import __tsdown_shims_url from 'node:url';
3
3
  import { GcsStorageOptions } from "./types.mjs";
4
4
  import { gcsKey } from "./keys.mjs";
5
5
  import { StorageAdapter } from "@storyshelf/core/adapter/storage";
6
- //#region src/index.d.ts
7
6
  /**
8
7
  * Create a Google Cloud Storage (GCS) StorageAdapter.
9
8
  *
@@ -11,6 +10,5 @@ import { StorageAdapter } from "@storyshelf/core/adapter/storage";
11
10
  * @returns A StorageAdapter backed by the configured GCS bucket.
12
11
  */
13
12
  declare function createGcsStorage(options: GcsStorageOptions): StorageAdapter;
14
- //#endregion
15
13
  export { type GcsStorageOptions, createGcsStorage, gcsKey };
16
14
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import { createGcsLifecycle } from "./lifecycle.mjs";
6
6
  import { gcsKey } from "./keys.mjs";
7
7
  import { gcsDelete, gcsExists, gcsList, gcsRead, gcsWrite } from "./operations.mjs";
8
8
  import { gcsReadStream, gcsWriteStream } from "./streams.mjs";
9
- //#region src/index.ts
9
+ // src/index.ts
10
10
  /**
11
11
  * Create a Google Cloud Storage (GCS) StorageAdapter.
12
12
  *
@@ -18,7 +18,7 @@ function createGcsStorage(options) {
18
18
  return {
19
19
  metadata: {
20
20
  name: "GCS Storage",
21
- version: globalThis.__PKG_VERSION__ ?? "0.0.0",
21
+ version: "0.8.0",
22
22
  description: "Google Cloud Storage adapter",
23
23
  kind: "gcs",
24
24
  category: "storage"
@@ -47,7 +47,6 @@ function createGcsStorage(options) {
47
47
  }
48
48
  };
49
49
  }
50
- //#endregion
51
50
  export { createGcsStorage, gcsKey };
52
51
 
53
52
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Google Cloud Storage adapter for StoryShelf.\n *\n * Server-side blob storage for screenshots, diffs, and Storybook archives.\n * The factory wires per-concern modules (client, lifecycle, operations,\n * streams); key and option helpers are re-exported below.\n */\nimport type { StorageAdapter } from \"@storyshelf/core/adapter/storage\";\nimport { createGcsContext } from \"./client.ts\";\nimport { createGcsLifecycle } from \"./lifecycle.ts\";\nimport { gcsDelete, gcsExists, gcsList, gcsRead, gcsWrite } from \"./operations.ts\";\nimport { gcsReadStream, gcsWriteStream } from \"./streams.ts\";\nimport type { GcsStorageOptions } from \"./types.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\n/**\n * Create a Google Cloud Storage (GCS) StorageAdapter.\n *\n * @param options - GCS configuration options.\n * @returns A StorageAdapter backed by the configured GCS bucket.\n */\nexport function createGcsStorage(options: GcsStorageOptions): StorageAdapter {\n const ctx = createGcsContext(options);\n\n return {\n metadata: {\n name: \"GCS Storage\",\n version: (globalThis as unknown as { __PKG_VERSION__?: string }).__PKG_VERSION__ ?? \"0.0.0\",\n description: \"Google Cloud Storage adapter\",\n kind: \"gcs\",\n category: \"storage\",\n },\n lifecycle: createGcsLifecycle(ctx),\n async read(path) {\n return await gcsRead(ctx, path);\n },\n async write(path, data) {\n await gcsWrite(ctx, path, data);\n },\n async delete(path) {\n await gcsDelete(ctx, path);\n },\n async exists(path) {\n return await gcsExists(ctx, path);\n },\n async list(listPrefix) {\n return await gcsList(ctx, listPrefix);\n },\n async writeStream(path, stream) {\n await gcsWriteStream(ctx, path, stream);\n },\n async readStream(path) {\n return await gcsReadStream(ctx, path);\n },\n };\n}\n\nexport type { GcsStorageOptions } from \"./types.ts\";\nexport { gcsKey } from \"./keys.ts\";\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAiB,SAA4C;CAC3E,MAAM,MAAM,iBAAiB,OAAO;CAEpC,OAAO;EACL,UAAU;GACR,MAAM;GACN,SAAU,WAAuD,mBAAmB;GACpF,aAAa;GACb,MAAM;GACN,UAAU;EACZ;EACA,WAAW,mBAAmB,GAAG;EACjC,MAAM,KAAK,MAAM;GACf,OAAO,MAAM,QAAQ,KAAK,IAAI;EAChC;EACA,MAAM,MAAM,MAAM,MAAM;GACtB,MAAM,SAAS,KAAK,MAAM,IAAI;EAChC;EACA,MAAM,OAAO,MAAM;GACjB,MAAM,UAAU,KAAK,IAAI;EAC3B;EACA,MAAM,OAAO,MAAM;GACjB,OAAO,MAAM,UAAU,KAAK,IAAI;EAClC;EACA,MAAM,KAAK,YAAY;GACrB,OAAO,MAAM,QAAQ,KAAK,UAAU;EACtC;EACA,MAAM,YAAY,MAAM,QAAQ;GAC9B,MAAM,eAAe,KAAK,MAAM,MAAM;EACxC;EACA,MAAM,WAAW,MAAM;GACrB,OAAO,MAAM,cAAc,KAAK,IAAI;EACtC;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Google Cloud Storage adapter for StoryShelf.\n *\n * Server-side blob storage for screenshots, diffs, and Storybook archives.\n * The factory wires per-concern modules (client, lifecycle, operations,\n * streams); key and option helpers are re-exported below.\n */\nimport type { StorageAdapter } from \"@storyshelf/core/adapter/storage\";\nimport { createGcsContext } from \"./client.ts\";\nimport { createGcsLifecycle } from \"./lifecycle.ts\";\nimport { gcsDelete, gcsExists, gcsList, gcsRead, gcsWrite } from \"./operations.ts\";\nimport { gcsReadStream, gcsWriteStream } from \"./streams.ts\";\nimport type { GcsStorageOptions } from \"./types.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\n/**\n * Create a Google Cloud Storage (GCS) StorageAdapter.\n *\n * @param options - GCS configuration options.\n * @returns A StorageAdapter backed by the configured GCS bucket.\n */\nexport function createGcsStorage(options: GcsStorageOptions): StorageAdapter {\n const ctx = createGcsContext(options);\n\n return {\n metadata: {\n name: \"GCS Storage\",\n version: typeof __PKG_VERSION__ === \"string\" ? __PKG_VERSION__ : \"0.0.0\",\n description: \"Google Cloud Storage adapter\",\n kind: \"gcs\",\n category: \"storage\",\n },\n lifecycle: createGcsLifecycle(ctx),\n async read(path) {\n return await gcsRead(ctx, path);\n },\n async write(path, data) {\n await gcsWrite(ctx, path, data);\n },\n async delete(path) {\n await gcsDelete(ctx, path);\n },\n async exists(path) {\n return await gcsExists(ctx, path);\n },\n async list(listPrefix) {\n return await gcsList(ctx, listPrefix);\n },\n async writeStream(path, stream) {\n await gcsWriteStream(ctx, path, stream);\n },\n async readStream(path) {\n return await gcsReadStream(ctx, path);\n },\n };\n}\n\nexport type { GcsStorageOptions } from \"./types.ts\";\nexport { gcsKey } from \"./keys.ts\";\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAiB,SAA4C;CAC3E,MAAM,MAAM,iBAAiB,OAAO;CAEpC,OAAO;EACL,UAAU;GACR,MAAM;GACN,SAAA;GACA,aAAa;GACb,MAAM;GACN,UAAU;EACZ;EACA,WAAW,mBAAmB,GAAG;EACjC,MAAM,KAAK,MAAM;GACf,OAAO,MAAM,QAAQ,KAAK,IAAI;EAChC;EACA,MAAM,MAAM,MAAM,MAAM;GACtB,MAAM,SAAS,KAAK,MAAM,IAAI;EAChC;EACA,MAAM,OAAO,MAAM;GACjB,MAAM,UAAU,KAAK,IAAI;EAC3B;EACA,MAAM,OAAO,MAAM;GACjB,OAAO,MAAM,UAAU,KAAK,IAAI;EAClC;EACA,MAAM,KAAK,YAAY;GACrB,OAAO,MAAM,QAAQ,KAAK,UAAU;EACtC;EACA,MAAM,YAAY,MAAM,QAAQ;GAC9B,MAAM,eAAe,KAAK,MAAM,MAAM;EACxC;EACA,MAAM,WAAW,MAAM;GACrB,OAAO,MAAM,cAAc,KAAK,IAAI;EACtC;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 GCS object keys. */
5
4
  /** Join an optional key prefix with a storage path. */
6
5
  declare function gcsKey(prefix: string, path: string): string;
7
- //#endregion
8
6
  export { gcsKey };
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
- //#region src/keys.ts
4
+ // src/keys.ts
5
5
  /** Key join/split for GCS object keys. */
6
6
  /** Join an optional key prefix with a storage path. */
7
7
  function gcsKey(prefix, path) {
@@ -11,7 +11,6 @@ function gcsKey(prefix, path) {
11
11
  function gcsRel(prefix, key) {
12
12
  return prefix === "" ? key : key.slice(prefix.length + 1);
13
13
  }
14
- //#endregion
15
14
  export { gcsKey, gcsRel };
16
15
 
17
16
  //# sourceMappingURL=keys.mjs.map
@@ -1,7 +1,7 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
- //#region src/lifecycle.ts
4
+ // src/lifecycle.ts
5
5
  /** Build the setup/health/teardown hooks probing a GCS bucket. */
6
6
  function createGcsLifecycle(ctx) {
7
7
  return {
@@ -24,7 +24,6 @@ function gcsHealthQuery(prefix) {
24
24
  maxResults: 1
25
25
  };
26
26
  }
27
- //#endregion
28
27
  export { createGcsLifecycle, gcsHealthQuery };
29
28
 
30
29
  //# sourceMappingURL=lifecycle.mjs.map
@@ -3,7 +3,7 @@ import "node:url";
3
3
  import.meta.url;
4
4
  import { isNotFound } from "./errors.mjs";
5
5
  import { gcsKey, gcsRel } from "./keys.mjs";
6
- //#region src/operations.ts
6
+ // src/operations.ts
7
7
  /** Download the full bytes stored at `path`. */
8
8
  async function gcsRead(ctx, path) {
9
9
  const [data] = await ctx.bucket.file(gcsKey(ctx.prefix, path)).download();
@@ -45,7 +45,6 @@ function nextQueryQuery(nextQuery) {
45
45
  if (!nextQuery || typeof nextQuery !== "object") return;
46
46
  return nextQuery.pageToken ? nextQuery : void 0;
47
47
  }
48
- //#endregion
49
48
  export { gcsDelete, gcsExists, gcsList, gcsRead, gcsWrite };
50
49
 
51
50
  //# sourceMappingURL=operations.mjs.map
package/dist/streams.mjs CHANGED
@@ -3,7 +3,7 @@ import "node:url";
3
3
  import.meta.url;
4
4
  import { gcsKey } from "./keys.mjs";
5
5
  import { pipeline } from "node:stream/promises";
6
- //#region src/streams.ts
6
+ // src/streams.ts
7
7
  /** Stream `stream` to `path`, deleting the partial object when the pipeline fails. */
8
8
  async function gcsWriteStream(ctx, path, stream) {
9
9
  const file = ctx.bucket.file(gcsKey(ctx.prefix, path));
@@ -24,7 +24,6 @@ async function gcsReadStream(ctx, path) {
24
24
  if (!exists) throw new Error(`No object at "${path}"`);
25
25
  return file.createReadStream();
26
26
  }
27
- //#endregion
28
27
  export { gcsReadStream, gcsWriteStream };
29
28
 
30
29
  //# 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 { Storage } from "@google-cloud/storage";
4
- //#region src/types.d.ts
5
4
  /** Options for configuring a GCS storage adapter. */
6
5
  interface GcsStorageOptions {
7
6
  /** GCS bucket name. */
@@ -19,6 +18,5 @@ interface GcsStorageOptions {
19
18
  /** Custom API endpoint (e.g. emulator: http://localhost:9090). */
20
19
  apiEndpoint?: string;
21
20
  }
22
- //#endregion
23
21
  export { GcsStorageOptions };
24
22
  //# sourceMappingURL=types.d.mts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyshelf/storage-gcs",
3
- "version": "0.6.2",
3
+ "version": "0.8.0",
4
4
  "description": "Google Cloud Storage adapter for StoryShelf.",
5
5
  "keywords": [
6
6
  "gcs",
@@ -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
  "@google-cloud/storage": "^7.13.0",
59
- "@storyshelf/core": "0.6.2"
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.0"
66
+ "vitest": "^5.0.5"
67
+ },
68
+ "engines": {
69
+ "node": ">=24"
70
70
  },
71
71
  "jsr": {
72
72
  "runtimeCompat": {