@xylex-group/athena 2.12.1 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1190 -1184
  3. package/bin/athena-js.js +104 -76
  4. package/dist/admin.cjs +45 -0
  5. package/dist/admin.cjs.map +1 -0
  6. package/dist/admin.d.cts +64 -0
  7. package/dist/admin.d.ts +64 -0
  8. package/dist/admin.js +41 -0
  9. package/dist/admin.js.map +1 -0
  10. package/dist/athena-auth-url-oLux_57a.d.cts +377 -0
  11. package/dist/athena-auth-url-oLux_57a.d.ts +377 -0
  12. package/dist/browser.cjs +580 -96
  13. package/dist/browser.cjs.map +1 -1
  14. package/dist/browser.d.cts +12 -10
  15. package/dist/browser.d.ts +12 -10
  16. package/dist/browser.js +580 -96
  17. package/dist/browser.js.map +1 -1
  18. package/dist/cli/index.cjs +690 -91
  19. package/dist/cli/index.cjs.map +1 -1
  20. package/dist/cli/index.d.cts +14 -5
  21. package/dist/cli/index.d.ts +14 -5
  22. package/dist/cli/index.js +690 -92
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/{client-CMtx5P4D.d.cts → client-uthENhaf.d.ts} +346 -1488
  25. package/dist/{client-Dre8H24u.d.ts → client-wU2J9yqb.d.cts} +346 -1488
  26. package/dist/cookies.cjs +18 -0
  27. package/dist/cookies.cjs.map +1 -1
  28. package/dist/cookies.d.cts +2 -1
  29. package/dist/cookies.d.ts +2 -1
  30. package/dist/cookies.js +17 -1
  31. package/dist/cookies.js.map +1 -1
  32. package/dist/{index-CVcQCGyG.d.ts → index-CFL9xbFR.d.cts} +2 -0
  33. package/dist/{index-CVcQCGyG.d.cts → index-UKJpunc6.d.ts} +2 -0
  34. package/dist/index.cjs +648 -96
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +13 -10
  37. package/dist/index.d.ts +13 -10
  38. package/dist/index.js +648 -97
  39. package/dist/index.js.map +1 -1
  40. package/dist/{model-form-DfTi8-D1.d.cts → model-form-BE1_Bmdd.d.cts} +2 -2
  41. package/dist/{model-form-CU0mWrF9.d.ts → model-form-DcH3R7WD.d.ts} +2 -2
  42. package/dist/{module-DBGmbIuh.d.ts → module-Ca3_OQqR.d.ts} +12 -9
  43. package/dist/{module-GoijrBXV.d.cts → module-DFGZXCtt.d.cts} +12 -9
  44. package/dist/next/client.cjs +992 -89
  45. package/dist/next/client.cjs.map +1 -1
  46. package/dist/next/client.d.cts +7 -4
  47. package/dist/next/client.d.ts +7 -4
  48. package/dist/next/client.js +970 -90
  49. package/dist/next/client.js.map +1 -1
  50. package/dist/next/server.cjs +832 -89
  51. package/dist/next/server.cjs.map +1 -1
  52. package/dist/next/server.d.cts +81 -5
  53. package/dist/next/server.d.ts +81 -5
  54. package/dist/next/server.js +820 -90
  55. package/dist/next/server.js.map +1 -1
  56. package/dist/organization.cjs +72 -0
  57. package/dist/organization.cjs.map +1 -0
  58. package/dist/organization.d.cts +43 -0
  59. package/dist/organization.d.ts +43 -0
  60. package/dist/organization.js +70 -0
  61. package/dist/organization.js.map +1 -0
  62. package/dist/payload-BbSCmILD.d.ts +219 -0
  63. package/dist/payload-zXIwKTQf.d.cts +219 -0
  64. package/dist/{pipeline-c7Gdm0qv.d.cts → pipeline-CwQoD5G9.d.cts} +1 -1
  65. package/dist/{pipeline-DrjU2vNA.d.ts → pipeline-DqwehoQV.d.ts} +1 -1
  66. package/dist/react.cjs +2 -13
  67. package/dist/react.cjs.map +1 -1
  68. package/dist/react.d.cts +26 -7
  69. package/dist/react.d.ts +26 -7
  70. package/dist/react.js +2 -13
  71. package/dist/react.js.map +1 -1
  72. package/dist/session-cookie-detection-BqOp9mO6.d.cts +46 -0
  73. package/dist/session-cookie-detection-BqOp9mO6.d.ts +46 -0
  74. package/dist/social-providers.cjs +4198 -0
  75. package/dist/social-providers.cjs.map +1 -0
  76. package/dist/social-providers.d.cts +4948 -0
  77. package/dist/social-providers.d.ts +4948 -0
  78. package/dist/social-providers.js +4126 -0
  79. package/dist/social-providers.js.map +1 -0
  80. package/dist/{types-kPaHUqUa.d.ts → types-6H575ITc.d.cts} +50 -2
  81. package/dist/{types-DRRb0Fd0.d.ts → types-C1swabT5.d.ts} +3 -3
  82. package/dist/{types-Bez4HSbI.d.cts → types-CD6K05JQ.d.ts} +50 -2
  83. package/dist/{types-BRUHGXo2.d.ts → types-YQUR7wu0.d.cts} +3 -3
  84. package/dist/{types-BRUHGXo2.d.cts → types-YQUR7wu0.d.ts} +3 -3
  85. package/dist/{types-BLizCLd1.d.cts → types-dHnjluBC.d.cts} +3 -3
  86. package/dist/types-eAKAh71s.d.cts +1476 -0
  87. package/dist/types-eAKAh71s.d.ts +1476 -0
  88. package/dist/utils.cjs +438 -15
  89. package/dist/utils.cjs.map +1 -1
  90. package/dist/utils.d.cts +76 -11
  91. package/dist/utils.d.ts +76 -11
  92. package/dist/utils.js +390 -16
  93. package/dist/utils.js.map +1 -1
  94. package/package.json +29 -1
  95. package/dist/shared-DZSGAmXs.d.cts +0 -35
  96. package/dist/shared-MMnVBBfy.d.ts +0 -35
package/dist/browser.cjs CHANGED
@@ -802,7 +802,7 @@ var getCookieCache = async (request2, config) => {
802
802
 
803
803
  // src/utils/athena-request-headers.ts
804
804
  var NO_CACHE_HEADER_VALUE = "no-cache";
805
- var API_KEY_HEADER_CANDIDATES = ["X-Api-Key", "x-api-key", "apikey"];
805
+ var API_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key", "X-Api-Key", "x-api-key", "apikey"];
806
806
  var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
807
807
  var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
808
808
  var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
@@ -904,17 +904,6 @@ function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, ex
904
904
  });
905
905
  }
906
906
  function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
907
- if (apiKey) {
908
- if (!hasHeaderIgnoreCase(headers, "apikey")) {
909
- headers.apikey = apiKey;
910
- }
911
- if (!Object.hasOwn(headers, "x-api-key")) {
912
- headers["x-api-key"] = apiKey;
913
- }
914
- if (!Object.hasOwn(headers, "X-Api-Key")) {
915
- headers["X-Api-Key"] = apiKey;
916
- }
917
- }
918
907
  const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
919
908
  if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
920
909
  headers["X-Athena-Key"] = resolvedAthenaKey;
@@ -1040,7 +1029,7 @@ function buildAthenaRequestHeaders(input) {
1040
1029
 
1041
1030
  // package.json
1042
1031
  var package_default = {
1043
- version: "2.12.1"
1032
+ version: "2.14.0"
1044
1033
  };
1045
1034
 
1046
1035
  // src/sdk-version.ts
@@ -3743,39 +3732,224 @@ async function withRetry(config, fn) {
3743
3732
  throw new Error("withRetry reached an unexpected state");
3744
3733
  }
3745
3734
 
3746
- // src/db/module.ts
3747
- function createDbModule(input) {
3748
- const db = {
3749
- from: input.from,
3750
- select(table2, first, second) {
3751
- if (first && typeof first === "object" && !Array.isArray(first)) {
3752
- return input.from(table2).select(void 0, first);
3735
+ // src/storage/direct-upload.ts
3736
+ var SERVICE = "s3";
3737
+ var TERMINATOR = "aws4_request";
3738
+ async function putDirectStorageUploadBody(config, bucket, storageKey, body, uploadHeaders, signal, onProgress) {
3739
+ if (config.bucket && bucket && config.bucket !== bucket) {
3740
+ throw new Error(
3741
+ `athena.storage.file.upload direct mode bucket mismatch: configured ${config.bucket} but Athena returned ${bucket}`
3742
+ );
3743
+ }
3744
+ const target = createDirectUploadTarget(config, bucket, storageKey);
3745
+ const bytes = await bodyToArrayBuffer(body);
3746
+ const payloadHash = await sha256Hex(bytes);
3747
+ const headers = new Headers(uploadHeaders);
3748
+ if (isBlobBody(body) && body.type && !headers.has("Content-Type")) {
3749
+ headers.set("Content-Type", body.type);
3750
+ }
3751
+ const signed = await signDirectUploadRequest(config, target, headers, payloadHash);
3752
+ if (typeof XMLHttpRequest !== "undefined") {
3753
+ return putWithXhr(target.toString(), signed, body, signal, onProgress);
3754
+ }
3755
+ onProgress({ loaded: 0 });
3756
+ const response = await fetch(target, {
3757
+ method: "PUT",
3758
+ headers: signed.requestHeaders,
3759
+ body,
3760
+ signal
3761
+ });
3762
+ if (!response.ok) {
3763
+ throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
3764
+ }
3765
+ onProgress({ loaded: bytes.byteLength });
3766
+ return response;
3767
+ }
3768
+ function createDirectUploadTarget(config, bucket, storageKey) {
3769
+ const resolvedBucket = config.bucket ?? bucket;
3770
+ if (!resolvedBucket?.trim()) {
3771
+ throw new Error(
3772
+ "athena.storage.file.upload direct mode requires a bucket in experimental.directStorageUpload or the server upload response"
3773
+ );
3774
+ }
3775
+ if (!storageKey.trim()) {
3776
+ throw new Error("athena.storage.file.upload direct mode requires a storage key");
3777
+ }
3778
+ let endpoint;
3779
+ try {
3780
+ endpoint = new URL(config.endpoint);
3781
+ } catch (error) {
3782
+ throw new Error(
3783
+ `athena.storage.file.upload direct mode received an invalid endpoint: ${error instanceof Error ? error.message : String(error)}`
3784
+ );
3785
+ }
3786
+ if (endpoint.search || endpoint.hash) {
3787
+ throw new Error("athena.storage.file.upload direct mode endpoint must not contain a query or hash");
3788
+ }
3789
+ const endpointPath = endpoint.pathname.replace(/\/+$/, "");
3790
+ const pathParts = config.forcePathStyle === false ? [endpointPath, storageKey] : [endpointPath, resolvedBucket, storageKey];
3791
+ if (config.forcePathStyle === false) {
3792
+ endpoint.hostname = `${resolvedBucket}.${endpoint.hostname}`;
3793
+ }
3794
+ endpoint.pathname = pathParts.filter(Boolean).flatMap((part) => part.split("/")).map(awsEncode).join("/").replace(/^([^/])/, "/$1");
3795
+ return endpoint;
3796
+ }
3797
+ async function signDirectUploadRequest(config, target, inputHeaders, payloadHash) {
3798
+ const accessKeyId = config.accessKeyId.trim();
3799
+ const secretAccessKey = config.secretAccessKey.trim();
3800
+ if (!accessKeyId || !secretAccessKey) {
3801
+ throw new Error(
3802
+ "athena.storage.file.upload direct mode requires accessKeyId and secretAccessKey"
3803
+ );
3804
+ }
3805
+ const now = /* @__PURE__ */ new Date();
3806
+ const amzDate = formatAmzDate(now);
3807
+ const shortDate = amzDate.slice(0, 8);
3808
+ const region = config.region?.trim() || "auto";
3809
+ const headers = {};
3810
+ inputHeaders.forEach((value, key) => {
3811
+ if (key.toLowerCase() !== "authorization" && key.toLowerCase() !== "host") {
3812
+ headers[key.toLowerCase()] = value.trim().replace(/\s+/g, " ");
3813
+ }
3814
+ });
3815
+ headers["x-amz-content-sha256"] = payloadHash;
3816
+ headers["x-amz-date"] = amzDate;
3817
+ if (config.sessionToken?.trim()) {
3818
+ headers["x-amz-security-token"] = config.sessionToken.trim();
3819
+ }
3820
+ const canonicalHeaders = Object.keys(headers).sort().map((key) => `${key}:${headers[key]}
3821
+ `).join("");
3822
+ const signedHeaders = Object.keys(headers).sort().join(";");
3823
+ const canonicalRequest = [
3824
+ "PUT",
3825
+ target.pathname,
3826
+ "",
3827
+ `host:${target.host}
3828
+ ${canonicalHeaders}`,
3829
+ `host;${signedHeaders}`,
3830
+ payloadHash
3831
+ ].join("\n");
3832
+ const credentialScope = `${shortDate}/${region}/${SERVICE}/${TERMINATOR}`;
3833
+ const stringToSign = [
3834
+ "AWS4-HMAC-SHA256",
3835
+ amzDate,
3836
+ credentialScope,
3837
+ await sha256Hex(canonicalRequest)
3838
+ ].join("\n");
3839
+ const dateKey = await hmac(`AWS4${secretAccessKey}`, shortDate);
3840
+ const regionKey = await hmac(dateKey, region);
3841
+ const serviceKey = await hmac(regionKey, SERVICE);
3842
+ const signingKey = await hmac(serviceKey, TERMINATOR);
3843
+ const signature = await hmacHex(signingKey, stringToSign);
3844
+ headers.authorization = `AWS4-HMAC-SHA256 Credential=${accessKeyId}/${credentialScope}, SignedHeaders=host;${signedHeaders}, Signature=${signature}`;
3845
+ return { requestHeaders: headers };
3846
+ }
3847
+ async function putWithXhr(url, signed, body, signal, onProgress) {
3848
+ const Xhr = XMLHttpRequest;
3849
+ if (Xhr === void 0) {
3850
+ return Promise.reject(new Error("athena.storage.file.upload direct mode requires XMLHttpRequest in this runtime"));
3851
+ }
3852
+ return new Promise((resolve, reject) => {
3853
+ const xhr = new Xhr();
3854
+ const abort = () => xhr.abort();
3855
+ xhr.open("PUT", url);
3856
+ Object.entries(signed.requestHeaders).forEach(([key, value]) => xhr.setRequestHeader(key, value));
3857
+ xhr.upload.onprogress = (event) => onProgress({ loaded: event.loaded });
3858
+ xhr.onload = () => {
3859
+ signal?.removeEventListener("abort", abort);
3860
+ if (xhr.status < 200 || xhr.status >= 300) {
3861
+ reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
3862
+ return;
3753
3863
  }
3754
- return input.from(table2).select(first, second);
3755
- },
3756
- insert(table2, values, options) {
3757
- return Array.isArray(values) ? input.from(table2).insert(values, options) : input.from(table2).insert(values, options);
3758
- },
3759
- upsert(table2, values, options) {
3760
- return Array.isArray(values) ? input.from(table2).upsert(values, options) : input.from(table2).upsert(values, options);
3761
- },
3762
- update(table2, values, options) {
3763
- return input.from(table2).update(values, options);
3764
- },
3765
- delete(table2, options) {
3766
- return input.from(table2).delete(options);
3767
- },
3768
- rpc(fn, args, options) {
3769
- return input.rpc(fn, args, options);
3770
- },
3771
- query(query, options) {
3772
- return input.query(query, options);
3864
+ onProgress({ loaded: bodySize(body) });
3865
+ resolve(new Response(xhr.response, {
3866
+ status: xhr.status,
3867
+ statusText: xhr.statusText,
3868
+ headers: parseXhrHeaders(xhr.getAllResponseHeaders())
3869
+ }));
3870
+ };
3871
+ xhr.onerror = () => {
3872
+ signal?.removeEventListener("abort", abort);
3873
+ reject(new Error("athena.storage.file.upload failed with a network error"));
3874
+ };
3875
+ xhr.onabort = () => {
3876
+ signal?.removeEventListener("abort", abort);
3877
+ reject(new DOMException("Upload aborted", "AbortError"));
3878
+ };
3879
+ if (signal) {
3880
+ if (signal.aborted) {
3881
+ abort();
3882
+ return;
3883
+ }
3884
+ signal.addEventListener("abort", abort, { once: true });
3773
3885
  }
3774
- };
3775
- return db;
3886
+ xhr.send(body);
3887
+ });
3888
+ }
3889
+ function isBlobBody(body) {
3890
+ return typeof Blob !== "undefined" && body instanceof Blob;
3891
+ }
3892
+ async function bodyToArrayBuffer(body) {
3893
+ if (isBlobBody(body)) return body.arrayBuffer();
3894
+ if (body instanceof ArrayBuffer) return body;
3895
+ if (ArrayBuffer.isView(body)) {
3896
+ return body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
3897
+ }
3898
+ throw new Error("athena.storage.file.upload direct mode does not support ReadableStream bodies");
3899
+ }
3900
+ function bodySize(body) {
3901
+ if (isBlobBody(body)) return body.size;
3902
+ if (body instanceof ArrayBuffer) return body.byteLength;
3903
+ if (ArrayBuffer.isView(body)) return body.byteLength;
3904
+ return 0;
3905
+ }
3906
+ function awsEncode(value) {
3907
+ return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
3908
+ }
3909
+ function formatAmzDate(date) {
3910
+ return date.toISOString().replace(/[:-]|\.\d{3}/g, "");
3911
+ }
3912
+ async function sha256Hex(value) {
3913
+ const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
3914
+ const digest = await crypto.subtle.digest("SHA-256", bytes);
3915
+ return toHex(new Uint8Array(digest));
3916
+ }
3917
+ async function hmac(key, value) {
3918
+ const keyBytes = typeof key === "string" ? new TextEncoder().encode(key) : key;
3919
+ const cryptoKey = await crypto.subtle.importKey(
3920
+ "raw",
3921
+ keyBytes,
3922
+ { name: "HMAC", hash: "SHA-256" },
3923
+ false,
3924
+ ["sign"]
3925
+ );
3926
+ return crypto.subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(value));
3927
+ }
3928
+ async function hmacHex(key, value) {
3929
+ return toHex(new Uint8Array(await hmac(key, value)));
3930
+ }
3931
+ function toHex(bytes) {
3932
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
3933
+ }
3934
+ function parseXhrHeaders(rawHeaders) {
3935
+ const headers = new Headers();
3936
+ rawHeaders.trim().split(/[\r\n]+/).forEach((line) => {
3937
+ const separator = line.indexOf(":");
3938
+ if (separator > 0) {
3939
+ headers.set(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
3940
+ }
3941
+ });
3942
+ return headers;
3776
3943
  }
3777
3944
 
3778
3945
  // src/storage/file.ts
3946
+ function mergeUploadHeaders(serverHeaders, inputHeaders) {
3947
+ const headers = { ...serverHeaders };
3948
+ new Headers(inputHeaders).forEach((value, key) => {
3949
+ headers[key] = value;
3950
+ });
3951
+ return headers;
3952
+ }
3779
3953
  function createStorageFileModule(base, config = {}) {
3780
3954
  const upload = async (input, options) => {
3781
3955
  const sources = normalizeUploadSources(input);
@@ -3811,16 +3985,25 @@ function createStorageFileModule(base, config = {}) {
3811
3985
  for (let index = 0; index < uploadRequests.length; index += 1) {
3812
3986
  const request2 = uploadRequests[index];
3813
3987
  const uploadUrl = uploadUrls[index];
3814
- const response = await putUploadBody(
3988
+ const aggregateProgress = (progress) => {
3989
+ aggregateLoaded[index] = progress.loaded;
3990
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3991
+ };
3992
+ const response = config.directUpload ? await putDirectStorageUploadBody(
3993
+ config.directUpload,
3994
+ uploadUrl.upload.bucket,
3995
+ uploadUrl.upload.storage_key,
3996
+ request2.source.source,
3997
+ mergeUploadHeaders(uploadUrl.upload.headers ?? {}, input.uploadHeaders),
3998
+ options?.signal,
3999
+ aggregateProgress
4000
+ ) : await putUploadBody(
3815
4001
  uploadUrl.upload.url,
3816
4002
  uploadUrl.upload.headers ?? {},
3817
4003
  request2.source,
3818
4004
  input,
3819
4005
  options,
3820
- (progress) => {
3821
- aggregateLoaded[index] = progress.loaded;
3822
- input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3823
- }
4006
+ aggregateProgress
3824
4007
  );
3825
4008
  uploaded.push({
3826
4009
  file: uploadUrl.file,
@@ -3971,7 +4154,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
3971
4154
  resolve(new Response(xhr.response, {
3972
4155
  status: xhr.status,
3973
4156
  statusText: xhr.statusText,
3974
- headers: parseXhrHeaders(xhr.getAllResponseHeaders())
4157
+ headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
3975
4158
  }));
3976
4159
  };
3977
4160
  xhr.onerror = () => {
@@ -4109,7 +4292,7 @@ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoad
4109
4292
  function sum(values) {
4110
4293
  return values.reduce((total, value) => total + value, 0);
4111
4294
  }
4112
- function parseXhrHeaders(raw) {
4295
+ function parseXhrHeaders2(raw) {
4113
4296
  const headers = new Headers();
4114
4297
  for (const line of raw.trim().split(/[\r\n]+/)) {
4115
4298
  const index = line.indexOf(":");
@@ -4126,6 +4309,230 @@ function isRecord5(value) {
4126
4309
  return Boolean(value) && typeof value === "object";
4127
4310
  }
4128
4311
 
4312
+ // src/storage/backup.ts
4313
+ function backupError(message, status, endpoint, method, cause, raw) {
4314
+ const error = new Error(message);
4315
+ error.name = "AthenaStorageError";
4316
+ error.code = status === 0 ? "NETWORK_ERROR" : "HTTP_ERROR";
4317
+ error.status = status;
4318
+ error.endpoint = endpoint;
4319
+ error.method = method;
4320
+ error.cause = cause;
4321
+ error.raw = raw;
4322
+ throw error;
4323
+ }
4324
+ function isRecord6(value) {
4325
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4326
+ }
4327
+ function asPath(path) {
4328
+ return path;
4329
+ }
4330
+ function appendQuery(path, query) {
4331
+ if (!query) return path;
4332
+ const params = new URLSearchParams();
4333
+ for (const [key, value] of Object.entries(query)) {
4334
+ if (value === void 0 || value === null || value === "") continue;
4335
+ params.set(key, String(value));
4336
+ }
4337
+ const text = params.toString();
4338
+ return text ? `${path}?${text}` : path;
4339
+ }
4340
+ function unwrapAthenaData(payload) {
4341
+ if (isRecord6(payload) && "data" in payload) {
4342
+ return payload.data;
4343
+ }
4344
+ return payload;
4345
+ }
4346
+ function requireKey(key) {
4347
+ const trimmed = key.trim();
4348
+ if (!trimmed || trimmed === "undefined" || trimmed === "null") {
4349
+ backupError("Backup object key is required", 400, "/admin/backups/{key}", "DELETE");
4350
+ }
4351
+ return trimmed;
4352
+ }
4353
+ function resolveMessage(payload, fallback) {
4354
+ if (isRecord6(payload)) {
4355
+ const message = payload.message ?? payload.error ?? payload.details;
4356
+ if (typeof message === "string" && message.trim()) return message.trim();
4357
+ }
4358
+ if (typeof payload === "string" && payload.trim()) return payload.trim();
4359
+ return fallback;
4360
+ }
4361
+ async function callBackupEndpoint(gateway, path, method, payload, options, runtime) {
4362
+ const endpoint = asPath(path);
4363
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4364
+ const url = buildAthenaGatewayUrl(baseUrl, endpoint);
4365
+ const headers = gateway.buildHeaders(options);
4366
+ const init = {
4367
+ method,
4368
+ headers,
4369
+ signal: options?.signal
4370
+ };
4371
+ if (payload !== void 0 && method !== "GET") {
4372
+ init.body = JSON.stringify(payload);
4373
+ }
4374
+ let response;
4375
+ try {
4376
+ response = await fetch(url, init);
4377
+ } catch (error) {
4378
+ backupError(
4379
+ error instanceof Error ? error.message : "Backup network error",
4380
+ 0,
4381
+ path,
4382
+ method,
4383
+ error
4384
+ );
4385
+ }
4386
+ const rawText = await response.text();
4387
+ let parsed = null;
4388
+ if (rawText) {
4389
+ try {
4390
+ parsed = JSON.parse(rawText);
4391
+ } catch {
4392
+ parsed = rawText;
4393
+ }
4394
+ }
4395
+ if (!response.ok) {
4396
+ backupError(
4397
+ resolveMessage(parsed, `Backup ${method} ${path} failed (${response.status})`),
4398
+ response.status,
4399
+ path,
4400
+ method,
4401
+ void 0,
4402
+ parsed
4403
+ );
4404
+ }
4405
+ return unwrapAthenaData(parsed);
4406
+ }
4407
+ function createStorageBackupModule(gateway, runtimeOptions) {
4408
+ const resolvedBaseUrl = () => String(gateway.baseUrl ?? "").replace(/\/+$/, "");
4409
+ return {
4410
+ async list(query, options) {
4411
+ const path = appendQuery("/admin/backups", {
4412
+ limit: query?.limit ?? 10,
4413
+ client_name: query?.client_name,
4414
+ cursor: query?.cursor ?? void 0
4415
+ });
4416
+ const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
4417
+ const backups = (data?.backups ?? []).map((row) => ({
4418
+ ...row,
4419
+ key: row.key ?? row.s3_key
4420
+ }));
4421
+ return {
4422
+ backups,
4423
+ next_cursor: data?.next_cursor ?? null
4424
+ };
4425
+ },
4426
+ async create(input, options) {
4427
+ const data = await callBackupEndpoint(gateway, "/admin/backups", "POST", input, options);
4428
+ return {
4429
+ job_id: Number(data?.job_id ?? 0),
4430
+ client_name: String(data?.client_name ?? input.client_name),
4431
+ status: String(data?.status ?? "pending")
4432
+ };
4433
+ },
4434
+ async restore(key, input, options) {
4435
+ const backupKey = requireKey(key);
4436
+ const path = `/admin/backups/${encodeURIComponent(backupKey)}/restore`;
4437
+ const data = await callBackupEndpoint(gateway, path, "POST", input, options);
4438
+ return {
4439
+ job_id: Number(data?.job_id ?? 0),
4440
+ client_name: String(data?.client_name ?? input.client_name),
4441
+ status: String(data?.status ?? "pending"),
4442
+ key: String(data?.key ?? backupKey)
4443
+ };
4444
+ },
4445
+ async delete(key, options) {
4446
+ const backupKey = requireKey(key);
4447
+ await callBackupEndpoint(
4448
+ gateway,
4449
+ `/admin/backups/${encodeURIComponent(backupKey)}`,
4450
+ "DELETE",
4451
+ void 0,
4452
+ options);
4453
+ },
4454
+ downloadUrl(key, options) {
4455
+ const backupKey = requireKey(key);
4456
+ const base = `${resolvedBaseUrl()}/admin/backups/${encodeURIComponent(backupKey)}/download`;
4457
+ return options?.apiKey ? `${base}?api_key=${encodeURIComponent(options.apiKey)}` : base;
4458
+ },
4459
+ jobs: {
4460
+ async list(query, options) {
4461
+ const path = appendQuery("/admin/backups/jobs", query ?? {});
4462
+ const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
4463
+ if (Array.isArray(data)) return data;
4464
+ if (isRecord6(data) && Array.isArray(data.jobs)) return data.jobs;
4465
+ return [];
4466
+ },
4467
+ async get(jobId, options) {
4468
+ return callBackupEndpoint(
4469
+ gateway,
4470
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
4471
+ "GET",
4472
+ void 0,
4473
+ options);
4474
+ },
4475
+ async cancel(jobId, options) {
4476
+ return callBackupEndpoint(
4477
+ gateway,
4478
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}/cancel`,
4479
+ "POST",
4480
+ {},
4481
+ options);
4482
+ },
4483
+ async delete(jobId, options) {
4484
+ await callBackupEndpoint(
4485
+ gateway,
4486
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
4487
+ "DELETE",
4488
+ void 0,
4489
+ options);
4490
+ },
4491
+ async openObjectUrl(jobId, options) {
4492
+ const data = await callBackupEndpoint(
4493
+ gateway,
4494
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}/s3-open`,
4495
+ "GET",
4496
+ void 0,
4497
+ options);
4498
+ return String(data?.url ?? "");
4499
+ }
4500
+ },
4501
+ schedules: {
4502
+ async list(options) {
4503
+ const data = await callBackupEndpoint(gateway, "/admin/backups/schedules", "GET", void 0, options);
4504
+ if (Array.isArray(data)) return data;
4505
+ if (isRecord6(data) && Array.isArray(data.schedules)) return data.schedules;
4506
+ return [];
4507
+ },
4508
+ async create(input, options) {
4509
+ return callBackupEndpoint(
4510
+ gateway,
4511
+ "/admin/backups/schedules",
4512
+ "POST",
4513
+ input,
4514
+ options);
4515
+ },
4516
+ async update(id, input, options) {
4517
+ return callBackupEndpoint(
4518
+ gateway,
4519
+ `/admin/backups/schedules/${encodeURIComponent(String(id))}`,
4520
+ "PATCH",
4521
+ input,
4522
+ options);
4523
+ },
4524
+ async delete(id, options) {
4525
+ await callBackupEndpoint(
4526
+ gateway,
4527
+ `/admin/backups/schedules/${encodeURIComponent(String(id))}`,
4528
+ "DELETE",
4529
+ void 0,
4530
+ options);
4531
+ }
4532
+ }
4533
+ };
4534
+ }
4535
+
4129
4536
  // src/storage/module.ts
4130
4537
  var storageSdkManifest = {
4131
4538
  namespace: "storage",
@@ -4174,6 +4581,53 @@ var storageSdkManifest = {
4174
4581
  responseEnvelope: "raw",
4175
4582
  responseType: "{ data: S3CredentialListItem[] }"
4176
4583
  },
4584
+ {
4585
+ name: "backup.list",
4586
+ method: "GET",
4587
+ path: "/admin/backups",
4588
+ responseEnvelope: "athena",
4589
+ responseType: "StorageBackupListPage",
4590
+ note: "Admin backup archives on server S3/R2 profile"
4591
+ },
4592
+ {
4593
+ name: "backup.create",
4594
+ method: "POST",
4595
+ path: "/admin/backups",
4596
+ requestType: "StorageBackupCreateRequest",
4597
+ responseEnvelope: "athena",
4598
+ responseType: "StorageBackupQueuedJob"
4599
+ },
4600
+ {
4601
+ name: "backup.restore",
4602
+ method: "POST",
4603
+ path: "/admin/backups/{key}/restore",
4604
+ pathParams: ["key"],
4605
+ requestType: "StorageBackupRestoreRequest",
4606
+ responseEnvelope: "athena",
4607
+ responseType: "StorageBackupQueuedJob"
4608
+ },
4609
+ {
4610
+ name: "backup.delete",
4611
+ method: "DELETE",
4612
+ path: "/admin/backups/{key}",
4613
+ pathParams: ["key"],
4614
+ responseEnvelope: "athena",
4615
+ responseType: "void"
4616
+ },
4617
+ {
4618
+ name: "backup.jobs.list",
4619
+ method: "GET",
4620
+ path: "/admin/backups/jobs",
4621
+ responseEnvelope: "athena",
4622
+ responseType: "StorageBackupJob[]"
4623
+ },
4624
+ {
4625
+ name: "backup.schedules.list",
4626
+ method: "GET",
4627
+ path: "/admin/backups/schedules",
4628
+ responseEnvelope: "athena",
4629
+ responseType: "StorageBackupSchedule[]"
4630
+ },
4177
4631
  {
4178
4632
  name: "createStorageUploadUrl",
4179
4633
  method: "POST",
@@ -4829,7 +5283,7 @@ var AthenaStorageError = class extends Error {
4829
5283
  };
4830
5284
  }
4831
5285
  };
4832
- function isRecord6(value) {
5286
+ function isRecord7(value) {
4833
5287
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4834
5288
  }
4835
5289
  function causeToString(cause) {
@@ -4927,7 +5381,7 @@ function parseResponseBody3(rawText, contentType) {
4927
5381
  return { parsed: rawText, parseFailed: true };
4928
5382
  }
4929
5383
  }
4930
- function appendQuery(path, query) {
5384
+ function appendQuery2(path, query) {
4931
5385
  if (!query) return path;
4932
5386
  const params = new URLSearchParams();
4933
5387
  for (const [key, value] of Object.entries(query)) {
@@ -4953,7 +5407,7 @@ function withPathParam(path, name, value) {
4953
5407
  return path.replace(`{${name}}`, encodeURIComponent(value));
4954
5408
  }
4955
5409
  function resolveErrorMessage3(payload, fallback) {
4956
- if (isRecord6(payload)) {
5410
+ if (isRecord7(payload)) {
4957
5411
  const message = payload.message ?? payload.error ?? payload.details;
4958
5412
  if (typeof message === "string" && message.trim()) {
4959
5413
  return message.trim();
@@ -4965,12 +5419,12 @@ function resolveErrorMessage3(payload, fallback) {
4965
5419
  return fallback;
4966
5420
  }
4967
5421
  function resolveErrorHint2(payload) {
4968
- if (!isRecord6(payload)) return void 0;
5422
+ if (!isRecord7(payload)) return void 0;
4969
5423
  const hint = payload.hint ?? payload.suggestion;
4970
5424
  return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
4971
5425
  }
4972
5426
  function resolveErrorCause(payload) {
4973
- if (!isRecord6(payload)) return void 0;
5427
+ if (!isRecord7(payload)) return void 0;
4974
5428
  const cause = payload.cause ?? payload.reason;
4975
5429
  return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
4976
5430
  }
@@ -5089,7 +5543,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
5089
5543
  );
5090
5544
  }
5091
5545
  if (envelope === "athena") {
5092
- if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5546
+ if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5093
5547
  return rejectStorageError(
5094
5548
  {
5095
5549
  code: "INVALID_ATHENA_ENVELOPE",
@@ -5197,7 +5651,7 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
5197
5651
  runtimeOptions
5198
5652
  );
5199
5653
  }
5200
- function isBlobBody(body) {
5654
+ function isBlobBody2(body) {
5201
5655
  return typeof Blob !== "undefined" && body instanceof Blob;
5202
5656
  }
5203
5657
  function isReadableStreamBody(body) {
@@ -5206,7 +5660,7 @@ function isReadableStreamBody(body) {
5206
5660
  async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
5207
5661
  const headers = new Headers(uploadHeaders);
5208
5662
  Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
5209
- if (!headers.has("Content-Type") && isBlobBody(body) && body.type) {
5663
+ if (!headers.has("Content-Type") && isBlobBody2(body) && body.type) {
5210
5664
  headers.set("Content-Type", body.type);
5211
5665
  }
5212
5666
  const init = {
@@ -5301,7 +5755,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
5301
5755
  }
5302
5756
  delete headers["Content-Type"];
5303
5757
  delete headers["content-type"];
5304
- if (isBlobBody(body) && body.type) {
5758
+ if (isBlobBody2(body) && body.type) {
5305
5759
  headers["Content-Type"] = body.type;
5306
5760
  }
5307
5761
  const requestInit = {
@@ -5386,7 +5840,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
5386
5840
  runtimeOptions
5387
5841
  );
5388
5842
  }
5389
- if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5843
+ if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5390
5844
  return rejectStorageError(
5391
5845
  {
5392
5846
  code: "INVALID_ATHENA_ENVELOPE",
@@ -5458,14 +5912,14 @@ function createStorageModule(gateway, runtimeOptions) {
5458
5912
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
5459
5913
  },
5460
5914
  getStorageFileUrl(fileId, query, options) {
5461
- const path = appendQuery(
5915
+ const path = appendQuery2(
5462
5916
  withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
5463
5917
  query
5464
5918
  );
5465
5919
  return callAthena2(path, "GET", void 0, options);
5466
5920
  },
5467
5921
  getStorageFileProxy(fileId, query, options) {
5468
- const path = appendQuery(
5922
+ const path = appendQuery2(
5469
5923
  withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
5470
5924
  query
5471
5925
  );
@@ -5489,7 +5943,7 @@ function createStorageModule(gateway, runtimeOptions) {
5489
5943
  };
5490
5944
  const fileFacade = createStorageFileModule(base, runtimeOptions);
5491
5945
  const fileUpload = ((input, options) => {
5492
- if (isRecord6(input) && "files" in input) {
5946
+ if (isRecord7(input) && "files" in input) {
5493
5947
  return fileFacade.upload(input, options);
5494
5948
  }
5495
5949
  return base.createStorageUploadUrl(
@@ -5551,7 +6005,7 @@ function createStorageModule(gateway, runtimeOptions) {
5551
6005
  return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
5552
6006
  },
5553
6007
  proxyUrl(fileId, query, options) {
5554
- const path = appendQuery(
6008
+ const path = appendQuery2(
5555
6009
  withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
5556
6010
  query
5557
6011
  );
@@ -5589,7 +6043,7 @@ function createStorageModule(gateway, runtimeOptions) {
5589
6043
  },
5590
6044
  retention: {
5591
6045
  get(fileId, query, options) {
5592
- const path = appendQuery(
6046
+ const path = appendQuery2(
5593
6047
  withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
5594
6048
  query
5595
6049
  );
@@ -5791,6 +6245,7 @@ function createStorageModule(gateway, runtimeOptions) {
5791
6245
  return callAthena2("/storage/audit/list", "POST", input, options);
5792
6246
  }
5793
6247
  };
6248
+ const backup = createStorageBackupModule(gateway);
5794
6249
  return {
5795
6250
  ...base,
5796
6251
  credentials,
@@ -5802,6 +6257,7 @@ function createStorageModule(gateway, runtimeOptions) {
5802
6257
  bucket,
5803
6258
  multipart,
5804
6259
  audit,
6260
+ backup,
5805
6261
  delete: file.delete
5806
6262
  };
5807
6263
  }
@@ -5851,7 +6307,7 @@ function normalizeWsUrl(value, label) {
5851
6307
  parsed.pathname = parsed.pathname.replace(/\/+$/, "");
5852
6308
  return parsed.toString().replace(/\/$/, "");
5853
6309
  }
5854
- function isRecord7(value) {
6310
+ function isRecord8(value) {
5855
6311
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5856
6312
  }
5857
6313
  function parseResponseBody4(rawText, contentType) {
@@ -5873,7 +6329,7 @@ function resolveRequestId3(headers) {
5873
6329
  return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
5874
6330
  }
5875
6331
  function resolveErrorMessage4(payload, fallback) {
5876
- if (isRecord7(payload)) {
6332
+ if (isRecord8(payload)) {
5877
6333
  for (const candidate of [payload.error, payload.message, payload.details]) {
5878
6334
  if (typeof candidate === "string" && candidate.trim().length > 0) {
5879
6335
  return candidate.trim();
@@ -6520,7 +6976,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
6520
6976
  "ilike",
6521
6977
  "is"
6522
6978
  ]);
6523
- function isRecord8(value) {
6979
+ function isRecord9(value) {
6524
6980
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6525
6981
  }
6526
6982
  function isUuidString(value) {
@@ -6533,7 +6989,7 @@ function shouldUseUuidTextComparison(column, value) {
6533
6989
  return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
6534
6990
  }
6535
6991
  function isRelationSelectNode(value) {
6536
- return isRecord8(value) && isRecord8(value.select);
6992
+ return isRecord9(value) && isRecord9(value.select);
6537
6993
  }
6538
6994
  function normalizeIdentifier(value, label) {
6539
6995
  const normalized = value.trim();
@@ -6589,7 +7045,7 @@ function compileRelationToken(key, node) {
6589
7045
  return `${prefix}${relationToken}(${nested})`;
6590
7046
  }
6591
7047
  function compileSelectShape(select) {
6592
- if (!isRecord8(select)) {
7048
+ if (!isRecord9(select)) {
6593
7049
  throw new Error("findMany select must be an object");
6594
7050
  }
6595
7051
  const tokens = [];
@@ -6613,7 +7069,7 @@ function compileSelectShape(select) {
6613
7069
  return tokens.join(",");
6614
7070
  }
6615
7071
  function selectShapeUsesRelationSchema(select) {
6616
- if (!isRecord8(select)) {
7072
+ if (!isRecord9(select)) {
6617
7073
  return false;
6618
7074
  }
6619
7075
  for (const rawValue of Object.values(select)) {
@@ -6631,7 +7087,7 @@ function selectShapeUsesRelationSchema(select) {
6631
7087
  }
6632
7088
  function compileColumnWhere(column, input) {
6633
7089
  const normalizedColumn = normalizeIdentifier(column, "where column");
6634
- if (!isRecord8(input)) {
7090
+ if (!isRecord9(input)) {
6635
7091
  return [buildGatewayCondition("eq", normalizedColumn, input)];
6636
7092
  }
6637
7093
  const conditions = [];
@@ -6659,7 +7115,7 @@ function compileColumnWhere(column, input) {
6659
7115
  return conditions;
6660
7116
  }
6661
7117
  function compileBooleanExpressionTerms(clause, label) {
6662
- if (!isRecord8(clause)) {
7118
+ if (!isRecord9(clause)) {
6663
7119
  throw new Error(`findMany where.${label} clauses must be objects`);
6664
7120
  }
6665
7121
  const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
@@ -6668,7 +7124,7 @@ function compileBooleanExpressionTerms(clause, label) {
6668
7124
  }
6669
7125
  const [rawColumn, rawValue] = entries[0];
6670
7126
  const column = normalizeIdentifier(rawColumn, `where.${label} column`);
6671
- if (!isRecord8(rawValue)) {
7127
+ if (!isRecord9(rawValue)) {
6672
7128
  return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
6673
7129
  }
6674
7130
  const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
@@ -6692,7 +7148,7 @@ function compileWhere(where) {
6692
7148
  if (where === void 0) {
6693
7149
  return void 0;
6694
7150
  }
6695
- if (!isRecord8(where)) {
7151
+ if (!isRecord9(where)) {
6696
7152
  throw new Error("findMany where must be an object");
6697
7153
  }
6698
7154
  const conditions = [];
@@ -6742,7 +7198,7 @@ function compileOrderBy(orderBy) {
6742
7198
  if (orderBy === void 0) {
6743
7199
  return void 0;
6744
7200
  }
6745
- if (!isRecord8(orderBy)) {
7201
+ if (!isRecord9(orderBy)) {
6746
7202
  throw new Error("findMany orderBy must be an object");
6747
7203
  }
6748
7204
  if ("column" in orderBy) {
@@ -6917,11 +7373,11 @@ function toFindManyAstOrder(order) {
6917
7373
  ascending: order.direction !== "descending"
6918
7374
  };
6919
7375
  }
6920
- function isRecord9(value) {
7376
+ function isRecord10(value) {
6921
7377
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6922
7378
  }
6923
7379
  function normalizeFindManyAstColumnPredicate(value) {
6924
- if (!isRecord9(value)) {
7380
+ if (!isRecord10(value)) {
6925
7381
  return {
6926
7382
  eq: value
6927
7383
  };
@@ -6945,7 +7401,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
6945
7401
  return normalized;
6946
7402
  }
6947
7403
  function normalizeFindManyAstWhere(where) {
6948
- if (!where || !isRecord9(where)) {
7404
+ if (!where || !isRecord10(where)) {
6949
7405
  return where;
6950
7406
  }
6951
7407
  const normalized = {};
@@ -6959,7 +7415,7 @@ function normalizeFindManyAstWhere(where) {
6959
7415
  );
6960
7416
  continue;
6961
7417
  }
6962
- if (key === "not" && isRecord9(value)) {
7418
+ if (key === "not" && isRecord10(value)) {
6963
7419
  normalized.not = normalizeFindManyAstBooleanOperand(
6964
7420
  value
6965
7421
  );
@@ -6970,7 +7426,7 @@ function normalizeFindManyAstWhere(where) {
6970
7426
  return normalized;
6971
7427
  }
6972
7428
  function predicateRequiresUuidQueryFallback(column, value) {
6973
- if (!isRecord9(value)) {
7429
+ if (!isRecord10(value)) {
6974
7430
  return shouldUseUuidTextComparison(column, value);
6975
7431
  }
6976
7432
  const eqValue = value.eq;
@@ -6988,7 +7444,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
6988
7444
  return false;
6989
7445
  }
6990
7446
  function findManyAstWhereRequiresLegacyTransport(where) {
6991
- if (!where || !isRecord9(where)) {
7447
+ if (!where || !isRecord10(where)) {
6992
7448
  return false;
6993
7449
  }
6994
7450
  for (const [key, value] of Object.entries(where)) {
@@ -7003,7 +7459,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
7003
7459
  }
7004
7460
  continue;
7005
7461
  }
7006
- if (key === "not" && isRecord9(value)) {
7462
+ if (key === "not" && isRecord10(value)) {
7007
7463
  if (booleanOperandRequiresUuidQueryFallback(value)) {
7008
7464
  return true;
7009
7465
  }
@@ -7629,7 +8085,7 @@ async function executeExperimentalRead(experimental, runner) {
7629
8085
  throw error;
7630
8086
  }
7631
8087
  }
7632
- function isRecord10(value) {
8088
+ function isRecord11(value) {
7633
8089
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7634
8090
  }
7635
8091
  function firstNonEmptyString2(...values) {
@@ -7641,8 +8097,8 @@ function firstNonEmptyString2(...values) {
7641
8097
  return void 0;
7642
8098
  }
7643
8099
  function resolveStructuredErrorPayload2(raw) {
7644
- if (!isRecord10(raw)) return null;
7645
- return isRecord10(raw.error) ? raw.error : raw;
8100
+ if (!isRecord11(raw)) return null;
8101
+ return isRecord11(raw.error) ? raw.error : raw;
7646
8102
  }
7647
8103
  function resolveStructuredErrorDetails(payload, message) {
7648
8104
  if (!payload || !("details" in payload)) {
@@ -7658,7 +8114,7 @@ function resolveStructuredErrorDetails(payload, message) {
7658
8114
  return details;
7659
8115
  }
7660
8116
  function createResultError(response, result, normalized) {
7661
- const rawRecord = isRecord10(response.raw) ? response.raw : null;
8117
+ const rawRecord = isRecord11(response.raw) ? response.raw : null;
7662
8118
  const payload = resolveStructuredErrorPayload2(response.raw);
7663
8119
  const message = firstNonEmptyString2(
7664
8120
  response.error,
@@ -9406,7 +9862,30 @@ function createClientFromConfig(config, sourceConfig) {
9406
9862
  config.experimental,
9407
9863
  queryTracer
9408
9864
  );
9409
- const db = createDbModule({ from, rpc, query });
9865
+ const untypedDbFrom = from;
9866
+ const db = {
9867
+ from,
9868
+ select(table2, first, second) {
9869
+ if (first && typeof first === "object" && !Array.isArray(first)) {
9870
+ return untypedDbFrom(table2).select(void 0, first);
9871
+ }
9872
+ return untypedDbFrom(table2).select(first, second);
9873
+ },
9874
+ insert(table2, values, options) {
9875
+ return Array.isArray(values) ? untypedDbFrom(table2).insert(values, options) : untypedDbFrom(table2).insert(values, options);
9876
+ },
9877
+ upsert(table2, values, options) {
9878
+ return Array.isArray(values) ? untypedDbFrom(table2).upsert(values, options) : untypedDbFrom(table2).upsert(values, options);
9879
+ },
9880
+ update(table2, values, options) {
9881
+ return untypedDbFrom(table2).update(values, options);
9882
+ },
9883
+ delete(table2, options) {
9884
+ return untypedDbFrom(table2).delete(options);
9885
+ },
9886
+ rpc,
9887
+ query
9888
+ };
9410
9889
  const chat = createChatModule({
9411
9890
  baseUrl: config.chatUrl,
9412
9891
  apiKey: config.apiKey,
@@ -9544,6 +10023,7 @@ function createClientFromConfig(config, sourceConfig) {
9544
10023
  withOptions: storageWithOptions,
9545
10024
  storage: createStorageModule(gateway, {
9546
10025
  ...config.experimental.storage,
10026
+ ...config.experimental.directStorageUpload ? { directUpload: config.experimental.directStorageUpload } : {},
9547
10027
  ...config.storageUrl ? {
9548
10028
  baseUrl: config.storageUrl,
9549
10029
  stripBasePath: true
@@ -9557,7 +10037,9 @@ function createClientFromConfig(config, sourceConfig) {
9557
10037
  var AthenaClient = class {
9558
10038
  /** Create a fluent builder for a strongly-typed Athena SDK client. */
9559
10039
  static builder() {
9560
- return createAthenaClientBuilder((config) => createClientFromInput(config));
10040
+ return createAthenaClientBuilder(
10041
+ (config) => createClientFromInput(config)
10042
+ );
9561
10043
  }
9562
10044
  static fromEnvironment(options = {}) {
9563
10045
  const env = options.env ?? process.env;
@@ -9588,7 +10070,8 @@ var AthenaClient = class {
9588
10070
  });
9589
10071
  }
9590
10072
  };
9591
- function createClient(configOrUrl, apiKey, options) {
10073
+ function createClient(...args) {
10074
+ const [configOrUrl, apiKey, options] = args;
9592
10075
  if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
9593
10076
  return createClientFromInput({
9594
10077
  url: configOrUrl,
@@ -9627,7 +10110,7 @@ function resolveNullishValue(mode) {
9627
10110
  if (mode === "null") return null;
9628
10111
  return "";
9629
10112
  }
9630
- function isRecord11(value) {
10113
+ function isRecord12(value) {
9631
10114
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
9632
10115
  }
9633
10116
  function isNullableColumn(model, key) {
@@ -9636,7 +10119,7 @@ function isNullableColumn(model, key) {
9636
10119
  }
9637
10120
  function toModelFormDefaults(model, values, options) {
9638
10121
  const source = values;
9639
- if (!isRecord11(source)) {
10122
+ if (!isRecord12(source)) {
9640
10123
  return {};
9641
10124
  }
9642
10125
  const mode = options?.nullishMode ?? "empty-string";
@@ -10209,7 +10692,8 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
10209
10692
  fromModel(database, schema, model) {
10210
10693
  const modelDef = this.registryNavigator.resolveModel(database, schema, model);
10211
10694
  const tableName = this.registryNavigator.resolveTableName(schema, model, modelDef);
10212
- return this.baseClient.from(tableName);
10695
+ const from = this.baseClient.from;
10696
+ return from(tableName);
10213
10697
  }
10214
10698
  };
10215
10699
  function createTypedClient(registry, url, apiKey, options) {
@@ -10586,15 +11070,15 @@ function readCookieFromHeaders(headers, name) {
10586
11070
  }
10587
11071
  return parseCookies(cookieHeader).get(name);
10588
11072
  }
10589
- function isRecord12(value) {
11073
+ function isRecord13(value) {
10590
11074
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
10591
11075
  }
10592
11076
  function resolveSessionCandidate(value) {
10593
- if (!isRecord12(value)) {
11077
+ if (!isRecord13(value)) {
10594
11078
  return null;
10595
11079
  }
10596
- const session = isRecord12(value.session) ? value.session : void 0;
10597
- const user = isRecord12(value.user) ? value.user : void 0;
11080
+ const session = isRecord13(value.session) ? value.session : void 0;
11081
+ const user = isRecord13(value.user) ? value.user : void 0;
10598
11082
  if (session && typeof session.token === "string" && session.token.length > 0 && user) {
10599
11083
  return {
10600
11084
  session,
@@ -10604,7 +11088,7 @@ function resolveSessionCandidate(value) {
10604
11088
  return null;
10605
11089
  }
10606
11090
  function inferSessionPair(returned) {
10607
- return resolveSessionCandidate(returned) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.session) : null);
11091
+ return resolveSessionCandidate(returned) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.session) : null);
10608
11092
  }
10609
11093
  function resolveResponseHeaders(ctx) {
10610
11094
  if (ctx.context.responseHeaders instanceof Headers) {