@kumulo/storage-bunny 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Stahl-Gruber
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 OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,15 @@
1
- # Temporary Holding Version
1
+ # @kumulo/storage-bunny
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Object storage provider for bunny.net. Each bucket is one S3-type storage zone, tracked by id in `<cluster>.buckets.yaml`. Zone names are globally unique and checked at plan time, and a zone with files in it is never deleted. The bunny S3 API is a public preview: no versioning, no server-side encryption, no lifecycle rules, and a limit of 500 requests per second per zone.
4
+
5
+ Part of [kumulo](../../../README.md) — a CLI that provisions and manages
6
+ Kubernetes clusters on OVH from a single YAML config. This package is
7
+ published from that workspace and is normally consumed through the `kumulo`
8
+ CLI rather than directly.
9
+
10
+ ```sh
11
+ bun add @kumulo/storage-bunny
12
+ ```
13
+
14
+ See the [root README](../../../README.md) for configuration, commands and
15
+ examples, and the [changelog](../../../CHANGELOG.md) for release notes.
package/dist/diff.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import type { BucketRef } from "@kumulo/core";
2
+ export type BunnyTier = "standard" | "edge";
3
+ export interface BunnyBucketSpec {
4
+ readonly name: string;
5
+ readonly region: string;
6
+ readonly tier?: BunnyTier | undefined;
7
+ readonly retain: boolean;
8
+ }
9
+ export interface ExistingBunnyBucket {
10
+ readonly id: number;
11
+ readonly name: string;
12
+ readonly region: string;
13
+ readonly tier: BunnyTier;
14
+ readonly retain: boolean;
15
+ }
16
+ export interface BunnyBucketDiff {
17
+ readonly toCreate: ReadonlyArray<BunnyBucketSpec>;
18
+ readonly toReplace: ReadonlyArray<{
19
+ readonly ref: BucketRef;
20
+ readonly spec: BunnyBucketSpec;
21
+ }>;
22
+ readonly toDelete: ReadonlyArray<BucketRef>;
23
+ readonly noop: ReadonlyArray<BucketRef>;
24
+ }
25
+ export declare const diffBuckets: ({ desired, existing }: {
26
+ readonly desired: ReadonlyArray<BunnyBucketSpec>;
27
+ readonly existing: ReadonlyArray<ExistingBunnyBucket>;
28
+ }) => BunnyBucketDiff;
@@ -0,0 +1,5 @@
1
+ export declare const packageName = "@kumulo/storage-bunny";
2
+ export { diffBuckets } from "./diff";
3
+ export type { BunnyTier } from "./diff";
4
+ export { OutputsBucket, OutputsInvalid, outputsPath, parseOutputsYaml, readOutputs, writeOutputs } from "./outputs";
5
+ export { bunnyObjectStorageProviderLive, makeBunnyObjectStorageProvider } from "./provider";
package/dist/index.mjs ADDED
@@ -0,0 +1,149 @@
1
+ import { BucketNotEmpty, ObjectStorageProvider, OutputsInvalid, ResourceConflict, ResourceNotFound, diffBuckets as diffBuckets$1, makeOutputsFile } from "@kumulo/core";
2
+ import { Effect, Layer, Option, Redacted, Schema } from "effect";
3
+ import { bunnyCapabilityAsApiError } from "@kumulo/bunny";
4
+ // src/diff.ts
5
+ const _toRef = (bucket) => ({
6
+ name: bucket.name,
7
+ region: bucket.region
8
+ });
9
+ const diffBuckets = ({ desired, existing }) => {
10
+ const diff = diffBuckets$1({
11
+ desired,
12
+ existing,
13
+ isImmutable: (spec, current) => spec.region !== current.region || (spec.tier ?? "standard") !== current.tier
14
+ });
15
+ return {
16
+ toCreate: diff.toCreate,
17
+ toReplace: diff.toReplace.map(({ existing: current, spec }) => ({
18
+ ref: _toRef(current),
19
+ spec
20
+ })),
21
+ toDelete: diff.toDelete.map(_toRef),
22
+ noop: diff.noop.map(_toRef)
23
+ };
24
+ };
25
+ // src/outputs.ts
26
+ const OutputsBucket = Schema.Struct({
27
+ id: Schema.Number,
28
+ name: Schema.NonEmptyString,
29
+ region: Schema.NonEmptyString,
30
+ tier: Schema.Literals(["standard", "edge"]),
31
+ retain: Schema.Boolean
32
+ });
33
+ const OutputsFile = Schema.Struct({
34
+ cluster: Schema.NonEmptyString,
35
+ buckets: Schema.Array(OutputsBucket)
36
+ });
37
+ const _file = makeOutputsFile({
38
+ schema: OutputsFile,
39
+ suffix: "buckets",
40
+ empty: (tag) => ({
41
+ cluster: tag,
42
+ buckets: []
43
+ }),
44
+ clusterOf: (file) => file.cluster,
45
+ order: (file) => ({
46
+ cluster: file.cluster,
47
+ buckets: file.buckets
48
+ })
49
+ });
50
+ const outputsPath = _file.path;
51
+ const parseOutputsYaml = _file.parseYaml;
52
+ _file.stringify;
53
+ _file.empty;
54
+ const readOutputs = _file.read;
55
+ const writeOutputs = _file.write;
56
+ // src/provider.ts
57
+ const _kind = "storage-zone";
58
+ const _mapped = (self) => Effect.mapError(self, bunnyCapabilityAsApiError);
59
+ const _endpoint = (zone) => zone.S3Hostname ? `https://${zone.S3Hostname}` : `https://${zone.Region.toLowerCase()}-s3.storage.bunnycdn.com`;
60
+ const _toInfo = (zone) => ({
61
+ name: zone.Name,
62
+ region: zone.Region,
63
+ endpoint: _endpoint(zone)
64
+ });
65
+ const _tier = (zone) => zone.ZoneTier === "Edge" ? "edge" : "standard";
66
+ const _credential = (zone) => ({
67
+ ..._toInfo(zone),
68
+ accessKey: Redacted.make(zone.Name),
69
+ secretKey: Redacted.make(zone.Password ?? "")
70
+ });
71
+ const makeBunnyObjectStorageProvider = ({ owned, storage }) => {
72
+ const ownedByName = new Map(owned.map((bucket) => [bucket.name, bucket]));
73
+ const ensureZone = (spec) => Effect.gen(function* () {
74
+ const mine = ownedByName.get(spec.name);
75
+ if (mine !== void 0) {
76
+ const zone = yield* _mapped(storage.getZone(mine.id));
77
+ return {
78
+ info: _toInfo(zone),
79
+ bucket: {
80
+ ...mine,
81
+ region: zone.Region,
82
+ tier: _tier(zone)
83
+ }
84
+ };
85
+ }
86
+ if (!(yield* _mapped(storage.checkAvailability(spec.name)))) return yield* Effect.fail(new ResourceConflict({
87
+ kind: _kind,
88
+ ref: spec.name
89
+ }));
90
+ const zone = yield* _mapped(storage.createZone({
91
+ name: spec.name,
92
+ region: spec.region,
93
+ zoneTier: spec.tier === "edge" ? "Edge" : "Standard"
94
+ }));
95
+ return {
96
+ info: _toInfo(zone),
97
+ bucket: {
98
+ id: zone.Id,
99
+ name: zone.Name,
100
+ region: zone.Region,
101
+ tier: _tier(zone),
102
+ retain: spec.retain
103
+ }
104
+ };
105
+ });
106
+ const listBuckets = (region) => Effect.map(_mapped(storage.listZones()), (zones) => zones.filter((zone) => zone.Region === region && ownedByName.has(zone.Name)).map(_toInfo));
107
+ const ensureBucket = (spec) => Effect.map(ensureZone(spec), (ensured) => ensured.info);
108
+ const deleteBucket = (ref) => Effect.gen(function* () {
109
+ const mine = ownedByName.get(ref.name);
110
+ if (mine === void 0) return yield* Effect.fail(new ResourceNotFound({
111
+ kind: _kind,
112
+ ref: ref.name
113
+ }));
114
+ if (mine.retain) return;
115
+ const zone = yield* _mapped(storage.getZone(mine.id)).pipe(Effect.map(Option.some), Effect.catchTag("ResourceNotFound", () => Effect.succeed(Option.none())));
116
+ if (Option.isNone(zone)) return;
117
+ if (zone.value.FilesStored > 0) return yield* Effect.fail(new BucketNotEmpty({
118
+ bucket: ref.name,
119
+ objectCount: zone.value.FilesStored
120
+ }));
121
+ yield* _mapped(storage.deleteZone(mine.id));
122
+ });
123
+ const ensureCredentials = (clusterName) => Effect.map(Effect.forEach(owned, (bucket) => _mapped(storage.getZone(bucket.id))), (zones) => ({
124
+ user: `kumulo-${clusterName}`,
125
+ accessKey: Redacted.make(""),
126
+ secretKey: Redacted.make(""),
127
+ buckets: zones.map(_toInfo),
128
+ bucketCredentials: zones.map(_credential)
129
+ }));
130
+ return {
131
+ listBuckets,
132
+ ensureBucket,
133
+ ensureZone,
134
+ deleteBucket,
135
+ ensureCredentials
136
+ };
137
+ };
138
+ const bunnyObjectStorageProviderLive = (input) => {
139
+ const { deleteBucket, ensureBucket, ensureCredentials, listBuckets } = makeBunnyObjectStorageProvider(input);
140
+ return Layer.succeed(ObjectStorageProvider, {
141
+ listBuckets,
142
+ ensureBucket,
143
+ deleteBucket,
144
+ ensureCredentials
145
+ });
146
+ };
147
+ // src/index.ts
148
+ const packageName = "@kumulo/storage-bunny";
149
+ export { OutputsBucket, OutputsInvalid, bunnyObjectStorageProviderLive, diffBuckets, makeBunnyObjectStorageProvider, outputsPath, packageName, parseOutputsYaml, readOutputs, writeOutputs };
@@ -0,0 +1,80 @@
1
+ import { Schema } from "effect";
2
+ import type { ClusterTag } from "@kumulo/core";
3
+ export { OutputsInvalid } from "@kumulo/core";
4
+ export declare const OutputsBucket: Schema.Struct<{
5
+ readonly id: Schema.Number;
6
+ readonly name: Schema.NonEmptyString;
7
+ readonly region: Schema.NonEmptyString;
8
+ readonly tier: Schema.Literals<readonly ["standard", "edge"]>;
9
+ readonly retain: Schema.Boolean;
10
+ }>;
11
+ export type OutputsBucket = Schema.Schema.Type<typeof OutputsBucket>;
12
+ export declare const OutputsFile: Schema.Struct<{
13
+ readonly cluster: Schema.NonEmptyString;
14
+ readonly buckets: Schema.$Array<Schema.Struct<{
15
+ readonly id: Schema.Number;
16
+ readonly name: Schema.NonEmptyString;
17
+ readonly region: Schema.NonEmptyString;
18
+ readonly tier: Schema.Literals<readonly ["standard", "edge"]>;
19
+ readonly retain: Schema.Boolean;
20
+ }>>;
21
+ }>;
22
+ export type OutputsFile = Schema.Schema.Type<typeof OutputsFile>;
23
+ export declare const outputsPath: ({ dir, format, tag }: import("@kumulo/core").OutputsLocation) => string;
24
+ export declare const parseOutputsYaml: (text: string) => import("effect/Effect").Effect<{
25
+ readonly cluster: string;
26
+ readonly buckets: readonly {
27
+ readonly id: number;
28
+ readonly name: string;
29
+ readonly region: string;
30
+ readonly tier: "edge" | "standard";
31
+ readonly retain: boolean;
32
+ }[];
33
+ }, import("@kumulo/core").OutputsInvalid, never>;
34
+ export declare const stringifyOutputs: ({ file, format }: {
35
+ readonly file: {
36
+ readonly cluster: string;
37
+ readonly buckets: readonly {
38
+ readonly id: number;
39
+ readonly name: string;
40
+ readonly region: string;
41
+ readonly tier: "edge" | "standard";
42
+ readonly retain: boolean;
43
+ }[];
44
+ };
45
+ readonly format?: import("@kumulo/core").OutputsFormat | undefined;
46
+ }) => string;
47
+ export declare const emptyOutputs: (tag: ClusterTag) => {
48
+ readonly cluster: string;
49
+ readonly buckets: readonly {
50
+ readonly id: number;
51
+ readonly name: string;
52
+ readonly region: string;
53
+ readonly tier: "edge" | "standard";
54
+ readonly retain: boolean;
55
+ }[];
56
+ };
57
+ export declare const readOutputs: ({ dir, format, tag }: import("@kumulo/core").OutputsLocation) => import("effect/Effect").Effect<{
58
+ readonly cluster: string;
59
+ readonly buckets: readonly {
60
+ readonly id: number;
61
+ readonly name: string;
62
+ readonly region: string;
63
+ readonly tier: "edge" | "standard";
64
+ readonly retain: boolean;
65
+ }[];
66
+ }, import("@kumulo/core").OutputsInvalid | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
67
+ export declare const writeOutputs: ({ dir, file, format }: {
68
+ readonly dir: string;
69
+ readonly file: {
70
+ readonly cluster: string;
71
+ readonly buckets: readonly {
72
+ readonly id: number;
73
+ readonly name: string;
74
+ readonly region: string;
75
+ readonly tier: "edge" | "standard";
76
+ readonly retain: boolean;
77
+ }[];
78
+ };
79
+ readonly format?: import("@kumulo/core").OutputsFormat | undefined;
80
+ }) => import("effect/Effect").Effect<void, import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
@@ -0,0 +1,24 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { ObjectStorageProvider } from "@kumulo/core";
3
+ import type { BucketInfo, BucketRef, ClusterTag, ObjectStorageError, S3Credentials } from "@kumulo/core";
4
+ import type { BunnyStorageClient } from "@kumulo/bunny";
5
+ import type { BunnyBucketSpec } from "./diff";
6
+ import type { OutputsBucket } from "./outputs";
7
+ export interface EnsuredZone {
8
+ readonly info: BucketInfo;
9
+ readonly bucket: OutputsBucket;
10
+ }
11
+ export declare const makeBunnyObjectStorageProvider: ({ owned, storage }: {
12
+ readonly storage: BunnyStorageClient;
13
+ readonly owned: ReadonlyArray<OutputsBucket>;
14
+ }) => {
15
+ listBuckets: (region: string) => Effect.Effect<ReadonlyArray<BucketInfo>, ObjectStorageError>;
16
+ ensureBucket: (spec: BunnyBucketSpec) => Effect.Effect<BucketInfo, ObjectStorageError>;
17
+ ensureZone: (spec: BunnyBucketSpec) => Effect.Effect<EnsuredZone, ObjectStorageError>;
18
+ deleteBucket: (ref: BucketRef) => Effect.Effect<void, ObjectStorageError>;
19
+ ensureCredentials: (clusterName: ClusterTag) => Effect.Effect<S3Credentials, ObjectStorageError>;
20
+ };
21
+ export declare const bunnyObjectStorageProviderLive: (input: {
22
+ readonly storage: BunnyStorageClient;
23
+ readonly owned: ReadonlyArray<OutputsBucket>;
24
+ }) => Layer.Layer<ObjectStorageProvider, never, never>;
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@kumulo/storage-bunny",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "bunny.net Storage provider for kumulo.",
5
+ "license": "MIT",
6
+ "author": "David Stahl-Gruber",
7
+ "homepage": "https://github.com/DwieDave/kumulo#readme",
8
+ "bugs": "https://github.com/DwieDave/kumulo/issues",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/DwieDave/kumulo.git",
12
+ "directory": "packages/bunny/storage"
13
+ },
14
+ "keywords": [
15
+ "bunny",
16
+ "storage",
17
+ "effect",
18
+ "typescript"
19
+ ],
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.mjs"
25
+ }
26
+ },
27
+ "main": "./dist/index.mjs",
28
+ "types": "./dist/index.d.ts",
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "engines": {
35
+ "node": ">=22"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "dependencies": {
41
+ "@kumulo/bunny": "0.2.0",
42
+ "@kumulo/core": "0.2.0"
43
+ },
44
+ "peerDependencies": {
45
+ "effect": "4.1.0"
46
+ },
47
+ "devDependencies": {
48
+ "@effect/vitest": "4.1.0",
49
+ "vitest": "5.0.5",
50
+ "effect": "4.1.0"
51
+ },
52
+ "scripts": {
53
+ "build": "bash ../../../scripts/build-package.sh",
54
+ "prepack": "node ../../../scripts/prepack-exports.mjs strip",
55
+ "postpack": "node ../../../scripts/prepack-exports.mjs restore",
56
+ "prepublishOnly": "bun run build"
57
+ }
58
+ }