@voltro/plugin-storage 0.86.0 → 0.88.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 +5484 -0
  2. package/README.md +27 -0
  3. package/THIRD-PARTY-NOTICES.md +2503 -690
  4. package/dist/access.js +26 -27
  5. package/dist/assetRef.js +1 -2
  6. package/dist/avatar.js +1 -2
  7. package/dist/byteSecurity.d.ts +3 -0
  8. package/dist/byteSecurity.js +6 -0
  9. package/dist/connection.js +98 -0
  10. package/dist/constraints.js +1 -2
  11. package/dist/custody.js +131 -0
  12. package/dist/derivatives.js +1 -2
  13. package/dist/env.js +8 -3
  14. package/dist/grant.js +90 -71
  15. package/dist/index.d.ts +453 -215
  16. package/dist/index.js +709 -537
  17. package/dist/ingest.js +7 -2
  18. package/dist/ingestPolicy.js +1 -1
  19. package/dist/metadataError.js +8 -9
  20. package/dist/objectAbandon.js +15 -0
  21. package/dist/objectLifecycle.js +135 -102
  22. package/dist/objectMetadata.js +253 -96
  23. package/dist/objectWriter.js +51 -23
  24. package/dist/pathDurability.js +1 -2
  25. package/dist/physicalReferences.js +53 -0
  26. package/dist/providers.js +451 -307
  27. package/dist/referenceCatalogue.js +1 -2
  28. package/dist/renditionProof.js +81 -0
  29. package/dist/retainedCapture.js +390 -0
  30. package/dist/retainedObjects.js +189 -0
  31. package/dist/rpc.d.ts +1 -15
  32. package/dist/rpc.js +1 -2
  33. package/dist/scanners.js +1 -2
  34. package/dist/server.d.ts +153 -0
  35. package/dist/server.js +4 -0
  36. package/dist/service.js +879 -546
  37. package/dist/sourceIdentity.js +13 -0
  38. package/dist/sourcePin.js +34 -0
  39. package/dist/storageNamespaces.js +52 -29
  40. package/dist/storageNumbers.js +1 -2
  41. package/dist/storageObjectNamespaces.js +170 -122
  42. package/dist/storageReferenceInstances.js +1 -2
  43. package/dist/storageRequest.js +9 -0
  44. package/dist/storageRouting.js +45 -0
  45. package/dist/streamBridge.js +5 -3
  46. package/dist/table.js +2 -2
  47. package/dist/transcodeVideo.js +85 -48
  48. package/dist/transform.js +30 -27
  49. package/dist/transformCache.js +1 -2
  50. package/dist/types.d.ts +115 -137
  51. package/dist/types.js +15 -16
  52. package/package.json +22 -11
package/dist/table.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { bigint as e, bytes as t, id as n, integer as r, json as i, table as a, text as o, timestamp as s } from "@voltro/database";
2
- //#region src/table.ts
2
+ // src/table.ts
3
3
  var c = "_voltro_storage_refs", l = "_voltro_storage_grants", u = "_voltro_storage_blobs", d = "_voltro_storage_usage", f = a(c, {
4
4
  id: n({ prefix: "file" }),
5
5
  storageInstance: o().nullable(),
@@ -24,6 +24,7 @@ var c = "_voltro_storage_refs", l = "_voltro_storage_grants", u = "_voltro_stora
24
24
  caption: o().nullable(),
25
25
  derivedFrom: o().nullable(),
26
26
  kind: o().nullable(),
27
+ renditionProof: i().nullable(),
27
28
  createdAt: s()
28
29
  }).index(["storageInstance"]).index(["objectNamespace"]).index(["key"]).index(["tenantId"]).index(["ownerId"]).index(["folder"]).index(["derivedFrom"]), p = a(l, {
29
30
  id: n({ prefix: "sgrant" }),
@@ -49,5 +50,4 @@ var c = "_voltro_storage_refs", l = "_voltro_storage_grants", u = "_voltro_stora
49
50
  contentType: o(),
50
51
  size: e()
51
52
  }).index(["key"]);
52
- //#endregion
53
53
  export { u as STORAGE_BLOBS_TABLE, l as STORAGE_GRANTS_TABLE, c as STORAGE_REFS_TABLE, d as STORAGE_USAGE_TABLE, h as _voltroStorageBlobsTable, p as _voltroStorageGrantsTable, f as _voltroStorageRefsTable, m as _voltroStorageUsageTable };
@@ -1,53 +1,90 @@
1
- import { join as e } from "node:path";
2
- import { spawn as t } from "node:child_process";
3
- import { mkdtemp as n, readFile as r, rm as i, writeFile as a } from "node:fs/promises";
4
- import { tmpdir as o } from "node:os";
5
- //#region src/transcodeVideo.ts
6
- var s = (e, n, r) => new Promise((i, a) => {
7
- let o = t(e, [...n], { stdio: [
8
- "ignore",
1
+ import { createHash as e } from "node:crypto";
2
+ import { join as t } from "node:path";
3
+ import { canonicalJson as n } from "@voltro/protocol";
4
+ import { mkdtemp as r, readFile as i, rm as a, writeFile as o } from "node:fs/promises";
5
+ import { tmpdir as s } from "node:os";
6
+ import { spawn as c } from "node:child_process";
7
+ // src/transcodeVideo.ts
8
+ var l = (e, t, n) => new Promise((r, i) => {
9
+ let a = c(e, [...t], { stdio: [
9
10
  "ignore",
11
+ "pipe",
10
12
  "pipe"
11
- ] }), s = "", c = setTimeout(() => {
12
- o.kill("SIGKILL"), a(/* @__PURE__ */ Error("ffmpeg timed out"));
13
- }, r);
14
- o.stderr?.on("data", (e) => {
15
- s += String(e);
16
- }), o.on("error", (e) => {
17
- clearTimeout(c), a(e);
18
- }), o.on("close", (e) => {
19
- clearTimeout(c), e === 0 ? i() : a(/* @__PURE__ */ Error(`ffmpeg exited ${String(e)}: ${s.slice(-400)}`));
13
+ ] }), o = "", s = "", l, u = (e) => {
14
+ l === void 0 && (l = Error(e), a.kill("SIGKILL"));
15
+ }, d = setTimeout(() => u("ffmpeg timed out"), n);
16
+ a.stdout?.on("data", (e) => {
17
+ if (o.length + e.length > 65536) return u("ffmpeg output exceeds its metadata bound");
18
+ o += String(e);
19
+ }), a.stderr?.on("data", (e) => {
20
+ s = (s + String(e)).slice(-400);
21
+ }), a.on("error", (e) => {
22
+ clearTimeout(d), i(e);
23
+ }), a.on("close", (e) => {
24
+ clearTimeout(d), l === void 0 ? e === 0 ? r(o) : i(/* @__PURE__ */ Error(`ffmpeg exited ${String(e)}: ${s}`)) : i(l);
20
25
  });
21
- }), c = (t) => async ({ bytes: c }) => {
22
- let l = t.ffmpegPath ?? "ffmpeg", u = t.timeoutMs ?? 3e5, d = await n(e(o(), "voltro-tc-")), f = e(d, "in"), p = [];
23
- try {
24
- await a(f, c);
25
- for (let n of t.renditions) {
26
- let t = e(d, `out.${n.ext}`);
27
- try {
28
- await s(l, [
29
- "-y",
30
- "-i",
31
- f,
32
- ...n.args,
33
- t
34
- ], u);
35
- let e = await r(t);
36
- p.push({
37
- bytes: new Uint8Array(e),
38
- contentType: n.contentType,
39
- kind: n.kind,
40
- ...n.label === void 0 ? {} : { label: n.label }
41
- }), await i(t, { force: !0 });
42
- } catch {}
26
+ }), u = (t) => e("sha256").update(t).digest("hex"), d = (e) => {
27
+ let t = e.replace(/\r\n/g, "\n").trim(), n = t.split("\n")[0] ?? "";
28
+ if (!n.startsWith("ffmpeg version ") || n.length > 512) throw Error("ffmpeg version metadata unavailable");
29
+ return {
30
+ name: "ffmpeg",
31
+ version: n.slice(15),
32
+ digest: u(t)
33
+ };
34
+ }, f = (e) => {
35
+ let c = e.ffmpegPath ?? "ffmpeg", f = e.timeoutMs ?? 3e5, p = e.renditions.map((e) => ({
36
+ ...e,
37
+ args: [...e.args]
38
+ }));
39
+ return async ({ bytes: e }) => {
40
+ let m = await r(t(s(), "voltro-tc-")), h = t(m, "in"), g = [];
41
+ try {
42
+ await o(h, e);
43
+ for (let e of p) {
44
+ let r = t(m, `out.${e.ext}`);
45
+ try {
46
+ let t = performance.now() + f, o = (e) => {
47
+ let n = Math.ceil(t - performance.now());
48
+ if (n <= 0) throw Error("ffmpeg rendition timed out");
49
+ return l(c, e, n);
50
+ }, s = d(await o(["-version"]));
51
+ await o([
52
+ "-y",
53
+ "-i",
54
+ h,
55
+ ...e.args,
56
+ r
57
+ ]);
58
+ let p = d(await o(["-version"]));
59
+ if (s.digest !== p.digest) throw Error("ffmpeg build changed during rendition");
60
+ let m = await i(r);
61
+ g.push({
62
+ bytes: new Uint8Array(m),
63
+ contentType: e.contentType,
64
+ kind: e.kind,
65
+ derivation: {
66
+ engine: s,
67
+ recipe: {
68
+ format: "ffmpeg-cli/v1",
69
+ digest: u(n({
70
+ kind: e.kind,
71
+ contentType: e.contentType,
72
+ ext: e.ext,
73
+ args: e.args
74
+ }))
75
+ }
76
+ },
77
+ ...e.label === void 0 ? {} : { label: e.label }
78
+ }), await a(r, { force: !0 });
79
+ } catch {}
80
+ }
81
+ } finally {
82
+ await a(m, {
83
+ recursive: !0,
84
+ force: !0
85
+ }).catch(() => void 0);
43
86
  }
44
- } finally {
45
- await i(d, {
46
- recursive: !0,
47
- force: !0
48
- }).catch(() => void 0);
49
- }
50
- return p;
87
+ return g;
88
+ };
51
89
  };
52
- //#endregion
53
- export { c as ffmpegTranscoder };
90
+ export { f as ffmpegTranscoder };
package/dist/transform.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createTransformCache as e } from "./transformCache.js";
2
- //#region src/transform.ts
3
- var t = (e, t, n, r, i, a) => {
2
+ import { createHash as t } from "node:crypto";
3
+ // src/transform.ts
4
+ var n = (e, t, n, r, i, a) => {
4
5
  let o = n / r, s = Math.min(e, Math.round(t * o)), c = Math.min(t, Math.round(s / o)), l = (e, t) => Math.max(0, Math.min(t, e));
5
6
  return {
6
7
  left: l(Math.round(i * e - s / 2), e - s),
@@ -8,13 +9,13 @@ var t = (e, t, n, r, i, a) => {
8
9
  width: s,
9
10
  height: c
10
11
  };
11
- }, n = {
12
+ }, r = {
12
13
  webp: "image/webp",
13
14
  avif: "image/avif",
14
15
  jpeg: "image/jpeg",
15
16
  jpg: "image/jpeg",
16
17
  png: "image/png"
17
- }, r = (e) => {
18
+ }, i = (e) => {
18
19
  if (!e) return null;
19
20
  let t = new URLSearchParams(e), n = (e) => {
20
21
  let n = t.get(e);
@@ -33,28 +34,28 @@ var t = (e, t, n, r, i, a) => {
33
34
  ...s ? { fit: s } : {},
34
35
  ...l ? { fp: l } : {}
35
36
  };
36
- }, i = (e) => e.startsWith("image/") && !e.includes("svg"), a, o = async () => (a ??= import("sharp").then((e) => e.default ?? e, () => null), a), s = async (e, t) => t ? null : i(e) ? await o() === null ? "no-sharp" : "failed" : "not-an-image", c = async (e, r, a) => {
37
- if (!i(r)) return null;
38
- let s = await o();
39
- if (!s) return null;
37
+ }, a = (e) => e.startsWith("image/") && !e.includes("svg"), o, s = async () => (o ??= import("sharp").then((e) => e.default ?? e, () => null), o), c = async (e, t) => t ? null : a(e) ? await s() === null ? "no-sharp" : "failed" : "not-an-image", l = async (e, t, i) => {
38
+ if (!a(t)) return null;
39
+ let o = await s();
40
+ if (!o) return null;
40
41
  try {
41
- let i = s(Buffer.from(e), { failOn: "none" }), o = a.fit ?? "cover";
42
- if (a.fp !== void 0 && a.w !== void 0 && a.h !== void 0 && o === "cover") {
43
- let e = await i.metadata();
44
- e.width !== void 0 && e.height !== void 0 && (i = i.extract(t(e.width, e.height, a.w, a.h, a.fp.x, a.fp.y)));
42
+ let a = o(Buffer.from(e), { failOn: "none" }), s = i.fit ?? "cover";
43
+ if (i.fp !== void 0 && i.w !== void 0 && i.h !== void 0 && s === "cover") {
44
+ let e = await a.metadata();
45
+ e.width !== void 0 && e.height !== void 0 && (a = a.extract(n(e.width, e.height, i.w, i.h, i.fp.x, i.fp.y)));
45
46
  }
46
- (a.w !== void 0 || a.h !== void 0) && (i = i.resize({
47
- ...a.w === void 0 ? {} : { width: a.w },
48
- ...a.h === void 0 ? {} : { height: a.h },
49
- fit: a.fit ?? "cover",
47
+ (i.w !== void 0 || i.h !== void 0) && (a = a.resize({
48
+ ...i.w === void 0 ? {} : { width: i.w },
49
+ ...i.h === void 0 ? {} : { height: i.h },
50
+ fit: i.fit ?? "cover",
50
51
  withoutEnlargement: !0
51
52
  }));
52
- let c = a.format && n[a.format] ? a.format : void 0, l = r;
53
+ let c = i.format && r[i.format] ? i.format : void 0, l = t;
53
54
  if (c) {
54
55
  let e = c === "jpg" ? "jpeg" : c;
55
- i = i.toFormat(e, a.q === void 0 ? {} : { quality: a.q }), l = n[c];
56
- } else a.q !== void 0 && (r === "image/jpeg" || r === "image/webp") && (i = i.toFormat(r === "image/webp" ? "webp" : "jpeg", { quality: a.q }));
57
- let u = await i.toBuffer();
56
+ a = a.toFormat(e, i.q === void 0 ? {} : { quality: i.q }), l = r[c];
57
+ } else i.q !== void 0 && (t === "image/jpeg" || t === "image/webp") && (a = a.toFormat(t === "image/webp" ? "webp" : "jpeg", { quality: i.q }));
58
+ let u = await a.toBuffer();
58
59
  return {
59
60
  bytes: new Uint8Array(u),
60
61
  contentType: l
@@ -62,9 +63,9 @@ var t = (e, t, n, r, i, a) => {
62
63
  } catch {
63
64
  return null;
64
65
  }
65
- }, l = async (e, t, n) => {
66
- if (!i(t) || n.rotate === void 0 && n.flip !== !0 && n.flop !== !0 && n.grayscale !== !0 && n.crop === void 0) return null;
67
- let r = await o();
66
+ }, u = async (e, t, n) => {
67
+ if (!a(t) || n.rotate === void 0 && n.flip !== !0 && n.flop !== !0 && n.grayscale !== !0 && n.crop === void 0) return null;
68
+ let r = await s();
68
69
  if (!r) return null;
69
70
  try {
70
71
  let i = r(Buffer.from(e), { failOn: "none" });
@@ -75,7 +76,7 @@ var t = (e, t, n, r, i, a) => {
75
76
  } catch {
76
77
  return null;
77
78
  }
78
- }, u = e(), d = (e, t, n) => JSON.stringify([
79
+ }, d = (e, t, n) => JSON.stringify([
79
80
  e,
80
81
  t,
81
82
  n.w,
@@ -85,6 +86,8 @@ var t = (e, t, n, r, i, a) => {
85
86
  n.fit,
86
87
  n.fp?.x,
87
88
  n.fp?.y
88
- ]), f = async (e, t, n, r) => u.getOrCreate(d(e, n, r), () => c(t, n, r));
89
- //#endregion
90
- export { l as editImage, t as focalRegion, i as isTransformable, o as loadSharp, r as parseTransformParams, f as transformCached, s as transformFallbackReason, c as transformImage, d as transformKey };
89
+ ]), f = () => {
90
+ let n = e();
91
+ return async (e, r, i, a) => n.getOrCreate(d(JSON.stringify([e, t("sha256").update(r).digest("hex")]), i, a), () => l(r, i, a));
92
+ }, p = f();
93
+ export { f as createTransformCache, u as editImage, n as focalRegion, a as isTransformable, s as loadSharp, i as parseTransformParams, p as transformCached, c as transformFallbackReason, l as transformImage, d as transformKey };
@@ -1,4 +1,4 @@
1
- //#region src/transformCache.ts
1
+ // src/transformCache.ts
2
2
  var e = (e = {
3
3
  entries: 200,
4
4
  bytes: 67108864,
@@ -27,5 +27,4 @@ var e = (e = {
27
27
  return n.set(i, c), c;
28
28
  } };
29
29
  };
30
- //#endregion
31
30
  export { e as createTransformCache };