@voltro/plugin-storage 0.83.0 → 0.84.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 +717 -0
- package/THIRD-PARTY-NOTICES.md +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +738 -683
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -2,87 +2,87 @@ import { StorageAccessDenied as e, StorageError as t, StorageRejected as n, Stor
|
|
|
2
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
3
|
import { processIdentity as _ } from "@voltro/protocol/identity";
|
|
4
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
|
|
6
|
-
import { readCookie as
|
|
7
|
-
import { and as E, bytes as
|
|
8
|
-
import { pluginEnv as
|
|
9
|
-
import { createHash as
|
|
10
|
-
import { ssrfReason as
|
|
11
|
-
import { spawn as
|
|
12
|
-
import { mkdtemp as
|
|
13
|
-
import { tmpdir as
|
|
14
|
-
import { join as
|
|
15
|
-
import { statSync as
|
|
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, authoredError as ue, bigint as E, bytes as D, causeBranches as de, column as fe, contains as pe, eq as O, extractDbCause as me, generateId as k, id as A, integer as j, isTransientContention as he, json as ge, mixin as _e, neq as ve, or as M, reference as ye, table as N, text as P, timestamp as be, wireSafeCause as xe } from "@voltro/database";
|
|
8
|
+
import { pluginEnv as Se } from "@voltro/env";
|
|
9
|
+
import { createHash as Ce, createHmac as F, randomBytes as we, randomUUID as Te, scryptSync as Ee, timingSafeEqual as I } from "node:crypto";
|
|
10
|
+
import { ssrfReason as L } from "@voltro/runtime";
|
|
11
|
+
import { spawn as R } from "node:child_process";
|
|
12
|
+
import { mkdtemp as De, readFile as Oe, rm as ke, writeFile as Ae } from "node:fs/promises";
|
|
13
|
+
import { tmpdir as je } from "node:os";
|
|
14
|
+
import { join as Me } from "node:path";
|
|
15
|
+
import { statSync as Ne } from "node:fs";
|
|
16
16
|
//#region src/streamBridge.ts
|
|
17
|
-
var
|
|
17
|
+
var Pe = 1 << 20, Fe = (e, n, r = !1) => new t({
|
|
18
18
|
provider: e,
|
|
19
19
|
message: n,
|
|
20
20
|
transient: r
|
|
21
|
-
}),
|
|
21
|
+
}), Ie = (e) => {
|
|
22
22
|
let t = 0;
|
|
23
23
|
for (let n of e) t += n.byteLength;
|
|
24
24
|
let n = new Uint8Array(t), r = 0;
|
|
25
25
|
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
26
26
|
return n;
|
|
27
|
-
},
|
|
27
|
+
}, Le = (e, t = Pe) => {
|
|
28
28
|
let n = [];
|
|
29
29
|
for (let r = 0; r < e.byteLength; r += t) n.push(e.subarray(r, Math.min(r + t, e.byteLength)));
|
|
30
30
|
return w.fromIterable(n);
|
|
31
|
-
},
|
|
31
|
+
}, Re = (e) => e.pipe(w.runCollect, y.map((e) => Ie(v.toReadonlyArray(e)))), ze = (e, t) => w.suspend(() => w.fromAsyncIterable(t(), (t) => Fe(e, `read stream failed: ${String(t?.message ?? t)}`, !0))).pipe(w.map((e) => e instanceof Uint8Array ? e : new Uint8Array(e))), Be = async (e) => {
|
|
32
32
|
let { Readable: t } = await import("node:stream");
|
|
33
33
|
return t.fromWeb(w.toReadableStream(e));
|
|
34
|
-
},
|
|
35
|
-
stream:
|
|
34
|
+
}, Ve = (e, t) => e.getStream ? e.getStream(t) : e.get(t).pipe(y.map((e) => ({
|
|
35
|
+
stream: Le(e.bytes),
|
|
36
36
|
contentType: e.contentType,
|
|
37
37
|
size: e.bytes.byteLength
|
|
38
|
-
}))),
|
|
38
|
+
}))), He = (e, t, n, r) => e.putStream ? e.putStream(t, n, r) : Re(n).pipe(y.flatMap((n) => e.put(t, n, {
|
|
39
39
|
contentType: r.contentType,
|
|
40
40
|
...r.public === void 0 ? {} : { public: r.public }
|
|
41
|
-
}))),
|
|
42
|
-
id:
|
|
43
|
-
tenantId:
|
|
44
|
-
ownerId:
|
|
45
|
-
bucket:
|
|
46
|
-
key:
|
|
47
|
-
contentType:
|
|
48
|
-
size:
|
|
49
|
-
checksum:
|
|
50
|
-
visibility:
|
|
51
|
-
accessPolicy:
|
|
52
|
-
passwordHash:
|
|
53
|
-
width:
|
|
54
|
-
height:
|
|
55
|
-
duration:
|
|
56
|
-
placeholder:
|
|
57
|
-
folder:
|
|
58
|
-
tags:
|
|
59
|
-
alt:
|
|
60
|
-
caption:
|
|
61
|
-
derivedFrom:
|
|
62
|
-
kind:
|
|
63
|
-
createdAt:
|
|
64
|
-
}).index(["key"]).index(["tenantId"]).index(["ownerId"]).index(["folder"]).index(["derivedFrom"]),
|
|
65
|
-
id:
|
|
66
|
-
refId:
|
|
67
|
-
principalType:
|
|
68
|
-
principalId:
|
|
69
|
-
permission:
|
|
70
|
-
createdAt:
|
|
71
|
-
expiresAt:
|
|
72
|
-
createdBy:
|
|
73
|
-
}).index(["refId"]).index(["principalId"]),
|
|
74
|
-
id:
|
|
75
|
-
tenantId:
|
|
76
|
-
bytes:
|
|
77
|
-
count:
|
|
78
|
-
updatedAt:
|
|
79
|
-
}).unique("byStorageUsageTenant", ["tenantId"]),
|
|
80
|
-
id:
|
|
81
|
-
key:
|
|
82
|
-
data:
|
|
83
|
-
contentType:
|
|
84
|
-
size:
|
|
85
|
-
}).index(["key"]),
|
|
41
|
+
}))), z = "_voltro_storage_refs", B = "_voltro_storage_grants", V = "_voltro_storage_blobs", Ue = "_voltro_storage_usage", We = N(z, {
|
|
42
|
+
id: A({ prefix: "file" }),
|
|
43
|
+
tenantId: P().nullable(),
|
|
44
|
+
ownerId: P().nullable(),
|
|
45
|
+
bucket: P(),
|
|
46
|
+
key: P(),
|
|
47
|
+
contentType: P(),
|
|
48
|
+
size: E(),
|
|
49
|
+
checksum: P(),
|
|
50
|
+
visibility: P(),
|
|
51
|
+
accessPolicy: ge().nullable(),
|
|
52
|
+
passwordHash: P().nullable(),
|
|
53
|
+
width: j().nullable(),
|
|
54
|
+
height: j().nullable(),
|
|
55
|
+
duration: j().nullable(),
|
|
56
|
+
placeholder: P().nullable(),
|
|
57
|
+
folder: P().nullable(),
|
|
58
|
+
tags: ge().nullable(),
|
|
59
|
+
alt: P().nullable(),
|
|
60
|
+
caption: P().nullable(),
|
|
61
|
+
derivedFrom: P().nullable(),
|
|
62
|
+
kind: P().nullable(),
|
|
63
|
+
createdAt: be()
|
|
64
|
+
}).index(["key"]).index(["tenantId"]).index(["ownerId"]).index(["folder"]).index(["derivedFrom"]), Ge = N(B, {
|
|
65
|
+
id: A({ prefix: "sgrant" }),
|
|
66
|
+
refId: P(),
|
|
67
|
+
principalType: P(),
|
|
68
|
+
principalId: P(),
|
|
69
|
+
permission: P(),
|
|
70
|
+
createdAt: be(),
|
|
71
|
+
expiresAt: be().nullable(),
|
|
72
|
+
createdBy: P().nullable()
|
|
73
|
+
}).index(["refId"]).index(["principalId"]), Ke = N(Ue, {
|
|
74
|
+
id: A({ prefix: "susage" }),
|
|
75
|
+
tenantId: P().maxLength(191),
|
|
76
|
+
bytes: E().default("0"),
|
|
77
|
+
count: E().default("0"),
|
|
78
|
+
updatedAt: be()
|
|
79
|
+
}).unique("byStorageUsageTenant", ["tenantId"]), qe = N(V, {
|
|
80
|
+
id: A({ prefix: "blob" }),
|
|
81
|
+
key: P(),
|
|
82
|
+
data: D(),
|
|
83
|
+
contentType: P(),
|
|
84
|
+
size: E()
|
|
85
|
+
}).index(["key"]), H = Se([
|
|
86
86
|
{
|
|
87
87
|
name: "STORAGE_PROVIDER",
|
|
88
88
|
required: !1,
|
|
@@ -233,16 +233,36 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
233
233
|
secret: !1,
|
|
234
234
|
description: "clamd port for the optional clamav virus scanner. Default 3310."
|
|
235
235
|
}
|
|
236
|
-
]),
|
|
236
|
+
]), U = (e, n) => {
|
|
237
|
+
let r = typeof e == "number" ? e : typeof e == "bigint" || typeof e == "string" && /^\d+$/.test(e) ? Number(e) : NaN;
|
|
238
|
+
if (!Number.isSafeInteger(r) || r < 0) throw new t({
|
|
239
|
+
provider: "metadata",
|
|
240
|
+
message: `Storage ${n} must be a non-negative safe integer at most Number.MAX_SAFE_INTEGER`,
|
|
241
|
+
transient: !1
|
|
242
|
+
});
|
|
243
|
+
return r;
|
|
244
|
+
}, W = (e, t, n) => U(e + t, n), G = (e, n, r = !1) => {
|
|
245
|
+
let i = de(e).find(C.is(t));
|
|
246
|
+
if (i !== void 0) return i;
|
|
247
|
+
let a = me(e), o = a.dbCode === "22003" || a.dbSqlState === "22003" || a.dbCode === "ER_WARN_DATA_OUT_OF_RANGE" || a.dbErrno === 1264 || a.dbNumber === 8115 || a.dbNumber === 248, s = new t({
|
|
248
|
+
provider: n,
|
|
249
|
+
message: `${o ? "Storage metadata numeric value out of range: " : ""}${xe(e)}`,
|
|
250
|
+
transient: o ? !1 : he(e) || r
|
|
251
|
+
});
|
|
252
|
+
return Object.defineProperty(s, "cause", {
|
|
253
|
+
value: e,
|
|
254
|
+
configurable: !0
|
|
255
|
+
}), s;
|
|
256
|
+
}, Je = (e) => de(e).find(C.is(n)), K = (e, n, r, i) => new t({
|
|
237
257
|
provider: e,
|
|
238
258
|
message: n,
|
|
239
259
|
transient: r,
|
|
240
260
|
...i === void 0 ? {} : { status: i }
|
|
241
|
-
}),
|
|
242
|
-
|
|
243
|
-
},
|
|
244
|
-
let t =
|
|
245
|
-
return
|
|
261
|
+
}), Ye = (e) => e === void 0 || e === 408 || e === 429 || e >= 500, Xe = /* @__PURE__ */ new Map(), Ze = (e, t) => Xe.get(e)?.get(t)?.bytes, Qe = (e) => {
|
|
262
|
+
Xe.get(e)?.clear();
|
|
263
|
+
}, $e = (e = "default") => {
|
|
264
|
+
let t = Xe.get(e) ?? /* @__PURE__ */ new Map();
|
|
265
|
+
return Xe.set(e, t), {
|
|
246
266
|
name: "memory",
|
|
247
267
|
presigns: !1,
|
|
248
268
|
put: (e, n, r) => y.sync(() => (t.set(e, {
|
|
@@ -254,7 +274,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
254
274
|
return n ? y.succeed({
|
|
255
275
|
bytes: n.bytes,
|
|
256
276
|
contentType: n.contentType
|
|
257
|
-
}) : y.fail(
|
|
277
|
+
}) : y.fail(K("memory", `no object at key '${e}'`, !1, 404));
|
|
258
278
|
}),
|
|
259
279
|
delete: (e) => y.sync(() => {
|
|
260
280
|
t.delete(e);
|
|
@@ -266,14 +286,14 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
266
286
|
return n ? { size: n.bytes.byteLength } : null;
|
|
267
287
|
})
|
|
268
288
|
};
|
|
269
|
-
},
|
|
289
|
+
}, et = (e) => {
|
|
270
290
|
let t = e.root, n = async (e) => {
|
|
271
291
|
let { join: n, resolve: r, sep: i } = await import("node:path"), a = r(t), o = r(a, e);
|
|
272
292
|
if (o !== a && !o.startsWith(a + i)) throw Error(`key '${e}' escapes the storage root`);
|
|
273
293
|
return n(o);
|
|
274
294
|
}, r = (e, t, n = !1) => y.tryPromise({
|
|
275
295
|
try: e,
|
|
276
|
-
catch: (e) => e?.code === "ENOENT" ?
|
|
296
|
+
catch: (e) => e?.code === "ENOENT" ? K("filesystem", `no object at key '${t}'`, !1, 404) : K("filesystem", String(e?.message ?? e), n)
|
|
277
297
|
});
|
|
278
298
|
return {
|
|
279
299
|
root: t,
|
|
@@ -312,12 +332,12 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
312
332
|
throw e;
|
|
313
333
|
}
|
|
314
334
|
},
|
|
315
|
-
catch: (e) =>
|
|
335
|
+
catch: (e) => K("filesystem", String(e?.message ?? e), !1)
|
|
316
336
|
}),
|
|
317
337
|
getStream: (e) => r(async () => {
|
|
318
338
|
let t = await import("node:fs/promises"), { createReadStream: r } = await import("node:fs"), i = await n(e), a = await t.stat(i);
|
|
319
339
|
return {
|
|
320
|
-
stream:
|
|
340
|
+
stream: ze("filesystem", () => r(i)),
|
|
321
341
|
contentType: "application/octet-stream",
|
|
322
342
|
size: a.size
|
|
323
343
|
};
|
|
@@ -327,7 +347,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
327
347
|
await r.mkdir(i(c), { recursive: !0 });
|
|
328
348
|
let l = `${c}.tmp-${a()}`;
|
|
329
349
|
try {
|
|
330
|
-
await s(await
|
|
350
|
+
await s(await Be(t), o(l));
|
|
331
351
|
let e = await r.stat(l);
|
|
332
352
|
return await r.rename(l, c), { size: e.size };
|
|
333
353
|
} catch (e) {
|
|
@@ -342,10 +362,10 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
342
362
|
end: i
|
|
343
363
|
});
|
|
344
364
|
s.on("data", (e) => o.push(e)), s.on("end", () => e()), s.on("error", n);
|
|
345
|
-
}),
|
|
365
|
+
}), Ie(o);
|
|
346
366
|
}, e)
|
|
347
367
|
};
|
|
348
|
-
},
|
|
368
|
+
}, tt = (e) => {
|
|
349
369
|
let t = e.name ?? "s3", n = e.publicAcl ?? !0, r = null, i = () => r || (r = (async () => {
|
|
350
370
|
let t, n;
|
|
351
371
|
try {
|
|
@@ -370,7 +390,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
370
390
|
try: e,
|
|
371
391
|
catch: (e) => {
|
|
372
392
|
let n = e?.$metadata?.httpStatusCode;
|
|
373
|
-
return
|
|
393
|
+
return K(t, String(e?.message ?? e), Ye(n), n);
|
|
374
394
|
}
|
|
375
395
|
}), o = async (e) => {
|
|
376
396
|
let t = e;
|
|
@@ -493,7 +513,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
493
513
|
},
|
|
494
514
|
catch: (e) => {
|
|
495
515
|
let n = e?.$metadata?.httpStatusCode;
|
|
496
|
-
return
|
|
516
|
+
return K(t, String(e?.message ?? e), Ye(n), n);
|
|
497
517
|
}
|
|
498
518
|
}),
|
|
499
519
|
getStream: (n) => a(async () => {
|
|
@@ -502,7 +522,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
502
522
|
Key: n
|
|
503
523
|
})), s = o.Body;
|
|
504
524
|
return {
|
|
505
|
-
stream:
|
|
525
|
+
stream: ze(t, () => s),
|
|
506
526
|
contentType: o.ContentType ?? "application/octet-stream",
|
|
507
527
|
...o.ContentLength === void 0 ? {} : { size: o.ContentLength }
|
|
508
528
|
};
|
|
@@ -514,7 +534,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
514
534
|
} catch (e) {
|
|
515
535
|
throw Error("s3/minio `putStream` requires the '@aws-sdk/lib-storage' optional dependency (multipart upload). Install it to enable streamed uploads.", { cause: e });
|
|
516
536
|
}
|
|
517
|
-
let l = await
|
|
537
|
+
let l = await Be(r);
|
|
518
538
|
return await new c.Upload({
|
|
519
539
|
client: a,
|
|
520
540
|
params: {
|
|
@@ -538,15 +558,15 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
538
558
|
return o(c.Body);
|
|
539
559
|
})
|
|
540
560
|
};
|
|
541
|
-
},
|
|
561
|
+
}, nt = (e) => e instanceof Uint8Array ? e : typeof e == "string" ? new Uint8Array(Buffer.from(e, "base64")) : new Uint8Array(e), rt = () => {
|
|
542
562
|
let e = null, t = () => {
|
|
543
|
-
if (!e) throw
|
|
563
|
+
if (!e) throw ue("the 'database' storage provider isn't bound to a DataStore yet");
|
|
544
564
|
return e;
|
|
545
565
|
}, n = (e) => y.tryPromise({
|
|
546
566
|
try: e,
|
|
547
|
-
catch: (e) => G("database",
|
|
567
|
+
catch: (e) => G(e, "database", !0)
|
|
548
568
|
}), r = async (e, n) => (await t().query({
|
|
549
|
-
table:
|
|
569
|
+
table: V,
|
|
550
570
|
predicate: {
|
|
551
571
|
column: "key",
|
|
552
572
|
op: "eq",
|
|
@@ -565,37 +585,37 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
565
585
|
},
|
|
566
586
|
put: (e, i, a) => n(async () => {
|
|
567
587
|
let n = await r(e);
|
|
568
|
-
return n ? await t().update(
|
|
588
|
+
return n ? await t().update(V, String(n.id), {
|
|
569
589
|
data: i,
|
|
570
590
|
contentType: a.contentType,
|
|
571
|
-
size: i.byteLength
|
|
572
|
-
}) : await t().insert(
|
|
591
|
+
size: String(i.byteLength)
|
|
592
|
+
}) : await t().insert(V, {
|
|
573
593
|
id: k({
|
|
574
594
|
kind: "typeid",
|
|
575
595
|
prefix: "blob"
|
|
576
|
-
},
|
|
596
|
+
}, V),
|
|
577
597
|
key: e,
|
|
578
598
|
data: i,
|
|
579
599
|
contentType: a.contentType,
|
|
580
|
-
size: i.byteLength
|
|
600
|
+
size: String(i.byteLength)
|
|
581
601
|
}), { size: i.byteLength };
|
|
582
602
|
}),
|
|
583
603
|
get: (e) => y.suspend(() => n(() => r(e)).pipe(y.flatMap((t) => t ? y.succeed({
|
|
584
|
-
bytes:
|
|
604
|
+
bytes: nt(t.data),
|
|
585
605
|
contentType: String(t.contentType)
|
|
586
|
-
}) : y.fail(
|
|
606
|
+
}) : y.fail(K("database", `no object at key '${e}'`, !1, 404))))),
|
|
587
607
|
delete: (e) => n(async () => {
|
|
588
608
|
let n = await r(e, ["id"]);
|
|
589
|
-
n && await t().delete(
|
|
609
|
+
n && await t().delete(V, String(n.id));
|
|
590
610
|
}),
|
|
591
611
|
publicUrl: () => null,
|
|
592
612
|
getUrl: () => y.succeed(""),
|
|
593
613
|
head: (e) => n(async () => {
|
|
594
614
|
let t = await r(e, ["size"]);
|
|
595
|
-
return t ? { size:
|
|
615
|
+
return t ? { size: U(t.size, "blob size") } : null;
|
|
596
616
|
})
|
|
597
617
|
};
|
|
598
|
-
},
|
|
618
|
+
}, it = (e) => {
|
|
599
619
|
let t = null, n = () => t || (t = (async () => {
|
|
600
620
|
let t;
|
|
601
621
|
try {
|
|
@@ -603,7 +623,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
603
623
|
} catch (e) {
|
|
604
624
|
throw Error("the 'azure' storage provider requires the '@azure/storage-blob' optional dependency. Install it to enable it.", { cause: e });
|
|
605
625
|
}
|
|
606
|
-
let n =
|
|
626
|
+
let n = H.read("AZURE_STORAGE_ACCOUNT", e.accountName), r = H.read("AZURE_STORAGE_KEY", e.accountKey), i = n && r ? new t.StorageSharedKeyCredential(n, r) : null, a = H.read("AZURE_STORAGE_CONNECTION_STRING", e.connectionString);
|
|
607
627
|
return {
|
|
608
628
|
container: (a ? t.BlobServiceClient.fromConnectionString(a) : new t.BlobServiceClient(e.endpoint ?? `https://${n}.blob.core.windows.net`, i ?? void 0)).getContainerClient(e.container),
|
|
609
629
|
sdk: t,
|
|
@@ -613,7 +633,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
613
633
|
try: e,
|
|
614
634
|
catch: (e) => {
|
|
615
635
|
let t = e?.statusCode;
|
|
616
|
-
return
|
|
636
|
+
return K("azure", String(e?.message ?? e), Ye(t), t);
|
|
617
637
|
}
|
|
618
638
|
}), i = async (e) => {
|
|
619
639
|
if (!e) return /* @__PURE__ */ new Uint8Array();
|
|
@@ -671,19 +691,19 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
671
691
|
},
|
|
672
692
|
catch: (e) => {
|
|
673
693
|
let t = e?.statusCode;
|
|
674
|
-
return
|
|
694
|
+
return K("azure", String(e?.message ?? e), Ye(t), t);
|
|
675
695
|
}
|
|
676
696
|
}),
|
|
677
697
|
getStream: (e) => r(async () => {
|
|
678
698
|
let { container: t } = await n(), r = await t.getBlockBlobClient(e).download();
|
|
679
699
|
return {
|
|
680
|
-
stream:
|
|
700
|
+
stream: ze("azure", () => r.readableStreamBody),
|
|
681
701
|
contentType: r.contentType ?? "application/octet-stream",
|
|
682
702
|
...r.contentLength === void 0 ? {} : { size: r.contentLength }
|
|
683
703
|
};
|
|
684
704
|
}),
|
|
685
705
|
putStream: (e, t, i) => r(async () => {
|
|
686
|
-
let { container: r } = await n(), a = await
|
|
706
|
+
let { container: r } = await n(), a = await Be(t);
|
|
687
707
|
return await r.getBlockBlobClient(e).uploadStream(a, 4194304, 5, { blobHTTPHeaders: { blobContentType: i.contentType } }), { size: i.totalSize ?? (await r.getBlockBlobClient(e).getProperties()).contentLength ?? 0 };
|
|
688
708
|
}),
|
|
689
709
|
getRange: (e, t, a) => r(async () => {
|
|
@@ -691,7 +711,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
691
711
|
return i(o.readableStreamBody);
|
|
692
712
|
})
|
|
693
713
|
};
|
|
694
|
-
},
|
|
714
|
+
}, at = (e, t, n, r, i, a) => {
|
|
695
715
|
let o = n / r, s = Math.min(e, Math.round(t * o)), c = Math.min(t, Math.round(s / o)), l = (e, t) => Math.max(0, Math.min(t, e));
|
|
696
716
|
return {
|
|
697
717
|
left: l(Math.round(i * e - s / 2), e - s),
|
|
@@ -699,13 +719,13 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
699
719
|
width: s,
|
|
700
720
|
height: c
|
|
701
721
|
};
|
|
702
|
-
},
|
|
722
|
+
}, ot = {
|
|
703
723
|
webp: "image/webp",
|
|
704
724
|
avif: "image/avif",
|
|
705
725
|
jpeg: "image/jpeg",
|
|
706
726
|
jpg: "image/jpeg",
|
|
707
727
|
png: "image/png"
|
|
708
|
-
},
|
|
728
|
+
}, st = (e) => {
|
|
709
729
|
if (!e) return null;
|
|
710
730
|
let t = new URLSearchParams(e), n = (e) => {
|
|
711
731
|
let n = t.get(e);
|
|
@@ -724,24 +744,24 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
724
744
|
...s ? { fit: s } : {},
|
|
725
745
|
...l ? { fp: l } : {}
|
|
726
746
|
};
|
|
727
|
-
},
|
|
728
|
-
if (
|
|
747
|
+
}, ct = (e) => e.startsWith("image/") && !e.includes("svg"), lt, ut = async () => {
|
|
748
|
+
if (lt !== void 0) return lt;
|
|
729
749
|
try {
|
|
730
750
|
let e = await import("sharp");
|
|
731
|
-
|
|
751
|
+
lt = e.default ?? e;
|
|
732
752
|
} catch {
|
|
733
|
-
|
|
753
|
+
lt = null;
|
|
734
754
|
}
|
|
735
|
-
return
|
|
736
|
-
},
|
|
737
|
-
if (!
|
|
738
|
-
let r = await
|
|
755
|
+
return lt;
|
|
756
|
+
}, dt = async (e, t) => t ? null : ct(e) ? await ut() === null ? "no-sharp" : "failed" : "not-an-image", ft = async (e, t, n) => {
|
|
757
|
+
if (!ct(t)) return null;
|
|
758
|
+
let r = await ut();
|
|
739
759
|
if (!r) return null;
|
|
740
760
|
try {
|
|
741
761
|
let i = r(Buffer.from(e), { failOn: "none" }), a = n.fit ?? "cover";
|
|
742
762
|
if (n.fp !== void 0 && n.w !== void 0 && n.h !== void 0 && a === "cover") {
|
|
743
763
|
let e = await i.metadata();
|
|
744
|
-
e.width !== void 0 && e.height !== void 0 && (i = i.extract(
|
|
764
|
+
e.width !== void 0 && e.height !== void 0 && (i = i.extract(at(e.width, e.height, n.w, n.h, n.fp.x, n.fp.y)));
|
|
745
765
|
}
|
|
746
766
|
(n.w !== void 0 || n.h !== void 0) && (i = i.resize({
|
|
747
767
|
...n.w === void 0 ? {} : { width: n.w },
|
|
@@ -749,10 +769,10 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
749
769
|
fit: n.fit ?? "cover",
|
|
750
770
|
withoutEnlargement: !0
|
|
751
771
|
}));
|
|
752
|
-
let o = n.format &&
|
|
772
|
+
let o = n.format && ot[n.format] ? n.format : void 0, s = t;
|
|
753
773
|
if (o) {
|
|
754
774
|
let e = o === "jpg" ? "jpeg" : o;
|
|
755
|
-
i = i.toFormat(e, n.q === void 0 ? {} : { quality: n.q }), s =
|
|
775
|
+
i = i.toFormat(e, n.q === void 0 ? {} : { quality: n.q }), s = ot[o];
|
|
756
776
|
} else n.q !== void 0 && (t === "image/jpeg" || t === "image/webp") && (i = i.toFormat(t === "image/webp" ? "webp" : "jpeg", { quality: n.q }));
|
|
757
777
|
let c = await i.toBuffer();
|
|
758
778
|
return {
|
|
@@ -762,43 +782,43 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
762
782
|
} catch {
|
|
763
783
|
return null;
|
|
764
784
|
}
|
|
765
|
-
},
|
|
766
|
-
let i = `${e}::${JSON.stringify(r)}`, a =
|
|
785
|
+
}, pt = 200, mt = /* @__PURE__ */ new Map(), ht = async (e, t, n, r) => {
|
|
786
|
+
let i = `${e}::${JSON.stringify(r)}`, a = mt.get(i);
|
|
767
787
|
if (a) return a;
|
|
768
|
-
let o = await
|
|
769
|
-
if (o && (
|
|
770
|
-
let e =
|
|
771
|
-
e !== void 0 &&
|
|
788
|
+
let o = await ft(t, n, r);
|
|
789
|
+
if (o && (mt.set(i, o), mt.size > pt)) {
|
|
790
|
+
let e = mt.keys().next().value;
|
|
791
|
+
e !== void 0 && mt.delete(e);
|
|
772
792
|
}
|
|
773
793
|
return o;
|
|
774
|
-
},
|
|
775
|
-
let t =
|
|
776
|
-
return `${t}:${
|
|
777
|
-
},
|
|
794
|
+
}, gt = (e) => {
|
|
795
|
+
let t = we(16).toString("hex");
|
|
796
|
+
return `${t}:${Ee(e, t, 32).toString("hex")}`;
|
|
797
|
+
}, _t = (e, t) => {
|
|
778
798
|
if (!e || !t) return !1;
|
|
779
799
|
let [n, r] = t.split(":");
|
|
780
800
|
if (!n || !r) return !1;
|
|
781
|
-
let i = Buffer.from(r, "hex"), a =
|
|
782
|
-
return a.length === i.length &&
|
|
783
|
-
},
|
|
801
|
+
let i = Buffer.from(r, "hex"), a = Ee(e, n, i.length);
|
|
802
|
+
return a.length === i.length && I(a, i);
|
|
803
|
+
}, vt = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], yt = (e) => vt(e.metadata?.roles), bt = (e) => vt(e.scopes), xt = (e, t) => e.some((e) => t.includes(e)), St = (e) => vt(e.metadata?.groups), Ct = (e) => typeof e == "boolean" ? y.succeed(e) : y.isEffect(e) ? e : y.promise(() => e), wt = (e, t, n = {}) => y.gen(function* () {
|
|
784
804
|
if (t.id && e.ownerId && t.id === e.ownerId) return !0;
|
|
785
805
|
let r = e.accessPolicy ?? [];
|
|
786
806
|
if (r.length === 0) return !1;
|
|
787
|
-
let i = n.resolveGroups ? yield* y.promise(async () => await n.resolveGroups(t)) :
|
|
788
|
-
for (let a of r) if (yield*
|
|
807
|
+
let i = n.resolveGroups ? yield* y.promise(async () => await n.resolveGroups(t)) : St(t);
|
|
808
|
+
for (let a of r) if (yield* Tt(a, e, t, i, n)) return !0;
|
|
789
809
|
return !1;
|
|
790
|
-
}),
|
|
810
|
+
}), Tt = (e, t, n, r, i) => y.gen(function* () {
|
|
791
811
|
let a = !1, o = (e) => (a = !0, e);
|
|
792
|
-
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(
|
|
812
|
+
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(xt(yt(n), e.roles)) || e.groups && e.groups.length > 0 && !o(xt(r, e.groups)) || e.scopes && e.scopes.length > 0 && !o(xt(bt(n), e.scopes)) || e.password !== void 0 && e.password && !o(_t(i.password, t.passwordHash))) return !1;
|
|
793
813
|
if (e.guard) {
|
|
794
814
|
let r = i.guards?.[e.guard];
|
|
795
|
-
if (!o(r ? yield*
|
|
815
|
+
if (!o(r ? yield* Ct(r({
|
|
796
816
|
subject: n,
|
|
797
817
|
ref: t
|
|
798
818
|
})) : !1)) return !1;
|
|
799
819
|
}
|
|
800
820
|
return a;
|
|
801
|
-
}),
|
|
821
|
+
}), Et = (e, t) => {
|
|
802
822
|
let n = [];
|
|
803
823
|
e.id && n.push({
|
|
804
824
|
type: e.type === "apiKey" ? "apiKey" : "user",
|
|
@@ -809,116 +829,116 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
809
829
|
id: e
|
|
810
830
|
});
|
|
811
831
|
return n;
|
|
812
|
-
},
|
|
813
|
-
let a =
|
|
832
|
+
}, Dt = (e, t, n, r, i) => {
|
|
833
|
+
let a = Et(t, n);
|
|
814
834
|
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));
|
|
815
|
-
},
|
|
835
|
+
}, Ot = (e, t) => t.resolveGroups ? y.promise(async () => await t.resolveGroups(e)) : y.succeed(St(e)), q = () => H.read("VOLTRO_STORAGE_SECRET") ?? ce(), J = (e) => (typeof e == "string" ? Buffer.from(e, "utf8") : e).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""), Y = (e) => {
|
|
816
836
|
let t = e.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - e.length % 4) % 4);
|
|
817
837
|
return Buffer.from(t, "base64");
|
|
818
|
-
},
|
|
838
|
+
}, kt = (e, t, n = q(), r = "/_voltro/storage") => {
|
|
819
839
|
if (!n) throw Error("signGrant: secret must be a non-empty string");
|
|
820
840
|
let i = {
|
|
821
841
|
refId: e,
|
|
822
842
|
audience: r,
|
|
823
843
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
824
|
-
}, a =
|
|
825
|
-
return `${a}.${
|
|
826
|
-
},
|
|
844
|
+
}, a = J(JSON.stringify(i));
|
|
845
|
+
return `${a}.${J(F("sha256", n).update(a).digest())}`;
|
|
846
|
+
}, At = (e, t = q()) => {
|
|
827
847
|
if (!e || !t) return null;
|
|
828
848
|
let n = e.indexOf(".");
|
|
829
849
|
if (n <= 0 || n === e.length - 1) return null;
|
|
830
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
831
|
-
if (o.length !== a.length || !
|
|
850
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = F("sha256", t).update(r).digest(), o = Y(i);
|
|
851
|
+
if (o.length !== a.length || !I(o, a)) return null;
|
|
832
852
|
try {
|
|
833
|
-
let e = JSON.parse(
|
|
853
|
+
let e = JSON.parse(Y(r).toString("utf8"));
|
|
834
854
|
return typeof e.audience != "string" || !e.audience || typeof e.refId != "string" || typeof e.exp != "number" || e.exp < Math.floor(Date.now() / 1e3) ? null : e;
|
|
835
855
|
} catch {
|
|
836
856
|
return null;
|
|
837
857
|
}
|
|
838
|
-
},
|
|
858
|
+
}, jt = (e, t, n = q()) => {
|
|
839
859
|
if (!n) throw Error("signUploadTicket: secret must be a non-empty string");
|
|
840
860
|
let r = {
|
|
841
861
|
...e,
|
|
842
862
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
843
|
-
}, i =
|
|
844
|
-
return `${i}.${
|
|
845
|
-
},
|
|
863
|
+
}, i = J(JSON.stringify(r));
|
|
864
|
+
return `${i}.${J(F("sha256", n).update(`u:${i}`).digest())}`;
|
|
865
|
+
}, Mt = (e, t = q()) => {
|
|
846
866
|
if (!e || !t) return null;
|
|
847
867
|
let n = e.indexOf(".");
|
|
848
868
|
if (n <= 0 || n === e.length - 1) return null;
|
|
849
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
850
|
-
if (o.length !== a.length || !
|
|
869
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = F("sha256", t).update(`u:${r}`).digest(), o = Y(i);
|
|
870
|
+
if (o.length !== a.length || !I(o, a)) return null;
|
|
851
871
|
try {
|
|
852
|
-
let e = JSON.parse(
|
|
872
|
+
let e = JSON.parse(Y(r).toString("utf8"));
|
|
853
873
|
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;
|
|
854
874
|
} catch {
|
|
855
875
|
return null;
|
|
856
876
|
}
|
|
857
|
-
},
|
|
877
|
+
}, Nt = (e, t, n = q()) => {
|
|
858
878
|
if (!n) throw Error("signFinalizeTicket: secret must be a non-empty string");
|
|
859
879
|
let r = {
|
|
860
880
|
...e,
|
|
861
881
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
862
|
-
}, i =
|
|
863
|
-
return `${i}.${
|
|
864
|
-
},
|
|
882
|
+
}, i = J(JSON.stringify(r));
|
|
883
|
+
return `${i}.${J(F("sha256", n).update(`f:${i}`).digest())}`;
|
|
884
|
+
}, Pt = (e, t = q()) => {
|
|
865
885
|
if (!e || !t) return null;
|
|
866
886
|
let n = e.indexOf(".");
|
|
867
887
|
if (n <= 0 || n === e.length - 1) return null;
|
|
868
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
869
|
-
if (o.length !== a.length || !
|
|
888
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = F("sha256", t).update(`f:${r}`).digest(), o = Y(i);
|
|
889
|
+
if (o.length !== a.length || !I(o, a)) return null;
|
|
870
890
|
try {
|
|
871
|
-
let e = JSON.parse(
|
|
891
|
+
let e = JSON.parse(Y(r).toString("utf8"));
|
|
872
892
|
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;
|
|
873
893
|
} catch {
|
|
874
894
|
return null;
|
|
875
895
|
}
|
|
876
|
-
},
|
|
896
|
+
}, Ft = (e, t, n = q()) => {
|
|
877
897
|
if (!n) throw Error("signResumableTicket: secret must be a non-empty string");
|
|
878
898
|
let r = {
|
|
879
899
|
...e,
|
|
880
900
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
881
|
-
}, i =
|
|
882
|
-
return `${i}.${
|
|
883
|
-
},
|
|
901
|
+
}, i = J(JSON.stringify(r));
|
|
902
|
+
return `${i}.${J(F("sha256", n).update(`r:${i}`).digest())}`;
|
|
903
|
+
}, It = (e, t = q()) => {
|
|
884
904
|
if (!e || !t) return null;
|
|
885
905
|
let n = e.indexOf(".");
|
|
886
906
|
if (n <= 0 || n === e.length - 1) return null;
|
|
887
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
888
|
-
if (o.length !== a.length || !
|
|
907
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = F("sha256", t).update(`r:${r}`).digest(), o = Y(i);
|
|
908
|
+
if (o.length !== a.length || !I(o, a)) return null;
|
|
889
909
|
try {
|
|
890
|
-
let e = JSON.parse(
|
|
910
|
+
let e = JSON.parse(Y(r).toString("utf8"));
|
|
891
911
|
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;
|
|
892
912
|
} catch {
|
|
893
913
|
return null;
|
|
894
914
|
}
|
|
895
|
-
},
|
|
915
|
+
}, Lt = (e, t, n = q()) => {
|
|
896
916
|
if (!n) throw Error("signMultipartTicket: secret must be a non-empty string");
|
|
897
917
|
let r = {
|
|
898
918
|
...e,
|
|
899
919
|
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
900
|
-
}, i =
|
|
901
|
-
return `${i}.${
|
|
902
|
-
},
|
|
920
|
+
}, i = J(JSON.stringify(r));
|
|
921
|
+
return `${i}.${J(F("sha256", n).update(`m:${i}`).digest())}`;
|
|
922
|
+
}, Rt = (e, t = q()) => {
|
|
903
923
|
if (!e || !t) return null;
|
|
904
924
|
let n = e.indexOf(".");
|
|
905
925
|
if (n <= 0 || n === e.length - 1) return null;
|
|
906
|
-
let r = e.slice(0, n), i = e.slice(n + 1), a =
|
|
907
|
-
if (o.length !== a.length || !
|
|
926
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = F("sha256", t).update(`m:${r}`).digest(), o = Y(i);
|
|
927
|
+
if (o.length !== a.length || !I(o, a)) return null;
|
|
908
928
|
try {
|
|
909
|
-
let e = JSON.parse(
|
|
929
|
+
let e = JSON.parse(Y(r).toString("utf8"));
|
|
910
930
|
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;
|
|
911
931
|
} catch {
|
|
912
932
|
return null;
|
|
913
933
|
}
|
|
914
|
-
},
|
|
934
|
+
}, zt = (e, t) => {
|
|
915
935
|
if (!t || t.length === 0) return !0;
|
|
916
936
|
let n = e.toLowerCase();
|
|
917
937
|
return t.some((e) => {
|
|
918
938
|
let t = e.toLowerCase();
|
|
919
939
|
return t.endsWith("/*") ? n.startsWith(t.slice(0, -1)) : n === t;
|
|
920
940
|
});
|
|
921
|
-
},
|
|
941
|
+
}, Bt = [
|
|
922
942
|
{
|
|
923
943
|
ct: /^image\/png$/,
|
|
924
944
|
offset: 0,
|
|
@@ -988,21 +1008,21 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
988
1008
|
offset: 0,
|
|
989
1009
|
magic: [31, 139]
|
|
990
1010
|
}
|
|
991
|
-
],
|
|
992
|
-
let n = t.toLowerCase(), r =
|
|
1011
|
+
], Vt = (e, t) => {
|
|
1012
|
+
let n = t.toLowerCase(), r = Bt.find((e) => e.ct.test(n));
|
|
993
1013
|
return r ? e.length < r.offset + r.magic.length ? !1 : r.magic.every((t, n) => e[r.offset + n] === t) : !0;
|
|
994
|
-
},
|
|
1014
|
+
}, Ht = (e, t, n) => n ? n.maxBytes !== void 0 && e.byteLength > n.maxBytes ? {
|
|
995
1015
|
reason: "too-large",
|
|
996
1016
|
detail: `${e.byteLength} bytes exceeds the ${n.maxBytes}-byte limit`
|
|
997
|
-
} :
|
|
1017
|
+
} : zt(t, n.allowedContentTypes) ? n.sniff && !Vt(e, t) ? {
|
|
998
1018
|
reason: "content-mismatch",
|
|
999
1019
|
detail: `bytes do not match the declared content type '${t}'`
|
|
1000
1020
|
} : null : {
|
|
1001
1021
|
reason: "content-type-not-allowed",
|
|
1002
1022
|
detail: `content type '${t}' is not in the allow-list`
|
|
1003
|
-
} : null,
|
|
1004
|
-
if (!
|
|
1005
|
-
let r = await
|
|
1023
|
+
} : null, Ut = async (e, t, n) => {
|
|
1024
|
+
if (!ct(t)) return { bytes: e };
|
|
1025
|
+
let r = await ut();
|
|
1006
1026
|
if (!r) return { bytes: e };
|
|
1007
1027
|
try {
|
|
1008
1028
|
let t = e;
|
|
@@ -1025,14 +1045,14 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1025
1045
|
} catch {
|
|
1026
1046
|
return { bytes: e };
|
|
1027
1047
|
}
|
|
1028
|
-
},
|
|
1048
|
+
}, Wt = 67108864, Gt = (e) => new n({
|
|
1029
1049
|
reason: "too-large",
|
|
1030
1050
|
detail: `remote body exceeds the ${e}-byte ingest limit`
|
|
1031
|
-
}),
|
|
1051
|
+
}), Kt = (e, t) => new n({
|
|
1032
1052
|
reason: "blocked-source",
|
|
1033
1053
|
detail: `will not fetch ${e}: ${t}`
|
|
1034
|
-
}),
|
|
1035
|
-
let a = r ??
|
|
1054
|
+
}), qt = (e, r, i = {}) => y.suspend(() => {
|
|
1055
|
+
let a = r ?? Wt;
|
|
1036
1056
|
return !Number.isSafeInteger(a) || a < 0 ? y.fail(new t({
|
|
1037
1057
|
provider: "ingest",
|
|
1038
1058
|
message: "limits.maxBytes must be a non-negative safe integer",
|
|
@@ -1041,15 +1061,15 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1041
1061
|
try: async (n) => {
|
|
1042
1062
|
let r = e, o;
|
|
1043
1063
|
for (let e = 0;; e++) {
|
|
1044
|
-
let t =
|
|
1045
|
-
if (t !== null) throw
|
|
1064
|
+
let t = L(r, { ...i.allowHosts === void 0 ? {} : { allowHosts: i.allowHosts } });
|
|
1065
|
+
if (t !== null) throw Kt(r, t);
|
|
1046
1066
|
o = await fetch(r, {
|
|
1047
1067
|
signal: n,
|
|
1048
1068
|
redirect: "manual"
|
|
1049
1069
|
});
|
|
1050
1070
|
let a = o.headers.get("location");
|
|
1051
1071
|
if (o.status < 300 || o.status >= 400 || a === null) break;
|
|
1052
|
-
if (await o.body?.cancel().catch(() => {}), e >= (i.maxRedirects ?? 5)) throw
|
|
1072
|
+
if (await o.body?.cancel().catch(() => {}), e >= (i.maxRedirects ?? 5)) throw Kt(r, "too many redirects");
|
|
1053
1073
|
r = new URL(a, r).toString();
|
|
1054
1074
|
}
|
|
1055
1075
|
let s;
|
|
@@ -1061,12 +1081,12 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1061
1081
|
status: o.status
|
|
1062
1082
|
});
|
|
1063
1083
|
let e = o.headers.get("content-length"), n = o.headers.get("content-encoding")?.trim().toLowerCase();
|
|
1064
|
-
if ((!n || n === "identity") && e !== null && /^\d+$/.test(e) && BigInt(e) > BigInt(a)) throw
|
|
1084
|
+
if ((!n || n === "identity") && e !== null && /^\d+$/.test(e) && BigInt(e) > BigInt(a)) throw Gt(a);
|
|
1065
1085
|
let r = /* @__PURE__ */ new Uint8Array(), i = 0;
|
|
1066
1086
|
if (o.body !== null) for (s = o.body.getReader();;) {
|
|
1067
1087
|
let e = await s.read();
|
|
1068
1088
|
if (e.done) break;
|
|
1069
|
-
if (e.value.byteLength > a - i) throw
|
|
1089
|
+
if (e.value.byteLength > a - i) throw Gt(a);
|
|
1070
1090
|
if (e.value.byteLength !== 0) {
|
|
1071
1091
|
let t = i + e.value.byteLength;
|
|
1072
1092
|
if (t > r.byteLength) {
|
|
@@ -1090,7 +1110,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1090
1110
|
transient: !0
|
|
1091
1111
|
})
|
|
1092
1112
|
});
|
|
1093
|
-
}),
|
|
1113
|
+
}), Jt = (e, t) => y.suspend(() => {
|
|
1094
1114
|
if (t === void 0) return e;
|
|
1095
1115
|
if (t.aborted) return y.interrupt;
|
|
1096
1116
|
let n = y.async((e) => {
|
|
@@ -1098,18 +1118,27 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1098
1118
|
return t.addEventListener("abort", n, { once: !0 }), t.aborted && n(), y.sync(() => t.removeEventListener("abort", n));
|
|
1099
1119
|
});
|
|
1100
1120
|
return y.raceFirst(e, n);
|
|
1101
|
-
}),
|
|
1102
|
-
let r = (e,
|
|
1103
|
-
try:
|
|
1104
|
-
catch: (
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1121
|
+
}), Yt = (e) => {
|
|
1122
|
+
let r = (e, n) => y.tryPromise({
|
|
1123
|
+
try: n,
|
|
1124
|
+
catch: (n) => {
|
|
1125
|
+
let r = Je(n);
|
|
1126
|
+
if (r !== void 0) return r;
|
|
1127
|
+
let i = G(n, "metadata"), a = new t({
|
|
1128
|
+
provider: "metadata",
|
|
1129
|
+
message: `Storage ${e} was not confirmed: ${i.message}; retain the operation identity for recovery`,
|
|
1130
|
+
transient: i.transient,
|
|
1131
|
+
...i.status === void 0 ? {} : { status: i.status }
|
|
1132
|
+
});
|
|
1133
|
+
return Object.defineProperty(a, "cause", {
|
|
1134
|
+
value: n,
|
|
1135
|
+
configurable: !0
|
|
1136
|
+
}), a;
|
|
1137
|
+
}
|
|
1109
1138
|
});
|
|
1110
1139
|
return {
|
|
1111
1140
|
put: (t) => y.gen(function* () {
|
|
1112
|
-
if (t.bytes.byteLength !== t.ref.size ||
|
|
1141
|
+
if (t.bytes.byteLength !== t.ref.size || Ce("sha256").update(t.bytes).digest("hex") !== t.identity.checksum) return yield* y.fail(new n({
|
|
1113
1142
|
reason: "operation-content-mismatch",
|
|
1114
1143
|
detail: "Storage operation bytes do not match their reserved identity"
|
|
1115
1144
|
}));
|
|
@@ -1130,10 +1159,10 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1130
1159
|
"operation" in a && (a.operation.deleteKey !== null && (yield* e.provider.delete(a.operation.deleteKey)), yield* r("delete confirmation", () => e.metadata.confirmDelete(a.identity)));
|
|
1131
1160
|
})
|
|
1132
1161
|
};
|
|
1133
|
-
},
|
|
1162
|
+
}, Xt = async (e) => {
|
|
1134
1163
|
let { createHash: t } = await import("node:crypto");
|
|
1135
1164
|
return t("sha256").update(e).digest("hex");
|
|
1136
|
-
},
|
|
1165
|
+
}, Zt = (e, t, n) => `${e?.replace(/\/+$/, "") ?? ""}${n}/${t}`, Qt = (e) => {
|
|
1137
1166
|
let t = /* @__PURE__ */ new Map(), n = {
|
|
1138
1167
|
public: 0,
|
|
1139
1168
|
private: 0
|
|
@@ -1143,13 +1172,13 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1143
1172
|
count: 0,
|
|
1144
1173
|
bytes: 0
|
|
1145
1174
|
};
|
|
1146
|
-
i.count
|
|
1175
|
+
i.count = W(i.count, r.count, "ref count"), i.bytes = W(i.bytes, r.bytes, "usage bytes"), t.set(e, i), r.visibility === "public" ? n.public = W(n.public, r.count, "public ref count") : n.private = W(n.private, r.count, "private ref count");
|
|
1147
1176
|
}
|
|
1148
1177
|
return {
|
|
1149
1178
|
byTenant: Object.fromEntries(t),
|
|
1150
1179
|
visibility: n
|
|
1151
1180
|
};
|
|
1152
|
-
},
|
|
1181
|
+
}, $t = (e, t) => {
|
|
1153
1182
|
if (t.search && ![
|
|
1154
1183
|
e.id,
|
|
1155
1184
|
e.key,
|
|
@@ -1166,19 +1195,25 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1166
1195
|
if (!t.tags.every((e) => n.includes(e))) return !1;
|
|
1167
1196
|
}
|
|
1168
1197
|
return !0;
|
|
1169
|
-
},
|
|
1198
|
+
}, en = (e) => e ?? "global", tn = () => {
|
|
1170
1199
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
1171
1200
|
return {
|
|
1172
|
-
statistics: () => y.
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
e
|
|
1201
|
+
statistics: () => y.try({
|
|
1202
|
+
try: () => Qt((function* () {
|
|
1203
|
+
for (let t of e.values()) yield {
|
|
1204
|
+
tenantId: t.tenantId,
|
|
1205
|
+
visibility: t.visibility,
|
|
1206
|
+
count: 1,
|
|
1207
|
+
bytes: t.size
|
|
1208
|
+
};
|
|
1209
|
+
})()),
|
|
1210
|
+
catch: (e) => G(e, "refstore")
|
|
1211
|
+
}),
|
|
1212
|
+
insert: (t) => y.try({
|
|
1213
|
+
try: () => {
|
|
1214
|
+
U(t.size, "ref size"), e.set(t.id, t);
|
|
1215
|
+
},
|
|
1216
|
+
catch: (e) => G(e, "refstore")
|
|
1182
1217
|
}),
|
|
1183
1218
|
getById: (t) => y.sync(() => e.get(t) ?? null),
|
|
1184
1219
|
delete: (t) => y.sync(() => e.delete(t)),
|
|
@@ -1194,46 +1229,57 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1194
1229
|
};
|
|
1195
1230
|
return e.set(t, i), i;
|
|
1196
1231
|
}),
|
|
1197
|
-
usageByTenant: (t) => y.
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1232
|
+
usageByTenant: (t) => y.try({
|
|
1233
|
+
try: () => {
|
|
1234
|
+
let n = 0, r = 0;
|
|
1235
|
+
for (let i of e.values()) (i.tenantId ?? null) === (t ?? null) && (n = W(n, i.size, "usage bytes"), r++);
|
|
1236
|
+
return {
|
|
1237
|
+
bytes: n,
|
|
1238
|
+
count: r
|
|
1239
|
+
};
|
|
1240
|
+
},
|
|
1241
|
+
catch: (e) => G(e, "refstore")
|
|
1204
1242
|
}),
|
|
1205
|
-
consumeUsage: (e, n, r) => y.
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
count
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1243
|
+
consumeUsage: (e, n, r) => y.try({
|
|
1244
|
+
try: () => {
|
|
1245
|
+
let i = en(e), a = t.get(i) ?? {
|
|
1246
|
+
bytes: 0,
|
|
1247
|
+
count: 0
|
|
1248
|
+
};
|
|
1249
|
+
U(n.bytes, "usage byte delta"), U(n.count, "usage count delta");
|
|
1250
|
+
let o = Number.isSafeInteger(a.bytes + n.bytes) && Number.isSafeInteger(a.count + n.count) && (r?.maxBytes === void 0 || a.bytes + n.bytes <= r.maxBytes) && (r?.maxCount === void 0 || a.count + n.count <= r.maxCount);
|
|
1251
|
+
return o && t.set(i, {
|
|
1252
|
+
bytes: a.bytes + n.bytes,
|
|
1253
|
+
count: a.count + n.count
|
|
1254
|
+
}), {
|
|
1255
|
+
allowed: o,
|
|
1256
|
+
bytes: a.bytes,
|
|
1257
|
+
count: a.count
|
|
1258
|
+
};
|
|
1259
|
+
},
|
|
1260
|
+
catch: (e) => G(e, "refstore")
|
|
1218
1261
|
}),
|
|
1219
|
-
releaseUsage: (e, n) => y.
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
bytes
|
|
1223
|
-
|
|
1224
|
-
|
|
1262
|
+
releaseUsage: (e, n) => y.try({
|
|
1263
|
+
try: () => {
|
|
1264
|
+
let r = en(e), i = t.get(r);
|
|
1265
|
+
U(n.bytes, "usage byte delta"), U(n.count, "usage count delta"), i && t.set(r, {
|
|
1266
|
+
bytes: Math.max(0, i.bytes - n.bytes),
|
|
1267
|
+
count: Math.max(0, i.count - n.count)
|
|
1268
|
+
});
|
|
1269
|
+
},
|
|
1270
|
+
catch: (e) => G(e, "refstore")
|
|
1225
1271
|
}),
|
|
1226
1272
|
listByDerivedFrom: (t) => y.sync(() => [...e.values()].filter((e) => (e.derivedFrom ?? null) === t)),
|
|
1227
|
-
listRefs: (t) => y.sync(() => [...e.values()].filter((e) =>
|
|
1273
|
+
listRefs: (t) => y.sync(() => [...e.values()].filter((e) => $t(e, t)).sort((e, t) => t.createdAt.getTime() - e.createdAt.getTime() || t.id.localeCompare(e.id)).slice(t.offset, t.offset + t.limit))
|
|
1228
1274
|
};
|
|
1229
|
-
},
|
|
1275
|
+
}, nn = (e) => Array.isArray(e) && e.every((e) => typeof e == "string") ? e : null, X = (e) => ({
|
|
1230
1276
|
id: String(e.id),
|
|
1231
1277
|
tenantId: e.tenantId ?? null,
|
|
1232
1278
|
ownerId: e.ownerId ?? null,
|
|
1233
1279
|
bucket: String(e.bucket),
|
|
1234
1280
|
key: String(e.key),
|
|
1235
1281
|
contentType: String(e.contentType),
|
|
1236
|
-
size:
|
|
1282
|
+
size: U(e.size, "ref size"),
|
|
1237
1283
|
checksum: String(e.checksum),
|
|
1238
1284
|
visibility: e.visibility === "public" ? "public" : "private",
|
|
1239
1285
|
accessPolicy: e.accessPolicy ?? null,
|
|
@@ -1244,19 +1290,15 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1244
1290
|
duration: e.duration ?? null,
|
|
1245
1291
|
placeholder: e.placeholder ?? null,
|
|
1246
1292
|
folder: e.folder ?? null,
|
|
1247
|
-
tags:
|
|
1293
|
+
tags: nn(e.tags),
|
|
1248
1294
|
alt: e.alt ?? null,
|
|
1249
1295
|
caption: e.caption ?? null,
|
|
1250
1296
|
derivedFrom: e.derivedFrom ?? null,
|
|
1251
1297
|
kind: e.kind ?? null
|
|
1252
|
-
}),
|
|
1298
|
+
}), Z = (e) => y.tryPromise({
|
|
1253
1299
|
try: e,
|
|
1254
|
-
catch: (e) =>
|
|
1255
|
-
|
|
1256
|
-
message: String(e?.message ?? e),
|
|
1257
|
-
transient: !0
|
|
1258
|
-
})
|
|
1259
|
-
}), qt = async (e, t) => (await e.query({
|
|
1300
|
+
catch: (e) => G(e, "refstore", !0)
|
|
1301
|
+
}), rn = async (e, t) => (await e.query({
|
|
1260
1302
|
table: "_voltro_storage_usage",
|
|
1261
1303
|
predicate: {
|
|
1262
1304
|
column: "tenantId",
|
|
@@ -1267,33 +1309,41 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1267
1309
|
take: 1,
|
|
1268
1310
|
skip: void 0,
|
|
1269
1311
|
projection: void 0
|
|
1270
|
-
}))[0] ?? null,
|
|
1271
|
-
statistics: () =>
|
|
1272
|
-
table:
|
|
1312
|
+
}))[0] ?? null, an = (e) => ({
|
|
1313
|
+
statistics: () => Z(async () => Qt((await e.query({
|
|
1314
|
+
table: z,
|
|
1273
1315
|
predicate: void 0,
|
|
1274
1316
|
order: [],
|
|
1275
1317
|
take: void 0,
|
|
1276
1318
|
skip: void 0,
|
|
1277
1319
|
projection: void 0,
|
|
1278
1320
|
groupBy: ["tenantId", "visibility"],
|
|
1279
|
-
aggregations: [
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1321
|
+
aggregations: [
|
|
1322
|
+
fe("tenantId"),
|
|
1323
|
+
fe("visibility"),
|
|
1324
|
+
{
|
|
1325
|
+
op: "count",
|
|
1326
|
+
alias: "count"
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
op: "sum",
|
|
1330
|
+
column: "size",
|
|
1331
|
+
alias: "bytes"
|
|
1332
|
+
}
|
|
1333
|
+
]
|
|
1287
1334
|
})).map((e) => ({
|
|
1288
1335
|
tenantId: e.tenantId == null ? null : String(e.tenantId),
|
|
1289
1336
|
visibility: String(e.visibility),
|
|
1290
|
-
count:
|
|
1291
|
-
bytes:
|
|
1337
|
+
count: U(e.count, "ref count"),
|
|
1338
|
+
bytes: U(e.bytes ?? 0, "usage bytes")
|
|
1292
1339
|
})))),
|
|
1293
|
-
insert: (t) =>
|
|
1294
|
-
|
|
1340
|
+
insert: (t) => Z(() => e.insert(z, {
|
|
1341
|
+
...t,
|
|
1342
|
+
size: String(U(t.size, "ref size"))
|
|
1343
|
+
})),
|
|
1344
|
+
getById: (t) => Z(async () => {
|
|
1295
1345
|
let n = await e.query({
|
|
1296
|
-
table:
|
|
1346
|
+
table: z,
|
|
1297
1347
|
predicate: {
|
|
1298
1348
|
column: "id",
|
|
1299
1349
|
op: "eq",
|
|
@@ -1304,11 +1354,11 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1304
1354
|
skip: void 0,
|
|
1305
1355
|
projection: void 0
|
|
1306
1356
|
});
|
|
1307
|
-
return n[0] ?
|
|
1357
|
+
return n[0] ? X(n[0]) : null;
|
|
1308
1358
|
}),
|
|
1309
|
-
delete: (t) =>
|
|
1310
|
-
listRecent: (t) =>
|
|
1311
|
-
table:
|
|
1359
|
+
delete: (t) => Z(() => e.delete(z, t)),
|
|
1360
|
+
listRecent: (t) => Z(async () => (await e.query({
|
|
1361
|
+
table: z,
|
|
1312
1362
|
predicate: void 0,
|
|
1313
1363
|
order: [{
|
|
1314
1364
|
column: "createdAt",
|
|
@@ -1317,9 +1367,9 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1317
1367
|
take: t,
|
|
1318
1368
|
skip: void 0,
|
|
1319
1369
|
projection: void 0
|
|
1320
|
-
})).map(
|
|
1321
|
-
countByKey: (t, n) =>
|
|
1322
|
-
table:
|
|
1370
|
+
})).map(X)),
|
|
1371
|
+
countByKey: (t, n) => Z(async () => (await e.query({
|
|
1372
|
+
table: z,
|
|
1323
1373
|
predicate: { and: [{
|
|
1324
1374
|
column: "bucket",
|
|
1325
1375
|
op: "eq",
|
|
@@ -1334,8 +1384,8 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1334
1384
|
skip: void 0,
|
|
1335
1385
|
projection: void 0
|
|
1336
1386
|
})).length),
|
|
1337
|
-
countPublicByKey: (t, n) =>
|
|
1338
|
-
table:
|
|
1387
|
+
countPublicByKey: (t, n) => Z(async () => (await e.query({
|
|
1388
|
+
table: z,
|
|
1339
1389
|
predicate: { and: [
|
|
1340
1390
|
{
|
|
1341
1391
|
column: "bucket",
|
|
@@ -1358,13 +1408,13 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1358
1408
|
skip: void 0,
|
|
1359
1409
|
projection: ["id"]
|
|
1360
1410
|
})).length),
|
|
1361
|
-
setVisibility: (t, n) =>
|
|
1362
|
-
let r = await e.update(
|
|
1363
|
-
return r ?
|
|
1411
|
+
setVisibility: (t, n) => Z(async () => {
|
|
1412
|
+
let r = await e.update(z, t, { visibility: n });
|
|
1413
|
+
return r ? X(r) : null;
|
|
1364
1414
|
}),
|
|
1365
|
-
usageByTenant: (t) =>
|
|
1415
|
+
usageByTenant: (t) => Z(async () => {
|
|
1366
1416
|
let n = await e.query({
|
|
1367
|
-
table:
|
|
1417
|
+
table: z,
|
|
1368
1418
|
predicate: {
|
|
1369
1419
|
column: "tenantId",
|
|
1370
1420
|
op: "eq",
|
|
@@ -1375,28 +1425,29 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1375
1425
|
skip: void 0,
|
|
1376
1426
|
projection: void 0
|
|
1377
1427
|
}), r = 0;
|
|
1378
|
-
for (let e of n) r
|
|
1428
|
+
for (let e of n) r = W(r, U(e.size, "ref size"), "usage bytes");
|
|
1379
1429
|
return {
|
|
1380
1430
|
bytes: r,
|
|
1381
1431
|
count: n.length
|
|
1382
1432
|
};
|
|
1383
1433
|
}),
|
|
1384
|
-
consumeUsage: (t, n, r) =>
|
|
1385
|
-
let i =
|
|
1434
|
+
consumeUsage: (t, n, r) => Z(async () => {
|
|
1435
|
+
let i = en(t);
|
|
1436
|
+
U(n.bytes, "usage byte delta"), U(n.count, "usage count delta");
|
|
1386
1437
|
for (let t = 0; t < 32; t++) {
|
|
1387
1438
|
t > 0 && await new Promise((e) => setTimeout(e, t));
|
|
1388
|
-
let a = await
|
|
1389
|
-
if (!((r?.maxBytes === void 0 || o + n.bytes <= r.maxBytes) && (r?.maxCount === void 0 || s + n.count <= r.maxCount))) return {
|
|
1439
|
+
let a = await rn(e, i), o = a ? U(a.bytes, "usage bytes") : 0, s = a ? U(a.count, "ref count") : 0;
|
|
1440
|
+
if (!(Number.isSafeInteger(o + n.bytes) && Number.isSafeInteger(s + n.count) && (r?.maxBytes === void 0 || o + n.bytes <= r.maxBytes) && (r?.maxCount === void 0 || s + n.count <= r.maxCount))) return {
|
|
1390
1441
|
allowed: !1,
|
|
1391
1442
|
bytes: o,
|
|
1392
1443
|
count: s
|
|
1393
1444
|
};
|
|
1394
1445
|
if (a) {
|
|
1395
1446
|
if (await e.updateMany("_voltro_storage_usage", {
|
|
1396
|
-
bytes: o + n.bytes,
|
|
1397
|
-
count: s + n.count,
|
|
1447
|
+
bytes: String(o + n.bytes),
|
|
1448
|
+
count: String(s + n.count),
|
|
1398
1449
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1399
|
-
}, { where:
|
|
1450
|
+
}, { where: T(O("id", String(a.id)), O("bytes", a.bytes), O("count", a.count)) }) === 1) return {
|
|
1400
1451
|
allowed: !0,
|
|
1401
1452
|
bytes: o,
|
|
1402
1453
|
count: s
|
|
@@ -1405,11 +1456,11 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1405
1456
|
let t = k({
|
|
1406
1457
|
kind: "typeid",
|
|
1407
1458
|
prefix: "susage"
|
|
1408
|
-
},
|
|
1459
|
+
}, Ue), r = await e.insertIgnore(Ue, {
|
|
1409
1460
|
id: t,
|
|
1410
1461
|
tenantId: i,
|
|
1411
|
-
bytes: n.bytes,
|
|
1412
|
-
count: n.count,
|
|
1462
|
+
bytes: String(n.bytes),
|
|
1463
|
+
count: String(n.count),
|
|
1413
1464
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1414
1465
|
}, { conflictColumns: ["tenantId"] });
|
|
1415
1466
|
if (String(r.id) === t) return {
|
|
@@ -1419,25 +1470,26 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1419
1470
|
};
|
|
1420
1471
|
}
|
|
1421
1472
|
}
|
|
1422
|
-
throw
|
|
1473
|
+
throw ue("Storage quota reservation contended after 32 attempts; retry");
|
|
1423
1474
|
}),
|
|
1424
|
-
releaseUsage: (t, n) =>
|
|
1425
|
-
let r =
|
|
1475
|
+
releaseUsage: (t, n) => Z(async () => {
|
|
1476
|
+
let r = en(t);
|
|
1477
|
+
U(n.bytes, "usage byte delta"), U(n.count, "usage count delta");
|
|
1426
1478
|
for (let t = 0; t < 32; t++) {
|
|
1427
1479
|
t > 0 && await new Promise((e) => setTimeout(e, t));
|
|
1428
|
-
let i = await
|
|
1480
|
+
let i = await rn(e, r);
|
|
1429
1481
|
if (!i) return;
|
|
1430
|
-
let a =
|
|
1482
|
+
let a = U(i.bytes, "usage bytes"), o = U(i.count, "ref count");
|
|
1431
1483
|
if (await e.updateMany("_voltro_storage_usage", {
|
|
1432
|
-
bytes: Math.max(0, a - n.bytes),
|
|
1433
|
-
count: Math.max(0, o - n.count),
|
|
1484
|
+
bytes: String(Math.max(0, a - n.bytes)),
|
|
1485
|
+
count: String(Math.max(0, o - n.count)),
|
|
1434
1486
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1435
|
-
}, { where:
|
|
1487
|
+
}, { where: T(O("id", String(i.id)), O("bytes", i.bytes), O("count", i.count)) }) === 1) return;
|
|
1436
1488
|
}
|
|
1437
|
-
throw
|
|
1489
|
+
throw ue("Storage quota release contended after 32 attempts; retry");
|
|
1438
1490
|
}),
|
|
1439
|
-
listByDerivedFrom: (t) =>
|
|
1440
|
-
table:
|
|
1491
|
+
listByDerivedFrom: (t) => Z(async () => (await e.query({
|
|
1492
|
+
table: z,
|
|
1441
1493
|
predicate: {
|
|
1442
1494
|
column: "derivedFrom",
|
|
1443
1495
|
op: "eq",
|
|
@@ -1450,18 +1502,18 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1450
1502
|
take: void 0,
|
|
1451
1503
|
skip: void 0,
|
|
1452
1504
|
projection: void 0
|
|
1453
|
-
})).map(
|
|
1454
|
-
listRefs: (t) =>
|
|
1505
|
+
})).map(X)),
|
|
1506
|
+
listRefs: (t) => Z(async () => {
|
|
1455
1507
|
let n = [];
|
|
1456
|
-
t.tenantId !== void 0 && n.push(O("tenantId", t.tenantId)), t.ownerId !== void 0 && n.push(O("ownerId", t.ownerId)), t.search && n.push(
|
|
1508
|
+
t.tenantId !== void 0 && n.push(O("tenantId", t.tenantId)), t.ownerId !== void 0 && n.push(O("ownerId", t.ownerId)), t.search && n.push(M(...[
|
|
1457
1509
|
"id",
|
|
1458
1510
|
"key",
|
|
1459
1511
|
"contentType",
|
|
1460
1512
|
"ownerId",
|
|
1461
1513
|
"tenantId"
|
|
1462
|
-
].map((e) =>
|
|
1463
|
-
let r = t.folder === void 0 && t.tags.length === 0 && t.includeDerived, i = n.length ?
|
|
1464
|
-
table:
|
|
1514
|
+
].map((e) => pe(e, t.search))));
|
|
1515
|
+
let r = t.folder === void 0 && t.tags.length === 0 && t.includeDerived, i = n.length ? T(...n) : void 0, a = await e.query({
|
|
1516
|
+
table: z,
|
|
1465
1517
|
predicate: i,
|
|
1466
1518
|
order: [{
|
|
1467
1519
|
column: "createdAt",
|
|
@@ -1474,9 +1526,9 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1474
1526
|
skip: r ? t.offset : void 0,
|
|
1475
1527
|
projection: void 0
|
|
1476
1528
|
});
|
|
1477
|
-
return r ? a.map(
|
|
1529
|
+
return r ? a.map(X) : a.map(X).filter((e) => $t(e, t)).slice(t.offset, t.offset + t.limit);
|
|
1478
1530
|
})
|
|
1479
|
-
}),
|
|
1531
|
+
}), on = () => {
|
|
1480
1532
|
let e = /* @__PURE__ */ new Map();
|
|
1481
1533
|
return {
|
|
1482
1534
|
insert: (t) => y.sync(() => {
|
|
@@ -1491,7 +1543,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1491
1543
|
for (let [n, r] of e) r.refId === t && e.delete(n);
|
|
1492
1544
|
})
|
|
1493
1545
|
};
|
|
1494
|
-
},
|
|
1546
|
+
}, sn = (e) => ({
|
|
1495
1547
|
id: String(e.id),
|
|
1496
1548
|
refId: String(e.refId),
|
|
1497
1549
|
principalType: e.principalType,
|
|
@@ -1500,12 +1552,12 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1500
1552
|
createdAt: e.createdAt instanceof Date ? e.createdAt : new Date(String(e.createdAt)),
|
|
1501
1553
|
expiresAt: e.expiresAt ? e.expiresAt instanceof Date ? e.expiresAt : new Date(String(e.expiresAt)) : null,
|
|
1502
1554
|
createdBy: e.createdBy ?? null
|
|
1503
|
-
}),
|
|
1504
|
-
insert: (t) =>
|
|
1505
|
-
delete: (t) =>
|
|
1506
|
-
getById: (t) =>
|
|
1555
|
+
}), cn = (e) => ({
|
|
1556
|
+
insert: (t) => Z(() => e.insert(B, { ...t })),
|
|
1557
|
+
delete: (t) => Z(() => e.delete(B, t)),
|
|
1558
|
+
getById: (t) => Z(async () => {
|
|
1507
1559
|
let n = (await e.query({
|
|
1508
|
-
table:
|
|
1560
|
+
table: B,
|
|
1509
1561
|
predicate: {
|
|
1510
1562
|
column: "id",
|
|
1511
1563
|
op: "eq",
|
|
@@ -1516,10 +1568,10 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1516
1568
|
skip: void 0,
|
|
1517
1569
|
projection: void 0
|
|
1518
1570
|
}))[0];
|
|
1519
|
-
return n ?
|
|
1571
|
+
return n ? sn(n) : null;
|
|
1520
1572
|
}),
|
|
1521
|
-
listByRef: (t) =>
|
|
1522
|
-
table:
|
|
1573
|
+
listByRef: (t) => Z(async () => (await e.query({
|
|
1574
|
+
table: B,
|
|
1523
1575
|
predicate: {
|
|
1524
1576
|
column: "refId",
|
|
1525
1577
|
op: "eq",
|
|
@@ -1532,10 +1584,10 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1532
1584
|
take: void 0,
|
|
1533
1585
|
skip: void 0,
|
|
1534
1586
|
projection: void 0
|
|
1535
|
-
})).map(
|
|
1536
|
-
deleteByRef: (t) =>
|
|
1587
|
+
})).map(sn)),
|
|
1588
|
+
deleteByRef: (t) => Z(async () => {
|
|
1537
1589
|
let n = await e.query({
|
|
1538
|
-
table:
|
|
1590
|
+
table: B,
|
|
1539
1591
|
predicate: {
|
|
1540
1592
|
column: "refId",
|
|
1541
1593
|
op: "eq",
|
|
@@ -1546,16 +1598,16 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1546
1598
|
skip: void 0,
|
|
1547
1599
|
projection: void 0
|
|
1548
1600
|
});
|
|
1549
|
-
for (let t of n) await e.delete(
|
|
1601
|
+
for (let t of n) await e.delete(B, String(t.id));
|
|
1550
1602
|
})
|
|
1551
|
-
}),
|
|
1603
|
+
}), ln = () => k({
|
|
1552
1604
|
kind: "typeid",
|
|
1553
1605
|
prefix: "file"
|
|
1554
|
-
},
|
|
1606
|
+
}, z), un = () => k({
|
|
1555
1607
|
kind: "typeid",
|
|
1556
1608
|
prefix: "grant"
|
|
1557
|
-
},
|
|
1558
|
-
let { provider: a, refStore: o, grantStore: s, bucket: c } = i, l = i.access ?? {}, u = i.attempts ?? 3, d = i.urlExpiresInSec ?? 3600, f = (e) =>
|
|
1609
|
+
}, B), dn = (i) => {
|
|
1610
|
+
let { provider: a, refStore: o, grantStore: s, bucket: c } = i, l = i.access ?? {}, u = i.attempts ?? 3, d = i.urlExpiresInSec ?? 3600, f = (e) => Zt(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) => [
|
|
1559
1611
|
i.tenantPrefix,
|
|
1560
1612
|
e ?? "global",
|
|
1561
1613
|
n ?? t
|
|
@@ -1595,7 +1647,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1595
1647
|
transient: !1
|
|
1596
1648
|
})
|
|
1597
1649
|
});
|
|
1598
|
-
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*
|
|
1650
|
+
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* Yt({
|
|
1599
1651
|
metadata: o,
|
|
1600
1652
|
provider: {
|
|
1601
1653
|
...a,
|
|
@@ -1635,7 +1687,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1635
1687
|
catch: () => null
|
|
1636
1688
|
}).pipe(y.catchAll(() => y.succeed(null)));
|
|
1637
1689
|
}), _ = (e) => y.gen(function* () {
|
|
1638
|
-
let t =
|
|
1690
|
+
let t = Ht(e.bytes, e.contentType, i.limits);
|
|
1639
1691
|
if (t) return yield* y.fail(new n(t));
|
|
1640
1692
|
if (e.claim !== void 0 && e.operationId === void 0) return yield* y.fail(new n({
|
|
1641
1693
|
reason: "claim-without-operation",
|
|
@@ -1649,11 +1701,11 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1649
1701
|
});
|
|
1650
1702
|
if (!t.clean) return yield* y.fail(new r({ threat: t.threat ?? "unknown" }));
|
|
1651
1703
|
}
|
|
1652
|
-
let s = yield* y.promise(() =>
|
|
1704
|
+
let s = yield* y.promise(() => Ut(e.bytes, e.contentType, { normalize: i.normalizeImages ?? !1 })), l = s.bytes, u = yield* ie({
|
|
1653
1705
|
bytes: l,
|
|
1654
1706
|
contentType: e.contentType
|
|
1655
|
-
}), d = s.width ?? u?.width, f = s.height ?? u?.height, te = s.placeholder ?? u?.poster, h = e.duration ?? u?.duration, ne = yield* y.promise(() =>
|
|
1656
|
-
id:
|
|
1707
|
+
}), d = s.width ?? u?.width, f = s.height ?? u?.height, te = s.placeholder ?? u?.poster, h = e.duration ?? u?.duration, ne = yield* y.promise(() => Xt(l)), g = e.tenantId ?? null, _ = e.visibility ?? "private", v = m(g, ne, yield* ee(e.key)), S = e.password ? yield* y.sync(() => gt(e.password)) : null, C = {
|
|
1708
|
+
id: ln(),
|
|
1657
1709
|
tenantId: g,
|
|
1658
1710
|
ownerId: e.ownerId ?? null,
|
|
1659
1711
|
bucket: c,
|
|
@@ -1675,7 +1727,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1675
1727
|
...e.caption === void 0 ? {} : { caption: e.caption },
|
|
1676
1728
|
...e.derivedFrom === void 0 ? {} : { derivedFrom: e.derivedFrom },
|
|
1677
1729
|
...e.kind === void 0 ? {} : { kind: e.kind }
|
|
1678
|
-
}, w = i.transcode !== void 0 && i.autoTranscode !== !1,
|
|
1730
|
+
}, 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;
|
|
1679
1731
|
if (e.operationId !== void 0) {
|
|
1680
1732
|
let t = i.objects?.();
|
|
1681
1733
|
if (t === void 0) return yield* y.fail(new n({
|
|
@@ -1688,7 +1740,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1688
1740
|
operationId: e.operationId,
|
|
1689
1741
|
checksum: ne,
|
|
1690
1742
|
logicalKey: v,
|
|
1691
|
-
fingerprint: yield* y.promise(() =>
|
|
1743
|
+
fingerprint: yield* y.promise(() => Xt(new TextEncoder().encode(JSON.stringify([
|
|
1692
1744
|
ne,
|
|
1693
1745
|
e.contentType,
|
|
1694
1746
|
_,
|
|
@@ -1704,7 +1756,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1704
1756
|
h ?? null,
|
|
1705
1757
|
e.password !== void 0
|
|
1706
1758
|
]))))
|
|
1707
|
-
}, o = yield*
|
|
1759
|
+
}, o = yield* Yt({
|
|
1708
1760
|
metadata: t,
|
|
1709
1761
|
provider: {
|
|
1710
1762
|
...a,
|
|
@@ -1717,26 +1769,26 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1717
1769
|
...i.quota === void 0 ? {} : { quota: i.quota },
|
|
1718
1770
|
...e.claim === void 0 ? {} : { claim: e.claim }
|
|
1719
1771
|
});
|
|
1720
|
-
return yield*
|
|
1772
|
+
return yield* ae(o.ref), {
|
|
1721
1773
|
...o.ref,
|
|
1722
1774
|
outcome: o.outcome
|
|
1723
1775
|
};
|
|
1724
1776
|
}
|
|
1725
|
-
let
|
|
1777
|
+
let oe = {
|
|
1726
1778
|
bytes: l.byteLength,
|
|
1727
1779
|
count: 1
|
|
1728
|
-
},
|
|
1729
|
-
if (!
|
|
1730
|
-
let e = i.quota ?? {}, t = e.maxCount !== void 0 &&
|
|
1780
|
+
}, se = yield* o.consumeUsage(g, oe, i.quota);
|
|
1781
|
+
if (!se.allowed) {
|
|
1782
|
+
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}`;
|
|
1731
1783
|
return yield* y.fail(new n({
|
|
1732
1784
|
reason: "quota-exceeded",
|
|
1733
1785
|
detail: t
|
|
1734
1786
|
}));
|
|
1735
1787
|
}
|
|
1736
|
-
return yield* ((e) => e.pipe(y.onExit((e) => b.isSuccess(e) ? y.void : o.delete(C.id).pipe(y.zipRight(o.releaseUsage(g,
|
|
1788
|
+
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, {
|
|
1737
1789
|
contentType: e.contentType,
|
|
1738
1790
|
public: _ === "public"
|
|
1739
|
-
}).pipe(y.retry(p))))), yield*
|
|
1791
|
+
}).pipe(y.retry(p))))), yield* ae(C), {
|
|
1740
1792
|
...C,
|
|
1741
1793
|
outcome: "created"
|
|
1742
1794
|
};
|
|
@@ -1774,13 +1826,13 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1774
1826
|
}
|
|
1775
1827
|
return r;
|
|
1776
1828
|
}), C = (e, t, n) => y.gen(function* () {
|
|
1777
|
-
if (e.visibility === "public" || (yield*
|
|
1829
|
+
if (e.visibility === "public" || (yield* wt(e, t, {
|
|
1778
1830
|
...l,
|
|
1779
1831
|
...n?.password === void 0 ? {} : { password: n.password }
|
|
1780
1832
|
}))) return !0;
|
|
1781
|
-
let r = yield*
|
|
1782
|
-
return
|
|
1783
|
-
}),
|
|
1833
|
+
let r = yield* Ot(t, l);
|
|
1834
|
+
return Dt(yield* s.listByRef(e.id), t, r, n?.permission ?? "read", Date.now());
|
|
1835
|
+
}), ae = (e) => {
|
|
1784
1836
|
if (e.visibility === "public") {
|
|
1785
1837
|
let t = a.publicUrl?.(e.key);
|
|
1786
1838
|
if (t != null) return t;
|
|
@@ -1817,16 +1869,16 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1817
1869
|
totalSize: r
|
|
1818
1870
|
})));
|
|
1819
1871
|
})),
|
|
1820
|
-
getUrl: (e, t) => g(e, t?.tenantId).pipe(y.flatMap((e) => e.visibility === "public" ? y.succeed(
|
|
1872
|
+
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)))),
|
|
1821
1873
|
head: (e, t) => o.getById(e).pipe(y.flatMap((e) => e ? h(e, t?.tenantId).pipe(y.map((e) => e)) : y.succeed(null))),
|
|
1822
1874
|
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, {
|
|
1823
1875
|
bytes: t.size,
|
|
1824
1876
|
count: 1
|
|
1825
1877
|
}))) : y.void), y.asVoid))))),
|
|
1826
1878
|
signedUrl: (e, t) => g(e, t?.tenantId).pipe(y.flatMap((e) => {
|
|
1827
|
-
if (e.visibility === "public") return y.succeed(
|
|
1879
|
+
if (e.visibility === "public") return y.succeed(ae(e));
|
|
1828
1880
|
let n = t?.expiresInSec ?? d;
|
|
1829
|
-
return a.presigns ? a.getUrl(e.key, n) : y.sync(() => `${f(e.id)}?t=${
|
|
1881
|
+
return a.presigns ? a.getUrl(e.key, n) : y.sync(() => `${f(e.id)}?t=${kt(e.id, n, void 0, i.httpPath ?? "/_voltro/storage")}`);
|
|
1830
1882
|
})),
|
|
1831
1883
|
setVisibility: (e, r, i) => y.gen(function* () {
|
|
1832
1884
|
let s = yield* g(e, i?.tenantId);
|
|
@@ -1864,14 +1916,14 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1864
1916
|
transient: !1,
|
|
1865
1917
|
status: 404
|
|
1866
1918
|
}))));
|
|
1867
|
-
if (c.visibility === "public") return
|
|
1919
|
+
if (c.visibility === "public") return ae(c);
|
|
1868
1920
|
if (!(yield* C(c, r, s?.password === void 0 ? {} : { password: s.password }))) return yield* y.fail(new e({
|
|
1869
1921
|
refId: n,
|
|
1870
1922
|
reason: "access denied"
|
|
1871
1923
|
}));
|
|
1872
1924
|
let l = s?.expiresInSec ?? d;
|
|
1873
1925
|
if (a.presigns) return yield* a.getUrl(c.key, l);
|
|
1874
|
-
let u = yield* y.sync(() =>
|
|
1926
|
+
let u = yield* y.sync(() => kt(c.id, l, void 0, i.httpPath ?? "/_voltro/storage"));
|
|
1875
1927
|
return `${f(c.id)}?t=${u}`;
|
|
1876
1928
|
}),
|
|
1877
1929
|
mintUploadUrl: (e) => y.gen(function* () {
|
|
@@ -1887,7 +1939,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1887
1939
|
checkAccess: C,
|
|
1888
1940
|
grant: (e) => y.gen(function* () {
|
|
1889
1941
|
let t = {
|
|
1890
|
-
id:
|
|
1942
|
+
id: un(),
|
|
1891
1943
|
refId: e.refId,
|
|
1892
1944
|
principalType: e.principalType,
|
|
1893
1945
|
principalId: e.principalId,
|
|
@@ -1937,8 +1989,8 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1937
1989
|
removed: i
|
|
1938
1990
|
};
|
|
1939
1991
|
}),
|
|
1940
|
-
ingestUrl: (e, t) =>
|
|
1941
|
-
let n = yield*
|
|
1992
|
+
ingestUrl: (e, t) => Jt(y.gen(function* () {
|
|
1993
|
+
let n = yield* qt(e, i.limits?.maxBytes, i.ingest);
|
|
1942
1994
|
return yield* _({
|
|
1943
1995
|
bytes: n.bytes,
|
|
1944
1996
|
contentType: t?.contentType ?? n.contentType,
|
|
@@ -1964,7 +2016,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
1964
2016
|
let n = e.expiresInSec ?? d, r = `_incoming/${k({
|
|
1965
2017
|
kind: "typeid",
|
|
1966
2018
|
prefix: "up"
|
|
1967
|
-
},
|
|
2019
|
+
}, z)}`, i = m(e.tenantId ?? null, "", r);
|
|
1968
2020
|
return {
|
|
1969
2021
|
uploadUrl: yield* a.getUploadUrl(i, n, e.contentType),
|
|
1970
2022
|
key: i,
|
|
@@ -2028,7 +2080,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2028
2080
|
}
|
|
2029
2081
|
let i = /* @__PURE__ */ new Uint8Array(), s = 0;
|
|
2030
2082
|
for (let t = 0; t < e.count; t++) {
|
|
2031
|
-
let e = yield*
|
|
2083
|
+
let e = yield* Ve(a, o(t)).pipe(y.retry(p));
|
|
2032
2084
|
yield* w.runForEach(e.stream, (e) => y.gen(function* () {
|
|
2033
2085
|
if (e.byteLength > r - s) return yield* y.fail(c());
|
|
2034
2086
|
let t = s + e.byteLength;
|
|
@@ -2065,7 +2117,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2065
2117
|
let n = m(e.tenantId ?? null, "", `multipart/${k({
|
|
2066
2118
|
kind: "typeid",
|
|
2067
2119
|
prefix: "mp"
|
|
2068
|
-
},
|
|
2120
|
+
}, z)}`);
|
|
2069
2121
|
return {
|
|
2070
2122
|
uploadId: (yield* a.createMultipartUpload(n, e.contentType, { public: (e.visibility ?? "private") === "public" })).uploadId,
|
|
2071
2123
|
key: n
|
|
@@ -2093,7 +2145,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2093
2145
|
detail: `multipart upload of ${l} bytes exceeds tenant quota`
|
|
2094
2146
|
}));
|
|
2095
2147
|
let m = {
|
|
2096
|
-
id:
|
|
2148
|
+
id: ln(),
|
|
2097
2149
|
tenantId: e.tenantId ?? null,
|
|
2098
2150
|
ownerId: e.ownerId ?? null,
|
|
2099
2151
|
bucket: c,
|
|
@@ -2114,33 +2166,33 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2114
2166
|
}),
|
|
2115
2167
|
abortMultipart: (e) => y.suspend(() => a.abortMultipartUpload ? a.abortMultipartUpload(e.key, e.uploadId).pipe(y.retry(p)) : y.void)
|
|
2116
2168
|
};
|
|
2117
|
-
},
|
|
2118
|
-
|
|
2119
|
-
id:
|
|
2120
|
-
nonce:
|
|
2169
|
+
}, fn = (e) => x.succeed(i, dn(e)), pn = "_voltro_storage_operation_locks", Q = "_voltro_storage_object_heads", mn = "_voltro_storage_operations", hn = "_voltro_storage_object_claims", gn = [
|
|
2170
|
+
N(pn, {
|
|
2171
|
+
id: P().maxLength(64),
|
|
2172
|
+
nonce: P()
|
|
2121
2173
|
}).primaryKey(["id"]).nonReactive(),
|
|
2122
|
-
|
|
2123
|
-
id:
|
|
2124
|
-
generation:
|
|
2125
|
-
key:
|
|
2126
|
-
reservations:
|
|
2174
|
+
N(Q, {
|
|
2175
|
+
id: P().maxLength(64),
|
|
2176
|
+
generation: P(),
|
|
2177
|
+
key: P(),
|
|
2178
|
+
reservations: E()
|
|
2127
2179
|
}).primaryKey(["id"]).nonReactive(),
|
|
2128
|
-
|
|
2129
|
-
id:
|
|
2130
|
-
objectId:
|
|
2131
|
-
fingerprint:
|
|
2132
|
-
generation:
|
|
2133
|
-
key:
|
|
2134
|
-
refId:
|
|
2135
|
-
state:
|
|
2136
|
-
deleteKey:
|
|
2180
|
+
N(mn, {
|
|
2181
|
+
id: P().maxLength(64),
|
|
2182
|
+
objectId: P().maxLength(64),
|
|
2183
|
+
fingerprint: P().maxLength(64),
|
|
2184
|
+
generation: P(),
|
|
2185
|
+
key: P(),
|
|
2186
|
+
refId: P(),
|
|
2187
|
+
state: P(),
|
|
2188
|
+
deleteKey: P().nullable()
|
|
2137
2189
|
}).primaryKey(["id"]).nonReactive(),
|
|
2138
|
-
|
|
2139
|
-
id:
|
|
2140
|
-
operationId:
|
|
2141
|
-
claim:
|
|
2190
|
+
N(hn, {
|
|
2191
|
+
id: P().maxLength(64),
|
|
2192
|
+
operationId: P().maxLength(64),
|
|
2193
|
+
claim: P()
|
|
2142
2194
|
}).primaryKey(["id"]).nonReactive()
|
|
2143
|
-
],
|
|
2195
|
+
], _n = C.Struct({
|
|
2144
2196
|
id: C.String,
|
|
2145
2197
|
objectId: C.String,
|
|
2146
2198
|
fingerprint: C.String,
|
|
@@ -2149,47 +2201,50 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2149
2201
|
refId: C.String,
|
|
2150
2202
|
state: C.Literal("reserved", "ready", "deleting", "deleted"),
|
|
2151
2203
|
deleteKey: C.NullOr(C.String)
|
|
2152
|
-
}),
|
|
2204
|
+
}), vn = C.Struct({
|
|
2153
2205
|
id: C.String,
|
|
2154
2206
|
generation: C.String,
|
|
2155
2207
|
key: C.String,
|
|
2156
2208
|
reservations: C.Int.pipe(C.nonNegative())
|
|
2157
|
-
}),
|
|
2209
|
+
}), yn = (e) => C.decodeUnknownSync(vn)({
|
|
2210
|
+
...e,
|
|
2211
|
+
reservations: U(e.reservations, "shared-object reservation count")
|
|
2212
|
+
}), bn = (e) => Ce("sha256").update(JSON.stringify(e)).digest("hex"), xn = (e, t) => bn([e, t]), Sn = (e) => {
|
|
2158
2213
|
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");
|
|
2159
2214
|
return {
|
|
2160
|
-
id:
|
|
2215
|
+
id: bn([
|
|
2161
2216
|
e.bucket,
|
|
2162
2217
|
e.tenantId,
|
|
2163
2218
|
e.operationId
|
|
2164
2219
|
]),
|
|
2165
|
-
objectId:
|
|
2220
|
+
objectId: bn([
|
|
2166
2221
|
e.bucket,
|
|
2167
2222
|
e.tenantId,
|
|
2168
2223
|
e.logicalKey,
|
|
2169
2224
|
e.checksum
|
|
2170
2225
|
]),
|
|
2171
|
-
lockId:
|
|
2226
|
+
lockId: bn([e.tenantId])
|
|
2172
2227
|
};
|
|
2173
|
-
},
|
|
2174
|
-
let { lockId: r } =
|
|
2175
|
-
return await e.insertIgnoreWithOutcome(
|
|
2228
|
+
}, Cn = async (e, t, n) => {
|
|
2229
|
+
let { lockId: r } = Sn(t);
|
|
2230
|
+
return await e.insertIgnoreWithOutcome(pn, {
|
|
2176
2231
|
id: r,
|
|
2177
|
-
nonce:
|
|
2232
|
+
nonce: Te()
|
|
2178
2233
|
}, { conflictColumns: ["id"] }), e.transactional(async (e) => {
|
|
2179
2234
|
if ((await e.query({
|
|
2180
|
-
table:
|
|
2235
|
+
table: pn,
|
|
2181
2236
|
predicate: O("id", r),
|
|
2182
2237
|
lock: "update",
|
|
2183
2238
|
order: [],
|
|
2184
2239
|
take: 1,
|
|
2185
2240
|
skip: void 0,
|
|
2186
2241
|
projection: void 0
|
|
2187
|
-
})).length !== 1 || await e.update(
|
|
2242
|
+
})).length !== 1 || await e.update(pn, r, { nonce: Te() }) === null) throw Error("Storage operation lock is unavailable");
|
|
2188
2243
|
return n(e);
|
|
2189
2244
|
});
|
|
2190
|
-
},
|
|
2191
|
-
let r =
|
|
2192
|
-
table:
|
|
2245
|
+
}, $ = async (e, t) => {
|
|
2246
|
+
let r = Sn(t), i = await e.query({
|
|
2247
|
+
table: mn,
|
|
2193
2248
|
predicate: O("id", r.id),
|
|
2194
2249
|
order: [],
|
|
2195
2250
|
take: 1,
|
|
@@ -2197,28 +2252,28 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2197
2252
|
projection: void 0
|
|
2198
2253
|
});
|
|
2199
2254
|
if (!i[0]) return;
|
|
2200
|
-
let a = C.decodeUnknownSync(
|
|
2255
|
+
let a = C.decodeUnknownSync(_n)(i[0]);
|
|
2201
2256
|
if (a.fingerprint !== t.fingerprint || a.objectId !== r.objectId) throw new n({
|
|
2202
2257
|
reason: "operation-identity-reused",
|
|
2203
2258
|
detail: `storage operation '${t.operationId}' was already used with different inputs`
|
|
2204
2259
|
});
|
|
2205
2260
|
return a;
|
|
2206
|
-
},
|
|
2207
|
-
let n = await
|
|
2261
|
+
}, wn = async (e, t) => {
|
|
2262
|
+
let n = await $(e, t);
|
|
2208
2263
|
if (n) return n;
|
|
2209
|
-
let { id: r, objectId: i } =
|
|
2210
|
-
table:
|
|
2264
|
+
let { id: r, objectId: i } = Sn(t), a = await e.query({
|
|
2265
|
+
table: Q,
|
|
2211
2266
|
predicate: O("id", i),
|
|
2212
2267
|
order: [],
|
|
2213
2268
|
take: 1,
|
|
2214
2269
|
skip: void 0,
|
|
2215
2270
|
projection: void 0
|
|
2216
|
-
}), o = a[0] ?
|
|
2217
|
-
o ? await e.update(
|
|
2271
|
+
}), o = a[0] ? yn(a[0]) : void 0, s = o?.generation ?? Te(), c = o?.key ?? `${t.logicalKey}/g-${s}`;
|
|
2272
|
+
o ? await e.update(Q, i, { reservations: String(W(o.reservations, 1, "shared-object reservation count")) }) : await e.insert(Q, {
|
|
2218
2273
|
id: i,
|
|
2219
2274
|
generation: s,
|
|
2220
2275
|
key: c,
|
|
2221
|
-
reservations: 1
|
|
2276
|
+
reservations: "1"
|
|
2222
2277
|
});
|
|
2223
2278
|
let l = {
|
|
2224
2279
|
id: r,
|
|
@@ -2226,35 +2281,35 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2226
2281
|
fingerprint: t.fingerprint,
|
|
2227
2282
|
generation: s,
|
|
2228
2283
|
key: c,
|
|
2229
|
-
refId: `file_${
|
|
2284
|
+
refId: `file_${Te()}`,
|
|
2230
2285
|
state: "reserved",
|
|
2231
2286
|
deleteKey: null
|
|
2232
2287
|
};
|
|
2233
|
-
return await e.insert(
|
|
2234
|
-
},
|
|
2235
|
-
let n = await
|
|
2288
|
+
return await e.insert(mn, l), l;
|
|
2289
|
+
}, Tn = async (e, t) => {
|
|
2290
|
+
let n = await $(e, t);
|
|
2236
2291
|
if (!n) throw Error("Storage operation is missing");
|
|
2237
2292
|
if (n.state === "deleting" || n.state === "deleted") throw Error("Deleted storage operation cannot be confirmed by a late put");
|
|
2238
|
-
return await e.update(
|
|
2293
|
+
return await e.update(mn, n.id, { state: "ready" }), {
|
|
2239
2294
|
...n,
|
|
2240
2295
|
state: "ready"
|
|
2241
2296
|
};
|
|
2242
|
-
},
|
|
2243
|
-
let n = await
|
|
2297
|
+
}, En = async (e, t) => {
|
|
2298
|
+
let n = await $(e, t);
|
|
2244
2299
|
if (!n) throw Error("Storage operation is missing");
|
|
2245
2300
|
if (n.state === "deleting" || n.state === "deleted") return n;
|
|
2246
2301
|
if (n.state !== "ready") throw Error("An unconfirmed put cannot be deleted");
|
|
2247
2302
|
let r = await e.query({
|
|
2248
|
-
table:
|
|
2303
|
+
table: Q,
|
|
2249
2304
|
predicate: O("id", n.objectId),
|
|
2250
2305
|
order: [],
|
|
2251
2306
|
take: 1,
|
|
2252
2307
|
skip: void 0,
|
|
2253
2308
|
projection: void 0
|
|
2254
|
-
}), i = r[0] ?
|
|
2309
|
+
}), i = r[0] ? yn(r[0]) : void 0;
|
|
2255
2310
|
if (!i || i.generation !== n.generation || i.reservations < 1) throw Error("Storage object generation does not own its reservation");
|
|
2256
2311
|
let a = i.reservations === 1 ? i.key : null;
|
|
2257
|
-
return a === null ? await e.update(
|
|
2312
|
+
return a === null ? await e.update(Q, i.id, { reservations: String(i.reservations - 1) }) : await e.delete(Q, i.id), await e.update(mn, n.id, {
|
|
2258
2313
|
state: "deleting",
|
|
2259
2314
|
deleteKey: a
|
|
2260
2315
|
}), {
|
|
@@ -2262,45 +2317,45 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2262
2317
|
state: "deleting",
|
|
2263
2318
|
deleteKey: a
|
|
2264
2319
|
};
|
|
2265
|
-
},
|
|
2266
|
-
let n = await
|
|
2320
|
+
}, Dn = async (e, t) => {
|
|
2321
|
+
let n = await $(e, t);
|
|
2267
2322
|
if (!n || n.state !== "deleting" && n.state !== "deleted") throw Error("Storage deletion has not been accepted");
|
|
2268
|
-
return n.state !== "deleted" && (await e.update(
|
|
2269
|
-
},
|
|
2323
|
+
return n.state !== "deleted" && (await e.update(mn, n.id, { state: "deleted" }), !0);
|
|
2324
|
+
}, On = async (e, t, n) => {
|
|
2270
2325
|
if (!n) throw Error("Storage object claim must be a non-empty string");
|
|
2271
|
-
await e.insertIgnoreWithOutcome(
|
|
2272
|
-
id:
|
|
2326
|
+
await e.insertIgnoreWithOutcome(hn, {
|
|
2327
|
+
id: xn(t, n),
|
|
2273
2328
|
operationId: t,
|
|
2274
2329
|
claim: n
|
|
2275
2330
|
}, { conflictColumns: ["id"] });
|
|
2276
|
-
},
|
|
2277
|
-
let r =
|
|
2331
|
+
}, kn = async (e, t, n) => {
|
|
2332
|
+
let r = xn(t, n);
|
|
2278
2333
|
return {
|
|
2279
|
-
held: await e.delete(
|
|
2334
|
+
held: await e.delete(hn, r),
|
|
2280
2335
|
others: (await e.query({
|
|
2281
|
-
table:
|
|
2282
|
-
predicate:
|
|
2336
|
+
table: hn,
|
|
2337
|
+
predicate: T(O("operationId", t), ve("claim", n)),
|
|
2283
2338
|
order: [],
|
|
2284
2339
|
take: 1,
|
|
2285
2340
|
skip: void 0,
|
|
2286
2341
|
projection: void 0
|
|
2287
2342
|
})).length > 0
|
|
2288
2343
|
};
|
|
2289
|
-
},
|
|
2290
|
-
id:
|
|
2291
|
-
refId:
|
|
2292
|
-
identity:
|
|
2293
|
-
ref:
|
|
2294
|
-
}).primaryKey(["id"]).unique("storagePutRef", ["refId"]).nonReactive(),
|
|
2344
|
+
}, An = (e, t) => e.deleteMany(hn, { where: O("operationId", t) }), jn = "_voltro_storage_put_intents", Mn = N(jn, {
|
|
2345
|
+
id: P().maxLength(64),
|
|
2346
|
+
refId: P().maxLength(64),
|
|
2347
|
+
identity: ge(),
|
|
2348
|
+
ref: ge()
|
|
2349
|
+
}).primaryKey(["id"]).unique("storagePutRef", ["refId"]).nonReactive(), Nn = C.Struct({
|
|
2295
2350
|
tenantId: C.NullOr(C.String),
|
|
2296
2351
|
bucket: C.String,
|
|
2297
2352
|
operationId: C.String,
|
|
2298
2353
|
fingerprint: C.String,
|
|
2299
2354
|
checksum: C.String,
|
|
2300
2355
|
logicalKey: C.String
|
|
2301
|
-
}),
|
|
2356
|
+
}), Pn = async (e, t) => {
|
|
2302
2357
|
let n = await e.query({
|
|
2303
|
-
table:
|
|
2358
|
+
table: jn,
|
|
2304
2359
|
predicate: O("refId", t),
|
|
2305
2360
|
order: [],
|
|
2306
2361
|
take: 2,
|
|
@@ -2309,31 +2364,31 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2309
2364
|
});
|
|
2310
2365
|
if (n.length === 0) return;
|
|
2311
2366
|
if (n.length !== 1) throw Error("Storage reference has ambiguous operation ownership");
|
|
2312
|
-
let r = n[0], i = C.decodeUnknownSync(
|
|
2367
|
+
let r = n[0], i = C.decodeUnknownSync(Nn)(r.identity);
|
|
2313
2368
|
if (typeof r.ref != "object" || r.ref === null || Array.isArray(r.ref)) throw Error("Storage operation reference is unreadable");
|
|
2314
|
-
let a =
|
|
2369
|
+
let a = X(r.ref);
|
|
2315
2370
|
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");
|
|
2316
2371
|
return {
|
|
2317
2372
|
identity: i,
|
|
2318
2373
|
ref: a
|
|
2319
2374
|
};
|
|
2320
|
-
},
|
|
2321
|
-
intent: (t) =>
|
|
2322
|
-
reserve: (t, r, i, a) =>
|
|
2375
|
+
}, Fn = (e) => ({
|
|
2376
|
+
intent: (t) => Pn(e, t),
|
|
2377
|
+
reserve: (t, r, i, a) => Cn(e, t, async (e) => {
|
|
2323
2378
|
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");
|
|
2324
|
-
let o = await
|
|
2379
|
+
let o = await $(e, t);
|
|
2325
2380
|
if (o) {
|
|
2326
2381
|
if (o.state === "deleting" || o.state === "deleted") throw Error("Storage put identity has already been deleted");
|
|
2327
|
-
let t = await
|
|
2382
|
+
let t = await Pn(e, o.refId);
|
|
2328
2383
|
if (!t) throw Error("Storage operation lost its put intent");
|
|
2329
2384
|
let n = o.state === "ready";
|
|
2330
|
-
return n && a !== void 0 && await
|
|
2385
|
+
return n && a !== void 0 && await On(e, o.id, a), {
|
|
2331
2386
|
ref: t.ref,
|
|
2332
2387
|
ready: n,
|
|
2333
2388
|
outcome: n ? "joined" : "resumed"
|
|
2334
2389
|
};
|
|
2335
2390
|
}
|
|
2336
|
-
let s = await
|
|
2391
|
+
let s = await wn(e, t), c = an(e);
|
|
2337
2392
|
if (!(await y.runPromise(c.consumeUsage(t.tenantId, {
|
|
2338
2393
|
bytes: r.size,
|
|
2339
2394
|
count: 1
|
|
@@ -2341,12 +2396,12 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2341
2396
|
reason: "quota-exceeded",
|
|
2342
2397
|
detail: "Storage operation exceeds tenant quota"
|
|
2343
2398
|
});
|
|
2344
|
-
let l =
|
|
2399
|
+
let l = X({
|
|
2345
2400
|
...r,
|
|
2346
2401
|
id: s.refId,
|
|
2347
2402
|
key: s.key
|
|
2348
2403
|
});
|
|
2349
|
-
return await e.insert(
|
|
2404
|
+
return await e.insert(jn, {
|
|
2350
2405
|
id: s.id,
|
|
2351
2406
|
refId: l.id,
|
|
2352
2407
|
identity: t,
|
|
@@ -2357,31 +2412,31 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2357
2412
|
outcome: "created"
|
|
2358
2413
|
};
|
|
2359
2414
|
}),
|
|
2360
|
-
confirm: (t, n) =>
|
|
2361
|
-
let r = await
|
|
2415
|
+
confirm: (t, n) => Cn(e, t, async (e) => {
|
|
2416
|
+
let r = await $(e, t);
|
|
2362
2417
|
if (!r) throw Error("Storage put operation is missing");
|
|
2363
|
-
let i = await
|
|
2418
|
+
let i = await Pn(e, r.refId);
|
|
2364
2419
|
if (!i) throw Error("Storage put intent is missing");
|
|
2365
|
-
if (n !== void 0 && await
|
|
2366
|
-
let n = await y.runPromise(
|
|
2420
|
+
if (n !== void 0 && await On(e, r.id, n), r.state === "ready") {
|
|
2421
|
+
let n = await y.runPromise(an(e).getById(r.refId));
|
|
2367
2422
|
if (!n || n.key !== r.key || n.checksum !== t.checksum) throw Error("Confirmed storage operation lost its reference");
|
|
2368
2423
|
return n;
|
|
2369
2424
|
}
|
|
2370
|
-
return await
|
|
2425
|
+
return await Tn(e, t), await y.runPromise(an(e).insert(i.ref)), i.ref;
|
|
2371
2426
|
}),
|
|
2372
2427
|
beginDelete: async (t, r, i) => {
|
|
2373
|
-
let a = await
|
|
2428
|
+
let a = await Pn(e, t);
|
|
2374
2429
|
if (!a) throw Error("Storage delete operation is missing");
|
|
2375
2430
|
if (r !== void 0 && a.identity.tenantId !== r) throw Error("Storage delete tenant mismatch");
|
|
2376
|
-
return
|
|
2377
|
-
let r = await
|
|
2431
|
+
return Cn(e, a.identity, async (e) => {
|
|
2432
|
+
let r = await Pn(e, t);
|
|
2378
2433
|
if (!r) throw Error("Storage delete intent disappeared");
|
|
2379
|
-
let a = await
|
|
2434
|
+
let a = await $(e, r.identity);
|
|
2380
2435
|
if (!a) throw Error("Storage delete lost its operation");
|
|
2381
2436
|
let o = a.state !== "deleting" && a.state !== "deleted";
|
|
2382
|
-
if (i === void 0) o && await
|
|
2437
|
+
if (i === void 0) o && await An(e, a.id);
|
|
2383
2438
|
else if (o) {
|
|
2384
|
-
let o = await
|
|
2439
|
+
let o = await kn(e, a.id, i);
|
|
2385
2440
|
if (o.others) return {
|
|
2386
2441
|
released: !0,
|
|
2387
2442
|
identity: r.identity
|
|
@@ -2391,10 +2446,10 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2391
2446
|
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`
|
|
2392
2447
|
});
|
|
2393
2448
|
}
|
|
2394
|
-
let s = await
|
|
2449
|
+
let s = await En(e, r.identity);
|
|
2395
2450
|
if (a.state === "ready") {
|
|
2396
|
-
let n =
|
|
2397
|
-
if (await y.runPromise(
|
|
2451
|
+
let n = an(e);
|
|
2452
|
+
if (await y.runPromise(cn(e).deleteByRef(t)), !await y.runPromise(n.delete(t))) throw Error("Storage deletion lost its confirmed reference");
|
|
2398
2453
|
await y.runPromise(n.releaseUsage(r.identity.tenantId, {
|
|
2399
2454
|
bytes: r.ref.size,
|
|
2400
2455
|
count: 1
|
|
@@ -2407,8 +2462,8 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2407
2462
|
};
|
|
2408
2463
|
});
|
|
2409
2464
|
},
|
|
2410
|
-
confirmDelete: (t) =>
|
|
2411
|
-
}),
|
|
2465
|
+
confirmDelete: (t) => Cn(e, t, (e) => Dn(e, t))
|
|
2466
|
+
}), In = (e, t = 65536) => {
|
|
2412
2467
|
let n = [Buffer.from("zINSTREAM\0", "utf8")];
|
|
2413
2468
|
for (let r = 0; r < e.length; r += t) {
|
|
2414
2469
|
let i = e.subarray(r, Math.min(r + t, e.length)), a = Buffer.alloc(4);
|
|
@@ -2416,7 +2471,7 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2416
2471
|
}
|
|
2417
2472
|
let r = Buffer.alloc(4);
|
|
2418
2473
|
return r.writeUInt32BE(0, 0), n.push(r), Buffer.concat(n);
|
|
2419
|
-
},
|
|
2474
|
+
}, Ln = (e) => {
|
|
2420
2475
|
let t = e.replace(/\0+$/, "").trim();
|
|
2421
2476
|
if (/\bOK$/.test(t)) return { clean: !0 };
|
|
2422
2477
|
let n = /:\s*(.+?)\s+FOUND$/.exec(t);
|
|
@@ -2425,8 +2480,8 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2425
2480
|
threat: n[1] ?? "unknown"
|
|
2426
2481
|
};
|
|
2427
2482
|
throw Error(`clamav: unexpected response: ${t}`);
|
|
2428
|
-
},
|
|
2429
|
-
let n = await import("node:net"), r =
|
|
2483
|
+
}, Rn = async (e, t) => {
|
|
2484
|
+
let n = await import("node:net"), r = H.read("CLAMAV_HOST", t.host) ?? "127.0.0.1", i = H.read("CLAMAV_PORT"), a = t.port ?? (i ? Number(i) : 3310), o = t.timeoutMs ?? 3e4;
|
|
2430
2485
|
return new Promise((i, s) => {
|
|
2431
2486
|
let c = n.createConnection({
|
|
2432
2487
|
host: r,
|
|
@@ -2437,20 +2492,20 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2437
2492
|
c.on("error", (e) => {
|
|
2438
2493
|
clearTimeout(u), s(e);
|
|
2439
2494
|
}), c.on("connect", () => {
|
|
2440
|
-
c.end(
|
|
2495
|
+
c.end(In(e, t.chunkSize));
|
|
2441
2496
|
}), c.on("data", (e) => {
|
|
2442
2497
|
l += e.toString("utf8");
|
|
2443
2498
|
}), c.on("close", () => {
|
|
2444
2499
|
clearTimeout(u);
|
|
2445
2500
|
try {
|
|
2446
|
-
i(
|
|
2501
|
+
i(Ln(l));
|
|
2447
2502
|
} catch (e) {
|
|
2448
2503
|
s(e);
|
|
2449
2504
|
}
|
|
2450
2505
|
});
|
|
2451
2506
|
});
|
|
2452
|
-
},
|
|
2453
|
-
let a =
|
|
2507
|
+
}, zn = (e = {}) => (t) => Rn(t.bytes, e), Bn = (e, t, n) => new Promise((r, i) => {
|
|
2508
|
+
let a = R(e, [...t], { stdio: [
|
|
2454
2509
|
"ignore",
|
|
2455
2510
|
"ignore",
|
|
2456
2511
|
"pipe"
|
|
@@ -2464,31 +2519,31 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2464
2519
|
}), a.on("close", (e) => {
|
|
2465
2520
|
clearTimeout(s), e === 0 ? r() : i(/* @__PURE__ */ Error(`ffmpeg exited ${String(e)}: ${o.slice(-400)}`));
|
|
2466
2521
|
});
|
|
2467
|
-
}),
|
|
2468
|
-
let n = e.ffmpegPath ?? "ffmpeg", r = e.timeoutMs ?? 3e5, i = await
|
|
2522
|
+
}), Vn = (e) => async ({ bytes: t }) => {
|
|
2523
|
+
let n = e.ffmpegPath ?? "ffmpeg", r = e.timeoutMs ?? 3e5, i = await De(Me(je(), "voltro-tc-")), a = Me(i, "in"), o = [];
|
|
2469
2524
|
try {
|
|
2470
|
-
await
|
|
2525
|
+
await Ae(a, t);
|
|
2471
2526
|
for (let t of e.renditions) {
|
|
2472
|
-
let e =
|
|
2527
|
+
let e = Me(i, `out.${t.ext}`);
|
|
2473
2528
|
try {
|
|
2474
|
-
await
|
|
2529
|
+
await Bn(n, [
|
|
2475
2530
|
"-y",
|
|
2476
2531
|
"-i",
|
|
2477
2532
|
a,
|
|
2478
2533
|
...t.args,
|
|
2479
2534
|
e
|
|
2480
2535
|
], r);
|
|
2481
|
-
let i = await
|
|
2536
|
+
let i = await Oe(e);
|
|
2482
2537
|
o.push({
|
|
2483
2538
|
bytes: new Uint8Array(i),
|
|
2484
2539
|
contentType: t.contentType,
|
|
2485
2540
|
kind: t.kind,
|
|
2486
2541
|
...t.label === void 0 ? {} : { label: t.label }
|
|
2487
|
-
}), await
|
|
2542
|
+
}), await ke(e, { force: !0 });
|
|
2488
2543
|
} catch {}
|
|
2489
2544
|
}
|
|
2490
2545
|
} finally {
|
|
2491
|
-
await
|
|
2546
|
+
await ke(i, {
|
|
2492
2547
|
recursive: !0,
|
|
2493
2548
|
force: !0
|
|
2494
2549
|
}).catch(() => void 0);
|
|
@@ -2497,21 +2552,21 @@ var Te = 1 << 20, Ee = (e, n, r = !1) => new t({
|
|
|
2497
2552
|
};
|
|
2498
2553
|
//#endregion
|
|
2499
2554
|
//#region src/assetRef.ts
|
|
2500
|
-
function
|
|
2501
|
-
let t = e.nullable ?? !0, n = e.fk === !1 ?
|
|
2555
|
+
function Hn(e = {}) {
|
|
2556
|
+
let t = e.nullable ?? !0, n = e.fk === !1 ? P().externalId() : ye(() => We, { onDelete: e.onDelete ?? "setNull" });
|
|
2502
2557
|
return t ? n.nullable() : n;
|
|
2503
2558
|
}
|
|
2504
|
-
var
|
|
2559
|
+
var Un = () => _e({
|
|
2505
2560
|
id: "@voltro/plugin-storage/withStorage",
|
|
2506
|
-
fields: { asset:
|
|
2507
|
-
}),
|
|
2561
|
+
fields: { asset: Hn() }
|
|
2562
|
+
}), Wn = {
|
|
2508
2563
|
"image/png": "png",
|
|
2509
2564
|
"image/jpeg": "jpg",
|
|
2510
2565
|
"image/jpg": "jpg",
|
|
2511
2566
|
"image/gif": "gif",
|
|
2512
2567
|
"image/webp": "webp",
|
|
2513
2568
|
"image/svg+xml": "svg"
|
|
2514
|
-
},
|
|
2569
|
+
}, Gn = (e) => {
|
|
2515
2570
|
let t = /^data:([^;,]+)(;base64)?,(.*)$/s.exec(e);
|
|
2516
2571
|
if (!t) throw Error("not a data URI");
|
|
2517
2572
|
let n = t[1] || "application/octet-stream", r = !!t[2], i = t[3] ?? "";
|
|
@@ -2519,16 +2574,16 @@ var Mn = () => de({
|
|
|
2519
2574
|
bytes: r ? new Uint8Array(Buffer.from(i, "base64")) : new Uint8Array(Buffer.from(decodeURIComponent(i), "utf8")),
|
|
2520
2575
|
contentType: n
|
|
2521
2576
|
};
|
|
2522
|
-
},
|
|
2577
|
+
}, Kn = (e, n) => y.gen(function* () {
|
|
2523
2578
|
let r = yield* y.try({
|
|
2524
|
-
try: () =>
|
|
2579
|
+
try: () => Gn(n.dataUri),
|
|
2525
2580
|
catch: (e) => new t({
|
|
2526
2581
|
provider: "avatar",
|
|
2527
2582
|
message: String(e?.message ?? e),
|
|
2528
2583
|
transient: !1,
|
|
2529
2584
|
status: 400
|
|
2530
2585
|
})
|
|
2531
|
-
}), i =
|
|
2586
|
+
}), i = Wn[r.contentType] ?? "bin";
|
|
2532
2587
|
return yield* e.put({
|
|
2533
2588
|
bytes: r.bytes,
|
|
2534
2589
|
contentType: r.contentType,
|
|
@@ -2537,27 +2592,27 @@ var Mn = () => de({
|
|
|
2537
2592
|
visibility: "public",
|
|
2538
2593
|
key: `avatars/${n.userId}/avatar.${i}`
|
|
2539
2594
|
});
|
|
2540
|
-
}),
|
|
2595
|
+
}), qn = (e) => {
|
|
2541
2596
|
try {
|
|
2542
|
-
let t =
|
|
2597
|
+
let t = Ne(e), n = Ne("/");
|
|
2543
2598
|
return typeof t.dev != "number" || typeof n.dev != "number" ? "unknown" : t.dev === n.dev ? "same-device-as-root" : "separate-mount";
|
|
2544
2599
|
} catch {
|
|
2545
2600
|
return "unknown";
|
|
2546
2601
|
}
|
|
2547
|
-
},
|
|
2548
|
-
if (
|
|
2602
|
+
}, Jn = (e) => {
|
|
2603
|
+
if (qn(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
|
|
2549
2604
|
dies with it — which is the exact failure it exists for. On a development machine this is normal
|
|
2550
2605
|
and can be ignored.`;
|
|
2551
|
-
},
|
|
2552
|
-
|
|
2553
|
-
},
|
|
2606
|
+
}, Yn = H.read("VOLTRO_SESSION_COOKIE") ?? "voltro:session", Xn, Zn = (e) => {
|
|
2607
|
+
Xn = e;
|
|
2608
|
+
}, Qn = () => Xn ?? er({}), $n = () => Xn === void 0 ? H.read("STORAGE_PROVIDER") === void 0 ? void 0 : er({}) : Xn, er = (e) => {
|
|
2554
2609
|
if (e.provider && typeof e.provider == "object") return e.provider;
|
|
2555
|
-
let t = (e.provider ??
|
|
2610
|
+
let t = (e.provider ?? H.read("STORAGE_PROVIDER") ?? "memory").toLowerCase(), n = H.read("S3_BUCKET", e.bucket) ?? H.read("STORAGE_BUCKET") ?? "voltro";
|
|
2556
2611
|
switch (t) {
|
|
2557
2612
|
case "s3":
|
|
2558
2613
|
case "minio": {
|
|
2559
|
-
let r =
|
|
2560
|
-
return
|
|
2614
|
+
let r = H.read("S3_REGION", e.region) ?? H.read("AWS_REGION"), i = H.read("S3_ENDPOINT", e.endpoint) ?? H.read("MINIO_ENDPOINT"), a = H.read("S3_ACCESS_KEY_ID", e.accessKeyId) ?? H.read("AWS_ACCESS_KEY_ID"), o = H.read("S3_SECRET_ACCESS_KEY", e.secretAccessKey) ?? H.read("AWS_SECRET_ACCESS_KEY"), s = H.read("STORAGE_CDN_URL", e.cdnBaseUrl);
|
|
2615
|
+
return tt({
|
|
2561
2616
|
bucket: n,
|
|
2562
2617
|
name: t,
|
|
2563
2618
|
...r ? { region: r } : {},
|
|
@@ -2566,13 +2621,13 @@ var Mn = () => de({
|
|
|
2566
2621
|
...o ? { secretAccessKey: o } : {},
|
|
2567
2622
|
...s ? { cdnBaseUrl: s } : {},
|
|
2568
2623
|
...e.publicAcl === void 0 ? {} : { publicAcl: e.publicAcl },
|
|
2569
|
-
...t === "minio" ||
|
|
2624
|
+
...t === "minio" || H.read("S3_FORCE_PATH_STYLE") === "1" ? { forcePathStyle: !0 } : {}
|
|
2570
2625
|
});
|
|
2571
2626
|
}
|
|
2572
2627
|
case "azure": {
|
|
2573
|
-
let t =
|
|
2574
|
-
return
|
|
2575
|
-
container:
|
|
2628
|
+
let t = H.read("AZURE_STORAGE_ACCOUNT", e.accountName), r = H.read("AZURE_STORAGE_KEY", e.accountKey), i = H.read("AZURE_STORAGE_CONNECTION_STRING", e.connectionString), a = H.read("AZURE_STORAGE_ENDPOINT", e.endpoint), o = H.read("STORAGE_CDN_URL", e.cdnBaseUrl);
|
|
2629
|
+
return it({
|
|
2630
|
+
container: H.read("AZURE_STORAGE_CONTAINER", e.bucket) ?? n,
|
|
2576
2631
|
...t ? { accountName: t } : {},
|
|
2577
2632
|
...r ? { accountKey: r } : {},
|
|
2578
2633
|
...i ? { connectionString: i } : {},
|
|
@@ -2580,11 +2635,11 @@ var Mn = () => de({
|
|
|
2580
2635
|
...o ? { cdnBaseUrl: o } : {}
|
|
2581
2636
|
});
|
|
2582
2637
|
}
|
|
2583
|
-
case "database": return
|
|
2584
|
-
case "filesystem": return
|
|
2585
|
-
default: return
|
|
2638
|
+
case "database": return rt();
|
|
2639
|
+
case "filesystem": return et({ root: H.read("STORAGE_ROOT", e.root) ?? ".voltro-storage" });
|
|
2640
|
+
default: return $e(e.name ?? "default");
|
|
2586
2641
|
}
|
|
2587
|
-
},
|
|
2642
|
+
}, tr = (e) => {
|
|
2588
2643
|
let t = "stored files (uploads, renditions) and their reads", n = "provider 'database' or 'filesystem' keeps the bytes inside the installation";
|
|
2589
2644
|
if (e.provider && typeof e.provider == "object") return [{
|
|
2590
2645
|
destination: `runtime:the '${e.provider.name}' storage provider`,
|
|
@@ -2592,9 +2647,9 @@ var Mn = () => de({
|
|
|
2592
2647
|
data: ["files"],
|
|
2593
2648
|
disable: n
|
|
2594
2649
|
}];
|
|
2595
|
-
let r = (e.provider ??
|
|
2650
|
+
let r = (e.provider ?? H.read("STORAGE_PROVIDER") ?? "memory").toLowerCase();
|
|
2596
2651
|
if (r === "s3" || r === "minio") {
|
|
2597
|
-
let r =
|
|
2652
|
+
let r = H.read("S3_ENDPOINT", e.endpoint) ?? H.read("MINIO_ENDPOINT"), i = H.read("S3_REGION", e.region) ?? H.read("AWS_REGION") ?? "us-east-1";
|
|
2598
2653
|
return [{
|
|
2599
2654
|
destination: r ?? `s3.${i}.amazonaws.com`,
|
|
2600
2655
|
purpose: t,
|
|
@@ -2603,7 +2658,7 @@ var Mn = () => de({
|
|
|
2603
2658
|
}];
|
|
2604
2659
|
}
|
|
2605
2660
|
if (r === "azure") {
|
|
2606
|
-
let r =
|
|
2661
|
+
let r = H.read("AZURE_STORAGE_ENDPOINT", e.endpoint), i = H.read("AZURE_STORAGE_ACCOUNT", e.accountName);
|
|
2607
2662
|
return [{
|
|
2608
2663
|
destination: r ?? (i === void 0 ? "runtime:the Azure storage connection string" : `${i}.blob.core.windows.net`),
|
|
2609
2664
|
purpose: t,
|
|
@@ -2612,11 +2667,11 @@ var Mn = () => de({
|
|
|
2612
2667
|
}];
|
|
2613
2668
|
}
|
|
2614
2669
|
return [];
|
|
2615
|
-
},
|
|
2670
|
+
}, nr = (e) => {
|
|
2616
2671
|
if (e !== void 0) return e;
|
|
2617
|
-
let t =
|
|
2672
|
+
let t = H.read("STORAGE_ALLOWED_ORIGINS");
|
|
2618
2673
|
return t ? t.trim() === "*" ? "*" : t.split(",").map((e) => e.trim()).filter(Boolean) : [];
|
|
2619
|
-
},
|
|
2674
|
+
}, rr = (e, t) => {
|
|
2620
2675
|
if (!e || t !== "*" && !t.includes(e)) return {};
|
|
2621
2676
|
let n = {
|
|
2622
2677
|
"access-control-allow-origin": t === "*" ? "*" : e,
|
|
@@ -2626,7 +2681,7 @@ var Mn = () => de({
|
|
|
2626
2681
|
vary: "Origin"
|
|
2627
2682
|
};
|
|
2628
2683
|
return t !== "*" && (n["access-control-allow-credentials"] = "true"), n;
|
|
2629
|
-
},
|
|
2684
|
+
}, ir = (e) => ({
|
|
2630
2685
|
id: e.id,
|
|
2631
2686
|
tenantId: e.tenantId,
|
|
2632
2687
|
ownerId: e.ownerId,
|
|
@@ -2649,29 +2704,29 @@ var Mn = () => de({
|
|
|
2649
2704
|
caption: e.caption ?? null,
|
|
2650
2705
|
derivedFrom: e.derivedFrom ?? null,
|
|
2651
2706
|
kind: e.kind ?? null
|
|
2652
|
-
}),
|
|
2707
|
+
}), ar = () => new t({
|
|
2653
2708
|
provider: "storage",
|
|
2654
2709
|
message: "not permitted to administer sharing for this object",
|
|
2655
2710
|
transient: !1,
|
|
2656
2711
|
status: 403
|
|
2657
|
-
}),
|
|
2712
|
+
}), or = (e, t, n) => {
|
|
2658
2713
|
let r = n.request.subject;
|
|
2659
|
-
return (r.scopes ?? []).includes("admin:full") ? y.void : e.head(t, { tenantId: r.tenantId ?? null }).pipe(y.catchAll(() => y.fail(
|
|
2714
|
+
return (r.scopes ?? []).includes("admin:full") ? y.void : e.head(t, { tenantId: r.tenantId ?? null }).pipe(y.catchAll(() => y.fail(ar())), y.flatMap((e) => {
|
|
2660
2715
|
let t = e?.ownerId;
|
|
2661
|
-
return t != null && t === r.id ? y.void : y.fail(
|
|
2716
|
+
return t != null && t === r.id ? y.void : y.fail(ar());
|
|
2662
2717
|
}));
|
|
2663
|
-
},
|
|
2718
|
+
}, sr = () => new t({
|
|
2664
2719
|
provider: "storage",
|
|
2665
2720
|
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.",
|
|
2666
2721
|
transient: !1,
|
|
2667
2722
|
status: 401
|
|
2668
|
-
}),
|
|
2723
|
+
}), cr = (e, t) => {
|
|
2669
2724
|
let n = e.request.subject.id ?? null, r = e.request.subject.tenantId ?? null;
|
|
2670
|
-
return n === null && !t ? y.fail(
|
|
2725
|
+
return n === null && !t ? y.fail(sr()) : y.succeed({
|
|
2671
2726
|
id: n,
|
|
2672
2727
|
tenantId: r
|
|
2673
2728
|
});
|
|
2674
|
-
},
|
|
2729
|
+
}, lr = (e, t) => e !== null && e !== (t ?? null), ur = (e) => ({
|
|
2675
2730
|
id: e.id,
|
|
2676
2731
|
refId: e.refId,
|
|
2677
2732
|
principalType: e.principalType,
|
|
@@ -2680,46 +2735,46 @@ var Mn = () => de({
|
|
|
2680
2735
|
createdAt: e.createdAt.toISOString(),
|
|
2681
2736
|
expiresAt: e.expiresAt ? e.expiresAt.toISOString() : null,
|
|
2682
2737
|
createdBy: e.createdBy
|
|
2683
|
-
}),
|
|
2684
|
-
base:
|
|
2738
|
+
}), dr = "@voltro/plugin-storage", fr = (e = {}) => oe({
|
|
2739
|
+
base: dr,
|
|
2685
2740
|
alias: e.alias,
|
|
2686
2741
|
instance: e.name
|
|
2687
|
-
}),
|
|
2688
|
-
let v =
|
|
2689
|
-
base:
|
|
2742
|
+
}), pr = (i = {}) => {
|
|
2743
|
+
let v = oe({
|
|
2744
|
+
base: dr,
|
|
2690
2745
|
alias: i.alias,
|
|
2691
2746
|
instance: i.name
|
|
2692
|
-
}), b = v ===
|
|
2693
|
-
|
|
2694
|
-
let S =
|
|
2695
|
-
insert: (e) =>
|
|
2696
|
-
getById: (e) =>
|
|
2697
|
-
delete: (e) =>
|
|
2698
|
-
statistics: () =>
|
|
2699
|
-
listRecent: (e) =>
|
|
2700
|
-
countByKey: (e, t) =>
|
|
2701
|
-
usageByTenant: (e) =>
|
|
2702
|
-
consumeUsage: (e, t, n) =>
|
|
2703
|
-
releaseUsage: (e, t) =>
|
|
2704
|
-
listByDerivedFrom: (e) =>
|
|
2705
|
-
listRefs: (e) =>
|
|
2747
|
+
}), b = v === dr ? "/_voltro/storage" : `/_voltro/storage/i/${Buffer.from(v).toString("hex")}`, x = er(i);
|
|
2748
|
+
Zn(x);
|
|
2749
|
+
let S = H.read("S3_BUCKET", i.bucket) ?? H.read("STORAGE_BUCKET") ?? "voltro", T = H.read("VOLTRO_PUBLIC_URL", i.publicBaseUrl), ue = nr(i.allowedOrigins), E = i.limits?.maxBytes, D = i.anonymousUploads === !0, de = 5242880, fe = 21600, pe = i.refStore === void 0 || i.refStore === "memory", O = i.grantStore === void 0 || i.grantStore === "memory", me = (e) => e !== "public" && i.uploadAccess !== void 0 ? { access: i.uploadAccess } : {}, k = { current: pe ? tn() : i.refStore }, A = { current: O ? on() : i.grantStore }, j = { current: void 0 }, he = {
|
|
2750
|
+
insert: (e) => k.current.insert(e),
|
|
2751
|
+
getById: (e) => k.current.getById(e),
|
|
2752
|
+
delete: (e) => k.current.delete(e),
|
|
2753
|
+
statistics: () => k.current.statistics(),
|
|
2754
|
+
listRecent: (e) => k.current.listRecent(e),
|
|
2755
|
+
countByKey: (e, t) => k.current.countByKey(e, t),
|
|
2756
|
+
usageByTenant: (e) => k.current.usageByTenant(e),
|
|
2757
|
+
consumeUsage: (e, t, n) => k.current.consumeUsage(e, t, n),
|
|
2758
|
+
releaseUsage: (e, t) => k.current.releaseUsage(e, t),
|
|
2759
|
+
listByDerivedFrom: (e) => k.current.listByDerivedFrom(e),
|
|
2760
|
+
listRefs: (e) => k.current.listRefs(e),
|
|
2706
2761
|
get setVisibility() {
|
|
2707
|
-
return
|
|
2762
|
+
return k.current.setVisibility;
|
|
2708
2763
|
},
|
|
2709
2764
|
get countPublicByKey() {
|
|
2710
|
-
return
|
|
2765
|
+
return k.current.countPublicByKey;
|
|
2711
2766
|
}
|
|
2712
|
-
},
|
|
2713
|
-
insert: (e) =>
|
|
2714
|
-
delete: (e) =>
|
|
2715
|
-
getById: (e) =>
|
|
2716
|
-
listByRef: (e) =>
|
|
2717
|
-
deleteByRef: (e) =>
|
|
2718
|
-
},
|
|
2767
|
+
}, ge = {
|
|
2768
|
+
insert: (e) => A.current.insert(e),
|
|
2769
|
+
delete: (e) => A.current.delete(e),
|
|
2770
|
+
getById: (e) => A.current.getById(e),
|
|
2771
|
+
listByRef: (e) => A.current.listByRef(e),
|
|
2772
|
+
deleteByRef: (e) => A.current.deleteByRef(e)
|
|
2773
|
+
}, _e = {
|
|
2719
2774
|
httpPath: b,
|
|
2720
2775
|
provider: x,
|
|
2721
|
-
refStore:
|
|
2722
|
-
grantStore:
|
|
2776
|
+
refStore: he,
|
|
2777
|
+
grantStore: ge,
|
|
2723
2778
|
bucket: S,
|
|
2724
2779
|
...i.tenantPrefix === void 0 ? {} : { tenantPrefix: i.tenantPrefix },
|
|
2725
2780
|
...i.attempts === void 0 ? {} : { attempts: i.attempts },
|
|
@@ -2731,11 +2786,11 @@ var Mn = () => de({
|
|
|
2731
2786
|
...i.videoProbe === void 0 ? {} : { videoProbe: i.videoProbe },
|
|
2732
2787
|
...i.transcode === void 0 ? {} : { transcode: i.transcode },
|
|
2733
2788
|
...i.autoTranscode === void 0 ? {} : { autoTranscode: i.autoTranscode },
|
|
2734
|
-
...
|
|
2789
|
+
...T ? { publicBaseUrl: T } : {},
|
|
2735
2790
|
...i.normalizeImages === void 0 ? {} : { normalizeImages: i.normalizeImages },
|
|
2736
2791
|
...i.quota === void 0 ? {} : { quota: i.quota },
|
|
2737
|
-
objects: () =>
|
|
2738
|
-
},
|
|
2792
|
+
objects: () => j.current
|
|
2793
|
+
}, ve = fn(_e), M = dn(_e), ye = `${b}/`, N = (e) => y.runPromise(e.pipe(y.catchAll(() => y.succeed(null)))), P = (e, t) => {
|
|
2739
2794
|
if (!e) return "invalid";
|
|
2740
2795
|
let n = /^bytes=(\d*)-(\d*)$/.exec(e.trim());
|
|
2741
2796
|
if (!n) return "invalid";
|
|
@@ -2756,31 +2811,31 @@ var Mn = () => de({
|
|
|
2756
2811
|
start: a,
|
|
2757
2812
|
endInclusive: o
|
|
2758
2813
|
};
|
|
2759
|
-
},
|
|
2814
|
+
}, be = /^(?:image\/(?!svg)|video\/|audio\/|application\/pdf(?:;|$)|text\/plain(?:;|$))/i, xe = (e) => ({
|
|
2760
2815
|
"x-content-type-options": "nosniff",
|
|
2761
|
-
"content-disposition":
|
|
2762
|
-
}),
|
|
2816
|
+
"content-disposition": be.test(e) ? "inline" : "attachment"
|
|
2817
|
+
}), Se = async (e, t, n, r) => {
|
|
2763
2818
|
if (n) {
|
|
2764
|
-
let r = await
|
|
2819
|
+
let r = await N(M.get(e.id));
|
|
2765
2820
|
if (!r) return {
|
|
2766
2821
|
status: 404,
|
|
2767
2822
|
body: "not found",
|
|
2768
2823
|
contentType: "text/plain"
|
|
2769
2824
|
};
|
|
2770
|
-
let i = await
|
|
2825
|
+
let i = await ht(e.id, r.bytes, e.contentType, n).catch(() => null), a = i ? i.bytes : r.bytes, o = i ? i.contentType : e.contentType, s = await dt(e.contentType, i !== null);
|
|
2771
2826
|
return {
|
|
2772
2827
|
status: 200,
|
|
2773
2828
|
body: a,
|
|
2774
2829
|
contentType: o,
|
|
2775
2830
|
headers: {
|
|
2776
|
-
...
|
|
2831
|
+
...xe(o),
|
|
2777
2832
|
"cache-control": t,
|
|
2778
2833
|
"accept-ranges": "none",
|
|
2779
2834
|
...s === null ? {} : { "x-voltro-transform": `original; reason=${s}` }
|
|
2780
2835
|
}
|
|
2781
2836
|
};
|
|
2782
2837
|
}
|
|
2783
|
-
let i = r === void 0 ? "invalid" :
|
|
2838
|
+
let i = r === void 0 ? "invalid" : P(r, e.size);
|
|
2784
2839
|
if (i === "unsatisfiable") return {
|
|
2785
2840
|
status: 416,
|
|
2786
2841
|
body: "range not satisfiable",
|
|
@@ -2791,13 +2846,13 @@ var Mn = () => de({
|
|
|
2791
2846
|
}
|
|
2792
2847
|
};
|
|
2793
2848
|
if (i !== "invalid") {
|
|
2794
|
-
let n = await
|
|
2849
|
+
let n = await N(M.getRange(e.id, i));
|
|
2795
2850
|
return n ? {
|
|
2796
2851
|
status: 206,
|
|
2797
2852
|
body: n.bytes,
|
|
2798
2853
|
contentType: e.contentType,
|
|
2799
2854
|
headers: {
|
|
2800
|
-
...
|
|
2855
|
+
...xe(e.contentType),
|
|
2801
2856
|
"cache-control": t,
|
|
2802
2857
|
"accept-ranges": "bytes",
|
|
2803
2858
|
"content-range": `bytes ${i.start}-${i.endInclusive}/${n.totalSize}`
|
|
@@ -2808,12 +2863,12 @@ var Mn = () => de({
|
|
|
2808
2863
|
contentType: "text/plain"
|
|
2809
2864
|
};
|
|
2810
2865
|
}
|
|
2811
|
-
let a = await
|
|
2866
|
+
let a = await N(M.getStream(e.id));
|
|
2812
2867
|
return a ? {
|
|
2813
2868
|
status: 200,
|
|
2814
2869
|
contentType: e.contentType,
|
|
2815
2870
|
headers: {
|
|
2816
|
-
...
|
|
2871
|
+
...xe(e.contentType),
|
|
2817
2872
|
"cache-control": t,
|
|
2818
2873
|
"accept-ranges": "bytes"
|
|
2819
2874
|
},
|
|
@@ -2826,20 +2881,20 @@ var Mn = () => de({
|
|
|
2826
2881
|
body: "not found",
|
|
2827
2882
|
contentType: "text/plain"
|
|
2828
2883
|
};
|
|
2829
|
-
},
|
|
2830
|
-
let t = e.path.startsWith(
|
|
2884
|
+
}, F = async (e) => {
|
|
2885
|
+
let t = e.path.startsWith(ye) ? e.path.slice(ye.length).split("/")[0] ?? "" : "";
|
|
2831
2886
|
if (!t) return {
|
|
2832
2887
|
status: 404,
|
|
2833
2888
|
body: "not found",
|
|
2834
2889
|
contentType: "text/plain"
|
|
2835
2890
|
};
|
|
2836
|
-
let n = await
|
|
2891
|
+
let n = await N(M.head(t));
|
|
2837
2892
|
if (!n) return {
|
|
2838
2893
|
status: 404,
|
|
2839
2894
|
body: "not found",
|
|
2840
2895
|
contentType: "text/plain"
|
|
2841
2896
|
};
|
|
2842
|
-
let r =
|
|
2897
|
+
let r = st(e.query), i = e.headers.range;
|
|
2843
2898
|
if (n.visibility === "public") {
|
|
2844
2899
|
let e = x.publicUrl?.(n.key) ?? null;
|
|
2845
2900
|
return e && !r ? {
|
|
@@ -2848,16 +2903,16 @@ var Mn = () => de({
|
|
|
2848
2903
|
location: e,
|
|
2849
2904
|
"cache-control": "public, max-age=300"
|
|
2850
2905
|
}
|
|
2851
|
-
} :
|
|
2906
|
+
} : Se(n, "public, max-age=31536000, immutable", r, i);
|
|
2852
2907
|
}
|
|
2853
2908
|
let a = !1, o = e.query ? new URLSearchParams(e.query).get("t") : null;
|
|
2854
2909
|
if (o) {
|
|
2855
|
-
let e =
|
|
2910
|
+
let e = At(o);
|
|
2856
2911
|
a = !!e && e.refId === t && e.audience === b;
|
|
2857
2912
|
}
|
|
2858
2913
|
if (!a) {
|
|
2859
|
-
let t =
|
|
2860
|
-
r && (a = await
|
|
2914
|
+
let t = se(e.headers.cookie, Yn), r = t ? le(t, ce()) : null;
|
|
2915
|
+
r && (a = await N(M.checkAccess(n, r)) === !0);
|
|
2861
2916
|
}
|
|
2862
2917
|
if (!a) return {
|
|
2863
2918
|
status: 403,
|
|
@@ -2865,7 +2920,7 @@ var Mn = () => de({
|
|
|
2865
2920
|
contentType: "text/plain"
|
|
2866
2921
|
};
|
|
2867
2922
|
if (x.presigns && !r) {
|
|
2868
|
-
let e = await
|
|
2923
|
+
let e = await N(x.getUrl(n.key, 300));
|
|
2869
2924
|
if (e && /^https?:/.test(e)) return {
|
|
2870
2925
|
status: 302,
|
|
2871
2926
|
headers: {
|
|
@@ -2874,12 +2929,12 @@ var Mn = () => de({
|
|
|
2874
2929
|
}
|
|
2875
2930
|
};
|
|
2876
2931
|
}
|
|
2877
|
-
return
|
|
2878
|
-
},
|
|
2932
|
+
return Se(n, "private, no-store", r, i);
|
|
2933
|
+
}, we = {
|
|
2879
2934
|
method: "GET",
|
|
2880
2935
|
path: b,
|
|
2881
2936
|
handle: async (e) => {
|
|
2882
|
-
let t = await
|
|
2937
|
+
let t = await F(e), n = rr(e.headers.origin, ue);
|
|
2883
2938
|
return Object.keys(n).length === 0 ? t : {
|
|
2884
2939
|
...t,
|
|
2885
2940
|
headers: {
|
|
@@ -2888,12 +2943,12 @@ var Mn = () => de({
|
|
|
2888
2943
|
}
|
|
2889
2944
|
};
|
|
2890
2945
|
}
|
|
2891
|
-
},
|
|
2946
|
+
}, Ee = {
|
|
2892
2947
|
method: "*",
|
|
2893
2948
|
path: `${b}/upload`,
|
|
2894
2949
|
originGuard: "exempt",
|
|
2895
2950
|
handle: async (e) => {
|
|
2896
|
-
let t =
|
|
2951
|
+
let t = rr(e.headers.origin, ue);
|
|
2897
2952
|
if (e.method === "OPTIONS") return {
|
|
2898
2953
|
status: 204,
|
|
2899
2954
|
headers: t
|
|
@@ -2904,7 +2959,7 @@ var Mn = () => de({
|
|
|
2904
2959
|
contentType: "text/plain",
|
|
2905
2960
|
headers: t
|
|
2906
2961
|
};
|
|
2907
|
-
let n = e.query ? new URLSearchParams(e.query).get("ticket") : null, r = n ?
|
|
2962
|
+
let n = e.query ? new URLSearchParams(e.query).get("ticket") : null, r = n ? Mt(n) : null;
|
|
2908
2963
|
if (!r || r.instance !== v) return {
|
|
2909
2964
|
status: 401,
|
|
2910
2965
|
body: "invalid or expired upload ticket",
|
|
@@ -2929,20 +2984,20 @@ var Mn = () => de({
|
|
|
2929
2984
|
contentType: "text/plain",
|
|
2930
2985
|
headers: t
|
|
2931
2986
|
};
|
|
2932
|
-
let i = await y.runPromise(
|
|
2987
|
+
let i = await y.runPromise(M.put({
|
|
2933
2988
|
bytes: e.rawBody,
|
|
2934
2989
|
contentType: r.ct,
|
|
2935
2990
|
tenantId: r.tenant,
|
|
2936
2991
|
ownerId: r.sub,
|
|
2937
2992
|
visibility: r.vis,
|
|
2938
|
-
...
|
|
2993
|
+
...me(r.vis),
|
|
2939
2994
|
...r.operationId === void 0 ? {} : { operationId: r.operationId },
|
|
2940
2995
|
...r.key === void 0 ? {} : { key: r.key },
|
|
2941
2996
|
...r.folder === void 0 ? {} : { folder: r.folder },
|
|
2942
2997
|
...r.tags === void 0 ? {} : { tags: r.tags },
|
|
2943
2998
|
...r.alt === void 0 ? {} : { alt: r.alt },
|
|
2944
2999
|
...r.caption === void 0 ? {} : { caption: r.caption }
|
|
2945
|
-
}).pipe(y.flatMap((e) =>
|
|
3000
|
+
}).pipe(y.flatMap((e) => M.getUrl(e.id).pipe(y.map((t) => ({
|
|
2946
3001
|
kind: "ok",
|
|
2947
3002
|
ref: e,
|
|
2948
3003
|
url: t
|
|
@@ -2988,17 +3043,17 @@ var Mn = () => de({
|
|
|
2988
3043
|
headers: t
|
|
2989
3044
|
};
|
|
2990
3045
|
}
|
|
2991
|
-
},
|
|
3046
|
+
}, I = {
|
|
2992
3047
|
method: "*",
|
|
2993
3048
|
path: `${b}/upload/resumable`,
|
|
2994
3049
|
originGuard: "exempt",
|
|
2995
3050
|
handle: async (e) => {
|
|
2996
|
-
let t =
|
|
3051
|
+
let t = rr(e.headers.origin, ue);
|
|
2997
3052
|
if (e.method === "OPTIONS") return {
|
|
2998
3053
|
status: 204,
|
|
2999
3054
|
headers: t
|
|
3000
3055
|
};
|
|
3001
|
-
let n = new URLSearchParams(e.query || ""), r =
|
|
3056
|
+
let n = new URLSearchParams(e.query || ""), r = It(n.get("token") ?? "");
|
|
3002
3057
|
if (!r || r.instance !== v) return {
|
|
3003
3058
|
status: 401,
|
|
3004
3059
|
body: "invalid or expired resumable token",
|
|
@@ -3006,7 +3061,7 @@ var Mn = () => de({
|
|
|
3006
3061
|
headers: t
|
|
3007
3062
|
};
|
|
3008
3063
|
if (e.method === "GET" || e.method === "HEAD") {
|
|
3009
|
-
let e = await y.runPromise(
|
|
3064
|
+
let e = await y.runPromise(M.resumableStatus({
|
|
3010
3065
|
uploadId: r.id,
|
|
3011
3066
|
tenantId: r.tenant
|
|
3012
3067
|
}).pipe(y.match({
|
|
@@ -3047,24 +3102,24 @@ var Mn = () => de({
|
|
|
3047
3102
|
contentType: "text/plain",
|
|
3048
3103
|
headers: t
|
|
3049
3104
|
};
|
|
3050
|
-
let a = n.get("final") === "1", o = await y.runPromise(
|
|
3105
|
+
let a = n.get("final") === "1", o = await y.runPromise(M.putResumableChunk({
|
|
3051
3106
|
uploadId: r.id,
|
|
3052
3107
|
tenantId: r.tenant,
|
|
3053
3108
|
index: i,
|
|
3054
3109
|
bytes: e.rawBody
|
|
3055
|
-
}).pipe(y.flatMap(() => a ?
|
|
3110
|
+
}).pipe(y.flatMap(() => a ? M.finalizeResumable({
|
|
3056
3111
|
uploadId: r.id,
|
|
3057
3112
|
count: i + 1,
|
|
3058
3113
|
contentType: r.ct,
|
|
3059
3114
|
tenantId: r.tenant,
|
|
3060
3115
|
ownerId: r.sub,
|
|
3061
3116
|
visibility: r.vis,
|
|
3062
|
-
...
|
|
3117
|
+
...me(r.vis),
|
|
3063
3118
|
...r.folder === void 0 ? {} : { folder: r.folder },
|
|
3064
3119
|
...r.tags === void 0 ? {} : { tags: r.tags },
|
|
3065
3120
|
...r.alt === void 0 ? {} : { alt: r.alt },
|
|
3066
3121
|
...r.caption === void 0 ? {} : { caption: r.caption }
|
|
3067
|
-
}).pipe(y.flatMap((e) =>
|
|
3122
|
+
}).pipe(y.flatMap((e) => M.getUrl(e.id).pipe(y.map((t) => ({
|
|
3068
3123
|
kind: "done",
|
|
3069
3124
|
ref: e,
|
|
3070
3125
|
url: t
|
|
@@ -3116,20 +3171,20 @@ var Mn = () => de({
|
|
|
3116
3171
|
headers: t
|
|
3117
3172
|
};
|
|
3118
3173
|
}
|
|
3119
|
-
},
|
|
3174
|
+
}, L = (e) => ({
|
|
3120
3175
|
kind: "json",
|
|
3121
3176
|
data: e
|
|
3122
|
-
}),
|
|
3177
|
+
}), R = (e, t) => ({
|
|
3123
3178
|
kind: "json",
|
|
3124
3179
|
status: e,
|
|
3125
3180
|
data: { error: t }
|
|
3126
|
-
}),
|
|
3181
|
+
}), De = (e, t) => {
|
|
3127
3182
|
try {
|
|
3128
3183
|
return new URL(e, "http://localhost").searchParams.get(t);
|
|
3129
3184
|
} catch {
|
|
3130
3185
|
return null;
|
|
3131
3186
|
}
|
|
3132
|
-
},
|
|
3187
|
+
}, Oe = [
|
|
3133
3188
|
{
|
|
3134
3189
|
method: "POST",
|
|
3135
3190
|
path: "/upload-ticket",
|
|
@@ -3149,11 +3204,11 @@ var Mn = () => de({
|
|
|
3149
3204
|
transient: !1,
|
|
3150
3205
|
status: 400
|
|
3151
3206
|
})));
|
|
3152
|
-
if (r.operationId !== void 0 &&
|
|
3153
|
-
if (
|
|
3154
|
-
let i =
|
|
3207
|
+
if (r.operationId !== void 0 && j.current === void 0) return R(409, "Durable uploads require a bound operation store with default reference and grant stores");
|
|
3208
|
+
if (E !== void 0 && r.size > E) return R(413, "File exceeds the configured upload limit");
|
|
3209
|
+
let i = jt({
|
|
3155
3210
|
instance: v,
|
|
3156
|
-
...r.operationId === void 0 ? {} : { operationId: `inspect-upload:${
|
|
3211
|
+
...r.operationId === void 0 ? {} : { operationId: `inspect-upload:${Ce("sha256").update(JSON.stringify([v, r.operationId])).digest("hex")}` },
|
|
3157
3212
|
replicaId: _().replicaId,
|
|
3158
3213
|
sub: r.ownerId,
|
|
3159
3214
|
tenant: r.tenantId,
|
|
@@ -3162,21 +3217,21 @@ var Mn = () => de({
|
|
|
3162
3217
|
vis: r.visibility ?? "private",
|
|
3163
3218
|
max: r.size
|
|
3164
3219
|
}, 300);
|
|
3165
|
-
return
|
|
3220
|
+
return L({
|
|
3166
3221
|
uploadPath: `${b}/upload?ticket=${encodeURIComponent(i)}`,
|
|
3167
3222
|
expiresInSec: 300,
|
|
3168
3223
|
maxBytes: r.size
|
|
3169
3224
|
});
|
|
3170
|
-
}).pipe(y.catchAll((e) => y.succeed(
|
|
3225
|
+
}).pipe(y.catchAll((e) => y.succeed(R(e.status ?? 500, e.message))))
|
|
3171
3226
|
},
|
|
3172
3227
|
{
|
|
3173
3228
|
method: "GET",
|
|
3174
3229
|
path: "/download",
|
|
3175
3230
|
description: "Stream a stored file as an attachment for authorized inspect readers",
|
|
3176
3231
|
handler: (e) => y.gen(function* () {
|
|
3177
|
-
let t =
|
|
3178
|
-
if (!t?.trim()) return
|
|
3179
|
-
let { ref: n, stream: r } = yield*
|
|
3232
|
+
let t = De(e.url, "refId");
|
|
3233
|
+
if (!t?.trim()) return R(400, "A non-empty refId is required");
|
|
3234
|
+
let { ref: n, stream: r } = yield* M.getStream(t), i = n.key.split("/").pop() || n.id, a = encodeURIComponent(i).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
3180
3235
|
return {
|
|
3181
3236
|
kind: "bytes",
|
|
3182
3237
|
contentType: n.contentType,
|
|
@@ -3187,7 +3242,7 @@ var Mn = () => de({
|
|
|
3187
3242
|
},
|
|
3188
3243
|
headers: { "cache-control": "no-store" }
|
|
3189
3244
|
};
|
|
3190
|
-
}).pipe(y.catchAll((e) => y.succeed(
|
|
3245
|
+
}).pipe(y.catchAll((e) => y.succeed(R(e.status ?? 500, e.message))))
|
|
3191
3246
|
},
|
|
3192
3247
|
{
|
|
3193
3248
|
method: "GET",
|
|
@@ -3195,8 +3250,8 @@ var Mn = () => de({
|
|
|
3195
3250
|
scope: "process",
|
|
3196
3251
|
description: "Searchable storage refs, newest first, paginated",
|
|
3197
3252
|
handler: (e) => {
|
|
3198
|
-
let t = Number(
|
|
3199
|
-
return
|
|
3253
|
+
let t = Number(De(e.url, "offset") ?? 0), n = Number.isSafeInteger(t) && t >= 0 ? t : 0, r = (De(e.url, "search") ?? "").trim().slice(0, 200);
|
|
3254
|
+
return he.listRefs({
|
|
3200
3255
|
tenantId: void 0,
|
|
3201
3256
|
ownerId: void 0,
|
|
3202
3257
|
folder: void 0,
|
|
@@ -3205,14 +3260,14 @@ var Mn = () => de({
|
|
|
3205
3260
|
search: r,
|
|
3206
3261
|
limit: 51,
|
|
3207
3262
|
offset: n
|
|
3208
|
-
}).pipe(y.map((e) =>
|
|
3209
|
-
refs: e.slice(0, 50).map(
|
|
3263
|
+
}).pipe(y.map((e) => L({
|
|
3264
|
+
refs: e.slice(0, 50).map(ir),
|
|
3210
3265
|
page: {
|
|
3211
3266
|
search: r,
|
|
3212
3267
|
offset: n,
|
|
3213
3268
|
nextOffset: e.length > 50 ? n + 50 : null
|
|
3214
3269
|
}
|
|
3215
|
-
})), y.catchAll((e) => y.succeed(
|
|
3270
|
+
})), y.catchAll((e) => y.succeed(R(500, e.message))));
|
|
3216
3271
|
}
|
|
3217
3272
|
},
|
|
3218
3273
|
{
|
|
@@ -3220,11 +3275,11 @@ var Mn = () => de({
|
|
|
3220
3275
|
path: "/stats",
|
|
3221
3276
|
scope: "process",
|
|
3222
3277
|
description: "Object count + total bytes per tenant + visibility split",
|
|
3223
|
-
handler: () =>
|
|
3278
|
+
handler: () => he.statistics().pipe(y.map((e) => L({
|
|
3224
3279
|
provider: x.name,
|
|
3225
3280
|
bucket: S,
|
|
3226
3281
|
...e
|
|
3227
|
-
})), y.catchAll((e) => y.succeed(
|
|
3282
|
+
})), y.catchAll((e) => y.succeed(R(500, e.message))))
|
|
3228
3283
|
},
|
|
3229
3284
|
{
|
|
3230
3285
|
method: "GET",
|
|
@@ -3232,8 +3287,8 @@ var Mn = () => de({
|
|
|
3232
3287
|
scope: "process",
|
|
3233
3288
|
description: "Grants for a ref (?refId=…)",
|
|
3234
3289
|
handler: (e) => {
|
|
3235
|
-
let t =
|
|
3236
|
-
return t ?
|
|
3290
|
+
let t = De(e.url, "refId");
|
|
3291
|
+
return t ? ge.listByRef(t).pipe(y.map((e) => L({ grants: e.map(ur) })), y.catchAll((e) => y.succeed(R(500, e.message)))) : y.succeed(R(400, "refId query param required"));
|
|
3237
3292
|
}
|
|
3238
3293
|
},
|
|
3239
3294
|
{
|
|
@@ -3253,16 +3308,16 @@ var Mn = () => de({
|
|
|
3253
3308
|
transient: !1,
|
|
3254
3309
|
status: 400
|
|
3255
3310
|
}))), r = n.expiresInDays === void 0 ? null : new Date(Date.now() + n.expiresInDays * 864e5);
|
|
3256
|
-
if (r !== null && !Number.isFinite(r.getTime())) return
|
|
3257
|
-
let i = yield*
|
|
3311
|
+
if (r !== null && !Number.isFinite(r.getTime())) return R(400, "Expiry exceeds the supported date range");
|
|
3312
|
+
let i = yield* M.grant({
|
|
3258
3313
|
refId: n.refId,
|
|
3259
3314
|
principalType: n.principalType,
|
|
3260
3315
|
principalId: n.principalId,
|
|
3261
3316
|
...n.permission ? { permission: n.permission } : {},
|
|
3262
3317
|
expiresAt: r
|
|
3263
3318
|
});
|
|
3264
|
-
return
|
|
3265
|
-
}).pipe(y.catchAll((e) => y.succeed(
|
|
3319
|
+
return L({ grant: ur(i) });
|
|
3320
|
+
}).pipe(y.catchAll((e) => y.succeed(R(e.status ?? 500, e.message ?? "share failed"))))
|
|
3266
3321
|
},
|
|
3267
3322
|
{
|
|
3268
3323
|
method: "POST",
|
|
@@ -3275,8 +3330,8 @@ var Mn = () => de({
|
|
|
3275
3330
|
transient: !1,
|
|
3276
3331
|
status: 400
|
|
3277
3332
|
})));
|
|
3278
|
-
return yield*
|
|
3279
|
-
}).pipe(y.catchAll((e) => y.succeed(
|
|
3333
|
+
return yield* M.delete(n.refId), L({ ok: !0 });
|
|
3334
|
+
}).pipe(y.catchAll((e) => y.succeed(R(e.status ?? 500, e.message))))
|
|
3280
3335
|
},
|
|
3281
3336
|
{
|
|
3282
3337
|
method: "POST",
|
|
@@ -3289,15 +3344,15 @@ var Mn = () => de({
|
|
|
3289
3344
|
transient: !1,
|
|
3290
3345
|
status: 400
|
|
3291
3346
|
})));
|
|
3292
|
-
return yield*
|
|
3293
|
-
}).pipe(y.catchAll((e) => y.succeed(
|
|
3347
|
+
return yield* M.revoke(n.grantId), L({ ok: !0 });
|
|
3348
|
+
}).pipe(y.catchAll((e) => y.succeed(R(e.status ?? 500, e.message ?? "revoke failed"))))
|
|
3294
3349
|
}
|
|
3295
|
-
],
|
|
3350
|
+
], ke = [
|
|
3296
3351
|
{
|
|
3297
3352
|
...te,
|
|
3298
3353
|
execute: (e, t) => {
|
|
3299
3354
|
let n = e;
|
|
3300
|
-
return
|
|
3355
|
+
return M.mintUrl(n.id, t.request.subject, {
|
|
3301
3356
|
...n.password === void 0 ? {} : { password: n.password },
|
|
3302
3357
|
...n.expiresInSec === void 0 ? {} : { expiresInSec: n.expiresInSec }
|
|
3303
3358
|
}).pipe(y.map((e) => ({ url: e })));
|
|
@@ -3307,7 +3362,7 @@ var Mn = () => de({
|
|
|
3307
3362
|
...ee,
|
|
3308
3363
|
execute: (e, t) => {
|
|
3309
3364
|
let n = e;
|
|
3310
|
-
return
|
|
3365
|
+
return M.mintUploadUrl({
|
|
3311
3366
|
key: n.key,
|
|
3312
3367
|
contentType: n.contentType,
|
|
3313
3368
|
tenantId: t.request.subject.tenantId,
|
|
@@ -3319,8 +3374,8 @@ var Mn = () => de({
|
|
|
3319
3374
|
...m,
|
|
3320
3375
|
execute: (e, t) => {
|
|
3321
3376
|
let n = e;
|
|
3322
|
-
return
|
|
3323
|
-
let t = n.expiresInSec ?? 900, r =
|
|
3377
|
+
return cr(t, D).pipe(y.map((e) => {
|
|
3378
|
+
let t = n.expiresInSec ?? 900, r = jt({
|
|
3324
3379
|
instance: v,
|
|
3325
3380
|
sub: e.id,
|
|
3326
3381
|
tenant: e.tenantId,
|
|
@@ -3331,10 +3386,10 @@ var Mn = () => de({
|
|
|
3331
3386
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
3332
3387
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3333
3388
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3334
|
-
...
|
|
3389
|
+
...E === void 0 ? {} : { max: E }
|
|
3335
3390
|
}, t);
|
|
3336
3391
|
return {
|
|
3337
|
-
uploadUrl: `${
|
|
3392
|
+
uploadUrl: `${T ? T.replace(/\/+$/, "") : ""}${b}/upload?ticket=${encodeURIComponent(r)}`,
|
|
3338
3393
|
expiresInSec: t
|
|
3339
3394
|
};
|
|
3340
3395
|
}));
|
|
@@ -3344,12 +3399,12 @@ var Mn = () => de({
|
|
|
3344
3399
|
...p,
|
|
3345
3400
|
execute: (e, t) => {
|
|
3346
3401
|
let n = e;
|
|
3347
|
-
return
|
|
3402
|
+
return cr(t, D).pipe(y.flatMap((e) => M.mintPresignedUpload({
|
|
3348
3403
|
contentType: n.contentType,
|
|
3349
3404
|
tenantId: e.tenantId,
|
|
3350
3405
|
...n.expiresInSec === void 0 ? {} : { expiresInSec: n.expiresInSec }
|
|
3351
3406
|
}).pipe(y.map((t) => {
|
|
3352
|
-
let r =
|
|
3407
|
+
let r = Nt({
|
|
3353
3408
|
instance: v,
|
|
3354
3409
|
key: t.key,
|
|
3355
3410
|
sub: e.id,
|
|
@@ -3360,7 +3415,7 @@ var Mn = () => de({
|
|
|
3360
3415
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
3361
3416
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3362
3417
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3363
|
-
...
|
|
3418
|
+
...E === void 0 ? {} : { max: E }
|
|
3364
3419
|
}, t.expiresInSec);
|
|
3365
3420
|
return {
|
|
3366
3421
|
uploadUrl: t.uploadUrl,
|
|
@@ -3373,29 +3428,29 @@ var Mn = () => de({
|
|
|
3373
3428
|
{
|
|
3374
3429
|
...l,
|
|
3375
3430
|
execute: (e, n) => {
|
|
3376
|
-
let r =
|
|
3431
|
+
let r = Pt(e.finalizeToken);
|
|
3377
3432
|
return !r || r.instance !== v ? y.fail(new t({
|
|
3378
3433
|
provider: "storage",
|
|
3379
3434
|
message: "invalid or expired finalize token",
|
|
3380
3435
|
transient: !1,
|
|
3381
3436
|
status: 401
|
|
3382
|
-
})) :
|
|
3437
|
+
})) : lr(r.sub, n.request.subject.id) ? y.fail(new t({
|
|
3383
3438
|
provider: "storage",
|
|
3384
3439
|
message: "finalize token belongs to another subject",
|
|
3385
3440
|
transient: !1,
|
|
3386
3441
|
status: 403
|
|
3387
|
-
})) :
|
|
3442
|
+
})) : M.finalizeUpload({
|
|
3388
3443
|
key: r.key,
|
|
3389
3444
|
contentType: r.ct,
|
|
3390
3445
|
tenantId: r.tenant,
|
|
3391
3446
|
ownerId: r.sub,
|
|
3392
3447
|
visibility: r.vis,
|
|
3393
|
-
...
|
|
3448
|
+
...me(r.vis),
|
|
3394
3449
|
...r.folder === void 0 ? {} : { folder: r.folder },
|
|
3395
3450
|
...r.tags === void 0 ? {} : { tags: r.tags },
|
|
3396
3451
|
...r.alt === void 0 ? {} : { alt: r.alt },
|
|
3397
3452
|
...r.caption === void 0 ? {} : { caption: r.caption }
|
|
3398
|
-
}).pipe(y.flatMap((e) =>
|
|
3453
|
+
}).pipe(y.flatMap((e) => M.getUrl(e.id).pipe(y.map((t) => ({
|
|
3399
3454
|
id: e.id,
|
|
3400
3455
|
url: t,
|
|
3401
3456
|
contentType: e.contentType,
|
|
@@ -3409,11 +3464,11 @@ var Mn = () => de({
|
|
|
3409
3464
|
...s,
|
|
3410
3465
|
execute: (e, t) => {
|
|
3411
3466
|
let n = e;
|
|
3412
|
-
return
|
|
3413
|
-
let t = n.expiresInSec ??
|
|
3467
|
+
return cr(t, D).pipe(y.map((e) => {
|
|
3468
|
+
let t = n.expiresInSec ?? fe, r = Te(), i = n.chunkSize && n.chunkSize > 0 ? n.chunkSize : de;
|
|
3414
3469
|
return {
|
|
3415
3470
|
uploadId: r,
|
|
3416
|
-
resumableToken:
|
|
3471
|
+
resumableToken: Ft({
|
|
3417
3472
|
instance: v,
|
|
3418
3473
|
id: r,
|
|
3419
3474
|
sub: e.id,
|
|
@@ -3425,9 +3480,9 @@ var Mn = () => de({
|
|
|
3425
3480
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
3426
3481
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3427
3482
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3428
|
-
...
|
|
3483
|
+
...E === void 0 ? {} : { max: E }
|
|
3429
3484
|
}, t),
|
|
3430
|
-
uploadUrl: `${
|
|
3485
|
+
uploadUrl: `${T ? T.replace(/\/+$/, "") : ""}${b}/upload/resumable`,
|
|
3431
3486
|
chunkSize: i,
|
|
3432
3487
|
expiresInSec: t
|
|
3433
3488
|
};
|
|
@@ -3437,14 +3492,14 @@ var Mn = () => de({
|
|
|
3437
3492
|
{
|
|
3438
3493
|
...o,
|
|
3439
3494
|
execute: (e, t) => {
|
|
3440
|
-
let n = e, r = n.expiresInSec ??
|
|
3441
|
-
return
|
|
3495
|
+
let n = e, r = n.expiresInSec ?? fe;
|
|
3496
|
+
return cr(t, D).pipe(y.flatMap((e) => M.beginMultipartUpload({
|
|
3442
3497
|
contentType: n.contentType,
|
|
3443
3498
|
tenantId: e.tenantId,
|
|
3444
3499
|
visibility: n.visibility ?? "private",
|
|
3445
3500
|
expiresInSec: r
|
|
3446
3501
|
}).pipe(y.map((t) => ({
|
|
3447
|
-
multipartToken:
|
|
3502
|
+
multipartToken: Lt({
|
|
3448
3503
|
instance: v,
|
|
3449
3504
|
key: t.key,
|
|
3450
3505
|
uploadId: t.uploadId,
|
|
@@ -3458,7 +3513,7 @@ var Mn = () => de({
|
|
|
3458
3513
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3459
3514
|
...n.caption === void 0 ? {} : { caption: n.caption }
|
|
3460
3515
|
}, r),
|
|
3461
|
-
partSize: n.partSize && n.partSize >=
|
|
3516
|
+
partSize: n.partSize && n.partSize >= de ? n.partSize : de,
|
|
3462
3517
|
expiresInSec: r
|
|
3463
3518
|
})))));
|
|
3464
3519
|
}
|
|
@@ -3466,7 +3521,7 @@ var Mn = () => de({
|
|
|
3466
3521
|
{
|
|
3467
3522
|
...g,
|
|
3468
3523
|
execute: (e) => {
|
|
3469
|
-
let n = e, r =
|
|
3524
|
+
let n = e, r = Rt(n.multipartToken);
|
|
3470
3525
|
return !r || r.instance !== v ? y.fail(new t({
|
|
3471
3526
|
provider: "storage",
|
|
3472
3527
|
message: "invalid or expired multipart token",
|
|
@@ -3477,7 +3532,7 @@ var Mn = () => de({
|
|
|
3477
3532
|
message: "partNumber must be a positive integer",
|
|
3478
3533
|
transient: !1,
|
|
3479
3534
|
status: 400
|
|
3480
|
-
})) :
|
|
3535
|
+
})) : M.signMultipartPart({
|
|
3481
3536
|
key: r.key,
|
|
3482
3537
|
uploadId: r.uploadId,
|
|
3483
3538
|
partNumber: n.partNumber
|
|
@@ -3487,18 +3542,18 @@ var Mn = () => de({
|
|
|
3487
3542
|
{
|
|
3488
3543
|
...c,
|
|
3489
3544
|
execute: (e, n) => {
|
|
3490
|
-
let r = e, i =
|
|
3545
|
+
let r = e, i = Rt(r.multipartToken);
|
|
3491
3546
|
return !i || i.instance !== v ? y.fail(new t({
|
|
3492
3547
|
provider: "storage",
|
|
3493
3548
|
message: "invalid or expired multipart token",
|
|
3494
3549
|
transient: !1,
|
|
3495
3550
|
status: 401
|
|
3496
|
-
})) :
|
|
3551
|
+
})) : lr(i.sub, n.request.subject.id) ? y.fail(new t({
|
|
3497
3552
|
provider: "storage",
|
|
3498
3553
|
message: "multipart token belongs to another subject",
|
|
3499
3554
|
transient: !1,
|
|
3500
3555
|
status: 403
|
|
3501
|
-
})) :
|
|
3556
|
+
})) : M.completeMultipart({
|
|
3502
3557
|
key: i.key,
|
|
3503
3558
|
uploadId: i.uploadId,
|
|
3504
3559
|
parts: r.parts,
|
|
@@ -3506,12 +3561,12 @@ var Mn = () => de({
|
|
|
3506
3561
|
tenantId: i.tenant,
|
|
3507
3562
|
ownerId: i.sub,
|
|
3508
3563
|
visibility: i.vis,
|
|
3509
|
-
...
|
|
3564
|
+
...me(i.vis),
|
|
3510
3565
|
...i.folder === void 0 ? {} : { folder: i.folder },
|
|
3511
3566
|
...i.tags === void 0 ? {} : { tags: i.tags },
|
|
3512
3567
|
...i.alt === void 0 ? {} : { alt: i.alt },
|
|
3513
3568
|
...i.caption === void 0 ? {} : { caption: i.caption }
|
|
3514
|
-
}).pipe(y.flatMap((e) =>
|
|
3569
|
+
}).pipe(y.flatMap((e) => M.getUrl(e.id).pipe(y.map((t) => ({
|
|
3515
3570
|
id: e.id,
|
|
3516
3571
|
url: t,
|
|
3517
3572
|
size: e.size
|
|
@@ -3521,13 +3576,13 @@ var Mn = () => de({
|
|
|
3521
3576
|
{
|
|
3522
3577
|
...a,
|
|
3523
3578
|
execute: (e) => {
|
|
3524
|
-
let n =
|
|
3579
|
+
let n = Rt(e.multipartToken);
|
|
3525
3580
|
return !n || n.instance !== v ? y.fail(new t({
|
|
3526
3581
|
provider: "storage",
|
|
3527
3582
|
message: "invalid or expired multipart token",
|
|
3528
3583
|
transient: !1,
|
|
3529
3584
|
status: 401
|
|
3530
|
-
})) :
|
|
3585
|
+
})) : M.abortMultipart({
|
|
3531
3586
|
key: n.key,
|
|
3532
3587
|
uploadId: n.uploadId
|
|
3533
3588
|
}).pipe(y.as({ ok: !0 }));
|
|
@@ -3537,7 +3592,7 @@ var Mn = () => de({
|
|
|
3537
3592
|
...ie,
|
|
3538
3593
|
execute: (e, t) => {
|
|
3539
3594
|
let n = e, r = new Uint8Array(Buffer.from(n.bytesBase64, "base64"));
|
|
3540
|
-
return
|
|
3595
|
+
return cr(t, D).pipe(y.flatMap((e) => M.put({
|
|
3541
3596
|
bytes: r,
|
|
3542
3597
|
contentType: n.contentType,
|
|
3543
3598
|
tenantId: e.tenantId,
|
|
@@ -3545,7 +3600,7 @@ var Mn = () => de({
|
|
|
3545
3600
|
...n.visibility ? { visibility: n.visibility } : {},
|
|
3546
3601
|
...n.key ? { key: n.key } : {},
|
|
3547
3602
|
...n.password ? { password: n.password } : {}
|
|
3548
|
-
})), y.flatMap((e) =>
|
|
3603
|
+
})), y.flatMap((e) => M.getUrl(e.id).pipe(y.map((t) => ({
|
|
3549
3604
|
id: e.id,
|
|
3550
3605
|
url: t
|
|
3551
3606
|
})))));
|
|
@@ -3555,7 +3610,7 @@ var Mn = () => de({
|
|
|
3555
3610
|
...u,
|
|
3556
3611
|
execute: (e, t) => {
|
|
3557
3612
|
let n = e;
|
|
3558
|
-
return
|
|
3613
|
+
return cr(t, D).pipe(y.flatMap((e) => M.ingestUrl(n.url, {
|
|
3559
3614
|
tenantId: e.tenantId,
|
|
3560
3615
|
ownerId: e.id,
|
|
3561
3616
|
...n.visibility ? { visibility: n.visibility } : {},
|
|
@@ -3564,7 +3619,7 @@ var Mn = () => de({
|
|
|
3564
3619
|
...n.alt === void 0 ? {} : { alt: n.alt },
|
|
3565
3620
|
...n.caption === void 0 ? {} : { caption: n.caption },
|
|
3566
3621
|
...n.key === void 0 ? {} : { key: n.key }
|
|
3567
|
-
})), y.flatMap((e) =>
|
|
3622
|
+
})), y.flatMap((e) => M.getUrl(e.id).pipe(y.map((t) => ({
|
|
3568
3623
|
id: e.id,
|
|
3569
3624
|
url: t
|
|
3570
3625
|
})))));
|
|
@@ -3574,7 +3629,7 @@ var Mn = () => de({
|
|
|
3574
3629
|
...ne,
|
|
3575
3630
|
execute: (e, t) => {
|
|
3576
3631
|
let n = e, r = n.expiresInDays ? new Date(Date.now() + n.expiresInDays * 864e5) : null;
|
|
3577
|
-
return
|
|
3632
|
+
return or(M, n.refId, t).pipe(y.flatMap(() => M.grant({
|
|
3578
3633
|
refId: n.refId,
|
|
3579
3634
|
principalType: n.principalType,
|
|
3580
3635
|
principalId: n.principalId,
|
|
@@ -3588,21 +3643,21 @@ var Mn = () => de({
|
|
|
3588
3643
|
...h,
|
|
3589
3644
|
execute: (e, t) => {
|
|
3590
3645
|
let n = e;
|
|
3591
|
-
return
|
|
3646
|
+
return M.getGrant(n.grantId).pipe(y.flatMap((e) => e === null ? y.fail(ar()) : or(M, e.refId, t)), y.flatMap(() => M.revoke(n.grantId)), y.map(() => ({ ok: !0 })));
|
|
3592
3647
|
}
|
|
3593
3648
|
},
|
|
3594
3649
|
{
|
|
3595
3650
|
...d,
|
|
3596
3651
|
execute: (e, t) => {
|
|
3597
3652
|
let n = e;
|
|
3598
|
-
return
|
|
3653
|
+
return or(M, n.refId, t).pipe(y.flatMap(() => M.listGrants(n.refId)), y.map((e) => ({ grants: e.map(ur) })));
|
|
3599
3654
|
}
|
|
3600
3655
|
},
|
|
3601
3656
|
{
|
|
3602
3657
|
...f,
|
|
3603
3658
|
execute: (e, t) => {
|
|
3604
3659
|
let n = e;
|
|
3605
|
-
return
|
|
3660
|
+
return M.listRefs({
|
|
3606
3661
|
tenantId: t.request.subject.tenantId,
|
|
3607
3662
|
...n.folder === void 0 ? {} : { folder: n.folder },
|
|
3608
3663
|
...n.tags === void 0 ? {} : { tags: n.tags },
|
|
@@ -3611,35 +3666,35 @@ var Mn = () => de({
|
|
|
3611
3666
|
...n.limit === void 0 ? {} : { limit: n.limit },
|
|
3612
3667
|
...n.offset === void 0 ? {} : { offset: n.offset }
|
|
3613
3668
|
}).pipe(y.map((e) => ({
|
|
3614
|
-
refs: e.refs.map(
|
|
3669
|
+
refs: e.refs.map(ir),
|
|
3615
3670
|
nextOffset: e.nextOffset
|
|
3616
3671
|
})));
|
|
3617
3672
|
}
|
|
3618
3673
|
}
|
|
3619
3674
|
];
|
|
3620
|
-
return
|
|
3621
|
-
name:
|
|
3622
|
-
base:
|
|
3675
|
+
return ae({
|
|
3676
|
+
name: oe({
|
|
3677
|
+
base: dr,
|
|
3623
3678
|
alias: i.alias,
|
|
3624
3679
|
instance: i.name
|
|
3625
3680
|
}),
|
|
3626
|
-
baseName:
|
|
3681
|
+
baseName: dr,
|
|
3627
3682
|
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.",
|
|
3628
3683
|
permissions: [
|
|
3629
3684
|
"network:outbound:*",
|
|
3630
3685
|
"inspect:read",
|
|
3631
3686
|
"inspect:write"
|
|
3632
3687
|
],
|
|
3633
|
-
declaredEnv:
|
|
3634
|
-
egress:
|
|
3635
|
-
services:
|
|
3636
|
-
inspectEndpoints:
|
|
3688
|
+
declaredEnv: H.declared,
|
|
3689
|
+
egress: tr(i),
|
|
3690
|
+
services: ve,
|
|
3691
|
+
inspectEndpoints: Oe,
|
|
3637
3692
|
httpRoutes: [
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3693
|
+
we,
|
|
3694
|
+
Ee,
|
|
3695
|
+
I
|
|
3641
3696
|
],
|
|
3642
|
-
routes:
|
|
3697
|
+
routes: ke,
|
|
3643
3698
|
rpcClientDescriptors: re,
|
|
3644
3699
|
errorSchemas: [
|
|
3645
3700
|
{
|
|
@@ -3673,7 +3728,7 @@ var Mn = () => de({
|
|
|
3673
3728
|
],
|
|
3674
3729
|
capabilities: { mediaPersist: {
|
|
3675
3730
|
put: async ({ bytes: e, mediaType: t, tenantId: n, operationId: r, ownerId: i, visibility: a, tags: o }) => {
|
|
3676
|
-
let s = await y.runPromise(
|
|
3731
|
+
let s = await y.runPromise(M.put({
|
|
3677
3732
|
bytes: e,
|
|
3678
3733
|
contentType: t,
|
|
3679
3734
|
tenantId: n,
|
|
@@ -3681,40 +3736,40 @@ var Mn = () => de({
|
|
|
3681
3736
|
...i === void 0 ? {} : { ownerId: i },
|
|
3682
3737
|
...a === void 0 ? {} : { visibility: a },
|
|
3683
3738
|
...o === void 0 ? {} : { tags: o },
|
|
3684
|
-
...
|
|
3739
|
+
...j.current === void 0 ? {} : { operationId: r }
|
|
3685
3740
|
}));
|
|
3686
3741
|
return {
|
|
3687
|
-
url: await y.runPromise(
|
|
3742
|
+
url: await y.runPromise(M.getUrl(s.id, { tenantId: n })),
|
|
3688
3743
|
refId: s.id
|
|
3689
3744
|
};
|
|
3690
3745
|
},
|
|
3691
3746
|
ingestUrl: async ({ url: e, tenantId: t, operationId: n, ownerId: r, visibility: i, tags: a }) => {
|
|
3692
|
-
let o = await y.runPromise(
|
|
3747
|
+
let o = await y.runPromise(M.ingestUrl(e, {
|
|
3693
3748
|
tenantId: t,
|
|
3694
3749
|
...r === void 0 ? {} : { ownerId: r },
|
|
3695
3750
|
...i === void 0 ? {} : { visibility: i },
|
|
3696
3751
|
...a === void 0 ? {} : { tags: a },
|
|
3697
|
-
...
|
|
3752
|
+
...j.current === void 0 ? {} : { operationId: n }
|
|
3698
3753
|
}));
|
|
3699
3754
|
return {
|
|
3700
|
-
url: await y.runPromise(
|
|
3755
|
+
url: await y.runPromise(M.getUrl(o.id, { tenantId: t })),
|
|
3701
3756
|
refId: o.id
|
|
3702
3757
|
};
|
|
3703
3758
|
}
|
|
3704
3759
|
} },
|
|
3705
3760
|
bindDataStore: (e) => {
|
|
3706
|
-
|
|
3761
|
+
pe && (k.current = an(e)), O && (A.current = cn(e)), pe && O && (j.current = Fn(e)), x.bindDataStore?.(e);
|
|
3707
3762
|
},
|
|
3708
3763
|
onActivate: (e) => y.sync(() => {
|
|
3709
|
-
let t = !!
|
|
3764
|
+
let t = !!T || !!H.read("STORAGE_CDN_URL", i.cdnBaseUrl);
|
|
3710
3765
|
e.logger.info(`storage: provider=${x.name} presign=${x.presigns ? "yes" : "no"} publicUrl=${t ? "yes" : "no"} transforms=yes`, {
|
|
3711
3766
|
provider: x.name,
|
|
3712
3767
|
bucket: S,
|
|
3713
|
-
refStore:
|
|
3768
|
+
refStore: pe ? "memory" : "custom"
|
|
3714
3769
|
}), 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.");
|
|
3715
3770
|
}),
|
|
3716
3771
|
onDeactivate: () => y.void
|
|
3717
3772
|
});
|
|
3718
3773
|
};
|
|
3719
3774
|
//#endregion
|
|
3720
|
-
export {
|
|
3775
|
+
export { V as STORAGE_BLOBS_TABLE, B as STORAGE_GRANTS_TABLE, z as STORAGE_REFS_TABLE, Ue as STORAGE_USAGE_TABLE, e as StorageAccessDenied, t as StorageError, n as StorageRejected, r as StorageScanRejected, i as StorageService, qe as _voltroStorageBlobsTable, Ge as _voltroStorageGrantsTable, We as _voltroStorageRefsTable, Ke as _voltroStorageUsageTable, Qn as appStorageProvider, Hn as assetRef, it as azureProvider, dn as buildStorageService, Le as bytesToStream, Ht as checkLimits, zn as clamavScanner, Qe as clearStorageBuffer, Re as collectStream, Ie as concatBytes, $n as configuredStorageProvider, zt as contentTypeAllowed, cn as dataStoreGrantStore, an as dataStoreRefStore, rt as databaseProvider, Gn as decodeDataUri, Jn as durabilityNotice, In as encodeInstream, Vn as ffmpegTranscoder, et as filesystemProvider, ze as fromNodeReadable, Ve as getObjectStream, gt as hashPassword, Fn as makeStorageObjectMetadata, on as memoryGrantStore, $e as memoryProvider, tn as memoryRefStore, Ln as parseClamavResponse, st as parseTransformParams, qn as pathDurability, Kn as putAvatar, He as putObjectStream, Ze as readStorageBuffer, $t as refMatchesListQuery, er as resolveStorageProvider, q as resolveStorageSecret, tt as s3Provider, Zn as setActiveStorageProvider, Nt as signFinalizeTicket, kt as signGrant, Lt as signMultipartTicket, Ft as signResumableTicket, jt as signUploadTicket, Vt as sniffMatches, tr as storageEgressOf, fr as storageInstanceName, gn as storageObjectLifecycleTables, pr as storagePlugin, Mn as storagePutIntentsTable, fn as storageServiceLayer, Be as toNodeReadable, ht as transformCached, dt as transformFallbackReason, ft as transformImage, Pt as verifyFinalizeTicket, At as verifyGrant, Rt as verifyMultipartTicket, _t as verifyPassword, It as verifyResumableTicket, Mt as verifyUploadTicket, Un as withStorage };
|