@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.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/bin/athena-js.js +0 -0
  3. package/dist/browser.cjs +552 -52
  4. package/dist/browser.cjs.map +1 -1
  5. package/dist/browser.d.cts +9 -9
  6. package/dist/browser.d.ts +9 -9
  7. package/dist/browser.js +552 -52
  8. package/dist/browser.js.map +1 -1
  9. package/dist/cli/index.cjs +545 -45
  10. package/dist/cli/index.cjs.map +1 -1
  11. package/dist/cli/index.d.cts +4 -4
  12. package/dist/cli/index.d.ts +4 -4
  13. package/dist/cli/index.js +545 -45
  14. package/dist/cli/index.js.map +1 -1
  15. package/dist/{client-DVOKSYDI.d.ts → client-uthENhaf.d.ts} +289 -92
  16. package/dist/{client-BJjUwDSg.d.cts → client-wU2J9yqb.d.cts} +289 -92
  17. package/dist/index.cjs +552 -52
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +9 -9
  20. package/dist/index.d.ts +9 -9
  21. package/dist/index.js +552 -52
  22. package/dist/index.js.map +1 -1
  23. package/dist/{model-form-Dw4zEL5a.d.cts → model-form-BE1_Bmdd.d.cts} +2 -2
  24. package/dist/{model-form-yRg71q3H.d.ts → model-form-DcH3R7WD.d.ts} +2 -2
  25. package/dist/{module-DBteUIob.d.ts → module-Ca3_OQqR.d.ts} +5 -5
  26. package/dist/{module-yoX49uQC.d.cts → module-DFGZXCtt.d.cts} +5 -5
  27. package/dist/next/client.cjs +545 -45
  28. package/dist/next/client.cjs.map +1 -1
  29. package/dist/next/client.d.cts +5 -5
  30. package/dist/next/client.d.ts +5 -5
  31. package/dist/next/client.js +545 -45
  32. package/dist/next/client.js.map +1 -1
  33. package/dist/next/server.cjs +545 -45
  34. package/dist/next/server.cjs.map +1 -1
  35. package/dist/next/server.d.cts +5 -5
  36. package/dist/next/server.d.ts +5 -5
  37. package/dist/next/server.js +545 -45
  38. package/dist/next/server.js.map +1 -1
  39. package/dist/{payload-DEOWN_oo.d.ts → payload-BbSCmILD.d.ts} +2 -2
  40. package/dist/{payload-BzVbUgY_.d.cts → payload-zXIwKTQf.d.cts} +2 -2
  41. package/dist/{pipeline-Dwck-wZO.d.cts → pipeline-CwQoD5G9.d.cts} +1 -1
  42. package/dist/{pipeline-Bj6RWt1A.d.ts → pipeline-DqwehoQV.d.ts} +1 -1
  43. package/dist/react.cjs +1 -1
  44. package/dist/react.cjs.map +1 -1
  45. package/dist/react.d.cts +5 -5
  46. package/dist/react.d.ts +5 -5
  47. package/dist/react.js +1 -1
  48. package/dist/react.js.map +1 -1
  49. package/dist/social-providers.cjs +24 -15
  50. package/dist/social-providers.cjs.map +1 -1
  51. package/dist/social-providers.js +24 -15
  52. package/dist/social-providers.js.map +1 -1
  53. package/dist/{types-BU8uJH_b.d.cts → types-6H575ITc.d.cts} +1 -1
  54. package/dist/{types-DPgejxYC.d.ts → types-C1swabT5.d.ts} +2 -2
  55. package/dist/{types-BRP7sfSF.d.ts → types-CD6K05JQ.d.ts} +1 -1
  56. package/dist/{types-CH78O90i.d.cts → types-YQUR7wu0.d.cts} +1 -1
  57. package/dist/{types-CH78O90i.d.ts → types-YQUR7wu0.d.ts} +1 -1
  58. package/dist/{types-CjC9_5ZQ.d.cts → types-dHnjluBC.d.cts} +2 -2
  59. package/dist/utils.d.cts +1 -1
  60. package/dist/utils.d.ts +1 -1
  61. package/package.json +22 -21
package/dist/browser.cjs CHANGED
@@ -1029,7 +1029,7 @@ function buildAthenaRequestHeaders(input) {
1029
1029
 
1030
1030
  // package.json
1031
1031
  var package_default = {
1032
- version: "2.13.0"
1032
+ version: "2.14.0"
1033
1033
  };
1034
1034
 
1035
1035
  // src/sdk-version.ts
@@ -3732,7 +3732,224 @@ async function withRetry(config, fn) {
3732
3732
  throw new Error("withRetry reached an unexpected state");
3733
3733
  }
3734
3734
 
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;
3863
+ }
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 });
3885
+ }
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;
3943
+ }
3944
+
3735
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
+ }
3736
3953
  function createStorageFileModule(base, config = {}) {
3737
3954
  const upload = async (input, options) => {
3738
3955
  const sources = normalizeUploadSources(input);
@@ -3768,16 +3985,25 @@ function createStorageFileModule(base, config = {}) {
3768
3985
  for (let index = 0; index < uploadRequests.length; index += 1) {
3769
3986
  const request2 = uploadRequests[index];
3770
3987
  const uploadUrl = uploadUrls[index];
3771
- 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(
3772
4001
  uploadUrl.upload.url,
3773
4002
  uploadUrl.upload.headers ?? {},
3774
4003
  request2.source,
3775
4004
  input,
3776
4005
  options,
3777
- (progress) => {
3778
- aggregateLoaded[index] = progress.loaded;
3779
- input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3780
- }
4006
+ aggregateProgress
3781
4007
  );
3782
4008
  uploaded.push({
3783
4009
  file: uploadUrl.file,
@@ -3928,7 +4154,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
3928
4154
  resolve(new Response(xhr.response, {
3929
4155
  status: xhr.status,
3930
4156
  statusText: xhr.statusText,
3931
- headers: parseXhrHeaders(xhr.getAllResponseHeaders())
4157
+ headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
3932
4158
  }));
3933
4159
  };
3934
4160
  xhr.onerror = () => {
@@ -4066,7 +4292,7 @@ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoad
4066
4292
  function sum(values) {
4067
4293
  return values.reduce((total, value) => total + value, 0);
4068
4294
  }
4069
- function parseXhrHeaders(raw) {
4295
+ function parseXhrHeaders2(raw) {
4070
4296
  const headers = new Headers();
4071
4297
  for (const line of raw.trim().split(/[\r\n]+/)) {
4072
4298
  const index = line.indexOf(":");
@@ -4083,6 +4309,230 @@ function isRecord5(value) {
4083
4309
  return Boolean(value) && typeof value === "object";
4084
4310
  }
4085
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
+
4086
4536
  // src/storage/module.ts
4087
4537
  var storageSdkManifest = {
4088
4538
  namespace: "storage",
@@ -4131,6 +4581,53 @@ var storageSdkManifest = {
4131
4581
  responseEnvelope: "raw",
4132
4582
  responseType: "{ data: S3CredentialListItem[] }"
4133
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
+ },
4134
4631
  {
4135
4632
  name: "createStorageUploadUrl",
4136
4633
  method: "POST",
@@ -4786,7 +5283,7 @@ var AthenaStorageError = class extends Error {
4786
5283
  };
4787
5284
  }
4788
5285
  };
4789
- function isRecord6(value) {
5286
+ function isRecord7(value) {
4790
5287
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4791
5288
  }
4792
5289
  function causeToString(cause) {
@@ -4884,7 +5381,7 @@ function parseResponseBody3(rawText, contentType) {
4884
5381
  return { parsed: rawText, parseFailed: true };
4885
5382
  }
4886
5383
  }
4887
- function appendQuery(path, query) {
5384
+ function appendQuery2(path, query) {
4888
5385
  if (!query) return path;
4889
5386
  const params = new URLSearchParams();
4890
5387
  for (const [key, value] of Object.entries(query)) {
@@ -4910,7 +5407,7 @@ function withPathParam(path, name, value) {
4910
5407
  return path.replace(`{${name}}`, encodeURIComponent(value));
4911
5408
  }
4912
5409
  function resolveErrorMessage3(payload, fallback) {
4913
- if (isRecord6(payload)) {
5410
+ if (isRecord7(payload)) {
4914
5411
  const message = payload.message ?? payload.error ?? payload.details;
4915
5412
  if (typeof message === "string" && message.trim()) {
4916
5413
  return message.trim();
@@ -4922,12 +5419,12 @@ function resolveErrorMessage3(payload, fallback) {
4922
5419
  return fallback;
4923
5420
  }
4924
5421
  function resolveErrorHint2(payload) {
4925
- if (!isRecord6(payload)) return void 0;
5422
+ if (!isRecord7(payload)) return void 0;
4926
5423
  const hint = payload.hint ?? payload.suggestion;
4927
5424
  return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
4928
5425
  }
4929
5426
  function resolveErrorCause(payload) {
4930
- if (!isRecord6(payload)) return void 0;
5427
+ if (!isRecord7(payload)) return void 0;
4931
5428
  const cause = payload.cause ?? payload.reason;
4932
5429
  return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
4933
5430
  }
@@ -5046,7 +5543,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
5046
5543
  );
5047
5544
  }
5048
5545
  if (envelope === "athena") {
5049
- if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5546
+ if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5050
5547
  return rejectStorageError(
5051
5548
  {
5052
5549
  code: "INVALID_ATHENA_ENVELOPE",
@@ -5154,7 +5651,7 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
5154
5651
  runtimeOptions
5155
5652
  );
5156
5653
  }
5157
- function isBlobBody(body) {
5654
+ function isBlobBody2(body) {
5158
5655
  return typeof Blob !== "undefined" && body instanceof Blob;
5159
5656
  }
5160
5657
  function isReadableStreamBody(body) {
@@ -5163,7 +5660,7 @@ function isReadableStreamBody(body) {
5163
5660
  async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
5164
5661
  const headers = new Headers(uploadHeaders);
5165
5662
  Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
5166
- if (!headers.has("Content-Type") && isBlobBody(body) && body.type) {
5663
+ if (!headers.has("Content-Type") && isBlobBody2(body) && body.type) {
5167
5664
  headers.set("Content-Type", body.type);
5168
5665
  }
5169
5666
  const init = {
@@ -5258,7 +5755,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
5258
5755
  }
5259
5756
  delete headers["Content-Type"];
5260
5757
  delete headers["content-type"];
5261
- if (isBlobBody(body) && body.type) {
5758
+ if (isBlobBody2(body) && body.type) {
5262
5759
  headers["Content-Type"] = body.type;
5263
5760
  }
5264
5761
  const requestInit = {
@@ -5343,7 +5840,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
5343
5840
  runtimeOptions
5344
5841
  );
5345
5842
  }
5346
- if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5843
+ if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5347
5844
  return rejectStorageError(
5348
5845
  {
5349
5846
  code: "INVALID_ATHENA_ENVELOPE",
@@ -5415,14 +5912,14 @@ function createStorageModule(gateway, runtimeOptions) {
5415
5912
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
5416
5913
  },
5417
5914
  getStorageFileUrl(fileId, query, options) {
5418
- const path = appendQuery(
5915
+ const path = appendQuery2(
5419
5916
  withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
5420
5917
  query
5421
5918
  );
5422
5919
  return callAthena2(path, "GET", void 0, options);
5423
5920
  },
5424
5921
  getStorageFileProxy(fileId, query, options) {
5425
- const path = appendQuery(
5922
+ const path = appendQuery2(
5426
5923
  withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
5427
5924
  query
5428
5925
  );
@@ -5446,7 +5943,7 @@ function createStorageModule(gateway, runtimeOptions) {
5446
5943
  };
5447
5944
  const fileFacade = createStorageFileModule(base, runtimeOptions);
5448
5945
  const fileUpload = ((input, options) => {
5449
- if (isRecord6(input) && "files" in input) {
5946
+ if (isRecord7(input) && "files" in input) {
5450
5947
  return fileFacade.upload(input, options);
5451
5948
  }
5452
5949
  return base.createStorageUploadUrl(
@@ -5508,7 +6005,7 @@ function createStorageModule(gateway, runtimeOptions) {
5508
6005
  return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
5509
6006
  },
5510
6007
  proxyUrl(fileId, query, options) {
5511
- const path = appendQuery(
6008
+ const path = appendQuery2(
5512
6009
  withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
5513
6010
  query
5514
6011
  );
@@ -5546,7 +6043,7 @@ function createStorageModule(gateway, runtimeOptions) {
5546
6043
  },
5547
6044
  retention: {
5548
6045
  get(fileId, query, options) {
5549
- const path = appendQuery(
6046
+ const path = appendQuery2(
5550
6047
  withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
5551
6048
  query
5552
6049
  );
@@ -5748,6 +6245,7 @@ function createStorageModule(gateway, runtimeOptions) {
5748
6245
  return callAthena2("/storage/audit/list", "POST", input, options);
5749
6246
  }
5750
6247
  };
6248
+ const backup = createStorageBackupModule(gateway);
5751
6249
  return {
5752
6250
  ...base,
5753
6251
  credentials,
@@ -5759,6 +6257,7 @@ function createStorageModule(gateway, runtimeOptions) {
5759
6257
  bucket,
5760
6258
  multipart,
5761
6259
  audit,
6260
+ backup,
5762
6261
  delete: file.delete
5763
6262
  };
5764
6263
  }
@@ -5808,7 +6307,7 @@ function normalizeWsUrl(value, label) {
5808
6307
  parsed.pathname = parsed.pathname.replace(/\/+$/, "");
5809
6308
  return parsed.toString().replace(/\/$/, "");
5810
6309
  }
5811
- function isRecord7(value) {
6310
+ function isRecord8(value) {
5812
6311
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5813
6312
  }
5814
6313
  function parseResponseBody4(rawText, contentType) {
@@ -5830,7 +6329,7 @@ function resolveRequestId3(headers) {
5830
6329
  return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
5831
6330
  }
5832
6331
  function resolveErrorMessage4(payload, fallback) {
5833
- if (isRecord7(payload)) {
6332
+ if (isRecord8(payload)) {
5834
6333
  for (const candidate of [payload.error, payload.message, payload.details]) {
5835
6334
  if (typeof candidate === "string" && candidate.trim().length > 0) {
5836
6335
  return candidate.trim();
@@ -6477,7 +6976,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
6477
6976
  "ilike",
6478
6977
  "is"
6479
6978
  ]);
6480
- function isRecord8(value) {
6979
+ function isRecord9(value) {
6481
6980
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6482
6981
  }
6483
6982
  function isUuidString(value) {
@@ -6490,7 +6989,7 @@ function shouldUseUuidTextComparison(column, value) {
6490
6989
  return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
6491
6990
  }
6492
6991
  function isRelationSelectNode(value) {
6493
- return isRecord8(value) && isRecord8(value.select);
6992
+ return isRecord9(value) && isRecord9(value.select);
6494
6993
  }
6495
6994
  function normalizeIdentifier(value, label) {
6496
6995
  const normalized = value.trim();
@@ -6546,7 +7045,7 @@ function compileRelationToken(key, node) {
6546
7045
  return `${prefix}${relationToken}(${nested})`;
6547
7046
  }
6548
7047
  function compileSelectShape(select) {
6549
- if (!isRecord8(select)) {
7048
+ if (!isRecord9(select)) {
6550
7049
  throw new Error("findMany select must be an object");
6551
7050
  }
6552
7051
  const tokens = [];
@@ -6570,7 +7069,7 @@ function compileSelectShape(select) {
6570
7069
  return tokens.join(",");
6571
7070
  }
6572
7071
  function selectShapeUsesRelationSchema(select) {
6573
- if (!isRecord8(select)) {
7072
+ if (!isRecord9(select)) {
6574
7073
  return false;
6575
7074
  }
6576
7075
  for (const rawValue of Object.values(select)) {
@@ -6588,7 +7087,7 @@ function selectShapeUsesRelationSchema(select) {
6588
7087
  }
6589
7088
  function compileColumnWhere(column, input) {
6590
7089
  const normalizedColumn = normalizeIdentifier(column, "where column");
6591
- if (!isRecord8(input)) {
7090
+ if (!isRecord9(input)) {
6592
7091
  return [buildGatewayCondition("eq", normalizedColumn, input)];
6593
7092
  }
6594
7093
  const conditions = [];
@@ -6616,7 +7115,7 @@ function compileColumnWhere(column, input) {
6616
7115
  return conditions;
6617
7116
  }
6618
7117
  function compileBooleanExpressionTerms(clause, label) {
6619
- if (!isRecord8(clause)) {
7118
+ if (!isRecord9(clause)) {
6620
7119
  throw new Error(`findMany where.${label} clauses must be objects`);
6621
7120
  }
6622
7121
  const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
@@ -6625,7 +7124,7 @@ function compileBooleanExpressionTerms(clause, label) {
6625
7124
  }
6626
7125
  const [rawColumn, rawValue] = entries[0];
6627
7126
  const column = normalizeIdentifier(rawColumn, `where.${label} column`);
6628
- if (!isRecord8(rawValue)) {
7127
+ if (!isRecord9(rawValue)) {
6629
7128
  return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
6630
7129
  }
6631
7130
  const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
@@ -6649,7 +7148,7 @@ function compileWhere(where) {
6649
7148
  if (where === void 0) {
6650
7149
  return void 0;
6651
7150
  }
6652
- if (!isRecord8(where)) {
7151
+ if (!isRecord9(where)) {
6653
7152
  throw new Error("findMany where must be an object");
6654
7153
  }
6655
7154
  const conditions = [];
@@ -6699,7 +7198,7 @@ function compileOrderBy(orderBy) {
6699
7198
  if (orderBy === void 0) {
6700
7199
  return void 0;
6701
7200
  }
6702
- if (!isRecord8(orderBy)) {
7201
+ if (!isRecord9(orderBy)) {
6703
7202
  throw new Error("findMany orderBy must be an object");
6704
7203
  }
6705
7204
  if ("column" in orderBy) {
@@ -6874,11 +7373,11 @@ function toFindManyAstOrder(order) {
6874
7373
  ascending: order.direction !== "descending"
6875
7374
  };
6876
7375
  }
6877
- function isRecord9(value) {
7376
+ function isRecord10(value) {
6878
7377
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6879
7378
  }
6880
7379
  function normalizeFindManyAstColumnPredicate(value) {
6881
- if (!isRecord9(value)) {
7380
+ if (!isRecord10(value)) {
6882
7381
  return {
6883
7382
  eq: value
6884
7383
  };
@@ -6902,7 +7401,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
6902
7401
  return normalized;
6903
7402
  }
6904
7403
  function normalizeFindManyAstWhere(where) {
6905
- if (!where || !isRecord9(where)) {
7404
+ if (!where || !isRecord10(where)) {
6906
7405
  return where;
6907
7406
  }
6908
7407
  const normalized = {};
@@ -6916,7 +7415,7 @@ function normalizeFindManyAstWhere(where) {
6916
7415
  );
6917
7416
  continue;
6918
7417
  }
6919
- if (key === "not" && isRecord9(value)) {
7418
+ if (key === "not" && isRecord10(value)) {
6920
7419
  normalized.not = normalizeFindManyAstBooleanOperand(
6921
7420
  value
6922
7421
  );
@@ -6927,7 +7426,7 @@ function normalizeFindManyAstWhere(where) {
6927
7426
  return normalized;
6928
7427
  }
6929
7428
  function predicateRequiresUuidQueryFallback(column, value) {
6930
- if (!isRecord9(value)) {
7429
+ if (!isRecord10(value)) {
6931
7430
  return shouldUseUuidTextComparison(column, value);
6932
7431
  }
6933
7432
  const eqValue = value.eq;
@@ -6945,7 +7444,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
6945
7444
  return false;
6946
7445
  }
6947
7446
  function findManyAstWhereRequiresLegacyTransport(where) {
6948
- if (!where || !isRecord9(where)) {
7447
+ if (!where || !isRecord10(where)) {
6949
7448
  return false;
6950
7449
  }
6951
7450
  for (const [key, value] of Object.entries(where)) {
@@ -6960,7 +7459,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
6960
7459
  }
6961
7460
  continue;
6962
7461
  }
6963
- if (key === "not" && isRecord9(value)) {
7462
+ if (key === "not" && isRecord10(value)) {
6964
7463
  if (booleanOperandRequiresUuidQueryFallback(value)) {
6965
7464
  return true;
6966
7465
  }
@@ -7586,7 +8085,7 @@ async function executeExperimentalRead(experimental, runner) {
7586
8085
  throw error;
7587
8086
  }
7588
8087
  }
7589
- function isRecord10(value) {
8088
+ function isRecord11(value) {
7590
8089
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7591
8090
  }
7592
8091
  function firstNonEmptyString2(...values) {
@@ -7598,8 +8097,8 @@ function firstNonEmptyString2(...values) {
7598
8097
  return void 0;
7599
8098
  }
7600
8099
  function resolveStructuredErrorPayload2(raw) {
7601
- if (!isRecord10(raw)) return null;
7602
- return isRecord10(raw.error) ? raw.error : raw;
8100
+ if (!isRecord11(raw)) return null;
8101
+ return isRecord11(raw.error) ? raw.error : raw;
7603
8102
  }
7604
8103
  function resolveStructuredErrorDetails(payload, message) {
7605
8104
  if (!payload || !("details" in payload)) {
@@ -7615,7 +8114,7 @@ function resolveStructuredErrorDetails(payload, message) {
7615
8114
  return details;
7616
8115
  }
7617
8116
  function createResultError(response, result, normalized) {
7618
- const rawRecord = isRecord10(response.raw) ? response.raw : null;
8117
+ const rawRecord = isRecord11(response.raw) ? response.raw : null;
7619
8118
  const payload = resolveStructuredErrorPayload2(response.raw);
7620
8119
  const message = firstNonEmptyString2(
7621
8120
  response.error,
@@ -9524,6 +10023,7 @@ function createClientFromConfig(config, sourceConfig) {
9524
10023
  withOptions: storageWithOptions,
9525
10024
  storage: createStorageModule(gateway, {
9526
10025
  ...config.experimental.storage,
10026
+ ...config.experimental.directStorageUpload ? { directUpload: config.experimental.directStorageUpload } : {},
9527
10027
  ...config.storageUrl ? {
9528
10028
  baseUrl: config.storageUrl,
9529
10029
  stripBasePath: true
@@ -9610,7 +10110,7 @@ function resolveNullishValue(mode) {
9610
10110
  if (mode === "null") return null;
9611
10111
  return "";
9612
10112
  }
9613
- function isRecord11(value) {
10113
+ function isRecord12(value) {
9614
10114
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
9615
10115
  }
9616
10116
  function isNullableColumn(model, key) {
@@ -9619,7 +10119,7 @@ function isNullableColumn(model, key) {
9619
10119
  }
9620
10120
  function toModelFormDefaults(model, values, options) {
9621
10121
  const source = values;
9622
- if (!isRecord11(source)) {
10122
+ if (!isRecord12(source)) {
9623
10123
  return {};
9624
10124
  }
9625
10125
  const mode = options?.nullishMode ?? "empty-string";
@@ -10570,15 +11070,15 @@ function readCookieFromHeaders(headers, name) {
10570
11070
  }
10571
11071
  return parseCookies(cookieHeader).get(name);
10572
11072
  }
10573
- function isRecord12(value) {
11073
+ function isRecord13(value) {
10574
11074
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
10575
11075
  }
10576
11076
  function resolveSessionCandidate(value) {
10577
- if (!isRecord12(value)) {
11077
+ if (!isRecord13(value)) {
10578
11078
  return null;
10579
11079
  }
10580
- const session = isRecord12(value.session) ? value.session : void 0;
10581
- 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;
10582
11082
  if (session && typeof session.token === "string" && session.token.length > 0 && user) {
10583
11083
  return {
10584
11084
  session,
@@ -10588,7 +11088,7 @@ function resolveSessionCandidate(value) {
10588
11088
  return null;
10589
11089
  }
10590
11090
  function inferSessionPair(returned) {
10591
- 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);
10592
11092
  }
10593
11093
  function resolveResponseHeaders(ctx) {
10594
11094
  if (ctx.context.responseHeaders instanceof Headers) {