@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/cli/index.cjs
CHANGED
|
@@ -2231,7 +2231,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
2231
2231
|
|
|
2232
2232
|
// package.json
|
|
2233
2233
|
var package_default = {
|
|
2234
|
-
version: "2.
|
|
2234
|
+
version: "2.14.0"
|
|
2235
2235
|
};
|
|
2236
2236
|
|
|
2237
2237
|
// src/sdk-version.ts
|
|
@@ -4324,7 +4324,224 @@ function createAuthClient(config = {}) {
|
|
|
4324
4324
|
};
|
|
4325
4325
|
}
|
|
4326
4326
|
|
|
4327
|
+
// src/storage/direct-upload.ts
|
|
4328
|
+
var SERVICE = "s3";
|
|
4329
|
+
var TERMINATOR = "aws4_request";
|
|
4330
|
+
async function putDirectStorageUploadBody(config, bucket, storageKey, body, uploadHeaders, signal, onProgress) {
|
|
4331
|
+
if (config.bucket && bucket && config.bucket !== bucket) {
|
|
4332
|
+
throw new Error(
|
|
4333
|
+
`athena.storage.file.upload direct mode bucket mismatch: configured ${config.bucket} but Athena returned ${bucket}`
|
|
4334
|
+
);
|
|
4335
|
+
}
|
|
4336
|
+
const target = createDirectUploadTarget(config, bucket, storageKey);
|
|
4337
|
+
const bytes = await bodyToArrayBuffer(body);
|
|
4338
|
+
const payloadHash = await sha256Hex(bytes);
|
|
4339
|
+
const headers = new Headers(uploadHeaders);
|
|
4340
|
+
if (isBlobBody(body) && body.type && !headers.has("Content-Type")) {
|
|
4341
|
+
headers.set("Content-Type", body.type);
|
|
4342
|
+
}
|
|
4343
|
+
const signed = await signDirectUploadRequest(config, target, headers, payloadHash);
|
|
4344
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
4345
|
+
return putWithXhr(target.toString(), signed, body, signal, onProgress);
|
|
4346
|
+
}
|
|
4347
|
+
onProgress({ loaded: 0 });
|
|
4348
|
+
const response = await fetch(target, {
|
|
4349
|
+
method: "PUT",
|
|
4350
|
+
headers: signed.requestHeaders,
|
|
4351
|
+
body,
|
|
4352
|
+
signal
|
|
4353
|
+
});
|
|
4354
|
+
if (!response.ok) {
|
|
4355
|
+
throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
|
|
4356
|
+
}
|
|
4357
|
+
onProgress({ loaded: bytes.byteLength });
|
|
4358
|
+
return response;
|
|
4359
|
+
}
|
|
4360
|
+
function createDirectUploadTarget(config, bucket, storageKey) {
|
|
4361
|
+
const resolvedBucket = config.bucket ?? bucket;
|
|
4362
|
+
if (!resolvedBucket?.trim()) {
|
|
4363
|
+
throw new Error(
|
|
4364
|
+
"athena.storage.file.upload direct mode requires a bucket in experimental.directStorageUpload or the server upload response"
|
|
4365
|
+
);
|
|
4366
|
+
}
|
|
4367
|
+
if (!storageKey.trim()) {
|
|
4368
|
+
throw new Error("athena.storage.file.upload direct mode requires a storage key");
|
|
4369
|
+
}
|
|
4370
|
+
let endpoint;
|
|
4371
|
+
try {
|
|
4372
|
+
endpoint = new URL(config.endpoint);
|
|
4373
|
+
} catch (error) {
|
|
4374
|
+
throw new Error(
|
|
4375
|
+
`athena.storage.file.upload direct mode received an invalid endpoint: ${error instanceof Error ? error.message : String(error)}`
|
|
4376
|
+
);
|
|
4377
|
+
}
|
|
4378
|
+
if (endpoint.search || endpoint.hash) {
|
|
4379
|
+
throw new Error("athena.storage.file.upload direct mode endpoint must not contain a query or hash");
|
|
4380
|
+
}
|
|
4381
|
+
const endpointPath = endpoint.pathname.replace(/\/+$/, "");
|
|
4382
|
+
const pathParts = config.forcePathStyle === false ? [endpointPath, storageKey] : [endpointPath, resolvedBucket, storageKey];
|
|
4383
|
+
if (config.forcePathStyle === false) {
|
|
4384
|
+
endpoint.hostname = `${resolvedBucket}.${endpoint.hostname}`;
|
|
4385
|
+
}
|
|
4386
|
+
endpoint.pathname = pathParts.filter(Boolean).flatMap((part) => part.split("/")).map(awsEncode).join("/").replace(/^([^/])/, "/$1");
|
|
4387
|
+
return endpoint;
|
|
4388
|
+
}
|
|
4389
|
+
async function signDirectUploadRequest(config, target, inputHeaders, payloadHash) {
|
|
4390
|
+
const accessKeyId = config.accessKeyId.trim();
|
|
4391
|
+
const secretAccessKey = config.secretAccessKey.trim();
|
|
4392
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
4393
|
+
throw new Error(
|
|
4394
|
+
"athena.storage.file.upload direct mode requires accessKeyId and secretAccessKey"
|
|
4395
|
+
);
|
|
4396
|
+
}
|
|
4397
|
+
const now = /* @__PURE__ */ new Date();
|
|
4398
|
+
const amzDate = formatAmzDate(now);
|
|
4399
|
+
const shortDate = amzDate.slice(0, 8);
|
|
4400
|
+
const region = config.region?.trim() || "auto";
|
|
4401
|
+
const headers = {};
|
|
4402
|
+
inputHeaders.forEach((value, key) => {
|
|
4403
|
+
if (key.toLowerCase() !== "authorization" && key.toLowerCase() !== "host") {
|
|
4404
|
+
headers[key.toLowerCase()] = value.trim().replace(/\s+/g, " ");
|
|
4405
|
+
}
|
|
4406
|
+
});
|
|
4407
|
+
headers["x-amz-content-sha256"] = payloadHash;
|
|
4408
|
+
headers["x-amz-date"] = amzDate;
|
|
4409
|
+
if (config.sessionToken?.trim()) {
|
|
4410
|
+
headers["x-amz-security-token"] = config.sessionToken.trim();
|
|
4411
|
+
}
|
|
4412
|
+
const canonicalHeaders = Object.keys(headers).sort().map((key) => `${key}:${headers[key]}
|
|
4413
|
+
`).join("");
|
|
4414
|
+
const signedHeaders = Object.keys(headers).sort().join(";");
|
|
4415
|
+
const canonicalRequest = [
|
|
4416
|
+
"PUT",
|
|
4417
|
+
target.pathname,
|
|
4418
|
+
"",
|
|
4419
|
+
`host:${target.host}
|
|
4420
|
+
${canonicalHeaders}`,
|
|
4421
|
+
`host;${signedHeaders}`,
|
|
4422
|
+
payloadHash
|
|
4423
|
+
].join("\n");
|
|
4424
|
+
const credentialScope = `${shortDate}/${region}/${SERVICE}/${TERMINATOR}`;
|
|
4425
|
+
const stringToSign = [
|
|
4426
|
+
"AWS4-HMAC-SHA256",
|
|
4427
|
+
amzDate,
|
|
4428
|
+
credentialScope,
|
|
4429
|
+
await sha256Hex(canonicalRequest)
|
|
4430
|
+
].join("\n");
|
|
4431
|
+
const dateKey = await hmac(`AWS4${secretAccessKey}`, shortDate);
|
|
4432
|
+
const regionKey = await hmac(dateKey, region);
|
|
4433
|
+
const serviceKey = await hmac(regionKey, SERVICE);
|
|
4434
|
+
const signingKey = await hmac(serviceKey, TERMINATOR);
|
|
4435
|
+
const signature = await hmacHex(signingKey, stringToSign);
|
|
4436
|
+
headers.authorization = `AWS4-HMAC-SHA256 Credential=${accessKeyId}/${credentialScope}, SignedHeaders=host;${signedHeaders}, Signature=${signature}`;
|
|
4437
|
+
return { requestHeaders: headers };
|
|
4438
|
+
}
|
|
4439
|
+
async function putWithXhr(url, signed, body, signal, onProgress) {
|
|
4440
|
+
const Xhr = XMLHttpRequest;
|
|
4441
|
+
if (Xhr === void 0) {
|
|
4442
|
+
return Promise.reject(new Error("athena.storage.file.upload direct mode requires XMLHttpRequest in this runtime"));
|
|
4443
|
+
}
|
|
4444
|
+
return new Promise((resolve3, reject) => {
|
|
4445
|
+
const xhr = new Xhr();
|
|
4446
|
+
const abort = () => xhr.abort();
|
|
4447
|
+
xhr.open("PUT", url);
|
|
4448
|
+
Object.entries(signed.requestHeaders).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
4449
|
+
xhr.upload.onprogress = (event) => onProgress({ loaded: event.loaded });
|
|
4450
|
+
xhr.onload = () => {
|
|
4451
|
+
signal?.removeEventListener("abort", abort);
|
|
4452
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
4453
|
+
reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
|
|
4454
|
+
return;
|
|
4455
|
+
}
|
|
4456
|
+
onProgress({ loaded: bodySize(body) });
|
|
4457
|
+
resolve3(new Response(xhr.response, {
|
|
4458
|
+
status: xhr.status,
|
|
4459
|
+
statusText: xhr.statusText,
|
|
4460
|
+
headers: parseXhrHeaders(xhr.getAllResponseHeaders())
|
|
4461
|
+
}));
|
|
4462
|
+
};
|
|
4463
|
+
xhr.onerror = () => {
|
|
4464
|
+
signal?.removeEventListener("abort", abort);
|
|
4465
|
+
reject(new Error("athena.storage.file.upload failed with a network error"));
|
|
4466
|
+
};
|
|
4467
|
+
xhr.onabort = () => {
|
|
4468
|
+
signal?.removeEventListener("abort", abort);
|
|
4469
|
+
reject(new DOMException("Upload aborted", "AbortError"));
|
|
4470
|
+
};
|
|
4471
|
+
if (signal) {
|
|
4472
|
+
if (signal.aborted) {
|
|
4473
|
+
abort();
|
|
4474
|
+
return;
|
|
4475
|
+
}
|
|
4476
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
4477
|
+
}
|
|
4478
|
+
xhr.send(body);
|
|
4479
|
+
});
|
|
4480
|
+
}
|
|
4481
|
+
function isBlobBody(body) {
|
|
4482
|
+
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
4483
|
+
}
|
|
4484
|
+
async function bodyToArrayBuffer(body) {
|
|
4485
|
+
if (isBlobBody(body)) return body.arrayBuffer();
|
|
4486
|
+
if (body instanceof ArrayBuffer) return body;
|
|
4487
|
+
if (ArrayBuffer.isView(body)) {
|
|
4488
|
+
return body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
4489
|
+
}
|
|
4490
|
+
throw new Error("athena.storage.file.upload direct mode does not support ReadableStream bodies");
|
|
4491
|
+
}
|
|
4492
|
+
function bodySize(body) {
|
|
4493
|
+
if (isBlobBody(body)) return body.size;
|
|
4494
|
+
if (body instanceof ArrayBuffer) return body.byteLength;
|
|
4495
|
+
if (ArrayBuffer.isView(body)) return body.byteLength;
|
|
4496
|
+
return 0;
|
|
4497
|
+
}
|
|
4498
|
+
function awsEncode(value) {
|
|
4499
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
4500
|
+
}
|
|
4501
|
+
function formatAmzDate(date) {
|
|
4502
|
+
return date.toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
4503
|
+
}
|
|
4504
|
+
async function sha256Hex(value) {
|
|
4505
|
+
const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
|
|
4506
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
4507
|
+
return toHex(new Uint8Array(digest));
|
|
4508
|
+
}
|
|
4509
|
+
async function hmac(key, value) {
|
|
4510
|
+
const keyBytes = typeof key === "string" ? new TextEncoder().encode(key) : key;
|
|
4511
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
4512
|
+
"raw",
|
|
4513
|
+
keyBytes,
|
|
4514
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
4515
|
+
false,
|
|
4516
|
+
["sign"]
|
|
4517
|
+
);
|
|
4518
|
+
return crypto.subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(value));
|
|
4519
|
+
}
|
|
4520
|
+
async function hmacHex(key, value) {
|
|
4521
|
+
return toHex(new Uint8Array(await hmac(key, value)));
|
|
4522
|
+
}
|
|
4523
|
+
function toHex(bytes) {
|
|
4524
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
4525
|
+
}
|
|
4526
|
+
function parseXhrHeaders(rawHeaders) {
|
|
4527
|
+
const headers = new Headers();
|
|
4528
|
+
rawHeaders.trim().split(/[\r\n]+/).forEach((line) => {
|
|
4529
|
+
const separator = line.indexOf(":");
|
|
4530
|
+
if (separator > 0) {
|
|
4531
|
+
headers.set(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
4532
|
+
}
|
|
4533
|
+
});
|
|
4534
|
+
return headers;
|
|
4535
|
+
}
|
|
4536
|
+
|
|
4327
4537
|
// src/storage/file.ts
|
|
4538
|
+
function mergeUploadHeaders(serverHeaders, inputHeaders) {
|
|
4539
|
+
const headers = { ...serverHeaders };
|
|
4540
|
+
new Headers(inputHeaders).forEach((value, key) => {
|
|
4541
|
+
headers[key] = value;
|
|
4542
|
+
});
|
|
4543
|
+
return headers;
|
|
4544
|
+
}
|
|
4328
4545
|
function createStorageFileModule(base, config = {}) {
|
|
4329
4546
|
const upload = async (input, options) => {
|
|
4330
4547
|
const sources = normalizeUploadSources(input);
|
|
@@ -4360,16 +4577,25 @@ function createStorageFileModule(base, config = {}) {
|
|
|
4360
4577
|
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
4361
4578
|
const request2 = uploadRequests[index];
|
|
4362
4579
|
const uploadUrl = uploadUrls[index];
|
|
4363
|
-
const
|
|
4580
|
+
const aggregateProgress = (progress) => {
|
|
4581
|
+
aggregateLoaded[index] = progress.loaded;
|
|
4582
|
+
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
4583
|
+
};
|
|
4584
|
+
const response = config.directUpload ? await putDirectStorageUploadBody(
|
|
4585
|
+
config.directUpload,
|
|
4586
|
+
uploadUrl.upload.bucket,
|
|
4587
|
+
uploadUrl.upload.storage_key,
|
|
4588
|
+
request2.source.source,
|
|
4589
|
+
mergeUploadHeaders(uploadUrl.upload.headers ?? {}, input.uploadHeaders),
|
|
4590
|
+
options?.signal,
|
|
4591
|
+
aggregateProgress
|
|
4592
|
+
) : await putUploadBody(
|
|
4364
4593
|
uploadUrl.upload.url,
|
|
4365
4594
|
uploadUrl.upload.headers ?? {},
|
|
4366
4595
|
request2.source,
|
|
4367
4596
|
input,
|
|
4368
4597
|
options,
|
|
4369
|
-
|
|
4370
|
-
aggregateLoaded[index] = progress.loaded;
|
|
4371
|
-
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
4372
|
-
}
|
|
4598
|
+
aggregateProgress
|
|
4373
4599
|
);
|
|
4374
4600
|
uploaded.push({
|
|
4375
4601
|
file: uploadUrl.file,
|
|
@@ -4520,7 +4746,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
|
|
|
4520
4746
|
resolve3(new Response(xhr.response, {
|
|
4521
4747
|
status: xhr.status,
|
|
4522
4748
|
statusText: xhr.statusText,
|
|
4523
|
-
headers:
|
|
4749
|
+
headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
|
|
4524
4750
|
}));
|
|
4525
4751
|
};
|
|
4526
4752
|
xhr.onerror = () => {
|
|
@@ -4658,7 +4884,7 @@ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoad
|
|
|
4658
4884
|
function sum(values) {
|
|
4659
4885
|
return values.reduce((total, value) => total + value, 0);
|
|
4660
4886
|
}
|
|
4661
|
-
function
|
|
4887
|
+
function parseXhrHeaders2(raw) {
|
|
4662
4888
|
const headers = new Headers();
|
|
4663
4889
|
for (const line of raw.trim().split(/[\r\n]+/)) {
|
|
4664
4890
|
const index = line.indexOf(":");
|
|
@@ -4675,6 +4901,230 @@ function isRecord5(value) {
|
|
|
4675
4901
|
return Boolean(value) && typeof value === "object";
|
|
4676
4902
|
}
|
|
4677
4903
|
|
|
4904
|
+
// src/storage/backup.ts
|
|
4905
|
+
function backupError(message, status, endpoint, method, cause, raw) {
|
|
4906
|
+
const error = new Error(message);
|
|
4907
|
+
error.name = "AthenaStorageError";
|
|
4908
|
+
error.code = status === 0 ? "NETWORK_ERROR" : "HTTP_ERROR";
|
|
4909
|
+
error.status = status;
|
|
4910
|
+
error.endpoint = endpoint;
|
|
4911
|
+
error.method = method;
|
|
4912
|
+
error.cause = cause;
|
|
4913
|
+
error.raw = raw;
|
|
4914
|
+
throw error;
|
|
4915
|
+
}
|
|
4916
|
+
function isRecord6(value) {
|
|
4917
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4918
|
+
}
|
|
4919
|
+
function asPath(path) {
|
|
4920
|
+
return path;
|
|
4921
|
+
}
|
|
4922
|
+
function appendQuery(path, query) {
|
|
4923
|
+
if (!query) return path;
|
|
4924
|
+
const params = new URLSearchParams();
|
|
4925
|
+
for (const [key, value] of Object.entries(query)) {
|
|
4926
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
4927
|
+
params.set(key, String(value));
|
|
4928
|
+
}
|
|
4929
|
+
const text = params.toString();
|
|
4930
|
+
return text ? `${path}?${text}` : path;
|
|
4931
|
+
}
|
|
4932
|
+
function unwrapAthenaData(payload) {
|
|
4933
|
+
if (isRecord6(payload) && "data" in payload) {
|
|
4934
|
+
return payload.data;
|
|
4935
|
+
}
|
|
4936
|
+
return payload;
|
|
4937
|
+
}
|
|
4938
|
+
function requireKey(key) {
|
|
4939
|
+
const trimmed = key.trim();
|
|
4940
|
+
if (!trimmed || trimmed === "undefined" || trimmed === "null") {
|
|
4941
|
+
backupError("Backup object key is required", 400, "/admin/backups/{key}", "DELETE");
|
|
4942
|
+
}
|
|
4943
|
+
return trimmed;
|
|
4944
|
+
}
|
|
4945
|
+
function resolveMessage(payload, fallback) {
|
|
4946
|
+
if (isRecord6(payload)) {
|
|
4947
|
+
const message = payload.message ?? payload.error ?? payload.details;
|
|
4948
|
+
if (typeof message === "string" && message.trim()) return message.trim();
|
|
4949
|
+
}
|
|
4950
|
+
if (typeof payload === "string" && payload.trim()) return payload.trim();
|
|
4951
|
+
return fallback;
|
|
4952
|
+
}
|
|
4953
|
+
async function callBackupEndpoint(gateway, path, method, payload, options, runtime) {
|
|
4954
|
+
const endpoint = asPath(path);
|
|
4955
|
+
const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
|
|
4956
|
+
const url = buildAthenaGatewayUrl(baseUrl, endpoint);
|
|
4957
|
+
const headers = gateway.buildHeaders(options);
|
|
4958
|
+
const init = {
|
|
4959
|
+
method,
|
|
4960
|
+
headers,
|
|
4961
|
+
signal: options?.signal
|
|
4962
|
+
};
|
|
4963
|
+
if (payload !== void 0 && method !== "GET") {
|
|
4964
|
+
init.body = JSON.stringify(payload);
|
|
4965
|
+
}
|
|
4966
|
+
let response;
|
|
4967
|
+
try {
|
|
4968
|
+
response = await fetch(url, init);
|
|
4969
|
+
} catch (error) {
|
|
4970
|
+
backupError(
|
|
4971
|
+
error instanceof Error ? error.message : "Backup network error",
|
|
4972
|
+
0,
|
|
4973
|
+
path,
|
|
4974
|
+
method,
|
|
4975
|
+
error
|
|
4976
|
+
);
|
|
4977
|
+
}
|
|
4978
|
+
const rawText = await response.text();
|
|
4979
|
+
let parsed = null;
|
|
4980
|
+
if (rawText) {
|
|
4981
|
+
try {
|
|
4982
|
+
parsed = JSON.parse(rawText);
|
|
4983
|
+
} catch {
|
|
4984
|
+
parsed = rawText;
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
if (!response.ok) {
|
|
4988
|
+
backupError(
|
|
4989
|
+
resolveMessage(parsed, `Backup ${method} ${path} failed (${response.status})`),
|
|
4990
|
+
response.status,
|
|
4991
|
+
path,
|
|
4992
|
+
method,
|
|
4993
|
+
void 0,
|
|
4994
|
+
parsed
|
|
4995
|
+
);
|
|
4996
|
+
}
|
|
4997
|
+
return unwrapAthenaData(parsed);
|
|
4998
|
+
}
|
|
4999
|
+
function createStorageBackupModule(gateway, runtimeOptions) {
|
|
5000
|
+
const resolvedBaseUrl = () => String(gateway.baseUrl ?? "").replace(/\/+$/, "");
|
|
5001
|
+
return {
|
|
5002
|
+
async list(query, options) {
|
|
5003
|
+
const path = appendQuery("/admin/backups", {
|
|
5004
|
+
limit: query?.limit ?? 10,
|
|
5005
|
+
client_name: query?.client_name,
|
|
5006
|
+
cursor: query?.cursor ?? void 0
|
|
5007
|
+
});
|
|
5008
|
+
const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
|
|
5009
|
+
const backups = (data?.backups ?? []).map((row) => ({
|
|
5010
|
+
...row,
|
|
5011
|
+
key: row.key ?? row.s3_key
|
|
5012
|
+
}));
|
|
5013
|
+
return {
|
|
5014
|
+
backups,
|
|
5015
|
+
next_cursor: data?.next_cursor ?? null
|
|
5016
|
+
};
|
|
5017
|
+
},
|
|
5018
|
+
async create(input, options) {
|
|
5019
|
+
const data = await callBackupEndpoint(gateway, "/admin/backups", "POST", input, options);
|
|
5020
|
+
return {
|
|
5021
|
+
job_id: Number(data?.job_id ?? 0),
|
|
5022
|
+
client_name: String(data?.client_name ?? input.client_name),
|
|
5023
|
+
status: String(data?.status ?? "pending")
|
|
5024
|
+
};
|
|
5025
|
+
},
|
|
5026
|
+
async restore(key, input, options) {
|
|
5027
|
+
const backupKey = requireKey(key);
|
|
5028
|
+
const path = `/admin/backups/${encodeURIComponent(backupKey)}/restore`;
|
|
5029
|
+
const data = await callBackupEndpoint(gateway, path, "POST", input, options);
|
|
5030
|
+
return {
|
|
5031
|
+
job_id: Number(data?.job_id ?? 0),
|
|
5032
|
+
client_name: String(data?.client_name ?? input.client_name),
|
|
5033
|
+
status: String(data?.status ?? "pending"),
|
|
5034
|
+
key: String(data?.key ?? backupKey)
|
|
5035
|
+
};
|
|
5036
|
+
},
|
|
5037
|
+
async delete(key, options) {
|
|
5038
|
+
const backupKey = requireKey(key);
|
|
5039
|
+
await callBackupEndpoint(
|
|
5040
|
+
gateway,
|
|
5041
|
+
`/admin/backups/${encodeURIComponent(backupKey)}`,
|
|
5042
|
+
"DELETE",
|
|
5043
|
+
void 0,
|
|
5044
|
+
options);
|
|
5045
|
+
},
|
|
5046
|
+
downloadUrl(key, options) {
|
|
5047
|
+
const backupKey = requireKey(key);
|
|
5048
|
+
const base = `${resolvedBaseUrl()}/admin/backups/${encodeURIComponent(backupKey)}/download`;
|
|
5049
|
+
return options?.apiKey ? `${base}?api_key=${encodeURIComponent(options.apiKey)}` : base;
|
|
5050
|
+
},
|
|
5051
|
+
jobs: {
|
|
5052
|
+
async list(query, options) {
|
|
5053
|
+
const path = appendQuery("/admin/backups/jobs", query ?? {});
|
|
5054
|
+
const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
|
|
5055
|
+
if (Array.isArray(data)) return data;
|
|
5056
|
+
if (isRecord6(data) && Array.isArray(data.jobs)) return data.jobs;
|
|
5057
|
+
return [];
|
|
5058
|
+
},
|
|
5059
|
+
async get(jobId, options) {
|
|
5060
|
+
return callBackupEndpoint(
|
|
5061
|
+
gateway,
|
|
5062
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
|
|
5063
|
+
"GET",
|
|
5064
|
+
void 0,
|
|
5065
|
+
options);
|
|
5066
|
+
},
|
|
5067
|
+
async cancel(jobId, options) {
|
|
5068
|
+
return callBackupEndpoint(
|
|
5069
|
+
gateway,
|
|
5070
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}/cancel`,
|
|
5071
|
+
"POST",
|
|
5072
|
+
{},
|
|
5073
|
+
options);
|
|
5074
|
+
},
|
|
5075
|
+
async delete(jobId, options) {
|
|
5076
|
+
await callBackupEndpoint(
|
|
5077
|
+
gateway,
|
|
5078
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
|
|
5079
|
+
"DELETE",
|
|
5080
|
+
void 0,
|
|
5081
|
+
options);
|
|
5082
|
+
},
|
|
5083
|
+
async openObjectUrl(jobId, options) {
|
|
5084
|
+
const data = await callBackupEndpoint(
|
|
5085
|
+
gateway,
|
|
5086
|
+
`/admin/backups/jobs/${encodeURIComponent(String(jobId))}/s3-open`,
|
|
5087
|
+
"GET",
|
|
5088
|
+
void 0,
|
|
5089
|
+
options);
|
|
5090
|
+
return String(data?.url ?? "");
|
|
5091
|
+
}
|
|
5092
|
+
},
|
|
5093
|
+
schedules: {
|
|
5094
|
+
async list(options) {
|
|
5095
|
+
const data = await callBackupEndpoint(gateway, "/admin/backups/schedules", "GET", void 0, options);
|
|
5096
|
+
if (Array.isArray(data)) return data;
|
|
5097
|
+
if (isRecord6(data) && Array.isArray(data.schedules)) return data.schedules;
|
|
5098
|
+
return [];
|
|
5099
|
+
},
|
|
5100
|
+
async create(input, options) {
|
|
5101
|
+
return callBackupEndpoint(
|
|
5102
|
+
gateway,
|
|
5103
|
+
"/admin/backups/schedules",
|
|
5104
|
+
"POST",
|
|
5105
|
+
input,
|
|
5106
|
+
options);
|
|
5107
|
+
},
|
|
5108
|
+
async update(id, input, options) {
|
|
5109
|
+
return callBackupEndpoint(
|
|
5110
|
+
gateway,
|
|
5111
|
+
`/admin/backups/schedules/${encodeURIComponent(String(id))}`,
|
|
5112
|
+
"PATCH",
|
|
5113
|
+
input,
|
|
5114
|
+
options);
|
|
5115
|
+
},
|
|
5116
|
+
async delete(id, options) {
|
|
5117
|
+
await callBackupEndpoint(
|
|
5118
|
+
gateway,
|
|
5119
|
+
`/admin/backups/schedules/${encodeURIComponent(String(id))}`,
|
|
5120
|
+
"DELETE",
|
|
5121
|
+
void 0,
|
|
5122
|
+
options);
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
};
|
|
5126
|
+
}
|
|
5127
|
+
|
|
4678
5128
|
// src/storage/module.ts
|
|
4679
5129
|
var storageSdkManifest = {
|
|
4680
5130
|
methods: [
|
|
@@ -4717,6 +5167,53 @@ var storageSdkManifest = {
|
|
|
4717
5167
|
responseEnvelope: "raw",
|
|
4718
5168
|
responseType: "{ data: S3CredentialListItem[] }"
|
|
4719
5169
|
},
|
|
5170
|
+
{
|
|
5171
|
+
name: "backup.list",
|
|
5172
|
+
method: "GET",
|
|
5173
|
+
path: "/admin/backups",
|
|
5174
|
+
responseEnvelope: "athena",
|
|
5175
|
+
responseType: "StorageBackupListPage",
|
|
5176
|
+
note: "Admin backup archives on server S3/R2 profile"
|
|
5177
|
+
},
|
|
5178
|
+
{
|
|
5179
|
+
name: "backup.create",
|
|
5180
|
+
method: "POST",
|
|
5181
|
+
path: "/admin/backups",
|
|
5182
|
+
requestType: "StorageBackupCreateRequest",
|
|
5183
|
+
responseEnvelope: "athena",
|
|
5184
|
+
responseType: "StorageBackupQueuedJob"
|
|
5185
|
+
},
|
|
5186
|
+
{
|
|
5187
|
+
name: "backup.restore",
|
|
5188
|
+
method: "POST",
|
|
5189
|
+
path: "/admin/backups/{key}/restore",
|
|
5190
|
+
pathParams: ["key"],
|
|
5191
|
+
requestType: "StorageBackupRestoreRequest",
|
|
5192
|
+
responseEnvelope: "athena",
|
|
5193
|
+
responseType: "StorageBackupQueuedJob"
|
|
5194
|
+
},
|
|
5195
|
+
{
|
|
5196
|
+
name: "backup.delete",
|
|
5197
|
+
method: "DELETE",
|
|
5198
|
+
path: "/admin/backups/{key}",
|
|
5199
|
+
pathParams: ["key"],
|
|
5200
|
+
responseEnvelope: "athena",
|
|
5201
|
+
responseType: "void"
|
|
5202
|
+
},
|
|
5203
|
+
{
|
|
5204
|
+
name: "backup.jobs.list",
|
|
5205
|
+
method: "GET",
|
|
5206
|
+
path: "/admin/backups/jobs",
|
|
5207
|
+
responseEnvelope: "athena",
|
|
5208
|
+
responseType: "StorageBackupJob[]"
|
|
5209
|
+
},
|
|
5210
|
+
{
|
|
5211
|
+
name: "backup.schedules.list",
|
|
5212
|
+
method: "GET",
|
|
5213
|
+
path: "/admin/backups/schedules",
|
|
5214
|
+
responseEnvelope: "athena",
|
|
5215
|
+
responseType: "StorageBackupSchedule[]"
|
|
5216
|
+
},
|
|
4720
5217
|
{
|
|
4721
5218
|
name: "createStorageUploadUrl",
|
|
4722
5219
|
method: "POST",
|
|
@@ -5364,7 +5861,7 @@ var AthenaStorageError = class extends Error {
|
|
|
5364
5861
|
};
|
|
5365
5862
|
}
|
|
5366
5863
|
};
|
|
5367
|
-
function
|
|
5864
|
+
function isRecord7(value) {
|
|
5368
5865
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5369
5866
|
}
|
|
5370
5867
|
function causeToString(cause) {
|
|
@@ -5462,7 +5959,7 @@ function parseResponseBody3(rawText, contentType) {
|
|
|
5462
5959
|
return { parsed: rawText, parseFailed: true };
|
|
5463
5960
|
}
|
|
5464
5961
|
}
|
|
5465
|
-
function
|
|
5962
|
+
function appendQuery2(path, query) {
|
|
5466
5963
|
if (!query) return path;
|
|
5467
5964
|
const params = new URLSearchParams();
|
|
5468
5965
|
for (const [key, value] of Object.entries(query)) {
|
|
@@ -5488,7 +5985,7 @@ function withPathParam(path, name, value) {
|
|
|
5488
5985
|
return path.replace(`{${name}}`, encodeURIComponent(value));
|
|
5489
5986
|
}
|
|
5490
5987
|
function resolveErrorMessage3(payload, fallback) {
|
|
5491
|
-
if (
|
|
5988
|
+
if (isRecord7(payload)) {
|
|
5492
5989
|
const message = payload.message ?? payload.error ?? payload.details;
|
|
5493
5990
|
if (typeof message === "string" && message.trim()) {
|
|
5494
5991
|
return message.trim();
|
|
@@ -5500,12 +5997,12 @@ function resolveErrorMessage3(payload, fallback) {
|
|
|
5500
5997
|
return fallback;
|
|
5501
5998
|
}
|
|
5502
5999
|
function resolveErrorHint2(payload) {
|
|
5503
|
-
if (!
|
|
6000
|
+
if (!isRecord7(payload)) return void 0;
|
|
5504
6001
|
const hint = payload.hint ?? payload.suggestion;
|
|
5505
6002
|
return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
|
|
5506
6003
|
}
|
|
5507
6004
|
function resolveErrorCause(payload) {
|
|
5508
|
-
if (!
|
|
6005
|
+
if (!isRecord7(payload)) return void 0;
|
|
5509
6006
|
const cause = payload.cause ?? payload.reason;
|
|
5510
6007
|
return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
|
|
5511
6008
|
}
|
|
@@ -5624,7 +6121,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
|
|
|
5624
6121
|
);
|
|
5625
6122
|
}
|
|
5626
6123
|
if (envelope === "athena") {
|
|
5627
|
-
if (!
|
|
6124
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5628
6125
|
return rejectStorageError(
|
|
5629
6126
|
{
|
|
5630
6127
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5732,7 +6229,7 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
|
|
|
5732
6229
|
runtimeOptions
|
|
5733
6230
|
);
|
|
5734
6231
|
}
|
|
5735
|
-
function
|
|
6232
|
+
function isBlobBody2(body) {
|
|
5736
6233
|
return typeof Blob !== "undefined" && body instanceof Blob;
|
|
5737
6234
|
}
|
|
5738
6235
|
function isReadableStreamBody(body) {
|
|
@@ -5741,7 +6238,7 @@ function isReadableStreamBody(body) {
|
|
|
5741
6238
|
async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
|
|
5742
6239
|
const headers = new Headers(uploadHeaders);
|
|
5743
6240
|
Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
|
|
5744
|
-
if (!headers.has("Content-Type") &&
|
|
6241
|
+
if (!headers.has("Content-Type") && isBlobBody2(body) && body.type) {
|
|
5745
6242
|
headers.set("Content-Type", body.type);
|
|
5746
6243
|
}
|
|
5747
6244
|
const init = {
|
|
@@ -5836,7 +6333,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5836
6333
|
}
|
|
5837
6334
|
delete headers["Content-Type"];
|
|
5838
6335
|
delete headers["content-type"];
|
|
5839
|
-
if (
|
|
6336
|
+
if (isBlobBody2(body) && body.type) {
|
|
5840
6337
|
headers["Content-Type"] = body.type;
|
|
5841
6338
|
}
|
|
5842
6339
|
const requestInit = {
|
|
@@ -5921,7 +6418,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
|
|
|
5921
6418
|
runtimeOptions
|
|
5922
6419
|
);
|
|
5923
6420
|
}
|
|
5924
|
-
if (!
|
|
6421
|
+
if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
|
|
5925
6422
|
return rejectStorageError(
|
|
5926
6423
|
{
|
|
5927
6424
|
code: "INVALID_ATHENA_ENVELOPE",
|
|
@@ -5993,14 +6490,14 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5993
6490
|
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
|
|
5994
6491
|
},
|
|
5995
6492
|
getStorageFileUrl(fileId, query, options) {
|
|
5996
|
-
const path =
|
|
6493
|
+
const path = appendQuery2(
|
|
5997
6494
|
withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
|
|
5998
6495
|
query
|
|
5999
6496
|
);
|
|
6000
6497
|
return callAthena2(path, "GET", void 0, options);
|
|
6001
6498
|
},
|
|
6002
6499
|
getStorageFileProxy(fileId, query, options) {
|
|
6003
|
-
const path =
|
|
6500
|
+
const path = appendQuery2(
|
|
6004
6501
|
withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
|
|
6005
6502
|
query
|
|
6006
6503
|
);
|
|
@@ -6024,7 +6521,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
6024
6521
|
};
|
|
6025
6522
|
const fileFacade = createStorageFileModule(base, runtimeOptions);
|
|
6026
6523
|
const fileUpload = ((input, options) => {
|
|
6027
|
-
if (
|
|
6524
|
+
if (isRecord7(input) && "files" in input) {
|
|
6028
6525
|
return fileFacade.upload(input, options);
|
|
6029
6526
|
}
|
|
6030
6527
|
return base.createStorageUploadUrl(
|
|
@@ -6086,7 +6583,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
6086
6583
|
return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
|
|
6087
6584
|
},
|
|
6088
6585
|
proxyUrl(fileId, query, options) {
|
|
6089
|
-
const path =
|
|
6586
|
+
const path = appendQuery2(
|
|
6090
6587
|
withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
|
|
6091
6588
|
query
|
|
6092
6589
|
);
|
|
@@ -6124,7 +6621,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
6124
6621
|
},
|
|
6125
6622
|
retention: {
|
|
6126
6623
|
get(fileId, query, options) {
|
|
6127
|
-
const path =
|
|
6624
|
+
const path = appendQuery2(
|
|
6128
6625
|
withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
|
|
6129
6626
|
query
|
|
6130
6627
|
);
|
|
@@ -6326,6 +6823,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
6326
6823
|
return callAthena2("/storage/audit/list", "POST", input, options);
|
|
6327
6824
|
}
|
|
6328
6825
|
};
|
|
6826
|
+
const backup = createStorageBackupModule(gateway);
|
|
6329
6827
|
return {
|
|
6330
6828
|
...base,
|
|
6331
6829
|
credentials,
|
|
@@ -6337,6 +6835,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
6337
6835
|
bucket,
|
|
6338
6836
|
multipart,
|
|
6339
6837
|
audit,
|
|
6838
|
+
backup,
|
|
6340
6839
|
delete: file.delete
|
|
6341
6840
|
};
|
|
6342
6841
|
}
|
|
@@ -6386,7 +6885,7 @@ function normalizeWsUrl(value, label) {
|
|
|
6386
6885
|
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
6387
6886
|
return parsed.toString().replace(/\/$/, "");
|
|
6388
6887
|
}
|
|
6389
|
-
function
|
|
6888
|
+
function isRecord8(value) {
|
|
6390
6889
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6391
6890
|
}
|
|
6392
6891
|
function parseResponseBody4(rawText, contentType) {
|
|
@@ -6408,7 +6907,7 @@ function resolveRequestId3(headers) {
|
|
|
6408
6907
|
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
6409
6908
|
}
|
|
6410
6909
|
function resolveErrorMessage4(payload, fallback) {
|
|
6411
|
-
if (
|
|
6910
|
+
if (isRecord8(payload)) {
|
|
6412
6911
|
for (const candidate of [payload.error, payload.message, payload.details]) {
|
|
6413
6912
|
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
6414
6913
|
return candidate.trim();
|
|
@@ -6817,7 +7316,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
6817
7316
|
"ilike",
|
|
6818
7317
|
"is"
|
|
6819
7318
|
]);
|
|
6820
|
-
function
|
|
7319
|
+
function isRecord9(value) {
|
|
6821
7320
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6822
7321
|
}
|
|
6823
7322
|
function isUuidString(value) {
|
|
@@ -6830,7 +7329,7 @@ function shouldUseUuidTextComparison(column, value) {
|
|
|
6830
7329
|
return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
|
|
6831
7330
|
}
|
|
6832
7331
|
function isRelationSelectNode(value) {
|
|
6833
|
-
return
|
|
7332
|
+
return isRecord9(value) && isRecord9(value.select);
|
|
6834
7333
|
}
|
|
6835
7334
|
function normalizeIdentifier(value, label) {
|
|
6836
7335
|
const normalized = value.trim();
|
|
@@ -6886,7 +7385,7 @@ function compileRelationToken(key, node) {
|
|
|
6886
7385
|
return `${prefix}${relationToken}(${nested})`;
|
|
6887
7386
|
}
|
|
6888
7387
|
function compileSelectShape(select) {
|
|
6889
|
-
if (!
|
|
7388
|
+
if (!isRecord9(select)) {
|
|
6890
7389
|
throw new Error("findMany select must be an object");
|
|
6891
7390
|
}
|
|
6892
7391
|
const tokens = [];
|
|
@@ -6910,7 +7409,7 @@ function compileSelectShape(select) {
|
|
|
6910
7409
|
return tokens.join(",");
|
|
6911
7410
|
}
|
|
6912
7411
|
function selectShapeUsesRelationSchema(select) {
|
|
6913
|
-
if (!
|
|
7412
|
+
if (!isRecord9(select)) {
|
|
6914
7413
|
return false;
|
|
6915
7414
|
}
|
|
6916
7415
|
for (const rawValue of Object.values(select)) {
|
|
@@ -6928,7 +7427,7 @@ function selectShapeUsesRelationSchema(select) {
|
|
|
6928
7427
|
}
|
|
6929
7428
|
function compileColumnWhere(column, input) {
|
|
6930
7429
|
const normalizedColumn = normalizeIdentifier(column, "where column");
|
|
6931
|
-
if (!
|
|
7430
|
+
if (!isRecord9(input)) {
|
|
6932
7431
|
return [buildGatewayCondition("eq", normalizedColumn, input)];
|
|
6933
7432
|
}
|
|
6934
7433
|
const conditions = [];
|
|
@@ -6956,7 +7455,7 @@ function compileColumnWhere(column, input) {
|
|
|
6956
7455
|
return conditions;
|
|
6957
7456
|
}
|
|
6958
7457
|
function compileBooleanExpressionTerms(clause, label) {
|
|
6959
|
-
if (!
|
|
7458
|
+
if (!isRecord9(clause)) {
|
|
6960
7459
|
throw new Error(`findMany where.${label} clauses must be objects`);
|
|
6961
7460
|
}
|
|
6962
7461
|
const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
|
|
@@ -6965,7 +7464,7 @@ function compileBooleanExpressionTerms(clause, label) {
|
|
|
6965
7464
|
}
|
|
6966
7465
|
const [rawColumn, rawValue] = entries[0];
|
|
6967
7466
|
const column = normalizeIdentifier(rawColumn, `where.${label} column`);
|
|
6968
|
-
if (!
|
|
7467
|
+
if (!isRecord9(rawValue)) {
|
|
6969
7468
|
return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
|
|
6970
7469
|
}
|
|
6971
7470
|
const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
|
|
@@ -6989,7 +7488,7 @@ function compileWhere(where) {
|
|
|
6989
7488
|
if (where === void 0) {
|
|
6990
7489
|
return void 0;
|
|
6991
7490
|
}
|
|
6992
|
-
if (!
|
|
7491
|
+
if (!isRecord9(where)) {
|
|
6993
7492
|
throw new Error("findMany where must be an object");
|
|
6994
7493
|
}
|
|
6995
7494
|
const conditions = [];
|
|
@@ -7039,7 +7538,7 @@ function compileOrderBy(orderBy) {
|
|
|
7039
7538
|
if (orderBy === void 0) {
|
|
7040
7539
|
return void 0;
|
|
7041
7540
|
}
|
|
7042
|
-
if (!
|
|
7541
|
+
if (!isRecord9(orderBy)) {
|
|
7043
7542
|
throw new Error("findMany orderBy must be an object");
|
|
7044
7543
|
}
|
|
7045
7544
|
if ("column" in orderBy) {
|
|
@@ -7214,11 +7713,11 @@ function toFindManyAstOrder(order) {
|
|
|
7214
7713
|
ascending: order.direction !== "descending"
|
|
7215
7714
|
};
|
|
7216
7715
|
}
|
|
7217
|
-
function
|
|
7716
|
+
function isRecord10(value) {
|
|
7218
7717
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7219
7718
|
}
|
|
7220
7719
|
function normalizeFindManyAstColumnPredicate(value) {
|
|
7221
|
-
if (!
|
|
7720
|
+
if (!isRecord10(value)) {
|
|
7222
7721
|
return {
|
|
7223
7722
|
eq: value
|
|
7224
7723
|
};
|
|
@@ -7242,7 +7741,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
|
|
|
7242
7741
|
return normalized;
|
|
7243
7742
|
}
|
|
7244
7743
|
function normalizeFindManyAstWhere(where) {
|
|
7245
|
-
if (!where || !
|
|
7744
|
+
if (!where || !isRecord10(where)) {
|
|
7246
7745
|
return where;
|
|
7247
7746
|
}
|
|
7248
7747
|
const normalized = {};
|
|
@@ -7256,7 +7755,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
7256
7755
|
);
|
|
7257
7756
|
continue;
|
|
7258
7757
|
}
|
|
7259
|
-
if (key === "not" &&
|
|
7758
|
+
if (key === "not" && isRecord10(value)) {
|
|
7260
7759
|
normalized.not = normalizeFindManyAstBooleanOperand(
|
|
7261
7760
|
value
|
|
7262
7761
|
);
|
|
@@ -7267,7 +7766,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
7267
7766
|
return normalized;
|
|
7268
7767
|
}
|
|
7269
7768
|
function predicateRequiresUuidQueryFallback(column, value) {
|
|
7270
|
-
if (!
|
|
7769
|
+
if (!isRecord10(value)) {
|
|
7271
7770
|
return shouldUseUuidTextComparison(column, value);
|
|
7272
7771
|
}
|
|
7273
7772
|
const eqValue = value.eq;
|
|
@@ -7285,7 +7784,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
|
|
|
7285
7784
|
return false;
|
|
7286
7785
|
}
|
|
7287
7786
|
function findManyAstWhereRequiresLegacyTransport(where) {
|
|
7288
|
-
if (!where || !
|
|
7787
|
+
if (!where || !isRecord10(where)) {
|
|
7289
7788
|
return false;
|
|
7290
7789
|
}
|
|
7291
7790
|
for (const [key, value] of Object.entries(where)) {
|
|
@@ -7300,7 +7799,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
|
|
|
7300
7799
|
}
|
|
7301
7800
|
continue;
|
|
7302
7801
|
}
|
|
7303
|
-
if (key === "not" &&
|
|
7802
|
+
if (key === "not" && isRecord10(value)) {
|
|
7304
7803
|
if (booleanOperandRequiresUuidQueryFallback(value)) {
|
|
7305
7804
|
return true;
|
|
7306
7805
|
}
|
|
@@ -7920,7 +8419,7 @@ async function executeExperimentalRead(experimental, runner) {
|
|
|
7920
8419
|
throw error;
|
|
7921
8420
|
}
|
|
7922
8421
|
}
|
|
7923
|
-
function
|
|
8422
|
+
function isRecord11(value) {
|
|
7924
8423
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7925
8424
|
}
|
|
7926
8425
|
function firstNonEmptyString2(...values) {
|
|
@@ -7932,8 +8431,8 @@ function firstNonEmptyString2(...values) {
|
|
|
7932
8431
|
return void 0;
|
|
7933
8432
|
}
|
|
7934
8433
|
function resolveStructuredErrorPayload2(raw) {
|
|
7935
|
-
if (!
|
|
7936
|
-
return
|
|
8434
|
+
if (!isRecord11(raw)) return null;
|
|
8435
|
+
return isRecord11(raw.error) ? raw.error : raw;
|
|
7937
8436
|
}
|
|
7938
8437
|
function resolveStructuredErrorDetails(payload, message) {
|
|
7939
8438
|
if (!payload || !("details" in payload)) {
|
|
@@ -7949,7 +8448,7 @@ function resolveStructuredErrorDetails(payload, message) {
|
|
|
7949
8448
|
return details;
|
|
7950
8449
|
}
|
|
7951
8450
|
function createResultError(response, result, normalized) {
|
|
7952
|
-
const rawRecord =
|
|
8451
|
+
const rawRecord = isRecord11(response.raw) ? response.raw : null;
|
|
7953
8452
|
const payload = resolveStructuredErrorPayload2(response.raw);
|
|
7954
8453
|
const message = firstNonEmptyString2(
|
|
7955
8454
|
response.error,
|
|
@@ -9832,6 +10331,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9832
10331
|
withOptions: storageWithOptions,
|
|
9833
10332
|
storage: createStorageModule(gateway, {
|
|
9834
10333
|
...config.experimental.storage,
|
|
10334
|
+
...config.experimental.directStorageUpload ? { directUpload: config.experimental.directStorageUpload } : {},
|
|
9835
10335
|
...config.storageUrl ? {
|
|
9836
10336
|
baseUrl: config.storageUrl,
|
|
9837
10337
|
stripBasePath: true
|