@voltro/plugin-storage 0.85.0 → 0.87.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +5987 -0
  2. package/README.md +77 -0
  3. package/THIRD-PARTY-NOTICES.md +860 -249
  4. package/dist/access.js +47 -0
  5. package/dist/assetRef.js +13 -0
  6. package/dist/avatar.js +39 -0
  7. package/dist/byteSecurity.d.ts +3 -0
  8. package/dist/byteSecurity.js +7 -0
  9. package/dist/connection.js +99 -0
  10. package/dist/constraints.js +93 -0
  11. package/dist/custody.js +132 -0
  12. package/dist/derivatives.js +30 -0
  13. package/dist/env.js +162 -0
  14. package/dist/grant.js +132 -0
  15. package/dist/index.d.ts +525 -203
  16. package/dist/index.js +765 -3196
  17. package/dist/ingest.js +87 -0
  18. package/dist/ingestPolicy.js +1 -0
  19. package/dist/metadataError.js +19 -0
  20. package/dist/objectAbandon.js +16 -0
  21. package/dist/objectLifecycle.js +243 -0
  22. package/dist/objectMetadata.js +308 -0
  23. package/dist/objectWriter.js +87 -0
  24. package/dist/pathDurability.js +16 -0
  25. package/dist/physicalReferences.js +54 -0
  26. package/dist/providers.js +638 -0
  27. package/dist/referenceCatalogue.js +31 -0
  28. package/dist/renditionProof.js +82 -0
  29. package/dist/retainedCapture.js +391 -0
  30. package/dist/retainedObjects.js +190 -0
  31. package/dist/rpc.d.ts +3 -15
  32. package/dist/rpc.js +3 -1
  33. package/dist/scanners.js +46 -0
  34. package/dist/server.d.ts +153 -0
  35. package/dist/server.js +4 -0
  36. package/dist/service.js +1418 -0
  37. package/dist/sourceIdentity.js +14 -0
  38. package/dist/sourcePin.js +35 -0
  39. package/dist/storageNamespaces.js +80 -0
  40. package/dist/storageNumbers.js +13 -0
  41. package/dist/storageObjectNamespaces.js +243 -0
  42. package/dist/storageReferenceInstances.js +52 -0
  43. package/dist/storageRequest.js +10 -0
  44. package/dist/storageRouting.js +46 -0
  45. package/dist/streamBridge.js +33 -0
  46. package/dist/table.js +54 -0
  47. package/dist/transcodeVideo.js +91 -0
  48. package/dist/transform.js +94 -0
  49. package/dist/transformCache.js +31 -0
  50. package/dist/types.d.ts +116 -134
  51. package/dist/types.js +14 -14
  52. package/package.json +17 -6
@@ -0,0 +1,87 @@
1
+ import { StorageError as e, StorageRejected as t } from "./types.js";
2
+ import { putObjectStream as n } from "./streamBridge.js";
3
+ import { storageMetadataError as r, storageRejectedCause as i } from "./metadataError.js";
4
+ import { Effect as a, Stream as o } from "effect";
5
+ import { createHash as s } from "node:crypto";
6
+ //#region src/objectWriter.ts
7
+ var c = (c) => {
8
+ let l = (t) => a.gen(function* () {
9
+ (yield* c.provider.objectNamespace) !== (yield* a.tryPromise({
10
+ try: () => c.metadata.scopeFor(t),
11
+ catch: (e) => r(e, "metadata")
12
+ })).objectNamespace && (yield* a.fail(new e({
13
+ provider: "metadata",
14
+ message: "Storage metadata is bound to another physical object namespace",
15
+ transient: !1,
16
+ status: 409
17
+ })));
18
+ }), u = (t, n) => a.tryPromise({
19
+ try: n,
20
+ catch: (n) => {
21
+ let a = i(n);
22
+ if (a !== void 0) return a;
23
+ let o = r(n, "metadata"), s = new e({
24
+ provider: "metadata",
25
+ message: `Storage ${t} was not confirmed: ${o.message}; retain the operation identity for recovery`,
26
+ transient: o.transient,
27
+ ...o.status === void 0 ? {} : { status: o.status }
28
+ });
29
+ return Object.defineProperty(s, "cause", {
30
+ value: n,
31
+ configurable: !0
32
+ }), s;
33
+ }
34
+ });
35
+ return {
36
+ put: (e) => a.gen(function* () {
37
+ if (e.bytes.byteLength !== e.ref.size || s("sha256").update(e.bytes).digest("hex") !== e.identity.checksum) return yield* a.fail(new t({
38
+ reason: "operation-content-mismatch",
39
+ detail: "Storage operation bytes do not match their reserved identity"
40
+ }));
41
+ yield* l(e.identity);
42
+ let n = yield* u("put reservation", () => c.metadata.reserve(e.identity, e.ref, e.quota, e.claim)), r = n.outcome;
43
+ return n.ready ? {
44
+ ref: n.ref,
45
+ outcome: r
46
+ } : (yield* c.provider.put(n.ref.key, e.bytes, {
47
+ contentType: n.ref.contentType,
48
+ public: n.ref.visibility === "public"
49
+ }), {
50
+ ref: yield* u("put confirmation", () => c.metadata.confirm(e.identity, e.claim)),
51
+ outcome: r
52
+ });
53
+ }),
54
+ putStream: (t) => a.gen(function* () {
55
+ let r = yield* u("put reservation", () => c.metadata.reserve(t.identity, t.ref, t.quota, t.claim)), i = r.outcome;
56
+ if (r.ready) return {
57
+ ref: r.ref,
58
+ outcome: i
59
+ };
60
+ let l = () => new e({
61
+ provider: "integrity",
62
+ message: "Storage operation stream does not match its reserved checksum and size",
63
+ transient: !1,
64
+ status: 409
65
+ }), d = s("sha256"), f = 0, p = !1, m = t.stream.pipe(o.mapEffect((e) => a.suspend(() => {
66
+ if (e.byteLength > r.ref.size - f) return a.fail(l());
67
+ let t = Uint8Array.from(e);
68
+ return f += t.byteLength, d.update(t), a.succeed(t);
69
+ })), o.concat(o.fromEffect(a.suspend(() => f !== r.ref.size || d.digest("hex") !== t.identity.checksum ? a.fail(l()) : (p = !0, a.succeed(/* @__PURE__ */ new Uint8Array())))))), h = yield* n(c.provider, r.ref.key, m, {
70
+ contentType: r.ref.contentType,
71
+ public: r.ref.visibility === "public",
72
+ totalSize: r.ref.size
73
+ });
74
+ return !p || h.size !== r.ref.size ? yield* a.fail(l()) : {
75
+ ref: yield* u("put confirmation", () => c.metadata.confirm(t.identity, t.claim)),
76
+ outcome: i
77
+ };
78
+ }),
79
+ delete: (e, t, n) => a.gen(function* () {
80
+ yield* l({ refId: e });
81
+ let r = yield* u("delete acceptance", () => c.metadata.beginDelete(e, t, n));
82
+ "operation" in r && (r.operation.deleteKey !== null && (yield* c.provider.delete(r.operation.deleteKey)), yield* u("delete confirmation", () => c.metadata.confirmDelete(r.identity)));
83
+ })
84
+ };
85
+ };
86
+ //#endregion
87
+ export { c as makeStorageObjectWriter };
@@ -0,0 +1,16 @@
1
+ import { statSync as e } from "node:fs";
2
+ //#region src/pathDurability.ts
3
+ var t = (t) => {
4
+ try {
5
+ let n = e(t), r = e("/");
6
+ return typeof n.dev != "number" || typeof r.dev != "number" ? "unknown" : n.dev === r.dev ? "same-device-as-root" : "separate-mount";
7
+ } catch {
8
+ return "unknown";
9
+ }
10
+ }, n = (e) => {
11
+ if (t(e) === "same-device-as-root") return `the capture is going to ${e}, which is on the SAME filesystem as \`/\`.\n A mounted volume would be a separate one. If this process is a container, that means the capture
12
+ dies with it — which is the exact failure it exists for. On a development machine this is normal
13
+ and can be ignored.`;
14
+ };
15
+ //#endregion
16
+ export { n as durabilityNotice, t as pathDurability };
@@ -0,0 +1,54 @@
1
+ import { StorageError as e } from "@voltro/kv/storage";
2
+ import { Effect as t } from "effect";
3
+ //#region src/physicalReferences.ts
4
+ var n = (n, r, i, a) => {
5
+ let o = (o, s) => t.gen(function* () {
6
+ let c = (yield* r.listObjectReferences()).filter((e) => !s || e.visibility === "public"), l = yield* n.objectNamespace;
7
+ if (!s && r.hasObjectReservation !== void 0 && (yield* r.hasObjectReservation(l, o))) return !0;
8
+ if (c.length === 0) return !1;
9
+ let u, d = !1, f = !1;
10
+ for (let e of c) {
11
+ if (e.objectNamespace === l && e.key === o) return !0;
12
+ let t = yield* a === void 0 ? i({
13
+ destination: e.bucket,
14
+ tenantId: e.tenantId,
15
+ key: e.key
16
+ }) : a(e);
17
+ if (e.objectNamespace !== void 0 && (yield* t.objectNamespace) !== e.objectNamespace) {
18
+ f = !0;
19
+ continue;
20
+ }
21
+ if (n === t) {
22
+ if (o === e.key) return !0;
23
+ continue;
24
+ }
25
+ d ||= (u = n.objectLocation === void 0 ? void 0 : yield* n.objectLocation(o), !0);
26
+ let r = t.objectLocation === void 0 ? void 0 : yield* t.objectLocation(e.key);
27
+ if (u === void 0 || r === void 0) f = !0;
28
+ else if (u.namespace === r.namespace && u.key === r.key) return !0;
29
+ }
30
+ return f ? yield* t.fail(new e({
31
+ provider: "storage",
32
+ message: "Physical object ownership cannot be established for every storage destination",
33
+ transient: !1
34
+ })) : !1;
35
+ }), s = (e, n) => n === !0 ? t.succeed(!0) : o(e, !0);
36
+ return {
37
+ ...n,
38
+ delete: (e) => o(e, !1).pipe(t.flatMap((r) => r ? n.setObjectPublic === void 0 ? t.void : o(e, !0).pipe(t.flatMap((t) => n.setObjectPublic(e, t))) : n.delete(e))),
39
+ ...n.setObjectPublic === void 0 ? {} : {
40
+ setObjectPublic: (e, r) => s(e, r).pipe(t.flatMap((t) => n.setObjectPublic(e, t))),
41
+ put: (e, r, i) => s(e, i.public).pipe(t.flatMap((t) => n.put(e, r, {
42
+ ...i,
43
+ public: t
44
+ }))),
45
+ ...n.putStream === void 0 ? {} : { putStream: (e, r, i) => s(e, i.public).pipe(t.flatMap((t) => n.putStream(e, r, {
46
+ ...i,
47
+ public: t
48
+ }))) },
49
+ ...n.createMultipartUpload === void 0 ? {} : { createMultipartUpload: (e, r, i) => s(e, i?.public).pipe(t.flatMap((t) => n.createMultipartUpload(e, r, { public: t }))) }
50
+ }
51
+ };
52
+ };
53
+ //#endregion
54
+ export { n as protectStorageReferences };