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