@xylex-group/athena 2.13.0 → 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/README.md +1 -1
- package/bin/athena-js.js +0 -0
- package/dist/browser.cjs +552 -52
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +9 -9
- package/dist/browser.d.ts +9 -9
- package/dist/browser.js +552 -52
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +545 -45
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -4
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +545 -45
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-DVOKSYDI.d.ts → client-uthENhaf.d.ts} +289 -92
- package/dist/{client-BJjUwDSg.d.cts → client-wU2J9yqb.d.cts} +289 -92
- package/dist/index.cjs +552 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +552 -52
- package/dist/index.js.map +1 -1
- package/dist/{model-form-Dw4zEL5a.d.cts → model-form-BE1_Bmdd.d.cts} +2 -2
- package/dist/{model-form-yRg71q3H.d.ts → model-form-DcH3R7WD.d.ts} +2 -2
- package/dist/{module-DBteUIob.d.ts → module-Ca3_OQqR.d.ts} +5 -5
- package/dist/{module-yoX49uQC.d.cts → module-DFGZXCtt.d.cts} +5 -5
- package/dist/next/client.cjs +545 -45
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +5 -5
- package/dist/next/client.d.ts +5 -5
- package/dist/next/client.js +545 -45
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +545 -45
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +5 -5
- package/dist/next/server.d.ts +5 -5
- package/dist/next/server.js +545 -45
- package/dist/next/server.js.map +1 -1
- package/dist/{payload-DEOWN_oo.d.ts → payload-BbSCmILD.d.ts} +2 -2
- package/dist/{payload-BzVbUgY_.d.cts → payload-zXIwKTQf.d.cts} +2 -2
- package/dist/{pipeline-Dwck-wZO.d.cts → pipeline-CwQoD5G9.d.cts} +1 -1
- package/dist/{pipeline-Bj6RWt1A.d.ts → pipeline-DqwehoQV.d.ts} +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +5 -5
- package/dist/react.d.ts +5 -5
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/social-providers.cjs +24 -15
- package/dist/social-providers.cjs.map +1 -1
- package/dist/social-providers.js +24 -15
- package/dist/social-providers.js.map +1 -1
- package/dist/{types-BU8uJH_b.d.cts → types-6H575ITc.d.cts} +1 -1
- package/dist/{types-DPgejxYC.d.ts → types-C1swabT5.d.ts} +2 -2
- package/dist/{types-BRP7sfSF.d.ts → types-CD6K05JQ.d.ts} +1 -1
- package/dist/{types-CH78O90i.d.cts → types-YQUR7wu0.d.cts} +1 -1
- package/dist/{types-CH78O90i.d.ts → types-YQUR7wu0.d.ts} +1 -1
- package/dist/{types-CjC9_5ZQ.d.cts → types-dHnjluBC.d.cts} +2 -2
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +22 -21
package/dist/index.cjs
CHANGED
|
@@ -1033,7 +1033,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
1033
1033
|
|
|
1034
1034
|
// package.json
|
|
1035
1035
|
var package_default = {
|
|
1036
|
-
version: "2.
|
|
1036
|
+
version: "2.14.0"
|
|
1037
1037
|
};
|
|
1038
1038
|
|
|
1039
1039
|
// src/sdk-version.ts
|
|
@@ -3736,7 +3736,224 @@ async function withRetry(config, fn) {
|
|
|
3736
3736
|
throw new Error("withRetry reached an unexpected state");
|
|
3737
3737
|
}
|
|
3738
3738
|
|
|
3739
|
+
// src/storage/direct-upload.ts
|
|
3740
|
+
var SERVICE = "s3";
|
|
3741
|
+
var TERMINATOR = "aws4_request";
|
|
3742
|
+
async function putDirectStorageUploadBody(config, bucket, storageKey, body, uploadHeaders, signal, onProgress) {
|
|
3743
|
+
if (config.bucket && bucket && config.bucket !== bucket) {
|
|
3744
|
+
throw new Error(
|
|
3745
|
+
`athena.storage.file.upload direct mode bucket mismatch: configured ${config.bucket} but Athena returned ${bucket}`
|
|
3746
|
+
);
|
|
3747
|
+
}
|
|
3748
|
+
const target = createDirectUploadTarget(config, bucket, storageKey);
|
|
3749
|
+
const bytes = await bodyToArrayBuffer(body);
|
|
3750
|
+
const payloadHash = await sha256Hex(bytes);
|
|
3751
|
+
const headers = new Headers(uploadHeaders);
|
|
3752
|
+
if (isBlobBody(body) && body.type && !headers.has("Content-Type")) {
|
|
3753
|
+
headers.set("Content-Type", body.type);
|
|
3754
|
+
}
|
|
3755
|
+
const signed = await signDirectUploadRequest(config, target, headers, payloadHash);
|
|
3756
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
3757
|
+
return putWithXhr(target.toString(), signed, body, signal, onProgress);
|
|
3758
|
+
}
|
|
3759
|
+
onProgress({ loaded: 0 });
|
|
3760
|
+
const response = await fetch(target, {
|
|
3761
|
+
method: "PUT",
|
|
3762
|
+
headers: signed.requestHeaders,
|
|
3763
|
+
body,
|
|
3764
|
+
signal
|
|
3765
|
+
});
|
|
3766
|
+
if (!response.ok) {
|
|
3767
|
+
throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
|
|
3768
|
+
}
|
|
3769
|
+
onProgress({ loaded: bytes.byteLength });
|
|
3770
|
+
return response;
|
|
3771
|
+
}
|
|
3772
|
+
function createDirectUploadTarget(config, bucket, storageKey) {
|
|
3773
|
+
const resolvedBucket = config.bucket ?? bucket;
|
|
3774
|
+
if (!resolvedBucket?.trim()) {
|
|
3775
|
+
throw new Error(
|
|
3776
|
+
"athena.storage.file.upload direct mode requires a bucket in experimental.directStorageUpload or the server upload response"
|
|
3777
|
+
);
|
|
3778
|
+
}
|
|
3779
|
+
if (!storageKey.trim()) {
|
|
3780
|
+
throw new Error("athena.storage.file.upload direct mode requires a storage key");
|
|
3781
|
+
}
|
|
3782
|
+
let endpoint;
|
|
3783
|
+
try {
|
|
3784
|
+
endpoint = new URL(config.endpoint);
|
|
3785
|
+
} catch (error) {
|
|
3786
|
+
throw new Error(
|
|
3787
|
+
`athena.storage.file.upload direct mode received an invalid endpoint: ${error instanceof Error ? error.message : String(error)}`
|
|
3788
|
+
);
|
|
3789
|
+
}
|
|
3790
|
+
if (endpoint.search || endpoint.hash) {
|
|
3791
|
+
throw new Error("athena.storage.file.upload direct mode endpoint must not contain a query or hash");
|
|
3792
|
+
}
|
|
3793
|
+
const endpointPath = endpoint.pathname.replace(/\/+$/, "");
|
|
3794
|
+
const pathParts = config.forcePathStyle === false ? [endpointPath, storageKey] : [endpointPath, resolvedBucket, storageKey];
|
|
3795
|
+
if (config.forcePathStyle === false) {
|
|
3796
|
+
endpoint.hostname = `${resolvedBucket}.${endpoint.hostname}`;
|
|
3797
|
+
}
|
|
3798
|
+
endpoint.pathname = pathParts.filter(Boolean).flatMap((part) => part.split("/")).map(awsEncode).join("/").replace(/^([^/])/, "/$1");
|
|
3799
|
+
return endpoint;
|
|
3800
|
+
}
|
|
3801
|
+
async function signDirectUploadRequest(config, target, inputHeaders, payloadHash) {
|
|
3802
|
+
const accessKeyId = config.accessKeyId.trim();
|
|
3803
|
+
const secretAccessKey = config.secretAccessKey.trim();
|
|
3804
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
3805
|
+
throw new Error(
|
|
3806
|
+
"athena.storage.file.upload direct mode requires accessKeyId and secretAccessKey"
|
|
3807
|
+
);
|
|
3808
|
+
}
|
|
3809
|
+
const now = /* @__PURE__ */ new Date();
|
|
3810
|
+
const amzDate = formatAmzDate(now);
|
|
3811
|
+
const shortDate = amzDate.slice(0, 8);
|
|
3812
|
+
const region = config.region?.trim() || "auto";
|
|
3813
|
+
const headers = {};
|
|
3814
|
+
inputHeaders.forEach((value, key) => {
|
|
3815
|
+
if (key.toLowerCase() !== "authorization" && key.toLowerCase() !== "host") {
|
|
3816
|
+
headers[key.toLowerCase()] = value.trim().replace(/\s+/g, " ");
|
|
3817
|
+
}
|
|
3818
|
+
});
|
|
3819
|
+
headers["x-amz-content-sha256"] = payloadHash;
|
|
3820
|
+
headers["x-amz-date"] = amzDate;
|
|
3821
|
+
if (config.sessionToken?.trim()) {
|
|
3822
|
+
headers["x-amz-security-token"] = config.sessionToken.trim();
|
|
3823
|
+
}
|
|
3824
|
+
const canonicalHeaders = Object.keys(headers).sort().map((key) => `${key}:${headers[key]}
|
|
3825
|
+
`).join("");
|
|
3826
|
+
const signedHeaders = Object.keys(headers).sort().join(";");
|
|
3827
|
+
const canonicalRequest = [
|
|
3828
|
+
"PUT",
|
|
3829
|
+
target.pathname,
|
|
3830
|
+
"",
|
|
3831
|
+
`host:${target.host}
|
|
3832
|
+
${canonicalHeaders}`,
|
|
3833
|
+
`host;${signedHeaders}`,
|
|
3834
|
+
payloadHash
|
|
3835
|
+
].join("\n");
|
|
3836
|
+
const credentialScope = `${shortDate}/${region}/${SERVICE}/${TERMINATOR}`;
|
|
3837
|
+
const stringToSign = [
|
|
3838
|
+
"AWS4-HMAC-SHA256",
|
|
3839
|
+
amzDate,
|
|
3840
|
+
credentialScope,
|
|
3841
|
+
await sha256Hex(canonicalRequest)
|
|
3842
|
+
].join("\n");
|
|
3843
|
+
const dateKey = await hmac(`AWS4${secretAccessKey}`, shortDate);
|
|
3844
|
+
const regionKey = await hmac(dateKey, region);
|
|
3845
|
+
const serviceKey = await hmac(regionKey, SERVICE);
|
|
3846
|
+
const signingKey = await hmac(serviceKey, TERMINATOR);
|
|
3847
|
+
const signature = await hmacHex(signingKey, stringToSign);
|
|
3848
|
+
headers.authorization = `AWS4-HMAC-SHA256 Credential=${accessKeyId}/${credentialScope}, SignedHeaders=host;${signedHeaders}, Signature=${signature}`;
|
|
3849
|
+
return { requestHeaders: headers };
|
|
3850
|
+
}
|
|
3851
|
+
async function putWithXhr(url, signed, body, signal, onProgress) {
|
|
3852
|
+
const Xhr = XMLHttpRequest;
|
|
3853
|
+
if (Xhr === void 0) {
|
|
3854
|
+
return Promise.reject(new Error("athena.storage.file.upload direct mode requires XMLHttpRequest in this runtime"));
|
|
3855
|
+
}
|
|
3856
|
+
return new Promise((resolve3, reject) => {
|
|
3857
|
+
const xhr = new Xhr();
|
|
3858
|
+
const abort = () => xhr.abort();
|
|
3859
|
+
xhr.open("PUT", url);
|
|
3860
|
+
Object.entries(signed.requestHeaders).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
3861
|
+
xhr.upload.onprogress = (event) => onProgress({ loaded: event.loaded });
|
|
3862
|
+
xhr.onload = () => {
|
|
3863
|
+
signal?.removeEventListener("abort", abort);
|
|
3864
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
3865
|
+
reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
|
|
3866
|
+
return;
|
|
3867
|
+
}
|
|
3868
|
+
onProgress({ loaded: bodySize(body) });
|
|
3869
|
+
resolve3(new Response(xhr.response, {
|
|
3870
|
+
status: xhr.status,
|
|
3871
|
+
statusText: xhr.statusText,
|
|
3872
|
+
headers: parseXhrHeaders(xhr.getAllResponseHeaders())
|
|
3873
|
+
}));
|
|
3874
|
+
};
|
|
3875
|
+
xhr.onerror = () => {
|
|
3876
|
+
signal?.removeEventListener("abort", abort);
|
|
3877
|
+
reject(new Error("athena.storage.file.upload failed with a network error"));
|
|
3878
|
+
};
|
|
3879
|
+
xhr.onabort = () => {
|
|
3880
|
+
signal?.removeEventListener("abort", abort);
|
|
3881
|
+
reject(new DOMException("Upload aborted", "AbortError"));
|
|
3882
|
+
};
|
|
3883
|
+
if (signal) {
|
|
3884
|
+
if (signal.aborted) {
|
|
3885
|
+
abort();
|
|
3886
|
+
return;
|
|
3887
|
+
}
|
|
3888
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
3889
|
+
}
|
|
3890
|
+
xhr.send(body);
|
|
3891
|
+
});
|
|
3892
|
+
}
|
|
3893
|
+
function isBlobBody(body) {
|
|
3894
|
+
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
3895
|
+
}
|
|
3896
|
+
async function bodyToArrayBuffer(body) {
|
|
3897
|
+
if (isBlobBody(body)) return body.arrayBuffer();
|
|
3898
|
+
if (body instanceof ArrayBuffer) return body;
|
|
3899
|
+
if (ArrayBuffer.isView(body)) {
|
|
3900
|
+
return body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
3901
|
+
}
|
|
3902
|
+
throw new Error("athena.storage.file.upload direct mode does not support ReadableStream bodies");
|
|
3903
|
+
}
|
|
3904
|
+
function bodySize(body) {
|
|
3905
|
+
if (isBlobBody(body)) return body.size;
|
|
3906
|
+
if (body instanceof ArrayBuffer) return body.byteLength;
|
|
3907
|
+
if (ArrayBuffer.isView(body)) return body.byteLength;
|
|
3908
|
+
return 0;
|
|
3909
|
+
}
|
|
3910
|
+
function awsEncode(value) {
|
|
3911
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
3912
|
+
}
|
|
3913
|
+
function formatAmzDate(date) {
|
|
3914
|
+
return date.toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
3915
|
+
}
|
|
3916
|
+
async function sha256Hex(value) {
|
|
3917
|
+
const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
|
|
3918
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
3919
|
+
return toHex(new Uint8Array(digest));
|
|
3920
|
+
}
|
|
3921
|
+
async function hmac(key, value) {
|
|
3922
|
+
const keyBytes = typeof key === "string" ? new TextEncoder().encode(key) : key;
|
|
3923
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
3924
|
+
"raw",
|
|
3925
|
+
keyBytes,
|
|
3926
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
3927
|
+
false,
|
|
3928
|
+
["sign"]
|
|
3929
|
+
);
|
|
3930
|
+
return crypto.subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(value));
|
|
3931
|
+
}
|
|
3932
|
+
async function hmacHex(key, value) {
|
|
3933
|
+
return toHex(new Uint8Array(await hmac(key, value)));
|
|
3934
|
+
}
|
|
3935
|
+
function toHex(bytes) {
|
|
3936
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3937
|
+
}
|
|
3938
|
+
function parseXhrHeaders(rawHeaders) {
|
|
3939
|
+
const headers = new Headers();
|
|
3940
|
+
rawHeaders.trim().split(/[\r\n]+/).forEach((line) => {
|
|
3941
|
+
const separator = line.indexOf(":");
|
|
3942
|
+
if (separator > 0) {
|
|
3943
|
+
headers.set(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
3944
|
+
}
|
|
3945
|
+
});
|
|
3946
|
+
return headers;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3739
3949
|
// src/storage/file.ts
|
|
3950
|
+
function mergeUploadHeaders(serverHeaders, inputHeaders) {
|
|
3951
|
+
const headers = { ...serverHeaders };
|
|
3952
|
+
new Headers(inputHeaders).forEach((value, key) => {
|
|
3953
|
+
headers[key] = value;
|
|
3954
|
+
});
|
|
3955
|
+
return headers;
|
|
3956
|
+
}
|
|
3740
3957
|
function createStorageFileModule(base, config = {}) {
|
|
3741
3958
|
const upload = async (input, options) => {
|
|
3742
3959
|
const sources = normalizeUploadSources(input);
|
|
@@ -3772,16 +3989,25 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3772
3989
|
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
3773
3990
|
const request2 = uploadRequests[index];
|
|
3774
3991
|
const uploadUrl = uploadUrls[index];
|
|
3775
|
-
const
|
|
3992
|
+
const aggregateProgress = (progress) => {
|
|
3993
|
+
aggregateLoaded[index] = progress.loaded;
|
|
3994
|
+
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
3995
|
+
};
|
|
3996
|
+
const response = config.directUpload ? await putDirectStorageUploadBody(
|
|
3997
|
+
config.directUpload,
|
|
3998
|
+
uploadUrl.upload.bucket,
|
|
3999
|
+
uploadUrl.upload.storage_key,
|
|
4000
|
+
request2.source.source,
|
|
4001
|
+
mergeUploadHeaders(uploadUrl.upload.headers ?? {}, input.uploadHeaders),
|
|
4002
|
+
options?.signal,
|
|
4003
|
+
aggregateProgress
|
|
4004
|
+
) : await putUploadBody(
|
|
3776
4005
|
uploadUrl.upload.url,
|
|
3777
4006
|
uploadUrl.upload.headers ?? {},
|
|
3778
4007
|
request2.source,
|
|
3779
4008
|
input,
|
|
3780
4009
|
options,
|
|
3781
|
-
|
|
3782
|
-
aggregateLoaded[index] = progress.loaded;
|
|
3783
|
-
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
3784
|
-
}
|
|
4010
|
+
aggregateProgress
|
|
3785
4011
|
);
|
|
3786
4012
|
uploaded.push({
|
|
3787
4013
|
file: uploadUrl.file,
|
|
@@ -3932,7 +4158,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
|
|
|
3932
4158
|
resolve3(new Response(xhr.response, {
|
|
3933
4159
|
status: xhr.status,
|
|
3934
4160
|
statusText: xhr.statusText,
|
|
3935
|
-
headers:
|
|
4161
|
+
headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
|
|
3936
4162
|
}));
|
|
3937
4163
|
};
|
|
3938
4164
|
xhr.onerror = () => {
|
|
@@ -4070,7 +4296,7 @@ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoad
|
|
|
4070
4296
|
function sum(values) {
|
|
4071
4297
|
return values.reduce((total, value) => total + value, 0);
|
|
4072
4298
|
}
|
|
4073
|
-
function
|
|
4299
|
+
function parseXhrHeaders2(raw) {
|
|
4074
4300
|
const headers = new Headers();
|
|
4075
4301
|
for (const line of raw.trim().split(/[\r\n]+/)) {
|
|
4076
4302
|
const index = line.indexOf(":");
|
|
@@ -4087,6 +4313,230 @@ function isRecord5(value) {
|
|
|
4087
4313
|
return Boolean(value) && typeof value === "object";
|
|
4088
4314
|
}
|
|
4089
4315
|
|
|
4316
|
+
// src/storage/backup.ts
|
|
4317
|
+
function backupError(message, status, endpoint, method, cause, raw) {
|
|
4318
|
+
const error = new Error(message);
|
|
4319
|
+
error.name = "AthenaStorageError";
|
|
4320
|
+
error.code = status === 0 ? "NETWORK_ERROR" : "HTTP_ERROR";
|
|
4321
|
+
error.status = status;
|
|
4322
|
+
error.endpoint = endpoint;
|
|
4323
|
+
error.method = method;
|
|
4324
|
+
error.cause = cause;
|
|
4325
|
+
error.raw = raw;
|
|
4326
|
+
throw error;
|
|
4327
|
+
}
|
|
4328
|
+
function isRecord6(value) {
|
|
4329
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4330
|
+
}
|
|
4331
|
+
function asPath(path) {
|
|
4332
|
+
return path;
|
|
4333
|
+
}
|
|
4334
|
+
function appendQuery(path, query) {
|
|
4335
|
+
if (!query) return path;
|
|
4336
|
+
const params = new URLSearchParams();
|
|
4337
|
+
for (const [key, value] of Object.entries(query)) {
|
|
4338
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
4339
|
+
params.set(key, String(value));
|
|
4340
|
+
}
|
|
4341
|
+
const text = params.toString();
|
|
4342
|
+
return text ? `${path}?${text}` : path;
|
|
4343
|
+
}
|
|
4344
|
+
function unwrapAthenaData(payload) {
|
|
4345
|
+
if (isRecord6(payload) && "data" in payload) {
|
|
4346
|
+
return payload.data;
|
|
4347
|
+
}
|
|
4348
|
+
return payload;
|
|
4349
|
+
}
|
|
4350
|
+
function requireKey(key) {
|
|
4351
|
+
const trimmed = key.trim();
|
|
4352
|
+
if (!trimmed || trimmed === "undefined" || trimmed === "null") {
|
|
4353
|
+
backupError("Backup object key is required", 400, "/admin/backups/{key}", "DELETE");
|
|
4354
|
+
}
|
|
4355
|
+
return trimmed;
|
|
4356
|
+
}
|
|
4357
|
+
function resolveMessage(payload, fallback) {
|
|
4358
|
+
if (isRecord6(payload)) {
|
|
4359
|
+
const message = payload.message ?? payload.error ?? payload.details;
|
|
4360
|
+
if (typeof message === "string" && message.trim()) return message.trim();
|
|
4361
|
+
}
|
|
4362
|
+
if (typeof payload === "string" && payload.trim()) return payload.trim();
|
|
4363
|
+
return fallback;
|
|
4364
|
+
}
|
|
4365
|
+
async function callBackupEndpoint(gateway, path, method, payload, options, runtime) {
|
|
4366
|
+
const endpoint = asPath(path);
|
|
4367
|
+
const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
|
|
4368
|
+
const url = buildAthenaGatewayUrl(baseUrl, endpoint);
|
|
4369
|
+
const headers = gateway.buildHeaders(options);
|
|
4370
|
+
const init = {
|
|
4371
|
+
method,
|
|
4372
|
+
headers,
|
|
4373
|
+
signal: options?.signal
|
|
4374
|
+
};
|
|
4375
|
+
if (payload !== void 0 && method !== "GET") {
|
|
4376
|
+
init.body = JSON.stringify(payload);
|
|
4377
|
+
}
|
|
4378
|
+
let response;
|
|
4379
|
+
try {
|
|
4380
|
+
response = await fetch(url, init);
|
|
4381
|
+
} catch (error) {
|
|
4382
|
+
backupError(
|
|
4383
|
+
error instanceof Error ? error.message : "Backup network error",
|
|
4384
|
+
0,
|
|
4385
|
+
path,
|
|
4386
|
+
method,
|
|
4387
|
+
error
|
|
4388
|
+
);
|
|
4389
|
+
}
|
|
4390
|
+
const rawText = await response.text();
|
|
4391
|
+
let parsed = null;
|
|
4392
|
+
if (rawText) {
|
|
4393
|
+
try {
|
|
4394
|
+
parsed = JSON.parse(rawText);
|
|
4395
|
+
} catch {
|
|
4396
|
+
parsed = rawText;
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
if (!response.ok) {
|
|
4400
|
+
backupError(
|
|
4401
|
+
resolveMessage(parsed, `Backup ${method} ${path} failed (${response.status})`),
|
|
4402
|
+
response.status,
|
|
4403
|
+
path,
|
|
4404
|
+
method,
|
|
4405
|
+
void 0,
|
|
4406
|
+
parsed
|
|
4407
|
+
);
|
|
4408
|
+
}
|
|
4409
|
+
return unwrapAthenaData(parsed);
|
|
4410
|
+
}
|
|
4411
|
+
function createStorageBackupModule(gateway, runtimeOptions) {
|
|
4412
|
+
const resolvedBaseUrl = () => String(gateway.baseUrl ?? "").replace(/\/+$/, "");
|
|
4413
|
+
return {
|
|
4414
|
+
async list(query, options) {
|
|
4415
|
+
const path = appendQuery("/admin/backups", {
|
|
4416
|
+
limit: query?.limit ?? 10,
|
|
4417
|
+
client_name: query?.client_name,
|
|
4418
|
+
cursor: query?.cursor ?? void 0
|
|
4419
|
+
});
|
|
4420
|
+
const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
|
|
4421
|
+
const backups = (data?.backups ?? []).map((row) => ({
|
|
4422
|
+
...row,
|
|
4423
|
+
key: row.key ?? row.s3_key
|
|
4424
|
+
}));
|
|
4425
|
+
return {
|
|
4426
|
+
backups,
|
|
4427
|
+
next_cursor: data?.next_cursor ?? null
|
|
4428
|
+
};
|
|
4429
|
+
},
|
|
4430
|
+
async create(input, options) {
|
|
4431
|
+
const data = await callBackupEndpoint(gateway, "/admin/backups", "POST", input, options);
|
|
4432
|
+
return {
|
|
4433
|
+
job_id: Number(data?.job_id ?? 0),
|
|
4434
|
+
client_name: String(data?.client_name ?? input.client_name),
|
|
4435
|
+
status: String(data?.status ?? "pending")
|
|
4436
|
+
};
|
|
4437
|
+
},
|
|
4438
|
+
async restore(key, input, options) {
|
|
4439
|
+
const backupKey = requireKey(key);
|
|
4440
|
+
const path = `/admin/backups/${encodeURIComponent(backupKey)}/restore`;
|
|
4441
|
+
const data = await callBackupEndpoint(gateway, path, "POST", input, options);
|
|
4442
|
+
return {
|
|
4443
|
+
job_id: Number(data?.job_id ?? 0),
|
|
4444
|
+
client_name: String(data?.client_name ?? input.client_name),
|
|
4445
|
+
status: String(data?.status ?? "pending"),
|
|
4446
|
+
key: String(data?.key ?? backupKey)
|
|
4447
|
+
};
|
|
4448
|
+
},
|
|
4449
|
+
async delete(key, options) {
|
|
4450
|
+
const backupKey = requireKey(key);
|
|
4451
|
+
await callBackupEndpoint(
|
|
4452
|
+
gateway,
|
|
4453
|
+
`/admin/backups/${encodeURIComponent(backupKey)}`,
|
|
4454
|
+
"DELETE",
|
|
4455
|
+
void 0,
|
|
4456
|
+
options);
|
|
4457
|
+
},
|
|
4458
|
+
downloadUrl(key, options) {
|
|
4459
|
+
const backupKey = requireKey(key);
|
|
4460
|
+
const base = `${resolvedBaseUrl()}/admin/backups/${encodeURIComponent(backupKey)}/download`;
|
|
4461
|
+
return options?.apiKey ? `${base}?api_key=${encodeURIComponent(options.apiKey)}` : base;
|
|
4462
|
+
},
|
|
4463
|
+
jobs: {
|
|
4464
|
+
async list(query, options) {
|
|
4465
|
+
const path = appendQuery("/admin/backups/jobs", query ?? {});
|
|
4466
|
+
const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
|
|
4467
|
+
if (Array.isArray(data)) return data;
|
|
4468
|
+
if (isRecord6(data) && Array.isArray(data.jobs)) return data.jobs;
|
|
4469
|
+
return [];
|
|
4470
|
+
},
|
|
4471
|
+
async get(jobId, options) {
|
|
4472
|
+
return callBackupEndpoint(
|
|
4473
|
+
gateway,
|
|
4474
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
|
|
4475
|
+
"GET",
|
|
4476
|
+
void 0,
|
|
4477
|
+
options);
|
|
4478
|
+
},
|
|
4479
|
+
async cancel(jobId, options) {
|
|
4480
|
+
return callBackupEndpoint(
|
|
4481
|
+
gateway,
|
|
4482
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}/cancel`,
|
|
4483
|
+
"POST",
|
|
4484
|
+
{},
|
|
4485
|
+
options);
|
|
4486
|
+
},
|
|
4487
|
+
async delete(jobId, options) {
|
|
4488
|
+
await callBackupEndpoint(
|
|
4489
|
+
gateway,
|
|
4490
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
|
|
4491
|
+
"DELETE",
|
|
4492
|
+
void 0,
|
|
4493
|
+
options);
|
|
4494
|
+
},
|
|
4495
|
+
async openObjectUrl(jobId, options) {
|
|
4496
|
+
const data = await callBackupEndpoint(
|
|
4497
|
+
gateway,
|
|
4498
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}/s3-open`,
|
|
4499
|
+
"GET",
|
|
4500
|
+
void 0,
|
|
4501
|
+
options);
|
|
4502
|
+
return String(data?.url ?? "");
|
|
4503
|
+
}
|
|
4504
|
+
},
|
|
4505
|
+
schedules: {
|
|
4506
|
+
async list(options) {
|
|
4507
|
+
const data = await callBackupEndpoint(gateway, "/admin/backups/schedules", "GET", void 0, options);
|
|
4508
|
+
if (Array.isArray(data)) return data;
|
|
4509
|
+
if (isRecord6(data) && Array.isArray(data.schedules)) return data.schedules;
|
|
4510
|
+
return [];
|
|
4511
|
+
},
|
|
4512
|
+
async create(input, options) {
|
|
4513
|
+
return callBackupEndpoint(
|
|
4514
|
+
gateway,
|
|
4515
|
+
"/admin/backups/schedules",
|
|
4516
|
+
"POST",
|
|
4517
|
+
input,
|
|
4518
|
+
options);
|
|
4519
|
+
},
|
|
4520
|
+
async update(id, input, options) {
|
|
4521
|
+
return callBackupEndpoint(
|
|
4522
|
+
gateway,
|
|
4523
|
+
`/admin/backups/schedules/${encodeURIComponent(String(id))}`,
|
|
4524
|
+
"PATCH",
|
|
4525
|
+
input,
|
|
4526
|
+
options);
|
|
4527
|
+
},
|
|
4528
|
+
async delete(id, options) {
|
|
4529
|
+
await callBackupEndpoint(
|
|
4530
|
+
gateway,
|
|
4531
|
+
`/admin/backups/schedules/${encodeURIComponent(String(id))}`,
|
|
4532
|
+
"DELETE",
|
|
4533
|
+
void 0,
|
|
4534
|
+
options);
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
};
|
|
4538
|
+
}
|
|
4539
|
+
|
|
4090
4540
|
// src/storage/module.ts
|
|
4091
4541
|
var storageSdkManifest = {
|
|
4092
4542
|
namespace: "storage",
|
|
@@ -4135,6 +4585,53 @@ var storageSdkManifest = {
|
|
|
4135
4585
|
responseEnvelope: "raw",
|
|
4136
4586
|
responseType: "{ data: S3CredentialListItem[] }"
|
|
4137
4587
|
},
|
|
4588
|
+
{
|
|
4589
|
+
name: "backup.list",
|
|
4590
|
+
method: "GET",
|
|
4591
|
+
path: "/admin/backups",
|
|
4592
|
+
responseEnvelope: "athena",
|
|
4593
|
+
responseType: "StorageBackupListPage",
|
|
4594
|
+
note: "Admin backup archives on server S3/R2 profile"
|
|
4595
|
+
},
|
|
4596
|
+
{
|
|
4597
|
+
name: "backup.create",
|
|
4598
|
+
method: "POST",
|
|
4599
|
+
path: "/admin/backups",
|
|
4600
|
+
requestType: "StorageBackupCreateRequest",
|
|
4601
|
+
responseEnvelope: "athena",
|
|
4602
|
+
responseType: "StorageBackupQueuedJob"
|
|
4603
|
+
},
|
|
4604
|
+
{
|
|
4605
|
+
name: "backup.restore",
|
|
4606
|
+
method: "POST",
|
|
4607
|
+
path: "/admin/backups/{key}/restore",
|
|
4608
|
+
pathParams: ["key"],
|
|
4609
|
+
requestType: "StorageBackupRestoreRequest",
|
|
4610
|
+
responseEnvelope: "athena",
|
|
4611
|
+
responseType: "StorageBackupQueuedJob"
|
|
4612
|
+
},
|
|
4613
|
+
{
|
|
4614
|
+
name: "backup.delete",
|
|
4615
|
+
method: "DELETE",
|
|
4616
|
+
path: "/admin/backups/{key}",
|
|
4617
|
+
pathParams: ["key"],
|
|
4618
|
+
responseEnvelope: "athena",
|
|
4619
|
+
responseType: "void"
|
|
4620
|
+
},
|
|
4621
|
+
{
|
|
4622
|
+
name: "backup.jobs.list",
|
|
4623
|
+
method: "GET",
|
|
4624
|
+
path: "/admin/backups/jobs",
|
|
4625
|
+
responseEnvelope: "athena",
|
|
4626
|
+
responseType: "StorageBackupJob[]"
|
|
4627
|
+
},
|
|
4628
|
+
{
|
|
4629
|
+
name: "backup.schedules.list",
|
|
4630
|
+
method: "GET",
|
|
4631
|
+
path: "/admin/backups/schedules",
|
|
4632
|
+
responseEnvelope: "athena",
|
|
4633
|
+
responseType: "StorageBackupSchedule[]"
|
|
4634
|
+
},
|
|
4138
4635
|
{
|
|
4139
4636
|
name: "createStorageUploadUrl",
|
|
4140
4637
|
method: "POST",
|
|
@@ -4790,7 +5287,7 @@ var AthenaStorageError = class extends Error {
|
|
|
4790
5287
|
};
|
|
4791
5288
|
}
|
|
4792
5289
|
};
|
|
4793
|
-
function
|
|
5290
|
+
function isRecord7(value) {
|
|
4794
5291
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4795
5292
|
}
|
|
4796
5293
|
function causeToString(cause) {
|
|
@@ -4888,7 +5385,7 @@ function parseResponseBody3(rawText, contentType) {
|
|
|
4888
5385
|
return { parsed: rawText, parseFailed: true };
|
|
4889
5386
|
}
|
|
4890
5387
|
}
|
|
4891
|
-
function
|
|
5388
|
+
function appendQuery2(path, query) {
|
|
4892
5389
|
if (!query) return path;
|
|
4893
5390
|
const params = new URLSearchParams();
|
|
4894
5391
|
for (const [key, value] of Object.entries(query)) {
|
|
@@ -4914,7 +5411,7 @@ function withPathParam(path, name, value) {
|
|
|
4914
5411
|
return path.replace(`{${name}}`, encodeURIComponent(value));
|
|
4915
5412
|
}
|
|
4916
5413
|
function resolveErrorMessage3(payload, fallback) {
|
|
4917
|
-
if (
|
|
5414
|
+
if (isRecord7(payload)) {
|
|
4918
5415
|
const message = payload.message ?? payload.error ?? payload.details;
|
|
4919
5416
|
if (typeof message === "string" && message.trim()) {
|
|
4920
5417
|
return message.trim();
|
|
@@ -4926,12 +5423,12 @@ function resolveErrorMessage3(payload, fallback) {
|
|
|
4926
5423
|
return fallback;
|
|
4927
5424
|
}
|
|
4928
5425
|
function resolveErrorHint2(payload) {
|
|
4929
|
-
if (!
|
|
5426
|
+
if (!isRecord7(payload)) return void 0;
|
|
4930
5427
|
const hint = payload.hint ?? payload.suggestion;
|
|
4931
5428
|
return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
|
|
4932
5429
|
}
|
|
4933
5430
|
function resolveErrorCause(payload) {
|
|
4934
|
-
if (!
|
|
5431
|
+
if (!isRecord7(payload)) return void 0;
|
|
4935
5432
|
const cause = payload.cause ?? payload.reason;
|
|
4936
5433
|
return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
|
|
4937
5434
|
}
|
|
@@ -5050,7 +5547,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
|
|
|
5050
5547
|
);
|
|
5051
5548
|
}
|
|
5052
5549
|
if (envelope === "athena") {
|
|
5053
|
-
if (!
|
|
5550
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5054
5551
|
return rejectStorageError(
|
|
5055
5552
|
{
|
|
5056
5553
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5158,7 +5655,7 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
|
|
|
5158
5655
|
runtimeOptions
|
|
5159
5656
|
);
|
|
5160
5657
|
}
|
|
5161
|
-
function
|
|
5658
|
+
function isBlobBody2(body) {
|
|
5162
5659
|
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
5163
5660
|
}
|
|
5164
5661
|
function isReadableStreamBody(body) {
|
|
@@ -5167,7 +5664,7 @@ function isReadableStreamBody(body) {
|
|
|
5167
5664
|
async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
|
|
5168
5665
|
const headers = new Headers(uploadHeaders);
|
|
5169
5666
|
Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
|
|
5170
|
-
if (!headers.has("Content-Type") &&
|
|
5667
|
+
if (!headers.has("Content-Type") && isBlobBody2(body) && body.type) {
|
|
5171
5668
|
headers.set("Content-Type", body.type);
|
|
5172
5669
|
}
|
|
5173
5670
|
const init = {
|
|
@@ -5262,7 +5759,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5262
5759
|
}
|
|
5263
5760
|
delete headers["Content-Type"];
|
|
5264
5761
|
delete headers["content-type"];
|
|
5265
|
-
if (
|
|
5762
|
+
if (isBlobBody2(body) && body.type) {
|
|
5266
5763
|
headers["Content-Type"] = body.type;
|
|
5267
5764
|
}
|
|
5268
5765
|
const requestInit = {
|
|
@@ -5347,7 +5844,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5347
5844
|
runtimeOptions
|
|
5348
5845
|
);
|
|
5349
5846
|
}
|
|
5350
|
-
if (!
|
|
5847
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5351
5848
|
return rejectStorageError(
|
|
5352
5849
|
{
|
|
5353
5850
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5419,14 +5916,14 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5419
5916
|
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
|
|
5420
5917
|
},
|
|
5421
5918
|
getStorageFileUrl(fileId, query, options) {
|
|
5422
|
-
const path =
|
|
5919
|
+
const path = appendQuery2(
|
|
5423
5920
|
withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
|
|
5424
5921
|
query
|
|
5425
5922
|
);
|
|
5426
5923
|
return callAthena2(path, "GET", void 0, options);
|
|
5427
5924
|
},
|
|
5428
5925
|
getStorageFileProxy(fileId, query, options) {
|
|
5429
|
-
const path =
|
|
5926
|
+
const path = appendQuery2(
|
|
5430
5927
|
withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
|
|
5431
5928
|
query
|
|
5432
5929
|
);
|
|
@@ -5450,7 +5947,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5450
5947
|
};
|
|
5451
5948
|
const fileFacade = createStorageFileModule(base, runtimeOptions);
|
|
5452
5949
|
const fileUpload = ((input, options) => {
|
|
5453
|
-
if (
|
|
5950
|
+
if (isRecord7(input) && "files" in input) {
|
|
5454
5951
|
return fileFacade.upload(input, options);
|
|
5455
5952
|
}
|
|
5456
5953
|
return base.createStorageUploadUrl(
|
|
@@ -5512,7 +6009,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5512
6009
|
return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
|
|
5513
6010
|
},
|
|
5514
6011
|
proxyUrl(fileId, query, options) {
|
|
5515
|
-
const path =
|
|
6012
|
+
const path = appendQuery2(
|
|
5516
6013
|
withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
|
|
5517
6014
|
query
|
|
5518
6015
|
);
|
|
@@ -5550,7 +6047,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5550
6047
|
},
|
|
5551
6048
|
retention: {
|
|
5552
6049
|
get(fileId, query, options) {
|
|
5553
|
-
const path =
|
|
6050
|
+
const path = appendQuery2(
|
|
5554
6051
|
withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
|
|
5555
6052
|
query
|
|
5556
6053
|
);
|
|
@@ -5752,6 +6249,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5752
6249
|
return callAthena2("/storage/audit/list", "POST", input, options);
|
|
5753
6250
|
}
|
|
5754
6251
|
};
|
|
6252
|
+
const backup = createStorageBackupModule(gateway);
|
|
5755
6253
|
return {
|
|
5756
6254
|
...base,
|
|
5757
6255
|
credentials,
|
|
@@ -5763,6 +6261,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5763
6261
|
bucket,
|
|
5764
6262
|
multipart,
|
|
5765
6263
|
audit,
|
|
6264
|
+
backup,
|
|
5766
6265
|
delete: file.delete
|
|
5767
6266
|
};
|
|
5768
6267
|
}
|
|
@@ -5812,7 +6311,7 @@ function normalizeWsUrl(value, label) {
|
|
|
5812
6311
|
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
5813
6312
|
return parsed.toString().replace(/\/$/, "");
|
|
5814
6313
|
}
|
|
5815
|
-
function
|
|
6314
|
+
function isRecord8(value) {
|
|
5816
6315
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5817
6316
|
}
|
|
5818
6317
|
function parseResponseBody4(rawText, contentType) {
|
|
@@ -5834,7 +6333,7 @@ function resolveRequestId3(headers) {
|
|
|
5834
6333
|
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
5835
6334
|
}
|
|
5836
6335
|
function resolveErrorMessage4(payload, fallback) {
|
|
5837
|
-
if (
|
|
6336
|
+
if (isRecord8(payload)) {
|
|
5838
6337
|
for (const candidate of [payload.error, payload.message, payload.details]) {
|
|
5839
6338
|
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
5840
6339
|
return candidate.trim();
|
|
@@ -6481,7 +6980,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
6481
6980
|
"ilike",
|
|
6482
6981
|
"is"
|
|
6483
6982
|
]);
|
|
6484
|
-
function
|
|
6983
|
+
function isRecord9(value) {
|
|
6485
6984
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6486
6985
|
}
|
|
6487
6986
|
function isUuidString(value) {
|
|
@@ -6494,7 +6993,7 @@ function shouldUseUuidTextComparison(column, value) {
|
|
|
6494
6993
|
return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
|
|
6495
6994
|
}
|
|
6496
6995
|
function isRelationSelectNode(value) {
|
|
6497
|
-
return
|
|
6996
|
+
return isRecord9(value) && isRecord9(value.select);
|
|
6498
6997
|
}
|
|
6499
6998
|
function normalizeIdentifier(value, label) {
|
|
6500
6999
|
const normalized = value.trim();
|
|
@@ -6550,7 +7049,7 @@ function compileRelationToken(key, node) {
|
|
|
6550
7049
|
return `${prefix}${relationToken}(${nested})`;
|
|
6551
7050
|
}
|
|
6552
7051
|
function compileSelectShape(select) {
|
|
6553
|
-
if (!
|
|
7052
|
+
if (!isRecord9(select)) {
|
|
6554
7053
|
throw new Error("findMany select must be an object");
|
|
6555
7054
|
}
|
|
6556
7055
|
const tokens = [];
|
|
@@ -6574,7 +7073,7 @@ function compileSelectShape(select) {
|
|
|
6574
7073
|
return tokens.join(",");
|
|
6575
7074
|
}
|
|
6576
7075
|
function selectShapeUsesRelationSchema(select) {
|
|
6577
|
-
if (!
|
|
7076
|
+
if (!isRecord9(select)) {
|
|
6578
7077
|
return false;
|
|
6579
7078
|
}
|
|
6580
7079
|
for (const rawValue of Object.values(select)) {
|
|
@@ -6592,7 +7091,7 @@ function selectShapeUsesRelationSchema(select) {
|
|
|
6592
7091
|
}
|
|
6593
7092
|
function compileColumnWhere(column, input) {
|
|
6594
7093
|
const normalizedColumn = normalizeIdentifier(column, "where column");
|
|
6595
|
-
if (!
|
|
7094
|
+
if (!isRecord9(input)) {
|
|
6596
7095
|
return [buildGatewayCondition("eq", normalizedColumn, input)];
|
|
6597
7096
|
}
|
|
6598
7097
|
const conditions = [];
|
|
@@ -6620,7 +7119,7 @@ function compileColumnWhere(column, input) {
|
|
|
6620
7119
|
return conditions;
|
|
6621
7120
|
}
|
|
6622
7121
|
function compileBooleanExpressionTerms(clause, label) {
|
|
6623
|
-
if (!
|
|
7122
|
+
if (!isRecord9(clause)) {
|
|
6624
7123
|
throw new Error(`findMany where.${label} clauses must be objects`);
|
|
6625
7124
|
}
|
|
6626
7125
|
const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
|
|
@@ -6629,7 +7128,7 @@ function compileBooleanExpressionTerms(clause, label) {
|
|
|
6629
7128
|
}
|
|
6630
7129
|
const [rawColumn, rawValue] = entries[0];
|
|
6631
7130
|
const column = normalizeIdentifier(rawColumn, `where.${label} column`);
|
|
6632
|
-
if (!
|
|
7131
|
+
if (!isRecord9(rawValue)) {
|
|
6633
7132
|
return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
|
|
6634
7133
|
}
|
|
6635
7134
|
const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
|
|
@@ -6653,7 +7152,7 @@ function compileWhere(where) {
|
|
|
6653
7152
|
if (where === void 0) {
|
|
6654
7153
|
return void 0;
|
|
6655
7154
|
}
|
|
6656
|
-
if (!
|
|
7155
|
+
if (!isRecord9(where)) {
|
|
6657
7156
|
throw new Error("findMany where must be an object");
|
|
6658
7157
|
}
|
|
6659
7158
|
const conditions = [];
|
|
@@ -6703,7 +7202,7 @@ function compileOrderBy(orderBy) {
|
|
|
6703
7202
|
if (orderBy === void 0) {
|
|
6704
7203
|
return void 0;
|
|
6705
7204
|
}
|
|
6706
|
-
if (!
|
|
7205
|
+
if (!isRecord9(orderBy)) {
|
|
6707
7206
|
throw new Error("findMany orderBy must be an object");
|
|
6708
7207
|
}
|
|
6709
7208
|
if ("column" in orderBy) {
|
|
@@ -6878,11 +7377,11 @@ function toFindManyAstOrder(order) {
|
|
|
6878
7377
|
ascending: order.direction !== "descending"
|
|
6879
7378
|
};
|
|
6880
7379
|
}
|
|
6881
|
-
function
|
|
7380
|
+
function isRecord10(value) {
|
|
6882
7381
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6883
7382
|
}
|
|
6884
7383
|
function normalizeFindManyAstColumnPredicate(value) {
|
|
6885
|
-
if (!
|
|
7384
|
+
if (!isRecord10(value)) {
|
|
6886
7385
|
return {
|
|
6887
7386
|
eq: value
|
|
6888
7387
|
};
|
|
@@ -6906,7 +7405,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
|
|
|
6906
7405
|
return normalized;
|
|
6907
7406
|
}
|
|
6908
7407
|
function normalizeFindManyAstWhere(where) {
|
|
6909
|
-
if (!where || !
|
|
7408
|
+
if (!where || !isRecord10(where)) {
|
|
6910
7409
|
return where;
|
|
6911
7410
|
}
|
|
6912
7411
|
const normalized = {};
|
|
@@ -6920,7 +7419,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6920
7419
|
);
|
|
6921
7420
|
continue;
|
|
6922
7421
|
}
|
|
6923
|
-
if (key === "not" &&
|
|
7422
|
+
if (key === "not" && isRecord10(value)) {
|
|
6924
7423
|
normalized.not = normalizeFindManyAstBooleanOperand(
|
|
6925
7424
|
value
|
|
6926
7425
|
);
|
|
@@ -6931,7 +7430,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6931
7430
|
return normalized;
|
|
6932
7431
|
}
|
|
6933
7432
|
function predicateRequiresUuidQueryFallback(column, value) {
|
|
6934
|
-
if (!
|
|
7433
|
+
if (!isRecord10(value)) {
|
|
6935
7434
|
return shouldUseUuidTextComparison(column, value);
|
|
6936
7435
|
}
|
|
6937
7436
|
const eqValue = value.eq;
|
|
@@ -6949,7 +7448,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
|
|
|
6949
7448
|
return false;
|
|
6950
7449
|
}
|
|
6951
7450
|
function findManyAstWhereRequiresLegacyTransport(where) {
|
|
6952
|
-
if (!where || !
|
|
7451
|
+
if (!where || !isRecord10(where)) {
|
|
6953
7452
|
return false;
|
|
6954
7453
|
}
|
|
6955
7454
|
for (const [key, value] of Object.entries(where)) {
|
|
@@ -6964,7 +7463,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
|
|
|
6964
7463
|
}
|
|
6965
7464
|
continue;
|
|
6966
7465
|
}
|
|
6967
|
-
if (key === "not" &&
|
|
7466
|
+
if (key === "not" && isRecord10(value)) {
|
|
6968
7467
|
if (booleanOperandRequiresUuidQueryFallback(value)) {
|
|
6969
7468
|
return true;
|
|
6970
7469
|
}
|
|
@@ -7590,7 +8089,7 @@ async function executeExperimentalRead(experimental, runner) {
|
|
|
7590
8089
|
throw error;
|
|
7591
8090
|
}
|
|
7592
8091
|
}
|
|
7593
|
-
function
|
|
8092
|
+
function isRecord11(value) {
|
|
7594
8093
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7595
8094
|
}
|
|
7596
8095
|
function firstNonEmptyString2(...values) {
|
|
@@ -7602,8 +8101,8 @@ function firstNonEmptyString2(...values) {
|
|
|
7602
8101
|
return void 0;
|
|
7603
8102
|
}
|
|
7604
8103
|
function resolveStructuredErrorPayload2(raw) {
|
|
7605
|
-
if (!
|
|
7606
|
-
return
|
|
8104
|
+
if (!isRecord11(raw)) return null;
|
|
8105
|
+
return isRecord11(raw.error) ? raw.error : raw;
|
|
7607
8106
|
}
|
|
7608
8107
|
function resolveStructuredErrorDetails(payload, message) {
|
|
7609
8108
|
if (!payload || !("details" in payload)) {
|
|
@@ -7619,7 +8118,7 @@ function resolveStructuredErrorDetails(payload, message) {
|
|
|
7619
8118
|
return details;
|
|
7620
8119
|
}
|
|
7621
8120
|
function createResultError(response, result, normalized) {
|
|
7622
|
-
const rawRecord =
|
|
8121
|
+
const rawRecord = isRecord11(response.raw) ? response.raw : null;
|
|
7623
8122
|
const payload = resolveStructuredErrorPayload2(response.raw);
|
|
7624
8123
|
const message = firstNonEmptyString2(
|
|
7625
8124
|
response.error,
|
|
@@ -9528,6 +10027,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9528
10027
|
withOptions: storageWithOptions,
|
|
9529
10028
|
storage: createStorageModule(gateway, {
|
|
9530
10029
|
...config.experimental.storage,
|
|
10030
|
+
...config.experimental.directStorageUpload ? { directUpload: config.experimental.directStorageUpload } : {},
|
|
9531
10031
|
...config.storageUrl ? {
|
|
9532
10032
|
baseUrl: config.storageUrl,
|
|
9533
10033
|
stripBasePath: true
|
|
@@ -9614,7 +10114,7 @@ function resolveNullishValue(mode) {
|
|
|
9614
10114
|
if (mode === "null") return null;
|
|
9615
10115
|
return "";
|
|
9616
10116
|
}
|
|
9617
|
-
function
|
|
10117
|
+
function isRecord12(value) {
|
|
9618
10118
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9619
10119
|
}
|
|
9620
10120
|
function isNullableColumn(model, key) {
|
|
@@ -9623,7 +10123,7 @@ function isNullableColumn(model, key) {
|
|
|
9623
10123
|
}
|
|
9624
10124
|
function toModelFormDefaults(model, values, options) {
|
|
9625
10125
|
const source = values;
|
|
9626
|
-
if (!
|
|
10126
|
+
if (!isRecord12(source)) {
|
|
9627
10127
|
return {};
|
|
9628
10128
|
}
|
|
9629
10129
|
const mode = options?.nullishMode ?? "empty-string";
|
|
@@ -12437,15 +12937,15 @@ function readCookieFromHeaders(headers, name) {
|
|
|
12437
12937
|
}
|
|
12438
12938
|
return parseCookies(cookieHeader).get(name);
|
|
12439
12939
|
}
|
|
12440
|
-
function
|
|
12940
|
+
function isRecord13(value) {
|
|
12441
12941
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
12442
12942
|
}
|
|
12443
12943
|
function resolveSessionCandidate(value) {
|
|
12444
|
-
if (!
|
|
12944
|
+
if (!isRecord13(value)) {
|
|
12445
12945
|
return null;
|
|
12446
12946
|
}
|
|
12447
|
-
const session =
|
|
12448
|
-
const user =
|
|
12947
|
+
const session = isRecord13(value.session) ? value.session : void 0;
|
|
12948
|
+
const user = isRecord13(value.user) ? value.user : void 0;
|
|
12449
12949
|
if (session && typeof session.token === "string" && session.token.length > 0 && user) {
|
|
12450
12950
|
return {
|
|
12451
12951
|
session,
|
|
@@ -12455,7 +12955,7 @@ function resolveSessionCandidate(value) {
|
|
|
12455
12955
|
return null;
|
|
12456
12956
|
}
|
|
12457
12957
|
function inferSessionPair(returned) {
|
|
12458
|
-
return resolveSessionCandidate(returned) ?? (
|
|
12958
|
+
return resolveSessionCandidate(returned) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.session) : null);
|
|
12459
12959
|
}
|
|
12460
12960
|
function resolveResponseHeaders(ctx) {
|
|
12461
12961
|
if (ctx.context.responseHeaders instanceof Headers) {
|