@voltro/plugin-storage 0.85.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/CHANGELOG.md +666 -0
- package/README.md +50 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- package/dist/access.js +47 -0
- package/dist/assetRef.js +13 -0
- package/dist/avatar.js +39 -0
- package/dist/constraints.js +93 -0
- package/dist/derivatives.js +30 -0
- package/dist/env.js +156 -0
- package/dist/grant.js +112 -0
- package/dist/index.d.ts +93 -9
- package/dist/index.js +581 -3185
- package/dist/ingest.js +81 -0
- package/dist/ingestPolicy.js +1 -0
- package/dist/metadataError.js +19 -0
- package/dist/objectLifecycle.js +209 -0
- package/dist/objectMetadata.js +150 -0
- package/dist/objectWriter.js +58 -0
- package/dist/pathDurability.js +16 -0
- package/dist/providers.js +493 -0
- package/dist/referenceCatalogue.js +31 -0
- package/dist/rpc.d.ts +2 -0
- package/dist/rpc.js +3 -1
- package/dist/scanners.js +46 -0
- package/dist/service.js +1084 -0
- package/dist/storageNamespaces.js +56 -0
- package/dist/storageNumbers.js +13 -0
- package/dist/storageObjectNamespaces.js +194 -0
- package/dist/storageReferenceInstances.js +52 -0
- package/dist/streamBridge.js +30 -0
- package/dist/table.js +53 -0
- package/dist/transcodeVideo.js +53 -0
- package/dist/transform.js +90 -0
- package/dist/transformCache.js +31 -0
- package/dist/types.d.ts +4 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,20 @@ export declare interface AssetRefOptions {
|
|
|
58
58
|
readonly nullable?: boolean;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/** The caller owns the after-schema transaction, with serving replicas stopped.
|
|
62
|
+
* Assignments preserve reference IDs, keys, grants, raw put identities, claims
|
|
63
|
+
* and quota. No provider I/O or nested transaction occurs. Returned cleanup
|
|
64
|
+
* targets run through their matching service after boot. */
|
|
65
|
+
export declare const assignStorageObjectNamespacesInTransaction: (store: DataStore, scopes: readonly StorageReferenceScope[], assignments: readonly StorageObjectNamespaceAssignment[]) => Promise<StorageObjectNamespaceMigrationResult>;
|
|
66
|
+
|
|
67
|
+
/** Run in an after-schema migration with serving replicas stopped. The mapping
|
|
68
|
+
* comes from the operator, never from provider failures or the default name.
|
|
69
|
+
* The supplied store belongs to the caller’s transaction. No nested transaction
|
|
70
|
+
* is opened. Only ownership columns change: IDs, bytes, claims, quota and replay stay put. */
|
|
71
|
+
export declare const assignStorageReferenceInstancesInTransaction: (store: DataStore, instances: readonly string[], assignments: readonly StorageReferenceInstanceAssignment[]) => Promise<{
|
|
72
|
+
readonly assigned: number;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
61
75
|
export declare const azureProvider: (options: AzureProviderOptions) => StorageProvider;
|
|
62
76
|
|
|
63
77
|
export declare interface AzureProviderOptions {
|
|
@@ -159,10 +173,10 @@ export declare const databaseProvider: () => StorageProvider & {
|
|
|
159
173
|
bindDataStore: (store: unknown) => void;
|
|
160
174
|
};
|
|
161
175
|
|
|
162
|
-
export declare const dataStoreGrantStore: (store: DataStore) => GrantStore;
|
|
176
|
+
export declare const dataStoreGrantStore: (store: DataStore, configuredScope: StorageReferenceScope) => GrantStore;
|
|
163
177
|
|
|
164
178
|
/** Ref store backed by the app's `DataStore` (`_voltro_storage_refs`). */
|
|
165
|
-
export declare const dataStoreRefStore: (store: DataStore) => RefStore;
|
|
179
|
+
export declare const dataStoreRefStore: (store: DataStore, configuredScope: StorageReferenceScope) => RefStore;
|
|
166
180
|
|
|
167
181
|
/** Decode a `data:<mime>;base64,<data>` URI to bytes + content type. */
|
|
168
182
|
export declare const decodeDataUri: (dataUri: string) => {
|
|
@@ -189,6 +203,12 @@ export declare const editImage: (bytes: Uint8Array, contentType: string, edit: I
|
|
|
189
203
|
* chunks, terminated by a zero-length chunk. Exposed for testing. */
|
|
190
204
|
export declare const encodeInstream: (bytes: Uint8Array, chunkSize?: number) => Buffer;
|
|
191
205
|
|
|
206
|
+
/** Boot-time initialization after normal schema reconciliation. This identity
|
|
207
|
+
* describes the persisted reference catalogue, not its provider bytes or host. */
|
|
208
|
+
export declare const ensureStorageReferenceCatalogue: (store: DataStore) => Promise<void>;
|
|
209
|
+
|
|
210
|
+
export declare const fetchIngestBody: (url: string, configuredMaxBytes?: number, policy?: IngestPolicy) => Effect.Effect<StoredObject, StorageError | StorageRejected>;
|
|
211
|
+
|
|
192
212
|
export declare interface FfmpegRenditionSpec {
|
|
193
213
|
/** Derivative class stored on the rendition ref — `'rendition'` / `'poster'`. */
|
|
194
214
|
readonly kind: string;
|
|
@@ -338,10 +358,16 @@ export declare interface ListRefsResult {
|
|
|
338
358
|
|
|
339
359
|
/** DataStore-backed metadata boundary, intentionally no provider access. The
|
|
340
360
|
* service must use reserve -> provider.put -> confirm and retain failed intents. */
|
|
341
|
-
export declare const makeStorageObjectMetadata: (store: DataStore) => {
|
|
361
|
+
export declare const makeStorageObjectMetadata: (store: DataStore, configuredScope: StorageReferenceScope) => {
|
|
362
|
+
scope: Readonly<{
|
|
363
|
+
storageInstance: string;
|
|
364
|
+
objectNamespace: string;
|
|
365
|
+
}>;
|
|
342
366
|
/** The put intent a reference was written under, if it was written through an operation at all. */
|
|
343
367
|
intent: (refId: string) => Promise<{
|
|
344
368
|
identity: {
|
|
369
|
+
readonly storageInstance: string;
|
|
370
|
+
readonly objectNamespace: string;
|
|
345
371
|
readonly tenantId: string | null;
|
|
346
372
|
readonly bucket: string;
|
|
347
373
|
readonly operationId: string;
|
|
@@ -366,6 +392,8 @@ export declare const makeStorageObjectMetadata: (store: DataStore) => {
|
|
|
366
392
|
beginDelete: (refId: string, tenantId?: string | null, claim?: string) => Promise<{
|
|
367
393
|
released: true;
|
|
368
394
|
identity: {
|
|
395
|
+
readonly storageInstance: string;
|
|
396
|
+
readonly objectNamespace: string;
|
|
369
397
|
readonly tenantId: string | null;
|
|
370
398
|
readonly bucket: string;
|
|
371
399
|
readonly operationId: string;
|
|
@@ -378,15 +406,19 @@ export declare const makeStorageObjectMetadata: (store: DataStore) => {
|
|
|
378
406
|
released: true;
|
|
379
407
|
operation: {
|
|
380
408
|
readonly id: string;
|
|
409
|
+
readonly storageInstance: string;
|
|
410
|
+
readonly objectNamespace: string;
|
|
381
411
|
readonly objectId: string;
|
|
382
412
|
readonly fingerprint: string;
|
|
383
413
|
readonly generation: string;
|
|
384
414
|
readonly key: string;
|
|
385
415
|
readonly refId: string;
|
|
386
|
-
readonly state: "ready" | "reserved" | "
|
|
416
|
+
readonly state: "ready" | "reserved" | "deleting" | "deleted";
|
|
387
417
|
readonly deleteKey: string | null;
|
|
388
418
|
};
|
|
389
419
|
identity: {
|
|
420
|
+
readonly storageInstance: string;
|
|
421
|
+
readonly objectNamespace: string;
|
|
390
422
|
readonly tenantId: string | null;
|
|
391
423
|
readonly bucket: string;
|
|
392
424
|
readonly operationId: string;
|
|
@@ -546,6 +578,9 @@ export declare interface RefStatistics {
|
|
|
546
578
|
}
|
|
547
579
|
|
|
548
580
|
export declare interface RefStore {
|
|
581
|
+
/** Stable identity of this actual reference view. Shared catalogues expose
|
|
582
|
+
* the same identity; independent/process-local stores must expose their own. */
|
|
583
|
+
readonly catalogueId: Effect.Effect<string, StorageError>;
|
|
549
584
|
/** Aggregate the complete reference index without a recent-object limit. */
|
|
550
585
|
readonly statistics: () => Effect.Effect<RefStatistics, StorageError>;
|
|
551
586
|
readonly insert: (ref: StorageRef) => Effect.Effect<void, StorageError>;
|
|
@@ -617,6 +652,9 @@ export declare interface Rendition {
|
|
|
617
652
|
readonly label?: string;
|
|
618
653
|
}
|
|
619
654
|
|
|
655
|
+
/** Nullable additions deliberately fail closed until the explicit upgrade. */
|
|
656
|
+
export declare const requireStorageObjectNamespaces: (store: DataStore) => Promise<void>;
|
|
657
|
+
|
|
620
658
|
/** A `ListRefsInput` after the service normalizes its defaults / clamps — what
|
|
621
659
|
* a `RefStore.listRefs` impl receives. `limit` is already the `+1` probe. */
|
|
622
660
|
export declare interface ResolvedListQuery {
|
|
@@ -668,6 +706,8 @@ export declare interface S3ProviderOptions {
|
|
|
668
706
|
readonly publicAcl?: boolean;
|
|
669
707
|
}
|
|
670
708
|
|
|
709
|
+
declare type ScopedStorageObjectIdentity = StorageObjectIdentity & StorageReferenceScope;
|
|
710
|
+
|
|
671
711
|
/** Register the app's storage provider (or clear with `undefined`). */
|
|
672
712
|
export declare const setActiveStorageProvider: (provider: StorageProvider | undefined) => void;
|
|
673
713
|
|
|
@@ -694,6 +734,8 @@ export declare const STORAGE_BLOBS_TABLE = "_voltro_storage_blobs";
|
|
|
694
734
|
|
|
695
735
|
export declare const STORAGE_GRANTS_TABLE = "_voltro_storage_grants";
|
|
696
736
|
|
|
737
|
+
export declare const STORAGE_REFERENCE_CATALOGUE_TABLE = "_voltro_storage_reference_catalogue";
|
|
738
|
+
|
|
697
739
|
export declare const STORAGE_REFS_TABLE = "_voltro_storage_refs";
|
|
698
740
|
|
|
699
741
|
export declare const STORAGE_USAGE_TABLE = "_voltro_storage_usage";
|
|
@@ -761,8 +803,9 @@ export declare type StorageGuard = (ctx: {
|
|
|
761
803
|
* and `BASE_NAME` is not exported, so a caller minting a ticket outside the
|
|
762
804
|
* plugin had to guess it. Guessing is exactly what a `string` parameter invites.
|
|
763
805
|
*
|
|
806
|
+
* const writeScope = await Effect.runPromise(service.uploadTicketScope())
|
|
764
807
|
* const ticket = signUploadTicket(
|
|
765
|
-
* { instance: storageInstanceName(), key, contentType },
|
|
808
|
+
* { writeScope, instance: storageInstanceName(options), key, ct: contentType, sub: ownerId, tenant: tenantId, vis: 'private' },
|
|
766
809
|
* 300,
|
|
767
810
|
* )
|
|
768
811
|
*
|
|
@@ -791,11 +834,14 @@ export declare const storageObjectLifecycleTables: ( Table<"_voltro_storage_oper
|
|
|
791
834
|
readonly nonce: ColumnBuilder<string, "text", boolean>;
|
|
792
835
|
}>, false, never> | Table<"_voltro_storage_object_heads", FieldDefinitions<{
|
|
793
836
|
readonly id: ColumnBuilder<string, "text", boolean>;
|
|
837
|
+
readonly objectNamespace: ColumnBuilder<string | null, "text", boolean>;
|
|
794
838
|
readonly generation: ColumnBuilder<string, "text", boolean>;
|
|
795
839
|
readonly key: ColumnBuilder<string, "text", boolean>;
|
|
796
840
|
readonly reservations: ColumnBuilder<string, "bigint", boolean>;
|
|
797
841
|
}>, false, never> | Table<"_voltro_storage_operations", FieldDefinitions<{
|
|
798
842
|
readonly id: ColumnBuilder<string, "text", boolean>;
|
|
843
|
+
readonly storageInstance: ColumnBuilder<string | null, "text", boolean>;
|
|
844
|
+
readonly objectNamespace: ColumnBuilder<string | null, "text", boolean>;
|
|
799
845
|
readonly objectId: ColumnBuilder<string, "text", boolean>;
|
|
800
846
|
readonly fingerprint: ColumnBuilder<string, "text", boolean>;
|
|
801
847
|
readonly generation: ColumnBuilder<string, "text", boolean>;
|
|
@@ -811,6 +857,19 @@ export declare const storageObjectLifecycleTables: ( Table<"_voltro_storage_oper
|
|
|
811
857
|
|
|
812
858
|
export declare type StorageObjectMetadata = ReturnType<typeof makeStorageObjectMetadata>;
|
|
813
859
|
|
|
860
|
+
/** Credential-independent identity of a physical object-key namespace.
|
|
861
|
+
* Equal identities mean an equal key addresses the same provider bytes. */
|
|
862
|
+
export declare const storageObjectNamespace: (parts: readonly string[]) => string;
|
|
863
|
+
|
|
864
|
+
export declare interface StorageObjectNamespaceAssignment extends StorageReferenceScope {
|
|
865
|
+
readonly refId: string;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export declare interface StorageObjectNamespaceMigrationResult {
|
|
869
|
+
readonly assigned: number;
|
|
870
|
+
readonly pendingDeletes: readonly StorageObjectNamespaceAssignment[];
|
|
871
|
+
}
|
|
872
|
+
|
|
814
873
|
export declare const storagePlugin: (options?: StoragePluginOptions) => VoltroPlugin;
|
|
815
874
|
|
|
816
875
|
export declare interface StoragePluginOptions {
|
|
@@ -965,6 +1024,8 @@ export declare interface StoragePluginOptions {
|
|
|
965
1024
|
* access policy.
|
|
966
1025
|
*/
|
|
967
1026
|
export declare interface StorageProvider {
|
|
1027
|
+
/** Stable physical object-key namespace; exclude credentials and plugin aliases. */
|
|
1028
|
+
readonly objectNamespace: Effect.Effect<string, StorageError>;
|
|
968
1029
|
/**
|
|
969
1030
|
* Where a FILESYSTEM provider writes. Absent for every other provider.
|
|
970
1031
|
*
|
|
@@ -1055,7 +1116,9 @@ export declare type StorageProviderName = 's3' | 'minio' | 'azure' | 'filesystem
|
|
|
1055
1116
|
export declare const storagePutIntentsTable: Table<"_voltro_storage_put_intents", FieldDefinitions<{
|
|
1056
1117
|
readonly id: ColumnBuilder<string, "text", boolean>;
|
|
1057
1118
|
readonly refId: ColumnBuilder<string, "text", boolean>;
|
|
1058
|
-
readonly
|
|
1119
|
+
readonly storageInstance: ColumnBuilder<string | null, "text", boolean>;
|
|
1120
|
+
readonly objectNamespace: ColumnBuilder<string | null, "text", boolean>;
|
|
1121
|
+
readonly identity: ColumnBuilder<ScopedStorageObjectIdentity, "json", boolean>;
|
|
1059
1122
|
readonly ref: ColumnBuilder<StorageRef, "json", boolean>;
|
|
1060
1123
|
}>, false, never>;
|
|
1061
1124
|
|
|
@@ -1105,6 +1168,21 @@ export declare interface StorageRef {
|
|
|
1105
1168
|
readonly kind?: string | null;
|
|
1106
1169
|
}
|
|
1107
1170
|
|
|
1171
|
+
export declare const storageReferenceCatalogueTable: Table<"_voltro_storage_reference_catalogue", FieldDefinitions<{
|
|
1172
|
+
readonly id: ColumnBuilder<string, "text", boolean>;
|
|
1173
|
+
readonly namespace: ColumnBuilder<string, "text", boolean>;
|
|
1174
|
+
}>, false, never>;
|
|
1175
|
+
|
|
1176
|
+
export declare interface StorageReferenceInstanceAssignment {
|
|
1177
|
+
readonly refId: string;
|
|
1178
|
+
readonly storageInstance: string;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
export declare interface StorageReferenceScope {
|
|
1182
|
+
readonly storageInstance: string;
|
|
1183
|
+
readonly objectNamespace: string;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1108
1186
|
/** An upload was rejected by a constraint (size / content-type / magic-byte
|
|
1109
1187
|
* mismatch). `reason` is a stable code; `detail` is human-readable. */
|
|
1110
1188
|
export declare class StorageRejected extends StorageRejected_base {
|
|
@@ -1151,6 +1229,8 @@ export declare interface StorageServiceOptions {
|
|
|
1151
1229
|
readonly refStore: RefStore;
|
|
1152
1230
|
readonly grantStore: GrantStore;
|
|
1153
1231
|
readonly bucket: string;
|
|
1232
|
+
/** Canonical plugin instance; separates new plain keys on a shared provider. */
|
|
1233
|
+
readonly storageInstance?: string;
|
|
1154
1234
|
/** Static prefix prepended to every key (e.g. an app/env namespace). */
|
|
1155
1235
|
readonly tenantPrefix?: string;
|
|
1156
1236
|
/** Transient-failure retries (429 / 5xx / network). Default 3. */
|
|
@@ -1203,6 +1283,8 @@ export declare interface StorageServiceOptions {
|
|
|
1203
1283
|
|
|
1204
1284
|
/** The service handlers consume: `const storage = yield* StorageService`. */
|
|
1205
1285
|
export declare interface StorageServiceShape {
|
|
1286
|
+
/** Opaque destination binding for manually signed upload-family credentials. */
|
|
1287
|
+
readonly uploadTicketScope: () => Effect.Effect<string, StorageError>;
|
|
1206
1288
|
/** Store bytes. The result is the ref plus this call's `outcome`. */
|
|
1207
1289
|
readonly put: (input: PutInput) => Effect.Effect<StoredRef, StorageError | StorageRejected | StorageScanRejected>;
|
|
1208
1290
|
/** Fetch an object's bytes by id. Enforces the tenant guard ONLY — it does
|
|
@@ -1587,11 +1669,13 @@ export declare interface UploadLimits {
|
|
|
1587
1669
|
* owner/tenant/content-type/visibility, until `exp`. */
|
|
1588
1670
|
export declare interface UploadTicketPayload {
|
|
1589
1671
|
/** Frozen-policy ticket contract. Previous tickets must be minted again. */
|
|
1590
|
-
readonly version:
|
|
1672
|
+
readonly version: 2;
|
|
1591
1673
|
/** Optional durable write identity, preserved across ticket renewal. */
|
|
1592
1674
|
readonly operationId?: string;
|
|
1593
|
-
/**
|
|
1594
|
-
readonly
|
|
1675
|
+
/** Exact reference catalogue and physical byte destination authorized by the issuer. */
|
|
1676
|
+
readonly writeScope: string;
|
|
1677
|
+
/** Optional signed routing hint for the binary relay; destination authorization still uses writeScope. */
|
|
1678
|
+
readonly issuerReplicaId?: string;
|
|
1595
1679
|
/** Exact storage plugin instance authorized to accept the bytes. */
|
|
1596
1680
|
readonly instance: string;
|
|
1597
1681
|
/** ownerId (subject id) the stored object is attributed to. */
|