@xylex-group/athena 2.12.1 → 2.14.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/LICENSE +21 -21
- package/README.md +1190 -1184
- package/bin/athena-js.js +104 -76
- package/dist/admin.cjs +45 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +64 -0
- package/dist/admin.d.ts +64 -0
- package/dist/admin.js +41 -0
- package/dist/admin.js.map +1 -0
- package/dist/athena-auth-url-oLux_57a.d.cts +377 -0
- package/dist/athena-auth-url-oLux_57a.d.ts +377 -0
- package/dist/browser.cjs +580 -96
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +12 -10
- package/dist/browser.d.ts +12 -10
- package/dist/browser.js +580 -96
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +690 -91
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +14 -5
- package/dist/cli/index.d.ts +14 -5
- package/dist/cli/index.js +690 -92
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-CMtx5P4D.d.cts → client-uthENhaf.d.ts} +346 -1488
- package/dist/{client-Dre8H24u.d.ts → client-wU2J9yqb.d.cts} +346 -1488
- package/dist/cookies.cjs +18 -0
- package/dist/cookies.cjs.map +1 -1
- package/dist/cookies.d.cts +2 -1
- package/dist/cookies.d.ts +2 -1
- package/dist/cookies.js +17 -1
- package/dist/cookies.js.map +1 -1
- package/dist/{index-CVcQCGyG.d.ts → index-CFL9xbFR.d.cts} +2 -0
- package/dist/{index-CVcQCGyG.d.cts → index-UKJpunc6.d.ts} +2 -0
- package/dist/index.cjs +648 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/index.js +648 -97
- package/dist/index.js.map +1 -1
- package/dist/{model-form-DfTi8-D1.d.cts → model-form-BE1_Bmdd.d.cts} +2 -2
- package/dist/{model-form-CU0mWrF9.d.ts → model-form-DcH3R7WD.d.ts} +2 -2
- package/dist/{module-DBGmbIuh.d.ts → module-Ca3_OQqR.d.ts} +12 -9
- package/dist/{module-GoijrBXV.d.cts → module-DFGZXCtt.d.cts} +12 -9
- package/dist/next/client.cjs +992 -89
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +7 -4
- package/dist/next/client.d.ts +7 -4
- package/dist/next/client.js +970 -90
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +832 -89
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +81 -5
- package/dist/next/server.d.ts +81 -5
- package/dist/next/server.js +820 -90
- package/dist/next/server.js.map +1 -1
- package/dist/organization.cjs +72 -0
- package/dist/organization.cjs.map +1 -0
- package/dist/organization.d.cts +43 -0
- package/dist/organization.d.ts +43 -0
- package/dist/organization.js +70 -0
- package/dist/organization.js.map +1 -0
- package/dist/payload-BbSCmILD.d.ts +219 -0
- package/dist/payload-zXIwKTQf.d.cts +219 -0
- package/dist/{pipeline-c7Gdm0qv.d.cts → pipeline-CwQoD5G9.d.cts} +1 -1
- package/dist/{pipeline-DrjU2vNA.d.ts → pipeline-DqwehoQV.d.ts} +1 -1
- package/dist/react.cjs +2 -13
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +26 -7
- package/dist/react.d.ts +26 -7
- package/dist/react.js +2 -13
- package/dist/react.js.map +1 -1
- package/dist/session-cookie-detection-BqOp9mO6.d.cts +46 -0
- package/dist/session-cookie-detection-BqOp9mO6.d.ts +46 -0
- package/dist/social-providers.cjs +4198 -0
- package/dist/social-providers.cjs.map +1 -0
- package/dist/social-providers.d.cts +4948 -0
- package/dist/social-providers.d.ts +4948 -0
- package/dist/social-providers.js +4126 -0
- package/dist/social-providers.js.map +1 -0
- package/dist/{types-kPaHUqUa.d.ts → types-6H575ITc.d.cts} +50 -2
- package/dist/{types-DRRb0Fd0.d.ts → types-C1swabT5.d.ts} +3 -3
- package/dist/{types-Bez4HSbI.d.cts → types-CD6K05JQ.d.ts} +50 -2
- package/dist/{types-BRUHGXo2.d.ts → types-YQUR7wu0.d.cts} +3 -3
- package/dist/{types-BRUHGXo2.d.cts → types-YQUR7wu0.d.ts} +3 -3
- package/dist/{types-BLizCLd1.d.cts → types-dHnjluBC.d.cts} +3 -3
- package/dist/types-eAKAh71s.d.cts +1476 -0
- package/dist/types-eAKAh71s.d.ts +1476 -0
- package/dist/utils.cjs +438 -15
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +76 -11
- package/dist/utils.d.ts +76 -11
- package/dist/utils.js +390 -16
- package/dist/utils.js.map +1 -1
- package/package.json +29 -1
- package/dist/shared-DZSGAmXs.d.cts +0 -35
- package/dist/shared-MMnVBBfy.d.ts +0 -35
package/dist/browser.js
CHANGED
|
@@ -800,7 +800,7 @@ var getCookieCache = async (request2, config) => {
|
|
|
800
800
|
|
|
801
801
|
// src/utils/athena-request-headers.ts
|
|
802
802
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
803
|
-
var API_KEY_HEADER_CANDIDATES = ["X-Api-Key", "x-api-key", "apikey"];
|
|
803
|
+
var API_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key", "X-Api-Key", "x-api-key", "apikey"];
|
|
804
804
|
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
805
805
|
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
806
806
|
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
@@ -902,17 +902,6 @@ function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, ex
|
|
|
902
902
|
});
|
|
903
903
|
}
|
|
904
904
|
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
905
|
-
if (apiKey) {
|
|
906
|
-
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
907
|
-
headers.apikey = apiKey;
|
|
908
|
-
}
|
|
909
|
-
if (!Object.hasOwn(headers, "x-api-key")) {
|
|
910
|
-
headers["x-api-key"] = apiKey;
|
|
911
|
-
}
|
|
912
|
-
if (!Object.hasOwn(headers, "X-Api-Key")) {
|
|
913
|
-
headers["X-Api-Key"] = apiKey;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
905
|
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
917
906
|
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
918
907
|
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
@@ -1038,7 +1027,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
1038
1027
|
|
|
1039
1028
|
// package.json
|
|
1040
1029
|
var package_default = {
|
|
1041
|
-
version: "2.
|
|
1030
|
+
version: "2.14.0"
|
|
1042
1031
|
};
|
|
1043
1032
|
|
|
1044
1033
|
// src/sdk-version.ts
|
|
@@ -3741,39 +3730,224 @@ async function withRetry(config, fn) {
|
|
|
3741
3730
|
throw new Error("withRetry reached an unexpected state");
|
|
3742
3731
|
}
|
|
3743
3732
|
|
|
3744
|
-
// src/
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3733
|
+
// src/storage/direct-upload.ts
|
|
3734
|
+
var SERVICE = "s3";
|
|
3735
|
+
var TERMINATOR = "aws4_request";
|
|
3736
|
+
async function putDirectStorageUploadBody(config, bucket, storageKey, body, uploadHeaders, signal, onProgress) {
|
|
3737
|
+
if (config.bucket && bucket && config.bucket !== bucket) {
|
|
3738
|
+
throw new Error(
|
|
3739
|
+
`athena.storage.file.upload direct mode bucket mismatch: configured ${config.bucket} but Athena returned ${bucket}`
|
|
3740
|
+
);
|
|
3741
|
+
}
|
|
3742
|
+
const target = createDirectUploadTarget(config, bucket, storageKey);
|
|
3743
|
+
const bytes = await bodyToArrayBuffer(body);
|
|
3744
|
+
const payloadHash = await sha256Hex(bytes);
|
|
3745
|
+
const headers = new Headers(uploadHeaders);
|
|
3746
|
+
if (isBlobBody(body) && body.type && !headers.has("Content-Type")) {
|
|
3747
|
+
headers.set("Content-Type", body.type);
|
|
3748
|
+
}
|
|
3749
|
+
const signed = await signDirectUploadRequest(config, target, headers, payloadHash);
|
|
3750
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
3751
|
+
return putWithXhr(target.toString(), signed, body, signal, onProgress);
|
|
3752
|
+
}
|
|
3753
|
+
onProgress({ loaded: 0 });
|
|
3754
|
+
const response = await fetch(target, {
|
|
3755
|
+
method: "PUT",
|
|
3756
|
+
headers: signed.requestHeaders,
|
|
3757
|
+
body,
|
|
3758
|
+
signal
|
|
3759
|
+
});
|
|
3760
|
+
if (!response.ok) {
|
|
3761
|
+
throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
|
|
3762
|
+
}
|
|
3763
|
+
onProgress({ loaded: bytes.byteLength });
|
|
3764
|
+
return response;
|
|
3765
|
+
}
|
|
3766
|
+
function createDirectUploadTarget(config, bucket, storageKey) {
|
|
3767
|
+
const resolvedBucket = config.bucket ?? bucket;
|
|
3768
|
+
if (!resolvedBucket?.trim()) {
|
|
3769
|
+
throw new Error(
|
|
3770
|
+
"athena.storage.file.upload direct mode requires a bucket in experimental.directStorageUpload or the server upload response"
|
|
3771
|
+
);
|
|
3772
|
+
}
|
|
3773
|
+
if (!storageKey.trim()) {
|
|
3774
|
+
throw new Error("athena.storage.file.upload direct mode requires a storage key");
|
|
3775
|
+
}
|
|
3776
|
+
let endpoint;
|
|
3777
|
+
try {
|
|
3778
|
+
endpoint = new URL(config.endpoint);
|
|
3779
|
+
} catch (error) {
|
|
3780
|
+
throw new Error(
|
|
3781
|
+
`athena.storage.file.upload direct mode received an invalid endpoint: ${error instanceof Error ? error.message : String(error)}`
|
|
3782
|
+
);
|
|
3783
|
+
}
|
|
3784
|
+
if (endpoint.search || endpoint.hash) {
|
|
3785
|
+
throw new Error("athena.storage.file.upload direct mode endpoint must not contain a query or hash");
|
|
3786
|
+
}
|
|
3787
|
+
const endpointPath = endpoint.pathname.replace(/\/+$/, "");
|
|
3788
|
+
const pathParts = config.forcePathStyle === false ? [endpointPath, storageKey] : [endpointPath, resolvedBucket, storageKey];
|
|
3789
|
+
if (config.forcePathStyle === false) {
|
|
3790
|
+
endpoint.hostname = `${resolvedBucket}.${endpoint.hostname}`;
|
|
3791
|
+
}
|
|
3792
|
+
endpoint.pathname = pathParts.filter(Boolean).flatMap((part) => part.split("/")).map(awsEncode).join("/").replace(/^([^/])/, "/$1");
|
|
3793
|
+
return endpoint;
|
|
3794
|
+
}
|
|
3795
|
+
async function signDirectUploadRequest(config, target, inputHeaders, payloadHash) {
|
|
3796
|
+
const accessKeyId = config.accessKeyId.trim();
|
|
3797
|
+
const secretAccessKey = config.secretAccessKey.trim();
|
|
3798
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
3799
|
+
throw new Error(
|
|
3800
|
+
"athena.storage.file.upload direct mode requires accessKeyId and secretAccessKey"
|
|
3801
|
+
);
|
|
3802
|
+
}
|
|
3803
|
+
const now = /* @__PURE__ */ new Date();
|
|
3804
|
+
const amzDate = formatAmzDate(now);
|
|
3805
|
+
const shortDate = amzDate.slice(0, 8);
|
|
3806
|
+
const region = config.region?.trim() || "auto";
|
|
3807
|
+
const headers = {};
|
|
3808
|
+
inputHeaders.forEach((value, key) => {
|
|
3809
|
+
if (key.toLowerCase() !== "authorization" && key.toLowerCase() !== "host") {
|
|
3810
|
+
headers[key.toLowerCase()] = value.trim().replace(/\s+/g, " ");
|
|
3811
|
+
}
|
|
3812
|
+
});
|
|
3813
|
+
headers["x-amz-content-sha256"] = payloadHash;
|
|
3814
|
+
headers["x-amz-date"] = amzDate;
|
|
3815
|
+
if (config.sessionToken?.trim()) {
|
|
3816
|
+
headers["x-amz-security-token"] = config.sessionToken.trim();
|
|
3817
|
+
}
|
|
3818
|
+
const canonicalHeaders = Object.keys(headers).sort().map((key) => `${key}:${headers[key]}
|
|
3819
|
+
`).join("");
|
|
3820
|
+
const signedHeaders = Object.keys(headers).sort().join(";");
|
|
3821
|
+
const canonicalRequest = [
|
|
3822
|
+
"PUT",
|
|
3823
|
+
target.pathname,
|
|
3824
|
+
"",
|
|
3825
|
+
`host:${target.host}
|
|
3826
|
+
${canonicalHeaders}`,
|
|
3827
|
+
`host;${signedHeaders}`,
|
|
3828
|
+
payloadHash
|
|
3829
|
+
].join("\n");
|
|
3830
|
+
const credentialScope = `${shortDate}/${region}/${SERVICE}/${TERMINATOR}`;
|
|
3831
|
+
const stringToSign = [
|
|
3832
|
+
"AWS4-HMAC-SHA256",
|
|
3833
|
+
amzDate,
|
|
3834
|
+
credentialScope,
|
|
3835
|
+
await sha256Hex(canonicalRequest)
|
|
3836
|
+
].join("\n");
|
|
3837
|
+
const dateKey = await hmac(`AWS4${secretAccessKey}`, shortDate);
|
|
3838
|
+
const regionKey = await hmac(dateKey, region);
|
|
3839
|
+
const serviceKey = await hmac(regionKey, SERVICE);
|
|
3840
|
+
const signingKey = await hmac(serviceKey, TERMINATOR);
|
|
3841
|
+
const signature = await hmacHex(signingKey, stringToSign);
|
|
3842
|
+
headers.authorization = `AWS4-HMAC-SHA256 Credential=${accessKeyId}/${credentialScope}, SignedHeaders=host;${signedHeaders}, Signature=${signature}`;
|
|
3843
|
+
return { requestHeaders: headers };
|
|
3844
|
+
}
|
|
3845
|
+
async function putWithXhr(url, signed, body, signal, onProgress) {
|
|
3846
|
+
const Xhr = XMLHttpRequest;
|
|
3847
|
+
if (Xhr === void 0) {
|
|
3848
|
+
return Promise.reject(new Error("athena.storage.file.upload direct mode requires XMLHttpRequest in this runtime"));
|
|
3849
|
+
}
|
|
3850
|
+
return new Promise((resolve, reject) => {
|
|
3851
|
+
const xhr = new Xhr();
|
|
3852
|
+
const abort = () => xhr.abort();
|
|
3853
|
+
xhr.open("PUT", url);
|
|
3854
|
+
Object.entries(signed.requestHeaders).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
3855
|
+
xhr.upload.onprogress = (event) => onProgress({ loaded: event.loaded });
|
|
3856
|
+
xhr.onload = () => {
|
|
3857
|
+
signal?.removeEventListener("abort", abort);
|
|
3858
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
3859
|
+
reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
|
|
3860
|
+
return;
|
|
3751
3861
|
}
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
}
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3862
|
+
onProgress({ loaded: bodySize(body) });
|
|
3863
|
+
resolve(new Response(xhr.response, {
|
|
3864
|
+
status: xhr.status,
|
|
3865
|
+
statusText: xhr.statusText,
|
|
3866
|
+
headers: parseXhrHeaders(xhr.getAllResponseHeaders())
|
|
3867
|
+
}));
|
|
3868
|
+
};
|
|
3869
|
+
xhr.onerror = () => {
|
|
3870
|
+
signal?.removeEventListener("abort", abort);
|
|
3871
|
+
reject(new Error("athena.storage.file.upload failed with a network error"));
|
|
3872
|
+
};
|
|
3873
|
+
xhr.onabort = () => {
|
|
3874
|
+
signal?.removeEventListener("abort", abort);
|
|
3875
|
+
reject(new DOMException("Upload aborted", "AbortError"));
|
|
3876
|
+
};
|
|
3877
|
+
if (signal) {
|
|
3878
|
+
if (signal.aborted) {
|
|
3879
|
+
abort();
|
|
3880
|
+
return;
|
|
3881
|
+
}
|
|
3882
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
3771
3883
|
}
|
|
3772
|
-
|
|
3773
|
-
|
|
3884
|
+
xhr.send(body);
|
|
3885
|
+
});
|
|
3886
|
+
}
|
|
3887
|
+
function isBlobBody(body) {
|
|
3888
|
+
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
3889
|
+
}
|
|
3890
|
+
async function bodyToArrayBuffer(body) {
|
|
3891
|
+
if (isBlobBody(body)) return body.arrayBuffer();
|
|
3892
|
+
if (body instanceof ArrayBuffer) return body;
|
|
3893
|
+
if (ArrayBuffer.isView(body)) {
|
|
3894
|
+
return body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
3895
|
+
}
|
|
3896
|
+
throw new Error("athena.storage.file.upload direct mode does not support ReadableStream bodies");
|
|
3897
|
+
}
|
|
3898
|
+
function bodySize(body) {
|
|
3899
|
+
if (isBlobBody(body)) return body.size;
|
|
3900
|
+
if (body instanceof ArrayBuffer) return body.byteLength;
|
|
3901
|
+
if (ArrayBuffer.isView(body)) return body.byteLength;
|
|
3902
|
+
return 0;
|
|
3903
|
+
}
|
|
3904
|
+
function awsEncode(value) {
|
|
3905
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
3906
|
+
}
|
|
3907
|
+
function formatAmzDate(date) {
|
|
3908
|
+
return date.toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
3909
|
+
}
|
|
3910
|
+
async function sha256Hex(value) {
|
|
3911
|
+
const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
|
|
3912
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
3913
|
+
return toHex(new Uint8Array(digest));
|
|
3914
|
+
}
|
|
3915
|
+
async function hmac(key, value) {
|
|
3916
|
+
const keyBytes = typeof key === "string" ? new TextEncoder().encode(key) : key;
|
|
3917
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
3918
|
+
"raw",
|
|
3919
|
+
keyBytes,
|
|
3920
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
3921
|
+
false,
|
|
3922
|
+
["sign"]
|
|
3923
|
+
);
|
|
3924
|
+
return crypto.subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(value));
|
|
3925
|
+
}
|
|
3926
|
+
async function hmacHex(key, value) {
|
|
3927
|
+
return toHex(new Uint8Array(await hmac(key, value)));
|
|
3928
|
+
}
|
|
3929
|
+
function toHex(bytes) {
|
|
3930
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3931
|
+
}
|
|
3932
|
+
function parseXhrHeaders(rawHeaders) {
|
|
3933
|
+
const headers = new Headers();
|
|
3934
|
+
rawHeaders.trim().split(/[\r\n]+/).forEach((line) => {
|
|
3935
|
+
const separator = line.indexOf(":");
|
|
3936
|
+
if (separator > 0) {
|
|
3937
|
+
headers.set(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
3938
|
+
}
|
|
3939
|
+
});
|
|
3940
|
+
return headers;
|
|
3774
3941
|
}
|
|
3775
3942
|
|
|
3776
3943
|
// src/storage/file.ts
|
|
3944
|
+
function mergeUploadHeaders(serverHeaders, inputHeaders) {
|
|
3945
|
+
const headers = { ...serverHeaders };
|
|
3946
|
+
new Headers(inputHeaders).forEach((value, key) => {
|
|
3947
|
+
headers[key] = value;
|
|
3948
|
+
});
|
|
3949
|
+
return headers;
|
|
3950
|
+
}
|
|
3777
3951
|
function createStorageFileModule(base, config = {}) {
|
|
3778
3952
|
const upload = async (input, options) => {
|
|
3779
3953
|
const sources = normalizeUploadSources(input);
|
|
@@ -3809,16 +3983,25 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3809
3983
|
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
3810
3984
|
const request2 = uploadRequests[index];
|
|
3811
3985
|
const uploadUrl = uploadUrls[index];
|
|
3812
|
-
const
|
|
3986
|
+
const aggregateProgress = (progress) => {
|
|
3987
|
+
aggregateLoaded[index] = progress.loaded;
|
|
3988
|
+
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
3989
|
+
};
|
|
3990
|
+
const response = config.directUpload ? await putDirectStorageUploadBody(
|
|
3991
|
+
config.directUpload,
|
|
3992
|
+
uploadUrl.upload.bucket,
|
|
3993
|
+
uploadUrl.upload.storage_key,
|
|
3994
|
+
request2.source.source,
|
|
3995
|
+
mergeUploadHeaders(uploadUrl.upload.headers ?? {}, input.uploadHeaders),
|
|
3996
|
+
options?.signal,
|
|
3997
|
+
aggregateProgress
|
|
3998
|
+
) : await putUploadBody(
|
|
3813
3999
|
uploadUrl.upload.url,
|
|
3814
4000
|
uploadUrl.upload.headers ?? {},
|
|
3815
4001
|
request2.source,
|
|
3816
4002
|
input,
|
|
3817
4003
|
options,
|
|
3818
|
-
|
|
3819
|
-
aggregateLoaded[index] = progress.loaded;
|
|
3820
|
-
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
3821
|
-
}
|
|
4004
|
+
aggregateProgress
|
|
3822
4005
|
);
|
|
3823
4006
|
uploaded.push({
|
|
3824
4007
|
file: uploadUrl.file,
|
|
@@ -3969,7 +4152,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
|
|
|
3969
4152
|
resolve(new Response(xhr.response, {
|
|
3970
4153
|
status: xhr.status,
|
|
3971
4154
|
statusText: xhr.statusText,
|
|
3972
|
-
headers:
|
|
4155
|
+
headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
|
|
3973
4156
|
}));
|
|
3974
4157
|
};
|
|
3975
4158
|
xhr.onerror = () => {
|
|
@@ -4107,7 +4290,7 @@ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoad
|
|
|
4107
4290
|
function sum(values) {
|
|
4108
4291
|
return values.reduce((total, value) => total + value, 0);
|
|
4109
4292
|
}
|
|
4110
|
-
function
|
|
4293
|
+
function parseXhrHeaders2(raw) {
|
|
4111
4294
|
const headers = new Headers();
|
|
4112
4295
|
for (const line of raw.trim().split(/[\r\n]+/)) {
|
|
4113
4296
|
const index = line.indexOf(":");
|
|
@@ -4124,6 +4307,230 @@ function isRecord5(value) {
|
|
|
4124
4307
|
return Boolean(value) && typeof value === "object";
|
|
4125
4308
|
}
|
|
4126
4309
|
|
|
4310
|
+
// src/storage/backup.ts
|
|
4311
|
+
function backupError(message, status, endpoint, method, cause, raw) {
|
|
4312
|
+
const error = new Error(message);
|
|
4313
|
+
error.name = "AthenaStorageError";
|
|
4314
|
+
error.code = status === 0 ? "NETWORK_ERROR" : "HTTP_ERROR";
|
|
4315
|
+
error.status = status;
|
|
4316
|
+
error.endpoint = endpoint;
|
|
4317
|
+
error.method = method;
|
|
4318
|
+
error.cause = cause;
|
|
4319
|
+
error.raw = raw;
|
|
4320
|
+
throw error;
|
|
4321
|
+
}
|
|
4322
|
+
function isRecord6(value) {
|
|
4323
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4324
|
+
}
|
|
4325
|
+
function asPath(path) {
|
|
4326
|
+
return path;
|
|
4327
|
+
}
|
|
4328
|
+
function appendQuery(path, query) {
|
|
4329
|
+
if (!query) return path;
|
|
4330
|
+
const params = new URLSearchParams();
|
|
4331
|
+
for (const [key, value] of Object.entries(query)) {
|
|
4332
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
4333
|
+
params.set(key, String(value));
|
|
4334
|
+
}
|
|
4335
|
+
const text = params.toString();
|
|
4336
|
+
return text ? `${path}?${text}` : path;
|
|
4337
|
+
}
|
|
4338
|
+
function unwrapAthenaData(payload) {
|
|
4339
|
+
if (isRecord6(payload) && "data" in payload) {
|
|
4340
|
+
return payload.data;
|
|
4341
|
+
}
|
|
4342
|
+
return payload;
|
|
4343
|
+
}
|
|
4344
|
+
function requireKey(key) {
|
|
4345
|
+
const trimmed = key.trim();
|
|
4346
|
+
if (!trimmed || trimmed === "undefined" || trimmed === "null") {
|
|
4347
|
+
backupError("Backup object key is required", 400, "/admin/backups/{key}", "DELETE");
|
|
4348
|
+
}
|
|
4349
|
+
return trimmed;
|
|
4350
|
+
}
|
|
4351
|
+
function resolveMessage(payload, fallback) {
|
|
4352
|
+
if (isRecord6(payload)) {
|
|
4353
|
+
const message = payload.message ?? payload.error ?? payload.details;
|
|
4354
|
+
if (typeof message === "string" && message.trim()) return message.trim();
|
|
4355
|
+
}
|
|
4356
|
+
if (typeof payload === "string" && payload.trim()) return payload.trim();
|
|
4357
|
+
return fallback;
|
|
4358
|
+
}
|
|
4359
|
+
async function callBackupEndpoint(gateway, path, method, payload, options, runtime) {
|
|
4360
|
+
const endpoint = asPath(path);
|
|
4361
|
+
const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
|
|
4362
|
+
const url = buildAthenaGatewayUrl(baseUrl, endpoint);
|
|
4363
|
+
const headers = gateway.buildHeaders(options);
|
|
4364
|
+
const init = {
|
|
4365
|
+
method,
|
|
4366
|
+
headers,
|
|
4367
|
+
signal: options?.signal
|
|
4368
|
+
};
|
|
4369
|
+
if (payload !== void 0 && method !== "GET") {
|
|
4370
|
+
init.body = JSON.stringify(payload);
|
|
4371
|
+
}
|
|
4372
|
+
let response;
|
|
4373
|
+
try {
|
|
4374
|
+
response = await fetch(url, init);
|
|
4375
|
+
} catch (error) {
|
|
4376
|
+
backupError(
|
|
4377
|
+
error instanceof Error ? error.message : "Backup network error",
|
|
4378
|
+
0,
|
|
4379
|
+
path,
|
|
4380
|
+
method,
|
|
4381
|
+
error
|
|
4382
|
+
);
|
|
4383
|
+
}
|
|
4384
|
+
const rawText = await response.text();
|
|
4385
|
+
let parsed = null;
|
|
4386
|
+
if (rawText) {
|
|
4387
|
+
try {
|
|
4388
|
+
parsed = JSON.parse(rawText);
|
|
4389
|
+
} catch {
|
|
4390
|
+
parsed = rawText;
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
if (!response.ok) {
|
|
4394
|
+
backupError(
|
|
4395
|
+
resolveMessage(parsed, `Backup ${method} ${path} failed (${response.status})`),
|
|
4396
|
+
response.status,
|
|
4397
|
+
path,
|
|
4398
|
+
method,
|
|
4399
|
+
void 0,
|
|
4400
|
+
parsed
|
|
4401
|
+
);
|
|
4402
|
+
}
|
|
4403
|
+
return unwrapAthenaData(parsed);
|
|
4404
|
+
}
|
|
4405
|
+
function createStorageBackupModule(gateway, runtimeOptions) {
|
|
4406
|
+
const resolvedBaseUrl = () => String(gateway.baseUrl ?? "").replace(/\/+$/, "");
|
|
4407
|
+
return {
|
|
4408
|
+
async list(query, options) {
|
|
4409
|
+
const path = appendQuery("/admin/backups", {
|
|
4410
|
+
limit: query?.limit ?? 10,
|
|
4411
|
+
client_name: query?.client_name,
|
|
4412
|
+
cursor: query?.cursor ?? void 0
|
|
4413
|
+
});
|
|
4414
|
+
const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
|
|
4415
|
+
const backups = (data?.backups ?? []).map((row) => ({
|
|
4416
|
+
...row,
|
|
4417
|
+
key: row.key ?? row.s3_key
|
|
4418
|
+
}));
|
|
4419
|
+
return {
|
|
4420
|
+
backups,
|
|
4421
|
+
next_cursor: data?.next_cursor ?? null
|
|
4422
|
+
};
|
|
4423
|
+
},
|
|
4424
|
+
async create(input, options) {
|
|
4425
|
+
const data = await callBackupEndpoint(gateway, "/admin/backups", "POST", input, options);
|
|
4426
|
+
return {
|
|
4427
|
+
job_id: Number(data?.job_id ?? 0),
|
|
4428
|
+
client_name: String(data?.client_name ?? input.client_name),
|
|
4429
|
+
status: String(data?.status ?? "pending")
|
|
4430
|
+
};
|
|
4431
|
+
},
|
|
4432
|
+
async restore(key, input, options) {
|
|
4433
|
+
const backupKey = requireKey(key);
|
|
4434
|
+
const path = `/admin/backups/${encodeURIComponent(backupKey)}/restore`;
|
|
4435
|
+
const data = await callBackupEndpoint(gateway, path, "POST", input, options);
|
|
4436
|
+
return {
|
|
4437
|
+
job_id: Number(data?.job_id ?? 0),
|
|
4438
|
+
client_name: String(data?.client_name ?? input.client_name),
|
|
4439
|
+
status: String(data?.status ?? "pending"),
|
|
4440
|
+
key: String(data?.key ?? backupKey)
|
|
4441
|
+
};
|
|
4442
|
+
},
|
|
4443
|
+
async delete(key, options) {
|
|
4444
|
+
const backupKey = requireKey(key);
|
|
4445
|
+
await callBackupEndpoint(
|
|
4446
|
+
gateway,
|
|
4447
|
+
`/admin/backups/${encodeURIComponent(backupKey)}`,
|
|
4448
|
+
"DELETE",
|
|
4449
|
+
void 0,
|
|
4450
|
+
options);
|
|
4451
|
+
},
|
|
4452
|
+
downloadUrl(key, options) {
|
|
4453
|
+
const backupKey = requireKey(key);
|
|
4454
|
+
const base = `${resolvedBaseUrl()}/admin/backups/${encodeURIComponent(backupKey)}/download`;
|
|
4455
|
+
return options?.apiKey ? `${base}?api_key=${encodeURIComponent(options.apiKey)}` : base;
|
|
4456
|
+
},
|
|
4457
|
+
jobs: {
|
|
4458
|
+
async list(query, options) {
|
|
4459
|
+
const path = appendQuery("/admin/backups/jobs", query ?? {});
|
|
4460
|
+
const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
|
|
4461
|
+
if (Array.isArray(data)) return data;
|
|
4462
|
+
if (isRecord6(data) && Array.isArray(data.jobs)) return data.jobs;
|
|
4463
|
+
return [];
|
|
4464
|
+
},
|
|
4465
|
+
async get(jobId, options) {
|
|
4466
|
+
return callBackupEndpoint(
|
|
4467
|
+
gateway,
|
|
4468
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
|
|
4469
|
+
"GET",
|
|
4470
|
+
void 0,
|
|
4471
|
+
options);
|
|
4472
|
+
},
|
|
4473
|
+
async cancel(jobId, options) {
|
|
4474
|
+
return callBackupEndpoint(
|
|
4475
|
+
gateway,
|
|
4476
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}/cancel`,
|
|
4477
|
+
"POST",
|
|
4478
|
+
{},
|
|
4479
|
+
options);
|
|
4480
|
+
},
|
|
4481
|
+
async delete(jobId, options) {
|
|
4482
|
+
await callBackupEndpoint(
|
|
4483
|
+
gateway,
|
|
4484
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
|
|
4485
|
+
"DELETE",
|
|
4486
|
+
void 0,
|
|
4487
|
+
options);
|
|
4488
|
+
},
|
|
4489
|
+
async openObjectUrl(jobId, options) {
|
|
4490
|
+
const data = await callBackupEndpoint(
|
|
4491
|
+
gateway,
|
|
4492
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}/s3-open`,
|
|
4493
|
+
"GET",
|
|
4494
|
+
void 0,
|
|
4495
|
+
options);
|
|
4496
|
+
return String(data?.url ?? "");
|
|
4497
|
+
}
|
|
4498
|
+
},
|
|
4499
|
+
schedules: {
|
|
4500
|
+
async list(options) {
|
|
4501
|
+
const data = await callBackupEndpoint(gateway, "/admin/backups/schedules", "GET", void 0, options);
|
|
4502
|
+
if (Array.isArray(data)) return data;
|
|
4503
|
+
if (isRecord6(data) && Array.isArray(data.schedules)) return data.schedules;
|
|
4504
|
+
return [];
|
|
4505
|
+
},
|
|
4506
|
+
async create(input, options) {
|
|
4507
|
+
return callBackupEndpoint(
|
|
4508
|
+
gateway,
|
|
4509
|
+
"/admin/backups/schedules",
|
|
4510
|
+
"POST",
|
|
4511
|
+
input,
|
|
4512
|
+
options);
|
|
4513
|
+
},
|
|
4514
|
+
async update(id, input, options) {
|
|
4515
|
+
return callBackupEndpoint(
|
|
4516
|
+
gateway,
|
|
4517
|
+
`/admin/backups/schedules/${encodeURIComponent(String(id))}`,
|
|
4518
|
+
"PATCH",
|
|
4519
|
+
input,
|
|
4520
|
+
options);
|
|
4521
|
+
},
|
|
4522
|
+
async delete(id, options) {
|
|
4523
|
+
await callBackupEndpoint(
|
|
4524
|
+
gateway,
|
|
4525
|
+
`/admin/backups/schedules/${encodeURIComponent(String(id))}`,
|
|
4526
|
+
"DELETE",
|
|
4527
|
+
void 0,
|
|
4528
|
+
options);
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
};
|
|
4532
|
+
}
|
|
4533
|
+
|
|
4127
4534
|
// src/storage/module.ts
|
|
4128
4535
|
var storageSdkManifest = {
|
|
4129
4536
|
namespace: "storage",
|
|
@@ -4172,6 +4579,53 @@ var storageSdkManifest = {
|
|
|
4172
4579
|
responseEnvelope: "raw",
|
|
4173
4580
|
responseType: "{ data: S3CredentialListItem[] }"
|
|
4174
4581
|
},
|
|
4582
|
+
{
|
|
4583
|
+
name: "backup.list",
|
|
4584
|
+
method: "GET",
|
|
4585
|
+
path: "/admin/backups",
|
|
4586
|
+
responseEnvelope: "athena",
|
|
4587
|
+
responseType: "StorageBackupListPage",
|
|
4588
|
+
note: "Admin backup archives on server S3/R2 profile"
|
|
4589
|
+
},
|
|
4590
|
+
{
|
|
4591
|
+
name: "backup.create",
|
|
4592
|
+
method: "POST",
|
|
4593
|
+
path: "/admin/backups",
|
|
4594
|
+
requestType: "StorageBackupCreateRequest",
|
|
4595
|
+
responseEnvelope: "athena",
|
|
4596
|
+
responseType: "StorageBackupQueuedJob"
|
|
4597
|
+
},
|
|
4598
|
+
{
|
|
4599
|
+
name: "backup.restore",
|
|
4600
|
+
method: "POST",
|
|
4601
|
+
path: "/admin/backups/{key}/restore",
|
|
4602
|
+
pathParams: ["key"],
|
|
4603
|
+
requestType: "StorageBackupRestoreRequest",
|
|
4604
|
+
responseEnvelope: "athena",
|
|
4605
|
+
responseType: "StorageBackupQueuedJob"
|
|
4606
|
+
},
|
|
4607
|
+
{
|
|
4608
|
+
name: "backup.delete",
|
|
4609
|
+
method: "DELETE",
|
|
4610
|
+
path: "/admin/backups/{key}",
|
|
4611
|
+
pathParams: ["key"],
|
|
4612
|
+
responseEnvelope: "athena",
|
|
4613
|
+
responseType: "void"
|
|
4614
|
+
},
|
|
4615
|
+
{
|
|
4616
|
+
name: "backup.jobs.list",
|
|
4617
|
+
method: "GET",
|
|
4618
|
+
path: "/admin/backups/jobs",
|
|
4619
|
+
responseEnvelope: "athena",
|
|
4620
|
+
responseType: "StorageBackupJob[]"
|
|
4621
|
+
},
|
|
4622
|
+
{
|
|
4623
|
+
name: "backup.schedules.list",
|
|
4624
|
+
method: "GET",
|
|
4625
|
+
path: "/admin/backups/schedules",
|
|
4626
|
+
responseEnvelope: "athena",
|
|
4627
|
+
responseType: "StorageBackupSchedule[]"
|
|
4628
|
+
},
|
|
4175
4629
|
{
|
|
4176
4630
|
name: "createStorageUploadUrl",
|
|
4177
4631
|
method: "POST",
|
|
@@ -4827,7 +5281,7 @@ var AthenaStorageError = class extends Error {
|
|
|
4827
5281
|
};
|
|
4828
5282
|
}
|
|
4829
5283
|
};
|
|
4830
|
-
function
|
|
5284
|
+
function isRecord7(value) {
|
|
4831
5285
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4832
5286
|
}
|
|
4833
5287
|
function causeToString(cause) {
|
|
@@ -4925,7 +5379,7 @@ function parseResponseBody3(rawText, contentType) {
|
|
|
4925
5379
|
return { parsed: rawText, parseFailed: true };
|
|
4926
5380
|
}
|
|
4927
5381
|
}
|
|
4928
|
-
function
|
|
5382
|
+
function appendQuery2(path, query) {
|
|
4929
5383
|
if (!query) return path;
|
|
4930
5384
|
const params = new URLSearchParams();
|
|
4931
5385
|
for (const [key, value] of Object.entries(query)) {
|
|
@@ -4951,7 +5405,7 @@ function withPathParam(path, name, value) {
|
|
|
4951
5405
|
return path.replace(`{${name}}`, encodeURIComponent(value));
|
|
4952
5406
|
}
|
|
4953
5407
|
function resolveErrorMessage3(payload, fallback) {
|
|
4954
|
-
if (
|
|
5408
|
+
if (isRecord7(payload)) {
|
|
4955
5409
|
const message = payload.message ?? payload.error ?? payload.details;
|
|
4956
5410
|
if (typeof message === "string" && message.trim()) {
|
|
4957
5411
|
return message.trim();
|
|
@@ -4963,12 +5417,12 @@ function resolveErrorMessage3(payload, fallback) {
|
|
|
4963
5417
|
return fallback;
|
|
4964
5418
|
}
|
|
4965
5419
|
function resolveErrorHint2(payload) {
|
|
4966
|
-
if (!
|
|
5420
|
+
if (!isRecord7(payload)) return void 0;
|
|
4967
5421
|
const hint = payload.hint ?? payload.suggestion;
|
|
4968
5422
|
return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
|
|
4969
5423
|
}
|
|
4970
5424
|
function resolveErrorCause(payload) {
|
|
4971
|
-
if (!
|
|
5425
|
+
if (!isRecord7(payload)) return void 0;
|
|
4972
5426
|
const cause = payload.cause ?? payload.reason;
|
|
4973
5427
|
return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
|
|
4974
5428
|
}
|
|
@@ -5087,7 +5541,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
|
|
|
5087
5541
|
);
|
|
5088
5542
|
}
|
|
5089
5543
|
if (envelope === "athena") {
|
|
5090
|
-
if (!
|
|
5544
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5091
5545
|
return rejectStorageError(
|
|
5092
5546
|
{
|
|
5093
5547
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5195,7 +5649,7 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
|
|
|
5195
5649
|
runtimeOptions
|
|
5196
5650
|
);
|
|
5197
5651
|
}
|
|
5198
|
-
function
|
|
5652
|
+
function isBlobBody2(body) {
|
|
5199
5653
|
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
5200
5654
|
}
|
|
5201
5655
|
function isReadableStreamBody(body) {
|
|
@@ -5204,7 +5658,7 @@ function isReadableStreamBody(body) {
|
|
|
5204
5658
|
async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
|
|
5205
5659
|
const headers = new Headers(uploadHeaders);
|
|
5206
5660
|
Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
|
|
5207
|
-
if (!headers.has("Content-Type") &&
|
|
5661
|
+
if (!headers.has("Content-Type") && isBlobBody2(body) && body.type) {
|
|
5208
5662
|
headers.set("Content-Type", body.type);
|
|
5209
5663
|
}
|
|
5210
5664
|
const init = {
|
|
@@ -5299,7 +5753,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5299
5753
|
}
|
|
5300
5754
|
delete headers["Content-Type"];
|
|
5301
5755
|
delete headers["content-type"];
|
|
5302
|
-
if (
|
|
5756
|
+
if (isBlobBody2(body) && body.type) {
|
|
5303
5757
|
headers["Content-Type"] = body.type;
|
|
5304
5758
|
}
|
|
5305
5759
|
const requestInit = {
|
|
@@ -5384,7 +5838,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5384
5838
|
runtimeOptions
|
|
5385
5839
|
);
|
|
5386
5840
|
}
|
|
5387
|
-
if (!
|
|
5841
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5388
5842
|
return rejectStorageError(
|
|
5389
5843
|
{
|
|
5390
5844
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5456,14 +5910,14 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5456
5910
|
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
|
|
5457
5911
|
},
|
|
5458
5912
|
getStorageFileUrl(fileId, query, options) {
|
|
5459
|
-
const path =
|
|
5913
|
+
const path = appendQuery2(
|
|
5460
5914
|
withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
|
|
5461
5915
|
query
|
|
5462
5916
|
);
|
|
5463
5917
|
return callAthena2(path, "GET", void 0, options);
|
|
5464
5918
|
},
|
|
5465
5919
|
getStorageFileProxy(fileId, query, options) {
|
|
5466
|
-
const path =
|
|
5920
|
+
const path = appendQuery2(
|
|
5467
5921
|
withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
|
|
5468
5922
|
query
|
|
5469
5923
|
);
|
|
@@ -5487,7 +5941,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5487
5941
|
};
|
|
5488
5942
|
const fileFacade = createStorageFileModule(base, runtimeOptions);
|
|
5489
5943
|
const fileUpload = ((input, options) => {
|
|
5490
|
-
if (
|
|
5944
|
+
if (isRecord7(input) && "files" in input) {
|
|
5491
5945
|
return fileFacade.upload(input, options);
|
|
5492
5946
|
}
|
|
5493
5947
|
return base.createStorageUploadUrl(
|
|
@@ -5549,7 +6003,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5549
6003
|
return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
|
|
5550
6004
|
},
|
|
5551
6005
|
proxyUrl(fileId, query, options) {
|
|
5552
|
-
const path =
|
|
6006
|
+
const path = appendQuery2(
|
|
5553
6007
|
withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
|
|
5554
6008
|
query
|
|
5555
6009
|
);
|
|
@@ -5587,7 +6041,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5587
6041
|
},
|
|
5588
6042
|
retention: {
|
|
5589
6043
|
get(fileId, query, options) {
|
|
5590
|
-
const path =
|
|
6044
|
+
const path = appendQuery2(
|
|
5591
6045
|
withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
|
|
5592
6046
|
query
|
|
5593
6047
|
);
|
|
@@ -5789,6 +6243,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5789
6243
|
return callAthena2("/storage/audit/list", "POST", input, options);
|
|
5790
6244
|
}
|
|
5791
6245
|
};
|
|
6246
|
+
const backup = createStorageBackupModule(gateway);
|
|
5792
6247
|
return {
|
|
5793
6248
|
...base,
|
|
5794
6249
|
credentials,
|
|
@@ -5800,6 +6255,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5800
6255
|
bucket,
|
|
5801
6256
|
multipart,
|
|
5802
6257
|
audit,
|
|
6258
|
+
backup,
|
|
5803
6259
|
delete: file.delete
|
|
5804
6260
|
};
|
|
5805
6261
|
}
|
|
@@ -5849,7 +6305,7 @@ function normalizeWsUrl(value, label) {
|
|
|
5849
6305
|
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
5850
6306
|
return parsed.toString().replace(/\/$/, "");
|
|
5851
6307
|
}
|
|
5852
|
-
function
|
|
6308
|
+
function isRecord8(value) {
|
|
5853
6309
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5854
6310
|
}
|
|
5855
6311
|
function parseResponseBody4(rawText, contentType) {
|
|
@@ -5871,7 +6327,7 @@ function resolveRequestId3(headers) {
|
|
|
5871
6327
|
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
5872
6328
|
}
|
|
5873
6329
|
function resolveErrorMessage4(payload, fallback) {
|
|
5874
|
-
if (
|
|
6330
|
+
if (isRecord8(payload)) {
|
|
5875
6331
|
for (const candidate of [payload.error, payload.message, payload.details]) {
|
|
5876
6332
|
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
5877
6333
|
return candidate.trim();
|
|
@@ -6518,7 +6974,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
6518
6974
|
"ilike",
|
|
6519
6975
|
"is"
|
|
6520
6976
|
]);
|
|
6521
|
-
function
|
|
6977
|
+
function isRecord9(value) {
|
|
6522
6978
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6523
6979
|
}
|
|
6524
6980
|
function isUuidString(value) {
|
|
@@ -6531,7 +6987,7 @@ function shouldUseUuidTextComparison(column, value) {
|
|
|
6531
6987
|
return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
|
|
6532
6988
|
}
|
|
6533
6989
|
function isRelationSelectNode(value) {
|
|
6534
|
-
return
|
|
6990
|
+
return isRecord9(value) && isRecord9(value.select);
|
|
6535
6991
|
}
|
|
6536
6992
|
function normalizeIdentifier(value, label) {
|
|
6537
6993
|
const normalized = value.trim();
|
|
@@ -6587,7 +7043,7 @@ function compileRelationToken(key, node) {
|
|
|
6587
7043
|
return `${prefix}${relationToken}(${nested})`;
|
|
6588
7044
|
}
|
|
6589
7045
|
function compileSelectShape(select) {
|
|
6590
|
-
if (!
|
|
7046
|
+
if (!isRecord9(select)) {
|
|
6591
7047
|
throw new Error("findMany select must be an object");
|
|
6592
7048
|
}
|
|
6593
7049
|
const tokens = [];
|
|
@@ -6611,7 +7067,7 @@ function compileSelectShape(select) {
|
|
|
6611
7067
|
return tokens.join(",");
|
|
6612
7068
|
}
|
|
6613
7069
|
function selectShapeUsesRelationSchema(select) {
|
|
6614
|
-
if (!
|
|
7070
|
+
if (!isRecord9(select)) {
|
|
6615
7071
|
return false;
|
|
6616
7072
|
}
|
|
6617
7073
|
for (const rawValue of Object.values(select)) {
|
|
@@ -6629,7 +7085,7 @@ function selectShapeUsesRelationSchema(select) {
|
|
|
6629
7085
|
}
|
|
6630
7086
|
function compileColumnWhere(column, input) {
|
|
6631
7087
|
const normalizedColumn = normalizeIdentifier(column, "where column");
|
|
6632
|
-
if (!
|
|
7088
|
+
if (!isRecord9(input)) {
|
|
6633
7089
|
return [buildGatewayCondition("eq", normalizedColumn, input)];
|
|
6634
7090
|
}
|
|
6635
7091
|
const conditions = [];
|
|
@@ -6657,7 +7113,7 @@ function compileColumnWhere(column, input) {
|
|
|
6657
7113
|
return conditions;
|
|
6658
7114
|
}
|
|
6659
7115
|
function compileBooleanExpressionTerms(clause, label) {
|
|
6660
|
-
if (!
|
|
7116
|
+
if (!isRecord9(clause)) {
|
|
6661
7117
|
throw new Error(`findMany where.${label} clauses must be objects`);
|
|
6662
7118
|
}
|
|
6663
7119
|
const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
|
|
@@ -6666,7 +7122,7 @@ function compileBooleanExpressionTerms(clause, label) {
|
|
|
6666
7122
|
}
|
|
6667
7123
|
const [rawColumn, rawValue] = entries[0];
|
|
6668
7124
|
const column = normalizeIdentifier(rawColumn, `where.${label} column`);
|
|
6669
|
-
if (!
|
|
7125
|
+
if (!isRecord9(rawValue)) {
|
|
6670
7126
|
return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
|
|
6671
7127
|
}
|
|
6672
7128
|
const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
|
|
@@ -6690,7 +7146,7 @@ function compileWhere(where) {
|
|
|
6690
7146
|
if (where === void 0) {
|
|
6691
7147
|
return void 0;
|
|
6692
7148
|
}
|
|
6693
|
-
if (!
|
|
7149
|
+
if (!isRecord9(where)) {
|
|
6694
7150
|
throw new Error("findMany where must be an object");
|
|
6695
7151
|
}
|
|
6696
7152
|
const conditions = [];
|
|
@@ -6740,7 +7196,7 @@ function compileOrderBy(orderBy) {
|
|
|
6740
7196
|
if (orderBy === void 0) {
|
|
6741
7197
|
return void 0;
|
|
6742
7198
|
}
|
|
6743
|
-
if (!
|
|
7199
|
+
if (!isRecord9(orderBy)) {
|
|
6744
7200
|
throw new Error("findMany orderBy must be an object");
|
|
6745
7201
|
}
|
|
6746
7202
|
if ("column" in orderBy) {
|
|
@@ -6915,11 +7371,11 @@ function toFindManyAstOrder(order) {
|
|
|
6915
7371
|
ascending: order.direction !== "descending"
|
|
6916
7372
|
};
|
|
6917
7373
|
}
|
|
6918
|
-
function
|
|
7374
|
+
function isRecord10(value) {
|
|
6919
7375
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6920
7376
|
}
|
|
6921
7377
|
function normalizeFindManyAstColumnPredicate(value) {
|
|
6922
|
-
if (!
|
|
7378
|
+
if (!isRecord10(value)) {
|
|
6923
7379
|
return {
|
|
6924
7380
|
eq: value
|
|
6925
7381
|
};
|
|
@@ -6943,7 +7399,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
|
|
|
6943
7399
|
return normalized;
|
|
6944
7400
|
}
|
|
6945
7401
|
function normalizeFindManyAstWhere(where) {
|
|
6946
|
-
if (!where || !
|
|
7402
|
+
if (!where || !isRecord10(where)) {
|
|
6947
7403
|
return where;
|
|
6948
7404
|
}
|
|
6949
7405
|
const normalized = {};
|
|
@@ -6957,7 +7413,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6957
7413
|
);
|
|
6958
7414
|
continue;
|
|
6959
7415
|
}
|
|
6960
|
-
if (key === "not" &&
|
|
7416
|
+
if (key === "not" && isRecord10(value)) {
|
|
6961
7417
|
normalized.not = normalizeFindManyAstBooleanOperand(
|
|
6962
7418
|
value
|
|
6963
7419
|
);
|
|
@@ -6968,7 +7424,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6968
7424
|
return normalized;
|
|
6969
7425
|
}
|
|
6970
7426
|
function predicateRequiresUuidQueryFallback(column, value) {
|
|
6971
|
-
if (!
|
|
7427
|
+
if (!isRecord10(value)) {
|
|
6972
7428
|
return shouldUseUuidTextComparison(column, value);
|
|
6973
7429
|
}
|
|
6974
7430
|
const eqValue = value.eq;
|
|
@@ -6986,7 +7442,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
|
|
|
6986
7442
|
return false;
|
|
6987
7443
|
}
|
|
6988
7444
|
function findManyAstWhereRequiresLegacyTransport(where) {
|
|
6989
|
-
if (!where || !
|
|
7445
|
+
if (!where || !isRecord10(where)) {
|
|
6990
7446
|
return false;
|
|
6991
7447
|
}
|
|
6992
7448
|
for (const [key, value] of Object.entries(where)) {
|
|
@@ -7001,7 +7457,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
|
|
|
7001
7457
|
}
|
|
7002
7458
|
continue;
|
|
7003
7459
|
}
|
|
7004
|
-
if (key === "not" &&
|
|
7460
|
+
if (key === "not" && isRecord10(value)) {
|
|
7005
7461
|
if (booleanOperandRequiresUuidQueryFallback(value)) {
|
|
7006
7462
|
return true;
|
|
7007
7463
|
}
|
|
@@ -7627,7 +8083,7 @@ async function executeExperimentalRead(experimental, runner) {
|
|
|
7627
8083
|
throw error;
|
|
7628
8084
|
}
|
|
7629
8085
|
}
|
|
7630
|
-
function
|
|
8086
|
+
function isRecord11(value) {
|
|
7631
8087
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7632
8088
|
}
|
|
7633
8089
|
function firstNonEmptyString2(...values) {
|
|
@@ -7639,8 +8095,8 @@ function firstNonEmptyString2(...values) {
|
|
|
7639
8095
|
return void 0;
|
|
7640
8096
|
}
|
|
7641
8097
|
function resolveStructuredErrorPayload2(raw) {
|
|
7642
|
-
if (!
|
|
7643
|
-
return
|
|
8098
|
+
if (!isRecord11(raw)) return null;
|
|
8099
|
+
return isRecord11(raw.error) ? raw.error : raw;
|
|
7644
8100
|
}
|
|
7645
8101
|
function resolveStructuredErrorDetails(payload, message) {
|
|
7646
8102
|
if (!payload || !("details" in payload)) {
|
|
@@ -7656,7 +8112,7 @@ function resolveStructuredErrorDetails(payload, message) {
|
|
|
7656
8112
|
return details;
|
|
7657
8113
|
}
|
|
7658
8114
|
function createResultError(response, result, normalized) {
|
|
7659
|
-
const rawRecord =
|
|
8115
|
+
const rawRecord = isRecord11(response.raw) ? response.raw : null;
|
|
7660
8116
|
const payload = resolveStructuredErrorPayload2(response.raw);
|
|
7661
8117
|
const message = firstNonEmptyString2(
|
|
7662
8118
|
response.error,
|
|
@@ -9404,7 +9860,30 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9404
9860
|
config.experimental,
|
|
9405
9861
|
queryTracer
|
|
9406
9862
|
);
|
|
9407
|
-
const
|
|
9863
|
+
const untypedDbFrom = from;
|
|
9864
|
+
const db = {
|
|
9865
|
+
from,
|
|
9866
|
+
select(table2, first, second) {
|
|
9867
|
+
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
9868
|
+
return untypedDbFrom(table2).select(void 0, first);
|
|
9869
|
+
}
|
|
9870
|
+
return untypedDbFrom(table2).select(first, second);
|
|
9871
|
+
},
|
|
9872
|
+
insert(table2, values, options) {
|
|
9873
|
+
return Array.isArray(values) ? untypedDbFrom(table2).insert(values, options) : untypedDbFrom(table2).insert(values, options);
|
|
9874
|
+
},
|
|
9875
|
+
upsert(table2, values, options) {
|
|
9876
|
+
return Array.isArray(values) ? untypedDbFrom(table2).upsert(values, options) : untypedDbFrom(table2).upsert(values, options);
|
|
9877
|
+
},
|
|
9878
|
+
update(table2, values, options) {
|
|
9879
|
+
return untypedDbFrom(table2).update(values, options);
|
|
9880
|
+
},
|
|
9881
|
+
delete(table2, options) {
|
|
9882
|
+
return untypedDbFrom(table2).delete(options);
|
|
9883
|
+
},
|
|
9884
|
+
rpc,
|
|
9885
|
+
query
|
|
9886
|
+
};
|
|
9408
9887
|
const chat = createChatModule({
|
|
9409
9888
|
baseUrl: config.chatUrl,
|
|
9410
9889
|
apiKey: config.apiKey,
|
|
@@ -9542,6 +10021,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9542
10021
|
withOptions: storageWithOptions,
|
|
9543
10022
|
storage: createStorageModule(gateway, {
|
|
9544
10023
|
...config.experimental.storage,
|
|
10024
|
+
...config.experimental.directStorageUpload ? { directUpload: config.experimental.directStorageUpload } : {},
|
|
9545
10025
|
...config.storageUrl ? {
|
|
9546
10026
|
baseUrl: config.storageUrl,
|
|
9547
10027
|
stripBasePath: true
|
|
@@ -9555,7 +10035,9 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9555
10035
|
var AthenaClient = class {
|
|
9556
10036
|
/** Create a fluent builder for a strongly-typed Athena SDK client. */
|
|
9557
10037
|
static builder() {
|
|
9558
|
-
return createAthenaClientBuilder(
|
|
10038
|
+
return createAthenaClientBuilder(
|
|
10039
|
+
(config) => createClientFromInput(config)
|
|
10040
|
+
);
|
|
9559
10041
|
}
|
|
9560
10042
|
static fromEnvironment(options = {}) {
|
|
9561
10043
|
const env = options.env ?? process.env;
|
|
@@ -9586,7 +10068,8 @@ var AthenaClient = class {
|
|
|
9586
10068
|
});
|
|
9587
10069
|
}
|
|
9588
10070
|
};
|
|
9589
|
-
function createClient(
|
|
10071
|
+
function createClient(...args) {
|
|
10072
|
+
const [configOrUrl, apiKey, options] = args;
|
|
9590
10073
|
if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
|
|
9591
10074
|
return createClientFromInput({
|
|
9592
10075
|
url: configOrUrl,
|
|
@@ -9625,7 +10108,7 @@ function resolveNullishValue(mode) {
|
|
|
9625
10108
|
if (mode === "null") return null;
|
|
9626
10109
|
return "";
|
|
9627
10110
|
}
|
|
9628
|
-
function
|
|
10111
|
+
function isRecord12(value) {
|
|
9629
10112
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9630
10113
|
}
|
|
9631
10114
|
function isNullableColumn(model, key) {
|
|
@@ -9634,7 +10117,7 @@ function isNullableColumn(model, key) {
|
|
|
9634
10117
|
}
|
|
9635
10118
|
function toModelFormDefaults(model, values, options) {
|
|
9636
10119
|
const source = values;
|
|
9637
|
-
if (!
|
|
10120
|
+
if (!isRecord12(source)) {
|
|
9638
10121
|
return {};
|
|
9639
10122
|
}
|
|
9640
10123
|
const mode = options?.nullishMode ?? "empty-string";
|
|
@@ -10207,7 +10690,8 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
|
|
|
10207
10690
|
fromModel(database, schema, model) {
|
|
10208
10691
|
const modelDef = this.registryNavigator.resolveModel(database, schema, model);
|
|
10209
10692
|
const tableName = this.registryNavigator.resolveTableName(schema, model, modelDef);
|
|
10210
|
-
|
|
10693
|
+
const from = this.baseClient.from;
|
|
10694
|
+
return from(tableName);
|
|
10211
10695
|
}
|
|
10212
10696
|
};
|
|
10213
10697
|
function createTypedClient(registry, url, apiKey, options) {
|
|
@@ -10584,15 +11068,15 @@ function readCookieFromHeaders(headers, name) {
|
|
|
10584
11068
|
}
|
|
10585
11069
|
return parseCookies(cookieHeader).get(name);
|
|
10586
11070
|
}
|
|
10587
|
-
function
|
|
11071
|
+
function isRecord13(value) {
|
|
10588
11072
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
10589
11073
|
}
|
|
10590
11074
|
function resolveSessionCandidate(value) {
|
|
10591
|
-
if (!
|
|
11075
|
+
if (!isRecord13(value)) {
|
|
10592
11076
|
return null;
|
|
10593
11077
|
}
|
|
10594
|
-
const session =
|
|
10595
|
-
const user =
|
|
11078
|
+
const session = isRecord13(value.session) ? value.session : void 0;
|
|
11079
|
+
const user = isRecord13(value.user) ? value.user : void 0;
|
|
10596
11080
|
if (session && typeof session.token === "string" && session.token.length > 0 && user) {
|
|
10597
11081
|
return {
|
|
10598
11082
|
session,
|
|
@@ -10602,7 +11086,7 @@ function resolveSessionCandidate(value) {
|
|
|
10602
11086
|
return null;
|
|
10603
11087
|
}
|
|
10604
11088
|
function inferSessionPair(returned) {
|
|
10605
|
-
return resolveSessionCandidate(returned) ?? (
|
|
11089
|
+
return resolveSessionCandidate(returned) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.session) : null);
|
|
10606
11090
|
}
|
|
10607
11091
|
function resolveResponseHeaders(ctx) {
|
|
10608
11092
|
if (ctx.context.responseHeaders instanceof Headers) {
|