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