@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/index.js CHANGED
@@ -1031,7 +1031,7 @@ function buildAthenaRequestHeaders(input) {
1031
1031
 
1032
1032
  // package.json
1033
1033
  var package_default = {
1034
- version: "2.13.0"
1034
+ version: "2.14.0"
1035
1035
  };
1036
1036
 
1037
1037
  // src/sdk-version.ts
@@ -3734,7 +3734,224 @@ async function withRetry(config, fn) {
3734
3734
  throw new Error("withRetry reached an unexpected state");
3735
3735
  }
3736
3736
 
3737
+ // src/storage/direct-upload.ts
3738
+ var SERVICE = "s3";
3739
+ var TERMINATOR = "aws4_request";
3740
+ async function putDirectStorageUploadBody(config, bucket, storageKey, body, uploadHeaders, signal, onProgress) {
3741
+ if (config.bucket && bucket && config.bucket !== bucket) {
3742
+ throw new Error(
3743
+ `athena.storage.file.upload direct mode bucket mismatch: configured ${config.bucket} but Athena returned ${bucket}`
3744
+ );
3745
+ }
3746
+ const target = createDirectUploadTarget(config, bucket, storageKey);
3747
+ const bytes = await bodyToArrayBuffer(body);
3748
+ const payloadHash = await sha256Hex(bytes);
3749
+ const headers = new Headers(uploadHeaders);
3750
+ if (isBlobBody(body) && body.type && !headers.has("Content-Type")) {
3751
+ headers.set("Content-Type", body.type);
3752
+ }
3753
+ const signed = await signDirectUploadRequest(config, target, headers, payloadHash);
3754
+ if (typeof XMLHttpRequest !== "undefined") {
3755
+ return putWithXhr(target.toString(), signed, body, signal, onProgress);
3756
+ }
3757
+ onProgress({ loaded: 0 });
3758
+ const response = await fetch(target, {
3759
+ method: "PUT",
3760
+ headers: signed.requestHeaders,
3761
+ body,
3762
+ signal
3763
+ });
3764
+ if (!response.ok) {
3765
+ throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
3766
+ }
3767
+ onProgress({ loaded: bytes.byteLength });
3768
+ return response;
3769
+ }
3770
+ function createDirectUploadTarget(config, bucket, storageKey) {
3771
+ const resolvedBucket = config.bucket ?? bucket;
3772
+ if (!resolvedBucket?.trim()) {
3773
+ throw new Error(
3774
+ "athena.storage.file.upload direct mode requires a bucket in experimental.directStorageUpload or the server upload response"
3775
+ );
3776
+ }
3777
+ if (!storageKey.trim()) {
3778
+ throw new Error("athena.storage.file.upload direct mode requires a storage key");
3779
+ }
3780
+ let endpoint;
3781
+ try {
3782
+ endpoint = new URL(config.endpoint);
3783
+ } catch (error) {
3784
+ throw new Error(
3785
+ `athena.storage.file.upload direct mode received an invalid endpoint: ${error instanceof Error ? error.message : String(error)}`
3786
+ );
3787
+ }
3788
+ if (endpoint.search || endpoint.hash) {
3789
+ throw new Error("athena.storage.file.upload direct mode endpoint must not contain a query or hash");
3790
+ }
3791
+ const endpointPath = endpoint.pathname.replace(/\/+$/, "");
3792
+ const pathParts = config.forcePathStyle === false ? [endpointPath, storageKey] : [endpointPath, resolvedBucket, storageKey];
3793
+ if (config.forcePathStyle === false) {
3794
+ endpoint.hostname = `${resolvedBucket}.${endpoint.hostname}`;
3795
+ }
3796
+ endpoint.pathname = pathParts.filter(Boolean).flatMap((part) => part.split("/")).map(awsEncode).join("/").replace(/^([^/])/, "/$1");
3797
+ return endpoint;
3798
+ }
3799
+ async function signDirectUploadRequest(config, target, inputHeaders, payloadHash) {
3800
+ const accessKeyId = config.accessKeyId.trim();
3801
+ const secretAccessKey = config.secretAccessKey.trim();
3802
+ if (!accessKeyId || !secretAccessKey) {
3803
+ throw new Error(
3804
+ "athena.storage.file.upload direct mode requires accessKeyId and secretAccessKey"
3805
+ );
3806
+ }
3807
+ const now = /* @__PURE__ */ new Date();
3808
+ const amzDate = formatAmzDate(now);
3809
+ const shortDate = amzDate.slice(0, 8);
3810
+ const region = config.region?.trim() || "auto";
3811
+ const headers = {};
3812
+ inputHeaders.forEach((value, key) => {
3813
+ if (key.toLowerCase() !== "authorization" && key.toLowerCase() !== "host") {
3814
+ headers[key.toLowerCase()] = value.trim().replace(/\s+/g, " ");
3815
+ }
3816
+ });
3817
+ headers["x-amz-content-sha256"] = payloadHash;
3818
+ headers["x-amz-date"] = amzDate;
3819
+ if (config.sessionToken?.trim()) {
3820
+ headers["x-amz-security-token"] = config.sessionToken.trim();
3821
+ }
3822
+ const canonicalHeaders = Object.keys(headers).sort().map((key) => `${key}:${headers[key]}
3823
+ `).join("");
3824
+ const signedHeaders = Object.keys(headers).sort().join(";");
3825
+ const canonicalRequest = [
3826
+ "PUT",
3827
+ target.pathname,
3828
+ "",
3829
+ `host:${target.host}
3830
+ ${canonicalHeaders}`,
3831
+ `host;${signedHeaders}`,
3832
+ payloadHash
3833
+ ].join("\n");
3834
+ const credentialScope = `${shortDate}/${region}/${SERVICE}/${TERMINATOR}`;
3835
+ const stringToSign = [
3836
+ "AWS4-HMAC-SHA256",
3837
+ amzDate,
3838
+ credentialScope,
3839
+ await sha256Hex(canonicalRequest)
3840
+ ].join("\n");
3841
+ const dateKey = await hmac(`AWS4${secretAccessKey}`, shortDate);
3842
+ const regionKey = await hmac(dateKey, region);
3843
+ const serviceKey = await hmac(regionKey, SERVICE);
3844
+ const signingKey = await hmac(serviceKey, TERMINATOR);
3845
+ const signature = await hmacHex(signingKey, stringToSign);
3846
+ headers.authorization = `AWS4-HMAC-SHA256 Credential=${accessKeyId}/${credentialScope}, SignedHeaders=host;${signedHeaders}, Signature=${signature}`;
3847
+ return { requestHeaders: headers };
3848
+ }
3849
+ async function putWithXhr(url, signed, body, signal, onProgress) {
3850
+ const Xhr = XMLHttpRequest;
3851
+ if (Xhr === void 0) {
3852
+ return Promise.reject(new Error("athena.storage.file.upload direct mode requires XMLHttpRequest in this runtime"));
3853
+ }
3854
+ return new Promise((resolve3, reject) => {
3855
+ const xhr = new Xhr();
3856
+ const abort = () => xhr.abort();
3857
+ xhr.open("PUT", url);
3858
+ Object.entries(signed.requestHeaders).forEach(([key, value]) => xhr.setRequestHeader(key, value));
3859
+ xhr.upload.onprogress = (event) => onProgress({ loaded: event.loaded });
3860
+ xhr.onload = () => {
3861
+ signal?.removeEventListener("abort", abort);
3862
+ if (xhr.status < 200 || xhr.status >= 300) {
3863
+ reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
3864
+ return;
3865
+ }
3866
+ onProgress({ loaded: bodySize(body) });
3867
+ resolve3(new Response(xhr.response, {
3868
+ status: xhr.status,
3869
+ statusText: xhr.statusText,
3870
+ headers: parseXhrHeaders(xhr.getAllResponseHeaders())
3871
+ }));
3872
+ };
3873
+ xhr.onerror = () => {
3874
+ signal?.removeEventListener("abort", abort);
3875
+ reject(new Error("athena.storage.file.upload failed with a network error"));
3876
+ };
3877
+ xhr.onabort = () => {
3878
+ signal?.removeEventListener("abort", abort);
3879
+ reject(new DOMException("Upload aborted", "AbortError"));
3880
+ };
3881
+ if (signal) {
3882
+ if (signal.aborted) {
3883
+ abort();
3884
+ return;
3885
+ }
3886
+ signal.addEventListener("abort", abort, { once: true });
3887
+ }
3888
+ xhr.send(body);
3889
+ });
3890
+ }
3891
+ function isBlobBody(body) {
3892
+ return typeof Blob !== "undefined" && body instanceof Blob;
3893
+ }
3894
+ async function bodyToArrayBuffer(body) {
3895
+ if (isBlobBody(body)) return body.arrayBuffer();
3896
+ if (body instanceof ArrayBuffer) return body;
3897
+ if (ArrayBuffer.isView(body)) {
3898
+ return body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
3899
+ }
3900
+ throw new Error("athena.storage.file.upload direct mode does not support ReadableStream bodies");
3901
+ }
3902
+ function bodySize(body) {
3903
+ if (isBlobBody(body)) return body.size;
3904
+ if (body instanceof ArrayBuffer) return body.byteLength;
3905
+ if (ArrayBuffer.isView(body)) return body.byteLength;
3906
+ return 0;
3907
+ }
3908
+ function awsEncode(value) {
3909
+ return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
3910
+ }
3911
+ function formatAmzDate(date) {
3912
+ return date.toISOString().replace(/[:-]|\.\d{3}/g, "");
3913
+ }
3914
+ async function sha256Hex(value) {
3915
+ const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
3916
+ const digest = await crypto.subtle.digest("SHA-256", bytes);
3917
+ return toHex(new Uint8Array(digest));
3918
+ }
3919
+ async function hmac(key, value) {
3920
+ const keyBytes = typeof key === "string" ? new TextEncoder().encode(key) : key;
3921
+ const cryptoKey = await crypto.subtle.importKey(
3922
+ "raw",
3923
+ keyBytes,
3924
+ { name: "HMAC", hash: "SHA-256" },
3925
+ false,
3926
+ ["sign"]
3927
+ );
3928
+ return crypto.subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(value));
3929
+ }
3930
+ async function hmacHex(key, value) {
3931
+ return toHex(new Uint8Array(await hmac(key, value)));
3932
+ }
3933
+ function toHex(bytes) {
3934
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
3935
+ }
3936
+ function parseXhrHeaders(rawHeaders) {
3937
+ const headers = new Headers();
3938
+ rawHeaders.trim().split(/[\r\n]+/).forEach((line) => {
3939
+ const separator = line.indexOf(":");
3940
+ if (separator > 0) {
3941
+ headers.set(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
3942
+ }
3943
+ });
3944
+ return headers;
3945
+ }
3946
+
3737
3947
  // src/storage/file.ts
3948
+ function mergeUploadHeaders(serverHeaders, inputHeaders) {
3949
+ const headers = { ...serverHeaders };
3950
+ new Headers(inputHeaders).forEach((value, key) => {
3951
+ headers[key] = value;
3952
+ });
3953
+ return headers;
3954
+ }
3738
3955
  function createStorageFileModule(base, config = {}) {
3739
3956
  const upload = async (input, options) => {
3740
3957
  const sources = normalizeUploadSources(input);
@@ -3770,16 +3987,25 @@ function createStorageFileModule(base, config = {}) {
3770
3987
  for (let index = 0; index < uploadRequests.length; index += 1) {
3771
3988
  const request2 = uploadRequests[index];
3772
3989
  const uploadUrl = uploadUrls[index];
3773
- const response = await putUploadBody(
3990
+ const aggregateProgress = (progress) => {
3991
+ aggregateLoaded[index] = progress.loaded;
3992
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3993
+ };
3994
+ const response = config.directUpload ? await putDirectStorageUploadBody(
3995
+ config.directUpload,
3996
+ uploadUrl.upload.bucket,
3997
+ uploadUrl.upload.storage_key,
3998
+ request2.source.source,
3999
+ mergeUploadHeaders(uploadUrl.upload.headers ?? {}, input.uploadHeaders),
4000
+ options?.signal,
4001
+ aggregateProgress
4002
+ ) : await putUploadBody(
3774
4003
  uploadUrl.upload.url,
3775
4004
  uploadUrl.upload.headers ?? {},
3776
4005
  request2.source,
3777
4006
  input,
3778
4007
  options,
3779
- (progress) => {
3780
- aggregateLoaded[index] = progress.loaded;
3781
- input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3782
- }
4008
+ aggregateProgress
3783
4009
  );
3784
4010
  uploaded.push({
3785
4011
  file: uploadUrl.file,
@@ -3930,7 +4156,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
3930
4156
  resolve3(new Response(xhr.response, {
3931
4157
  status: xhr.status,
3932
4158
  statusText: xhr.statusText,
3933
- headers: parseXhrHeaders(xhr.getAllResponseHeaders())
4159
+ headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
3934
4160
  }));
3935
4161
  };
3936
4162
  xhr.onerror = () => {
@@ -4068,7 +4294,7 @@ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoad
4068
4294
  function sum(values) {
4069
4295
  return values.reduce((total, value) => total + value, 0);
4070
4296
  }
4071
- function parseXhrHeaders(raw) {
4297
+ function parseXhrHeaders2(raw) {
4072
4298
  const headers = new Headers();
4073
4299
  for (const line of raw.trim().split(/[\r\n]+/)) {
4074
4300
  const index = line.indexOf(":");
@@ -4085,6 +4311,230 @@ function isRecord5(value) {
4085
4311
  return Boolean(value) && typeof value === "object";
4086
4312
  }
4087
4313
 
4314
+ // src/storage/backup.ts
4315
+ function backupError(message, status, endpoint, method, cause, raw) {
4316
+ const error = new Error(message);
4317
+ error.name = "AthenaStorageError";
4318
+ error.code = status === 0 ? "NETWORK_ERROR" : "HTTP_ERROR";
4319
+ error.status = status;
4320
+ error.endpoint = endpoint;
4321
+ error.method = method;
4322
+ error.cause = cause;
4323
+ error.raw = raw;
4324
+ throw error;
4325
+ }
4326
+ function isRecord6(value) {
4327
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4328
+ }
4329
+ function asPath(path) {
4330
+ return path;
4331
+ }
4332
+ function appendQuery(path, query) {
4333
+ if (!query) return path;
4334
+ const params = new URLSearchParams();
4335
+ for (const [key, value] of Object.entries(query)) {
4336
+ if (value === void 0 || value === null || value === "") continue;
4337
+ params.set(key, String(value));
4338
+ }
4339
+ const text = params.toString();
4340
+ return text ? `${path}?${text}` : path;
4341
+ }
4342
+ function unwrapAthenaData(payload) {
4343
+ if (isRecord6(payload) && "data" in payload) {
4344
+ return payload.data;
4345
+ }
4346
+ return payload;
4347
+ }
4348
+ function requireKey(key) {
4349
+ const trimmed = key.trim();
4350
+ if (!trimmed || trimmed === "undefined" || trimmed === "null") {
4351
+ backupError("Backup object key is required", 400, "/admin/backups/{key}", "DELETE");
4352
+ }
4353
+ return trimmed;
4354
+ }
4355
+ function resolveMessage(payload, fallback) {
4356
+ if (isRecord6(payload)) {
4357
+ const message = payload.message ?? payload.error ?? payload.details;
4358
+ if (typeof message === "string" && message.trim()) return message.trim();
4359
+ }
4360
+ if (typeof payload === "string" && payload.trim()) return payload.trim();
4361
+ return fallback;
4362
+ }
4363
+ async function callBackupEndpoint(gateway, path, method, payload, options, runtime) {
4364
+ const endpoint = asPath(path);
4365
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4366
+ const url = buildAthenaGatewayUrl(baseUrl, endpoint);
4367
+ const headers = gateway.buildHeaders(options);
4368
+ const init = {
4369
+ method,
4370
+ headers,
4371
+ signal: options?.signal
4372
+ };
4373
+ if (payload !== void 0 && method !== "GET") {
4374
+ init.body = JSON.stringify(payload);
4375
+ }
4376
+ let response;
4377
+ try {
4378
+ response = await fetch(url, init);
4379
+ } catch (error) {
4380
+ backupError(
4381
+ error instanceof Error ? error.message : "Backup network error",
4382
+ 0,
4383
+ path,
4384
+ method,
4385
+ error
4386
+ );
4387
+ }
4388
+ const rawText = await response.text();
4389
+ let parsed = null;
4390
+ if (rawText) {
4391
+ try {
4392
+ parsed = JSON.parse(rawText);
4393
+ } catch {
4394
+ parsed = rawText;
4395
+ }
4396
+ }
4397
+ if (!response.ok) {
4398
+ backupError(
4399
+ resolveMessage(parsed, `Backup ${method} ${path} failed (${response.status})`),
4400
+ response.status,
4401
+ path,
4402
+ method,
4403
+ void 0,
4404
+ parsed
4405
+ );
4406
+ }
4407
+ return unwrapAthenaData(parsed);
4408
+ }
4409
+ function createStorageBackupModule(gateway, runtimeOptions) {
4410
+ const resolvedBaseUrl = () => String(gateway.baseUrl ?? "").replace(/\/+$/, "");
4411
+ return {
4412
+ async list(query, options) {
4413
+ const path = appendQuery("/admin/backups", {
4414
+ limit: query?.limit ?? 10,
4415
+ client_name: query?.client_name,
4416
+ cursor: query?.cursor ?? void 0
4417
+ });
4418
+ const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
4419
+ const backups = (data?.backups ?? []).map((row) => ({
4420
+ ...row,
4421
+ key: row.key ?? row.s3_key
4422
+ }));
4423
+ return {
4424
+ backups,
4425
+ next_cursor: data?.next_cursor ?? null
4426
+ };
4427
+ },
4428
+ async create(input, options) {
4429
+ const data = await callBackupEndpoint(gateway, "/admin/backups", "POST", input, options);
4430
+ return {
4431
+ job_id: Number(data?.job_id ?? 0),
4432
+ client_name: String(data?.client_name ?? input.client_name),
4433
+ status: String(data?.status ?? "pending")
4434
+ };
4435
+ },
4436
+ async restore(key, input, options) {
4437
+ const backupKey = requireKey(key);
4438
+ const path = `/admin/backups/${encodeURIComponent(backupKey)}/restore`;
4439
+ const data = await callBackupEndpoint(gateway, path, "POST", input, options);
4440
+ return {
4441
+ job_id: Number(data?.job_id ?? 0),
4442
+ client_name: String(data?.client_name ?? input.client_name),
4443
+ status: String(data?.status ?? "pending"),
4444
+ key: String(data?.key ?? backupKey)
4445
+ };
4446
+ },
4447
+ async delete(key, options) {
4448
+ const backupKey = requireKey(key);
4449
+ await callBackupEndpoint(
4450
+ gateway,
4451
+ `/admin/backups/${encodeURIComponent(backupKey)}`,
4452
+ "DELETE",
4453
+ void 0,
4454
+ options);
4455
+ },
4456
+ downloadUrl(key, options) {
4457
+ const backupKey = requireKey(key);
4458
+ const base = `${resolvedBaseUrl()}/admin/backups/${encodeURIComponent(backupKey)}/download`;
4459
+ return options?.apiKey ? `${base}?api_key=${encodeURIComponent(options.apiKey)}` : base;
4460
+ },
4461
+ jobs: {
4462
+ async list(query, options) {
4463
+ const path = appendQuery("/admin/backups/jobs", query ?? {});
4464
+ const data = await callBackupEndpoint(gateway, path, "GET", void 0, options);
4465
+ if (Array.isArray(data)) return data;
4466
+ if (isRecord6(data) && Array.isArray(data.jobs)) return data.jobs;
4467
+ return [];
4468
+ },
4469
+ async get(jobId, options) {
4470
+ return callBackupEndpoint(
4471
+ gateway,
4472
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
4473
+ "GET",
4474
+ void 0,
4475
+ options);
4476
+ },
4477
+ async cancel(jobId, options) {
4478
+ return callBackupEndpoint(
4479
+ gateway,
4480
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}/cancel`,
4481
+ "POST",
4482
+ {},
4483
+ options);
4484
+ },
4485
+ async delete(jobId, options) {
4486
+ await callBackupEndpoint(
4487
+ gateway,
4488
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}`,
4489
+ "DELETE",
4490
+ void 0,
4491
+ options);
4492
+ },
4493
+ async openObjectUrl(jobId, options) {
4494
+ const data = await callBackupEndpoint(
4495
+ gateway,
4496
+ `/admin/backups/jobs/${encodeURIComponent(String(jobId))}/s3-open`,
4497
+ "GET",
4498
+ void 0,
4499
+ options);
4500
+ return String(data?.url ?? "");
4501
+ }
4502
+ },
4503
+ schedules: {
4504
+ async list(options) {
4505
+ const data = await callBackupEndpoint(gateway, "/admin/backups/schedules", "GET", void 0, options);
4506
+ if (Array.isArray(data)) return data;
4507
+ if (isRecord6(data) && Array.isArray(data.schedules)) return data.schedules;
4508
+ return [];
4509
+ },
4510
+ async create(input, options) {
4511
+ return callBackupEndpoint(
4512
+ gateway,
4513
+ "/admin/backups/schedules",
4514
+ "POST",
4515
+ input,
4516
+ options);
4517
+ },
4518
+ async update(id, input, options) {
4519
+ return callBackupEndpoint(
4520
+ gateway,
4521
+ `/admin/backups/schedules/${encodeURIComponent(String(id))}`,
4522
+ "PATCH",
4523
+ input,
4524
+ options);
4525
+ },
4526
+ async delete(id, options) {
4527
+ await callBackupEndpoint(
4528
+ gateway,
4529
+ `/admin/backups/schedules/${encodeURIComponent(String(id))}`,
4530
+ "DELETE",
4531
+ void 0,
4532
+ options);
4533
+ }
4534
+ }
4535
+ };
4536
+ }
4537
+
4088
4538
  // src/storage/module.ts
4089
4539
  var storageSdkManifest = {
4090
4540
  namespace: "storage",
@@ -4133,6 +4583,53 @@ var storageSdkManifest = {
4133
4583
  responseEnvelope: "raw",
4134
4584
  responseType: "{ data: S3CredentialListItem[] }"
4135
4585
  },
4586
+ {
4587
+ name: "backup.list",
4588
+ method: "GET",
4589
+ path: "/admin/backups",
4590
+ responseEnvelope: "athena",
4591
+ responseType: "StorageBackupListPage",
4592
+ note: "Admin backup archives on server S3/R2 profile"
4593
+ },
4594
+ {
4595
+ name: "backup.create",
4596
+ method: "POST",
4597
+ path: "/admin/backups",
4598
+ requestType: "StorageBackupCreateRequest",
4599
+ responseEnvelope: "athena",
4600
+ responseType: "StorageBackupQueuedJob"
4601
+ },
4602
+ {
4603
+ name: "backup.restore",
4604
+ method: "POST",
4605
+ path: "/admin/backups/{key}/restore",
4606
+ pathParams: ["key"],
4607
+ requestType: "StorageBackupRestoreRequest",
4608
+ responseEnvelope: "athena",
4609
+ responseType: "StorageBackupQueuedJob"
4610
+ },
4611
+ {
4612
+ name: "backup.delete",
4613
+ method: "DELETE",
4614
+ path: "/admin/backups/{key}",
4615
+ pathParams: ["key"],
4616
+ responseEnvelope: "athena",
4617
+ responseType: "void"
4618
+ },
4619
+ {
4620
+ name: "backup.jobs.list",
4621
+ method: "GET",
4622
+ path: "/admin/backups/jobs",
4623
+ responseEnvelope: "athena",
4624
+ responseType: "StorageBackupJob[]"
4625
+ },
4626
+ {
4627
+ name: "backup.schedules.list",
4628
+ method: "GET",
4629
+ path: "/admin/backups/schedules",
4630
+ responseEnvelope: "athena",
4631
+ responseType: "StorageBackupSchedule[]"
4632
+ },
4136
4633
  {
4137
4634
  name: "createStorageUploadUrl",
4138
4635
  method: "POST",
@@ -4788,7 +5285,7 @@ var AthenaStorageError = class extends Error {
4788
5285
  };
4789
5286
  }
4790
5287
  };
4791
- function isRecord6(value) {
5288
+ function isRecord7(value) {
4792
5289
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4793
5290
  }
4794
5291
  function causeToString(cause) {
@@ -4886,7 +5383,7 @@ function parseResponseBody3(rawText, contentType) {
4886
5383
  return { parsed: rawText, parseFailed: true };
4887
5384
  }
4888
5385
  }
4889
- function appendQuery(path, query) {
5386
+ function appendQuery2(path, query) {
4890
5387
  if (!query) return path;
4891
5388
  const params = new URLSearchParams();
4892
5389
  for (const [key, value] of Object.entries(query)) {
@@ -4912,7 +5409,7 @@ function withPathParam(path, name, value) {
4912
5409
  return path.replace(`{${name}}`, encodeURIComponent(value));
4913
5410
  }
4914
5411
  function resolveErrorMessage3(payload, fallback) {
4915
- if (isRecord6(payload)) {
5412
+ if (isRecord7(payload)) {
4916
5413
  const message = payload.message ?? payload.error ?? payload.details;
4917
5414
  if (typeof message === "string" && message.trim()) {
4918
5415
  return message.trim();
@@ -4924,12 +5421,12 @@ function resolveErrorMessage3(payload, fallback) {
4924
5421
  return fallback;
4925
5422
  }
4926
5423
  function resolveErrorHint2(payload) {
4927
- if (!isRecord6(payload)) return void 0;
5424
+ if (!isRecord7(payload)) return void 0;
4928
5425
  const hint = payload.hint ?? payload.suggestion;
4929
5426
  return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
4930
5427
  }
4931
5428
  function resolveErrorCause(payload) {
4932
- if (!isRecord6(payload)) return void 0;
5429
+ if (!isRecord7(payload)) return void 0;
4933
5430
  const cause = payload.cause ?? payload.reason;
4934
5431
  return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
4935
5432
  }
@@ -5048,7 +5545,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
5048
5545
  );
5049
5546
  }
5050
5547
  if (envelope === "athena") {
5051
- if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5548
+ if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5052
5549
  return rejectStorageError(
5053
5550
  {
5054
5551
  code: "INVALID_ATHENA_ENVELOPE",
@@ -5156,7 +5653,7 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
5156
5653
  runtimeOptions
5157
5654
  );
5158
5655
  }
5159
- function isBlobBody(body) {
5656
+ function isBlobBody2(body) {
5160
5657
  return typeof Blob !== "undefined" && body instanceof Blob;
5161
5658
  }
5162
5659
  function isReadableStreamBody(body) {
@@ -5165,7 +5662,7 @@ function isReadableStreamBody(body) {
5165
5662
  async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
5166
5663
  const headers = new Headers(uploadHeaders);
5167
5664
  Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
5168
- if (!headers.has("Content-Type") && isBlobBody(body) && body.type) {
5665
+ if (!headers.has("Content-Type") && isBlobBody2(body) && body.type) {
5169
5666
  headers.set("Content-Type", body.type);
5170
5667
  }
5171
5668
  const init = {
@@ -5260,7 +5757,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
5260
5757
  }
5261
5758
  delete headers["Content-Type"];
5262
5759
  delete headers["content-type"];
5263
- if (isBlobBody(body) && body.type) {
5760
+ if (isBlobBody2(body) && body.type) {
5264
5761
  headers["Content-Type"] = body.type;
5265
5762
  }
5266
5763
  const requestInit = {
@@ -5345,7 +5842,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
5345
5842
  runtimeOptions
5346
5843
  );
5347
5844
  }
5348
- if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5845
+ if (!isRecord7(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
5349
5846
  return rejectStorageError(
5350
5847
  {
5351
5848
  code: "INVALID_ATHENA_ENVELOPE",
@@ -5417,14 +5914,14 @@ function createStorageModule(gateway, runtimeOptions) {
5417
5914
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
5418
5915
  },
5419
5916
  getStorageFileUrl(fileId, query, options) {
5420
- const path = appendQuery(
5917
+ const path = appendQuery2(
5421
5918
  withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
5422
5919
  query
5423
5920
  );
5424
5921
  return callAthena2(path, "GET", void 0, options);
5425
5922
  },
5426
5923
  getStorageFileProxy(fileId, query, options) {
5427
- const path = appendQuery(
5924
+ const path = appendQuery2(
5428
5925
  withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
5429
5926
  query
5430
5927
  );
@@ -5448,7 +5945,7 @@ function createStorageModule(gateway, runtimeOptions) {
5448
5945
  };
5449
5946
  const fileFacade = createStorageFileModule(base, runtimeOptions);
5450
5947
  const fileUpload = ((input, options) => {
5451
- if (isRecord6(input) && "files" in input) {
5948
+ if (isRecord7(input) && "files" in input) {
5452
5949
  return fileFacade.upload(input, options);
5453
5950
  }
5454
5951
  return base.createStorageUploadUrl(
@@ -5510,7 +6007,7 @@ function createStorageModule(gateway, runtimeOptions) {
5510
6007
  return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
5511
6008
  },
5512
6009
  proxyUrl(fileId, query, options) {
5513
- const path = appendQuery(
6010
+ const path = appendQuery2(
5514
6011
  withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
5515
6012
  query
5516
6013
  );
@@ -5548,7 +6045,7 @@ function createStorageModule(gateway, runtimeOptions) {
5548
6045
  },
5549
6046
  retention: {
5550
6047
  get(fileId, query, options) {
5551
- const path = appendQuery(
6048
+ const path = appendQuery2(
5552
6049
  withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
5553
6050
  query
5554
6051
  );
@@ -5750,6 +6247,7 @@ function createStorageModule(gateway, runtimeOptions) {
5750
6247
  return callAthena2("/storage/audit/list", "POST", input, options);
5751
6248
  }
5752
6249
  };
6250
+ const backup = createStorageBackupModule(gateway);
5753
6251
  return {
5754
6252
  ...base,
5755
6253
  credentials,
@@ -5761,6 +6259,7 @@ function createStorageModule(gateway, runtimeOptions) {
5761
6259
  bucket,
5762
6260
  multipart,
5763
6261
  audit,
6262
+ backup,
5764
6263
  delete: file.delete
5765
6264
  };
5766
6265
  }
@@ -5810,7 +6309,7 @@ function normalizeWsUrl(value, label) {
5810
6309
  parsed.pathname = parsed.pathname.replace(/\/+$/, "");
5811
6310
  return parsed.toString().replace(/\/$/, "");
5812
6311
  }
5813
- function isRecord7(value) {
6312
+ function isRecord8(value) {
5814
6313
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5815
6314
  }
5816
6315
  function parseResponseBody4(rawText, contentType) {
@@ -5832,7 +6331,7 @@ function resolveRequestId3(headers) {
5832
6331
  return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
5833
6332
  }
5834
6333
  function resolveErrorMessage4(payload, fallback) {
5835
- if (isRecord7(payload)) {
6334
+ if (isRecord8(payload)) {
5836
6335
  for (const candidate of [payload.error, payload.message, payload.details]) {
5837
6336
  if (typeof candidate === "string" && candidate.trim().length > 0) {
5838
6337
  return candidate.trim();
@@ -6479,7 +6978,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
6479
6978
  "ilike",
6480
6979
  "is"
6481
6980
  ]);
6482
- function isRecord8(value) {
6981
+ function isRecord9(value) {
6483
6982
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6484
6983
  }
6485
6984
  function isUuidString(value) {
@@ -6492,7 +6991,7 @@ function shouldUseUuidTextComparison(column, value) {
6492
6991
  return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
6493
6992
  }
6494
6993
  function isRelationSelectNode(value) {
6495
- return isRecord8(value) && isRecord8(value.select);
6994
+ return isRecord9(value) && isRecord9(value.select);
6496
6995
  }
6497
6996
  function normalizeIdentifier(value, label) {
6498
6997
  const normalized = value.trim();
@@ -6548,7 +7047,7 @@ function compileRelationToken(key, node) {
6548
7047
  return `${prefix}${relationToken}(${nested})`;
6549
7048
  }
6550
7049
  function compileSelectShape(select) {
6551
- if (!isRecord8(select)) {
7050
+ if (!isRecord9(select)) {
6552
7051
  throw new Error("findMany select must be an object");
6553
7052
  }
6554
7053
  const tokens = [];
@@ -6572,7 +7071,7 @@ function compileSelectShape(select) {
6572
7071
  return tokens.join(",");
6573
7072
  }
6574
7073
  function selectShapeUsesRelationSchema(select) {
6575
- if (!isRecord8(select)) {
7074
+ if (!isRecord9(select)) {
6576
7075
  return false;
6577
7076
  }
6578
7077
  for (const rawValue of Object.values(select)) {
@@ -6590,7 +7089,7 @@ function selectShapeUsesRelationSchema(select) {
6590
7089
  }
6591
7090
  function compileColumnWhere(column, input) {
6592
7091
  const normalizedColumn = normalizeIdentifier(column, "where column");
6593
- if (!isRecord8(input)) {
7092
+ if (!isRecord9(input)) {
6594
7093
  return [buildGatewayCondition("eq", normalizedColumn, input)];
6595
7094
  }
6596
7095
  const conditions = [];
@@ -6618,7 +7117,7 @@ function compileColumnWhere(column, input) {
6618
7117
  return conditions;
6619
7118
  }
6620
7119
  function compileBooleanExpressionTerms(clause, label) {
6621
- if (!isRecord8(clause)) {
7120
+ if (!isRecord9(clause)) {
6622
7121
  throw new Error(`findMany where.${label} clauses must be objects`);
6623
7122
  }
6624
7123
  const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
@@ -6627,7 +7126,7 @@ function compileBooleanExpressionTerms(clause, label) {
6627
7126
  }
6628
7127
  const [rawColumn, rawValue] = entries[0];
6629
7128
  const column = normalizeIdentifier(rawColumn, `where.${label} column`);
6630
- if (!isRecord8(rawValue)) {
7129
+ if (!isRecord9(rawValue)) {
6631
7130
  return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
6632
7131
  }
6633
7132
  const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
@@ -6651,7 +7150,7 @@ function compileWhere(where) {
6651
7150
  if (where === void 0) {
6652
7151
  return void 0;
6653
7152
  }
6654
- if (!isRecord8(where)) {
7153
+ if (!isRecord9(where)) {
6655
7154
  throw new Error("findMany where must be an object");
6656
7155
  }
6657
7156
  const conditions = [];
@@ -6701,7 +7200,7 @@ function compileOrderBy(orderBy) {
6701
7200
  if (orderBy === void 0) {
6702
7201
  return void 0;
6703
7202
  }
6704
- if (!isRecord8(orderBy)) {
7203
+ if (!isRecord9(orderBy)) {
6705
7204
  throw new Error("findMany orderBy must be an object");
6706
7205
  }
6707
7206
  if ("column" in orderBy) {
@@ -6876,11 +7375,11 @@ function toFindManyAstOrder(order) {
6876
7375
  ascending: order.direction !== "descending"
6877
7376
  };
6878
7377
  }
6879
- function isRecord9(value) {
7378
+ function isRecord10(value) {
6880
7379
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6881
7380
  }
6882
7381
  function normalizeFindManyAstColumnPredicate(value) {
6883
- if (!isRecord9(value)) {
7382
+ if (!isRecord10(value)) {
6884
7383
  return {
6885
7384
  eq: value
6886
7385
  };
@@ -6904,7 +7403,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
6904
7403
  return normalized;
6905
7404
  }
6906
7405
  function normalizeFindManyAstWhere(where) {
6907
- if (!where || !isRecord9(where)) {
7406
+ if (!where || !isRecord10(where)) {
6908
7407
  return where;
6909
7408
  }
6910
7409
  const normalized = {};
@@ -6918,7 +7417,7 @@ function normalizeFindManyAstWhere(where) {
6918
7417
  );
6919
7418
  continue;
6920
7419
  }
6921
- if (key === "not" && isRecord9(value)) {
7420
+ if (key === "not" && isRecord10(value)) {
6922
7421
  normalized.not = normalizeFindManyAstBooleanOperand(
6923
7422
  value
6924
7423
  );
@@ -6929,7 +7428,7 @@ function normalizeFindManyAstWhere(where) {
6929
7428
  return normalized;
6930
7429
  }
6931
7430
  function predicateRequiresUuidQueryFallback(column, value) {
6932
- if (!isRecord9(value)) {
7431
+ if (!isRecord10(value)) {
6933
7432
  return shouldUseUuidTextComparison(column, value);
6934
7433
  }
6935
7434
  const eqValue = value.eq;
@@ -6947,7 +7446,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
6947
7446
  return false;
6948
7447
  }
6949
7448
  function findManyAstWhereRequiresLegacyTransport(where) {
6950
- if (!where || !isRecord9(where)) {
7449
+ if (!where || !isRecord10(where)) {
6951
7450
  return false;
6952
7451
  }
6953
7452
  for (const [key, value] of Object.entries(where)) {
@@ -6962,7 +7461,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
6962
7461
  }
6963
7462
  continue;
6964
7463
  }
6965
- if (key === "not" && isRecord9(value)) {
7464
+ if (key === "not" && isRecord10(value)) {
6966
7465
  if (booleanOperandRequiresUuidQueryFallback(value)) {
6967
7466
  return true;
6968
7467
  }
@@ -7588,7 +8087,7 @@ async function executeExperimentalRead(experimental, runner) {
7588
8087
  throw error;
7589
8088
  }
7590
8089
  }
7591
- function isRecord10(value) {
8090
+ function isRecord11(value) {
7592
8091
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7593
8092
  }
7594
8093
  function firstNonEmptyString2(...values) {
@@ -7600,8 +8099,8 @@ function firstNonEmptyString2(...values) {
7600
8099
  return void 0;
7601
8100
  }
7602
8101
  function resolveStructuredErrorPayload2(raw) {
7603
- if (!isRecord10(raw)) return null;
7604
- return isRecord10(raw.error) ? raw.error : raw;
8102
+ if (!isRecord11(raw)) return null;
8103
+ return isRecord11(raw.error) ? raw.error : raw;
7605
8104
  }
7606
8105
  function resolveStructuredErrorDetails(payload, message) {
7607
8106
  if (!payload || !("details" in payload)) {
@@ -7617,7 +8116,7 @@ function resolveStructuredErrorDetails(payload, message) {
7617
8116
  return details;
7618
8117
  }
7619
8118
  function createResultError(response, result, normalized) {
7620
- const rawRecord = isRecord10(response.raw) ? response.raw : null;
8119
+ const rawRecord = isRecord11(response.raw) ? response.raw : null;
7621
8120
  const payload = resolveStructuredErrorPayload2(response.raw);
7622
8121
  const message = firstNonEmptyString2(
7623
8122
  response.error,
@@ -9526,6 +10025,7 @@ function createClientFromConfig(config, sourceConfig) {
9526
10025
  withOptions: storageWithOptions,
9527
10026
  storage: createStorageModule(gateway, {
9528
10027
  ...config.experimental.storage,
10028
+ ...config.experimental.directStorageUpload ? { directUpload: config.experimental.directStorageUpload } : {},
9529
10029
  ...config.storageUrl ? {
9530
10030
  baseUrl: config.storageUrl,
9531
10031
  stripBasePath: true
@@ -9612,7 +10112,7 @@ function resolveNullishValue(mode) {
9612
10112
  if (mode === "null") return null;
9613
10113
  return "";
9614
10114
  }
9615
- function isRecord11(value) {
10115
+ function isRecord12(value) {
9616
10116
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
9617
10117
  }
9618
10118
  function isNullableColumn(model, key) {
@@ -9621,7 +10121,7 @@ function isNullableColumn(model, key) {
9621
10121
  }
9622
10122
  function toModelFormDefaults(model, values, options) {
9623
10123
  const source = values;
9624
- if (!isRecord11(source)) {
10124
+ if (!isRecord12(source)) {
9625
10125
  return {};
9626
10126
  }
9627
10127
  const mode = options?.nullishMode ?? "empty-string";
@@ -12435,15 +12935,15 @@ function readCookieFromHeaders(headers, name) {
12435
12935
  }
12436
12936
  return parseCookies(cookieHeader).get(name);
12437
12937
  }
12438
- function isRecord12(value) {
12938
+ function isRecord13(value) {
12439
12939
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
12440
12940
  }
12441
12941
  function resolveSessionCandidate(value) {
12442
- if (!isRecord12(value)) {
12942
+ if (!isRecord13(value)) {
12443
12943
  return null;
12444
12944
  }
12445
- const session = isRecord12(value.session) ? value.session : void 0;
12446
- const user = isRecord12(value.user) ? value.user : void 0;
12945
+ const session = isRecord13(value.session) ? value.session : void 0;
12946
+ const user = isRecord13(value.user) ? value.user : void 0;
12447
12947
  if (session && typeof session.token === "string" && session.token.length > 0 && user) {
12448
12948
  return {
12449
12949
  session,
@@ -12453,7 +12953,7 @@ function resolveSessionCandidate(value) {
12453
12953
  return null;
12454
12954
  }
12455
12955
  function inferSessionPair(returned) {
12456
- return resolveSessionCandidate(returned) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.session) : null);
12956
+ return resolveSessionCandidate(returned) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord13(returned) ? resolveSessionCandidate(returned.session) : null);
12457
12957
  }
12458
12958
  function resolveResponseHeaders(ctx) {
12459
12959
  if (ctx.context.responseHeaders instanceof Headers) {