@voltro/plugin-storage 0.75.0 → 0.77.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 +459 -0
- package/THIRD-PARTY-NOTICES.md +19 -19
- package/dist/index.d.ts +12 -6
- package/dist/index.js +891 -838
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,86 +1,87 @@
|
|
|
1
1
|
import { StorageAccessDenied as e, StorageError as t, StorageRejected as n, StorageScanRejected as r, StorageService as i } from "./types.js";
|
|
2
|
-
import { abortMultipartUploadDescriptor as a, beginMultipartUploadDescriptor as o, beginResumableUploadDescriptor as s, completeMultipartUploadDescriptor as c, finalizeUploadDescriptor as l, ingestUrlDescriptor as u, listGrantsDescriptor as d, listRefsDescriptor as f, mintPresignedUploadDescriptor as p, mintUploadTicketDescriptor as m, mintUploadUrlDescriptor as ee, mintUrlDescriptor as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
2
|
+
import { abortMultipartUploadDescriptor as a, beginMultipartUploadDescriptor as o, beginResumableUploadDescriptor as s, completeMultipartUploadDescriptor as c, finalizeUploadDescriptor as l, ingestUrlDescriptor as u, listGrantsDescriptor as d, listRefsDescriptor as f, mintPresignedUploadDescriptor as p, mintUploadTicketDescriptor as m, mintUploadUrlDescriptor as ee, mintUrlDescriptor as te, revokeDescriptor as h, shareDescriptor as ne, signMultipartPartDescriptor as g, storageRpcClientImports as re, uploadDescriptor as ie } from "./rpc.js";
|
|
3
|
+
import { processIdentity as _ } from "@voltro/protocol/identity";
|
|
4
|
+
import { Chunk as v, Effect as y, Exit as b, Layer as x, Schedule as S, Schema as C, Stream as w } from "effect";
|
|
5
|
+
import { definePlugin as ae, pluginInstanceName as oe } from "@voltro/protocol";
|
|
6
|
+
import { readCookie as se, resolveSessionSecret as ce, verifySession as le } from "@voltro/protocol/session";
|
|
7
|
+
import { and as T, bytes as ue, contains as E, eq as D, generateId as O, id as de, integer as k, json as A, mixin as j, neq as M, or as fe, reference as pe, table as N, text as P, timestamp as me } from "@voltro/database";
|
|
8
|
+
import { pluginEnv as F } from "@voltro/env";
|
|
9
|
+
import { createHash as he, createHmac as I, randomBytes as L, randomUUID as ge, scryptSync as _e, timingSafeEqual as R } from "node:crypto";
|
|
10
|
+
import { spawn as ve } from "node:child_process";
|
|
11
|
+
import { mkdtemp as ye, readFile as be, rm as xe, writeFile as Se } from "node:fs/promises";
|
|
12
|
+
import { tmpdir as Ce } from "node:os";
|
|
13
|
+
import { join as z } from "node:path";
|
|
14
|
+
import { statSync as B } from "node:fs";
|
|
14
15
|
//#region src/streamBridge.ts
|
|
15
|
-
var
|
|
16
|
+
var we = 1 << 20, Te = (e, n, r = !1) => new t({
|
|
16
17
|
provider: e,
|
|
17
18
|
message: n,
|
|
18
19
|
transient: r
|
|
19
|
-
}),
|
|
20
|
+
}), Ee = (e) => {
|
|
20
21
|
let t = 0;
|
|
21
22
|
for (let n of e) t += n.byteLength;
|
|
22
23
|
let n = new Uint8Array(t), r = 0;
|
|
23
24
|
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
24
25
|
return n;
|
|
25
|
-
},
|
|
26
|
+
}, De = (e, t = we) => {
|
|
26
27
|
let n = [];
|
|
27
28
|
for (let r = 0; r < e.byteLength; r += t) n.push(e.subarray(r, Math.min(r + t, e.byteLength)));
|
|
28
|
-
return
|
|
29
|
-
},
|
|
29
|
+
return w.fromIterable(n);
|
|
30
|
+
}, Oe = (e) => e.pipe(w.runCollect, y.map((e) => Ee(v.toReadonlyArray(e)))), ke = (e, t) => w.suspend(() => w.fromAsyncIterable(t(), (t) => Te(e, `read stream failed: ${String(t?.message ?? t)}`, !0))).pipe(w.map((e) => e instanceof Uint8Array ? e : new Uint8Array(e))), Ae = async (e) => {
|
|
30
31
|
let { Readable: t } = await import("node:stream");
|
|
31
|
-
return t.fromWeb(
|
|
32
|
-
},
|
|
33
|
-
stream:
|
|
32
|
+
return t.fromWeb(w.toReadableStream(e));
|
|
33
|
+
}, je = (e, t) => e.getStream ? e.getStream(t) : e.get(t).pipe(y.map((e) => ({
|
|
34
|
+
stream: De(e.bytes),
|
|
34
35
|
contentType: e.contentType,
|
|
35
36
|
size: e.bytes.byteLength
|
|
36
|
-
}))),
|
|
37
|
+
}))), Me = (e, t, n, r) => e.putStream ? e.putStream(t, n, r) : Oe(n).pipe(y.flatMap((n) => e.put(t, n, {
|
|
37
38
|
contentType: r.contentType,
|
|
38
39
|
...r.public === void 0 ? {} : { public: r.public }
|
|
39
|
-
}))),
|
|
40
|
-
id:
|
|
41
|
-
tenantId:
|
|
42
|
-
ownerId:
|
|
43
|
-
bucket:
|
|
44
|
-
key:
|
|
45
|
-
contentType:
|
|
46
|
-
size:
|
|
47
|
-
checksum:
|
|
48
|
-
visibility:
|
|
49
|
-
accessPolicy:
|
|
50
|
-
passwordHash:
|
|
51
|
-
width:
|
|
52
|
-
height:
|
|
53
|
-
duration:
|
|
54
|
-
placeholder:
|
|
55
|
-
folder:
|
|
56
|
-
tags:
|
|
57
|
-
alt:
|
|
58
|
-
caption:
|
|
59
|
-
derivedFrom:
|
|
60
|
-
kind:
|
|
61
|
-
createdAt:
|
|
62
|
-
}).index(["key"]).index(["tenantId"]).index(["ownerId"]).index(["folder"]).index(["derivedFrom"]),
|
|
63
|
-
id:
|
|
64
|
-
refId:
|
|
65
|
-
principalType:
|
|
66
|
-
principalId:
|
|
67
|
-
permission:
|
|
68
|
-
createdAt:
|
|
69
|
-
expiresAt:
|
|
70
|
-
createdBy:
|
|
71
|
-
}).index(["refId"]).index(["principalId"]),
|
|
72
|
-
id:
|
|
73
|
-
tenantId:
|
|
74
|
-
bytes:
|
|
75
|
-
count:
|
|
76
|
-
updatedAt:
|
|
77
|
-
}).unique("byStorageUsageTenant", ["tenantId"]),
|
|
78
|
-
id:
|
|
79
|
-
key:
|
|
80
|
-
data:
|
|
81
|
-
contentType:
|
|
82
|
-
size:
|
|
83
|
-
}).index(["key"]),
|
|
40
|
+
}))), V = "_voltro_storage_refs", H = "_voltro_storage_grants", U = "_voltro_storage_blobs", Ne = "_voltro_storage_usage", Pe = N(V, {
|
|
41
|
+
id: de({ prefix: "file" }),
|
|
42
|
+
tenantId: P().nullable(),
|
|
43
|
+
ownerId: P().nullable(),
|
|
44
|
+
bucket: P(),
|
|
45
|
+
key: P(),
|
|
46
|
+
contentType: P(),
|
|
47
|
+
size: k(),
|
|
48
|
+
checksum: P(),
|
|
49
|
+
visibility: P(),
|
|
50
|
+
accessPolicy: A().nullable(),
|
|
51
|
+
passwordHash: P().nullable(),
|
|
52
|
+
width: k().nullable(),
|
|
53
|
+
height: k().nullable(),
|
|
54
|
+
duration: k().nullable(),
|
|
55
|
+
placeholder: P().nullable(),
|
|
56
|
+
folder: P().nullable(),
|
|
57
|
+
tags: A().nullable(),
|
|
58
|
+
alt: P().nullable(),
|
|
59
|
+
caption: P().nullable(),
|
|
60
|
+
derivedFrom: P().nullable(),
|
|
61
|
+
kind: P().nullable(),
|
|
62
|
+
createdAt: me()
|
|
63
|
+
}).index(["key"]).index(["tenantId"]).index(["ownerId"]).index(["folder"]).index(["derivedFrom"]), Fe = N(H, {
|
|
64
|
+
id: de({ prefix: "sgrant" }),
|
|
65
|
+
refId: P(),
|
|
66
|
+
principalType: P(),
|
|
67
|
+
principalId: P(),
|
|
68
|
+
permission: P(),
|
|
69
|
+
createdAt: me(),
|
|
70
|
+
expiresAt: me().nullable(),
|
|
71
|
+
createdBy: P().nullable()
|
|
72
|
+
}).index(["refId"]).index(["principalId"]), Ie = N(Ne, {
|
|
73
|
+
id: de({ prefix: "susage" }),
|
|
74
|
+
tenantId: P().maxLength(191),
|
|
75
|
+
bytes: k().default(0),
|
|
76
|
+
count: k().default(0),
|
|
77
|
+
updatedAt: me()
|
|
78
|
+
}).unique("byStorageUsageTenant", ["tenantId"]), Le = N(U, {
|
|
79
|
+
id: de({ prefix: "blob" }),
|
|
80
|
+
key: P(),
|
|
81
|
+
data: ue(),
|
|
82
|
+
contentType: P(),
|
|
83
|
+
size: k()
|
|
84
|
+
}).index(["key"]), W = F([
|
|
84
85
|
{
|
|
85
86
|
name: "STORAGE_PROVIDER",
|
|
86
87
|
required: !1,
|
|
@@ -231,47 +232,47 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
231
232
|
secret: !1,
|
|
232
233
|
description: "clamd port for the optional clamav virus scanner. Default 3310."
|
|
233
234
|
}
|
|
234
|
-
]),
|
|
235
|
+
]), G = (e, n, r, i) => new t({
|
|
235
236
|
provider: e,
|
|
236
237
|
message: n,
|
|
237
238
|
transient: r,
|
|
238
239
|
...i === void 0 ? {} : { status: i }
|
|
239
|
-
}),
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
let t =
|
|
243
|
-
return
|
|
240
|
+
}), Re = (e) => e === void 0 || e === 408 || e === 429 || e >= 500, ze = /* @__PURE__ */ new Map(), Be = (e, t) => ze.get(e)?.get(t)?.bytes, Ve = (e) => {
|
|
241
|
+
ze.get(e)?.clear();
|
|
242
|
+
}, He = (e = "default") => {
|
|
243
|
+
let t = ze.get(e) ?? /* @__PURE__ */ new Map();
|
|
244
|
+
return ze.set(e, t), {
|
|
244
245
|
name: "memory",
|
|
245
246
|
presigns: !1,
|
|
246
|
-
put: (e, n, r) =>
|
|
247
|
+
put: (e, n, r) => y.sync(() => (t.set(e, {
|
|
247
248
|
bytes: n,
|
|
248
249
|
contentType: r.contentType
|
|
249
250
|
}), { size: n.byteLength })),
|
|
250
|
-
get: (e) =>
|
|
251
|
+
get: (e) => y.suspend(() => {
|
|
251
252
|
let n = t.get(e);
|
|
252
|
-
return n ?
|
|
253
|
+
return n ? y.succeed({
|
|
253
254
|
bytes: n.bytes,
|
|
254
255
|
contentType: n.contentType
|
|
255
|
-
}) :
|
|
256
|
+
}) : y.fail(G("memory", `no object at key '${e}'`, !1, 404));
|
|
256
257
|
}),
|
|
257
|
-
delete: (e) =>
|
|
258
|
+
delete: (e) => y.sync(() => {
|
|
258
259
|
t.delete(e);
|
|
259
260
|
}),
|
|
260
261
|
publicUrl: () => null,
|
|
261
|
-
getUrl: () =>
|
|
262
|
-
head: (e) =>
|
|
262
|
+
getUrl: () => y.succeed(""),
|
|
263
|
+
head: (e) => y.sync(() => {
|
|
263
264
|
let n = t.get(e);
|
|
264
265
|
return n ? { size: n.bytes.byteLength } : null;
|
|
265
266
|
})
|
|
266
267
|
};
|
|
267
|
-
},
|
|
268
|
+
}, Ue = (e) => {
|
|
268
269
|
let t = e.root, n = async (e) => {
|
|
269
270
|
let { join: n, resolve: r, sep: i } = await import("node:path"), a = r(t), o = r(a, e);
|
|
270
271
|
if (o !== a && !o.startsWith(a + i)) throw Error(`key '${e}' escapes the storage root`);
|
|
271
272
|
return n(o);
|
|
272
|
-
}, r = (e, t, n = !1) =>
|
|
273
|
+
}, r = (e, t, n = !1) => y.tryPromise({
|
|
273
274
|
try: e,
|
|
274
|
-
catch: (e) => e?.code === "ENOENT" ?
|
|
275
|
+
catch: (e) => e?.code === "ENOENT" ? G("filesystem", `no object at key '${t}'`, !1, 404) : G("filesystem", String(e?.message ?? e), n)
|
|
275
276
|
});
|
|
276
277
|
return {
|
|
277
278
|
root: t,
|
|
@@ -299,8 +300,8 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
299
300
|
await (await import("node:fs/promises")).rm(await n(e), { force: !0 });
|
|
300
301
|
}, e),
|
|
301
302
|
publicUrl: () => null,
|
|
302
|
-
getUrl: () =>
|
|
303
|
-
head: (e) =>
|
|
303
|
+
getUrl: () => y.succeed(""),
|
|
304
|
+
head: (e) => y.tryPromise({
|
|
304
305
|
try: async () => {
|
|
305
306
|
let t = await import("node:fs/promises");
|
|
306
307
|
try {
|
|
@@ -310,12 +311,12 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
310
311
|
throw e;
|
|
311
312
|
}
|
|
312
313
|
},
|
|
313
|
-
catch: (e) =>
|
|
314
|
+
catch: (e) => G("filesystem", String(e?.message ?? e), !1)
|
|
314
315
|
}),
|
|
315
316
|
getStream: (e) => r(async () => {
|
|
316
317
|
let t = await import("node:fs/promises"), { createReadStream: r } = await import("node:fs"), i = await n(e), a = await t.stat(i);
|
|
317
318
|
return {
|
|
318
|
-
stream:
|
|
319
|
+
stream: ke("filesystem", () => r(i)),
|
|
319
320
|
contentType: "application/octet-stream",
|
|
320
321
|
size: a.size
|
|
321
322
|
};
|
|
@@ -325,7 +326,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
325
326
|
await r.mkdir(i(c), { recursive: !0 });
|
|
326
327
|
let l = `${c}.tmp-${a()}`;
|
|
327
328
|
try {
|
|
328
|
-
await s(await
|
|
329
|
+
await s(await Ae(t), o(l));
|
|
329
330
|
let e = await r.stat(l);
|
|
330
331
|
return await r.rename(l, c), { size: e.size };
|
|
331
332
|
} catch (e) {
|
|
@@ -340,10 +341,10 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
340
341
|
end: i
|
|
341
342
|
});
|
|
342
343
|
s.on("data", (e) => o.push(e)), s.on("end", () => e()), s.on("error", n);
|
|
343
|
-
}),
|
|
344
|
+
}), Ee(o);
|
|
344
345
|
}, e)
|
|
345
346
|
};
|
|
346
|
-
},
|
|
347
|
+
}, We = (e) => {
|
|
347
348
|
let t = e.name ?? "s3", n = e.publicAcl ?? !0, r = null, i = () => r || (r = (async () => {
|
|
348
349
|
let t, n;
|
|
349
350
|
try {
|
|
@@ -364,11 +365,11 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
364
365
|
cmds: t,
|
|
365
366
|
presign: n.getSignedUrl
|
|
366
367
|
};
|
|
367
|
-
})(), r), a = (e) =>
|
|
368
|
+
})(), r), a = (e) => y.tryPromise({
|
|
368
369
|
try: e,
|
|
369
370
|
catch: (e) => {
|
|
370
371
|
let n = e?.$metadata?.httpStatusCode;
|
|
371
|
-
return
|
|
372
|
+
return G(t, String(e?.message ?? e), Re(n), n);
|
|
372
373
|
}
|
|
373
374
|
}), o = async (e) => {
|
|
374
375
|
let t = e;
|
|
@@ -464,7 +465,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
464
465
|
UploadId: n
|
|
465
466
|
}));
|
|
466
467
|
}),
|
|
467
|
-
head: (n) =>
|
|
468
|
+
head: (n) => y.tryPromise({
|
|
468
469
|
try: async () => {
|
|
469
470
|
let { client: t, cmds: r } = await i();
|
|
470
471
|
try {
|
|
@@ -483,7 +484,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
483
484
|
},
|
|
484
485
|
catch: (e) => {
|
|
485
486
|
let n = e?.$metadata?.httpStatusCode;
|
|
486
|
-
return
|
|
487
|
+
return G(t, String(e?.message ?? e), Re(n), n);
|
|
487
488
|
}
|
|
488
489
|
}),
|
|
489
490
|
getStream: (n) => a(async () => {
|
|
@@ -492,7 +493,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
492
493
|
Key: n
|
|
493
494
|
})), s = o.Body;
|
|
494
495
|
return {
|
|
495
|
-
stream:
|
|
496
|
+
stream: ke(t, () => s),
|
|
496
497
|
contentType: o.ContentType ?? "application/octet-stream",
|
|
497
498
|
...o.ContentLength === void 0 ? {} : { size: o.ContentLength }
|
|
498
499
|
};
|
|
@@ -504,7 +505,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
504
505
|
} catch (e) {
|
|
505
506
|
throw Error("s3/minio `putStream` requires the '@aws-sdk/lib-storage' optional dependency (multipart upload). Install it to enable streamed uploads.", { cause: e });
|
|
506
507
|
}
|
|
507
|
-
let l = await
|
|
508
|
+
let l = await Ae(r);
|
|
508
509
|
return await new c.Upload({
|
|
509
510
|
client: a,
|
|
510
511
|
params: {
|
|
@@ -528,15 +529,15 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
528
529
|
return o(c.Body);
|
|
529
530
|
})
|
|
530
531
|
};
|
|
531
|
-
},
|
|
532
|
+
}, Ge = (e) => e instanceof Uint8Array ? e : typeof e == "string" ? new Uint8Array(Buffer.from(e, "base64")) : new Uint8Array(e), Ke = () => {
|
|
532
533
|
let e = null, t = () => {
|
|
533
534
|
if (!e) throw Error("the 'database' storage provider isn't bound to a DataStore yet");
|
|
534
535
|
return e;
|
|
535
|
-
}, n = (e) =>
|
|
536
|
+
}, n = (e) => y.tryPromise({
|
|
536
537
|
try: e,
|
|
537
|
-
catch: (e) =>
|
|
538
|
-
}), r = async (e) => (await t().query({
|
|
539
|
-
table:
|
|
538
|
+
catch: (e) => G("database", String(e?.message ?? e), !0)
|
|
539
|
+
}), r = async (e, n) => (await t().query({
|
|
540
|
+
table: U,
|
|
540
541
|
predicate: {
|
|
541
542
|
column: "key",
|
|
542
543
|
op: "eq",
|
|
@@ -545,7 +546,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
545
546
|
order: [],
|
|
546
547
|
take: 1,
|
|
547
548
|
skip: void 0,
|
|
548
|
-
projection:
|
|
549
|
+
projection: n
|
|
549
550
|
}))[0];
|
|
550
551
|
return {
|
|
551
552
|
name: "database",
|
|
@@ -555,37 +556,37 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
555
556
|
},
|
|
556
557
|
put: (e, i, a) => n(async () => {
|
|
557
558
|
let n = await r(e);
|
|
558
|
-
return n ? await t().update(
|
|
559
|
+
return n ? await t().update(U, String(n.id), {
|
|
559
560
|
data: i,
|
|
560
561
|
contentType: a.contentType,
|
|
561
562
|
size: i.byteLength
|
|
562
|
-
}) : await t().insert(
|
|
563
|
-
id:
|
|
563
|
+
}) : await t().insert(U, {
|
|
564
|
+
id: O({
|
|
564
565
|
kind: "typeid",
|
|
565
566
|
prefix: "blob"
|
|
566
|
-
},
|
|
567
|
+
}, U),
|
|
567
568
|
key: e,
|
|
568
569
|
data: i,
|
|
569
570
|
contentType: a.contentType,
|
|
570
571
|
size: i.byteLength
|
|
571
572
|
}), { size: i.byteLength };
|
|
572
573
|
}),
|
|
573
|
-
get: (e) =>
|
|
574
|
-
bytes:
|
|
574
|
+
get: (e) => y.suspend(() => n(() => r(e)).pipe(y.flatMap((t) => t ? y.succeed({
|
|
575
|
+
bytes: Ge(t.data),
|
|
575
576
|
contentType: String(t.contentType)
|
|
576
|
-
}) :
|
|
577
|
+
}) : y.fail(G("database", `no object at key '${e}'`, !1, 404))))),
|
|
577
578
|
delete: (e) => n(async () => {
|
|
578
|
-
let n = await r(e);
|
|
579
|
-
n && await t().delete(
|
|
579
|
+
let n = await r(e, ["id"]);
|
|
580
|
+
n && await t().delete(U, String(n.id));
|
|
580
581
|
}),
|
|
581
582
|
publicUrl: () => null,
|
|
582
|
-
getUrl: () =>
|
|
583
|
+
getUrl: () => y.succeed(""),
|
|
583
584
|
head: (e) => n(async () => {
|
|
584
|
-
let t = await r(e);
|
|
585
|
+
let t = await r(e, ["size"]);
|
|
585
586
|
return t ? { size: Number(t.size) } : null;
|
|
586
587
|
})
|
|
587
588
|
};
|
|
588
|
-
},
|
|
589
|
+
}, qe = (e) => {
|
|
589
590
|
let t = null, n = () => t || (t = (async () => {
|
|
590
591
|
let t;
|
|
591
592
|
try {
|
|
@@ -593,17 +594,17 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
593
594
|
} catch (e) {
|
|
594
595
|
throw Error("the 'azure' storage provider requires the '@azure/storage-blob' optional dependency. Install it to enable it.", { cause: e });
|
|
595
596
|
}
|
|
596
|
-
let n =
|
|
597
|
+
let n = W.read("AZURE_STORAGE_ACCOUNT", e.accountName), r = W.read("AZURE_STORAGE_KEY", e.accountKey), i = n && r ? new t.StorageSharedKeyCredential(n, r) : null, a = W.read("AZURE_STORAGE_CONNECTION_STRING", e.connectionString);
|
|
597
598
|
return {
|
|
598
599
|
container: (a ? t.BlobServiceClient.fromConnectionString(a) : new t.BlobServiceClient(e.endpoint ?? `https://${n}.blob.core.windows.net`, i ?? void 0)).getContainerClient(e.container),
|
|
599
600
|
sdk: t,
|
|
600
601
|
cred: i
|
|
601
602
|
};
|
|
602
|
-
})(), t), r = (e) =>
|
|
603
|
+
})(), t), r = (e) => y.tryPromise({
|
|
603
604
|
try: e,
|
|
604
605
|
catch: (e) => {
|
|
605
606
|
let t = e?.statusCode;
|
|
606
|
-
return
|
|
607
|
+
return G("azure", String(e?.message ?? e), Re(t), t);
|
|
607
608
|
}
|
|
608
609
|
}), i = async (e) => {
|
|
609
610
|
if (!e) return /* @__PURE__ */ new Uint8Array();
|
|
@@ -645,7 +646,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
645
646
|
publicUrl: (t) => e.cdnBaseUrl ? `${e.cdnBaseUrl.replace(/\/$/, "")}/${t}` : null,
|
|
646
647
|
getUrl: (e, t) => r(() => a(e, "r", t)),
|
|
647
648
|
getUploadUrl: (e, t, n) => r(() => a(e, "cw", t)),
|
|
648
|
-
head: (e) =>
|
|
649
|
+
head: (e) => y.tryPromise({
|
|
649
650
|
try: async () => {
|
|
650
651
|
let { container: t } = await n();
|
|
651
652
|
try {
|
|
@@ -661,19 +662,19 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
661
662
|
},
|
|
662
663
|
catch: (e) => {
|
|
663
664
|
let t = e?.statusCode;
|
|
664
|
-
return
|
|
665
|
+
return G("azure", String(e?.message ?? e), Re(t), t);
|
|
665
666
|
}
|
|
666
667
|
}),
|
|
667
668
|
getStream: (e) => r(async () => {
|
|
668
669
|
let { container: t } = await n(), r = await t.getBlockBlobClient(e).download();
|
|
669
670
|
return {
|
|
670
|
-
stream:
|
|
671
|
+
stream: ke("azure", () => r.readableStreamBody),
|
|
671
672
|
contentType: r.contentType ?? "application/octet-stream",
|
|
672
673
|
...r.contentLength === void 0 ? {} : { size: r.contentLength }
|
|
673
674
|
};
|
|
674
675
|
}),
|
|
675
676
|
putStream: (e, t, i) => r(async () => {
|
|
676
|
-
let { container: r } = await n(), a = await
|
|
677
|
+
let { container: r } = await n(), a = await Ae(t);
|
|
677
678
|
return await r.getBlockBlobClient(e).uploadStream(a, 4194304, 5, { blobHTTPHeaders: { blobContentType: i.contentType } }), { size: i.totalSize ?? (await r.getBlockBlobClient(e).getProperties()).contentLength ?? 0 };
|
|
678
679
|
}),
|
|
679
680
|
getRange: (e, t, a) => r(async () => {
|
|
@@ -681,13 +682,13 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
681
682
|
return i(o.readableStreamBody);
|
|
682
683
|
})
|
|
683
684
|
};
|
|
684
|
-
},
|
|
685
|
+
}, Je = {
|
|
685
686
|
webp: "image/webp",
|
|
686
687
|
avif: "image/avif",
|
|
687
688
|
jpeg: "image/jpeg",
|
|
688
689
|
jpg: "image/jpeg",
|
|
689
690
|
png: "image/png"
|
|
690
|
-
},
|
|
691
|
+
}, Ye = (e) => {
|
|
691
692
|
if (!e) return null;
|
|
692
693
|
let t = new URLSearchParams(e), n = (e) => {
|
|
693
694
|
let n = t.get(e);
|
|
@@ -702,18 +703,18 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
702
703
|
...a === void 0 ? {} : { q: a },
|
|
703
704
|
...s ? { fit: s } : {}
|
|
704
705
|
};
|
|
705
|
-
},
|
|
706
|
-
if (
|
|
706
|
+
}, Xe = (e) => e.startsWith("image/") && !e.includes("svg"), Ze, Qe = async () => {
|
|
707
|
+
if (Ze !== void 0) return Ze;
|
|
707
708
|
try {
|
|
708
709
|
let e = await import("sharp");
|
|
709
|
-
|
|
710
|
+
Ze = e.default ?? e;
|
|
710
711
|
} catch {
|
|
711
|
-
|
|
712
|
+
Ze = null;
|
|
712
713
|
}
|
|
713
|
-
return
|
|
714
|
-
},
|
|
715
|
-
if (!
|
|
716
|
-
let r = await
|
|
714
|
+
return Ze;
|
|
715
|
+
}, $e = async (e, t, n) => {
|
|
716
|
+
if (!Xe(t)) return null;
|
|
717
|
+
let r = await Qe();
|
|
717
718
|
if (!r) return null;
|
|
718
719
|
try {
|
|
719
720
|
let i = r(Buffer.from(e), { failOn: "none" });
|
|
@@ -723,10 +724,10 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
723
724
|
fit: n.fit ?? "cover",
|
|
724
725
|
withoutEnlargement: !0
|
|
725
726
|
}));
|
|
726
|
-
let a = n.format &&
|
|
727
|
+
let a = n.format && Je[n.format] ? n.format : void 0, o = t;
|
|
727
728
|
if (a) {
|
|
728
729
|
let e = a === "jpg" ? "jpeg" : a;
|
|
729
|
-
i = i.toFormat(e, n.q === void 0 ? {} : { quality: n.q }), o =
|
|
730
|
+
i = i.toFormat(e, n.q === void 0 ? {} : { quality: n.q }), o = Je[a];
|
|
730
731
|
} else n.q !== void 0 && (t === "image/jpeg" || t === "image/webp") && (i = i.toFormat(t === "image/webp" ? "webp" : "jpeg", { quality: n.q }));
|
|
731
732
|
let s = await i.toBuffer();
|
|
732
733
|
return {
|
|
@@ -736,43 +737,43 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
736
737
|
} catch {
|
|
737
738
|
return null;
|
|
738
739
|
}
|
|
739
|
-
},
|
|
740
|
-
let i = `${e}::${JSON.stringify(r)}`, a =
|
|
740
|
+
}, et = 200, tt = /* @__PURE__ */ new Map(), nt = async (e, t, n, r) => {
|
|
741
|
+
let i = `${e}::${JSON.stringify(r)}`, a = tt.get(i);
|
|
741
742
|
if (a) return a;
|
|
742
|
-
let o = await
|
|
743
|
-
if (o && (
|
|
744
|
-
let e =
|
|
745
|
-
e !== void 0 &&
|
|
743
|
+
let o = await $e(t, n, r);
|
|
744
|
+
if (o && (tt.set(i, o), tt.size > et)) {
|
|
745
|
+
let e = tt.keys().next().value;
|
|
746
|
+
e !== void 0 && tt.delete(e);
|
|
746
747
|
}
|
|
747
748
|
return o;
|
|
748
|
-
},
|
|
749
|
-
let t =
|
|
750
|
-
return `${t}:${
|
|
751
|
-
},
|
|
749
|
+
}, rt = (e) => {
|
|
750
|
+
let t = L(16).toString("hex");
|
|
751
|
+
return `${t}:${_e(e, t, 32).toString("hex")}`;
|
|
752
|
+
}, it = (e, t) => {
|
|
752
753
|
if (!e || !t) return !1;
|
|
753
754
|
let [n, r] = t.split(":");
|
|
754
755
|
if (!n || !r) return !1;
|
|
755
|
-
let i = Buffer.from(r, "hex"), a =
|
|
756
|
-
return a.length === i.length &&
|
|
757
|
-
},
|
|
756
|
+
let i = Buffer.from(r, "hex"), a = _e(e, n, i.length);
|
|
757
|
+
return a.length === i.length && R(a, i);
|
|
758
|
+
}, at = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], ot = (e) => at(e.metadata?.roles), st = (e) => at(e.scopes), ct = (e, t) => e.some((e) => t.includes(e)), lt = (e) => at(e.metadata?.groups), ut = (e) => typeof e == "boolean" ? y.succeed(e) : y.isEffect(e) ? e : y.promise(() => e), dt = (e, t, n = {}) => y.gen(function* () {
|
|
758
759
|
if (t.id && e.ownerId && t.id === e.ownerId) return !0;
|
|
759
760
|
let r = e.accessPolicy ?? [];
|
|
760
761
|
if (r.length === 0) return !1;
|
|
761
|
-
let i = n.resolveGroups ? yield*
|
|
762
|
-
for (let a of r) if (yield*
|
|
762
|
+
let i = n.resolveGroups ? yield* y.promise(async () => await n.resolveGroups(t)) : lt(t);
|
|
763
|
+
for (let a of r) if (yield* ft(a, e, t, i, n)) return !0;
|
|
763
764
|
return !1;
|
|
764
|
-
}),
|
|
765
|
+
}), ft = (e, t, n, r, i) => y.gen(function* () {
|
|
765
766
|
let a = !1, o = (e) => (a = !0, e);
|
|
766
|
-
if (e.owner !== void 0 && e.owner && !o(!!n.id && !!t.ownerId && n.id === t.ownerId) || e.tenant !== void 0 && e.tenant && !o(!!n.tenantId && n.tenantId === t.tenantId) || e.apiKey !== void 0 && e.apiKey && !o(n.type === "apiKey") || e.roles && e.roles.length > 0 && !o(ot(
|
|
767
|
+
if (e.owner !== void 0 && e.owner && !o(!!n.id && !!t.ownerId && n.id === t.ownerId) || e.tenant !== void 0 && e.tenant && !o(!!n.tenantId && n.tenantId === t.tenantId) || e.apiKey !== void 0 && e.apiKey && !o(n.type === "apiKey") || e.roles && e.roles.length > 0 && !o(ct(ot(n), e.roles)) || e.groups && e.groups.length > 0 && !o(ct(r, e.groups)) || e.scopes && e.scopes.length > 0 && !o(ct(st(n), e.scopes)) || e.password !== void 0 && e.password && !o(it(i.password, t.passwordHash))) return !1;
|
|
767
768
|
if (e.guard) {
|
|
768
769
|
let r = i.guards?.[e.guard];
|
|
769
|
-
if (!o(r ? yield*
|
|
770
|
+
if (!o(r ? yield* ut(r({
|
|
770
771
|
subject: n,
|
|
771
772
|
ref: t
|
|
772
773
|
})) : !1)) return !1;
|
|
773
774
|
}
|
|
774
775
|
return a;
|
|
775
|
-
}),
|
|
776
|
+
}), pt = (e, t) => {
|
|
776
777
|
let n = [];
|
|
777
778
|
e.id && n.push({
|
|
778
779
|
type: e.type === "apiKey" ? "apiKey" : "user",
|
|
@@ -783,115 +784,116 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
783
784
|
id: e
|
|
784
785
|
});
|
|
785
786
|
return n;
|
|
786
|
-
},
|
|
787
|
-
let a =
|
|
787
|
+
}, mt = (e, t, n, r, i) => {
|
|
788
|
+
let a = pt(t, n);
|
|
788
789
|
return e.some((e) => e.expiresAt && e.expiresAt.getTime() < i || r === "write" && e.permission !== "write" ? !1 : a.some((t) => t.type === e.principalType && t.id === e.principalId));
|
|
789
|
-
},
|
|
790
|
+
}, ht = (e, t) => t.resolveGroups ? y.promise(async () => await t.resolveGroups(e)) : y.succeed(lt(e)), K = () => W.read("VOLTRO_STORAGE_SECRET") ?? ce(), q = (e) => (typeof e == "string" ? Buffer.from(e, "utf8") : e).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""), J = (e) => {
|
|
790
791
|
let t = e.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - e.length % 4) % 4);
|
|
791
792
|
return Buffer.from(t, "base64");
|
|
792
|
-
},
|
|
793
|
+
}, gt = (e, t, n = K(), r = "/_voltro/storage") => {
|
|
793
794
|
if (!n) throw Error("signGrant: secret must be a non-empty string");
|
|
794
|
-
let
|
|
795
|
+
let i = {
|
|
795
796
|
refId: e,
|
|
797
|
+
audience: r,
|
|
796
798
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
797
|
-
},
|
|
798
|
-
return `${
|
|
799
|
-
},
|
|
799
|
+
}, a = q(JSON.stringify(i));
|
|
800
|
+
return `${a}.${q(I("sha256", n).update(a).digest())}`;
|
|
801
|
+
}, _t = (e, t = K()) => {
|
|
800
802
|
if (!e || !t) return null;
|
|
801
803
|
let n = e.indexOf(".");
|
|
802
804
|
if (n <= 0 || n === e.length - 1) return null;
|
|
803
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
804
|
-
if (o.length !== a.length || !
|
|
805
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = I("sha256", t).update(r).digest(), o = J(i);
|
|
806
|
+
if (o.length !== a.length || !R(o, a)) return null;
|
|
805
807
|
try {
|
|
806
|
-
let e = JSON.parse(
|
|
807
|
-
return typeof e.refId != "string" || typeof e.exp != "number" || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
808
|
+
let e = JSON.parse(J(r).toString("utf8"));
|
|
809
|
+
return typeof e.audience != "string" || !e.audience || typeof e.refId != "string" || typeof e.exp != "number" || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
808
810
|
} catch {
|
|
809
811
|
return null;
|
|
810
812
|
}
|
|
811
|
-
},
|
|
813
|
+
}, vt = (e, t, n = K()) => {
|
|
812
814
|
if (!n) throw Error("signUploadTicket: secret must be a non-empty string");
|
|
813
815
|
let r = {
|
|
814
816
|
...e,
|
|
815
817
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
816
|
-
}, i =
|
|
817
|
-
return `${i}.${
|
|
818
|
-
},
|
|
818
|
+
}, i = q(JSON.stringify(r));
|
|
819
|
+
return `${i}.${q(I("sha256", n).update(`u:${i}`).digest())}`;
|
|
820
|
+
}, yt = (e, t = K()) => {
|
|
819
821
|
if (!e || !t) return null;
|
|
820
822
|
let n = e.indexOf(".");
|
|
821
823
|
if (n <= 0 || n === e.length - 1) return null;
|
|
822
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
823
|
-
if (o.length !== a.length || !
|
|
824
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = I("sha256", t).update(`u:${r}`).digest(), o = J(i);
|
|
825
|
+
if (o.length !== a.length || !R(o, a)) return null;
|
|
824
826
|
try {
|
|
825
|
-
let e = JSON.parse(
|
|
826
|
-
return typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || e.vis !== "public" && e.vis !== "private" || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
827
|
+
let e = JSON.parse(J(r).toString("utf8"));
|
|
828
|
+
return e.operationId !== void 0 && (typeof e.operationId != "string" || !e.operationId.trim() || e.operationId.length > 200) || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || e.vis !== "public" && e.vis !== "private" || e.replicaId !== void 0 && (typeof e.replicaId != "string" || !e.replicaId.trim()) || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
827
829
|
} catch {
|
|
828
830
|
return null;
|
|
829
831
|
}
|
|
830
|
-
},
|
|
832
|
+
}, bt = (e, t, n = K()) => {
|
|
831
833
|
if (!n) throw Error("signFinalizeTicket: secret must be a non-empty string");
|
|
832
834
|
let r = {
|
|
833
835
|
...e,
|
|
834
836
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
835
|
-
}, i =
|
|
836
|
-
return `${i}.${
|
|
837
|
-
},
|
|
837
|
+
}, i = q(JSON.stringify(r));
|
|
838
|
+
return `${i}.${q(I("sha256", n).update(`f:${i}`).digest())}`;
|
|
839
|
+
}, xt = (e, t = K()) => {
|
|
838
840
|
if (!e || !t) return null;
|
|
839
841
|
let n = e.indexOf(".");
|
|
840
842
|
if (n <= 0 || n === e.length - 1) return null;
|
|
841
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
842
|
-
if (o.length !== a.length || !
|
|
843
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = I("sha256", t).update(`f:${r}`).digest(), o = J(i);
|
|
844
|
+
if (o.length !== a.length || !R(o, a)) return null;
|
|
843
845
|
try {
|
|
844
|
-
let e = JSON.parse(
|
|
846
|
+
let e = JSON.parse(J(r).toString("utf8"));
|
|
845
847
|
return typeof e.key != "string" || e.key.length === 0 || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || e.vis !== "public" && e.vis !== "private" || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
846
848
|
} catch {
|
|
847
849
|
return null;
|
|
848
850
|
}
|
|
849
|
-
},
|
|
851
|
+
}, St = (e, t, n = K()) => {
|
|
850
852
|
if (!n) throw Error("signResumableTicket: secret must be a non-empty string");
|
|
851
853
|
let r = {
|
|
852
854
|
...e,
|
|
853
855
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
854
|
-
}, i =
|
|
855
|
-
return `${i}.${
|
|
856
|
-
},
|
|
856
|
+
}, i = q(JSON.stringify(r));
|
|
857
|
+
return `${i}.${q(I("sha256", n).update(`r:${i}`).digest())}`;
|
|
858
|
+
}, Ct = (e, t = K()) => {
|
|
857
859
|
if (!e || !t) return null;
|
|
858
860
|
let n = e.indexOf(".");
|
|
859
861
|
if (n <= 0 || n === e.length - 1) return null;
|
|
860
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
861
|
-
if (o.length !== a.length || !
|
|
862
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = I("sha256", t).update(`r:${r}`).digest(), o = J(i);
|
|
863
|
+
if (o.length !== a.length || !R(o, a)) return null;
|
|
862
864
|
try {
|
|
863
|
-
let e = JSON.parse(
|
|
865
|
+
let e = JSON.parse(J(r).toString("utf8"));
|
|
864
866
|
return typeof e.id != "string" || e.id.length === 0 || typeof e.size != "number" || e.size < 0 || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || e.vis !== "public" && e.vis !== "private" || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
865
867
|
} catch {
|
|
866
868
|
return null;
|
|
867
869
|
}
|
|
868
|
-
},
|
|
870
|
+
}, wt = (e, t, n = K()) => {
|
|
869
871
|
if (!n) throw Error("signMultipartTicket: secret must be a non-empty string");
|
|
870
872
|
let r = {
|
|
871
873
|
...e,
|
|
872
874
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
873
|
-
}, i =
|
|
874
|
-
return `${i}.${
|
|
875
|
-
},
|
|
875
|
+
}, i = q(JSON.stringify(r));
|
|
876
|
+
return `${i}.${q(I("sha256", n).update(`m:${i}`).digest())}`;
|
|
877
|
+
}, Tt = (e, t = K()) => {
|
|
876
878
|
if (!e || !t) return null;
|
|
877
879
|
let n = e.indexOf(".");
|
|
878
880
|
if (n <= 0 || n === e.length - 1) return null;
|
|
879
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
880
|
-
if (o.length !== a.length || !
|
|
881
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = I("sha256", t).update(`m:${r}`).digest(), o = J(i);
|
|
882
|
+
if (o.length !== a.length || !R(o, a)) return null;
|
|
881
883
|
try {
|
|
882
|
-
let e = JSON.parse(
|
|
884
|
+
let e = JSON.parse(J(r).toString("utf8"));
|
|
883
885
|
return typeof e.key != "string" || e.key.length === 0 || typeof e.uploadId != "string" || e.uploadId.length === 0 || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || e.vis !== "public" && e.vis !== "private" || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
884
886
|
} catch {
|
|
885
887
|
return null;
|
|
886
888
|
}
|
|
887
|
-
},
|
|
889
|
+
}, Et = (e, t) => {
|
|
888
890
|
if (!t || t.length === 0) return !0;
|
|
889
891
|
let n = e.toLowerCase();
|
|
890
892
|
return t.some((e) => {
|
|
891
893
|
let t = e.toLowerCase();
|
|
892
894
|
return t.endsWith("/*") ? n.startsWith(t.slice(0, -1)) : n === t;
|
|
893
895
|
});
|
|
894
|
-
},
|
|
896
|
+
}, Dt = [
|
|
895
897
|
{
|
|
896
898
|
ct: /^image\/png$/,
|
|
897
899
|
offset: 0,
|
|
@@ -961,21 +963,21 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
961
963
|
offset: 0,
|
|
962
964
|
magic: [31, 139]
|
|
963
965
|
}
|
|
964
|
-
],
|
|
965
|
-
let n = t.toLowerCase(), r =
|
|
966
|
+
], Ot = (e, t) => {
|
|
967
|
+
let n = t.toLowerCase(), r = Dt.find((e) => e.ct.test(n));
|
|
966
968
|
return r ? e.length < r.offset + r.magic.length ? !1 : r.magic.every((t, n) => e[r.offset + n] === t) : !0;
|
|
967
|
-
},
|
|
969
|
+
}, kt = (e, t, n) => n ? n.maxBytes !== void 0 && e.byteLength > n.maxBytes ? {
|
|
968
970
|
reason: "too-large",
|
|
969
971
|
detail: `${e.byteLength} bytes exceeds the ${n.maxBytes}-byte limit`
|
|
970
|
-
} :
|
|
972
|
+
} : Et(t, n.allowedContentTypes) ? n.sniff && !Ot(e, t) ? {
|
|
971
973
|
reason: "content-mismatch",
|
|
972
974
|
detail: `bytes do not match the declared content type '${t}'`
|
|
973
975
|
} : null : {
|
|
974
976
|
reason: "content-type-not-allowed",
|
|
975
977
|
detail: `content type '${t}' is not in the allow-list`
|
|
976
|
-
} : null,
|
|
977
|
-
if (!
|
|
978
|
-
let r = await
|
|
978
|
+
} : null, At = async (e, t, n) => {
|
|
979
|
+
if (!Xe(t)) return { bytes: e };
|
|
980
|
+
let r = await Qe();
|
|
979
981
|
if (!r) return { bytes: e };
|
|
980
982
|
try {
|
|
981
983
|
let t = e;
|
|
@@ -998,16 +1000,16 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
998
1000
|
} catch {
|
|
999
1001
|
return { bytes: e };
|
|
1000
1002
|
}
|
|
1001
|
-
},
|
|
1003
|
+
}, jt = 67108864, Mt = (e) => new n({
|
|
1002
1004
|
reason: "too-large",
|
|
1003
1005
|
detail: `remote body exceeds the ${e}-byte ingest limit`
|
|
1004
|
-
}),
|
|
1005
|
-
let i = r ??
|
|
1006
|
-
return !Number.isSafeInteger(i) || i < 0 ?
|
|
1006
|
+
}), Nt = (e, r) => y.suspend(() => {
|
|
1007
|
+
let i = r ?? jt;
|
|
1008
|
+
return !Number.isSafeInteger(i) || i < 0 ? y.fail(new t({
|
|
1007
1009
|
provider: "ingest",
|
|
1008
1010
|
message: "limits.maxBytes must be a non-negative safe integer",
|
|
1009
1011
|
transient: !1
|
|
1010
|
-
})) :
|
|
1012
|
+
})) : y.tryPromise({
|
|
1011
1013
|
try: async (n) => {
|
|
1012
1014
|
let r = await fetch(e, { signal: n }), a;
|
|
1013
1015
|
try {
|
|
@@ -1018,12 +1020,12 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1018
1020
|
status: r.status
|
|
1019
1021
|
});
|
|
1020
1022
|
let e = r.headers.get("content-length"), n = r.headers.get("content-encoding")?.trim().toLowerCase();
|
|
1021
|
-
if ((!n || n === "identity") && e !== null && /^\d+$/.test(e) && BigInt(e) > BigInt(i)) throw
|
|
1023
|
+
if ((!n || n === "identity") && e !== null && /^\d+$/.test(e) && BigInt(e) > BigInt(i)) throw Mt(i);
|
|
1022
1024
|
let o = /* @__PURE__ */ new Uint8Array(), s = 0;
|
|
1023
1025
|
if (r.body !== null) for (a = r.body.getReader();;) {
|
|
1024
1026
|
let e = await a.read();
|
|
1025
1027
|
if (e.done) break;
|
|
1026
|
-
if (e.value.byteLength > i - s) throw
|
|
1028
|
+
if (e.value.byteLength > i - s) throw Mt(i);
|
|
1027
1029
|
if (e.value.byteLength !== 0) {
|
|
1028
1030
|
let t = s + e.value.byteLength;
|
|
1029
1031
|
if (t > o.byteLength) {
|
|
@@ -1047,26 +1049,26 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1047
1049
|
transient: !0
|
|
1048
1050
|
})
|
|
1049
1051
|
});
|
|
1050
|
-
}),
|
|
1052
|
+
}), Pt = (e, t) => y.suspend(() => {
|
|
1051
1053
|
if (t === void 0) return e;
|
|
1052
|
-
if (t.aborted) return
|
|
1053
|
-
let n =
|
|
1054
|
-
let n = () => e(
|
|
1055
|
-
return t.addEventListener("abort", n, { once: !0 }), t.aborted && n(),
|
|
1054
|
+
if (t.aborted) return y.interrupt;
|
|
1055
|
+
let n = y.async((e) => {
|
|
1056
|
+
let n = () => e(y.interrupt);
|
|
1057
|
+
return t.addEventListener("abort", n, { once: !0 }), t.aborted && n(), y.sync(() => t.removeEventListener("abort", n));
|
|
1056
1058
|
});
|
|
1057
|
-
return
|
|
1058
|
-
}),
|
|
1059
|
-
let r = (e, r) =>
|
|
1059
|
+
return y.raceFirst(e, n);
|
|
1060
|
+
}), Ft = (e) => {
|
|
1061
|
+
let r = (e, r) => y.tryPromise({
|
|
1060
1062
|
try: r,
|
|
1061
|
-
catch: (r) =>
|
|
1063
|
+
catch: (r) => C.is(n)(r) ? r : new t({
|
|
1062
1064
|
provider: "metadata",
|
|
1063
1065
|
message: `Storage ${e} was not confirmed; retain the operation identity for recovery`,
|
|
1064
1066
|
transient: !1
|
|
1065
1067
|
})
|
|
1066
1068
|
});
|
|
1067
1069
|
return {
|
|
1068
|
-
put: (t) =>
|
|
1069
|
-
if (t.bytes.byteLength !== t.ref.size ||
|
|
1070
|
+
put: (t) => y.gen(function* () {
|
|
1071
|
+
if (t.bytes.byteLength !== t.ref.size || he("sha256").update(t.bytes).digest("hex") !== t.identity.checksum) return yield* y.fail(new n({
|
|
1070
1072
|
reason: "operation-content-mismatch",
|
|
1071
1073
|
detail: "Storage operation bytes do not match their reserved identity"
|
|
1072
1074
|
}));
|
|
@@ -1082,15 +1084,15 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1082
1084
|
outcome: a
|
|
1083
1085
|
});
|
|
1084
1086
|
}),
|
|
1085
|
-
delete: (t, n, i) =>
|
|
1087
|
+
delete: (t, n, i) => y.gen(function* () {
|
|
1086
1088
|
let a = yield* r("delete acceptance", () => e.metadata.beginDelete(t, n, i));
|
|
1087
1089
|
"operation" in a && (a.operation.deleteKey !== null && (yield* e.provider.delete(a.operation.deleteKey)), yield* r("delete confirmation", () => e.metadata.confirmDelete(a.identity)));
|
|
1088
1090
|
})
|
|
1089
1091
|
};
|
|
1090
|
-
},
|
|
1092
|
+
}, It = async (e) => {
|
|
1091
1093
|
let { createHash: t } = await import("node:crypto");
|
|
1092
1094
|
return t("sha256").update(e).digest("hex");
|
|
1093
|
-
},
|
|
1095
|
+
}, Lt = (e, t, n) => `${e?.replace(/\/+$/, "") ?? ""}${n}/${t}`, Rt = (e) => {
|
|
1094
1096
|
let t = /* @__PURE__ */ new Map(), n = {
|
|
1095
1097
|
public: 0,
|
|
1096
1098
|
private: 0
|
|
@@ -1106,7 +1108,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1106
1108
|
byTenant: Object.fromEntries(t),
|
|
1107
1109
|
visibility: n
|
|
1108
1110
|
};
|
|
1109
|
-
},
|
|
1111
|
+
}, zt = (e, t) => {
|
|
1110
1112
|
if (t.search && ![
|
|
1111
1113
|
e.id,
|
|
1112
1114
|
e.key,
|
|
@@ -1123,10 +1125,10 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1123
1125
|
if (!t.tags.every((e) => n.includes(e))) return !1;
|
|
1124
1126
|
}
|
|
1125
1127
|
return !0;
|
|
1126
|
-
},
|
|
1128
|
+
}, Bt = (e) => e ?? "global", Vt = () => {
|
|
1127
1129
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
1128
1130
|
return {
|
|
1129
|
-
statistics: () =>
|
|
1131
|
+
statistics: () => y.sync(() => Rt((function* () {
|
|
1130
1132
|
for (let t of e.values()) yield {
|
|
1131
1133
|
tenantId: t.tenantId,
|
|
1132
1134
|
visibility: t.visibility,
|
|
@@ -1134,14 +1136,14 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1134
1136
|
bytes: t.size
|
|
1135
1137
|
};
|
|
1136
1138
|
})())),
|
|
1137
|
-
insert: (t) =>
|
|
1139
|
+
insert: (t) => y.sync(() => {
|
|
1138
1140
|
e.set(t.id, t);
|
|
1139
1141
|
}),
|
|
1140
|
-
getById: (t) =>
|
|
1141
|
-
delete: (t) =>
|
|
1142
|
-
listRecent: (t) =>
|
|
1143
|
-
countByKey: (t, n) =>
|
|
1144
|
-
usageByTenant: (t) =>
|
|
1142
|
+
getById: (t) => y.sync(() => e.get(t) ?? null),
|
|
1143
|
+
delete: (t) => y.sync(() => e.delete(t)),
|
|
1144
|
+
listRecent: (t) => y.sync(() => [...e.values()].sort((e, t) => t.createdAt.getTime() - e.createdAt.getTime() || t.id.localeCompare(e.id)).slice(0, t)),
|
|
1145
|
+
countByKey: (t, n) => y.sync(() => [...e.values()].filter((e) => e.bucket === t && e.key === n).length),
|
|
1146
|
+
usageByTenant: (t) => y.sync(() => {
|
|
1145
1147
|
let n = 0, r = 0;
|
|
1146
1148
|
for (let i of e.values()) (i.tenantId ?? null) === (t ?? null) && (n += i.size, r++);
|
|
1147
1149
|
return {
|
|
@@ -1149,8 +1151,8 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1149
1151
|
count: r
|
|
1150
1152
|
};
|
|
1151
1153
|
}),
|
|
1152
|
-
consumeUsage: (e, n, r) =>
|
|
1153
|
-
let i =
|
|
1154
|
+
consumeUsage: (e, n, r) => y.sync(() => {
|
|
1155
|
+
let i = Bt(e), a = t.get(i) ?? {
|
|
1154
1156
|
bytes: 0,
|
|
1155
1157
|
count: 0
|
|
1156
1158
|
}, o = (r?.maxBytes === void 0 || a.bytes + n.bytes <= r.maxBytes) && (r?.maxCount === void 0 || a.count + n.count <= r.maxCount);
|
|
@@ -1163,17 +1165,17 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1163
1165
|
count: a.count
|
|
1164
1166
|
};
|
|
1165
1167
|
}),
|
|
1166
|
-
releaseUsage: (e, n) =>
|
|
1167
|
-
let r =
|
|
1168
|
+
releaseUsage: (e, n) => y.sync(() => {
|
|
1169
|
+
let r = Bt(e), i = t.get(r);
|
|
1168
1170
|
i && t.set(r, {
|
|
1169
1171
|
bytes: Math.max(0, i.bytes - n.bytes),
|
|
1170
1172
|
count: Math.max(0, i.count - n.count)
|
|
1171
1173
|
});
|
|
1172
1174
|
}),
|
|
1173
|
-
listByDerivedFrom: (t) =>
|
|
1174
|
-
listRefs: (t) =>
|
|
1175
|
+
listByDerivedFrom: (t) => y.sync(() => [...e.values()].filter((e) => (e.derivedFrom ?? null) === t)),
|
|
1176
|
+
listRefs: (t) => y.sync(() => [...e.values()].filter((e) => zt(e, t)).sort((e, t) => t.createdAt.getTime() - e.createdAt.getTime() || t.id.localeCompare(e.id)).slice(t.offset, t.offset + t.limit))
|
|
1175
1177
|
};
|
|
1176
|
-
},
|
|
1178
|
+
}, Ht = (e) => Array.isArray(e) && e.every((e) => typeof e == "string") ? e : null, Y = (e) => ({
|
|
1177
1179
|
id: String(e.id),
|
|
1178
1180
|
tenantId: e.tenantId ?? null,
|
|
1179
1181
|
ownerId: e.ownerId ?? null,
|
|
@@ -1191,19 +1193,19 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1191
1193
|
duration: e.duration ?? null,
|
|
1192
1194
|
placeholder: e.placeholder ?? null,
|
|
1193
1195
|
folder: e.folder ?? null,
|
|
1194
|
-
tags:
|
|
1196
|
+
tags: Ht(e.tags),
|
|
1195
1197
|
alt: e.alt ?? null,
|
|
1196
1198
|
caption: e.caption ?? null,
|
|
1197
1199
|
derivedFrom: e.derivedFrom ?? null,
|
|
1198
1200
|
kind: e.kind ?? null
|
|
1199
|
-
}),
|
|
1201
|
+
}), X = (e) => y.tryPromise({
|
|
1200
1202
|
try: e,
|
|
1201
1203
|
catch: (e) => new t({
|
|
1202
1204
|
provider: "refstore",
|
|
1203
1205
|
message: String(e?.message ?? e),
|
|
1204
1206
|
transient: !0
|
|
1205
1207
|
})
|
|
1206
|
-
}),
|
|
1208
|
+
}), Ut = async (e, t) => (await e.query({
|
|
1207
1209
|
table: "_voltro_storage_usage",
|
|
1208
1210
|
predicate: {
|
|
1209
1211
|
column: "tenantId",
|
|
@@ -1214,9 +1216,9 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1214
1216
|
take: 1,
|
|
1215
1217
|
skip: void 0,
|
|
1216
1218
|
projection: void 0
|
|
1217
|
-
}))[0] ?? null,
|
|
1218
|
-
statistics: () =>
|
|
1219
|
-
table:
|
|
1219
|
+
}))[0] ?? null, Wt = (e) => ({
|
|
1220
|
+
statistics: () => X(async () => Rt((await e.query({
|
|
1221
|
+
table: V,
|
|
1220
1222
|
predicate: void 0,
|
|
1221
1223
|
order: [],
|
|
1222
1224
|
take: void 0,
|
|
@@ -1237,10 +1239,10 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1237
1239
|
count: Number(e.count),
|
|
1238
1240
|
bytes: Number(e.bytes ?? 0)
|
|
1239
1241
|
})))),
|
|
1240
|
-
insert: (t) =>
|
|
1241
|
-
getById: (t) =>
|
|
1242
|
+
insert: (t) => X(() => e.insert(V, { ...t })),
|
|
1243
|
+
getById: (t) => X(async () => {
|
|
1242
1244
|
let n = await e.query({
|
|
1243
|
-
table:
|
|
1245
|
+
table: V,
|
|
1244
1246
|
predicate: {
|
|
1245
1247
|
column: "id",
|
|
1246
1248
|
op: "eq",
|
|
@@ -1251,11 +1253,11 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1251
1253
|
skip: void 0,
|
|
1252
1254
|
projection: void 0
|
|
1253
1255
|
});
|
|
1254
|
-
return n[0] ?
|
|
1256
|
+
return n[0] ? Y(n[0]) : null;
|
|
1255
1257
|
}),
|
|
1256
|
-
delete: (t) =>
|
|
1257
|
-
listRecent: (t) =>
|
|
1258
|
-
table:
|
|
1258
|
+
delete: (t) => X(() => e.delete(V, t)),
|
|
1259
|
+
listRecent: (t) => X(async () => (await e.query({
|
|
1260
|
+
table: V,
|
|
1259
1261
|
predicate: void 0,
|
|
1260
1262
|
order: [{
|
|
1261
1263
|
column: "createdAt",
|
|
@@ -1264,9 +1266,9 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1264
1266
|
take: t,
|
|
1265
1267
|
skip: void 0,
|
|
1266
1268
|
projection: void 0
|
|
1267
|
-
})).map(
|
|
1268
|
-
countByKey: (t, n) =>
|
|
1269
|
-
table:
|
|
1269
|
+
})).map(Y)),
|
|
1270
|
+
countByKey: (t, n) => X(async () => (await e.query({
|
|
1271
|
+
table: V,
|
|
1270
1272
|
predicate: { and: [{
|
|
1271
1273
|
column: "bucket",
|
|
1272
1274
|
op: "eq",
|
|
@@ -1281,9 +1283,9 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1281
1283
|
skip: void 0,
|
|
1282
1284
|
projection: void 0
|
|
1283
1285
|
})).length),
|
|
1284
|
-
usageByTenant: (t) =>
|
|
1286
|
+
usageByTenant: (t) => X(async () => {
|
|
1285
1287
|
let n = await e.query({
|
|
1286
|
-
table:
|
|
1288
|
+
table: V,
|
|
1287
1289
|
predicate: {
|
|
1288
1290
|
column: "tenantId",
|
|
1289
1291
|
op: "eq",
|
|
@@ -1300,11 +1302,11 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1300
1302
|
count: n.length
|
|
1301
1303
|
};
|
|
1302
1304
|
}),
|
|
1303
|
-
consumeUsage: (t, n, r) =>
|
|
1304
|
-
let i =
|
|
1305
|
+
consumeUsage: (t, n, r) => X(async () => {
|
|
1306
|
+
let i = Bt(t);
|
|
1305
1307
|
for (let t = 0; t < 32; t++) {
|
|
1306
1308
|
t > 0 && await new Promise((e) => setTimeout(e, t));
|
|
1307
|
-
let a = await
|
|
1309
|
+
let a = await Ut(e, i), o = a ? Number(a.bytes ?? 0) : 0, s = a ? Number(a.count ?? 0) : 0;
|
|
1308
1310
|
if (!((r?.maxBytes === void 0 || o + n.bytes <= r.maxBytes) && (r?.maxCount === void 0 || s + n.count <= r.maxCount))) return {
|
|
1309
1311
|
allowed: !1,
|
|
1310
1312
|
bytes: o,
|
|
@@ -1315,16 +1317,16 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1315
1317
|
bytes: o + n.bytes,
|
|
1316
1318
|
count: s + n.count,
|
|
1317
1319
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1318
|
-
}, { where: D(
|
|
1320
|
+
}, { where: T(D("id", String(a.id)), D("bytes", o), D("count", s)) }) === 1) return {
|
|
1319
1321
|
allowed: !0,
|
|
1320
1322
|
bytes: o,
|
|
1321
1323
|
count: s
|
|
1322
1324
|
};
|
|
1323
1325
|
} else {
|
|
1324
|
-
let t =
|
|
1326
|
+
let t = O({
|
|
1325
1327
|
kind: "typeid",
|
|
1326
1328
|
prefix: "susage"
|
|
1327
|
-
},
|
|
1329
|
+
}, Ne), r = await e.insertIgnore(Ne, {
|
|
1328
1330
|
id: t,
|
|
1329
1331
|
tenantId: i,
|
|
1330
1332
|
bytes: n.bytes,
|
|
@@ -1340,23 +1342,23 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1340
1342
|
}
|
|
1341
1343
|
throw Error(`storage usage consume: contention on tenant '${i}' exceeded 32 attempts`);
|
|
1342
1344
|
}),
|
|
1343
|
-
releaseUsage: (t, n) =>
|
|
1344
|
-
let r =
|
|
1345
|
+
releaseUsage: (t, n) => X(async () => {
|
|
1346
|
+
let r = Bt(t);
|
|
1345
1347
|
for (let t = 0; t < 32; t++) {
|
|
1346
1348
|
t > 0 && await new Promise((e) => setTimeout(e, t));
|
|
1347
|
-
let i = await
|
|
1349
|
+
let i = await Ut(e, r);
|
|
1348
1350
|
if (!i) return;
|
|
1349
1351
|
let a = Number(i.bytes ?? 0), o = Number(i.count ?? 0);
|
|
1350
1352
|
if (await e.updateMany("_voltro_storage_usage", {
|
|
1351
1353
|
bytes: Math.max(0, a - n.bytes),
|
|
1352
1354
|
count: Math.max(0, o - n.count),
|
|
1353
1355
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1354
|
-
}, { where: D(
|
|
1356
|
+
}, { where: T(D("id", String(i.id)), D("bytes", a), D("count", o)) }) === 1) return;
|
|
1355
1357
|
}
|
|
1356
1358
|
throw Error(`storage usage release: contention on tenant '${r}' exceeded 32 attempts`);
|
|
1357
1359
|
}),
|
|
1358
|
-
listByDerivedFrom: (t) =>
|
|
1359
|
-
table:
|
|
1360
|
+
listByDerivedFrom: (t) => X(async () => (await e.query({
|
|
1361
|
+
table: V,
|
|
1360
1362
|
predicate: {
|
|
1361
1363
|
column: "derivedFrom",
|
|
1362
1364
|
op: "eq",
|
|
@@ -1369,18 +1371,18 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1369
1371
|
take: void 0,
|
|
1370
1372
|
skip: void 0,
|
|
1371
1373
|
projection: void 0
|
|
1372
|
-
})).map(
|
|
1373
|
-
listRefs: (t) =>
|
|
1374
|
+
})).map(Y)),
|
|
1375
|
+
listRefs: (t) => X(async () => {
|
|
1374
1376
|
let n = [];
|
|
1375
|
-
t.tenantId !== void 0 && n.push(
|
|
1377
|
+
t.tenantId !== void 0 && n.push(D("tenantId", t.tenantId)), t.ownerId !== void 0 && n.push(D("ownerId", t.ownerId)), t.search && n.push(fe(...[
|
|
1376
1378
|
"id",
|
|
1377
1379
|
"key",
|
|
1378
1380
|
"contentType",
|
|
1379
1381
|
"ownerId",
|
|
1380
1382
|
"tenantId"
|
|
1381
|
-
].map((e) =>
|
|
1382
|
-
let r = t.folder === void 0 && t.tags.length === 0 && t.includeDerived, i = n.length ?
|
|
1383
|
-
table:
|
|
1383
|
+
].map((e) => E(e, t.search))));
|
|
1384
|
+
let r = t.folder === void 0 && t.tags.length === 0 && t.includeDerived, i = n.length ? T(...n) : void 0, a = await e.query({
|
|
1385
|
+
table: V,
|
|
1384
1386
|
predicate: i,
|
|
1385
1387
|
order: [{
|
|
1386
1388
|
column: "createdAt",
|
|
@@ -1393,24 +1395,24 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1393
1395
|
skip: r ? t.offset : void 0,
|
|
1394
1396
|
projection: void 0
|
|
1395
1397
|
});
|
|
1396
|
-
return r ? a.map(
|
|
1398
|
+
return r ? a.map(Y) : a.map(Y).filter((e) => zt(e, t)).slice(t.offset, t.offset + t.limit);
|
|
1397
1399
|
})
|
|
1398
|
-
}),
|
|
1400
|
+
}), Gt = () => {
|
|
1399
1401
|
let e = /* @__PURE__ */ new Map();
|
|
1400
1402
|
return {
|
|
1401
|
-
insert: (t) =>
|
|
1403
|
+
insert: (t) => y.sync(() => {
|
|
1402
1404
|
e.set(t.id, t);
|
|
1403
1405
|
}),
|
|
1404
|
-
delete: (t) =>
|
|
1406
|
+
delete: (t) => y.sync(() => {
|
|
1405
1407
|
e.delete(t);
|
|
1406
1408
|
}),
|
|
1407
|
-
getById: (t) =>
|
|
1408
|
-
listByRef: (t) =>
|
|
1409
|
-
deleteByRef: (t) =>
|
|
1409
|
+
getById: (t) => y.sync(() => e.get(t) ?? null),
|
|
1410
|
+
listByRef: (t) => y.sync(() => [...e.values()].filter((e) => e.refId === t)),
|
|
1411
|
+
deleteByRef: (t) => y.sync(() => {
|
|
1410
1412
|
for (let [n, r] of e) r.refId === t && e.delete(n);
|
|
1411
1413
|
})
|
|
1412
1414
|
};
|
|
1413
|
-
},
|
|
1415
|
+
}, Kt = (e) => ({
|
|
1414
1416
|
id: String(e.id),
|
|
1415
1417
|
refId: String(e.refId),
|
|
1416
1418
|
principalType: e.principalType,
|
|
@@ -1419,12 +1421,12 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1419
1421
|
createdAt: e.createdAt instanceof Date ? e.createdAt : new Date(String(e.createdAt)),
|
|
1420
1422
|
expiresAt: e.expiresAt ? e.expiresAt instanceof Date ? e.expiresAt : new Date(String(e.expiresAt)) : null,
|
|
1421
1423
|
createdBy: e.createdBy ?? null
|
|
1422
|
-
}),
|
|
1423
|
-
insert: (t) =>
|
|
1424
|
-
delete: (t) =>
|
|
1425
|
-
getById: (t) =>
|
|
1424
|
+
}), qt = (e) => ({
|
|
1425
|
+
insert: (t) => X(() => e.insert(H, { ...t })),
|
|
1426
|
+
delete: (t) => X(() => e.delete(H, t)),
|
|
1427
|
+
getById: (t) => X(async () => {
|
|
1426
1428
|
let n = (await e.query({
|
|
1427
|
-
table:
|
|
1429
|
+
table: H,
|
|
1428
1430
|
predicate: {
|
|
1429
1431
|
column: "id",
|
|
1430
1432
|
op: "eq",
|
|
@@ -1435,10 +1437,10 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1435
1437
|
skip: void 0,
|
|
1436
1438
|
projection: void 0
|
|
1437
1439
|
}))[0];
|
|
1438
|
-
return n ?
|
|
1440
|
+
return n ? Kt(n) : null;
|
|
1439
1441
|
}),
|
|
1440
|
-
listByRef: (t) =>
|
|
1441
|
-
table:
|
|
1442
|
+
listByRef: (t) => X(async () => (await e.query({
|
|
1443
|
+
table: H,
|
|
1442
1444
|
predicate: {
|
|
1443
1445
|
column: "refId",
|
|
1444
1446
|
op: "eq",
|
|
@@ -1451,10 +1453,10 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1451
1453
|
take: void 0,
|
|
1452
1454
|
skip: void 0,
|
|
1453
1455
|
projection: void 0
|
|
1454
|
-
})).map(
|
|
1455
|
-
deleteByRef: (t) =>
|
|
1456
|
+
})).map(Kt)),
|
|
1457
|
+
deleteByRef: (t) => X(async () => {
|
|
1456
1458
|
let n = await e.query({
|
|
1457
|
-
table:
|
|
1459
|
+
table: H,
|
|
1458
1460
|
predicate: {
|
|
1459
1461
|
column: "refId",
|
|
1460
1462
|
op: "eq",
|
|
@@ -1465,48 +1467,48 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1465
1467
|
skip: void 0,
|
|
1466
1468
|
projection: void 0
|
|
1467
1469
|
});
|
|
1468
|
-
for (let t of n) await e.delete(
|
|
1470
|
+
for (let t of n) await e.delete(H, String(t.id));
|
|
1469
1471
|
})
|
|
1470
|
-
}),
|
|
1472
|
+
}), Jt = () => O({
|
|
1471
1473
|
kind: "typeid",
|
|
1472
1474
|
prefix: "file"
|
|
1473
|
-
},
|
|
1475
|
+
}, V), Yt = () => O({
|
|
1474
1476
|
kind: "typeid",
|
|
1475
1477
|
prefix: "grant"
|
|
1476
|
-
},
|
|
1477
|
-
let { provider: a, refStore: o, grantStore: s, bucket: c } = i, l = i.access ?? {}, u = i.attempts ?? 3, d = i.urlExpiresInSec ?? 3600, f = (e) =>
|
|
1478
|
+
}, H), Xt = (i) => {
|
|
1479
|
+
let { provider: a, refStore: o, grantStore: s, bucket: c } = i, l = i.access ?? {}, u = i.attempts ?? 3, d = i.urlExpiresInSec ?? 3600, f = (e) => Lt(i.publicBaseUrl, e, i.httpPath ?? "/_voltro/storage"), p = S.recurs(Math.max(0, u - 1)).pipe(S.intersect(S.exponential("100 millis")), S.whileInput((e) => e.transient)), m = (e, t, n) => [
|
|
1478
1480
|
i.tenantPrefix,
|
|
1479
1481
|
e ?? "global",
|
|
1480
1482
|
n ?? t
|
|
1481
1483
|
].filter(Boolean).join("/"), ee = (e) => {
|
|
1482
|
-
if (e === void 0) return
|
|
1484
|
+
if (e === void 0) return y.succeed(void 0);
|
|
1483
1485
|
let n = e.length === 0 ? "empty" : e.includes("\0") ? "contains NUL" : e.startsWith("/") || e.startsWith("\\") ? "starts with a path separator" : e.includes("\\") ? "contains a backslash" : e.split("/").some((e) => e === "" || e === "." || e === "..") ? "contains an empty, \".\" or \"..\" segment" : void 0;
|
|
1484
|
-
return n === void 0 ?
|
|
1486
|
+
return n === void 0 ? y.succeed(e) : y.fail(new t({
|
|
1485
1487
|
provider: a.name,
|
|
1486
1488
|
message: `storage key rejected: ${n}`,
|
|
1487
1489
|
transient: !1,
|
|
1488
1490
|
status: 400
|
|
1489
1491
|
}));
|
|
1490
|
-
},
|
|
1492
|
+
}, te = (e, t, n) => [
|
|
1491
1493
|
i.tenantPrefix,
|
|
1492
1494
|
e ?? "global",
|
|
1493
1495
|
"_incoming",
|
|
1494
1496
|
t,
|
|
1495
1497
|
String(n).padStart(6, "0")
|
|
1496
|
-
].filter(Boolean).join("/"),
|
|
1498
|
+
].filter(Boolean).join("/"), h = (e, n) => n !== void 0 && e.tenantId !== n ? y.fail(new t({
|
|
1497
1499
|
provider: a.name,
|
|
1498
1500
|
message: "cross-tenant access denied",
|
|
1499
1501
|
transient: !1,
|
|
1500
1502
|
status: 403
|
|
1501
|
-
})) :
|
|
1503
|
+
})) : y.succeed(e), ne = (e, n, r) => y.gen(function* () {
|
|
1502
1504
|
let o = i.objects?.(), s = (e) => new t({
|
|
1503
1505
|
provider: "metadata",
|
|
1504
1506
|
message: e,
|
|
1505
1507
|
transient: !1,
|
|
1506
1508
|
status: 409
|
|
1507
1509
|
});
|
|
1508
|
-
if (o === void 0) return r === void 0 ? !1 : yield*
|
|
1509
|
-
let c = yield*
|
|
1510
|
+
if (o === void 0) return r === void 0 ? !1 : yield* y.fail(s(`claim '${r}' cannot be released: no data store is bound, so ref '${e}' holds no claims`));
|
|
1511
|
+
let c = yield* y.tryPromise({
|
|
1510
1512
|
try: () => o.intent(e),
|
|
1511
1513
|
catch: (e) => new t({
|
|
1512
1514
|
provider: "metadata",
|
|
@@ -1514,25 +1516,25 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1514
1516
|
transient: !1
|
|
1515
1517
|
})
|
|
1516
1518
|
});
|
|
1517
|
-
return c === void 0 ? r === void 0 ? !1 : yield*
|
|
1519
|
+
return c === void 0 ? r === void 0 ? !1 : yield* y.fail(s(`claim '${r}' cannot be released: ref '${e}' was not written through an operation and holds no claims`)) : (yield* h(c.ref, n), yield* Ft({
|
|
1518
1520
|
metadata: o,
|
|
1519
1521
|
provider: {
|
|
1520
1522
|
...a,
|
|
1521
|
-
delete: (e) => a.delete(e).pipe(
|
|
1523
|
+
delete: (e) => a.delete(e).pipe(y.retry(p))
|
|
1522
1524
|
}
|
|
1523
|
-
}).delete(e, n, r).pipe(
|
|
1525
|
+
}).delete(e, n, r).pipe(y.catchTag("StorageRejected", (e) => y.fail(e.reason === "claim-not-held" ? s(e.detail) : new t({
|
|
1524
1526
|
provider: "metadata",
|
|
1525
1527
|
message: e.detail,
|
|
1526
1528
|
transient: !1
|
|
1527
1529
|
})))), !0);
|
|
1528
|
-
}),
|
|
1530
|
+
}), g = (e, n) => o.getById(e).pipe(y.flatMap((r) => r ? h(r, n) : y.fail(new t({
|
|
1529
1531
|
provider: a.name,
|
|
1530
1532
|
message: `no ref '${e}'`,
|
|
1531
1533
|
transient: !1,
|
|
1532
1534
|
status: 404
|
|
1533
|
-
})))),
|
|
1535
|
+
})))), re = (e) => y.suspend(() => {
|
|
1534
1536
|
let n = i.scan(e);
|
|
1535
|
-
return
|
|
1537
|
+
return y.isEffect(n) ? n : y.tryPromise({
|
|
1536
1538
|
try: () => Promise.resolve(n),
|
|
1537
1539
|
catch: (e) => new t({
|
|
1538
1540
|
provider: "scan",
|
|
@@ -1540,77 +1542,77 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1540
1542
|
transient: !0
|
|
1541
1543
|
})
|
|
1542
1544
|
});
|
|
1543
|
-
}),
|
|
1545
|
+
}), ie = (e) => y.suspend(() => {
|
|
1544
1546
|
let t = e.contentType;
|
|
1545
|
-
if (!i.videoProbe || !(t.startsWith("video/") || t.startsWith("audio/"))) return
|
|
1547
|
+
if (!i.videoProbe || !(t.startsWith("video/") || t.startsWith("audio/"))) return y.succeed(null);
|
|
1546
1548
|
let n;
|
|
1547
1549
|
try {
|
|
1548
1550
|
n = i.videoProbe(e);
|
|
1549
1551
|
} catch {
|
|
1550
|
-
return
|
|
1552
|
+
return y.succeed(null);
|
|
1551
1553
|
}
|
|
1552
|
-
return
|
|
1554
|
+
return y.isEffect(n) ? n.pipe(y.catchAll(() => y.succeed(null))) : y.tryPromise({
|
|
1553
1555
|
try: () => Promise.resolve(n),
|
|
1554
1556
|
catch: () => null
|
|
1555
|
-
}).pipe(
|
|
1556
|
-
}),
|
|
1557
|
-
let t =
|
|
1558
|
-
if (t) return yield*
|
|
1559
|
-
if (e.claim !== void 0 && e.operationId === void 0) return yield*
|
|
1557
|
+
}).pipe(y.catchAll(() => y.succeed(null)));
|
|
1558
|
+
}), _ = (e) => y.gen(function* () {
|
|
1559
|
+
let t = kt(e.bytes, e.contentType, i.limits);
|
|
1560
|
+
if (t) return yield* y.fail(new n(t));
|
|
1561
|
+
if (e.claim !== void 0 && e.operationId === void 0) return yield* y.fail(new n({
|
|
1560
1562
|
reason: "claim-without-operation",
|
|
1561
1563
|
detail: "a put with a claim needs an operationId; the claim names this caller's hold on that operation's object"
|
|
1562
1564
|
}));
|
|
1563
1565
|
if (i.scan) {
|
|
1564
|
-
let t = yield*
|
|
1566
|
+
let t = yield* re({
|
|
1565
1567
|
bytes: e.bytes,
|
|
1566
1568
|
contentType: e.contentType,
|
|
1567
1569
|
...e.key ? { key: e.key } : {}
|
|
1568
1570
|
});
|
|
1569
|
-
if (!t.clean) return yield*
|
|
1571
|
+
if (!t.clean) return yield* y.fail(new r({ threat: t.threat ?? "unknown" }));
|
|
1570
1572
|
}
|
|
1571
|
-
let s = yield*
|
|
1573
|
+
let s = yield* y.promise(() => At(e.bytes, e.contentType, { normalize: i.normalizeImages ?? !1 })), l = s.bytes, u = yield* ie({
|
|
1572
1574
|
bytes: l,
|
|
1573
1575
|
contentType: e.contentType
|
|
1574
|
-
}), d = s.width ?? u?.width, f = s.height ?? u?.height,
|
|
1575
|
-
id:
|
|
1576
|
-
tenantId:
|
|
1576
|
+
}), d = s.width ?? u?.width, f = s.height ?? u?.height, te = s.placeholder ?? u?.poster, h = e.duration ?? u?.duration, ne = yield* y.promise(() => It(l)), g = e.tenantId ?? null, _ = e.visibility ?? "private", v = m(g, ne, yield* ee(e.key)), S = e.password ? yield* y.sync(() => rt(e.password)) : null, C = {
|
|
1577
|
+
id: Jt(),
|
|
1578
|
+
tenantId: g,
|
|
1577
1579
|
ownerId: e.ownerId ?? null,
|
|
1578
1580
|
bucket: c,
|
|
1579
|
-
key:
|
|
1581
|
+
key: v,
|
|
1580
1582
|
contentType: e.contentType,
|
|
1581
1583
|
size: l.byteLength,
|
|
1582
|
-
checksum:
|
|
1583
|
-
visibility:
|
|
1584
|
+
checksum: ne,
|
|
1585
|
+
visibility: _,
|
|
1584
1586
|
accessPolicy: e.access ?? null,
|
|
1585
|
-
passwordHash:
|
|
1587
|
+
passwordHash: S,
|
|
1586
1588
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1587
1589
|
...d === void 0 ? {} : { width: d },
|
|
1588
1590
|
...f === void 0 ? {} : { height: f },
|
|
1589
|
-
...
|
|
1590
|
-
...
|
|
1591
|
+
...te === void 0 ? {} : { placeholder: te },
|
|
1592
|
+
...h === void 0 ? {} : { duration: h },
|
|
1591
1593
|
...e.folder === void 0 ? {} : { folder: e.folder },
|
|
1592
1594
|
...e.tags === void 0 ? {} : { tags: e.tags },
|
|
1593
1595
|
...e.alt === void 0 ? {} : { alt: e.alt },
|
|
1594
1596
|
...e.caption === void 0 ? {} : { caption: e.caption },
|
|
1595
1597
|
...e.derivedFrom === void 0 ? {} : { derivedFrom: e.derivedFrom },
|
|
1596
1598
|
...e.kind === void 0 ? {} : { kind: e.kind }
|
|
1597
|
-
},
|
|
1599
|
+
}, w = i.transcode !== void 0 && i.autoTranscode !== !1, ae = (t) => w && t.derivedFrom == null && (e.contentType.startsWith("video/") || e.contentType.startsWith("audio/")) ? y.forkDaemon(x(t).pipe(y.ignore)) : y.void;
|
|
1598
1600
|
if (e.operationId !== void 0) {
|
|
1599
1601
|
let t = i.objects?.();
|
|
1600
|
-
if (t === void 0) return yield*
|
|
1602
|
+
if (t === void 0) return yield* y.fail(new n({
|
|
1601
1603
|
reason: "operation-store-unbound",
|
|
1602
1604
|
detail: "a put with an operationId needs a bound data store; the in-memory ref store cannot hold operation intents"
|
|
1603
1605
|
}));
|
|
1604
1606
|
let r = {
|
|
1605
|
-
tenantId:
|
|
1607
|
+
tenantId: g,
|
|
1606
1608
|
bucket: c,
|
|
1607
1609
|
operationId: e.operationId,
|
|
1608
|
-
checksum:
|
|
1609
|
-
logicalKey:
|
|
1610
|
-
fingerprint: yield*
|
|
1611
|
-
|
|
1610
|
+
checksum: ne,
|
|
1611
|
+
logicalKey: v,
|
|
1612
|
+
fingerprint: yield* y.promise(() => It(new TextEncoder().encode(JSON.stringify([
|
|
1613
|
+
ne,
|
|
1612
1614
|
e.contentType,
|
|
1613
|
-
|
|
1615
|
+
_,
|
|
1614
1616
|
e.access ?? null,
|
|
1615
1617
|
e.key ?? null,
|
|
1616
1618
|
e.ownerId ?? null,
|
|
@@ -1620,66 +1622,66 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1620
1622
|
e.caption ?? null,
|
|
1621
1623
|
e.derivedFrom ?? null,
|
|
1622
1624
|
e.kind ?? null,
|
|
1623
|
-
|
|
1625
|
+
h ?? null,
|
|
1624
1626
|
e.password !== void 0
|
|
1625
1627
|
]))))
|
|
1626
|
-
}, o = yield*
|
|
1628
|
+
}, o = yield* Ft({
|
|
1627
1629
|
metadata: t,
|
|
1628
1630
|
provider: {
|
|
1629
1631
|
...a,
|
|
1630
|
-
put: (e, t, n) => a.put(e, t, n).pipe(
|
|
1632
|
+
put: (e, t, n) => a.put(e, t, n).pipe(y.retry(p))
|
|
1631
1633
|
}
|
|
1632
1634
|
}).put({
|
|
1633
1635
|
identity: r,
|
|
1634
|
-
ref:
|
|
1636
|
+
ref: C,
|
|
1635
1637
|
bytes: l,
|
|
1636
1638
|
...i.quota === void 0 ? {} : { quota: i.quota },
|
|
1637
1639
|
...e.claim === void 0 ? {} : { claim: e.claim }
|
|
1638
1640
|
});
|
|
1639
|
-
return yield*
|
|
1641
|
+
return yield* ae(o.ref), {
|
|
1640
1642
|
...o.ref,
|
|
1641
1643
|
outcome: o.outcome
|
|
1642
1644
|
};
|
|
1643
1645
|
}
|
|
1644
|
-
let
|
|
1646
|
+
let oe = {
|
|
1645
1647
|
bytes: l.byteLength,
|
|
1646
1648
|
count: 1
|
|
1647
|
-
},
|
|
1648
|
-
if (!
|
|
1649
|
-
let e = i.quota ?? {}, t = e.maxCount !== void 0 &&
|
|
1650
|
-
return yield*
|
|
1649
|
+
}, se = yield* o.consumeUsage(g, oe, i.quota);
|
|
1650
|
+
if (!se.allowed) {
|
|
1651
|
+
let e = i.quota ?? {}, t = e.maxCount !== void 0 && se.count + 1 > e.maxCount ? `tenant object count ${se.count} + 1 exceeds max ${e.maxCount}` : `tenant usage ${se.bytes} + ${l.byteLength} bytes exceeds max ${e.maxBytes}`;
|
|
1652
|
+
return yield* y.fail(new n({
|
|
1651
1653
|
reason: "quota-exceeded",
|
|
1652
1654
|
detail: t
|
|
1653
1655
|
}));
|
|
1654
1656
|
}
|
|
1655
|
-
return yield* ((e) => e.pipe(
|
|
1657
|
+
return yield* ((e) => e.pipe(y.onExit((e) => b.isSuccess(e) ? y.void : o.delete(C.id).pipe(y.zipRight(o.releaseUsage(g, oe)), y.ignore))))(o.insert(C).pipe(y.zipRight(a.put(v, l, {
|
|
1656
1658
|
contentType: e.contentType,
|
|
1657
|
-
public:
|
|
1658
|
-
}).pipe(
|
|
1659
|
-
...
|
|
1659
|
+
public: _ === "public"
|
|
1660
|
+
}).pipe(y.retry(p))))), yield* ae(C), {
|
|
1661
|
+
...C,
|
|
1660
1662
|
outcome: "created"
|
|
1661
1663
|
};
|
|
1662
|
-
}),
|
|
1663
|
-
if (!i.transcode) return
|
|
1664
|
+
}), v = (e) => y.suspend(() => {
|
|
1665
|
+
if (!i.transcode) return y.succeed([]);
|
|
1664
1666
|
let t;
|
|
1665
1667
|
try {
|
|
1666
1668
|
t = i.transcode(e);
|
|
1667
1669
|
} catch {
|
|
1668
|
-
return
|
|
1670
|
+
return y.succeed([]);
|
|
1669
1671
|
}
|
|
1670
|
-
return
|
|
1672
|
+
return y.isEffect(t) ? t.pipe(y.catchAll(() => y.succeed([]))) : y.tryPromise({
|
|
1671
1673
|
try: () => Promise.resolve(t),
|
|
1672
1674
|
catch: () => []
|
|
1673
|
-
}).pipe(
|
|
1674
|
-
}),
|
|
1675
|
+
}).pipe(y.catchAll(() => y.succeed([])));
|
|
1676
|
+
}), x = (e) => y.gen(function* () {
|
|
1675
1677
|
if (!i.transcode || e.derivedFrom != null) return [];
|
|
1676
|
-
let t = yield* a.get(e.key).pipe(
|
|
1678
|
+
let t = yield* a.get(e.key).pipe(y.retry(p)), n = yield* v({
|
|
1677
1679
|
bytes: t.bytes,
|
|
1678
1680
|
contentType: e.contentType,
|
|
1679
1681
|
ref: e
|
|
1680
1682
|
}), r = [];
|
|
1681
1683
|
for (let t of n) {
|
|
1682
|
-
let n = yield*
|
|
1684
|
+
let n = yield* _({
|
|
1683
1685
|
bytes: t.bytes,
|
|
1684
1686
|
contentType: t.contentType,
|
|
1685
1687
|
tenantId: e.tenantId,
|
|
@@ -1692,14 +1694,14 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1692
1694
|
r.push(n);
|
|
1693
1695
|
}
|
|
1694
1696
|
return r;
|
|
1695
|
-
}),
|
|
1696
|
-
if (e.visibility === "public" || (yield*
|
|
1697
|
+
}), C = (e, t, n) => y.gen(function* () {
|
|
1698
|
+
if (e.visibility === "public" || (yield* dt(e, t, {
|
|
1697
1699
|
...l,
|
|
1698
1700
|
...n?.password === void 0 ? {} : { password: n.password }
|
|
1699
1701
|
}))) return !0;
|
|
1700
|
-
let r = yield*
|
|
1701
|
-
return
|
|
1702
|
-
}),
|
|
1702
|
+
let r = yield* ht(t, l);
|
|
1703
|
+
return mt(yield* s.listByRef(e.id), t, r, n?.permission ?? "read", Date.now());
|
|
1704
|
+
}), ae = (e) => {
|
|
1703
1705
|
if (e.visibility === "public") {
|
|
1704
1706
|
let t = a.publicUrl?.(e.key);
|
|
1705
1707
|
if (t != null) return t;
|
|
@@ -1707,60 +1709,60 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1707
1709
|
return f(e.id);
|
|
1708
1710
|
};
|
|
1709
1711
|
return {
|
|
1710
|
-
put:
|
|
1711
|
-
get: (e, t) =>
|
|
1712
|
+
put: _,
|
|
1713
|
+
get: (e, t) => g(e, t?.tenantId).pipe(y.flatMap((e) => a.get(e.key).pipe(y.retry(p), y.map((t) => ({
|
|
1712
1714
|
bytes: t.bytes,
|
|
1713
1715
|
ref: e
|
|
1714
1716
|
}))))),
|
|
1715
|
-
getStream: (e, t) =>
|
|
1717
|
+
getStream: (e, t) => g(e, t?.tenantId).pipe(y.map((e) => ({
|
|
1716
1718
|
ref: e,
|
|
1717
|
-
stream:
|
|
1719
|
+
stream: w.unwrap(y.suspend(() => a.getStream ? a.getStream(e.key).pipe(y.retry(p), y.map((e) => e.stream)) : a.get(e.key).pipe(y.retry(p), y.map((e) => w.make(e.bytes)))))
|
|
1718
1720
|
}))),
|
|
1719
|
-
getRange: (e, n, r) =>
|
|
1721
|
+
getRange: (e, n, r) => g(e, r?.tenantId).pipe(y.flatMap((e) => {
|
|
1720
1722
|
let r = e.size, i = Math.max(0, Math.trunc(n.start));
|
|
1721
|
-
if (r > 0 && i >= r) return
|
|
1723
|
+
if (r > 0 && i >= r) return y.fail(new t({
|
|
1722
1724
|
provider: a.name,
|
|
1723
1725
|
message: `range start ${i} past end ${r}`,
|
|
1724
1726
|
transient: !1,
|
|
1725
1727
|
status: 416
|
|
1726
1728
|
}));
|
|
1727
1729
|
let o = Math.min(Math.trunc(n.endInclusive), Math.max(0, r - 1));
|
|
1728
|
-
return o < i ?
|
|
1730
|
+
return o < i ? y.fail(new t({
|
|
1729
1731
|
provider: a.name,
|
|
1730
1732
|
message: `empty range ${i}-${o}`,
|
|
1731
1733
|
transient: !1,
|
|
1732
1734
|
status: 416
|
|
1733
|
-
})) : (a.getRange ? a.getRange(e.key, i, o).pipe(
|
|
1735
|
+
})) : (a.getRange ? a.getRange(e.key, i, o).pipe(y.retry(p)) : a.get(e.key).pipe(y.retry(p), y.map((e) => e.bytes.subarray(i, o + 1)))).pipe(y.map((t) => ({
|
|
1734
1736
|
bytes: t,
|
|
1735
1737
|
ref: e,
|
|
1736
1738
|
totalSize: r
|
|
1737
1739
|
})));
|
|
1738
1740
|
})),
|
|
1739
|
-
getUrl: (e, t) =>
|
|
1740
|
-
head: (e, t) => o.getById(e).pipe(
|
|
1741
|
-
delete: (e, t) =>
|
|
1741
|
+
getUrl: (e, t) => g(e, t?.tenantId).pipe(y.flatMap((e) => e.visibility === "public" ? y.succeed(ae(e)) : a.presigns ? a.getUrl(e.key, t?.expiresInSec ?? d) : y.succeed(f(e.id)))),
|
|
1742
|
+
head: (e, t) => o.getById(e).pipe(y.flatMap((e) => e ? h(e, t?.tenantId).pipe(y.map((e) => e)) : y.succeed(null))),
|
|
1743
|
+
delete: (e, t) => ne(e, t?.tenantId, t?.claim).pipe(y.flatMap((n) => n ? y.void : g(e, t?.tenantId).pipe(y.flatMap((t) => s.deleteByRef(e).pipe(y.flatMap(() => o.delete(e)), y.flatMap((e) => e ? o.countByKey(t.bucket, t.key).pipe(y.flatMap((e) => e === 0 ? a.delete(t.key).pipe(y.retry(p)) : y.void), y.flatMap(() => o.releaseUsage(t.tenantId, {
|
|
1742
1744
|
bytes: t.size,
|
|
1743
1745
|
count: 1
|
|
1744
|
-
}))) :
|
|
1745
|
-
mintUrl: (n, r,
|
|
1746
|
-
let
|
|
1746
|
+
}))) : y.void), y.asVoid))))),
|
|
1747
|
+
mintUrl: (n, r, s) => y.gen(function* () {
|
|
1748
|
+
let c = yield* o.getById(n).pipe(y.flatMap((e) => e ? y.succeed(e) : y.fail(new t({
|
|
1747
1749
|
provider: a.name,
|
|
1748
1750
|
message: `no ref '${n}'`,
|
|
1749
1751
|
transient: !1,
|
|
1750
1752
|
status: 404
|
|
1751
1753
|
}))));
|
|
1752
|
-
if (
|
|
1753
|
-
if (!(yield*
|
|
1754
|
+
if (c.visibility === "public") return ae(c);
|
|
1755
|
+
if (!(yield* C(c, r, s?.password === void 0 ? {} : { password: s.password }))) return yield* y.fail(new e({
|
|
1754
1756
|
refId: n,
|
|
1755
1757
|
reason: "access denied"
|
|
1756
1758
|
}));
|
|
1757
|
-
let
|
|
1758
|
-
if (a.presigns) return yield* a.getUrl(
|
|
1759
|
-
let
|
|
1760
|
-
return `${f(
|
|
1759
|
+
let l = s?.expiresInSec ?? d;
|
|
1760
|
+
if (a.presigns) return yield* a.getUrl(c.key, l);
|
|
1761
|
+
let u = yield* y.sync(() => gt(c.id, l, void 0, i.httpPath ?? "/_voltro/storage"));
|
|
1762
|
+
return `${f(c.id)}?t=${u}`;
|
|
1761
1763
|
}),
|
|
1762
|
-
mintUploadUrl: (e) =>
|
|
1763
|
-
if (!a.getUploadUrl) return yield*
|
|
1764
|
+
mintUploadUrl: (e) => y.gen(function* () {
|
|
1765
|
+
if (!a.getUploadUrl) return yield* y.fail(new t({
|
|
1764
1766
|
provider: a.name,
|
|
1765
1767
|
message: `provider '${a.name}' does not support presigned uploads`,
|
|
1766
1768
|
transient: !1,
|
|
@@ -1769,10 +1771,10 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1769
1771
|
let n = m(e.tenantId ?? null, "", yield* ee(e.key));
|
|
1770
1772
|
return yield* a.getUploadUrl(n, e.expiresInSec ?? d, e.contentType);
|
|
1771
1773
|
}),
|
|
1772
|
-
checkAccess:
|
|
1773
|
-
grant: (e) =>
|
|
1774
|
+
checkAccess: C,
|
|
1775
|
+
grant: (e) => y.gen(function* () {
|
|
1774
1776
|
let t = {
|
|
1775
|
-
id:
|
|
1777
|
+
id: Yt(),
|
|
1776
1778
|
refId: e.refId,
|
|
1777
1779
|
principalType: e.principalType,
|
|
1778
1780
|
principalId: e.principalId,
|
|
@@ -1783,7 +1785,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1783
1785
|
};
|
|
1784
1786
|
return yield* s.insert(t), t;
|
|
1785
1787
|
}),
|
|
1786
|
-
listRefs: (e) =>
|
|
1788
|
+
listRefs: (e) => y.suspend(() => {
|
|
1787
1789
|
let t = Math.min(500, Math.max(1, Math.trunc(e?.limit ?? 50))), n = Math.max(0, Math.trunc(e?.offset ?? 0)), r = {
|
|
1788
1790
|
tenantId: e && "tenantId" in e ? e.tenantId : void 0,
|
|
1789
1791
|
folder: e?.folder,
|
|
@@ -1793,7 +1795,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1793
1795
|
limit: t + 1,
|
|
1794
1796
|
offset: n
|
|
1795
1797
|
};
|
|
1796
|
-
return o.listRefs(r).pipe(
|
|
1798
|
+
return o.listRefs(r).pipe(y.map((e) => {
|
|
1797
1799
|
let r = e.length > t;
|
|
1798
1800
|
return {
|
|
1799
1801
|
refs: r ? e.slice(0, t) : e,
|
|
@@ -1805,7 +1807,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1805
1807
|
getGrant: (e) => s.getById(e),
|
|
1806
1808
|
listGrants: (e) => s.listByRef(e),
|
|
1807
1809
|
usage: (e) => o.usageByTenant(e),
|
|
1808
|
-
sweepOrphans: (e) =>
|
|
1810
|
+
sweepOrphans: (e) => y.gen(function* () {
|
|
1809
1811
|
let t = e?.limit ?? 1e3, n = e?.dryRun ?? !1, r = yield* o.listRecent(t), i = [];
|
|
1810
1812
|
for (let e of r) if ((yield* a.head(e.key)) === null) {
|
|
1811
1813
|
if (!n) {
|
|
@@ -1822,9 +1824,9 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1822
1824
|
removed: i
|
|
1823
1825
|
};
|
|
1824
1826
|
}),
|
|
1825
|
-
ingestUrl: (e, t) =>
|
|
1826
|
-
let n = yield*
|
|
1827
|
-
return yield*
|
|
1827
|
+
ingestUrl: (e, t) => Pt(y.gen(function* () {
|
|
1828
|
+
let n = yield* Nt(e, i.limits?.maxBytes);
|
|
1829
|
+
return yield* _({
|
|
1828
1830
|
bytes: n.bytes,
|
|
1829
1831
|
contentType: t?.contentType ?? n.contentType,
|
|
1830
1832
|
...t?.tenantId === void 0 ? {} : { tenantId: t.tenantId },
|
|
@@ -1838,24 +1840,24 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1838
1840
|
...t?.caption === void 0 ? {} : { caption: t.caption }
|
|
1839
1841
|
});
|
|
1840
1842
|
}), t?.abortSignal),
|
|
1841
|
-
mintPresignedUpload: (e) =>
|
|
1842
|
-
if (!a.getUploadUrl) return yield*
|
|
1843
|
+
mintPresignedUpload: (e) => y.gen(function* () {
|
|
1844
|
+
if (!a.getUploadUrl) return yield* y.fail(new t({
|
|
1843
1845
|
provider: a.name,
|
|
1844
1846
|
message: `provider '${a.name}' does not support presigned uploads`,
|
|
1845
1847
|
transient: !1,
|
|
1846
1848
|
status: 400
|
|
1847
1849
|
}));
|
|
1848
|
-
let n = e.expiresInSec ?? d, r = `_incoming/${
|
|
1850
|
+
let n = e.expiresInSec ?? d, r = `_incoming/${O({
|
|
1849
1851
|
kind: "typeid",
|
|
1850
1852
|
prefix: "up"
|
|
1851
|
-
},
|
|
1853
|
+
}, V)}`, i = m(e.tenantId ?? null, "", r);
|
|
1852
1854
|
return {
|
|
1853
1855
|
uploadUrl: yield* a.getUploadUrl(i, n, e.contentType),
|
|
1854
1856
|
key: i,
|
|
1855
1857
|
expiresInSec: n
|
|
1856
1858
|
};
|
|
1857
1859
|
}),
|
|
1858
|
-
finalizeUpload: (e) => a.get(e.key).pipe(
|
|
1860
|
+
finalizeUpload: (e) => a.get(e.key).pipe(y.retry(p), y.flatMap((t) => _({
|
|
1859
1861
|
bytes: t.bytes,
|
|
1860
1862
|
contentType: e.contentType,
|
|
1861
1863
|
...e.tenantId === void 0 ? {} : { tenantId: e.tenantId },
|
|
@@ -1865,12 +1867,12 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1865
1867
|
...e.tags === void 0 ? {} : { tags: e.tags },
|
|
1866
1868
|
...e.alt === void 0 ? {} : { alt: e.alt },
|
|
1867
1869
|
...e.caption === void 0 ? {} : { caption: e.caption }
|
|
1868
|
-
})),
|
|
1869
|
-
putResumableChunk: (e) => a.put(
|
|
1870
|
-
resumableStatus: (e) =>
|
|
1870
|
+
})), y.ensuring(a.delete(e.key).pipe(y.retry(p), y.ignore))),
|
|
1871
|
+
putResumableChunk: (e) => a.put(te(e.tenantId ?? null, e.uploadId, e.index), e.bytes, { contentType: "application/octet-stream" }).pipe(y.retry(p), y.asVoid),
|
|
1872
|
+
resumableStatus: (e) => y.gen(function* () {
|
|
1871
1873
|
let t = 0, n = 0;
|
|
1872
1874
|
for (; t < 1e6;) {
|
|
1873
|
-
let r = yield* a.head(
|
|
1875
|
+
let r = yield* a.head(te(e.tenantId ?? null, e.uploadId, t)).pipe(y.retry(p), y.catchAll(() => y.succeed(null)));
|
|
1874
1876
|
if (r === null) break;
|
|
1875
1877
|
n += r.size, t += 1;
|
|
1876
1878
|
}
|
|
@@ -1879,17 +1881,54 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1879
1881
|
nextIndex: t
|
|
1880
1882
|
};
|
|
1881
1883
|
}),
|
|
1882
|
-
finalizeResumable: (e) =>
|
|
1883
|
-
let
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
let o =
|
|
1891
|
-
|
|
1892
|
-
|
|
1884
|
+
finalizeResumable: (e) => y.gen(function* () {
|
|
1885
|
+
let r = i.limits?.maxBytes ?? 2 ** 53 - 1;
|
|
1886
|
+
if (!Number.isSafeInteger(r) || r < 0 || !Number.isSafeInteger(e.count) || e.count < 0) return yield* y.fail(new t({
|
|
1887
|
+
provider: a.name,
|
|
1888
|
+
message: "resumable count and limits.maxBytes must be non-negative safe integers",
|
|
1889
|
+
transient: !1,
|
|
1890
|
+
status: 400
|
|
1891
|
+
}));
|
|
1892
|
+
let o = (t) => te(e.tenantId ?? null, e.uploadId, t), s = y.gen(function* () {
|
|
1893
|
+
for (let t = 0; t < e.count; t++) yield* a.delete(o(t)).pipe(y.retry(p), y.ignore);
|
|
1894
|
+
}), c = () => new n({
|
|
1895
|
+
reason: "too-large",
|
|
1896
|
+
detail: `resumable upload exceeds ${r}-byte limit`
|
|
1897
|
+
}), l = yield* y.gen(function* () {
|
|
1898
|
+
let n = 0;
|
|
1899
|
+
for (let i = 0; i < e.count; i++) {
|
|
1900
|
+
let e = yield* a.head(o(i)).pipe(y.retry(p));
|
|
1901
|
+
if (e === null) return yield* y.fail(new t({
|
|
1902
|
+
provider: a.name,
|
|
1903
|
+
message: `no resumable chunk at '${o(i)}'`,
|
|
1904
|
+
transient: !1,
|
|
1905
|
+
status: 404
|
|
1906
|
+
}));
|
|
1907
|
+
if (!Number.isSafeInteger(e.size) || e.size < 0) return yield* y.fail(new t({
|
|
1908
|
+
provider: a.name,
|
|
1909
|
+
message: "resumable chunk metadata has an invalid size",
|
|
1910
|
+
transient: !1
|
|
1911
|
+
}));
|
|
1912
|
+
if (e.size > r - n) return yield* y.fail(c());
|
|
1913
|
+
n += e.size;
|
|
1914
|
+
}
|
|
1915
|
+
let i = /* @__PURE__ */ new Uint8Array(), s = 0;
|
|
1916
|
+
for (let t = 0; t < e.count; t++) {
|
|
1917
|
+
let e = yield* je(a, o(t)).pipe(y.retry(p));
|
|
1918
|
+
yield* w.runForEach(e.stream, (e) => y.gen(function* () {
|
|
1919
|
+
if (e.byteLength > r - s) return yield* y.fail(c());
|
|
1920
|
+
let t = s + e.byteLength;
|
|
1921
|
+
if (t > i.byteLength) {
|
|
1922
|
+
let e = new Uint8Array(Math.min(r, Math.max(65536, i.byteLength * 2, t)));
|
|
1923
|
+
e.set(i.subarray(0, s)), i = e;
|
|
1924
|
+
}
|
|
1925
|
+
i.set(e, s), s = t;
|
|
1926
|
+
}));
|
|
1927
|
+
}
|
|
1928
|
+
return i.subarray(0, s);
|
|
1929
|
+
}).pipe(y.tapError((e) => e._tag === "StorageRejected" ? s : y.void));
|
|
1930
|
+
return yield* _({
|
|
1931
|
+
bytes: l,
|
|
1893
1932
|
contentType: e.contentType,
|
|
1894
1933
|
...e.tenantId === void 0 ? {} : { tenantId: e.tenantId },
|
|
1895
1934
|
...e.ownerId === void 0 ? {} : { ownerId: e.ownerId },
|
|
@@ -1898,49 +1937,49 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1898
1937
|
...e.tags === void 0 ? {} : { tags: e.tags },
|
|
1899
1938
|
...e.alt === void 0 ? {} : { alt: e.alt },
|
|
1900
1939
|
...e.caption === void 0 ? {} : { caption: e.caption }
|
|
1901
|
-
}).pipe(
|
|
1940
|
+
}).pipe(y.ensuring(s));
|
|
1902
1941
|
}),
|
|
1903
|
-
transcode: (e, t) =>
|
|
1904
|
-
renditions: (e, t) =>
|
|
1905
|
-
beginMultipartUpload: (e) =>
|
|
1906
|
-
if (!a.createMultipartUpload || !a.presignUploadPart || !a.completeMultipartUpload) return yield*
|
|
1942
|
+
transcode: (e, t) => g(e, t?.tenantId).pipe(y.flatMap((e) => x(e))),
|
|
1943
|
+
renditions: (e, t) => g(e, t?.tenantId).pipe(y.flatMap(() => o.listByDerivedFrom(e))),
|
|
1944
|
+
beginMultipartUpload: (e) => y.gen(function* () {
|
|
1945
|
+
if (!a.createMultipartUpload || !a.presignUploadPart || !a.completeMultipartUpload) return yield* y.fail(new t({
|
|
1907
1946
|
provider: a.name,
|
|
1908
1947
|
message: `provider '${a.name}' does not support multipart uploads`,
|
|
1909
1948
|
transient: !1,
|
|
1910
1949
|
status: 400
|
|
1911
1950
|
}));
|
|
1912
|
-
let n = m(e.tenantId ?? null, "", `multipart/${
|
|
1951
|
+
let n = m(e.tenantId ?? null, "", `multipart/${O({
|
|
1913
1952
|
kind: "typeid",
|
|
1914
1953
|
prefix: "mp"
|
|
1915
|
-
},
|
|
1954
|
+
}, V)}`);
|
|
1916
1955
|
return {
|
|
1917
1956
|
uploadId: (yield* a.createMultipartUpload(n, e.contentType, { public: (e.visibility ?? "private") === "public" })).uploadId,
|
|
1918
1957
|
key: n
|
|
1919
1958
|
};
|
|
1920
1959
|
}),
|
|
1921
|
-
signMultipartPart: (e) =>
|
|
1960
|
+
signMultipartPart: (e) => y.suspend(() => a.presignUploadPart ? a.presignUploadPart(e.key, e.uploadId, e.partNumber, e.expiresInSec ?? d) : y.fail(new t({
|
|
1922
1961
|
provider: a.name,
|
|
1923
1962
|
message: "provider does not support multipart uploads",
|
|
1924
1963
|
transient: !1,
|
|
1925
1964
|
status: 400
|
|
1926
1965
|
}))),
|
|
1927
|
-
completeMultipart: (e) =>
|
|
1928
|
-
if (!a.completeMultipartUpload) return yield*
|
|
1966
|
+
completeMultipart: (e) => y.gen(function* () {
|
|
1967
|
+
if (!a.completeMultipartUpload) return yield* y.fail(new t({
|
|
1929
1968
|
provider: a.name,
|
|
1930
1969
|
message: "provider does not support multipart uploads",
|
|
1931
1970
|
transient: !1,
|
|
1932
1971
|
status: 400
|
|
1933
1972
|
}));
|
|
1934
|
-
let r = yield* a.completeMultipartUpload(e.key, e.uploadId, e.parts), s = yield* a.head(e.key).pipe(
|
|
1973
|
+
let r = yield* a.completeMultipartUpload(e.key, e.uploadId, e.parts), s = yield* a.head(e.key).pipe(y.retry(p)), l = s?.size ?? 0, u = (r.etag ?? s?.etag ?? "").replace(/"/g, ""), d = e.tenantId ?? null, f = {
|
|
1935
1974
|
bytes: l,
|
|
1936
1975
|
count: 1
|
|
1937
1976
|
};
|
|
1938
|
-
if (!(yield* o.consumeUsage(d, f, i.quota)).allowed) return yield* a.delete(e.key).pipe(
|
|
1977
|
+
if (!(yield* o.consumeUsage(d, f, i.quota)).allowed) return yield* a.delete(e.key).pipe(y.retry(p), y.ignore), yield* y.fail(new n({
|
|
1939
1978
|
reason: "quota-exceeded",
|
|
1940
1979
|
detail: `multipart upload of ${l} bytes exceeds tenant quota`
|
|
1941
1980
|
}));
|
|
1942
1981
|
let m = {
|
|
1943
|
-
id:
|
|
1982
|
+
id: Jt(),
|
|
1944
1983
|
tenantId: e.tenantId ?? null,
|
|
1945
1984
|
ownerId: e.ownerId ?? null,
|
|
1946
1985
|
bucket: c,
|
|
@@ -1957,111 +1996,111 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
1957
1996
|
...e.alt === void 0 ? {} : { alt: e.alt },
|
|
1958
1997
|
...e.caption === void 0 ? {} : { caption: e.caption }
|
|
1959
1998
|
};
|
|
1960
|
-
return yield* o.insert(m).pipe(
|
|
1999
|
+
return yield* o.insert(m).pipe(y.onExit((e) => b.isSuccess(e) ? y.void : o.releaseUsage(d, f).pipe(y.ignore))), m;
|
|
1961
2000
|
}),
|
|
1962
|
-
abortMultipart: (e) =>
|
|
2001
|
+
abortMultipart: (e) => y.suspend(() => a.abortMultipartUpload ? a.abortMultipartUpload(e.key, e.uploadId).pipe(y.retry(p)) : y.void)
|
|
1963
2002
|
};
|
|
1964
|
-
},
|
|
1965
|
-
|
|
1966
|
-
id:
|
|
1967
|
-
nonce:
|
|
2003
|
+
}, Zt = (e) => x.succeed(i, Xt(e)), Qt = "_voltro_storage_operation_locks", Z = "_voltro_storage_object_heads", Q = "_voltro_storage_operations", $t = "_voltro_storage_object_claims", en = [
|
|
2004
|
+
N(Qt, {
|
|
2005
|
+
id: P().maxLength(64),
|
|
2006
|
+
nonce: P()
|
|
1968
2007
|
}).primaryKey(["id"]).nonReactive(),
|
|
1969
|
-
|
|
1970
|
-
id:
|
|
1971
|
-
generation:
|
|
1972
|
-
key:
|
|
1973
|
-
reservations:
|
|
2008
|
+
N(Z, {
|
|
2009
|
+
id: P().maxLength(64),
|
|
2010
|
+
generation: P(),
|
|
2011
|
+
key: P(),
|
|
2012
|
+
reservations: k()
|
|
1974
2013
|
}).primaryKey(["id"]).nonReactive(),
|
|
1975
|
-
|
|
1976
|
-
id:
|
|
1977
|
-
objectId:
|
|
1978
|
-
fingerprint:
|
|
1979
|
-
generation:
|
|
1980
|
-
key:
|
|
1981
|
-
refId:
|
|
1982
|
-
state:
|
|
1983
|
-
deleteKey:
|
|
2014
|
+
N(Q, {
|
|
2015
|
+
id: P().maxLength(64),
|
|
2016
|
+
objectId: P().maxLength(64),
|
|
2017
|
+
fingerprint: P().maxLength(64),
|
|
2018
|
+
generation: P(),
|
|
2019
|
+
key: P(),
|
|
2020
|
+
refId: P(),
|
|
2021
|
+
state: P(),
|
|
2022
|
+
deleteKey: P().nullable()
|
|
1984
2023
|
}).primaryKey(["id"]).nonReactive(),
|
|
1985
|
-
|
|
1986
|
-
id:
|
|
1987
|
-
operationId:
|
|
1988
|
-
claim:
|
|
2024
|
+
N($t, {
|
|
2025
|
+
id: P().maxLength(64),
|
|
2026
|
+
operationId: P().maxLength(64),
|
|
2027
|
+
claim: P()
|
|
1989
2028
|
}).primaryKey(["id"]).nonReactive()
|
|
1990
|
-
],
|
|
1991
|
-
id:
|
|
1992
|
-
objectId:
|
|
1993
|
-
fingerprint:
|
|
1994
|
-
generation:
|
|
1995
|
-
key:
|
|
1996
|
-
refId:
|
|
1997
|
-
state:
|
|
1998
|
-
deleteKey:
|
|
1999
|
-
}),
|
|
2000
|
-
id:
|
|
2001
|
-
generation:
|
|
2002
|
-
key:
|
|
2003
|
-
reservations:
|
|
2004
|
-
}),
|
|
2029
|
+
], tn = C.Struct({
|
|
2030
|
+
id: C.String,
|
|
2031
|
+
objectId: C.String,
|
|
2032
|
+
fingerprint: C.String,
|
|
2033
|
+
generation: C.String,
|
|
2034
|
+
key: C.String,
|
|
2035
|
+
refId: C.String,
|
|
2036
|
+
state: C.Literal("reserved", "ready", "deleting", "deleted"),
|
|
2037
|
+
deleteKey: C.NullOr(C.String)
|
|
2038
|
+
}), nn = C.Struct({
|
|
2039
|
+
id: C.String,
|
|
2040
|
+
generation: C.String,
|
|
2041
|
+
key: C.String,
|
|
2042
|
+
reservations: C.Int.pipe(C.nonNegative())
|
|
2043
|
+
}), rn = (e) => he("sha256").update(JSON.stringify(e)).digest("hex"), an = (e, t) => rn([e, t]), on = (e) => {
|
|
2005
2044
|
if (!e.bucket || !e.operationId || !e.logicalKey || !/^[a-f0-9]{64}$/.test(e.fingerprint) || !/^[a-f0-9]{64}$/.test(e.checksum)) throw Error("Storage operation requires a bucket, operation identity, key and SHA-256 fingerprint");
|
|
2006
2045
|
return {
|
|
2007
|
-
id:
|
|
2046
|
+
id: rn([
|
|
2008
2047
|
e.bucket,
|
|
2009
2048
|
e.tenantId,
|
|
2010
2049
|
e.operationId
|
|
2011
2050
|
]),
|
|
2012
|
-
objectId:
|
|
2051
|
+
objectId: rn([
|
|
2013
2052
|
e.bucket,
|
|
2014
2053
|
e.tenantId,
|
|
2015
2054
|
e.logicalKey,
|
|
2016
2055
|
e.checksum
|
|
2017
2056
|
]),
|
|
2018
|
-
lockId:
|
|
2057
|
+
lockId: rn([e.tenantId])
|
|
2019
2058
|
};
|
|
2020
|
-
},
|
|
2021
|
-
let { lockId: r } =
|
|
2022
|
-
return await e.insertIgnoreWithOutcome(
|
|
2059
|
+
}, sn = async (e, t, n) => {
|
|
2060
|
+
let { lockId: r } = on(t);
|
|
2061
|
+
return await e.insertIgnoreWithOutcome(Qt, {
|
|
2023
2062
|
id: r,
|
|
2024
|
-
nonce:
|
|
2063
|
+
nonce: ge()
|
|
2025
2064
|
}, { conflictColumns: ["id"] }), e.transactional(async (e) => {
|
|
2026
2065
|
if ((await e.query({
|
|
2027
|
-
table:
|
|
2028
|
-
predicate:
|
|
2066
|
+
table: Qt,
|
|
2067
|
+
predicate: D("id", r),
|
|
2029
2068
|
lock: "update",
|
|
2030
2069
|
order: [],
|
|
2031
2070
|
take: 1,
|
|
2032
2071
|
skip: void 0,
|
|
2033
2072
|
projection: void 0
|
|
2034
|
-
})).length !== 1 || await e.update(
|
|
2073
|
+
})).length !== 1 || await e.update(Qt, r, { nonce: ge() }) === null) throw Error("Storage operation lock is unavailable");
|
|
2035
2074
|
return n(e);
|
|
2036
2075
|
});
|
|
2037
2076
|
}, $ = async (e, t) => {
|
|
2038
|
-
let r =
|
|
2039
|
-
table:
|
|
2040
|
-
predicate:
|
|
2077
|
+
let r = on(t), i = await e.query({
|
|
2078
|
+
table: Q,
|
|
2079
|
+
predicate: D("id", r.id),
|
|
2041
2080
|
order: [],
|
|
2042
2081
|
take: 1,
|
|
2043
2082
|
skip: void 0,
|
|
2044
2083
|
projection: void 0
|
|
2045
2084
|
});
|
|
2046
2085
|
if (!i[0]) return;
|
|
2047
|
-
let a =
|
|
2086
|
+
let a = C.decodeUnknownSync(tn)(i[0]);
|
|
2048
2087
|
if (a.fingerprint !== t.fingerprint || a.objectId !== r.objectId) throw new n({
|
|
2049
2088
|
reason: "operation-identity-reused",
|
|
2050
2089
|
detail: `storage operation '${t.operationId}' was already used with different inputs`
|
|
2051
2090
|
});
|
|
2052
2091
|
return a;
|
|
2053
|
-
},
|
|
2092
|
+
}, cn = async (e, t) => {
|
|
2054
2093
|
let n = await $(e, t);
|
|
2055
2094
|
if (n) return n;
|
|
2056
|
-
let { id: r, objectId: i } =
|
|
2057
|
-
table:
|
|
2058
|
-
predicate:
|
|
2095
|
+
let { id: r, objectId: i } = on(t), a = await e.query({
|
|
2096
|
+
table: Z,
|
|
2097
|
+
predicate: D("id", i),
|
|
2059
2098
|
order: [],
|
|
2060
2099
|
take: 1,
|
|
2061
2100
|
skip: void 0,
|
|
2062
2101
|
projection: void 0
|
|
2063
|
-
}), o = a[0] ?
|
|
2064
|
-
o ? await e.update(
|
|
2102
|
+
}), o = a[0] ? C.decodeUnknownSync(nn)(a[0]) : void 0, s = o?.generation ?? ge(), c = o?.key ?? `${t.logicalKey}/g-${s}`;
|
|
2103
|
+
o ? await e.update(Z, i, { reservations: o.reservations + 1 }) : await e.insert(Z, {
|
|
2065
2104
|
id: i,
|
|
2066
2105
|
generation: s,
|
|
2067
2106
|
key: c,
|
|
@@ -2073,35 +2112,35 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2073
2112
|
fingerprint: t.fingerprint,
|
|
2074
2113
|
generation: s,
|
|
2075
2114
|
key: c,
|
|
2076
|
-
refId: `file_${
|
|
2115
|
+
refId: `file_${ge()}`,
|
|
2077
2116
|
state: "reserved",
|
|
2078
2117
|
deleteKey: null
|
|
2079
2118
|
};
|
|
2080
|
-
return await e.insert(
|
|
2081
|
-
},
|
|
2119
|
+
return await e.insert(Q, l), l;
|
|
2120
|
+
}, ln = async (e, t) => {
|
|
2082
2121
|
let n = await $(e, t);
|
|
2083
2122
|
if (!n) throw Error("Storage operation is missing");
|
|
2084
2123
|
if (n.state === "deleting" || n.state === "deleted") throw Error("Deleted storage operation cannot be confirmed by a late put");
|
|
2085
|
-
return await e.update(
|
|
2124
|
+
return await e.update(Q, n.id, { state: "ready" }), {
|
|
2086
2125
|
...n,
|
|
2087
2126
|
state: "ready"
|
|
2088
2127
|
};
|
|
2089
|
-
},
|
|
2128
|
+
}, un = async (e, t) => {
|
|
2090
2129
|
let n = await $(e, t);
|
|
2091
2130
|
if (!n) throw Error("Storage operation is missing");
|
|
2092
2131
|
if (n.state === "deleting" || n.state === "deleted") return n;
|
|
2093
2132
|
if (n.state !== "ready") throw Error("An unconfirmed put cannot be deleted");
|
|
2094
2133
|
let r = await e.query({
|
|
2095
|
-
table:
|
|
2096
|
-
predicate:
|
|
2134
|
+
table: Z,
|
|
2135
|
+
predicate: D("id", n.objectId),
|
|
2097
2136
|
order: [],
|
|
2098
2137
|
take: 1,
|
|
2099
2138
|
skip: void 0,
|
|
2100
2139
|
projection: void 0
|
|
2101
|
-
}), i = r[0] ?
|
|
2140
|
+
}), i = r[0] ? C.decodeUnknownSync(nn)(r[0]) : void 0;
|
|
2102
2141
|
if (!i || i.generation !== n.generation || i.reservations < 1) throw Error("Storage object generation does not own its reservation");
|
|
2103
2142
|
let a = i.reservations === 1 ? i.key : null;
|
|
2104
|
-
return a === null ? await e.update(
|
|
2143
|
+
return a === null ? await e.update(Z, i.id, { reservations: i.reservations - 1 }) : await e.delete(Z, i.id), await e.update(Q, n.id, {
|
|
2105
2144
|
state: "deleting",
|
|
2106
2145
|
deleteKey: a
|
|
2107
2146
|
}), {
|
|
@@ -2109,46 +2148,46 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2109
2148
|
state: "deleting",
|
|
2110
2149
|
deleteKey: a
|
|
2111
2150
|
};
|
|
2112
|
-
},
|
|
2151
|
+
}, dn = async (e, t) => {
|
|
2113
2152
|
let n = await $(e, t);
|
|
2114
2153
|
if (!n || n.state !== "deleting" && n.state !== "deleted") throw Error("Storage deletion has not been accepted");
|
|
2115
|
-
return n.state !== "deleted" && (await e.update(
|
|
2116
|
-
},
|
|
2154
|
+
return n.state !== "deleted" && (await e.update(Q, n.id, { state: "deleted" }), !0);
|
|
2155
|
+
}, fn = async (e, t, n) => {
|
|
2117
2156
|
if (!n) throw Error("Storage object claim must be a non-empty string");
|
|
2118
|
-
await e.insertIgnoreWithOutcome(
|
|
2119
|
-
id:
|
|
2157
|
+
await e.insertIgnoreWithOutcome($t, {
|
|
2158
|
+
id: an(t, n),
|
|
2120
2159
|
operationId: t,
|
|
2121
2160
|
claim: n
|
|
2122
2161
|
}, { conflictColumns: ["id"] });
|
|
2123
|
-
},
|
|
2124
|
-
let r =
|
|
2162
|
+
}, pn = async (e, t, n) => {
|
|
2163
|
+
let r = an(t, n);
|
|
2125
2164
|
return {
|
|
2126
|
-
held: await e.delete(
|
|
2165
|
+
held: await e.delete($t, r),
|
|
2127
2166
|
others: (await e.query({
|
|
2128
|
-
table:
|
|
2129
|
-
predicate: D(
|
|
2167
|
+
table: $t,
|
|
2168
|
+
predicate: T(D("operationId", t), M("claim", n)),
|
|
2130
2169
|
order: [],
|
|
2131
2170
|
take: 1,
|
|
2132
2171
|
skip: void 0,
|
|
2133
2172
|
projection: void 0
|
|
2134
2173
|
})).length > 0
|
|
2135
2174
|
};
|
|
2136
|
-
},
|
|
2137
|
-
id:
|
|
2138
|
-
refId:
|
|
2139
|
-
identity:
|
|
2140
|
-
ref:
|
|
2141
|
-
}).primaryKey(["id"]).unique("storagePutRef", ["refId"]).nonReactive(),
|
|
2142
|
-
tenantId:
|
|
2143
|
-
bucket:
|
|
2144
|
-
operationId:
|
|
2145
|
-
fingerprint:
|
|
2146
|
-
checksum:
|
|
2147
|
-
logicalKey:
|
|
2148
|
-
}),
|
|
2175
|
+
}, mn = (e, t) => e.deleteMany($t, { where: D("operationId", t) }), hn = "_voltro_storage_put_intents", gn = N(hn, {
|
|
2176
|
+
id: P().maxLength(64),
|
|
2177
|
+
refId: P().maxLength(64),
|
|
2178
|
+
identity: A(),
|
|
2179
|
+
ref: A()
|
|
2180
|
+
}).primaryKey(["id"]).unique("storagePutRef", ["refId"]).nonReactive(), _n = C.Struct({
|
|
2181
|
+
tenantId: C.NullOr(C.String),
|
|
2182
|
+
bucket: C.String,
|
|
2183
|
+
operationId: C.String,
|
|
2184
|
+
fingerprint: C.String,
|
|
2185
|
+
checksum: C.String,
|
|
2186
|
+
logicalKey: C.String
|
|
2187
|
+
}), vn = async (e, t) => {
|
|
2149
2188
|
let n = await e.query({
|
|
2150
|
-
table:
|
|
2151
|
-
predicate:
|
|
2189
|
+
table: hn,
|
|
2190
|
+
predicate: D("refId", t),
|
|
2152
2191
|
order: [],
|
|
2153
2192
|
take: 2,
|
|
2154
2193
|
skip: void 0,
|
|
@@ -2156,44 +2195,44 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2156
2195
|
});
|
|
2157
2196
|
if (n.length === 0) return;
|
|
2158
2197
|
if (n.length !== 1) throw Error("Storage reference has ambiguous operation ownership");
|
|
2159
|
-
let r = n[0], i =
|
|
2198
|
+
let r = n[0], i = C.decodeUnknownSync(_n)(r.identity);
|
|
2160
2199
|
if (typeof r.ref != "object" || r.ref === null || Array.isArray(r.ref)) throw Error("Storage operation reference is unreadable");
|
|
2161
|
-
let a =
|
|
2200
|
+
let a = Y(r.ref);
|
|
2162
2201
|
if (a.id !== t || a.bucket !== i.bucket || a.tenantId !== i.tenantId || a.checksum !== i.checksum || !Number.isSafeInteger(a.size) || a.size < 0 || !Number.isFinite(a.createdAt.getTime())) throw Error("Storage operation reference does not match its identity");
|
|
2163
2202
|
return {
|
|
2164
2203
|
identity: i,
|
|
2165
2204
|
ref: a
|
|
2166
2205
|
};
|
|
2167
|
-
},
|
|
2168
|
-
intent: (t) =>
|
|
2169
|
-
reserve: (t, r, i, a) =>
|
|
2206
|
+
}, yn = (e) => ({
|
|
2207
|
+
intent: (t) => vn(e, t),
|
|
2208
|
+
reserve: (t, r, i, a) => sn(e, t, async (e) => {
|
|
2170
2209
|
if (r.tenantId !== t.tenantId || r.bucket !== t.bucket || r.checksum !== t.checksum || !Number.isSafeInteger(r.size) || r.size < 0) throw Error("Storage put metadata does not match its identity");
|
|
2171
2210
|
let o = await $(e, t);
|
|
2172
2211
|
if (o) {
|
|
2173
2212
|
if (o.state === "deleting" || o.state === "deleted") throw Error("Storage put identity has already been deleted");
|
|
2174
|
-
let t = await
|
|
2213
|
+
let t = await vn(e, o.refId);
|
|
2175
2214
|
if (!t) throw Error("Storage operation lost its put intent");
|
|
2176
2215
|
let n = o.state === "ready";
|
|
2177
|
-
return n && a !== void 0 && await
|
|
2216
|
+
return n && a !== void 0 && await fn(e, o.id, a), {
|
|
2178
2217
|
ref: t.ref,
|
|
2179
2218
|
ready: n,
|
|
2180
2219
|
outcome: n ? "joined" : "resumed"
|
|
2181
2220
|
};
|
|
2182
2221
|
}
|
|
2183
|
-
let s = await
|
|
2184
|
-
if (!(await
|
|
2222
|
+
let s = await cn(e, t), c = Wt(e);
|
|
2223
|
+
if (!(await y.runPromise(c.consumeUsage(t.tenantId, {
|
|
2185
2224
|
bytes: r.size,
|
|
2186
2225
|
count: 1
|
|
2187
2226
|
}, i))).allowed) throw new n({
|
|
2188
2227
|
reason: "quota-exceeded",
|
|
2189
2228
|
detail: "Storage operation exceeds tenant quota"
|
|
2190
2229
|
});
|
|
2191
|
-
let l =
|
|
2230
|
+
let l = Y({
|
|
2192
2231
|
...r,
|
|
2193
2232
|
id: s.refId,
|
|
2194
2233
|
key: s.key
|
|
2195
2234
|
});
|
|
2196
|
-
return await e.insert(
|
|
2235
|
+
return await e.insert(hn, {
|
|
2197
2236
|
id: s.id,
|
|
2198
2237
|
refId: l.id,
|
|
2199
2238
|
identity: t,
|
|
@@ -2204,31 +2243,31 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2204
2243
|
outcome: "created"
|
|
2205
2244
|
};
|
|
2206
2245
|
}),
|
|
2207
|
-
confirm: (t, n) =>
|
|
2246
|
+
confirm: (t, n) => sn(e, t, async (e) => {
|
|
2208
2247
|
let r = await $(e, t);
|
|
2209
2248
|
if (!r) throw Error("Storage put operation is missing");
|
|
2210
|
-
let i = await
|
|
2249
|
+
let i = await vn(e, r.refId);
|
|
2211
2250
|
if (!i) throw Error("Storage put intent is missing");
|
|
2212
|
-
if (n !== void 0 && await
|
|
2213
|
-
let n = await
|
|
2251
|
+
if (n !== void 0 && await fn(e, r.id, n), r.state === "ready") {
|
|
2252
|
+
let n = await y.runPromise(Wt(e).getById(r.refId));
|
|
2214
2253
|
if (!n || n.key !== r.key || n.checksum !== t.checksum) throw Error("Confirmed storage operation lost its reference");
|
|
2215
2254
|
return n;
|
|
2216
2255
|
}
|
|
2217
|
-
return await
|
|
2256
|
+
return await ln(e, t), await y.runPromise(Wt(e).insert(i.ref)), i.ref;
|
|
2218
2257
|
}),
|
|
2219
2258
|
beginDelete: async (t, r, i) => {
|
|
2220
|
-
let a = await
|
|
2259
|
+
let a = await vn(e, t);
|
|
2221
2260
|
if (!a) throw Error("Storage delete operation is missing");
|
|
2222
2261
|
if (r !== void 0 && a.identity.tenantId !== r) throw Error("Storage delete tenant mismatch");
|
|
2223
|
-
return
|
|
2224
|
-
let r = await
|
|
2262
|
+
return sn(e, a.identity, async (e) => {
|
|
2263
|
+
let r = await vn(e, t);
|
|
2225
2264
|
if (!r) throw Error("Storage delete intent disappeared");
|
|
2226
2265
|
let a = await $(e, r.identity);
|
|
2227
2266
|
if (!a) throw Error("Storage delete lost its operation");
|
|
2228
2267
|
let o = a.state !== "deleting" && a.state !== "deleted";
|
|
2229
|
-
if (i === void 0) o && await
|
|
2268
|
+
if (i === void 0) o && await mn(e, a.id);
|
|
2230
2269
|
else if (o) {
|
|
2231
|
-
let o = await
|
|
2270
|
+
let o = await pn(e, a.id, i);
|
|
2232
2271
|
if (o.others) return {
|
|
2233
2272
|
released: !0,
|
|
2234
2273
|
identity: r.identity
|
|
@@ -2238,11 +2277,11 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2238
2277
|
detail: `claim '${i}' is not held on storage reference '${t}'; a reference put without a claim is deleted as a whole by a delete that names none`
|
|
2239
2278
|
});
|
|
2240
2279
|
}
|
|
2241
|
-
let s = await
|
|
2280
|
+
let s = await un(e, r.identity);
|
|
2242
2281
|
if (a.state === "ready") {
|
|
2243
|
-
let n =
|
|
2244
|
-
if (await
|
|
2245
|
-
await
|
|
2282
|
+
let n = Wt(e);
|
|
2283
|
+
if (await y.runPromise(qt(e).deleteByRef(t)), !await y.runPromise(n.delete(t))) throw Error("Storage deletion lost its confirmed reference");
|
|
2284
|
+
await y.runPromise(n.releaseUsage(r.identity.tenantId, {
|
|
2246
2285
|
bytes: r.ref.size,
|
|
2247
2286
|
count: 1
|
|
2248
2287
|
}));
|
|
@@ -2254,8 +2293,8 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2254
2293
|
};
|
|
2255
2294
|
});
|
|
2256
2295
|
},
|
|
2257
|
-
confirmDelete: (t) =>
|
|
2258
|
-
}),
|
|
2296
|
+
confirmDelete: (t) => sn(e, t, (e) => dn(e, t))
|
|
2297
|
+
}), bn = (e, t = 65536) => {
|
|
2259
2298
|
let n = [Buffer.from("zINSTREAM\0", "utf8")];
|
|
2260
2299
|
for (let r = 0; r < e.length; r += t) {
|
|
2261
2300
|
let i = e.subarray(r, Math.min(r + t, e.length)), a = Buffer.alloc(4);
|
|
@@ -2263,7 +2302,7 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2263
2302
|
}
|
|
2264
2303
|
let r = Buffer.alloc(4);
|
|
2265
2304
|
return r.writeUInt32BE(0, 0), n.push(r), Buffer.concat(n);
|
|
2266
|
-
},
|
|
2305
|
+
}, xn = (e) => {
|
|
2267
2306
|
let t = e.replace(/\0+$/, "").trim();
|
|
2268
2307
|
if (/\bOK$/.test(t)) return { clean: !0 };
|
|
2269
2308
|
let n = /:\s*(.+?)\s+FOUND$/.exec(t);
|
|
@@ -2272,8 +2311,8 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2272
2311
|
threat: n[1] ?? "unknown"
|
|
2273
2312
|
};
|
|
2274
2313
|
throw Error(`clamav: unexpected response: ${t}`);
|
|
2275
|
-
},
|
|
2276
|
-
let n = await import("node:net"), r =
|
|
2314
|
+
}, Sn = async (e, t) => {
|
|
2315
|
+
let n = await import("node:net"), r = W.read("CLAMAV_HOST", t.host) ?? "127.0.0.1", i = W.read("CLAMAV_PORT"), a = t.port ?? (i ? Number(i) : 3310), o = t.timeoutMs ?? 3e4;
|
|
2277
2316
|
return new Promise((i, s) => {
|
|
2278
2317
|
let c = n.createConnection({
|
|
2279
2318
|
host: r,
|
|
@@ -2284,20 +2323,20 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2284
2323
|
c.on("error", (e) => {
|
|
2285
2324
|
clearTimeout(u), s(e);
|
|
2286
2325
|
}), c.on("connect", () => {
|
|
2287
|
-
c.end(
|
|
2326
|
+
c.end(bn(e, t.chunkSize));
|
|
2288
2327
|
}), c.on("data", (e) => {
|
|
2289
2328
|
l += e.toString("utf8");
|
|
2290
2329
|
}), c.on("close", () => {
|
|
2291
2330
|
clearTimeout(u);
|
|
2292
2331
|
try {
|
|
2293
|
-
i(
|
|
2332
|
+
i(xn(l));
|
|
2294
2333
|
} catch (e) {
|
|
2295
2334
|
s(e);
|
|
2296
2335
|
}
|
|
2297
2336
|
});
|
|
2298
2337
|
});
|
|
2299
|
-
},
|
|
2300
|
-
let a =
|
|
2338
|
+
}, Cn = (e = {}) => (t) => Sn(t.bytes, e), wn = (e, t, n) => new Promise((r, i) => {
|
|
2339
|
+
let a = ve(e, [...t], { stdio: [
|
|
2301
2340
|
"ignore",
|
|
2302
2341
|
"ignore",
|
|
2303
2342
|
"pipe"
|
|
@@ -2311,31 +2350,31 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2311
2350
|
}), a.on("close", (e) => {
|
|
2312
2351
|
clearTimeout(s), e === 0 ? r() : i(/* @__PURE__ */ Error(`ffmpeg exited ${String(e)}: ${o.slice(-400)}`));
|
|
2313
2352
|
});
|
|
2314
|
-
}),
|
|
2315
|
-
let n = e.ffmpegPath ?? "ffmpeg", r = e.timeoutMs ?? 3e5, i = await
|
|
2353
|
+
}), Tn = (e) => async ({ bytes: t }) => {
|
|
2354
|
+
let n = e.ffmpegPath ?? "ffmpeg", r = e.timeoutMs ?? 3e5, i = await ye(z(Ce(), "voltro-tc-")), a = z(i, "in"), o = [];
|
|
2316
2355
|
try {
|
|
2317
|
-
await
|
|
2356
|
+
await Se(a, t);
|
|
2318
2357
|
for (let t of e.renditions) {
|
|
2319
|
-
let e =
|
|
2358
|
+
let e = z(i, `out.${t.ext}`);
|
|
2320
2359
|
try {
|
|
2321
|
-
await
|
|
2360
|
+
await wn(n, [
|
|
2322
2361
|
"-y",
|
|
2323
2362
|
"-i",
|
|
2324
2363
|
a,
|
|
2325
2364
|
...t.args,
|
|
2326
2365
|
e
|
|
2327
2366
|
], r);
|
|
2328
|
-
let i = await
|
|
2367
|
+
let i = await be(e);
|
|
2329
2368
|
o.push({
|
|
2330
2369
|
bytes: new Uint8Array(i),
|
|
2331
2370
|
contentType: t.contentType,
|
|
2332
2371
|
kind: t.kind,
|
|
2333
2372
|
...t.label === void 0 ? {} : { label: t.label }
|
|
2334
|
-
}), await
|
|
2373
|
+
}), await xe(e, { force: !0 });
|
|
2335
2374
|
} catch {}
|
|
2336
2375
|
}
|
|
2337
2376
|
} finally {
|
|
2338
|
-
await
|
|
2377
|
+
await xe(i, {
|
|
2339
2378
|
recursive: !0,
|
|
2340
2379
|
force: !0
|
|
2341
2380
|
}).catch(() => void 0);
|
|
@@ -2344,21 +2383,21 @@ var Se = 1 << 20, Ce = (e, n, r = !1) => new t({
|
|
|
2344
2383
|
};
|
|
2345
2384
|
//#endregion
|
|
2346
2385
|
//#region src/assetRef.ts
|
|
2347
|
-
function
|
|
2348
|
-
let t = e.nullable ?? !0, n = e.fk === !1 ?
|
|
2386
|
+
function En(e = {}) {
|
|
2387
|
+
let t = e.nullable ?? !0, n = e.fk === !1 ? P().externalId() : pe(() => Pe, { onDelete: e.onDelete ?? "setNull" });
|
|
2349
2388
|
return t ? n.nullable() : n;
|
|
2350
2389
|
}
|
|
2351
|
-
var
|
|
2390
|
+
var Dn = () => j({
|
|
2352
2391
|
id: "@voltro/plugin-storage/withStorage",
|
|
2353
|
-
fields: { asset:
|
|
2354
|
-
}),
|
|
2392
|
+
fields: { asset: En() }
|
|
2393
|
+
}), On = {
|
|
2355
2394
|
"image/png": "png",
|
|
2356
2395
|
"image/jpeg": "jpg",
|
|
2357
2396
|
"image/jpg": "jpg",
|
|
2358
2397
|
"image/gif": "gif",
|
|
2359
2398
|
"image/webp": "webp",
|
|
2360
2399
|
"image/svg+xml": "svg"
|
|
2361
|
-
},
|
|
2400
|
+
}, kn = (e) => {
|
|
2362
2401
|
let t = /^data:([^;,]+)(;base64)?,(.*)$/s.exec(e);
|
|
2363
2402
|
if (!t) throw Error("not a data URI");
|
|
2364
2403
|
let n = t[1] || "application/octet-stream", r = !!t[2], i = t[3] ?? "";
|
|
@@ -2366,16 +2405,16 @@ var En = () => N({
|
|
|
2366
2405
|
bytes: r ? new Uint8Array(Buffer.from(i, "base64")) : new Uint8Array(Buffer.from(decodeURIComponent(i), "utf8")),
|
|
2367
2406
|
contentType: n
|
|
2368
2407
|
};
|
|
2369
|
-
},
|
|
2370
|
-
let r = yield*
|
|
2371
|
-
try: () =>
|
|
2408
|
+
}, An = (e, n) => y.gen(function* () {
|
|
2409
|
+
let r = yield* y.try({
|
|
2410
|
+
try: () => kn(n.dataUri),
|
|
2372
2411
|
catch: (e) => new t({
|
|
2373
2412
|
provider: "avatar",
|
|
2374
2413
|
message: String(e?.message ?? e),
|
|
2375
2414
|
transient: !1,
|
|
2376
2415
|
status: 400
|
|
2377
2416
|
})
|
|
2378
|
-
}), i =
|
|
2417
|
+
}), i = On[r.contentType] ?? "bin";
|
|
2379
2418
|
return yield* e.put({
|
|
2380
2419
|
bytes: r.bytes,
|
|
2381
2420
|
contentType: r.contentType,
|
|
@@ -2384,27 +2423,27 @@ var En = () => N({
|
|
|
2384
2423
|
visibility: "public",
|
|
2385
2424
|
key: `avatars/${n.userId}/avatar.${i}`
|
|
2386
2425
|
});
|
|
2387
|
-
}),
|
|
2426
|
+
}), jn = (e) => {
|
|
2388
2427
|
try {
|
|
2389
|
-
let t =
|
|
2428
|
+
let t = B(e), n = B("/");
|
|
2390
2429
|
return typeof t.dev != "number" || typeof n.dev != "number" ? "unknown" : t.dev === n.dev ? "same-device-as-root" : "separate-mount";
|
|
2391
2430
|
} catch {
|
|
2392
2431
|
return "unknown";
|
|
2393
2432
|
}
|
|
2394
|
-
},
|
|
2395
|
-
if (
|
|
2433
|
+
}, Mn = (e) => {
|
|
2434
|
+
if (jn(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
|
|
2396
2435
|
dies with it — which is the exact failure it exists for. On a development machine this is normal
|
|
2397
2436
|
and can be ignored.`;
|
|
2398
|
-
},
|
|
2399
|
-
|
|
2400
|
-
},
|
|
2437
|
+
}, Nn = W.read("VOLTRO_SESSION_COOKIE") ?? "voltro:session", Pn, Fn = (e) => {
|
|
2438
|
+
Pn = e;
|
|
2439
|
+
}, In = () => Pn ?? Rn({}), Ln = () => Pn === void 0 ? W.read("STORAGE_PROVIDER") === void 0 ? void 0 : Rn({}) : Pn, Rn = (e) => {
|
|
2401
2440
|
if (e.provider && typeof e.provider == "object") return e.provider;
|
|
2402
|
-
let t = (e.provider ??
|
|
2441
|
+
let t = (e.provider ?? W.read("STORAGE_PROVIDER") ?? "memory").toLowerCase(), n = W.read("S3_BUCKET", e.bucket) ?? W.read("STORAGE_BUCKET") ?? "voltro";
|
|
2403
2442
|
switch (t) {
|
|
2404
2443
|
case "s3":
|
|
2405
2444
|
case "minio": {
|
|
2406
|
-
let r =
|
|
2407
|
-
return
|
|
2445
|
+
let r = W.read("S3_REGION", e.region) ?? W.read("AWS_REGION"), i = W.read("S3_ENDPOINT", e.endpoint) ?? W.read("MINIO_ENDPOINT"), a = W.read("S3_ACCESS_KEY_ID", e.accessKeyId) ?? W.read("AWS_ACCESS_KEY_ID"), o = W.read("S3_SECRET_ACCESS_KEY", e.secretAccessKey) ?? W.read("AWS_SECRET_ACCESS_KEY"), s = W.read("STORAGE_CDN_URL", e.cdnBaseUrl);
|
|
2446
|
+
return We({
|
|
2408
2447
|
bucket: n,
|
|
2409
2448
|
name: t,
|
|
2410
2449
|
...r ? { region: r } : {},
|
|
@@ -2413,13 +2452,13 @@ var En = () => N({
|
|
|
2413
2452
|
...o ? { secretAccessKey: o } : {},
|
|
2414
2453
|
...s ? { cdnBaseUrl: s } : {},
|
|
2415
2454
|
...e.publicAcl === void 0 ? {} : { publicAcl: e.publicAcl },
|
|
2416
|
-
...t === "minio" ||
|
|
2455
|
+
...t === "minio" || W.read("S3_FORCE_PATH_STYLE") === "1" ? { forcePathStyle: !0 } : {}
|
|
2417
2456
|
});
|
|
2418
2457
|
}
|
|
2419
2458
|
case "azure": {
|
|
2420
|
-
let t =
|
|
2421
|
-
return
|
|
2422
|
-
container:
|
|
2459
|
+
let t = W.read("AZURE_STORAGE_ACCOUNT", e.accountName), r = W.read("AZURE_STORAGE_KEY", e.accountKey), i = W.read("AZURE_STORAGE_CONNECTION_STRING", e.connectionString), a = W.read("AZURE_STORAGE_ENDPOINT", e.endpoint), o = W.read("STORAGE_CDN_URL", e.cdnBaseUrl);
|
|
2460
|
+
return qe({
|
|
2461
|
+
container: W.read("AZURE_STORAGE_CONTAINER", e.bucket) ?? n,
|
|
2423
2462
|
...t ? { accountName: t } : {},
|
|
2424
2463
|
...r ? { accountKey: r } : {},
|
|
2425
2464
|
...i ? { connectionString: i } : {},
|
|
@@ -2427,15 +2466,15 @@ var En = () => N({
|
|
|
2427
2466
|
...o ? { cdnBaseUrl: o } : {}
|
|
2428
2467
|
});
|
|
2429
2468
|
}
|
|
2430
|
-
case "database": return
|
|
2431
|
-
case "filesystem": return
|
|
2432
|
-
default: return
|
|
2469
|
+
case "database": return Ke();
|
|
2470
|
+
case "filesystem": return Ue({ root: W.read("STORAGE_ROOT", e.root) ?? ".voltro-storage" });
|
|
2471
|
+
default: return He(e.name ?? "default");
|
|
2433
2472
|
}
|
|
2434
|
-
},
|
|
2473
|
+
}, zn = (e) => {
|
|
2435
2474
|
if (e !== void 0) return e;
|
|
2436
|
-
let t =
|
|
2475
|
+
let t = W.read("STORAGE_ALLOWED_ORIGINS");
|
|
2437
2476
|
return t ? t.trim() === "*" ? "*" : t.split(",").map((e) => e.trim()).filter(Boolean) : [];
|
|
2438
|
-
},
|
|
2477
|
+
}, Bn = (e, t) => {
|
|
2439
2478
|
if (!e || t !== "*" && !t.includes(e)) return {};
|
|
2440
2479
|
let n = {
|
|
2441
2480
|
"access-control-allow-origin": t === "*" ? "*" : e,
|
|
@@ -2445,7 +2484,7 @@ var En = () => N({
|
|
|
2445
2484
|
vary: "Origin"
|
|
2446
2485
|
};
|
|
2447
2486
|
return t !== "*" && (n["access-control-allow-credentials"] = "true"), n;
|
|
2448
|
-
},
|
|
2487
|
+
}, Vn = (e) => ({
|
|
2449
2488
|
id: e.id,
|
|
2450
2489
|
tenantId: e.tenantId,
|
|
2451
2490
|
ownerId: e.ownerId,
|
|
@@ -2468,29 +2507,29 @@ var En = () => N({
|
|
|
2468
2507
|
caption: e.caption ?? null,
|
|
2469
2508
|
derivedFrom: e.derivedFrom ?? null,
|
|
2470
2509
|
kind: e.kind ?? null
|
|
2471
|
-
}),
|
|
2510
|
+
}), Hn = () => new t({
|
|
2472
2511
|
provider: "storage",
|
|
2473
2512
|
message: "not permitted to administer sharing for this object",
|
|
2474
2513
|
transient: !1,
|
|
2475
2514
|
status: 403
|
|
2476
|
-
}),
|
|
2515
|
+
}), Un = (e, t, n) => {
|
|
2477
2516
|
let r = n.request.subject;
|
|
2478
|
-
return (r.scopes ?? []).includes("admin:full") ?
|
|
2517
|
+
return (r.scopes ?? []).includes("admin:full") ? y.void : e.head(t, { tenantId: r.tenantId ?? null }).pipe(y.catchAll(() => y.fail(Hn())), y.flatMap((e) => {
|
|
2479
2518
|
let t = e?.ownerId;
|
|
2480
|
-
return t != null && t === r.id ?
|
|
2519
|
+
return t != null && t === r.id ? y.void : y.fail(Hn());
|
|
2481
2520
|
}));
|
|
2482
|
-
},
|
|
2521
|
+
}, Wn = () => new t({
|
|
2483
2522
|
provider: "storage",
|
|
2484
2523
|
message: "an upload needs an identified caller: this request carries no subject, and the app has not set `anonymousUploads: true` on storagePlugin. The ticket attributes the object to whoever minted it — with no subject there is nobody to attribute it to, so the finalized object would carry no owner and no tenant and no later owner check, tenant filter or quota could reach it.",
|
|
2485
2524
|
transient: !1,
|
|
2486
2525
|
status: 401
|
|
2487
|
-
}),
|
|
2526
|
+
}), Gn = (e, t) => {
|
|
2488
2527
|
let n = e.request.subject.id ?? null, r = e.request.subject.tenantId ?? null;
|
|
2489
|
-
return n === null && !t ?
|
|
2528
|
+
return n === null && !t ? y.fail(Wn()) : y.succeed({
|
|
2490
2529
|
id: n,
|
|
2491
2530
|
tenantId: r
|
|
2492
2531
|
});
|
|
2493
|
-
},
|
|
2532
|
+
}, Kn = (e, t) => e !== null && e !== (t ?? null), qn = (e) => ({
|
|
2494
2533
|
id: e.id,
|
|
2495
2534
|
refId: e.refId,
|
|
2496
2535
|
principalType: e.principalType,
|
|
@@ -2499,41 +2538,41 @@ var En = () => N({
|
|
|
2499
2538
|
createdAt: e.createdAt.toISOString(),
|
|
2500
2539
|
expiresAt: e.expiresAt ? e.expiresAt.toISOString() : null,
|
|
2501
2540
|
createdBy: e.createdBy
|
|
2502
|
-
}),
|
|
2503
|
-
base:
|
|
2541
|
+
}), Jn = "@voltro/plugin-storage", Yn = (e = {}) => oe({
|
|
2542
|
+
base: Jn,
|
|
2504
2543
|
alias: e.alias,
|
|
2505
2544
|
instance: e.name
|
|
2506
|
-
}),
|
|
2507
|
-
let
|
|
2508
|
-
base:
|
|
2545
|
+
}), Xn = (i = {}) => {
|
|
2546
|
+
let v = oe({
|
|
2547
|
+
base: Jn,
|
|
2509
2548
|
alias: i.alias,
|
|
2510
2549
|
instance: i.name
|
|
2511
|
-
}),
|
|
2512
|
-
|
|
2513
|
-
let
|
|
2514
|
-
insert: (e) =>
|
|
2515
|
-
getById: (e) =>
|
|
2516
|
-
delete: (e) =>
|
|
2517
|
-
statistics: () =>
|
|
2518
|
-
listRecent: (e) =>
|
|
2519
|
-
countByKey: (e, t) =>
|
|
2520
|
-
usageByTenant: (e) =>
|
|
2521
|
-
consumeUsage: (e, t, n) =>
|
|
2522
|
-
releaseUsage: (e, t) =>
|
|
2523
|
-
listByDerivedFrom: (e) =>
|
|
2524
|
-
listRefs: (e) =>
|
|
2525
|
-
},
|
|
2526
|
-
insert: (e) =>
|
|
2527
|
-
delete: (e) =>
|
|
2528
|
-
getById: (e) =>
|
|
2529
|
-
listByRef: (e) =>
|
|
2530
|
-
deleteByRef: (e) =>
|
|
2531
|
-
},
|
|
2532
|
-
httpPath:
|
|
2533
|
-
provider:
|
|
2534
|
-
refStore:
|
|
2535
|
-
grantStore:
|
|
2536
|
-
bucket:
|
|
2550
|
+
}), b = v === Jn ? "/_voltro/storage" : `/_voltro/storage/i/${Buffer.from(v).toString("hex")}`, x = Rn(i);
|
|
2551
|
+
Fn(x);
|
|
2552
|
+
let S = W.read("S3_BUCKET", i.bucket) ?? W.read("STORAGE_BUCKET") ?? "voltro", T = W.read("VOLTRO_PUBLIC_URL", i.publicBaseUrl), ue = zn(i.allowedOrigins), E = i.limits?.maxBytes, D = i.anonymousUploads === !0, O = 5242880, de = 21600, k = i.refStore === void 0 || i.refStore === "memory", A = i.grantStore === void 0 || i.grantStore === "memory", j = { current: k ? Vt() : i.refStore }, M = { current: A ? Gt() : i.grantStore }, fe = { current: void 0 }, pe = {
|
|
2553
|
+
insert: (e) => j.current.insert(e),
|
|
2554
|
+
getById: (e) => j.current.getById(e),
|
|
2555
|
+
delete: (e) => j.current.delete(e),
|
|
2556
|
+
statistics: () => j.current.statistics(),
|
|
2557
|
+
listRecent: (e) => j.current.listRecent(e),
|
|
2558
|
+
countByKey: (e, t) => j.current.countByKey(e, t),
|
|
2559
|
+
usageByTenant: (e) => j.current.usageByTenant(e),
|
|
2560
|
+
consumeUsage: (e, t, n) => j.current.consumeUsage(e, t, n),
|
|
2561
|
+
releaseUsage: (e, t) => j.current.releaseUsage(e, t),
|
|
2562
|
+
listByDerivedFrom: (e) => j.current.listByDerivedFrom(e),
|
|
2563
|
+
listRefs: (e) => j.current.listRefs(e)
|
|
2564
|
+
}, N = {
|
|
2565
|
+
insert: (e) => M.current.insert(e),
|
|
2566
|
+
delete: (e) => M.current.delete(e),
|
|
2567
|
+
getById: (e) => M.current.getById(e),
|
|
2568
|
+
listByRef: (e) => M.current.listByRef(e),
|
|
2569
|
+
deleteByRef: (e) => M.current.deleteByRef(e)
|
|
2570
|
+
}, P = {
|
|
2571
|
+
httpPath: b,
|
|
2572
|
+
provider: x,
|
|
2573
|
+
refStore: pe,
|
|
2574
|
+
grantStore: N,
|
|
2575
|
+
bucket: S,
|
|
2537
2576
|
...i.tenantPrefix === void 0 ? {} : { tenantPrefix: i.tenantPrefix },
|
|
2538
2577
|
...i.attempts === void 0 ? {} : { attempts: i.attempts },
|
|
2539
2578
|
...i.urlExpiresInSec === void 0 ? {} : { urlExpiresInSec: i.urlExpiresInSec },
|
|
@@ -2543,11 +2582,11 @@ var En = () => N({
|
|
|
2543
2582
|
...i.videoProbe === void 0 ? {} : { videoProbe: i.videoProbe },
|
|
2544
2583
|
...i.transcode === void 0 ? {} : { transcode: i.transcode },
|
|
2545
2584
|
...i.autoTranscode === void 0 ? {} : { autoTranscode: i.autoTranscode },
|
|
2546
|
-
...
|
|
2585
|
+
...T ? { publicBaseUrl: T } : {},
|
|
2547
2586
|
...i.normalizeImages === void 0 ? {} : { normalizeImages: i.normalizeImages },
|
|
2548
2587
|
...i.quota === void 0 ? {} : { quota: i.quota },
|
|
2549
|
-
objects: () =>
|
|
2550
|
-
},
|
|
2588
|
+
objects: () => fe.current
|
|
2589
|
+
}, me = Zt(P), F = Xt(P), I = `${b}/`, L = (e) => y.runPromise(e.pipe(y.catchAll(() => y.succeed(null)))), _e = (e, t) => {
|
|
2551
2590
|
if (!e) return "invalid";
|
|
2552
2591
|
let n = /^bytes=(\d*)-(\d*)$/.exec(e.trim());
|
|
2553
2592
|
if (!n) return "invalid";
|
|
@@ -2568,30 +2607,30 @@ var En = () => N({
|
|
|
2568
2607
|
start: a,
|
|
2569
2608
|
endInclusive: o
|
|
2570
2609
|
};
|
|
2571
|
-
},
|
|
2610
|
+
}, R = /^(?:image\/(?!svg)|video\/|audio\/|application\/pdf(?:;|$)|text\/plain(?:;|$))/i, ve = (e) => ({
|
|
2572
2611
|
"x-content-type-options": "nosniff",
|
|
2573
|
-
"content-disposition":
|
|
2574
|
-
}),
|
|
2612
|
+
"content-disposition": R.test(e) ? "inline" : "attachment"
|
|
2613
|
+
}), ye = async (e, t, n, r) => {
|
|
2575
2614
|
if (n) {
|
|
2576
|
-
let r = await
|
|
2615
|
+
let r = await L(F.get(e.id));
|
|
2577
2616
|
if (!r) return {
|
|
2578
2617
|
status: 404,
|
|
2579
2618
|
body: "not found",
|
|
2580
2619
|
contentType: "text/plain"
|
|
2581
2620
|
};
|
|
2582
|
-
let i = await
|
|
2621
|
+
let i = await nt(e.id, r.bytes, e.contentType, n).catch(() => null), a = i ? i.bytes : r.bytes, o = i ? i.contentType : e.contentType;
|
|
2583
2622
|
return {
|
|
2584
2623
|
status: 200,
|
|
2585
2624
|
body: a,
|
|
2586
2625
|
contentType: o,
|
|
2587
2626
|
headers: {
|
|
2588
|
-
...
|
|
2627
|
+
...ve(o),
|
|
2589
2628
|
"cache-control": t,
|
|
2590
2629
|
"accept-ranges": "none"
|
|
2591
2630
|
}
|
|
2592
2631
|
};
|
|
2593
2632
|
}
|
|
2594
|
-
let i = r === void 0 ? "invalid" :
|
|
2633
|
+
let i = r === void 0 ? "invalid" : _e(r, e.size);
|
|
2595
2634
|
if (i === "unsatisfiable") return {
|
|
2596
2635
|
status: 416,
|
|
2597
2636
|
body: "range not satisfiable",
|
|
@@ -2602,13 +2641,13 @@ var En = () => N({
|
|
|
2602
2641
|
}
|
|
2603
2642
|
};
|
|
2604
2643
|
if (i !== "invalid") {
|
|
2605
|
-
let n = await
|
|
2644
|
+
let n = await L(F.getRange(e.id, i));
|
|
2606
2645
|
return n ? {
|
|
2607
2646
|
status: 206,
|
|
2608
2647
|
body: n.bytes,
|
|
2609
2648
|
contentType: e.contentType,
|
|
2610
2649
|
headers: {
|
|
2611
|
-
...
|
|
2650
|
+
...ve(e.contentType),
|
|
2612
2651
|
"cache-control": t,
|
|
2613
2652
|
"accept-ranges": "bytes",
|
|
2614
2653
|
"content-range": `bytes ${i.start}-${i.endInclusive}/${n.totalSize}`
|
|
@@ -2619,64 +2658,64 @@ var En = () => N({
|
|
|
2619
2658
|
contentType: "text/plain"
|
|
2620
2659
|
};
|
|
2621
2660
|
}
|
|
2622
|
-
let a = await
|
|
2661
|
+
let a = await L(F.getStream(e.id));
|
|
2623
2662
|
return a ? {
|
|
2624
2663
|
status: 200,
|
|
2625
2664
|
contentType: e.contentType,
|
|
2626
2665
|
headers: {
|
|
2627
|
-
...
|
|
2666
|
+
...ve(e.contentType),
|
|
2628
2667
|
"cache-control": t,
|
|
2629
2668
|
"accept-ranges": "bytes"
|
|
2630
2669
|
},
|
|
2631
2670
|
byteStream: {
|
|
2632
2671
|
contentLength: e.size,
|
|
2633
|
-
stream: () =>
|
|
2672
|
+
stream: () => w.toReadableStream(a.stream)
|
|
2634
2673
|
}
|
|
2635
2674
|
} : {
|
|
2636
2675
|
status: 404,
|
|
2637
2676
|
body: "not found",
|
|
2638
2677
|
contentType: "text/plain"
|
|
2639
2678
|
};
|
|
2640
|
-
},
|
|
2641
|
-
let t = e.path.startsWith(
|
|
2679
|
+
}, be = async (e) => {
|
|
2680
|
+
let t = e.path.startsWith(I) ? e.path.slice(I.length).split("/")[0] ?? "" : "";
|
|
2642
2681
|
if (!t) return {
|
|
2643
2682
|
status: 404,
|
|
2644
2683
|
body: "not found",
|
|
2645
2684
|
contentType: "text/plain"
|
|
2646
2685
|
};
|
|
2647
|
-
let n = await
|
|
2686
|
+
let n = await L(F.head(t));
|
|
2648
2687
|
if (!n) return {
|
|
2649
2688
|
status: 404,
|
|
2650
2689
|
body: "not found",
|
|
2651
2690
|
contentType: "text/plain"
|
|
2652
2691
|
};
|
|
2653
|
-
let r =
|
|
2692
|
+
let r = Ye(e.query), i = e.headers.range;
|
|
2654
2693
|
if (n.visibility === "public") {
|
|
2655
|
-
let e =
|
|
2694
|
+
let e = x.publicUrl?.(n.key) ?? null;
|
|
2656
2695
|
return e && !r ? {
|
|
2657
2696
|
status: 302,
|
|
2658
2697
|
headers: {
|
|
2659
2698
|
location: e,
|
|
2660
2699
|
"cache-control": "public, max-age=300"
|
|
2661
2700
|
}
|
|
2662
|
-
} :
|
|
2701
|
+
} : ye(n, "public, max-age=31536000, immutable", r, i);
|
|
2663
2702
|
}
|
|
2664
2703
|
let a = !1, o = e.query ? new URLSearchParams(e.query).get("t") : null;
|
|
2665
2704
|
if (o) {
|
|
2666
|
-
let e =
|
|
2667
|
-
a = !!e && e.refId === t;
|
|
2705
|
+
let e = _t(o);
|
|
2706
|
+
a = !!e && e.refId === t && e.audience === b;
|
|
2668
2707
|
}
|
|
2669
2708
|
if (!a) {
|
|
2670
|
-
let t =
|
|
2671
|
-
r && (a = await
|
|
2709
|
+
let t = se(e.headers.cookie, Nn), r = t ? le(t, ce()) : null;
|
|
2710
|
+
r && (a = await L(F.checkAccess(n, r)) === !0);
|
|
2672
2711
|
}
|
|
2673
2712
|
if (!a) return {
|
|
2674
2713
|
status: 403,
|
|
2675
2714
|
body: "forbidden",
|
|
2676
2715
|
contentType: "text/plain"
|
|
2677
2716
|
};
|
|
2678
|
-
if (
|
|
2679
|
-
let e = await
|
|
2717
|
+
if (x.presigns && !r) {
|
|
2718
|
+
let e = await L(x.getUrl(n.key, 300));
|
|
2680
2719
|
if (e && /^https?:/.test(e)) return {
|
|
2681
2720
|
status: 302,
|
|
2682
2721
|
headers: {
|
|
@@ -2685,12 +2724,12 @@ var En = () => N({
|
|
|
2685
2724
|
}
|
|
2686
2725
|
};
|
|
2687
2726
|
}
|
|
2688
|
-
return
|
|
2689
|
-
},
|
|
2727
|
+
return ye(n, "private, no-store", r, i);
|
|
2728
|
+
}, xe = {
|
|
2690
2729
|
method: "GET",
|
|
2691
|
-
path:
|
|
2730
|
+
path: b,
|
|
2692
2731
|
handle: async (e) => {
|
|
2693
|
-
let t = await
|
|
2732
|
+
let t = await be(e), n = Bn(e.headers.origin, ue);
|
|
2694
2733
|
return Object.keys(n).length === 0 ? t : {
|
|
2695
2734
|
...t,
|
|
2696
2735
|
headers: {
|
|
@@ -2699,12 +2738,12 @@ var En = () => N({
|
|
|
2699
2738
|
}
|
|
2700
2739
|
};
|
|
2701
2740
|
}
|
|
2702
|
-
},
|
|
2741
|
+
}, Se = {
|
|
2703
2742
|
method: "*",
|
|
2704
|
-
path: `${
|
|
2743
|
+
path: `${b}/upload`,
|
|
2705
2744
|
originGuard: "exempt",
|
|
2706
2745
|
handle: async (e) => {
|
|
2707
|
-
let t =
|
|
2746
|
+
let t = Bn(e.headers.origin, ue);
|
|
2708
2747
|
if (e.method === "OPTIONS") return {
|
|
2709
2748
|
status: 204,
|
|
2710
2749
|
headers: t
|
|
@@ -2715,13 +2754,19 @@ var En = () => N({
|
|
|
2715
2754
|
contentType: "text/plain",
|
|
2716
2755
|
headers: t
|
|
2717
2756
|
};
|
|
2718
|
-
let n = e.query ? new URLSearchParams(e.query).get("ticket") : null, r = n ?
|
|
2719
|
-
if (!r || r.instance !==
|
|
2757
|
+
let n = e.query ? new URLSearchParams(e.query).get("ticket") : null, r = n ? yt(n) : null;
|
|
2758
|
+
if (!r || r.instance !== v) return {
|
|
2720
2759
|
status: 401,
|
|
2721
2760
|
body: "invalid or expired upload ticket",
|
|
2722
2761
|
contentType: "text/plain",
|
|
2723
2762
|
headers: t
|
|
2724
2763
|
};
|
|
2764
|
+
if (r.replicaId !== void 0 && r.replicaId !== _().replicaId) return {
|
|
2765
|
+
status: 409,
|
|
2766
|
+
body: "upload ticket belongs to another replica",
|
|
2767
|
+
contentType: "text/plain",
|
|
2768
|
+
headers: t
|
|
2769
|
+
};
|
|
2725
2770
|
if (e.rawBody.length === 0) return {
|
|
2726
2771
|
status: 400,
|
|
2727
2772
|
body: "empty body",
|
|
@@ -2734,32 +2779,33 @@ var En = () => N({
|
|
|
2734
2779
|
contentType: "text/plain",
|
|
2735
2780
|
headers: t
|
|
2736
2781
|
};
|
|
2737
|
-
let i = await
|
|
2782
|
+
let i = await y.runPromise(F.put({
|
|
2738
2783
|
bytes: e.rawBody,
|
|
2739
2784
|
contentType: r.ct,
|
|
2740
2785
|
tenantId: r.tenant,
|
|
2741
2786
|
ownerId: r.sub,
|
|
2742
2787
|
visibility: r.vis,
|
|
2788
|
+
...r.operationId === void 0 ? {} : { operationId: r.operationId },
|
|
2743
2789
|
...r.key === void 0 ? {} : { key: r.key },
|
|
2744
2790
|
...r.folder === void 0 ? {} : { folder: r.folder },
|
|
2745
2791
|
...r.tags === void 0 ? {} : { tags: r.tags },
|
|
2746
2792
|
...r.alt === void 0 ? {} : { alt: r.alt },
|
|
2747
2793
|
...r.caption === void 0 ? {} : { caption: r.caption }
|
|
2748
|
-
}).pipe(
|
|
2794
|
+
}).pipe(y.flatMap((e) => F.getUrl(e.id).pipe(y.map((t) => ({
|
|
2749
2795
|
kind: "ok",
|
|
2750
2796
|
ref: e,
|
|
2751
2797
|
url: t
|
|
2752
|
-
})))),
|
|
2753
|
-
StorageRejected: (e) =>
|
|
2798
|
+
})))), y.catchTags({
|
|
2799
|
+
StorageRejected: (e) => y.succeed({
|
|
2754
2800
|
kind: "rejected",
|
|
2755
2801
|
status: e.reason === "too-large" ? 413 : 415,
|
|
2756
2802
|
detail: e.detail
|
|
2757
2803
|
}),
|
|
2758
|
-
StorageScanRejected: (e) =>
|
|
2804
|
+
StorageScanRejected: (e) => y.succeed({
|
|
2759
2805
|
kind: "scan",
|
|
2760
2806
|
threat: e.threat
|
|
2761
2807
|
}),
|
|
2762
|
-
StorageError: (e) =>
|
|
2808
|
+
StorageError: (e) => y.succeed({
|
|
2763
2809
|
kind: "error",
|
|
2764
2810
|
message: e.message
|
|
2765
2811
|
})
|
|
@@ -2791,28 +2837,28 @@ var En = () => N({
|
|
|
2791
2837
|
headers: t
|
|
2792
2838
|
};
|
|
2793
2839
|
}
|
|
2794
|
-
},
|
|
2840
|
+
}, Ce = {
|
|
2795
2841
|
method: "*",
|
|
2796
|
-
path: `${
|
|
2842
|
+
path: `${b}/upload/resumable`,
|
|
2797
2843
|
originGuard: "exempt",
|
|
2798
2844
|
handle: async (e) => {
|
|
2799
|
-
let t =
|
|
2845
|
+
let t = Bn(e.headers.origin, ue);
|
|
2800
2846
|
if (e.method === "OPTIONS") return {
|
|
2801
2847
|
status: 204,
|
|
2802
2848
|
headers: t
|
|
2803
2849
|
};
|
|
2804
|
-
let n = new URLSearchParams(e.query || ""), r =
|
|
2805
|
-
if (!r || r.instance !==
|
|
2850
|
+
let n = new URLSearchParams(e.query || ""), r = Ct(n.get("token") ?? "");
|
|
2851
|
+
if (!r || r.instance !== v) return {
|
|
2806
2852
|
status: 401,
|
|
2807
2853
|
body: "invalid or expired resumable token",
|
|
2808
2854
|
contentType: "text/plain",
|
|
2809
2855
|
headers: t
|
|
2810
2856
|
};
|
|
2811
2857
|
if (e.method === "GET" || e.method === "HEAD") {
|
|
2812
|
-
let e = await
|
|
2858
|
+
let e = await y.runPromise(F.resumableStatus({
|
|
2813
2859
|
uploadId: r.id,
|
|
2814
2860
|
tenantId: r.tenant
|
|
2815
|
-
}).pipe(
|
|
2861
|
+
}).pipe(y.match({
|
|
2816
2862
|
onFailure: (e) => ({ error: e.message }),
|
|
2817
2863
|
onSuccess: (e) => e
|
|
2818
2864
|
})));
|
|
@@ -2850,12 +2896,12 @@ var En = () => N({
|
|
|
2850
2896
|
contentType: "text/plain",
|
|
2851
2897
|
headers: t
|
|
2852
2898
|
};
|
|
2853
|
-
let a = n.get("final") === "1", o = await
|
|
2899
|
+
let a = n.get("final") === "1", o = await y.runPromise(F.putResumableChunk({
|
|
2854
2900
|
uploadId: r.id,
|
|
2855
2901
|
tenantId: r.tenant,
|
|
2856
2902
|
index: i,
|
|
2857
2903
|
bytes: e.rawBody
|
|
2858
|
-
}).pipe(
|
|
2904
|
+
}).pipe(y.flatMap(() => a ? F.finalizeResumable({
|
|
2859
2905
|
uploadId: r.id,
|
|
2860
2906
|
count: i + 1,
|
|
2861
2907
|
contentType: r.ct,
|
|
@@ -2866,21 +2912,21 @@ var En = () => N({
|
|
|
2866
2912
|
...r.tags === void 0 ? {} : { tags: r.tags },
|
|
2867
2913
|
...r.alt === void 0 ? {} : { alt: r.alt },
|
|
2868
2914
|
...r.caption === void 0 ? {} : { caption: r.caption }
|
|
2869
|
-
}).pipe(
|
|
2915
|
+
}).pipe(y.flatMap((e) => F.getUrl(e.id).pipe(y.map((t) => ({
|
|
2870
2916
|
kind: "done",
|
|
2871
2917
|
ref: e,
|
|
2872
2918
|
url: t
|
|
2873
|
-
}))))) :
|
|
2874
|
-
StorageRejected: (e) =>
|
|
2919
|
+
}))))) : y.succeed({ kind: "chunk" })), y.catchTags({
|
|
2920
|
+
StorageRejected: (e) => y.succeed({
|
|
2875
2921
|
kind: "rejected",
|
|
2876
2922
|
status: e.reason === "too-large" ? 413 : 415,
|
|
2877
2923
|
detail: e.detail
|
|
2878
2924
|
}),
|
|
2879
|
-
StorageScanRejected: (e) =>
|
|
2925
|
+
StorageScanRejected: (e) => y.succeed({
|
|
2880
2926
|
kind: "scan",
|
|
2881
2927
|
threat: e.threat
|
|
2882
2928
|
}),
|
|
2883
|
-
StorageError: (e) =>
|
|
2929
|
+
StorageError: (e) => y.succeed({
|
|
2884
2930
|
kind: "error",
|
|
2885
2931
|
message: e.message
|
|
2886
2932
|
})
|
|
@@ -2918,41 +2964,45 @@ var En = () => N({
|
|
|
2918
2964
|
headers: t
|
|
2919
2965
|
};
|
|
2920
2966
|
}
|
|
2921
|
-
},
|
|
2967
|
+
}, z = (e) => ({
|
|
2922
2968
|
kind: "json",
|
|
2923
2969
|
data: e
|
|
2924
|
-
}),
|
|
2970
|
+
}), B = (e, t) => ({
|
|
2925
2971
|
kind: "json",
|
|
2926
2972
|
status: e,
|
|
2927
2973
|
data: { error: t }
|
|
2928
|
-
}),
|
|
2974
|
+
}), we = (e, t) => {
|
|
2929
2975
|
try {
|
|
2930
2976
|
return new URL(e, "http://localhost").searchParams.get(t);
|
|
2931
2977
|
} catch {
|
|
2932
2978
|
return null;
|
|
2933
2979
|
}
|
|
2934
|
-
},
|
|
2980
|
+
}, Te = [
|
|
2935
2981
|
{
|
|
2936
2982
|
method: "POST",
|
|
2937
2983
|
path: "/upload-ticket",
|
|
2938
2984
|
description: "Authorize a binary upload with explicit tenant and owner attribution",
|
|
2939
|
-
handler: (e) =>
|
|
2940
|
-
let n =
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2985
|
+
handler: (e) => y.gen(function* () {
|
|
2986
|
+
let n = C.String.pipe(C.filter((e) => e.trim().length > 0)), r = yield* C.decodeUnknown(C.parseJson(C.Struct({
|
|
2987
|
+
operationId: C.optional(n.pipe(C.maxLength(200))),
|
|
2988
|
+
tenantId: C.NullOr(n),
|
|
2989
|
+
ownerId: C.NullOr(n),
|
|
2990
|
+
key: n.pipe(C.maxLength(1024)),
|
|
2991
|
+
contentType: n.pipe(C.maxLength(255), C.filter((e) => !/[\r\n]/.test(e))),
|
|
2992
|
+
size: C.Number.pipe(C.int(), C.positive(), C.filter(Number.isSafeInteger)),
|
|
2993
|
+
visibility: C.optional(C.Literal("public", "private"))
|
|
2994
|
+
})))(e.body).pipe(y.mapError(() => new t({
|
|
2948
2995
|
provider: "inspect",
|
|
2949
2996
|
message: "Provide explicit tenantId and ownerId (or null), key, contentType and a positive file size",
|
|
2950
2997
|
transient: !1,
|
|
2951
2998
|
status: 400
|
|
2952
2999
|
})));
|
|
2953
|
-
if (
|
|
2954
|
-
|
|
2955
|
-
|
|
3000
|
+
if (r.operationId !== void 0 && fe.current === void 0) return B(409, "Durable uploads require a bound operation store with default reference and grant stores");
|
|
3001
|
+
if (E !== void 0 && r.size > E) return B(413, "File exceeds the configured upload limit");
|
|
3002
|
+
let i = vt({
|
|
3003
|
+
instance: v,
|
|
3004
|
+
...r.operationId === void 0 ? {} : { operationId: `inspect-upload:${he("sha256").update(JSON.stringify([v, r.operationId])).digest("hex")}` },
|
|
3005
|
+
replicaId: _().replicaId,
|
|
2956
3006
|
sub: r.ownerId,
|
|
2957
3007
|
tenant: r.tenantId,
|
|
2958
3008
|
ct: r.contentType,
|
|
@@ -2960,40 +3010,41 @@ var En = () => N({
|
|
|
2960
3010
|
vis: r.visibility ?? "private",
|
|
2961
3011
|
max: r.size
|
|
2962
3012
|
}, 300);
|
|
2963
|
-
return
|
|
2964
|
-
uploadPath: `${
|
|
3013
|
+
return z({
|
|
3014
|
+
uploadPath: `${b}/upload?ticket=${encodeURIComponent(i)}`,
|
|
2965
3015
|
expiresInSec: 300,
|
|
2966
3016
|
maxBytes: r.size
|
|
2967
3017
|
});
|
|
2968
|
-
}).pipe(
|
|
3018
|
+
}).pipe(y.catchAll((e) => y.succeed(B(e.status ?? 500, e.message))))
|
|
2969
3019
|
},
|
|
2970
3020
|
{
|
|
2971
3021
|
method: "GET",
|
|
2972
3022
|
path: "/download",
|
|
2973
3023
|
description: "Stream a stored file as an attachment for authorized inspect readers",
|
|
2974
|
-
handler: (e) =>
|
|
2975
|
-
let t =
|
|
2976
|
-
if (!t?.trim()) return
|
|
2977
|
-
let { ref: n, stream: r } = yield*
|
|
3024
|
+
handler: (e) => y.gen(function* () {
|
|
3025
|
+
let t = we(e.url, "refId");
|
|
3026
|
+
if (!t?.trim()) return B(400, "A non-empty refId is required");
|
|
3027
|
+
let { ref: n, stream: r } = yield* F.getStream(t), i = n.key.split("/").pop() || n.id, a = encodeURIComponent(i).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
2978
3028
|
return {
|
|
2979
3029
|
kind: "bytes",
|
|
2980
3030
|
contentType: n.contentType,
|
|
2981
3031
|
byteStream: {
|
|
2982
|
-
stream: () =>
|
|
3032
|
+
stream: () => w.toReadableStream(r),
|
|
2983
3033
|
contentLength: n.size,
|
|
2984
3034
|
contentDisposition: `attachment; filename="download"; filename*=UTF-8''${a}`
|
|
2985
3035
|
},
|
|
2986
3036
|
headers: { "cache-control": "no-store" }
|
|
2987
3037
|
};
|
|
2988
|
-
}).pipe(
|
|
3038
|
+
}).pipe(y.catchAll((e) => y.succeed(B(e.status ?? 500, e.message))))
|
|
2989
3039
|
},
|
|
2990
3040
|
{
|
|
2991
3041
|
method: "GET",
|
|
2992
3042
|
path: "/refs",
|
|
3043
|
+
scope: "process",
|
|
2993
3044
|
description: "Searchable storage refs, newest first, paginated",
|
|
2994
3045
|
handler: (e) => {
|
|
2995
|
-
let t = Number(
|
|
2996
|
-
return
|
|
3046
|
+
let t = Number(we(e.url, "offset") ?? 0), n = Number.isSafeInteger(t) && t >= 0 ? t : 0, r = (we(e.url, "search") ?? "").trim().slice(0, 200);
|
|
3047
|
+
return pe.listRefs({
|
|
2997
3048
|
tenantId: void 0,
|
|
2998
3049
|
ownerId: void 0,
|
|
2999
3050
|
folder: void 0,
|
|
@@ -3002,121 +3053,123 @@ var En = () => N({
|
|
|
3002
3053
|
search: r,
|
|
3003
3054
|
limit: 51,
|
|
3004
3055
|
offset: n
|
|
3005
|
-
}).pipe(
|
|
3006
|
-
refs: e.slice(0, 50).map(
|
|
3056
|
+
}).pipe(y.map((e) => z({
|
|
3057
|
+
refs: e.slice(0, 50).map(Vn),
|
|
3007
3058
|
page: {
|
|
3008
3059
|
search: r,
|
|
3009
3060
|
offset: n,
|
|
3010
3061
|
nextOffset: e.length > 50 ? n + 50 : null
|
|
3011
3062
|
}
|
|
3012
|
-
})),
|
|
3063
|
+
})), y.catchAll((e) => y.succeed(B(500, e.message))));
|
|
3013
3064
|
}
|
|
3014
3065
|
},
|
|
3015
3066
|
{
|
|
3016
3067
|
method: "GET",
|
|
3017
3068
|
path: "/stats",
|
|
3069
|
+
scope: "process",
|
|
3018
3070
|
description: "Object count + total bytes per tenant + visibility split",
|
|
3019
|
-
handler: () =>
|
|
3020
|
-
provider:
|
|
3021
|
-
bucket:
|
|
3071
|
+
handler: () => pe.statistics().pipe(y.map((e) => z({
|
|
3072
|
+
provider: x.name,
|
|
3073
|
+
bucket: S,
|
|
3022
3074
|
...e
|
|
3023
|
-
})),
|
|
3075
|
+
})), y.catchAll((e) => y.succeed(B(500, e.message))))
|
|
3024
3076
|
},
|
|
3025
3077
|
{
|
|
3026
3078
|
method: "GET",
|
|
3027
3079
|
path: "/grants",
|
|
3080
|
+
scope: "process",
|
|
3028
3081
|
description: "Grants for a ref (?refId=…)",
|
|
3029
3082
|
handler: (e) => {
|
|
3030
|
-
let t =
|
|
3031
|
-
return t ?
|
|
3083
|
+
let t = we(e.url, "refId");
|
|
3084
|
+
return t ? N.listByRef(t).pipe(y.map((e) => z({ grants: e.map(qn) })), y.catchAll((e) => y.succeed(B(500, e.message)))) : y.succeed(B(400, "refId query param required"));
|
|
3032
3085
|
}
|
|
3033
3086
|
},
|
|
3034
3087
|
{
|
|
3035
3088
|
method: "POST",
|
|
3036
3089
|
path: "/share",
|
|
3037
3090
|
description: "Grant a principal access to a ref",
|
|
3038
|
-
handler: (e) =>
|
|
3039
|
-
let n = yield*
|
|
3040
|
-
refId:
|
|
3041
|
-
principalType:
|
|
3042
|
-
principalId:
|
|
3043
|
-
permission:
|
|
3044
|
-
expiresInDays:
|
|
3045
|
-
})))(e.body).pipe(
|
|
3091
|
+
handler: (e) => y.gen(function* () {
|
|
3092
|
+
let n = yield* C.decodeUnknown(C.parseJson(C.Struct({
|
|
3093
|
+
refId: C.String.pipe(C.filter((e) => e.trim().length > 0)),
|
|
3094
|
+
principalType: C.Literal("user", "group", "apiKey"),
|
|
3095
|
+
principalId: C.String.pipe(C.filter((e) => e.trim().length > 0)),
|
|
3096
|
+
permission: C.optional(C.Literal("read", "write")),
|
|
3097
|
+
expiresInDays: C.optional(C.Number.pipe(C.finite(), C.positive()))
|
|
3098
|
+
})))(e.body).pipe(y.mapError(() => new t({
|
|
3046
3099
|
provider: "inspect",
|
|
3047
3100
|
message: "Invalid share input: provide refId, principalType, principalId, read/write permission and a positive finite expiry if set",
|
|
3048
3101
|
transient: !1,
|
|
3049
3102
|
status: 400
|
|
3050
3103
|
}))), r = n.expiresInDays === void 0 ? null : new Date(Date.now() + n.expiresInDays * 864e5);
|
|
3051
|
-
if (r !== null && !Number.isFinite(r.getTime())) return
|
|
3052
|
-
let i = yield*
|
|
3104
|
+
if (r !== null && !Number.isFinite(r.getTime())) return B(400, "Expiry exceeds the supported date range");
|
|
3105
|
+
let i = yield* F.grant({
|
|
3053
3106
|
refId: n.refId,
|
|
3054
3107
|
principalType: n.principalType,
|
|
3055
3108
|
principalId: n.principalId,
|
|
3056
3109
|
...n.permission ? { permission: n.permission } : {},
|
|
3057
3110
|
expiresAt: r
|
|
3058
3111
|
});
|
|
3059
|
-
return
|
|
3060
|
-
}).pipe(
|
|
3112
|
+
return z({ grant: qn(i) });
|
|
3113
|
+
}).pipe(y.catchAll((e) => y.succeed(B(e.status ?? 500, e.message ?? "share failed"))))
|
|
3061
3114
|
},
|
|
3062
3115
|
{
|
|
3063
3116
|
method: "POST",
|
|
3064
3117
|
path: "/delete",
|
|
3065
3118
|
description: "Delete an object reference and its grants; release unreferenced bytes",
|
|
3066
|
-
handler: (e) =>
|
|
3067
|
-
let n = yield*
|
|
3119
|
+
handler: (e) => y.gen(function* () {
|
|
3120
|
+
let n = yield* C.decodeUnknown(C.parseJson(C.Struct({ refId: C.String.pipe(C.filter((e) => e.trim().length > 0)) })))(e.body).pipe(y.mapError(() => new t({
|
|
3068
3121
|
provider: "inspect",
|
|
3069
3122
|
message: "A non-empty refId is required",
|
|
3070
3123
|
transient: !1,
|
|
3071
3124
|
status: 400
|
|
3072
3125
|
})));
|
|
3073
|
-
return yield*
|
|
3074
|
-
}).pipe(
|
|
3126
|
+
return yield* F.delete(n.refId), z({ ok: !0 });
|
|
3127
|
+
}).pipe(y.catchAll((e) => y.succeed(B(e.status ?? 500, e.message))))
|
|
3075
3128
|
},
|
|
3076
3129
|
{
|
|
3077
3130
|
method: "POST",
|
|
3078
3131
|
path: "/revoke",
|
|
3079
3132
|
description: "Revoke a grant by id",
|
|
3080
|
-
handler: (e) =>
|
|
3081
|
-
let n = yield*
|
|
3133
|
+
handler: (e) => y.gen(function* () {
|
|
3134
|
+
let n = yield* C.decodeUnknown(C.parseJson(C.Struct({ grantId: C.String.pipe(C.filter((e) => e.trim().length > 0)) })))(e.body).pipe(y.mapError(() => new t({
|
|
3082
3135
|
provider: "inspect",
|
|
3083
3136
|
message: "A non-empty grantId is required",
|
|
3084
3137
|
transient: !1,
|
|
3085
3138
|
status: 400
|
|
3086
3139
|
})));
|
|
3087
|
-
return yield*
|
|
3088
|
-
}).pipe(
|
|
3140
|
+
return yield* F.revoke(n.grantId), z({ ok: !0 });
|
|
3141
|
+
}).pipe(y.catchAll((e) => y.succeed(B(e.status ?? 500, e.message ?? "revoke failed"))))
|
|
3089
3142
|
}
|
|
3090
|
-
],
|
|
3143
|
+
], Ee = [
|
|
3091
3144
|
{
|
|
3092
|
-
...
|
|
3145
|
+
...te,
|
|
3093
3146
|
execute: (e, t) => {
|
|
3094
3147
|
let n = e;
|
|
3095
|
-
return
|
|
3148
|
+
return F.mintUrl(n.id, t.request.subject, {
|
|
3096
3149
|
...n.password === void 0 ? {} : { password: n.password },
|
|
3097
3150
|
...n.expiresInSec === void 0 ? {} : { expiresInSec: n.expiresInSec }
|
|
3098
|
-
}).pipe(
|
|
3151
|
+
}).pipe(y.map((e) => ({ url: e })));
|
|
3099
3152
|
}
|
|
3100
3153
|
},
|
|
3101
3154
|
{
|
|
3102
3155
|
...ee,
|
|
3103
3156
|
execute: (e, t) => {
|
|
3104
3157
|
let n = e;
|
|
3105
|
-
return
|
|
3158
|
+
return F.mintUploadUrl({
|
|
3106
3159
|
key: n.key,
|
|
3107
3160
|
contentType: n.contentType,
|
|
3108
3161
|
tenantId: t.request.subject.tenantId,
|
|
3109
3162
|
...n.expiresInSec === void 0 ? {} : { expiresInSec: n.expiresInSec }
|
|
3110
|
-
}).pipe(
|
|
3163
|
+
}).pipe(y.map((e) => ({ url: e })));
|
|
3111
3164
|
}
|
|
3112
3165
|
},
|
|
3113
3166
|
{
|
|
3114
3167
|
...m,
|
|
3115
3168
|
execute: (e, t) => {
|
|
3116
3169
|
let n = e;
|
|
3117
|
-
return
|
|
3118
|
-
let t = n.expiresInSec ?? 900, r =
|
|
3119
|
-
instance:
|
|
3170
|
+
return Gn(t, D).pipe(y.map((e) => {
|
|
3171
|
+
let t = n.expiresInSec ?? 900, r = vt({
|
|
3172
|
+
instance: v,
|
|
3120
3173
|
sub: e.id,
|
|
3121
3174
|
tenant: e.tenantId,
|
|
3122
3175
|
ct: n.contentType,
|
|
@@ -3126,10 +3179,10 @@ var En = () => N({
|
|
|
3126
3179
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
3127
3180
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3128
3181
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3129
|
-
...
|
|
3182
|
+
...E === void 0 ? {} : { max: E }
|
|
3130
3183
|
}, t);
|
|
3131
3184
|
return {
|
|
3132
|
-
uploadUrl: `${
|
|
3185
|
+
uploadUrl: `${T ? T.replace(/\/+$/, "") : ""}${b}/upload?ticket=${encodeURIComponent(r)}`,
|
|
3133
3186
|
expiresInSec: t
|
|
3134
3187
|
};
|
|
3135
3188
|
}));
|
|
@@ -3139,13 +3192,13 @@ var En = () => N({
|
|
|
3139
3192
|
...p,
|
|
3140
3193
|
execute: (e, t) => {
|
|
3141
3194
|
let n = e;
|
|
3142
|
-
return
|
|
3195
|
+
return Gn(t, D).pipe(y.flatMap((e) => F.mintPresignedUpload({
|
|
3143
3196
|
contentType: n.contentType,
|
|
3144
3197
|
tenantId: e.tenantId,
|
|
3145
3198
|
...n.expiresInSec === void 0 ? {} : { expiresInSec: n.expiresInSec }
|
|
3146
|
-
}).pipe(
|
|
3147
|
-
let r =
|
|
3148
|
-
instance:
|
|
3199
|
+
}).pipe(y.map((t) => {
|
|
3200
|
+
let r = bt({
|
|
3201
|
+
instance: v,
|
|
3149
3202
|
key: t.key,
|
|
3150
3203
|
sub: e.id,
|
|
3151
3204
|
tenant: e.tenantId,
|
|
@@ -3155,7 +3208,7 @@ var En = () => N({
|
|
|
3155
3208
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
3156
3209
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3157
3210
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3158
|
-
...
|
|
3211
|
+
...E === void 0 ? {} : { max: E }
|
|
3159
3212
|
}, t.expiresInSec);
|
|
3160
3213
|
return {
|
|
3161
3214
|
uploadUrl: t.uploadUrl,
|
|
@@ -3168,18 +3221,18 @@ var En = () => N({
|
|
|
3168
3221
|
{
|
|
3169
3222
|
...l,
|
|
3170
3223
|
execute: (e, n) => {
|
|
3171
|
-
let r =
|
|
3172
|
-
return !r || r.instance !==
|
|
3224
|
+
let r = xt(e.finalizeToken);
|
|
3225
|
+
return !r || r.instance !== v ? y.fail(new t({
|
|
3173
3226
|
provider: "storage",
|
|
3174
3227
|
message: "invalid or expired finalize token",
|
|
3175
3228
|
transient: !1,
|
|
3176
3229
|
status: 401
|
|
3177
|
-
})) :
|
|
3230
|
+
})) : Kn(r.sub, n.request.subject.id) ? y.fail(new t({
|
|
3178
3231
|
provider: "storage",
|
|
3179
3232
|
message: "finalize token belongs to another subject",
|
|
3180
3233
|
transient: !1,
|
|
3181
3234
|
status: 403
|
|
3182
|
-
})) :
|
|
3235
|
+
})) : F.finalizeUpload({
|
|
3183
3236
|
key: r.key,
|
|
3184
3237
|
contentType: r.ct,
|
|
3185
3238
|
tenantId: r.tenant,
|
|
@@ -3189,7 +3242,7 @@ var En = () => N({
|
|
|
3189
3242
|
...r.tags === void 0 ? {} : { tags: r.tags },
|
|
3190
3243
|
...r.alt === void 0 ? {} : { alt: r.alt },
|
|
3191
3244
|
...r.caption === void 0 ? {} : { caption: r.caption }
|
|
3192
|
-
}).pipe(
|
|
3245
|
+
}).pipe(y.flatMap((e) => F.getUrl(e.id).pipe(y.map((t) => ({
|
|
3193
3246
|
id: e.id,
|
|
3194
3247
|
url: t,
|
|
3195
3248
|
contentType: e.contentType,
|
|
@@ -3203,12 +3256,12 @@ var En = () => N({
|
|
|
3203
3256
|
...s,
|
|
3204
3257
|
execute: (e, t) => {
|
|
3205
3258
|
let n = e;
|
|
3206
|
-
return
|
|
3207
|
-
let t = n.expiresInSec ??
|
|
3259
|
+
return Gn(t, D).pipe(y.map((e) => {
|
|
3260
|
+
let t = n.expiresInSec ?? de, r = ge(), i = n.chunkSize && n.chunkSize > 0 ? n.chunkSize : O;
|
|
3208
3261
|
return {
|
|
3209
3262
|
uploadId: r,
|
|
3210
|
-
resumableToken:
|
|
3211
|
-
instance:
|
|
3263
|
+
resumableToken: St({
|
|
3264
|
+
instance: v,
|
|
3212
3265
|
id: r,
|
|
3213
3266
|
sub: e.id,
|
|
3214
3267
|
tenant: e.tenantId,
|
|
@@ -3219,9 +3272,9 @@ var En = () => N({
|
|
|
3219
3272
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
3220
3273
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3221
3274
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3222
|
-
...
|
|
3275
|
+
...E === void 0 ? {} : { max: E }
|
|
3223
3276
|
}, t),
|
|
3224
|
-
uploadUrl: `${
|
|
3277
|
+
uploadUrl: `${T ? T.replace(/\/+$/, "") : ""}${b}/upload/resumable`,
|
|
3225
3278
|
chunkSize: i,
|
|
3226
3279
|
expiresInSec: t
|
|
3227
3280
|
};
|
|
@@ -3231,15 +3284,15 @@ var En = () => N({
|
|
|
3231
3284
|
{
|
|
3232
3285
|
...o,
|
|
3233
3286
|
execute: (e, t) => {
|
|
3234
|
-
let n = e, r = n.expiresInSec ??
|
|
3235
|
-
return
|
|
3287
|
+
let n = e, r = n.expiresInSec ?? de;
|
|
3288
|
+
return Gn(t, D).pipe(y.flatMap((e) => F.beginMultipartUpload({
|
|
3236
3289
|
contentType: n.contentType,
|
|
3237
3290
|
tenantId: e.tenantId,
|
|
3238
3291
|
visibility: n.visibility ?? "private",
|
|
3239
3292
|
expiresInSec: r
|
|
3240
|
-
}).pipe(
|
|
3241
|
-
multipartToken:
|
|
3242
|
-
instance:
|
|
3293
|
+
}).pipe(y.map((t) => ({
|
|
3294
|
+
multipartToken: wt({
|
|
3295
|
+
instance: v,
|
|
3243
3296
|
key: t.key,
|
|
3244
3297
|
uploadId: t.uploadId,
|
|
3245
3298
|
sub: e.id,
|
|
@@ -3252,47 +3305,47 @@ var En = () => N({
|
|
|
3252
3305
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3253
3306
|
...n.caption === void 0 ? {} : { caption: n.caption }
|
|
3254
3307
|
}, r),
|
|
3255
|
-
partSize: n.partSize && n.partSize >=
|
|
3308
|
+
partSize: n.partSize && n.partSize >= O ? n.partSize : O,
|
|
3256
3309
|
expiresInSec: r
|
|
3257
3310
|
})))));
|
|
3258
3311
|
}
|
|
3259
3312
|
},
|
|
3260
3313
|
{
|
|
3261
|
-
...
|
|
3314
|
+
...g,
|
|
3262
3315
|
execute: (e) => {
|
|
3263
|
-
let n = e, r =
|
|
3264
|
-
return !r || r.instance !==
|
|
3316
|
+
let n = e, r = Tt(n.multipartToken);
|
|
3317
|
+
return !r || r.instance !== v ? y.fail(new t({
|
|
3265
3318
|
provider: "storage",
|
|
3266
3319
|
message: "invalid or expired multipart token",
|
|
3267
3320
|
transient: !1,
|
|
3268
3321
|
status: 401
|
|
3269
|
-
})) : !Number.isInteger(n.partNumber) || n.partNumber < 1 ?
|
|
3322
|
+
})) : !Number.isInteger(n.partNumber) || n.partNumber < 1 ? y.fail(new t({
|
|
3270
3323
|
provider: "storage",
|
|
3271
3324
|
message: "partNumber must be a positive integer",
|
|
3272
3325
|
transient: !1,
|
|
3273
3326
|
status: 400
|
|
3274
|
-
})) :
|
|
3327
|
+
})) : F.signMultipartPart({
|
|
3275
3328
|
key: r.key,
|
|
3276
3329
|
uploadId: r.uploadId,
|
|
3277
3330
|
partNumber: n.partNumber
|
|
3278
|
-
}).pipe(
|
|
3331
|
+
}).pipe(y.map((e) => ({ url: e })));
|
|
3279
3332
|
}
|
|
3280
3333
|
},
|
|
3281
3334
|
{
|
|
3282
3335
|
...c,
|
|
3283
3336
|
execute: (e, n) => {
|
|
3284
|
-
let r = e, i =
|
|
3285
|
-
return !i || i.instance !==
|
|
3337
|
+
let r = e, i = Tt(r.multipartToken);
|
|
3338
|
+
return !i || i.instance !== v ? y.fail(new t({
|
|
3286
3339
|
provider: "storage",
|
|
3287
3340
|
message: "invalid or expired multipart token",
|
|
3288
3341
|
transient: !1,
|
|
3289
3342
|
status: 401
|
|
3290
|
-
})) :
|
|
3343
|
+
})) : Kn(i.sub, n.request.subject.id) ? y.fail(new t({
|
|
3291
3344
|
provider: "storage",
|
|
3292
3345
|
message: "multipart token belongs to another subject",
|
|
3293
3346
|
transient: !1,
|
|
3294
3347
|
status: 403
|
|
3295
|
-
})) :
|
|
3348
|
+
})) : F.completeMultipart({
|
|
3296
3349
|
key: i.key,
|
|
3297
3350
|
uploadId: i.uploadId,
|
|
3298
3351
|
parts: r.parts,
|
|
@@ -3304,7 +3357,7 @@ var En = () => N({
|
|
|
3304
3357
|
...i.tags === void 0 ? {} : { tags: i.tags },
|
|
3305
3358
|
...i.alt === void 0 ? {} : { alt: i.alt },
|
|
3306
3359
|
...i.caption === void 0 ? {} : { caption: i.caption }
|
|
3307
|
-
}).pipe(
|
|
3360
|
+
}).pipe(y.flatMap((e) => F.getUrl(e.id).pipe(y.map((t) => ({
|
|
3308
3361
|
id: e.id,
|
|
3309
3362
|
url: t,
|
|
3310
3363
|
size: e.size
|
|
@@ -3314,23 +3367,23 @@ var En = () => N({
|
|
|
3314
3367
|
{
|
|
3315
3368
|
...a,
|
|
3316
3369
|
execute: (e) => {
|
|
3317
|
-
let n =
|
|
3318
|
-
return !n || n.instance !==
|
|
3370
|
+
let n = Tt(e.multipartToken);
|
|
3371
|
+
return !n || n.instance !== v ? y.fail(new t({
|
|
3319
3372
|
provider: "storage",
|
|
3320
3373
|
message: "invalid or expired multipart token",
|
|
3321
3374
|
transient: !1,
|
|
3322
3375
|
status: 401
|
|
3323
|
-
})) :
|
|
3376
|
+
})) : F.abortMultipart({
|
|
3324
3377
|
key: n.key,
|
|
3325
3378
|
uploadId: n.uploadId
|
|
3326
|
-
}).pipe(
|
|
3379
|
+
}).pipe(y.as({ ok: !0 }));
|
|
3327
3380
|
}
|
|
3328
3381
|
},
|
|
3329
3382
|
{
|
|
3330
|
-
...
|
|
3383
|
+
...ie,
|
|
3331
3384
|
execute: (e, t) => {
|
|
3332
3385
|
let n = e, r = new Uint8Array(Buffer.from(n.bytesBase64, "base64"));
|
|
3333
|
-
return
|
|
3386
|
+
return Gn(t, D).pipe(y.flatMap((e) => F.put({
|
|
3334
3387
|
bytes: r,
|
|
3335
3388
|
contentType: n.contentType,
|
|
3336
3389
|
tenantId: e.tenantId,
|
|
@@ -3338,7 +3391,7 @@ var En = () => N({
|
|
|
3338
3391
|
...n.visibility ? { visibility: n.visibility } : {},
|
|
3339
3392
|
...n.key ? { key: n.key } : {},
|
|
3340
3393
|
...n.password ? { password: n.password } : {}
|
|
3341
|
-
})),
|
|
3394
|
+
})), y.flatMap((e) => F.getUrl(e.id).pipe(y.map((t) => ({
|
|
3342
3395
|
id: e.id,
|
|
3343
3396
|
url: t
|
|
3344
3397
|
})))));
|
|
@@ -3348,7 +3401,7 @@ var En = () => N({
|
|
|
3348
3401
|
...u,
|
|
3349
3402
|
execute: (e, t) => {
|
|
3350
3403
|
let n = e;
|
|
3351
|
-
return
|
|
3404
|
+
return Gn(t, D).pipe(y.flatMap((e) => F.ingestUrl(n.url, {
|
|
3352
3405
|
tenantId: e.tenantId,
|
|
3353
3406
|
ownerId: e.id,
|
|
3354
3407
|
...n.visibility ? { visibility: n.visibility } : {},
|
|
@@ -3357,45 +3410,45 @@ var En = () => N({
|
|
|
3357
3410
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3358
3411
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3359
3412
|
...n.key === void 0 ? {} : { key: n.key }
|
|
3360
|
-
})),
|
|
3413
|
+
})), y.flatMap((e) => F.getUrl(e.id).pipe(y.map((t) => ({
|
|
3361
3414
|
id: e.id,
|
|
3362
3415
|
url: t
|
|
3363
3416
|
})))));
|
|
3364
3417
|
}
|
|
3365
3418
|
},
|
|
3366
3419
|
{
|
|
3367
|
-
...
|
|
3420
|
+
...ne,
|
|
3368
3421
|
execute: (e, t) => {
|
|
3369
3422
|
let n = e, r = n.expiresInDays ? new Date(Date.now() + n.expiresInDays * 864e5) : null;
|
|
3370
|
-
return
|
|
3423
|
+
return Un(F, n.refId, t).pipe(y.flatMap(() => F.grant({
|
|
3371
3424
|
refId: n.refId,
|
|
3372
3425
|
principalType: n.principalType,
|
|
3373
3426
|
principalId: n.principalId,
|
|
3374
3427
|
...n.permission ? { permission: n.permission } : {},
|
|
3375
3428
|
expiresAt: r,
|
|
3376
3429
|
createdBy: t.request.subject.id
|
|
3377
|
-
})),
|
|
3430
|
+
})), y.map((e) => ({ grantId: e.id })));
|
|
3378
3431
|
}
|
|
3379
3432
|
},
|
|
3380
3433
|
{
|
|
3381
|
-
...
|
|
3434
|
+
...h,
|
|
3382
3435
|
execute: (e, t) => {
|
|
3383
3436
|
let n = e;
|
|
3384
|
-
return
|
|
3437
|
+
return F.getGrant(n.grantId).pipe(y.flatMap((e) => e === null ? y.fail(Hn()) : Un(F, e.refId, t)), y.flatMap(() => F.revoke(n.grantId)), y.map(() => ({ ok: !0 })));
|
|
3385
3438
|
}
|
|
3386
3439
|
},
|
|
3387
3440
|
{
|
|
3388
3441
|
...d,
|
|
3389
3442
|
execute: (e, t) => {
|
|
3390
3443
|
let n = e;
|
|
3391
|
-
return
|
|
3444
|
+
return Un(F, n.refId, t).pipe(y.flatMap(() => F.listGrants(n.refId)), y.map((e) => ({ grants: e.map(qn) })));
|
|
3392
3445
|
}
|
|
3393
3446
|
},
|
|
3394
3447
|
{
|
|
3395
3448
|
...f,
|
|
3396
3449
|
execute: (e, t) => {
|
|
3397
3450
|
let n = e;
|
|
3398
|
-
return
|
|
3451
|
+
return F.listRefs({
|
|
3399
3452
|
tenantId: t.request.subject.tenantId,
|
|
3400
3453
|
...n.folder === void 0 ? {} : { folder: n.folder },
|
|
3401
3454
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
@@ -3403,36 +3456,36 @@ var En = () => N({
|
|
|
3403
3456
|
...n.includeDerived === void 0 ? {} : { includeDerived: n.includeDerived },
|
|
3404
3457
|
...n.limit === void 0 ? {} : { limit: n.limit },
|
|
3405
3458
|
...n.offset === void 0 ? {} : { offset: n.offset }
|
|
3406
|
-
}).pipe(
|
|
3407
|
-
refs: e.refs.map(
|
|
3459
|
+
}).pipe(y.map((e) => ({
|
|
3460
|
+
refs: e.refs.map(Vn),
|
|
3408
3461
|
nextOffset: e.nextOffset
|
|
3409
3462
|
})));
|
|
3410
3463
|
}
|
|
3411
3464
|
}
|
|
3412
3465
|
];
|
|
3413
|
-
return
|
|
3414
|
-
name:
|
|
3415
|
-
base:
|
|
3466
|
+
return ae({
|
|
3467
|
+
name: oe({
|
|
3468
|
+
base: Jn,
|
|
3416
3469
|
alias: i.alias,
|
|
3417
3470
|
instance: i.name
|
|
3418
3471
|
}),
|
|
3419
|
-
baseName:
|
|
3472
|
+
baseName: Jn,
|
|
3420
3473
|
description: "File storage — StorageService over S3 / MinIO / filesystem / memory. Public objects served direct from bucket/CDN; private objects gated by an access policy + per-object grants. Checksums, tenant key-prefixing, _voltro_storage_refs + _voltro_storage_grants, retry.",
|
|
3421
3474
|
permissions: [
|
|
3422
3475
|
"network:outbound:*",
|
|
3423
3476
|
"inspect:read",
|
|
3424
3477
|
"inspect:write"
|
|
3425
3478
|
],
|
|
3426
|
-
declaredEnv:
|
|
3427
|
-
services:
|
|
3428
|
-
inspectEndpoints:
|
|
3479
|
+
declaredEnv: W.declared,
|
|
3480
|
+
services: me,
|
|
3481
|
+
inspectEndpoints: Te,
|
|
3429
3482
|
httpRoutes: [
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3483
|
+
xe,
|
|
3484
|
+
Se,
|
|
3485
|
+
Ce
|
|
3433
3486
|
],
|
|
3434
|
-
routes:
|
|
3435
|
-
rpcClientDescriptors:
|
|
3487
|
+
routes: Ee,
|
|
3488
|
+
rpcClientDescriptors: re,
|
|
3436
3489
|
errorSchemas: [
|
|
3437
3490
|
{
|
|
3438
3491
|
schema: t,
|
|
@@ -3465,7 +3518,7 @@ var En = () => N({
|
|
|
3465
3518
|
],
|
|
3466
3519
|
capabilities: { mediaPersist: {
|
|
3467
3520
|
put: async ({ bytes: e, mediaType: t, tenantId: n, operationId: r, ownerId: i, visibility: a, tags: o }) => {
|
|
3468
|
-
let s = await
|
|
3521
|
+
let s = await y.runPromise(F.put({
|
|
3469
3522
|
bytes: e,
|
|
3470
3523
|
contentType: t,
|
|
3471
3524
|
tenantId: n,
|
|
@@ -3473,40 +3526,40 @@ var En = () => N({
|
|
|
3473
3526
|
...i === void 0 ? {} : { ownerId: i },
|
|
3474
3527
|
...a === void 0 ? {} : { visibility: a },
|
|
3475
3528
|
...o === void 0 ? {} : { tags: o },
|
|
3476
|
-
...
|
|
3529
|
+
...fe.current === void 0 ? {} : { operationId: r }
|
|
3477
3530
|
}));
|
|
3478
3531
|
return {
|
|
3479
|
-
url: await
|
|
3532
|
+
url: await y.runPromise(F.getUrl(s.id, { tenantId: n })),
|
|
3480
3533
|
refId: s.id
|
|
3481
3534
|
};
|
|
3482
3535
|
},
|
|
3483
3536
|
ingestUrl: async ({ url: e, tenantId: t, operationId: n, ownerId: r, visibility: i, tags: a }) => {
|
|
3484
|
-
let o = await
|
|
3537
|
+
let o = await y.runPromise(F.ingestUrl(e, {
|
|
3485
3538
|
tenantId: t,
|
|
3486
3539
|
...r === void 0 ? {} : { ownerId: r },
|
|
3487
3540
|
...i === void 0 ? {} : { visibility: i },
|
|
3488
3541
|
...a === void 0 ? {} : { tags: a },
|
|
3489
|
-
...
|
|
3542
|
+
...fe.current === void 0 ? {} : { operationId: n }
|
|
3490
3543
|
}));
|
|
3491
3544
|
return {
|
|
3492
|
-
url: await
|
|
3545
|
+
url: await y.runPromise(F.getUrl(o.id, { tenantId: t })),
|
|
3493
3546
|
refId: o.id
|
|
3494
3547
|
};
|
|
3495
3548
|
}
|
|
3496
3549
|
} },
|
|
3497
3550
|
bindDataStore: (e) => {
|
|
3498
|
-
|
|
3551
|
+
k && (j.current = Wt(e)), A && (M.current = qt(e)), k && A && (fe.current = yn(e)), x.bindDataStore?.(e);
|
|
3499
3552
|
},
|
|
3500
|
-
onActivate: (e) =>
|
|
3501
|
-
let t = !!
|
|
3502
|
-
e.logger.info(`storage: provider=${
|
|
3503
|
-
provider:
|
|
3504
|
-
bucket:
|
|
3505
|
-
refStore:
|
|
3506
|
-
}),
|
|
3553
|
+
onActivate: (e) => y.sync(() => {
|
|
3554
|
+
let t = !!T || !!W.read("STORAGE_CDN_URL", i.cdnBaseUrl);
|
|
3555
|
+
e.logger.info(`storage: provider=${x.name} presign=${x.presigns ? "yes" : "no"} publicUrl=${t ? "yes" : "no"} transforms=yes`, {
|
|
3556
|
+
provider: x.name,
|
|
3557
|
+
bucket: S,
|
|
3558
|
+
refStore: k ? "memory" : "custom"
|
|
3559
|
+
}), x.name === "memory" && process.env.NODE_ENV !== "test" && e.logger.warn("storage: provider=memory — uploads are IN-MEMORY and LOST on restart. Set STORAGE_PROVIDER (filesystem / s3 / r2 / azure / gcs) for anything but throwaway dev. (Empty/placeholder storage env silently falls back to memory.)"), !t && !x.presigns && e.logger.warn("storage: no VOLTRO_PUBLIC_URL / STORAGE_CDN_URL and this provider can't presign — serve URLs are RELATIVE and will not resolve cross-origin (browser <img> / server-to-server AI fetches). Set VOLTRO_PUBLIC_URL to this api's absolute base URL.");
|
|
3507
3560
|
}),
|
|
3508
|
-
onDeactivate: () =>
|
|
3561
|
+
onDeactivate: () => y.void
|
|
3509
3562
|
});
|
|
3510
3563
|
};
|
|
3511
3564
|
//#endregion
|
|
3512
|
-
export {
|
|
3565
|
+
export { U as STORAGE_BLOBS_TABLE, H as STORAGE_GRANTS_TABLE, V as STORAGE_REFS_TABLE, Ne as STORAGE_USAGE_TABLE, e as StorageAccessDenied, t as StorageError, n as StorageRejected, r as StorageScanRejected, i as StorageService, Le as _voltroStorageBlobsTable, Fe as _voltroStorageGrantsTable, Pe as _voltroStorageRefsTable, Ie as _voltroStorageUsageTable, In as appStorageProvider, En as assetRef, qe as azureProvider, Xt as buildStorageService, De as bytesToStream, kt as checkLimits, Cn as clamavScanner, Ve as clearStorageBuffer, Oe as collectStream, Ee as concatBytes, Ln as configuredStorageProvider, Et as contentTypeAllowed, qt as dataStoreGrantStore, Wt as dataStoreRefStore, Ke as databaseProvider, kn as decodeDataUri, Mn as durabilityNotice, bn as encodeInstream, Tn as ffmpegTranscoder, Ue as filesystemProvider, ke as fromNodeReadable, je as getObjectStream, rt as hashPassword, yn as makeStorageObjectMetadata, Gt as memoryGrantStore, He as memoryProvider, Vt as memoryRefStore, xn as parseClamavResponse, Ye as parseTransformParams, jn as pathDurability, An as putAvatar, Me as putObjectStream, Be as readStorageBuffer, zt as refMatchesListQuery, Rn as resolveStorageProvider, K as resolveStorageSecret, We as s3Provider, Fn as setActiveStorageProvider, bt as signFinalizeTicket, gt as signGrant, wt as signMultipartTicket, St as signResumableTicket, vt as signUploadTicket, Ot as sniffMatches, Yn as storageInstanceName, en as storageObjectLifecycleTables, Xn as storagePlugin, gn as storagePutIntentsTable, Zt as storageServiceLayer, Ae as toNodeReadable, nt as transformCached, $e as transformImage, xt as verifyFinalizeTicket, _t as verifyGrant, Tt as verifyMultipartTicket, it as verifyPassword, Ct as verifyResumableTicket, yt as verifyUploadTicket, Dn as withStorage };
|