@xylex-group/athena 2.6.0 → 2.7.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/README.md +1 -1
- package/dist/browser.cjs +837 -114
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +7 -7
- package/dist/browser.d.ts +7 -7
- package/dist/browser.js +837 -114
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +830 -107
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -3
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +830 -107
- package/dist/cli/index.js.map +1 -1
- package/dist/cookies.cjs +10 -3
- package/dist/cookies.cjs.map +1 -1
- package/dist/cookies.js +10 -3
- package/dist/cookies.js.map +1 -1
- package/dist/index.cjs +837 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +837 -114
- package/dist/index.js.map +1 -1
- package/dist/model-form-AKYrgede.d.ts +2772 -0
- package/dist/model-form-ehfqLuG7.d.cts +2772 -0
- package/dist/{pipeline-Ce3pTw5h.d.ts → pipeline-BUsR9XlO.d.ts} +1 -1
- package/dist/{pipeline-D1ZYeoH7.d.cts → pipeline-BfCWSRYl.d.cts} +1 -1
- package/dist/react-email-BQzmXBDE.d.cts +304 -0
- package/dist/react-email-BrVRp80B.d.ts +304 -0
- package/dist/react.cjs +178 -71
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +22 -5
- package/dist/react.d.ts +22 -5
- package/dist/react.js +92 -5
- package/dist/react.js.map +1 -1
- package/dist/{types-CUuo4NDi.d.cts → types-BSIsyss1.d.cts} +1 -1
- package/dist/{types-DSX6AT5B.d.cts → types-BsyRW49r.d.cts} +1 -1
- package/dist/{types-DSX6AT5B.d.ts → types-BsyRW49r.d.ts} +1 -1
- package/dist/{types-DapchQY5.d.ts → types-t_TVqnmp.d.ts} +1 -1
- package/package.json +193 -193
- package/dist/model-form-BaHWi3gm.d.cts +0 -1383
- package/dist/model-form-Dh6gWjL0.d.ts +0 -1383
- package/dist/react-email-B8O1Jeff.d.cts +0 -1230
- package/dist/react-email-CDEF0jij.d.ts +0 -1230
package/dist/browser.cjs
CHANGED
|
@@ -668,9 +668,16 @@ var getSessionCookie = (request, config) => {
|
|
|
668
668
|
const { cookieName = "session_token", cookiePrefix = "athena-auth" } = config || {};
|
|
669
669
|
const parsedCookie = parseCookies(cookies);
|
|
670
670
|
const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
-
|
|
671
|
+
const candidateCookieNames = Array.from(/* @__PURE__ */ new Set([
|
|
672
|
+
cookieName,
|
|
673
|
+
cookieName.replace(/_/g, "-"),
|
|
674
|
+
cookieName.replace(/-/g, "_")
|
|
675
|
+
])).filter(Boolean);
|
|
676
|
+
for (const candidateName of candidateCookieNames) {
|
|
677
|
+
const sessionToken = getCookie(`${cookiePrefix}.${candidateName}`) || getCookie(`${cookiePrefix}-${candidateName}`);
|
|
678
|
+
if (sessionToken) {
|
|
679
|
+
return sessionToken;
|
|
680
|
+
}
|
|
674
681
|
}
|
|
675
682
|
return null;
|
|
676
683
|
};
|
|
@@ -793,7 +800,7 @@ var getCookieCache = async (request, config) => {
|
|
|
793
800
|
|
|
794
801
|
// package.json
|
|
795
802
|
var package_default = {
|
|
796
|
-
version: "2.
|
|
803
|
+
version: "2.7.0"
|
|
797
804
|
};
|
|
798
805
|
|
|
799
806
|
// src/sdk-version.ts
|
|
@@ -3368,6 +3375,344 @@ function createDbModule(input) {
|
|
|
3368
3375
|
return db;
|
|
3369
3376
|
}
|
|
3370
3377
|
|
|
3378
|
+
// src/storage/file.ts
|
|
3379
|
+
function createStorageFileModule(base, config = {}) {
|
|
3380
|
+
const upload = async (input, options) => {
|
|
3381
|
+
const sources = normalizeUploadSources(input);
|
|
3382
|
+
validateUploadConstraints(sources, input);
|
|
3383
|
+
const uploadRequests = sources.map((source, index) => {
|
|
3384
|
+
const storageKey = resolveUploadStorageKey(input, source, index, options, config);
|
|
3385
|
+
return {
|
|
3386
|
+
source,
|
|
3387
|
+
uploadRequest: {
|
|
3388
|
+
s3_id: input.s3_id,
|
|
3389
|
+
bucket: input.bucket,
|
|
3390
|
+
storage_key: storageKey,
|
|
3391
|
+
name: input.name ?? source.fileName,
|
|
3392
|
+
original_name: input.original_name ?? source.fileName,
|
|
3393
|
+
resource_id: input.resource_id ?? input.resourceId,
|
|
3394
|
+
mime_type: input.mime_type ?? source.contentType,
|
|
3395
|
+
content_type: input.content_type ?? source.contentType,
|
|
3396
|
+
size_bytes: source.sizeBytes,
|
|
3397
|
+
public: input.public,
|
|
3398
|
+
metadata: input.metadata
|
|
3399
|
+
}
|
|
3400
|
+
};
|
|
3401
|
+
});
|
|
3402
|
+
input.onProgress?.(createProgressSnapshot("preparing", sources, 0, 0, 0));
|
|
3403
|
+
const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((request) => request.uploadRequest) }, options)).files;
|
|
3404
|
+
const aggregateLoaded = new Array(uploadRequests.length).fill(0);
|
|
3405
|
+
const uploaded = [];
|
|
3406
|
+
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
3407
|
+
const request = uploadRequests[index];
|
|
3408
|
+
const uploadUrl = uploadUrls[index];
|
|
3409
|
+
const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
|
|
3410
|
+
aggregateLoaded[index] = progress.loaded;
|
|
3411
|
+
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
3412
|
+
});
|
|
3413
|
+
uploaded.push({
|
|
3414
|
+
file: uploadUrl.file,
|
|
3415
|
+
upload: uploadUrl.upload,
|
|
3416
|
+
source: request.source.source,
|
|
3417
|
+
fileName: request.source.fileName,
|
|
3418
|
+
storage_key: request.uploadRequest.storage_key,
|
|
3419
|
+
response
|
|
3420
|
+
});
|
|
3421
|
+
aggregateLoaded[index] = request.source.sizeBytes;
|
|
3422
|
+
input.onProgress?.(createProgressSnapshot("complete", sources, index, request.source.sizeBytes, sum(aggregateLoaded)));
|
|
3423
|
+
}
|
|
3424
|
+
return {
|
|
3425
|
+
files: uploaded,
|
|
3426
|
+
count: uploaded.length
|
|
3427
|
+
};
|
|
3428
|
+
};
|
|
3429
|
+
const download = ((input, queryOrOptions, maybeOptions) => {
|
|
3430
|
+
const { fileIds, query, options } = normalizeDownloadArgs(input, queryOrOptions, maybeOptions);
|
|
3431
|
+
const downloads = fileIds.map((fileId) => base.getStorageFileProxy(fileId, query, options));
|
|
3432
|
+
return Array.isArray(input) || isRecord5(input) && Array.isArray(input.fileIds) ? Promise.all(downloads) : downloads[0];
|
|
3433
|
+
});
|
|
3434
|
+
const deleteFile = ((input, options) => {
|
|
3435
|
+
if (Array.isArray(input)) {
|
|
3436
|
+
return Promise.all(input.map((fileId) => base.deleteStorageFile(fileId, options)));
|
|
3437
|
+
}
|
|
3438
|
+
return base.deleteStorageFile(input, options);
|
|
3439
|
+
});
|
|
3440
|
+
return {
|
|
3441
|
+
upload,
|
|
3442
|
+
download,
|
|
3443
|
+
list(input, options) {
|
|
3444
|
+
const prefix = resolveStoragePath(input.prefix ?? "", input, options, config);
|
|
3445
|
+
return base.listStorageFiles(
|
|
3446
|
+
{
|
|
3447
|
+
s3_id: input.s3_id,
|
|
3448
|
+
prefix
|
|
3449
|
+
},
|
|
3450
|
+
options
|
|
3451
|
+
);
|
|
3452
|
+
},
|
|
3453
|
+
delete: deleteFile
|
|
3454
|
+
};
|
|
3455
|
+
}
|
|
3456
|
+
function resolveStoragePath(path, input, options, config = {}) {
|
|
3457
|
+
const context = createPathContext(input, options, config);
|
|
3458
|
+
const prefixPath = input.prefixPath ?? config.prefixPath;
|
|
3459
|
+
const prefix = typeof prefixPath === "function" ? prefixPath(context) : prefixPath;
|
|
3460
|
+
return joinStoragePath(renderStorageTemplate(prefix ?? "", context), renderStorageTemplate(path, context));
|
|
3461
|
+
}
|
|
3462
|
+
function resolveUploadStorageKey(input, source, index, options, config) {
|
|
3463
|
+
const explicitKey = input.storage_key ?? input.storageKey;
|
|
3464
|
+
const keyTemplate = input.storageKeyTemplate;
|
|
3465
|
+
const fallbackName = source.fileName;
|
|
3466
|
+
const context = createPathContext(input, options, config);
|
|
3467
|
+
const key = keyTemplate ? renderStorageTemplate(keyTemplate, {
|
|
3468
|
+
...context,
|
|
3469
|
+
vars: {
|
|
3470
|
+
...context.vars,
|
|
3471
|
+
index,
|
|
3472
|
+
fileName: source.fileName,
|
|
3473
|
+
name: source.fileName
|
|
3474
|
+
}
|
|
3475
|
+
}) : explicitKey ?? fallbackName;
|
|
3476
|
+
return resolveStoragePath(key, input, options, config);
|
|
3477
|
+
}
|
|
3478
|
+
function normalizeUploadSources(input) {
|
|
3479
|
+
const files = toArray(input.files);
|
|
3480
|
+
if (files.length === 0) {
|
|
3481
|
+
throw new Error("athena.storage.file.upload requires at least one file");
|
|
3482
|
+
}
|
|
3483
|
+
return files.map((source, index) => {
|
|
3484
|
+
const fileName = input.fileName ?? sourceName(source) ?? `file-${index + 1}`;
|
|
3485
|
+
const sizeBytes = sourceSize(source);
|
|
3486
|
+
const contentType = input.content_type ?? input.mime_type ?? sourceContentType(source);
|
|
3487
|
+
return {
|
|
3488
|
+
source,
|
|
3489
|
+
fileName,
|
|
3490
|
+
sizeBytes,
|
|
3491
|
+
contentType
|
|
3492
|
+
};
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
function validateUploadConstraints(sources, input) {
|
|
3496
|
+
const maxFiles = input.maxFiles ?? 1;
|
|
3497
|
+
if (sources.length > maxFiles) {
|
|
3498
|
+
throw new Error(`athena.storage.file.upload accepts at most ${maxFiles} file${maxFiles === 1 ? "" : "s"} for this call`);
|
|
3499
|
+
}
|
|
3500
|
+
const maxFileSizeBytes = input.maxFileSizeBytes ?? (input.maxFileSizeMb === void 0 ? void 0 : Math.floor(input.maxFileSizeMb * 1024 * 1024));
|
|
3501
|
+
if (maxFileSizeBytes !== void 0) {
|
|
3502
|
+
const tooLarge = sources.find((source) => source.sizeBytes > maxFileSizeBytes);
|
|
3503
|
+
if (tooLarge) {
|
|
3504
|
+
throw new Error(`athena.storage.file.upload rejected ${tooLarge.fileName}: file exceeds ${maxFileSizeBytes} bytes`);
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
const allowedExtensions = normalizeExtensions(input.allowedExtensions ?? input.extensions);
|
|
3508
|
+
if (allowedExtensions.size > 0) {
|
|
3509
|
+
const invalid = sources.find((source) => !allowedExtensions.has(fileExtension(source.fileName)));
|
|
3510
|
+
if (invalid) {
|
|
3511
|
+
throw new Error(`athena.storage.file.upload rejected ${invalid.fileName}: extension is not allowed`);
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
async function putUploadBody(url, source, input, options, onProgress) {
|
|
3516
|
+
const headers = new Headers(input.uploadHeaders);
|
|
3517
|
+
if (source.contentType && !headers.has("Content-Type")) {
|
|
3518
|
+
headers.set("Content-Type", source.contentType);
|
|
3519
|
+
}
|
|
3520
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
3521
|
+
return putUploadBodyWithXhr(url, source, headers, options, onProgress);
|
|
3522
|
+
}
|
|
3523
|
+
onProgress({ loaded: 0 });
|
|
3524
|
+
const response = await fetch(url, {
|
|
3525
|
+
method: "PUT",
|
|
3526
|
+
headers,
|
|
3527
|
+
body: source.source,
|
|
3528
|
+
signal: options?.signal
|
|
3529
|
+
});
|
|
3530
|
+
if (!response.ok) {
|
|
3531
|
+
throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
|
|
3532
|
+
}
|
|
3533
|
+
onProgress({ loaded: source.sizeBytes });
|
|
3534
|
+
return response;
|
|
3535
|
+
}
|
|
3536
|
+
function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
|
|
3537
|
+
const Xhr = XMLHttpRequest;
|
|
3538
|
+
if (Xhr === void 0) {
|
|
3539
|
+
return Promise.reject(new Error("athena.storage.file.upload requires XMLHttpRequest in this runtime"));
|
|
3540
|
+
}
|
|
3541
|
+
return new Promise((resolve, reject) => {
|
|
3542
|
+
const xhr = new Xhr();
|
|
3543
|
+
const abort = () => xhr.abort();
|
|
3544
|
+
xhr.open("PUT", url);
|
|
3545
|
+
headers.forEach((value, key) => xhr.setRequestHeader(key, value));
|
|
3546
|
+
xhr.upload.onprogress = (event) => {
|
|
3547
|
+
onProgress({ loaded: event.loaded });
|
|
3548
|
+
};
|
|
3549
|
+
xhr.onload = () => {
|
|
3550
|
+
if (options?.signal) {
|
|
3551
|
+
options.signal.removeEventListener("abort", abort);
|
|
3552
|
+
}
|
|
3553
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
3554
|
+
reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
|
|
3555
|
+
return;
|
|
3556
|
+
}
|
|
3557
|
+
onProgress({ loaded: source.sizeBytes });
|
|
3558
|
+
resolve(new Response(xhr.response, {
|
|
3559
|
+
status: xhr.status,
|
|
3560
|
+
statusText: xhr.statusText,
|
|
3561
|
+
headers: parseXhrHeaders(xhr.getAllResponseHeaders())
|
|
3562
|
+
}));
|
|
3563
|
+
};
|
|
3564
|
+
xhr.onerror = () => {
|
|
3565
|
+
if (options?.signal) {
|
|
3566
|
+
options.signal.removeEventListener("abort", abort);
|
|
3567
|
+
}
|
|
3568
|
+
reject(new Error("athena.storage.file.upload failed with a network error"));
|
|
3569
|
+
};
|
|
3570
|
+
xhr.onabort = () => {
|
|
3571
|
+
if (options?.signal) {
|
|
3572
|
+
options.signal.removeEventListener("abort", abort);
|
|
3573
|
+
}
|
|
3574
|
+
reject(new DOMException("Upload aborted", "AbortError"));
|
|
3575
|
+
};
|
|
3576
|
+
if (options?.signal) {
|
|
3577
|
+
if (options.signal.aborted) {
|
|
3578
|
+
abort();
|
|
3579
|
+
return;
|
|
3580
|
+
}
|
|
3581
|
+
options.signal.addEventListener("abort", abort, { once: true });
|
|
3582
|
+
}
|
|
3583
|
+
xhr.send(source.source);
|
|
3584
|
+
});
|
|
3585
|
+
}
|
|
3586
|
+
function normalizeDownloadArgs(input, queryOrOptions, maybeOptions) {
|
|
3587
|
+
if (typeof input === "string") {
|
|
3588
|
+
return { fileIds: [input], query: queryOrOptions, options: maybeOptions };
|
|
3589
|
+
}
|
|
3590
|
+
if (Array.isArray(input)) {
|
|
3591
|
+
return { fileIds: [...input], query: queryOrOptions, options: maybeOptions };
|
|
3592
|
+
}
|
|
3593
|
+
const downloadInput = input;
|
|
3594
|
+
const { fileId, fileIds, ...query } = downloadInput;
|
|
3595
|
+
return {
|
|
3596
|
+
fileIds: fileIds ? [...fileIds] : fileId ? [fileId] : [],
|
|
3597
|
+
query,
|
|
3598
|
+
options: queryOrOptions
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
function createPathContext(input, options, config) {
|
|
3602
|
+
const organizationId = input.organizationId ?? input.organization_id ?? options?.organizationId ?? void 0;
|
|
3603
|
+
const userId = input.userId ?? input.user_id ?? options?.userId ?? void 0;
|
|
3604
|
+
const resourceId = input.resourceId ?? input.resource_id ?? void 0;
|
|
3605
|
+
const vars = {
|
|
3606
|
+
...config.vars ?? {},
|
|
3607
|
+
...input.vars ?? {}
|
|
3608
|
+
};
|
|
3609
|
+
if (organizationId !== void 0) {
|
|
3610
|
+
vars.organizationId = organizationId;
|
|
3611
|
+
vars.organization_id = organizationId;
|
|
3612
|
+
}
|
|
3613
|
+
if (userId !== void 0) {
|
|
3614
|
+
vars.userId = userId;
|
|
3615
|
+
vars.user_id = userId;
|
|
3616
|
+
}
|
|
3617
|
+
if (resourceId !== void 0) {
|
|
3618
|
+
vars.resourceId = resourceId;
|
|
3619
|
+
vars.resource_id = resourceId;
|
|
3620
|
+
}
|
|
3621
|
+
return {
|
|
3622
|
+
vars,
|
|
3623
|
+
env: {
|
|
3624
|
+
...readProcessEnv(),
|
|
3625
|
+
...config.env ?? {},
|
|
3626
|
+
...input.env ?? {}
|
|
3627
|
+
},
|
|
3628
|
+
organizationId,
|
|
3629
|
+
organization_id: organizationId,
|
|
3630
|
+
userId,
|
|
3631
|
+
user_id: userId,
|
|
3632
|
+
resourceId,
|
|
3633
|
+
resource_id: resourceId
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3636
|
+
function renderStorageTemplate(template, context) {
|
|
3637
|
+
return template.replace(/\$\{([^}]+)\}|\{([^}]+)\}/g, (_match, shellToken, braceToken) => {
|
|
3638
|
+
const token = (shellToken ?? braceToken ?? "").trim();
|
|
3639
|
+
if (!token) return "";
|
|
3640
|
+
const value = resolveTemplateToken(token, context);
|
|
3641
|
+
return value === void 0 || value === null ? "" : String(value);
|
|
3642
|
+
});
|
|
3643
|
+
}
|
|
3644
|
+
function resolveTemplateToken(token, context) {
|
|
3645
|
+
if (token.startsWith("env.")) {
|
|
3646
|
+
return context.env[token.slice(4)];
|
|
3647
|
+
}
|
|
3648
|
+
if (token in context.vars) {
|
|
3649
|
+
return context.vars[token];
|
|
3650
|
+
}
|
|
3651
|
+
return context.env[token];
|
|
3652
|
+
}
|
|
3653
|
+
function joinStoragePath(...parts) {
|
|
3654
|
+
return parts.map((part) => part.trim().replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
|
|
3655
|
+
}
|
|
3656
|
+
function toArray(files) {
|
|
3657
|
+
if (isUploadSource(files)) return [files];
|
|
3658
|
+
return Array.from(files);
|
|
3659
|
+
}
|
|
3660
|
+
function isUploadSource(value) {
|
|
3661
|
+
return value instanceof Blob || value instanceof ArrayBuffer || value instanceof Uint8Array;
|
|
3662
|
+
}
|
|
3663
|
+
function sourceName(source) {
|
|
3664
|
+
return isRecord5(source) && typeof source.name === "string" && source.name.trim() ? source.name.trim() : void 0;
|
|
3665
|
+
}
|
|
3666
|
+
function sourceSize(source) {
|
|
3667
|
+
if (source instanceof Blob) return source.size;
|
|
3668
|
+
return source.byteLength;
|
|
3669
|
+
}
|
|
3670
|
+
function sourceContentType(source) {
|
|
3671
|
+
return source instanceof Blob && source.type.trim() ? source.type.trim() : void 0;
|
|
3672
|
+
}
|
|
3673
|
+
function normalizeExtensions(extensions) {
|
|
3674
|
+
return new Set((extensions ?? []).map((extension) => extension.replace(/^\./, "").toLowerCase()).filter(Boolean));
|
|
3675
|
+
}
|
|
3676
|
+
function fileExtension(fileName) {
|
|
3677
|
+
const lastDot = fileName.lastIndexOf(".");
|
|
3678
|
+
return lastDot === -1 ? "" : fileName.slice(lastDot + 1).toLowerCase();
|
|
3679
|
+
}
|
|
3680
|
+
function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoaded) {
|
|
3681
|
+
const total = sources[fileIndex]?.sizeBytes ?? 0;
|
|
3682
|
+
const aggregateTotal = sources.reduce((totalBytes, source) => totalBytes + source.sizeBytes, 0);
|
|
3683
|
+
return {
|
|
3684
|
+
phase,
|
|
3685
|
+
fileIndex,
|
|
3686
|
+
fileCount: sources.length,
|
|
3687
|
+
fileName: sources[fileIndex]?.fileName ?? "",
|
|
3688
|
+
loaded,
|
|
3689
|
+
total,
|
|
3690
|
+
percent: total > 0 ? Math.round(loaded / total * 100) : 100,
|
|
3691
|
+
aggregateLoaded,
|
|
3692
|
+
aggregateTotal,
|
|
3693
|
+
aggregatePercent: aggregateTotal > 0 ? Math.round(aggregateLoaded / aggregateTotal * 100) : 100
|
|
3694
|
+
};
|
|
3695
|
+
}
|
|
3696
|
+
function sum(values) {
|
|
3697
|
+
return values.reduce((total, value) => total + value, 0);
|
|
3698
|
+
}
|
|
3699
|
+
function parseXhrHeaders(raw) {
|
|
3700
|
+
const headers = new Headers();
|
|
3701
|
+
for (const line of raw.trim().split(/[\r\n]+/)) {
|
|
3702
|
+
const index = line.indexOf(":");
|
|
3703
|
+
if (index === -1) continue;
|
|
3704
|
+
headers.set(line.slice(0, index).trim(), line.slice(index + 1).trim());
|
|
3705
|
+
}
|
|
3706
|
+
return headers;
|
|
3707
|
+
}
|
|
3708
|
+
function readProcessEnv() {
|
|
3709
|
+
const processLike = globalThis.process;
|
|
3710
|
+
return processLike?.env ?? {};
|
|
3711
|
+
}
|
|
3712
|
+
function isRecord5(value) {
|
|
3713
|
+
return Boolean(value) && typeof value === "object";
|
|
3714
|
+
}
|
|
3715
|
+
|
|
3371
3716
|
// src/storage/module.ts
|
|
3372
3717
|
var storageSdkManifest = {
|
|
3373
3718
|
namespace: "storage",
|
|
@@ -3576,7 +3921,7 @@ var AthenaStorageError = class extends Error {
|
|
|
3576
3921
|
};
|
|
3577
3922
|
}
|
|
3578
3923
|
};
|
|
3579
|
-
function
|
|
3924
|
+
function isRecord6(value) {
|
|
3580
3925
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3581
3926
|
}
|
|
3582
3927
|
function causeToString(cause) {
|
|
@@ -3691,7 +4036,7 @@ function withPathParam(path, name, value) {
|
|
|
3691
4036
|
return path.replace(`{${name}}`, encodeURIComponent(value));
|
|
3692
4037
|
}
|
|
3693
4038
|
function resolveErrorMessage3(payload, fallback) {
|
|
3694
|
-
if (
|
|
4039
|
+
if (isRecord6(payload)) {
|
|
3695
4040
|
const message = payload.message ?? payload.error ?? payload.details;
|
|
3696
4041
|
if (typeof message === "string" && message.trim()) {
|
|
3697
4042
|
return message.trim();
|
|
@@ -3703,12 +4048,12 @@ function resolveErrorMessage3(payload, fallback) {
|
|
|
3703
4048
|
return fallback;
|
|
3704
4049
|
}
|
|
3705
4050
|
function resolveErrorHint2(payload) {
|
|
3706
|
-
if (!
|
|
4051
|
+
if (!isRecord6(payload)) return void 0;
|
|
3707
4052
|
const hint = payload.hint ?? payload.suggestion;
|
|
3708
4053
|
return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
|
|
3709
4054
|
}
|
|
3710
4055
|
function resolveErrorCause(payload) {
|
|
3711
|
-
if (!
|
|
4056
|
+
if (!isRecord6(payload)) return void 0;
|
|
3712
4057
|
const cause = payload.cause ?? payload.reason;
|
|
3713
4058
|
return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
|
|
3714
4059
|
}
|
|
@@ -3827,7 +4172,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
|
|
|
3827
4172
|
);
|
|
3828
4173
|
}
|
|
3829
4174
|
if (envelope === "athena") {
|
|
3830
|
-
if (!
|
|
4175
|
+
if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
3831
4176
|
return rejectStorageError(
|
|
3832
4177
|
{
|
|
3833
4178
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -3935,81 +4280,260 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
|
|
|
3935
4280
|
runtimeOptions
|
|
3936
4281
|
);
|
|
3937
4282
|
}
|
|
3938
|
-
function
|
|
4283
|
+
function isBlobBody(body) {
|
|
4284
|
+
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
4285
|
+
}
|
|
4286
|
+
function isReadableStreamBody(body) {
|
|
4287
|
+
return typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
|
|
4288
|
+
}
|
|
4289
|
+
async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
|
|
4290
|
+
const headers = new Headers(uploadHeaders);
|
|
4291
|
+
Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
|
|
4292
|
+
if (!headers.has("Content-Type") && isBlobBody(body) && body.type) {
|
|
4293
|
+
headers.set("Content-Type", body.type);
|
|
4294
|
+
}
|
|
4295
|
+
const init = {
|
|
4296
|
+
method: "PUT",
|
|
4297
|
+
headers,
|
|
4298
|
+
body,
|
|
4299
|
+
signal: options?.signal
|
|
4300
|
+
};
|
|
4301
|
+
if (isReadableStreamBody(body)) {
|
|
4302
|
+
init.duplex = "half";
|
|
4303
|
+
}
|
|
4304
|
+
return fetch(uploadUrl, init);
|
|
4305
|
+
}
|
|
4306
|
+
function attachManagedUpload(upload) {
|
|
4307
|
+
const headers = {};
|
|
3939
4308
|
return {
|
|
4309
|
+
...upload,
|
|
4310
|
+
method: "PUT",
|
|
4311
|
+
headers,
|
|
4312
|
+
expiresAt: upload.expires_at,
|
|
4313
|
+
put(body, options) {
|
|
4314
|
+
return putPresignedUploadBody(upload.url, headers, body, options);
|
|
4315
|
+
}
|
|
4316
|
+
};
|
|
4317
|
+
}
|
|
4318
|
+
function attachUploadHelper(response) {
|
|
4319
|
+
return {
|
|
4320
|
+
...response,
|
|
4321
|
+
upload: attachManagedUpload(response.upload)
|
|
4322
|
+
};
|
|
4323
|
+
}
|
|
4324
|
+
function attachUploadHelpers(response) {
|
|
4325
|
+
return {
|
|
4326
|
+
files: response.files.map(attachUploadHelper)
|
|
4327
|
+
};
|
|
4328
|
+
}
|
|
4329
|
+
function normalizeUploadUrlRequest(input) {
|
|
4330
|
+
const s3_id = input.s3_id ?? input.s3Id;
|
|
4331
|
+
const storage_key = input.storage_key ?? input.storageKey;
|
|
4332
|
+
if (!s3_id?.trim()) {
|
|
4333
|
+
throw new Error("athena.storage.file.upload requires s3_id or s3Id");
|
|
4334
|
+
}
|
|
4335
|
+
if (!storage_key?.trim()) {
|
|
4336
|
+
throw new Error("athena.storage.file.upload requires storage_key or storageKey");
|
|
4337
|
+
}
|
|
4338
|
+
const fileName = input.fileName?.trim();
|
|
4339
|
+
const originalName = input.originalName?.trim();
|
|
4340
|
+
return {
|
|
4341
|
+
s3_id,
|
|
4342
|
+
bucket: input.bucket,
|
|
4343
|
+
storage_key,
|
|
4344
|
+
name: input.name ?? fileName,
|
|
4345
|
+
original_name: input.original_name ?? originalName ?? fileName,
|
|
4346
|
+
resource_id: input.resource_id ?? input.resourceId,
|
|
4347
|
+
mime_type: input.mime_type ?? input.mimeType,
|
|
4348
|
+
content_type: input.content_type ?? input.contentType,
|
|
4349
|
+
size_bytes: input.size_bytes ?? input.sizeBytes,
|
|
4350
|
+
file_id: input.file_id ?? input.fileId,
|
|
4351
|
+
public: input.public,
|
|
4352
|
+
visibility: input.visibility,
|
|
4353
|
+
metadata: input.metadata
|
|
4354
|
+
};
|
|
4355
|
+
}
|
|
4356
|
+
async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
|
|
4357
|
+
let url;
|
|
4358
|
+
let headers;
|
|
4359
|
+
try {
|
|
4360
|
+
const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
|
|
4361
|
+
url = buildAthenaGatewayUrl(baseUrl, endpoint);
|
|
4362
|
+
headers = gateway.buildHeaders(options);
|
|
4363
|
+
} catch (error) {
|
|
4364
|
+
return rejectStorageError(
|
|
4365
|
+
{
|
|
4366
|
+
code: storageCodeFromUnknown(error),
|
|
4367
|
+
message: error instanceof Error ? error.message : `Athena storage PUT ${endpoint} failed before sending the request`,
|
|
4368
|
+
status: isAthenaGatewayError(error) ? error.status : 0,
|
|
4369
|
+
endpoint,
|
|
4370
|
+
method: "PUT",
|
|
4371
|
+
raw: error,
|
|
4372
|
+
requestId: isAthenaGatewayError(error) ? error.requestId : void 0,
|
|
4373
|
+
hint: isAthenaGatewayError(error) ? error.hint : void 0,
|
|
4374
|
+
cause: error
|
|
4375
|
+
},
|
|
4376
|
+
options,
|
|
4377
|
+
runtimeOptions
|
|
4378
|
+
);
|
|
4379
|
+
}
|
|
4380
|
+
delete headers["Content-Type"];
|
|
4381
|
+
delete headers["content-type"];
|
|
4382
|
+
if (isBlobBody(body) && body.type) {
|
|
4383
|
+
headers["Content-Type"] = body.type;
|
|
4384
|
+
}
|
|
4385
|
+
const requestInit = {
|
|
4386
|
+
method: "PUT",
|
|
4387
|
+
headers,
|
|
4388
|
+
body,
|
|
4389
|
+
signal: options?.signal
|
|
4390
|
+
};
|
|
4391
|
+
if (isReadableStreamBody(body)) {
|
|
4392
|
+
requestInit.duplex = "half";
|
|
4393
|
+
}
|
|
4394
|
+
let response;
|
|
4395
|
+
try {
|
|
4396
|
+
response = await fetch(url, requestInit);
|
|
4397
|
+
} catch (error) {
|
|
4398
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4399
|
+
return rejectStorageError(
|
|
4400
|
+
{
|
|
4401
|
+
code: "NETWORK_ERROR",
|
|
4402
|
+
message: `Network error while calling Athena storage PUT ${endpoint}: ${message}`,
|
|
4403
|
+
status: 0,
|
|
4404
|
+
endpoint,
|
|
4405
|
+
method: "PUT",
|
|
4406
|
+
cause: error
|
|
4407
|
+
},
|
|
4408
|
+
options,
|
|
4409
|
+
runtimeOptions
|
|
4410
|
+
);
|
|
4411
|
+
}
|
|
4412
|
+
let rawText;
|
|
4413
|
+
try {
|
|
4414
|
+
rawText = await response.text();
|
|
4415
|
+
} catch (error) {
|
|
4416
|
+
return rejectStorageError(
|
|
4417
|
+
{
|
|
4418
|
+
code: "NETWORK_ERROR",
|
|
4419
|
+
message: `Athena storage PUT ${endpoint} response body could not be read`,
|
|
4420
|
+
status: response.status,
|
|
4421
|
+
endpoint,
|
|
4422
|
+
method: "PUT",
|
|
4423
|
+
requestId: headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]),
|
|
4424
|
+
cause: error
|
|
4425
|
+
},
|
|
4426
|
+
options,
|
|
4427
|
+
runtimeOptions
|
|
4428
|
+
);
|
|
4429
|
+
}
|
|
4430
|
+
const parsedBody = parseResponseBody3(rawText ?? "", response.headers.get("content-type"));
|
|
4431
|
+
const requestId = headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]);
|
|
4432
|
+
if (parsedBody.parseFailed) {
|
|
4433
|
+
return rejectStorageError(
|
|
4434
|
+
{
|
|
4435
|
+
code: "INVALID_JSON",
|
|
4436
|
+
message: `Athena storage PUT ${endpoint} returned malformed JSON`,
|
|
4437
|
+
status: response.status,
|
|
4438
|
+
endpoint,
|
|
4439
|
+
method: "PUT",
|
|
4440
|
+
requestId,
|
|
4441
|
+
raw: parsedBody.parsed
|
|
4442
|
+
},
|
|
4443
|
+
options,
|
|
4444
|
+
runtimeOptions
|
|
4445
|
+
);
|
|
4446
|
+
}
|
|
4447
|
+
if (!response.ok) {
|
|
4448
|
+
return rejectStorageError(
|
|
4449
|
+
{
|
|
4450
|
+
code: "HTTP_ERROR",
|
|
4451
|
+
message: resolveErrorMessage3(
|
|
4452
|
+
parsedBody.parsed,
|
|
4453
|
+
`Athena storage PUT ${endpoint} failed with status ${response.status}`
|
|
4454
|
+
),
|
|
4455
|
+
status: response.status,
|
|
4456
|
+
endpoint,
|
|
4457
|
+
method: "PUT",
|
|
4458
|
+
requestId,
|
|
4459
|
+
hint: resolveErrorHint2(parsedBody.parsed),
|
|
4460
|
+
cause: resolveErrorCause(parsedBody.parsed),
|
|
4461
|
+
raw: parsedBody.parsed
|
|
4462
|
+
},
|
|
4463
|
+
options,
|
|
4464
|
+
runtimeOptions
|
|
4465
|
+
);
|
|
4466
|
+
}
|
|
4467
|
+
if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
4468
|
+
return rejectStorageError(
|
|
4469
|
+
{
|
|
4470
|
+
code: "INVALID_ATHENA_ENVELOPE",
|
|
4471
|
+
message: `Athena storage PUT ${endpoint} returned an invalid Athena envelope`,
|
|
4472
|
+
status: response.status,
|
|
4473
|
+
endpoint,
|
|
4474
|
+
method: "PUT",
|
|
4475
|
+
requestId,
|
|
4476
|
+
raw: parsedBody.parsed
|
|
4477
|
+
},
|
|
4478
|
+
options,
|
|
4479
|
+
runtimeOptions
|
|
4480
|
+
);
|
|
4481
|
+
}
|
|
4482
|
+
return parsedBody.parsed.data;
|
|
4483
|
+
}
|
|
4484
|
+
function createStorageModule(gateway, runtimeOptions) {
|
|
4485
|
+
const callRaw = (path, method, payload, options) => callStorageEndpoint(
|
|
4486
|
+
gateway,
|
|
4487
|
+
storagePath(path),
|
|
4488
|
+
method,
|
|
4489
|
+
"raw",
|
|
4490
|
+
payload,
|
|
4491
|
+
options,
|
|
4492
|
+
runtimeOptions
|
|
4493
|
+
);
|
|
4494
|
+
const callAthena2 = (path, method, payload, options) => callStorageEndpoint(
|
|
4495
|
+
gateway,
|
|
4496
|
+
storagePath(path),
|
|
4497
|
+
method,
|
|
4498
|
+
"athena",
|
|
4499
|
+
payload,
|
|
4500
|
+
options,
|
|
4501
|
+
runtimeOptions
|
|
4502
|
+
);
|
|
4503
|
+
const base = {
|
|
3940
4504
|
listStorageCatalogs(options) {
|
|
3941
|
-
return
|
|
4505
|
+
return callRaw("/storage/catalogs", "GET", void 0, options);
|
|
3942
4506
|
},
|
|
3943
4507
|
createStorageCatalog(input, options) {
|
|
3944
|
-
return
|
|
4508
|
+
return callRaw("/storage/catalogs", "POST", input, options);
|
|
3945
4509
|
},
|
|
3946
4510
|
updateStorageCatalog(id, input, options) {
|
|
3947
|
-
return
|
|
3948
|
-
gateway,
|
|
3949
|
-
storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
|
|
3950
|
-
"PATCH",
|
|
3951
|
-
"raw",
|
|
3952
|
-
input,
|
|
3953
|
-
options,
|
|
3954
|
-
runtimeOptions
|
|
3955
|
-
);
|
|
4511
|
+
return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "PATCH", input, options);
|
|
3956
4512
|
},
|
|
3957
4513
|
deleteStorageCatalog(id, options) {
|
|
3958
|
-
return
|
|
3959
|
-
gateway,
|
|
3960
|
-
storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
|
|
3961
|
-
"DELETE",
|
|
3962
|
-
"raw",
|
|
3963
|
-
void 0,
|
|
3964
|
-
options,
|
|
3965
|
-
runtimeOptions
|
|
3966
|
-
);
|
|
4514
|
+
return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "DELETE", void 0, options);
|
|
3967
4515
|
},
|
|
3968
4516
|
listStorageCredentials(options) {
|
|
3969
|
-
return
|
|
4517
|
+
return callRaw("/storage/credentials", "GET", void 0, options);
|
|
3970
4518
|
},
|
|
3971
4519
|
createStorageUploadUrl(input, options) {
|
|
3972
|
-
return
|
|
3973
|
-
gateway,
|
|
3974
|
-
storagePath("/storage/files/upload-url"),
|
|
3975
|
-
"POST",
|
|
3976
|
-
"athena",
|
|
3977
|
-
input,
|
|
3978
|
-
options,
|
|
3979
|
-
runtimeOptions
|
|
3980
|
-
);
|
|
4520
|
+
return callAthena2("/storage/files/upload-url", "POST", input, options);
|
|
3981
4521
|
},
|
|
3982
4522
|
createStorageUploadUrls(input, options) {
|
|
3983
|
-
return
|
|
3984
|
-
gateway,
|
|
3985
|
-
storagePath("/storage/files/upload-urls"),
|
|
3986
|
-
"POST",
|
|
3987
|
-
"athena",
|
|
3988
|
-
input,
|
|
3989
|
-
options,
|
|
3990
|
-
runtimeOptions
|
|
3991
|
-
);
|
|
4523
|
+
return callAthena2("/storage/files/upload-urls", "POST", input, options);
|
|
3992
4524
|
},
|
|
3993
4525
|
listStorageFiles(input, options) {
|
|
3994
|
-
return
|
|
4526
|
+
return callAthena2("/storage/files/list", "POST", input, options);
|
|
3995
4527
|
},
|
|
3996
4528
|
getStorageFile(fileId, options) {
|
|
3997
|
-
return
|
|
3998
|
-
gateway,
|
|
3999
|
-
storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
|
|
4000
|
-
"GET",
|
|
4001
|
-
"athena",
|
|
4002
|
-
void 0,
|
|
4003
|
-
options,
|
|
4004
|
-
runtimeOptions
|
|
4005
|
-
);
|
|
4529
|
+
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
|
|
4006
4530
|
},
|
|
4007
4531
|
getStorageFileUrl(fileId, query, options) {
|
|
4008
4532
|
const path = appendQuery(
|
|
4009
4533
|
withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
|
|
4010
4534
|
query
|
|
4011
4535
|
);
|
|
4012
|
-
return
|
|
4536
|
+
return callAthena2(path, "GET", void 0, options);
|
|
4013
4537
|
},
|
|
4014
4538
|
getStorageFileProxy(fileId, query, options) {
|
|
4015
4539
|
const path = appendQuery(
|
|
@@ -4019,45 +4543,244 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
4019
4543
|
return callStorageBinaryEndpoint(gateway, storagePath(path), "GET", options, runtimeOptions);
|
|
4020
4544
|
},
|
|
4021
4545
|
updateStorageFile(fileId, input, options) {
|
|
4022
|
-
return
|
|
4023
|
-
gateway,
|
|
4024
|
-
storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
|
|
4025
|
-
"PATCH",
|
|
4026
|
-
"athena",
|
|
4027
|
-
input,
|
|
4028
|
-
options,
|
|
4029
|
-
runtimeOptions
|
|
4030
|
-
);
|
|
4546
|
+
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "PATCH", input, options);
|
|
4031
4547
|
},
|
|
4032
4548
|
deleteStorageFile(fileId, options) {
|
|
4033
|
-
return
|
|
4034
|
-
gateway,
|
|
4035
|
-
storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
|
|
4036
|
-
"DELETE",
|
|
4037
|
-
"athena",
|
|
4038
|
-
void 0,
|
|
4039
|
-
options,
|
|
4040
|
-
runtimeOptions
|
|
4041
|
-
);
|
|
4549
|
+
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
|
|
4042
4550
|
},
|
|
4043
4551
|
setStorageFileVisibility(fileId, input, options) {
|
|
4044
|
-
return
|
|
4552
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
|
|
4553
|
+
},
|
|
4554
|
+
deleteStorageFolder(input, options) {
|
|
4555
|
+
return callAthena2("/storage/folders/delete", "POST", input, options);
|
|
4556
|
+
},
|
|
4557
|
+
moveStorageFolder(input, options) {
|
|
4558
|
+
return callAthena2("/storage/folders/move", "POST", input, options);
|
|
4559
|
+
}
|
|
4560
|
+
};
|
|
4561
|
+
const fileFacade = createStorageFileModule(base, runtimeOptions);
|
|
4562
|
+
const fileUpload = ((input, options) => {
|
|
4563
|
+
if (isRecord6(input) && "files" in input) {
|
|
4564
|
+
return fileFacade.upload(input, options);
|
|
4565
|
+
}
|
|
4566
|
+
return base.createStorageUploadUrl(
|
|
4567
|
+
normalizeUploadUrlRequest(input),
|
|
4568
|
+
options
|
|
4569
|
+
).then(attachUploadHelper);
|
|
4570
|
+
});
|
|
4571
|
+
const fileDelete = ((input, options) => fileFacade.delete(input, options));
|
|
4572
|
+
const file = {
|
|
4573
|
+
...fileFacade,
|
|
4574
|
+
upload: fileUpload,
|
|
4575
|
+
uploadMany(input, options) {
|
|
4576
|
+
return base.createStorageUploadUrls(
|
|
4577
|
+
{ files: input.files.map(normalizeUploadUrlRequest) },
|
|
4578
|
+
options
|
|
4579
|
+
).then(attachUploadHelpers);
|
|
4580
|
+
},
|
|
4581
|
+
confirmUpload(fileId, input, options) {
|
|
4582
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/confirm-upload", "file_id", fileId), "POST", input ?? {}, options);
|
|
4583
|
+
},
|
|
4584
|
+
uploadBinary(fileId, body, options) {
|
|
4585
|
+
return callStorageUploadBinaryEndpoint(
|
|
4045
4586
|
gateway,
|
|
4046
|
-
storagePath(withPathParam("/storage/files/{file_id}/
|
|
4047
|
-
|
|
4048
|
-
"athena",
|
|
4049
|
-
input,
|
|
4587
|
+
storagePath(withPathParam("/storage/files/{file_id}/upload", "file_id", fileId)),
|
|
4588
|
+
body,
|
|
4050
4589
|
options,
|
|
4051
4590
|
runtimeOptions
|
|
4052
4591
|
);
|
|
4053
4592
|
},
|
|
4054
|
-
|
|
4055
|
-
return
|
|
4593
|
+
search(input, options) {
|
|
4594
|
+
return callAthena2("/storage/files/search", "POST", input, options);
|
|
4056
4595
|
},
|
|
4057
|
-
|
|
4058
|
-
return
|
|
4596
|
+
get(fileId, options) {
|
|
4597
|
+
return base.getStorageFile(fileId, options);
|
|
4598
|
+
},
|
|
4599
|
+
update(fileId, input, options) {
|
|
4600
|
+
return base.updateStorageFile(fileId, input, options);
|
|
4601
|
+
},
|
|
4602
|
+
delete: fileDelete,
|
|
4603
|
+
deleteMany(input, options) {
|
|
4604
|
+
return callAthena2("/storage/files/delete-many", "POST", input, options);
|
|
4605
|
+
},
|
|
4606
|
+
updateMany(input, options) {
|
|
4607
|
+
return callAthena2("/storage/files/update-many", "POST", input, options);
|
|
4608
|
+
},
|
|
4609
|
+
restore(fileId, options) {
|
|
4610
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/restore", "file_id", fileId), "POST", {}, options);
|
|
4611
|
+
},
|
|
4612
|
+
purge(fileId, options) {
|
|
4613
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/purge", "file_id", fileId), "DELETE", void 0, options);
|
|
4614
|
+
},
|
|
4615
|
+
copy(fileId, input, options) {
|
|
4616
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/copy", "file_id", fileId), "POST", input, options);
|
|
4617
|
+
},
|
|
4618
|
+
url(fileId, query, options) {
|
|
4619
|
+
return base.getStorageFileUrl(fileId, query, options);
|
|
4620
|
+
},
|
|
4621
|
+
publicUrl(fileId, options) {
|
|
4622
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
|
|
4623
|
+
},
|
|
4624
|
+
proxy(fileId, query, options) {
|
|
4625
|
+
return base.getStorageFileProxy(fileId, query, options);
|
|
4626
|
+
},
|
|
4627
|
+
visibility: {
|
|
4628
|
+
set(fileId, input, options) {
|
|
4629
|
+
return base.setStorageFileVisibility(fileId, input, options);
|
|
4630
|
+
},
|
|
4631
|
+
setMany(input, options) {
|
|
4632
|
+
return callAthena2("/storage/files/visibility-many", "POST", input, options);
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
};
|
|
4636
|
+
const credentials = {
|
|
4637
|
+
list(options) {
|
|
4638
|
+
return base.listStorageCredentials(options);
|
|
4639
|
+
}
|
|
4640
|
+
};
|
|
4641
|
+
const catalog = {
|
|
4642
|
+
list(options) {
|
|
4643
|
+
return base.listStorageCatalogs(options);
|
|
4644
|
+
},
|
|
4645
|
+
create(input, options) {
|
|
4646
|
+
return base.createStorageCatalog(input, options);
|
|
4647
|
+
},
|
|
4648
|
+
update(id, input, options) {
|
|
4649
|
+
return base.updateStorageCatalog(id, input, options);
|
|
4650
|
+
},
|
|
4651
|
+
delete(id, options) {
|
|
4652
|
+
return base.deleteStorageCatalog(id, options);
|
|
4653
|
+
}
|
|
4654
|
+
};
|
|
4655
|
+
const folder = {
|
|
4656
|
+
list(input, options) {
|
|
4657
|
+
return callAthena2("/storage/folders/list", "POST", input, options);
|
|
4658
|
+
},
|
|
4659
|
+
tree(input, options) {
|
|
4660
|
+
return callAthena2("/storage/folders/tree", "POST", input, options);
|
|
4661
|
+
},
|
|
4662
|
+
delete(input, options) {
|
|
4663
|
+
return base.deleteStorageFolder(input, options);
|
|
4664
|
+
},
|
|
4665
|
+
move(input, options) {
|
|
4666
|
+
return base.moveStorageFolder(input, options);
|
|
4667
|
+
}
|
|
4668
|
+
};
|
|
4669
|
+
const permission = {
|
|
4670
|
+
list(input, options) {
|
|
4671
|
+
return callAthena2("/storage/permissions/list", "POST", input, options);
|
|
4672
|
+
},
|
|
4673
|
+
grant(input, options) {
|
|
4674
|
+
return callAthena2("/storage/permissions/grant", "POST", input, options);
|
|
4675
|
+
},
|
|
4676
|
+
revoke(input, options) {
|
|
4677
|
+
return callAthena2("/storage/permissions/revoke", "POST", input, options);
|
|
4678
|
+
},
|
|
4679
|
+
check(input, options) {
|
|
4680
|
+
return callAthena2("/storage/permissions/check", "POST", input, options);
|
|
4059
4681
|
}
|
|
4060
4682
|
};
|
|
4683
|
+
const objectFolder = {
|
|
4684
|
+
create(input, options) {
|
|
4685
|
+
return callAthena2("/storage/objects/folder", "POST", input, options);
|
|
4686
|
+
},
|
|
4687
|
+
delete(input, options) {
|
|
4688
|
+
return callAthena2("/storage/objects/folder/delete", "POST", input, options);
|
|
4689
|
+
},
|
|
4690
|
+
rename(input, options) {
|
|
4691
|
+
return callAthena2("/storage/objects/folder/rename", "POST", input, options);
|
|
4692
|
+
}
|
|
4693
|
+
};
|
|
4694
|
+
const object = {
|
|
4695
|
+
list(input, options) {
|
|
4696
|
+
return callAthena2("/storage/objects", "POST", input, options);
|
|
4697
|
+
},
|
|
4698
|
+
head(input, options) {
|
|
4699
|
+
return callAthena2("/storage/objects/head", "POST", input, options);
|
|
4700
|
+
},
|
|
4701
|
+
exists(input, options) {
|
|
4702
|
+
return callAthena2("/storage/objects/exists", "POST", input, options);
|
|
4703
|
+
},
|
|
4704
|
+
validate(input, options) {
|
|
4705
|
+
return callAthena2("/storage/objects/validate", "POST", input, options);
|
|
4706
|
+
},
|
|
4707
|
+
update(input, options) {
|
|
4708
|
+
return callAthena2("/storage/objects/update", "POST", input, options);
|
|
4709
|
+
},
|
|
4710
|
+
copy(input, options) {
|
|
4711
|
+
return callAthena2("/storage/objects/copy", "POST", input, options);
|
|
4712
|
+
},
|
|
4713
|
+
url(input, options) {
|
|
4714
|
+
return callAthena2("/storage/objects/url", "POST", input, options);
|
|
4715
|
+
},
|
|
4716
|
+
publicUrl(input, options) {
|
|
4717
|
+
return callAthena2("/storage/objects/public-url", "POST", input, options);
|
|
4718
|
+
},
|
|
4719
|
+
delete(input, options) {
|
|
4720
|
+
return callAthena2("/storage/objects/delete", "POST", input, options);
|
|
4721
|
+
},
|
|
4722
|
+
uploadUrl(input, options) {
|
|
4723
|
+
return callAthena2("/storage/objects/upload-url", "POST", input, options);
|
|
4724
|
+
},
|
|
4725
|
+
folder: objectFolder
|
|
4726
|
+
};
|
|
4727
|
+
const bucket = {
|
|
4728
|
+
list(input, options) {
|
|
4729
|
+
return callAthena2("/storage/buckets/list", "POST", input, options);
|
|
4730
|
+
},
|
|
4731
|
+
create(input, options) {
|
|
4732
|
+
return callAthena2("/storage/buckets/create", "POST", input, options);
|
|
4733
|
+
},
|
|
4734
|
+
delete(input, options) {
|
|
4735
|
+
return callAthena2("/storage/buckets/delete", "POST", input, options);
|
|
4736
|
+
},
|
|
4737
|
+
cors: {
|
|
4738
|
+
get(input, options) {
|
|
4739
|
+
return callAthena2("/storage/buckets/cors", "POST", input, options);
|
|
4740
|
+
},
|
|
4741
|
+
set(input, options) {
|
|
4742
|
+
return callAthena2("/storage/buckets/cors/set", "POST", input, options);
|
|
4743
|
+
},
|
|
4744
|
+
delete(input, options) {
|
|
4745
|
+
return callAthena2("/storage/buckets/cors/delete", "POST", input, options);
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4748
|
+
};
|
|
4749
|
+
const multipart = {
|
|
4750
|
+
create(input, options) {
|
|
4751
|
+
return callAthena2("/storage/multipart/create", "POST", input, options);
|
|
4752
|
+
},
|
|
4753
|
+
signPart(input, options) {
|
|
4754
|
+
return callAthena2("/storage/multipart/sign-part", "POST", input, options);
|
|
4755
|
+
},
|
|
4756
|
+
complete(input, options) {
|
|
4757
|
+
return callAthena2("/storage/multipart/complete", "POST", input, options);
|
|
4758
|
+
},
|
|
4759
|
+
abort(input, options) {
|
|
4760
|
+
return callAthena2("/storage/multipart/abort", "POST", input, options);
|
|
4761
|
+
},
|
|
4762
|
+
listParts(input, options) {
|
|
4763
|
+
return callAthena2("/storage/multipart/list-parts", "POST", input, options);
|
|
4764
|
+
}
|
|
4765
|
+
};
|
|
4766
|
+
const audit = {
|
|
4767
|
+
list(input, options) {
|
|
4768
|
+
return callAthena2("/storage/audit/list", "POST", input, options);
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
return {
|
|
4772
|
+
...base,
|
|
4773
|
+
credentials,
|
|
4774
|
+
catalog,
|
|
4775
|
+
file,
|
|
4776
|
+
folder,
|
|
4777
|
+
permission,
|
|
4778
|
+
object,
|
|
4779
|
+
bucket,
|
|
4780
|
+
multipart,
|
|
4781
|
+
audit,
|
|
4782
|
+
delete: file.delete
|
|
4783
|
+
};
|
|
4061
4784
|
}
|
|
4062
4785
|
|
|
4063
4786
|
// src/query-ast.ts
|
|
@@ -4087,7 +4810,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
4087
4810
|
"ilike",
|
|
4088
4811
|
"is"
|
|
4089
4812
|
]);
|
|
4090
|
-
function
|
|
4813
|
+
function isRecord7(value) {
|
|
4091
4814
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4092
4815
|
}
|
|
4093
4816
|
function isUuidString(value) {
|
|
@@ -4100,7 +4823,7 @@ function shouldUseUuidTextComparison(column, value) {
|
|
|
4100
4823
|
return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
|
|
4101
4824
|
}
|
|
4102
4825
|
function isRelationSelectNode(value) {
|
|
4103
|
-
return
|
|
4826
|
+
return isRecord7(value) && isRecord7(value.select);
|
|
4104
4827
|
}
|
|
4105
4828
|
function normalizeIdentifier(value, label) {
|
|
4106
4829
|
const normalized = value.trim();
|
|
@@ -4156,7 +4879,7 @@ function compileRelationToken(key, node) {
|
|
|
4156
4879
|
return `${prefix}${relationToken}(${nested})`;
|
|
4157
4880
|
}
|
|
4158
4881
|
function compileSelectShape(select) {
|
|
4159
|
-
if (!
|
|
4882
|
+
if (!isRecord7(select)) {
|
|
4160
4883
|
throw new Error("findMany select must be an object");
|
|
4161
4884
|
}
|
|
4162
4885
|
const tokens = [];
|
|
@@ -4180,7 +4903,7 @@ function compileSelectShape(select) {
|
|
|
4180
4903
|
return tokens.join(",");
|
|
4181
4904
|
}
|
|
4182
4905
|
function selectShapeUsesRelationSchema(select) {
|
|
4183
|
-
if (!
|
|
4906
|
+
if (!isRecord7(select)) {
|
|
4184
4907
|
return false;
|
|
4185
4908
|
}
|
|
4186
4909
|
for (const rawValue of Object.values(select)) {
|
|
@@ -4198,7 +4921,7 @@ function selectShapeUsesRelationSchema(select) {
|
|
|
4198
4921
|
}
|
|
4199
4922
|
function compileColumnWhere(column, input) {
|
|
4200
4923
|
const normalizedColumn = normalizeIdentifier(column, "where column");
|
|
4201
|
-
if (!
|
|
4924
|
+
if (!isRecord7(input)) {
|
|
4202
4925
|
return [buildGatewayCondition("eq", normalizedColumn, input)];
|
|
4203
4926
|
}
|
|
4204
4927
|
const conditions = [];
|
|
@@ -4226,7 +4949,7 @@ function compileColumnWhere(column, input) {
|
|
|
4226
4949
|
return conditions;
|
|
4227
4950
|
}
|
|
4228
4951
|
function compileBooleanExpressionTerms(clause, label) {
|
|
4229
|
-
if (!
|
|
4952
|
+
if (!isRecord7(clause)) {
|
|
4230
4953
|
throw new Error(`findMany where.${label} clauses must be objects`);
|
|
4231
4954
|
}
|
|
4232
4955
|
const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
|
|
@@ -4235,7 +4958,7 @@ function compileBooleanExpressionTerms(clause, label) {
|
|
|
4235
4958
|
}
|
|
4236
4959
|
const [rawColumn, rawValue] = entries[0];
|
|
4237
4960
|
const column = normalizeIdentifier(rawColumn, `where.${label} column`);
|
|
4238
|
-
if (!
|
|
4961
|
+
if (!isRecord7(rawValue)) {
|
|
4239
4962
|
return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
|
|
4240
4963
|
}
|
|
4241
4964
|
const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
|
|
@@ -4259,7 +4982,7 @@ function compileWhere(where) {
|
|
|
4259
4982
|
if (where === void 0) {
|
|
4260
4983
|
return void 0;
|
|
4261
4984
|
}
|
|
4262
|
-
if (!
|
|
4985
|
+
if (!isRecord7(where)) {
|
|
4263
4986
|
throw new Error("findMany where must be an object");
|
|
4264
4987
|
}
|
|
4265
4988
|
const conditions = [];
|
|
@@ -4309,7 +5032,7 @@ function compileOrderBy(orderBy) {
|
|
|
4309
5032
|
if (orderBy === void 0) {
|
|
4310
5033
|
return void 0;
|
|
4311
5034
|
}
|
|
4312
|
-
if (!
|
|
5035
|
+
if (!isRecord7(orderBy)) {
|
|
4313
5036
|
throw new Error("findMany orderBy must be an object");
|
|
4314
5037
|
}
|
|
4315
5038
|
if ("column" in orderBy) {
|
|
@@ -4484,11 +5207,11 @@ function toFindManyAstOrder(order) {
|
|
|
4484
5207
|
ascending: order.direction !== "descending"
|
|
4485
5208
|
};
|
|
4486
5209
|
}
|
|
4487
|
-
function
|
|
5210
|
+
function isRecord8(value) {
|
|
4488
5211
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4489
5212
|
}
|
|
4490
5213
|
function normalizeFindManyAstColumnPredicate(value) {
|
|
4491
|
-
if (!
|
|
5214
|
+
if (!isRecord8(value)) {
|
|
4492
5215
|
return {
|
|
4493
5216
|
eq: value
|
|
4494
5217
|
};
|
|
@@ -4512,7 +5235,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
|
|
|
4512
5235
|
return normalized;
|
|
4513
5236
|
}
|
|
4514
5237
|
function normalizeFindManyAstWhere(where) {
|
|
4515
|
-
if (!where || !
|
|
5238
|
+
if (!where || !isRecord8(where)) {
|
|
4516
5239
|
return where;
|
|
4517
5240
|
}
|
|
4518
5241
|
const normalized = {};
|
|
@@ -4526,7 +5249,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
4526
5249
|
);
|
|
4527
5250
|
continue;
|
|
4528
5251
|
}
|
|
4529
|
-
if (key === "not" &&
|
|
5252
|
+
if (key === "not" && isRecord8(value)) {
|
|
4530
5253
|
normalized.not = normalizeFindManyAstBooleanOperand(
|
|
4531
5254
|
value
|
|
4532
5255
|
);
|
|
@@ -4537,7 +5260,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
4537
5260
|
return normalized;
|
|
4538
5261
|
}
|
|
4539
5262
|
function predicateRequiresUuidQueryFallback(column, value) {
|
|
4540
|
-
if (!
|
|
5263
|
+
if (!isRecord8(value)) {
|
|
4541
5264
|
return shouldUseUuidTextComparison(column, value);
|
|
4542
5265
|
}
|
|
4543
5266
|
const eqValue = value.eq;
|
|
@@ -4555,7 +5278,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
|
|
|
4555
5278
|
return false;
|
|
4556
5279
|
}
|
|
4557
5280
|
function findManyAstWhereRequiresLegacyTransport(where) {
|
|
4558
|
-
if (!where || !
|
|
5281
|
+
if (!where || !isRecord8(where)) {
|
|
4559
5282
|
return false;
|
|
4560
5283
|
}
|
|
4561
5284
|
for (const [key, value] of Object.entries(where)) {
|
|
@@ -4570,7 +5293,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
|
|
|
4570
5293
|
}
|
|
4571
5294
|
continue;
|
|
4572
5295
|
}
|
|
4573
|
-
if (key === "not" &&
|
|
5296
|
+
if (key === "not" && isRecord8(value)) {
|
|
4574
5297
|
if (booleanOperandRequiresUuidQueryFallback(value)) {
|
|
4575
5298
|
return true;
|
|
4576
5299
|
}
|
|
@@ -4772,7 +5495,7 @@ async function executeExperimentalRead(experimental, runner) {
|
|
|
4772
5495
|
throw error;
|
|
4773
5496
|
}
|
|
4774
5497
|
}
|
|
4775
|
-
function
|
|
5498
|
+
function isRecord9(value) {
|
|
4776
5499
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4777
5500
|
}
|
|
4778
5501
|
function firstNonEmptyString2(...values) {
|
|
@@ -4784,8 +5507,8 @@ function firstNonEmptyString2(...values) {
|
|
|
4784
5507
|
return void 0;
|
|
4785
5508
|
}
|
|
4786
5509
|
function resolveStructuredErrorPayload2(raw) {
|
|
4787
|
-
if (!
|
|
4788
|
-
return
|
|
5510
|
+
if (!isRecord9(raw)) return null;
|
|
5511
|
+
return isRecord9(raw.error) ? raw.error : raw;
|
|
4789
5512
|
}
|
|
4790
5513
|
function resolveStructuredErrorDetails(payload, message) {
|
|
4791
5514
|
if (!payload || !("details" in payload)) {
|
|
@@ -4801,7 +5524,7 @@ function resolveStructuredErrorDetails(payload, message) {
|
|
|
4801
5524
|
return details;
|
|
4802
5525
|
}
|
|
4803
5526
|
function createResultError(response, result, normalized) {
|
|
4804
|
-
const rawRecord =
|
|
5527
|
+
const rawRecord = isRecord9(response.raw) ? response.raw : null;
|
|
4805
5528
|
const payload = resolveStructuredErrorPayload2(response.raw);
|
|
4806
5529
|
const message = firstNonEmptyString2(
|
|
4807
5530
|
response.error,
|
|
@@ -6569,7 +7292,7 @@ function resolveNullishValue(mode) {
|
|
|
6569
7292
|
if (mode === "null") return null;
|
|
6570
7293
|
return "";
|
|
6571
7294
|
}
|
|
6572
|
-
function
|
|
7295
|
+
function isRecord10(value) {
|
|
6573
7296
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6574
7297
|
}
|
|
6575
7298
|
function isNullableColumn(model, key) {
|
|
@@ -6578,7 +7301,7 @@ function isNullableColumn(model, key) {
|
|
|
6578
7301
|
}
|
|
6579
7302
|
function toModelFormDefaults(model, values, options) {
|
|
6580
7303
|
const source = values;
|
|
6581
|
-
if (!
|
|
7304
|
+
if (!isRecord10(source)) {
|
|
6582
7305
|
return {};
|
|
6583
7306
|
}
|
|
6584
7307
|
const mode = options?.nullishMode ?? "empty-string";
|
|
@@ -6918,15 +7641,15 @@ function readCookieFromHeaders(headers, name) {
|
|
|
6918
7641
|
}
|
|
6919
7642
|
return parseCookies(cookieHeader).get(name);
|
|
6920
7643
|
}
|
|
6921
|
-
function
|
|
7644
|
+
function isRecord11(value) {
|
|
6922
7645
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6923
7646
|
}
|
|
6924
7647
|
function resolveSessionCandidate(value) {
|
|
6925
|
-
if (!
|
|
7648
|
+
if (!isRecord11(value)) {
|
|
6926
7649
|
return null;
|
|
6927
7650
|
}
|
|
6928
|
-
const session =
|
|
6929
|
-
const user =
|
|
7651
|
+
const session = isRecord11(value.session) ? value.session : void 0;
|
|
7652
|
+
const user = isRecord11(value.user) ? value.user : void 0;
|
|
6930
7653
|
if (session && typeof session.token === "string" && session.token.length > 0 && user) {
|
|
6931
7654
|
return {
|
|
6932
7655
|
session,
|
|
@@ -6936,7 +7659,7 @@ function resolveSessionCandidate(value) {
|
|
|
6936
7659
|
return null;
|
|
6937
7660
|
}
|
|
6938
7661
|
function inferSessionPair(returned) {
|
|
6939
|
-
return resolveSessionCandidate(returned) ?? (
|
|
7662
|
+
return resolveSessionCandidate(returned) ?? (isRecord11(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord11(returned) ? resolveSessionCandidate(returned.session) : null);
|
|
6940
7663
|
}
|
|
6941
7664
|
function resolveResponseHeaders(ctx) {
|
|
6942
7665
|
if (ctx.context.responseHeaders instanceof Headers) {
|