@voltro/plugin-storage 0.84.0 → 0.86.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/dist/types.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { Context } from 'effect';
2
2
  import { Effect } from 'effect';
3
3
  import { Schema } from 'effect';
4
+ import { StorageAccessPolicy } from '@voltro/protocol';
5
+ import { StorageAccessRule } from '@voltro/protocol';
4
6
  import { Stream } from 'effect';
5
7
  import { Subject } from '@voltro/protocol';
8
+ import { YieldableError } from 'effect/Cause';
6
9
 
7
- export declare type AccessPolicy = ReadonlyArray<AccessRule>;
10
+ export declare type AccessPolicy = StorageAccessPolicy;
8
11
 
9
12
  /**
10
13
  * One access rule. A rule GRANTS when EVERY present condition is satisfied
@@ -12,24 +15,7 @@ export declare type AccessPolicy = ReadonlyArray<AccessRule>;
12
15
  * grants (OR). An empty policy on a private object means owner-only (the
13
16
  * implicit owner check always applies).
14
17
  */
15
- export declare interface AccessRule {
16
- /** `subject.id === ref.ownerId`. */
17
- readonly owner?: boolean;
18
- /** `subject.metadata.roles` intersects these. */
19
- readonly roles?: ReadonlyArray<string>;
20
- /** resolved groups (default `subject.metadata.groups`) intersect these. */
21
- readonly groups?: ReadonlyArray<string>;
22
- /** `subject.scopes` intersects these. */
23
- readonly scopes?: ReadonlyArray<string>;
24
- /** `subject.tenantId === ref.tenantId`. */
25
- readonly tenant?: boolean;
26
- /** subject is any authenticated api-key. */
27
- readonly apiKey?: boolean;
28
- /** a correct password was supplied (checked at mint, against passwordHash). */
29
- readonly password?: boolean;
30
- /** a named custom guard (`options.guards[name]`) returns true. */
31
- readonly guard?: string;
32
- }
18
+ export declare type AccessRule = StorageAccessRule;
33
19
 
34
20
  /**
35
21
  * A lazy stream of bytes — the streaming counterpart to {@link StoredObject}'s
@@ -178,12 +164,10 @@ export declare interface Rendition {
178
164
  export declare class StorageAccessDenied extends StorageAccessDenied_base {
179
165
  }
180
166
 
181
- declare const StorageAccessDenied_base: Schema.TaggedErrorClass<StorageAccessDenied, "StorageAccessDenied", {
182
- readonly _tag: Schema.tag<"StorageAccessDenied">;
183
- } & {
184
- refId: typeof Schema.String;
185
- reason: typeof Schema.String;
186
- }>;
167
+ declare const StorageAccessDenied_base: Schema.Class<StorageAccessDenied, Schema.TaggedStruct<"StorageAccessDenied", {
168
+ readonly refId: Schema.String;
169
+ readonly reason: Schema.String;
170
+ }>, YieldableError>;
187
171
 
188
172
  /**
189
173
  * Storage failure. `transient` drives retry — `true` for 429 / 5xx /
@@ -193,14 +177,12 @@ declare const StorageAccessDenied_base: Schema.TaggedErrorClass<StorageAccessDen
193
177
  export declare class StorageError extends StorageError_base {
194
178
  }
195
179
 
196
- declare const StorageError_base: Schema.TaggedErrorClass<StorageError, "StorageError", {
197
- readonly _tag: Schema.tag<"StorageError">;
198
- } & {
199
- provider: typeof Schema.String;
200
- message: typeof Schema.String;
201
- transient: typeof Schema.Boolean;
202
- status: Schema.optional<typeof Schema.Number>;
203
- }>;
180
+ declare const StorageError_base: Schema.Class<StorageError, Schema.TaggedStruct<"StorageError", {
181
+ readonly provider: Schema.String;
182
+ readonly message: Schema.String;
183
+ readonly transient: Schema.Boolean;
184
+ readonly status: Schema.optional<Schema.Number>;
185
+ }>, YieldableError>;
204
186
 
205
187
  /** A persisted, explicit share of one object with one principal. */
206
188
  export declare interface StorageGrant {
@@ -226,6 +208,8 @@ export declare type StorageGuard = (ctx: {
226
208
  * access policy.
227
209
  */
228
210
  export declare interface StorageProvider {
211
+ /** Stable physical object-key namespace; exclude credentials and plugin aliases. */
212
+ readonly objectNamespace: Effect.Effect<string, StorageError>;
229
213
  /**
230
214
  * Where a FILESYSTEM provider writes. Absent for every other provider.
231
215
  *
@@ -356,15 +340,14 @@ export declare interface StorageRef {
356
340
  /** An upload was rejected by a constraint (size / content-type / magic-byte
357
341
  * mismatch). `reason` is a stable code; `detail` is human-readable. */
358
342
  export declare class StorageRejected extends StorageRejected_base {
343
+ get message(): string;
359
344
  }
360
345
 
361
- declare const StorageRejected_base: Schema.TaggedErrorClass<StorageRejected, "StorageRejected", {
362
- readonly _tag: Schema.tag<"StorageRejected">;
363
- } & {
346
+ declare const StorageRejected_base: Schema.Class<StorageRejected, Schema.TaggedStruct<"StorageRejected", {
364
347
  /** `'too-large' | 'content-type-not-allowed' | 'content-mismatch'` */
365
- reason: typeof Schema.String;
366
- detail: typeof Schema.String;
367
- }>;
348
+ readonly reason: Schema.String;
349
+ readonly detail: Schema.String;
350
+ }>, YieldableError>;
368
351
 
369
352
  /** Scans bytes before they're stored. Return `{ clean:false, threat }` to
370
353
  * reject the upload (fails with `StorageScanRejected`, nothing is stored). */
@@ -378,11 +361,9 @@ export declare type StorageScanner = (input: {
378
361
  export declare class StorageScanRejected extends StorageScanRejected_base {
379
362
  }
380
363
 
381
- declare const StorageScanRejected_base: Schema.TaggedErrorClass<StorageScanRejected, "StorageScanRejected", {
382
- readonly _tag: Schema.tag<"StorageScanRejected">;
383
- } & {
384
- threat: typeof Schema.String;
385
- }>;
364
+ declare const StorageScanRejected_base: Schema.Class<StorageScanRejected, Schema.TaggedStruct<"StorageScanRejected", {
365
+ readonly threat: Schema.String;
366
+ }>, YieldableError>;
386
367
 
387
368
  export declare interface StorageScanResult {
388
369
  readonly clean: boolean;
@@ -393,10 +374,12 @@ export declare interface StorageScanResult {
393
374
  export declare class StorageService extends StorageService_base {
394
375
  }
395
376
 
396
- declare const StorageService_base: Context.TagClass<StorageService, "@voltro/plugin-storage/StorageService", StorageServiceShape>;
377
+ declare const StorageService_base: Context.ServiceClass<StorageService, "@voltro/plugin-storage/StorageService", StorageServiceShape>;
397
378
 
398
379
  /** The service handlers consume: `const storage = yield* StorageService`. */
399
380
  export declare interface StorageServiceShape {
381
+ /** Opaque destination binding for manually signed upload-family credentials. */
382
+ readonly uploadTicketScope: () => Effect.Effect<string, StorageError>;
400
383
  /** Store bytes. The result is the ref plus this call's `outcome`. */
401
384
  readonly put: (input: PutInput) => Effect.Effect<StoredRef, StorageError | StorageRejected | StorageScanRejected>;
402
385
  /** Fetch an object's bytes by id. Enforces the tenant guard ONLY — it does
@@ -583,6 +566,7 @@ export declare interface StorageServiceShape {
583
566
  readonly tenantId?: string | null;
584
567
  readonly ownerId?: string | null;
585
568
  readonly visibility?: StorageVisibility;
569
+ readonly access?: AccessPolicy;
586
570
  readonly folder?: string;
587
571
  readonly tags?: ReadonlyArray<string>;
588
572
  readonly alt?: string;
@@ -616,6 +600,7 @@ export declare interface StorageServiceShape {
616
600
  readonly tenantId?: string | null;
617
601
  readonly ownerId?: string | null;
618
602
  readonly visibility?: StorageVisibility;
603
+ readonly access?: AccessPolicy;
619
604
  readonly folder?: string;
620
605
  readonly tags?: ReadonlyArray<string>;
621
606
  readonly alt?: string;
@@ -665,6 +650,7 @@ export declare interface StorageServiceShape {
665
650
  readonly tenantId?: string | null;
666
651
  readonly ownerId?: string | null;
667
652
  readonly visibility?: StorageVisibility;
653
+ readonly access?: AccessPolicy;
668
654
  readonly folder?: string;
669
655
  readonly tags?: ReadonlyArray<string>;
670
656
  readonly alt?: string;
package/dist/types.js CHANGED
@@ -11,6 +11,10 @@ var n = class extends t.TaggedError()("StorageError", {
11
11
  }) {}, i = class extends t.TaggedError()("StorageRejected", {
12
12
  reason: t.String,
13
13
  detail: t.String
14
- }) {}, a = class extends t.TaggedError()("StorageScanRejected", { threat: t.String }) {}, o = class extends e.Tag("@voltro/plugin-storage/StorageService")() {};
14
+ }) {
15
+ get message() {
16
+ return this.detail;
17
+ }
18
+ }, a = class extends t.TaggedError()("StorageScanRejected", { threat: t.String }) {}, o = class extends e.Service()("@voltro/plugin-storage/StorageService") {};
15
19
  //#endregion
16
20
  export { r as StorageAccessDenied, n as StorageError, i as StorageRejected, a as StorageScanRejected, o as StorageService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-storage",
3
- "version": "0.84.0",
3
+ "version": "0.86.0",
4
4
  "description": "File-storage plugin — one StorageProvider contract, switchable backends (S3 / MinIO / Azure / filesystem / memory / database). Public (CDN-direct) + private (access policy + per-object grants) objects, upload constraints, virus-scan hook, on-the-fly image transforms.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -43,10 +43,10 @@
43
43
  "node": ">=24.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@voltro/database": "0.84.0",
47
- "@voltro/env": "0.84.0",
48
- "@voltro/protocol": "0.84.0",
49
- "@voltro/runtime": "0.84.0"
46
+ "@voltro/database": "0.86.0",
47
+ "@voltro/env": "0.86.0",
48
+ "@voltro/protocol": "0.86.0",
49
+ "@voltro/runtime": "0.86.0"
50
50
  },
51
51
  "optionalDependencies": {
52
52
  "@aws-sdk/client-s3": "^3.1134.0",
@@ -56,7 +56,7 @@
56
56
  "sharp": "^0.35.5"
57
57
  },
58
58
  "peerDependencies": {
59
- "effect": "^3.22.2"
59
+ "effect": "4.0.1"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public"