@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.
- package/CHANGELOG.md +5484 -0
- package/README.md +27 -0
- package/THIRD-PARTY-NOTICES.md +2503 -690
- package/dist/access.js +26 -27
- package/dist/assetRef.js +1 -2
- package/dist/avatar.js +1 -2
- package/dist/byteSecurity.d.ts +3 -0
- package/dist/byteSecurity.js +6 -0
- package/dist/connection.js +98 -0
- package/dist/constraints.js +1 -2
- package/dist/custody.js +131 -0
- package/dist/derivatives.js +1 -2
- package/dist/env.js +8 -3
- package/dist/grant.js +90 -71
- package/dist/index.d.ts +453 -215
- package/dist/index.js +709 -537
- package/dist/ingest.js +7 -2
- package/dist/ingestPolicy.js +1 -1
- package/dist/metadataError.js +8 -9
- package/dist/objectAbandon.js +15 -0
- package/dist/objectLifecycle.js +135 -102
- package/dist/objectMetadata.js +253 -96
- package/dist/objectWriter.js +51 -23
- package/dist/pathDurability.js +1 -2
- package/dist/physicalReferences.js +53 -0
- package/dist/providers.js +451 -307
- package/dist/referenceCatalogue.js +1 -2
- package/dist/renditionProof.js +81 -0
- package/dist/retainedCapture.js +390 -0
- package/dist/retainedObjects.js +189 -0
- package/dist/rpc.d.ts +1 -15
- package/dist/rpc.js +1 -2
- package/dist/scanners.js +1 -2
- package/dist/server.d.ts +153 -0
- package/dist/server.js +4 -0
- package/dist/service.js +879 -546
- package/dist/sourceIdentity.js +13 -0
- package/dist/sourcePin.js +34 -0
- package/dist/storageNamespaces.js +52 -29
- package/dist/storageNumbers.js +1 -2
- package/dist/storageObjectNamespaces.js +170 -122
- package/dist/storageReferenceInstances.js +1 -2
- package/dist/storageRequest.js +9 -0
- package/dist/storageRouting.js +45 -0
- package/dist/streamBridge.js +5 -3
- package/dist/table.js +2 -2
- package/dist/transcodeVideo.js +85 -48
- package/dist/transform.js +30 -27
- package/dist/transformCache.js +1 -2
- package/dist/types.d.ts +115 -137
- package/dist/types.js +15 -16
- 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
|
-
|
|
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 };
|
package/dist/transcodeVideo.js
CHANGED
|
@@ -1,53 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 = "",
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
}),
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
recursive: !0,
|
|
47
|
-
force: !0
|
|
48
|
-
}).catch(() => void 0);
|
|
49
|
-
}
|
|
50
|
-
return p;
|
|
87
|
+
return g;
|
|
88
|
+
};
|
|
51
89
|
};
|
|
52
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
37
|
-
if (!
|
|
38
|
-
let
|
|
39
|
-
if (!
|
|
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
|
|
42
|
-
if (
|
|
43
|
-
let e = await
|
|
44
|
-
e.width !== void 0 && e.height !== void 0 && (
|
|
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
|
-
(
|
|
47
|
-
...
|
|
48
|
-
...
|
|
49
|
-
fit:
|
|
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 =
|
|
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
|
-
|
|
56
|
-
} else
|
|
57
|
-
let u = await
|
|
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
|
-
},
|
|
66
|
-
if (!
|
|
67
|
-
let r = await
|
|
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
|
-
},
|
|
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 =
|
|
89
|
-
|
|
90
|
-
|
|
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 };
|
package/dist/transformCache.js
CHANGED