@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/browser.js
CHANGED
|
@@ -1027,7 +1027,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
1027
1027
|
|
|
1028
1028
|
// package.json
|
|
1029
1029
|
var package_default = {
|
|
1030
|
-
version: "2.
|
|
1030
|
+
version: "2.14.0"
|
|
1031
1031
|
};
|
|
1032
1032
|
|
|
1033
1033
|
// src/sdk-version.ts
|
|
@@ -3730,7 +3730,224 @@ async function withRetry(config, fn) {
|
|
|
3730
3730
|
throw new Error("withRetry reached an unexpected state");
|
|
3731
3731
|
}
|
|
3732
3732
|
|
|
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;
|
|
3861
|
+
}
|
|
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 });
|
|
3883
|
+
}
|
|
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;
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3733
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
|
+
}
|
|
3734
3951
|
function createStorageFileModule(base, config = {}) {
|
|
3735
3952
|
const upload = async (input, options) => {
|
|
3736
3953
|
const sources = normalizeUploadSources(input);
|
|
@@ -3766,16 +3983,25 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3766
3983
|
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
3767
3984
|
const request2 = uploadRequests[index];
|
|
3768
3985
|
const uploadUrl = uploadUrls[index];
|
|
3769
|
-
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(
|
|
3770
3999
|
uploadUrl.upload.url,
|
|
3771
4000
|
uploadUrl.upload.headers ?? {},
|
|
3772
4001
|
request2.source,
|
|
3773
4002
|
input,
|
|
3774
4003
|
options,
|
|
3775
|
-
|
|
3776
|
-
aggregateLoaded[index] = progress.loaded;
|
|
3777
|
-
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
3778
|
-
}
|
|
4004
|
+
aggregateProgress
|
|
3779
4005
|
);
|
|
3780
4006
|
uploaded.push({
|
|
3781
4007
|
file: uploadUrl.file,
|
|
@@ -3926,7 +4152,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
|
|
|
3926
4152
|
resolve(new Response(xhr.response, {
|
|
3927
4153
|
status: xhr.status,
|
|
3928
4154
|
statusText: xhr.statusText,
|
|
3929
|
-
headers:
|
|
4155
|
+
headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
|
|
3930
4156
|
}));
|
|
3931
4157
|
};
|
|
3932
4158
|
xhr.onerror = () => {
|
|
@@ -4064,7 +4290,7 @@ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoad
|
|
|
4064
4290
|
function sum(values) {
|
|
4065
4291
|
return values.reduce((total, value) => total + value, 0);
|
|
4066
4292
|
}
|
|
4067
|
-
function
|
|
4293
|
+
function parseXhrHeaders2(raw) {
|
|
4068
4294
|
const headers = new Headers();
|
|
4069
4295
|
for (const line of raw.trim().split(/[\r\n]+/)) {
|
|
4070
4296
|
const index = line.indexOf(":");
|
|
@@ -4081,6 +4307,230 @@ function isRecord5(value) {
|
|
|
4081
4307
|
return Boolean(value) && typeof value === "object";
|
|
4082
4308
|
}
|
|
4083
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
|
+
|
|
4084
4534
|
// src/storage/module.ts
|
|
4085
4535
|
var storageSdkManifest = {
|
|
4086
4536
|
namespace: "storage",
|
|
@@ -4129,6 +4579,53 @@ var storageSdkManifest = {
|
|
|
4129
4579
|
responseEnvelope: "raw",
|
|
4130
4580
|
responseType: "{ data: S3CredentialListItem[] }"
|
|
4131
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
|
+
},
|
|
4132
4629
|
{
|
|
4133
4630
|
name: "createStorageUploadUrl",
|
|
4134
4631
|
method: "POST",
|
|
@@ -4784,7 +5281,7 @@ var AthenaStorageError = class extends Error {
|
|
|
4784
5281
|
};
|
|
4785
5282
|
}
|
|
4786
5283
|
};
|
|
4787
|
-
function
|
|
5284
|
+
function isRecord7(value) {
|
|
4788
5285
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4789
5286
|
}
|
|
4790
5287
|
function causeToString(cause) {
|
|
@@ -4882,7 +5379,7 @@ function parseResponseBody3(rawText, contentType) {
|
|
|
4882
5379
|
return { parsed: rawText, parseFailed: true };
|
|
4883
5380
|
}
|
|
4884
5381
|
}
|
|
4885
|
-
function
|
|
5382
|
+
function appendQuery2(path, query) {
|
|
4886
5383
|
if (!query) return path;
|
|
4887
5384
|
const params = new URLSearchParams();
|
|
4888
5385
|
for (const [key, value] of Object.entries(query)) {
|
|
@@ -4908,7 +5405,7 @@ function withPathParam(path, name, value) {
|
|
|
4908
5405
|
return path.replace(`{${name}}`, encodeURIComponent(value));
|
|
4909
5406
|
}
|
|
4910
5407
|
function resolveErrorMessage3(payload, fallback) {
|
|
4911
|
-
if (
|
|
5408
|
+
if (isRecord7(payload)) {
|
|
4912
5409
|
const message = payload.message ?? payload.error ?? payload.details;
|
|
4913
5410
|
if (typeof message === "string" && message.trim()) {
|
|
4914
5411
|
return message.trim();
|
|
@@ -4920,12 +5417,12 @@ function resolveErrorMessage3(payload, fallback) {
|
|
|
4920
5417
|
return fallback;
|
|
4921
5418
|
}
|
|
4922
5419
|
function resolveErrorHint2(payload) {
|
|
4923
|
-
if (!
|
|
5420
|
+
if (!isRecord7(payload)) return void 0;
|
|
4924
5421
|
const hint = payload.hint ?? payload.suggestion;
|
|
4925
5422
|
return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
|
|
4926
5423
|
}
|
|
4927
5424
|
function resolveErrorCause(payload) {
|
|
4928
|
-
if (!
|
|
5425
|
+
if (!isRecord7(payload)) return void 0;
|
|
4929
5426
|
const cause = payload.cause ?? payload.reason;
|
|
4930
5427
|
return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
|
|
4931
5428
|
}
|
|
@@ -5044,7 +5541,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
|
|
|
5044
5541
|
);
|
|
5045
5542
|
}
|
|
5046
5543
|
if (envelope === "athena") {
|
|
5047
|
-
if (!
|
|
5544
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5048
5545
|
return rejectStorageError(
|
|
5049
5546
|
{
|
|
5050
5547
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5152,7 +5649,7 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
|
|
|
5152
5649
|
runtimeOptions
|
|
5153
5650
|
);
|
|
5154
5651
|
}
|
|
5155
|
-
function
|
|
5652
|
+
function isBlobBody2(body) {
|
|
5156
5653
|
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
5157
5654
|
}
|
|
5158
5655
|
function isReadableStreamBody(body) {
|
|
@@ -5161,7 +5658,7 @@ function isReadableStreamBody(body) {
|
|
|
5161
5658
|
async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
|
|
5162
5659
|
const headers = new Headers(uploadHeaders);
|
|
5163
5660
|
Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
|
|
5164
|
-
if (!headers.has("Content-Type") &&
|
|
5661
|
+
if (!headers.has("Content-Type") && isBlobBody2(body) && body.type) {
|
|
5165
5662
|
headers.set("Content-Type", body.type);
|
|
5166
5663
|
}
|
|
5167
5664
|
const init = {
|
|
@@ -5256,7 +5753,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5256
5753
|
}
|
|
5257
5754
|
delete headers["Content-Type"];
|
|
5258
5755
|
delete headers["content-type"];
|
|
5259
|
-
if (
|
|
5756
|
+
if (isBlobBody2(body) && body.type) {
|
|
5260
5757
|
headers["Content-Type"] = body.type;
|
|
5261
5758
|
}
|
|
5262
5759
|
const requestInit = {
|
|
@@ -5341,7 +5838,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5341
5838
|
runtimeOptions
|
|
5342
5839
|
);
|
|
5343
5840
|
}
|
|
5344
|
-
if (!
|
|
5841
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5345
5842
|
return rejectStorageError(
|
|
5346
5843
|
{
|
|
5347
5844
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5413,14 +5910,14 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5413
5910
|
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
|
|
5414
5911
|
},
|
|
5415
5912
|
getStorageFileUrl(fileId, query, options) {
|
|
5416
|
-
const path =
|
|
5913
|
+
const path = appendQuery2(
|
|
5417
5914
|
withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
|
|
5418
5915
|
query
|
|
5419
5916
|
);
|
|
5420
5917
|
return callAthena2(path, "GET", void 0, options);
|
|
5421
5918
|
},
|
|
5422
5919
|
getStorageFileProxy(fileId, query, options) {
|
|
5423
|
-
const path =
|
|
5920
|
+
const path = appendQuery2(
|
|
5424
5921
|
withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
|
|
5425
5922
|
query
|
|
5426
5923
|
);
|
|
@@ -5444,7 +5941,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5444
5941
|
};
|
|
5445
5942
|
const fileFacade = createStorageFileModule(base, runtimeOptions);
|
|
5446
5943
|
const fileUpload = ((input, options) => {
|
|
5447
|
-
if (
|
|
5944
|
+
if (isRecord7(input) && "files" in input) {
|
|
5448
5945
|
return fileFacade.upload(input, options);
|
|
5449
5946
|
}
|
|
5450
5947
|
return base.createStorageUploadUrl(
|
|
@@ -5506,7 +6003,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5506
6003
|
return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
|
|
5507
6004
|
},
|
|
5508
6005
|
proxyUrl(fileId, query, options) {
|
|
5509
|
-
const path =
|
|
6006
|
+
const path = appendQuery2(
|
|
5510
6007
|
withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
|
|
5511
6008
|
query
|
|
5512
6009
|
);
|
|
@@ -5544,7 +6041,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5544
6041
|
},
|
|
5545
6042
|
retention: {
|
|
5546
6043
|
get(fileId, query, options) {
|
|
5547
|
-
const path =
|
|
6044
|
+
const path = appendQuery2(
|
|
5548
6045
|
withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
|
|
5549
6046
|
query
|
|
5550
6047
|
);
|
|
@@ -5746,6 +6243,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5746
6243
|
return callAthena2("/storage/audit/list", "POST", input, options);
|
|
5747
6244
|
}
|
|
5748
6245
|
};
|
|
6246
|
+
const backup = createStorageBackupModule(gateway);
|
|
5749
6247
|
return {
|
|
5750
6248
|
...base,
|
|
5751
6249
|
credentials,
|
|
@@ -5757,6 +6255,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5757
6255
|
bucket,
|
|
5758
6256
|
multipart,
|
|
5759
6257
|
audit,
|
|
6258
|
+
backup,
|
|
5760
6259
|
delete: file.delete
|
|
5761
6260
|
};
|
|
5762
6261
|
}
|
|
@@ -5806,7 +6305,7 @@ function normalizeWsUrl(value, label) {
|
|
|
5806
6305
|
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
5807
6306
|
return parsed.toString().replace(/\/$/, "");
|
|
5808
6307
|
}
|
|
5809
|
-
function
|
|
6308
|
+
function isRecord8(value) {
|
|
5810
6309
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5811
6310
|
}
|
|
5812
6311
|
function parseResponseBody4(rawText, contentType) {
|
|
@@ -5828,7 +6327,7 @@ function resolveRequestId3(headers) {
|
|
|
5828
6327
|
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
5829
6328
|
}
|
|
5830
6329
|
function resolveErrorMessage4(payload, fallback) {
|
|
5831
|
-
if (
|
|
6330
|
+
if (isRecord8(payload)) {
|
|
5832
6331
|
for (const candidate of [payload.error, payload.message, payload.details]) {
|
|
5833
6332
|
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
5834
6333
|
return candidate.trim();
|
|
@@ -6475,7 +6974,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
6475
6974
|
"ilike",
|
|
6476
6975
|
"is"
|
|
6477
6976
|
]);
|
|
6478
|
-
function
|
|
6977
|
+
function isRecord9(value) {
|
|
6479
6978
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6480
6979
|
}
|
|
6481
6980
|
function isUuidString(value) {
|
|
@@ -6488,7 +6987,7 @@ function shouldUseUuidTextComparison(column, value) {
|
|
|
6488
6987
|
return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
|
|
6489
6988
|
}
|
|
6490
6989
|
function isRelationSelectNode(value) {
|
|
6491
|
-
return
|
|
6990
|
+
return isRecord9(value) && isRecord9(value.select);
|
|
6492
6991
|
}
|
|
6493
6992
|
function normalizeIdentifier(value, label) {
|
|
6494
6993
|
const normalized = value.trim();
|
|
@@ -6544,7 +7043,7 @@ function compileRelationToken(key, node) {
|
|
|
6544
7043
|
return `${prefix}${relationToken}(${nested})`;
|
|
6545
7044
|
}
|
|
6546
7045
|
function compileSelectShape(select) {
|
|
6547
|
-
if (!
|
|
7046
|
+
if (!isRecord9(select)) {
|
|
6548
7047
|
throw new Error("findMany select must be an object");
|
|
6549
7048
|
}
|
|
6550
7049
|
const tokens = [];
|
|
@@ -6568,7 +7067,7 @@ function compileSelectShape(select) {
|
|
|
6568
7067
|
return tokens.join(",");
|
|
6569
7068
|
}
|
|
6570
7069
|
function selectShapeUsesRelationSchema(select) {
|
|
6571
|
-
if (!
|
|
7070
|
+
if (!isRecord9(select)) {
|
|
6572
7071
|
return false;
|
|
6573
7072
|
}
|
|
6574
7073
|
for (const rawValue of Object.values(select)) {
|
|
@@ -6586,7 +7085,7 @@ function selectShapeUsesRelationSchema(select) {
|
|
|
6586
7085
|
}
|
|
6587
7086
|
function compileColumnWhere(column, input) {
|
|
6588
7087
|
const normalizedColumn = normalizeIdentifier(column, "where column");
|
|
6589
|
-
if (!
|
|
7088
|
+
if (!isRecord9(input)) {
|
|
6590
7089
|
return [buildGatewayCondition("eq", normalizedColumn, input)];
|
|
6591
7090
|
}
|
|
6592
7091
|
const conditions = [];
|
|
@@ -6614,7 +7113,7 @@ function compileColumnWhere(column, input) {
|
|
|
6614
7113
|
return conditions;
|
|
6615
7114
|
}
|
|
6616
7115
|
function compileBooleanExpressionTerms(clause, label) {
|
|
6617
|
-
if (!
|
|
7116
|
+
if (!isRecord9(clause)) {
|
|
6618
7117
|
throw new Error(`findMany where.${label} clauses must be objects`);
|
|
6619
7118
|
}
|
|
6620
7119
|
const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
|
|
@@ -6623,7 +7122,7 @@ function compileBooleanExpressionTerms(clause, label) {
|
|
|
6623
7122
|
}
|
|
6624
7123
|
const [rawColumn, rawValue] = entries[0];
|
|
6625
7124
|
const column = normalizeIdentifier(rawColumn, `where.${label} column`);
|
|
6626
|
-
if (!
|
|
7125
|
+
if (!isRecord9(rawValue)) {
|
|
6627
7126
|
return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
|
|
6628
7127
|
}
|
|
6629
7128
|
const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
|
|
@@ -6647,7 +7146,7 @@ function compileWhere(where) {
|
|
|
6647
7146
|
if (where === void 0) {
|
|
6648
7147
|
return void 0;
|
|
6649
7148
|
}
|
|
6650
|
-
if (!
|
|
7149
|
+
if (!isRecord9(where)) {
|
|
6651
7150
|
throw new Error("findMany where must be an object");
|
|
6652
7151
|
}
|
|
6653
7152
|
const conditions = [];
|
|
@@ -6697,7 +7196,7 @@ function compileOrderBy(orderBy) {
|
|
|
6697
7196
|
if (orderBy === void 0) {
|
|
6698
7197
|
return void 0;
|
|
6699
7198
|
}
|
|
6700
|
-
if (!
|
|
7199
|
+
if (!isRecord9(orderBy)) {
|
|
6701
7200
|
throw new Error("findMany orderBy must be an object");
|
|
6702
7201
|
}
|
|
6703
7202
|
if ("column" in orderBy) {
|
|
@@ -6872,11 +7371,11 @@ function toFindManyAstOrder(order) {
|
|
|
6872
7371
|
ascending: order.direction !== "descending"
|
|
6873
7372
|
};
|
|
6874
7373
|
}
|
|
6875
|
-
function
|
|
7374
|
+
function isRecord10(value) {
|
|
6876
7375
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6877
7376
|
}
|
|
6878
7377
|
function normalizeFindManyAstColumnPredicate(value) {
|
|
6879
|
-
if (!
|
|
7378
|
+
if (!isRecord10(value)) {
|
|
6880
7379
|
return {
|
|
6881
7380
|
eq: value
|
|
6882
7381
|
};
|
|
@@ -6900,7 +7399,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
|
|
|
6900
7399
|
return normalized;
|
|
6901
7400
|
}
|
|
6902
7401
|
function normalizeFindManyAstWhere(where) {
|
|
6903
|
-
if (!where || !
|
|
7402
|
+
if (!where || !isRecord10(where)) {
|
|
6904
7403
|
return where;
|
|
6905
7404
|
}
|
|
6906
7405
|
const normalized = {};
|
|
@@ -6914,7 +7413,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6914
7413
|
);
|
|
6915
7414
|
continue;
|
|
6916
7415
|
}
|
|
6917
|
-
if (key === "not" &&
|
|
7416
|
+
if (key === "not" && isRecord10(value)) {
|
|
6918
7417
|
normalized.not = normalizeFindManyAstBooleanOperand(
|
|
6919
7418
|
value
|
|
6920
7419
|
);
|
|
@@ -6925,7 +7424,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6925
7424
|
return normalized;
|
|
6926
7425
|
}
|
|
6927
7426
|
function predicateRequiresUuidQueryFallback(column, value) {
|
|
6928
|
-
if (!
|
|
7427
|
+
if (!isRecord10(value)) {
|
|
6929
7428
|
return shouldUseUuidTextComparison(column, value);
|
|
6930
7429
|
}
|
|
6931
7430
|
const eqValue = value.eq;
|
|
@@ -6943,7 +7442,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
|
|
|
6943
7442
|
return false;
|
|
6944
7443
|
}
|
|
6945
7444
|
function findManyAstWhereRequiresLegacyTransport(where) {
|
|
6946
|
-
if (!where || !
|
|
7445
|
+
if (!where || !isRecord10(where)) {
|
|
6947
7446
|
return false;
|
|
6948
7447
|
}
|
|
6949
7448
|
for (const [key, value] of Object.entries(where)) {
|
|
@@ -6958,7 +7457,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
|
|
|
6958
7457
|
}
|
|
6959
7458
|
continue;
|
|
6960
7459
|
}
|
|
6961
|
-
if (key === "not" &&
|
|
7460
|
+
if (key === "not" && isRecord10(value)) {
|
|
6962
7461
|
if (booleanOperandRequiresUuidQueryFallback(value)) {
|
|
6963
7462
|
return true;
|
|
6964
7463
|
}
|
|
@@ -7584,7 +8083,7 @@ async function executeExperimentalRead(experimental, runner) {
|
|
|
7584
8083
|
throw error;
|
|
7585
8084
|
}
|
|
7586
8085
|
}
|
|
7587
|
-
function
|
|
8086
|
+
function isRecord11(value) {
|
|
7588
8087
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7589
8088
|
}
|
|
7590
8089
|
function firstNonEmptyString2(...values) {
|
|
@@ -7596,8 +8095,8 @@ function firstNonEmptyString2(...values) {
|
|
|
7596
8095
|
return void 0;
|
|
7597
8096
|
}
|
|
7598
8097
|
function resolveStructuredErrorPayload2(raw) {
|
|
7599
|
-
if (!
|
|
7600
|
-
return
|
|
8098
|
+
if (!isRecord11(raw)) return null;
|
|
8099
|
+
return isRecord11(raw.error) ? raw.error : raw;
|
|
7601
8100
|
}
|
|
7602
8101
|
function resolveStructuredErrorDetails(payload, message) {
|
|
7603
8102
|
if (!payload || !("details" in payload)) {
|
|
@@ -7613,7 +8112,7 @@ function resolveStructuredErrorDetails(payload, message) {
|
|
|
7613
8112
|
return details;
|
|
7614
8113
|
}
|
|
7615
8114
|
function createResultError(response, result, normalized) {
|
|
7616
|
-
const rawRecord =
|
|
8115
|
+
const rawRecord = isRecord11(response.raw) ? response.raw : null;
|
|
7617
8116
|
const payload = resolveStructuredErrorPayload2(response.raw);
|
|
7618
8117
|
const message = firstNonEmptyString2(
|
|
7619
8118
|
response.error,
|
|
@@ -9522,6 +10021,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9522
10021
|
withOptions: storageWithOptions,
|
|
9523
10022
|
storage: createStorageModule(gateway, {
|
|
9524
10023
|
...config.experimental.storage,
|
|
10024
|
+
...config.experimental.directStorageUpload ? { directUpload: config.experimental.directStorageUpload } : {},
|
|
9525
10025
|
...config.storageUrl ? {
|
|
9526
10026
|
baseUrl: config.storageUrl,
|
|
9527
10027
|
stripBasePath: true
|
|
@@ -9608,7 +10108,7 @@ function resolveNullishValue(mode) {
|
|
|
9608
10108
|
if (mode === "null") return null;
|
|
9609
10109
|
return "";
|
|
9610
10110
|
}
|
|
9611
|
-
function
|
|
10111
|
+
function isRecord12(value) {
|
|
9612
10112
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9613
10113
|
}
|
|
9614
10114
|
function isNullableColumn(model, key) {
|
|
@@ -9617,7 +10117,7 @@ function isNullableColumn(model, key) {
|
|
|
9617
10117
|
}
|
|
9618
10118
|
function toModelFormDefaults(model, values, options) {
|
|
9619
10119
|
const source = values;
|
|
9620
|
-
if (!
|
|
10120
|
+
if (!isRecord12(source)) {
|
|
9621
10121
|
return {};
|
|
9622
10122
|
}
|
|
9623
10123
|
const mode = options?.nullishMode ?? "empty-string";
|
|
@@ -10568,15 +11068,15 @@ function readCookieFromHeaders(headers, name) {
|
|
|
10568
11068
|
}
|
|
10569
11069
|
return parseCookies(cookieHeader).get(name);
|
|
10570
11070
|
}
|
|
10571
|
-
function
|
|
11071
|
+
function isRecord13(value) {
|
|
10572
11072
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
10573
11073
|
}
|
|
10574
11074
|
function resolveSessionCandidate(value) {
|
|
10575
|
-
if (!
|
|
11075
|
+
if (!isRecord13(value)) {
|
|
10576
11076
|
return null;
|
|
10577
11077
|
}
|
|
10578
|
-
const session =
|
|
10579
|
-
const user =
|
|
11078
|
+
const session = isRecord13(value.session) ? value.session : void 0;
|
|
11079
|
+
const user = isRecord13(value.user) ? value.user : void 0;
|
|
10580
11080
|
if (session && typeof session.token === "string" && session.token.length > 0 && user) {
|
|
10581
11081
|
return {
|
|
10582
11082
|
session,
|
|
@@ -10586,7 +11086,7 @@ function resolveSessionCandidate(value) {
|
|
|
10586
11086
|
return null;
|
|
10587
11087
|
}
|
|
10588
11088
|
function inferSessionPair(returned) {
|
|
10589
|
-
return resolveSessionCandidate(returned) ?? (
|
|
11089
|
+
return resolveSessionCandidate(returned) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.session) : null);
|
|
10590
11090
|
}
|
|
10591
11091
|
function resolveResponseHeaders(ctx) {
|
|
10592
11092
|
if (ctx.context.responseHeaders instanceof Headers) {
|