@xylex-group/athena 2.7.0 → 2.8.2

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 (36) hide show
  1. package/README.md +218 -18
  2. package/dist/browser.cjs +2173 -675
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.cts +8 -7
  5. package/dist/browser.d.ts +8 -7
  6. package/dist/browser.js +2167 -676
  7. package/dist/browser.js.map +1 -1
  8. package/dist/cli/index.cjs +2068 -559
  9. package/dist/cli/index.cjs.map +1 -1
  10. package/dist/cli/index.d.cts +3 -3
  11. package/dist/cli/index.d.ts +3 -3
  12. package/dist/cli/index.js +2068 -559
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/index.cjs +2815 -945
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +8 -7
  17. package/dist/index.d.ts +8 -7
  18. package/dist/index.js +2809 -946
  19. package/dist/index.js.map +1 -1
  20. package/dist/{model-form-AKYrgede.d.ts → model-form-Cx3wtvi8.d.ts} +963 -93
  21. package/dist/{model-form-ehfqLuG7.d.cts → model-form-_ugfOXao.d.cts} +963 -93
  22. package/dist/{pipeline-BfCWSRYl.d.cts → pipeline-BtD-Uo5X.d.cts} +1 -1
  23. package/dist/{pipeline-BUsR9XlO.d.ts → pipeline-yCIZNJHE.d.ts} +1 -1
  24. package/dist/{react-email-BQzmXBDE.d.cts → react-email-CiiSVa9F.d.cts} +121 -10
  25. package/dist/{react-email-BrVRp80B.d.ts → react-email-WN8UU3AL.d.ts} +121 -10
  26. package/dist/react.cjs +1 -1
  27. package/dist/react.cjs.map +1 -1
  28. package/dist/react.d.cts +4 -4
  29. package/dist/react.d.ts +4 -4
  30. package/dist/react.js +1 -1
  31. package/dist/react.js.map +1 -1
  32. package/dist/{types-t_TVqnmp.d.ts → types-89EfjLjV.d.cts} +48 -5
  33. package/dist/{types-BSIsyss1.d.cts → types-C2kiTt6-.d.ts} +48 -5
  34. package/dist/{types-BsyRW49r.d.cts → types-g8G6J0xE.d.cts} +26 -1
  35. package/dist/{types-BsyRW49r.d.ts → types-g8G6J0xE.d.ts} +26 -1
  36. package/package.json +28 -57
package/dist/browser.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { z } from 'zod';
2
+
1
3
  // src/gateway/errors.ts
2
4
  var AthenaGatewayError = class _AthenaGatewayError extends Error {
3
5
  code;
@@ -798,7 +800,7 @@ var getCookieCache = async (request, config) => {
798
800
 
799
801
  // package.json
800
802
  var package_default = {
801
- version: "2.7.0"
803
+ version: "2.8.2"
802
804
  };
803
805
 
804
806
  // src/sdk-version.ts
@@ -3115,7 +3117,7 @@ function normalizeAthenaError(resultOrError, context) {
3115
3117
  const details = resultOrError.errorDetails;
3116
3118
  const message2 = messageFromUnknownError(resultOrError.error) ?? details?.message ?? `Athena ${context?.operation ?? operationFromDetails(details) ?? "request"} failed`;
3117
3119
  const operation = context?.operation ?? operationFromDetails(details);
3118
- const table = context?.table ?? extractTable(message2);
3120
+ const table2 = context?.table ?? extractTable(message2);
3119
3121
  const constraint = extractConstraint(message2);
3120
3122
  const gatewayCode = details?.code ?? gatewayCodeFromUnknownError(resultOrError.error);
3121
3123
  const kind2 = classifyKind(resultOrError.status, gatewayCode, message2);
@@ -3128,7 +3130,7 @@ function normalizeAthenaError(resultOrError, context) {
3128
3130
  retryable: isRetryable(kind2, resultOrError.status),
3129
3131
  status: resultOrError.status,
3130
3132
  constraint,
3131
- table,
3133
+ table: table2,
3132
3134
  operation,
3133
3135
  message: message2,
3134
3136
  raw: resultOrError.raw
@@ -3137,7 +3139,7 @@ function normalizeAthenaError(resultOrError, context) {
3137
3139
  if (isAthenaGatewayError(resultOrError)) {
3138
3140
  const details = resultOrError.toDetails();
3139
3141
  const operation = context?.operation ?? operationFromDetails(details);
3140
- const table = context?.table ?? extractTable(resultOrError.message);
3142
+ const table2 = context?.table ?? extractTable(resultOrError.message);
3141
3143
  const constraint = extractConstraint(resultOrError.message);
3142
3144
  const kind2 = classifyKind(resultOrError.status, resultOrError.code, resultOrError.message);
3143
3145
  const code = toAthenaErrorCode(kind2, resultOrError.status, resultOrError.code);
@@ -3149,7 +3151,7 @@ function normalizeAthenaError(resultOrError, context) {
3149
3151
  retryable: isRetryable(kind2, resultOrError.status),
3150
3152
  status: resultOrError.status,
3151
3153
  constraint,
3152
- table,
3154
+ table: table2,
3153
3155
  operation,
3154
3156
  message: resultOrError.message,
3155
3157
  raw: resultOrError
@@ -3345,23 +3347,24 @@ async function withRetry(config, fn) {
3345
3347
  // src/db/module.ts
3346
3348
  function createDbModule(input) {
3347
3349
  const db = {
3348
- from(table, options) {
3349
- return input.from(table, options);
3350
- },
3351
- select(table, columns, options) {
3352
- return input.from(table).select(columns, options);
3350
+ from: input.from,
3351
+ select(table2, first, second) {
3352
+ if (first && typeof first === "object" && !Array.isArray(first)) {
3353
+ return input.from(table2).select(void 0, first);
3354
+ }
3355
+ return input.from(table2).select(first, second);
3353
3356
  },
3354
- insert(table, values, options) {
3355
- return Array.isArray(values) ? input.from(table).insert(values, options) : input.from(table).insert(values, options);
3357
+ insert(table2, values, options) {
3358
+ return Array.isArray(values) ? input.from(table2).insert(values, options) : input.from(table2).insert(values, options);
3356
3359
  },
3357
- upsert(table, values, options) {
3358
- return Array.isArray(values) ? input.from(table).upsert(values, options) : input.from(table).upsert(values, options);
3360
+ upsert(table2, values, options) {
3361
+ return Array.isArray(values) ? input.from(table2).upsert(values, options) : input.from(table2).upsert(values, options);
3359
3362
  },
3360
- update(table, values, options) {
3361
- return input.from(table).update(values, options);
3363
+ update(table2, values, options) {
3364
+ return input.from(table2).update(values, options);
3362
3365
  },
3363
- delete(table, options) {
3364
- return input.from(table).delete(options);
3366
+ delete(table2, options) {
3367
+ return input.from(table2).delete(options);
3365
3368
  },
3366
3369
  rpc(fn, args, options) {
3367
3370
  return input.rpc(fn, args, options);
@@ -3393,7 +3396,12 @@ function createStorageFileModule(base, config = {}) {
3393
3396
  content_type: input.content_type ?? source.contentType,
3394
3397
  size_bytes: source.sizeBytes,
3395
3398
  public: input.public,
3396
- metadata: input.metadata
3399
+ metadata: input.metadata,
3400
+ server_side_encryption: input.server_side_encryption,
3401
+ sse: input.sse,
3402
+ ssekms_key_id: input.ssekms_key_id,
3403
+ kms_key_id: input.kms_key_id,
3404
+ bucket_key_enabled: input.bucket_key_enabled
3397
3405
  }
3398
3406
  };
3399
3407
  });
@@ -3404,10 +3412,17 @@ function createStorageFileModule(base, config = {}) {
3404
3412
  for (let index = 0; index < uploadRequests.length; index += 1) {
3405
3413
  const request = uploadRequests[index];
3406
3414
  const uploadUrl = uploadUrls[index];
3407
- const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
3408
- aggregateLoaded[index] = progress.loaded;
3409
- input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3410
- });
3415
+ const response = await putUploadBody(
3416
+ uploadUrl.upload.url,
3417
+ uploadUrl.upload.headers ?? {},
3418
+ request.source,
3419
+ input,
3420
+ options,
3421
+ (progress) => {
3422
+ aggregateLoaded[index] = progress.loaded;
3423
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3424
+ }
3425
+ );
3411
3426
  uploaded.push({
3412
3427
  file: uploadUrl.file,
3413
3428
  upload: uploadUrl.upload,
@@ -3510,8 +3525,9 @@ function validateUploadConstraints(sources, input) {
3510
3525
  }
3511
3526
  }
3512
3527
  }
3513
- async function putUploadBody(url, source, input, options, onProgress) {
3514
- const headers = new Headers(input.uploadHeaders);
3528
+ async function putUploadBody(url, uploadHeaders, source, input, options, onProgress) {
3529
+ const headers = new Headers(uploadHeaders);
3530
+ new Headers(input.uploadHeaders).forEach((value, key) => headers.set(key, value));
3515
3531
  if (source.contentType && !headers.has("Content-Type")) {
3516
3532
  headers.set("Content-Type", source.contentType);
3517
3533
  }
@@ -3836,6 +3852,23 @@ var storageSdkManifest = {
3836
3852
  responseEnvelope: "athena",
3837
3853
  responseType: "StorageFileMutationResponse"
3838
3854
  },
3855
+ {
3856
+ name: "postStorageFileVisibility",
3857
+ method: "POST",
3858
+ path: "/storage/files/{file_id}/visibility",
3859
+ pathParams: ["file_id"],
3860
+ requestType: "SetStorageFileVisibilityRequest",
3861
+ responseEnvelope: "athena",
3862
+ responseType: "StorageFileMutationResponse"
3863
+ },
3864
+ {
3865
+ name: "setManyStorageFileVisibility",
3866
+ method: "POST",
3867
+ path: "/storage/files/visibility-many",
3868
+ requestType: "SetManyStorageFileVisibilityRequest",
3869
+ responseEnvelope: "athena",
3870
+ responseType: "StorageFileMutationManyResponse"
3871
+ },
3839
3872
  {
3840
3873
  name: "deleteStorageFolder",
3841
3874
  method: "POST",
@@ -3851,241 +3884,728 @@ var storageSdkManifest = {
3851
3884
  requestType: "MoveStorageFolderRequest",
3852
3885
  responseEnvelope: "athena",
3853
3886
  responseType: "StorageFolderMutationResponse"
3854
- }
3855
- ]
3856
- };
3857
- var AthenaStorageErrorCode = {
3858
- InvalidUrl: "INVALID_URL",
3859
- NetworkError: "NETWORK_ERROR",
3860
- HttpError: "HTTP_ERROR",
3861
- InvalidJson: "INVALID_JSON",
3862
- InvalidAthenaEnvelope: "INVALID_ATHENA_ENVELOPE",
3863
- UnknownError: "UNKNOWN_ERROR"
3864
- };
3865
- var AthenaStorageError = class extends Error {
3866
- code;
3867
- athenaCode;
3868
- kind;
3869
- category;
3870
- retryable;
3871
- status;
3872
- endpoint;
3873
- method;
3874
- requestId;
3875
- hint;
3876
- causeDetail;
3877
- raw;
3878
- normalized;
3879
- __athenaNormalizedError;
3880
- constructor(input) {
3881
- super(input.message, { cause: input.cause });
3882
- this.name = "AthenaStorageError";
3883
- this.code = input.code;
3884
- this.status = input.status;
3885
- this.endpoint = input.endpoint;
3886
- this.method = input.method;
3887
- this.requestId = input.requestId;
3888
- this.hint = input.hint;
3889
- this.causeDetail = causeToString(input.cause);
3890
- this.raw = input.raw ?? null;
3891
- this.normalized = normalizeStorageErrorInput(input);
3892
- this.__athenaNormalizedError = this.normalized;
3893
- this.athenaCode = this.normalized.code;
3894
- this.kind = this.normalized.kind;
3895
- this.category = this.normalized.category;
3896
- this.retryable = this.normalized.retryable;
3897
- Object.defineProperty(this, "__athenaNormalizedError", {
3898
- value: this.normalized,
3899
- enumerable: false,
3900
- configurable: false,
3901
- writable: false
3902
- });
3903
- }
3904
- toDetails() {
3905
- return {
3906
- code: this.code,
3907
- athenaCode: this.athenaCode,
3908
- kind: this.kind,
3909
- category: this.category,
3910
- retryable: this.retryable,
3911
- message: this.message,
3912
- status: this.status,
3913
- endpoint: this.endpoint,
3914
- method: this.method,
3915
- requestId: this.requestId,
3916
- hint: this.hint,
3917
- cause: this.causeDetail,
3918
- raw: this.raw
3919
- };
3920
- }
3921
- };
3922
- function isRecord6(value) {
3923
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3924
- }
3925
- function causeToString(cause) {
3926
- if (cause === void 0 || cause === null) return void 0;
3927
- if (typeof cause === "string") return cause;
3928
- if (cause instanceof Error && cause.message.trim()) return cause.message.trim();
3929
- try {
3930
- return JSON.stringify(cause);
3931
- } catch {
3932
- return String(cause);
3933
- }
3934
- }
3935
- function storageGatewayCode(code) {
3936
- if (code === "INVALID_URL") return "INVALID_URL";
3937
- if (code === "NETWORK_ERROR") return "NETWORK_ERROR";
3938
- if (code === "INVALID_JSON" || code === "INVALID_ATHENA_ENVELOPE") return "INVALID_JSON";
3939
- if (code === "HTTP_ERROR") return "HTTP_ERROR";
3940
- return "UNKNOWN_ERROR";
3941
- }
3942
- function headerValue(headers, names) {
3943
- for (const name of names) {
3944
- const value = headers.get(name);
3945
- if (value?.trim()) return value.trim();
3946
- }
3947
- return void 0;
3948
- }
3949
- function storageOperationFromEndpoint(endpoint, method) {
3950
- const endpointPath = String(endpoint).split("?")[0];
3951
- for (const candidate of storageSdkManifest.methods) {
3952
- if (candidate.method !== method) continue;
3953
- const pattern = `^${candidate.path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\\{[^/]+\\\}/g, "[^/]+")}$`;
3954
- if (new RegExp(pattern).test(endpointPath)) {
3955
- return candidate.name;
3956
- }
3957
- }
3958
- return `storage:${method.toLowerCase()}`;
3959
- }
3960
- function normalizeStorageErrorInput(input) {
3961
- return normalizeAthenaError(
3887
+ },
3962
3888
  {
3963
- data: null,
3964
- error: {
3965
- message: input.message,
3966
- gatewayCode: storageGatewayCode(input.code),
3967
- status: input.status,
3968
- raw: input.raw ?? input.cause ?? null
3969
- },
3970
- errorDetails: {
3971
- code: storageGatewayCode(input.code),
3972
- message: input.message,
3973
- status: input.status,
3974
- endpoint: input.endpoint,
3975
- method: input.method,
3976
- requestId: input.requestId,
3977
- hint: input.hint,
3978
- cause: causeToString(input.cause)
3979
- },
3980
- raw: input.raw ?? input.cause ?? null,
3981
- status: input.status
3889
+ name: "searchStorageFiles",
3890
+ method: "POST",
3891
+ path: "/storage/files/search",
3892
+ requestType: "SearchStorageFilesRequest",
3893
+ responseEnvelope: "athena",
3894
+ responseType: "StorageListFilesResponse"
3982
3895
  },
3983
- { operation: storageOperationFromEndpoint(input.endpoint, input.method) }
3984
- );
3985
- }
3986
- function createAthenaStorageError(input) {
3987
- return new AthenaStorageError(input);
3988
- }
3989
- async function notifyStorageError(error, options, runtimeOptions) {
3990
- const handlers = [runtimeOptions?.onError, options?.onError].filter(
3991
- (handler) => typeof handler === "function"
3992
- );
3993
- for (const handler of handlers) {
3994
- try {
3995
- await handler(error);
3996
- } catch {
3997
- }
3998
- }
3999
- }
4000
- async function rejectStorageError(input, options, runtimeOptions) {
4001
- const error = createAthenaStorageError(input);
4002
- await notifyStorageError(error, options, runtimeOptions);
4003
- throw error;
4004
- }
4005
- function parseResponseBody3(rawText, contentType) {
4006
- if (!rawText) {
4007
- return { parsed: null, parseFailed: false };
4008
- }
4009
- const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
4010
- const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
4011
- if (!looksJson) {
4012
- return { parsed: rawText, parseFailed: false };
4013
- }
4014
- try {
4015
- return { parsed: JSON.parse(rawText), parseFailed: false };
4016
- } catch {
4017
- return { parsed: rawText, parseFailed: true };
4018
- }
4019
- }
4020
- function appendQuery(path, query) {
4021
- if (!query) return path;
4022
- const params = new URLSearchParams();
4023
- for (const [key, value] of Object.entries(query)) {
4024
- if (value === void 0 || value === null) continue;
4025
- params.set(key, String(value));
4026
- }
4027
- const queryText = params.toString();
4028
- return queryText ? `${path}?${queryText}` : path;
4029
- }
4030
- function storagePath(path) {
4031
- return path;
4032
- }
4033
- function withPathParam(path, name, value) {
4034
- return path.replace(`{${name}}`, encodeURIComponent(value));
4035
- }
4036
- function resolveErrorMessage3(payload, fallback) {
4037
- if (isRecord6(payload)) {
4038
- const message = payload.message ?? payload.error ?? payload.details;
4039
- if (typeof message === "string" && message.trim()) {
4040
- return message.trim();
4041
- }
4042
- }
4043
- if (typeof payload === "string" && payload.trim()) {
4044
- return payload.trim();
4045
- }
4046
- return fallback;
4047
- }
4048
- function resolveErrorHint2(payload) {
4049
- if (!isRecord6(payload)) return void 0;
4050
- const hint = payload.hint ?? payload.suggestion;
4051
- return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
4052
- }
4053
- function resolveErrorCause(payload) {
4054
- if (!isRecord6(payload)) return void 0;
4055
- const cause = payload.cause ?? payload.reason;
4056
- return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
4057
- }
4058
- function storageCodeFromUnknown(error) {
4059
- if (isAthenaGatewayError(error)) {
4060
- if (error.code === "INVALID_URL") return "INVALID_URL";
4061
- if (error.code === "NETWORK_ERROR") return "NETWORK_ERROR";
4062
- if (error.code === "INVALID_JSON") return "INVALID_JSON";
4063
- if (error.code === "HTTP_ERROR") return "HTTP_ERROR";
4064
- }
4065
- return "UNKNOWN_ERROR";
4066
- }
4067
- async function callStorageEndpoint(gateway, endpoint, method, envelope, payload, options, runtimeOptions) {
4068
- let url;
4069
- let headers;
4070
- try {
4071
- const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4072
- url = buildAthenaGatewayUrl(baseUrl, endpoint);
4073
- headers = gateway.buildHeaders(options);
4074
- } catch (error) {
4075
- return rejectStorageError(
4076
- {
4077
- code: storageCodeFromUnknown(error),
4078
- message: error instanceof Error ? error.message : `Athena storage ${method} ${endpoint} failed before sending the request`,
4079
- status: isAthenaGatewayError(error) ? error.status : 0,
4080
- endpoint,
4081
- method,
4082
- raw: error,
4083
- requestId: isAthenaGatewayError(error) ? error.requestId : void 0,
4084
- hint: isAthenaGatewayError(error) ? error.hint : void 0,
4085
- cause: error
4086
- },
4087
- options,
4088
- runtimeOptions
3896
+ {
3897
+ name: "confirmStorageUpload",
3898
+ method: "POST",
3899
+ path: "/storage/files/{file_id}/confirm-upload",
3900
+ pathParams: ["file_id"],
3901
+ requestType: "ConfirmStorageUploadRequest",
3902
+ responseEnvelope: "athena",
3903
+ responseType: "StorageFileMutationResponse"
3904
+ },
3905
+ {
3906
+ name: "uploadStorageFileBinary",
3907
+ method: "PUT",
3908
+ path: "/storage/files/{file_id}/upload",
3909
+ pathParams: ["file_id"],
3910
+ responseEnvelope: "athena",
3911
+ responseType: "StorageFileMutationResponse",
3912
+ binary: true
3913
+ },
3914
+ {
3915
+ name: "copyStorageFile",
3916
+ method: "POST",
3917
+ path: "/storage/files/{file_id}/copy",
3918
+ pathParams: ["file_id"],
3919
+ requestType: "CopyStorageFileRequest",
3920
+ responseEnvelope: "athena",
3921
+ responseType: "StorageFileMutationResponse"
3922
+ },
3923
+ {
3924
+ name: "deleteManyStorageFiles",
3925
+ method: "POST",
3926
+ path: "/storage/files/delete-many",
3927
+ requestType: "DeleteManyStorageFilesRequest",
3928
+ responseEnvelope: "athena",
3929
+ responseType: "StorageFileMutationManyResponse"
3930
+ },
3931
+ {
3932
+ name: "updateManyStorageFiles",
3933
+ method: "POST",
3934
+ path: "/storage/files/update-many",
3935
+ requestType: "UpdateManyStorageFilesRequest",
3936
+ responseEnvelope: "athena",
3937
+ responseType: "StorageFileMutationManyResponse"
3938
+ },
3939
+ {
3940
+ name: "restoreStorageFile",
3941
+ method: "POST",
3942
+ path: "/storage/files/{file_id}/restore",
3943
+ pathParams: ["file_id"],
3944
+ responseEnvelope: "athena",
3945
+ responseType: "StorageFileMutationResponse"
3946
+ },
3947
+ {
3948
+ name: "purgeStorageFile",
3949
+ method: "DELETE",
3950
+ path: "/storage/files/{file_id}/purge",
3951
+ pathParams: ["file_id"],
3952
+ responseEnvelope: "athena",
3953
+ responseType: "StorageFileMutationResponse"
3954
+ },
3955
+ {
3956
+ name: "getStorageFilePublicUrl",
3957
+ method: "GET",
3958
+ path: "/storage/files/{file_id}/public-url",
3959
+ pathParams: ["file_id"],
3960
+ responseEnvelope: "athena",
3961
+ responseType: "Record<string, unknown>"
3962
+ },
3963
+ {
3964
+ name: "getStorageFileProxyUrl",
3965
+ method: "GET",
3966
+ path: "/storage/files/{file_id}/proxy-url",
3967
+ pathParams: ["file_id"],
3968
+ queryParams: ["purpose"],
3969
+ responseEnvelope: "athena",
3970
+ responseType: "Record<string, unknown>"
3971
+ },
3972
+ {
3973
+ name: "listStorageFileVersions",
3974
+ method: "GET",
3975
+ path: "/storage/files/{file_id}/versions",
3976
+ pathParams: ["file_id"],
3977
+ responseEnvelope: "athena",
3978
+ responseType: "Record<string, unknown>"
3979
+ },
3980
+ {
3981
+ name: "restoreStorageFileVersion",
3982
+ method: "POST",
3983
+ path: "/storage/files/{file_id}/versions/{version_id}/restore",
3984
+ pathParams: ["file_id", "version_id"],
3985
+ responseEnvelope: "athena",
3986
+ responseType: "Record<string, unknown>"
3987
+ },
3988
+ {
3989
+ name: "deleteStorageFileVersion",
3990
+ method: "DELETE",
3991
+ path: "/storage/files/{file_id}/versions/{version_id}",
3992
+ pathParams: ["file_id", "version_id"],
3993
+ responseEnvelope: "athena",
3994
+ responseType: "Record<string, unknown>"
3995
+ },
3996
+ {
3997
+ name: "getStorageFileRetention",
3998
+ method: "GET",
3999
+ path: "/storage/files/{file_id}/retention",
4000
+ pathParams: ["file_id"],
4001
+ queryParams: ["version_id"],
4002
+ responseEnvelope: "athena",
4003
+ responseType: "Record<string, unknown>"
4004
+ },
4005
+ {
4006
+ name: "setStorageFileRetention",
4007
+ method: "POST",
4008
+ path: "/storage/files/{file_id}/retention",
4009
+ pathParams: ["file_id"],
4010
+ requestType: "StorageFileRetentionRequest",
4011
+ responseEnvelope: "athena",
4012
+ responseType: "Record<string, unknown>"
4013
+ },
4014
+ {
4015
+ name: "listStorageFolders",
4016
+ method: "POST",
4017
+ path: "/storage/folders/list",
4018
+ requestType: "ListStorageFoldersRequest",
4019
+ responseEnvelope: "athena",
4020
+ responseType: "Record<string, unknown>"
4021
+ },
4022
+ {
4023
+ name: "treeStorageFolders",
4024
+ method: "POST",
4025
+ path: "/storage/folders/tree",
4026
+ requestType: "TreeStorageFoldersRequest",
4027
+ responseEnvelope: "athena",
4028
+ responseType: "Record<string, unknown>"
4029
+ },
4030
+ {
4031
+ name: "listStoragePermissions",
4032
+ method: "POST",
4033
+ path: "/storage/permissions/list",
4034
+ requestType: "StoragePermissionListRequest",
4035
+ responseEnvelope: "athena",
4036
+ responseType: "StoragePermissionListResponse"
4037
+ },
4038
+ {
4039
+ name: "grantStoragePermission",
4040
+ method: "POST",
4041
+ path: "/storage/permissions/grant",
4042
+ requestType: "StoragePermissionGrantRequest",
4043
+ responseEnvelope: "athena",
4044
+ responseType: "Record<string, unknown>"
4045
+ },
4046
+ {
4047
+ name: "revokeStoragePermission",
4048
+ method: "POST",
4049
+ path: "/storage/permissions/revoke",
4050
+ requestType: "StoragePermissionRevokeRequest",
4051
+ responseEnvelope: "athena",
4052
+ responseType: "Record<string, unknown>"
4053
+ },
4054
+ {
4055
+ name: "checkStoragePermission",
4056
+ method: "POST",
4057
+ path: "/storage/permissions/check",
4058
+ requestType: "StoragePermissionCheckRequest",
4059
+ responseEnvelope: "athena",
4060
+ responseType: "StoragePermissionCheckResponse"
4061
+ },
4062
+ {
4063
+ name: "listStorageObjects",
4064
+ method: "POST",
4065
+ path: "/storage/objects",
4066
+ requestType: "StorageListObjectsRequest",
4067
+ responseEnvelope: "athena",
4068
+ responseType: "Record<string, unknown>"
4069
+ },
4070
+ {
4071
+ name: "headStorageObject",
4072
+ method: "POST",
4073
+ path: "/storage/objects/head",
4074
+ requestType: "StorageObjectRequest",
4075
+ responseEnvelope: "athena",
4076
+ responseType: "Record<string, unknown>"
4077
+ },
4078
+ {
4079
+ name: "existsStorageObject",
4080
+ method: "POST",
4081
+ path: "/storage/objects/exists",
4082
+ requestType: "StorageObjectRequest",
4083
+ responseEnvelope: "athena",
4084
+ responseType: "Record<string, unknown>"
4085
+ },
4086
+ {
4087
+ name: "validateStorageObject",
4088
+ method: "POST",
4089
+ path: "/storage/objects/validate",
4090
+ requestType: "StorageObjectValidateRequest",
4091
+ responseEnvelope: "athena",
4092
+ responseType: "Record<string, unknown>"
4093
+ },
4094
+ {
4095
+ name: "updateStorageObject",
4096
+ method: "POST",
4097
+ path: "/storage/objects/update",
4098
+ requestType: "StorageUpdateObjectRequest",
4099
+ responseEnvelope: "athena",
4100
+ responseType: "Record<string, unknown>"
4101
+ },
4102
+ {
4103
+ name: "copyStorageObject",
4104
+ method: "POST",
4105
+ path: "/storage/objects/copy",
4106
+ requestType: "StorageObjectCopyRequest",
4107
+ responseEnvelope: "athena",
4108
+ responseType: "Record<string, unknown>"
4109
+ },
4110
+ {
4111
+ name: "getStorageObjectUrl",
4112
+ method: "POST",
4113
+ path: "/storage/objects/url",
4114
+ requestType: "StorageObjectRequest",
4115
+ responseEnvelope: "athena",
4116
+ responseType: "Record<string, unknown>"
4117
+ },
4118
+ {
4119
+ name: "getStorageObjectPublicUrl",
4120
+ method: "POST",
4121
+ path: "/storage/objects/public-url",
4122
+ requestType: "StorageObjectPublicUrlRequest",
4123
+ responseEnvelope: "athena",
4124
+ responseType: "Record<string, unknown>"
4125
+ },
4126
+ {
4127
+ name: "deleteStorageObject",
4128
+ method: "POST",
4129
+ path: "/storage/objects/delete",
4130
+ requestType: "StorageObjectRequest",
4131
+ responseEnvelope: "athena",
4132
+ responseType: "Record<string, unknown>"
4133
+ },
4134
+ {
4135
+ name: "createStorageObjectUploadUrl",
4136
+ method: "POST",
4137
+ path: "/storage/objects/upload-url",
4138
+ requestType: "StoragePresignUploadRequest",
4139
+ responseEnvelope: "athena",
4140
+ responseType: "Record<string, unknown>"
4141
+ },
4142
+ {
4143
+ name: "createStorageObjectPostPolicy",
4144
+ method: "POST",
4145
+ path: "/storage/objects/post-policy",
4146
+ requestType: "StorageSignedPostPolicyRequest",
4147
+ responseEnvelope: "athena",
4148
+ responseType: "Record<string, unknown>"
4149
+ },
4150
+ {
4151
+ name: "listStorageObjectVersions",
4152
+ method: "POST",
4153
+ path: "/storage/objects/versions",
4154
+ requestType: "StorageObjectVersionListRequest",
4155
+ responseEnvelope: "athena",
4156
+ responseType: "Record<string, unknown>"
4157
+ },
4158
+ {
4159
+ name: "restoreStorageObjectVersion",
4160
+ method: "POST",
4161
+ path: "/storage/objects/versions/restore",
4162
+ requestType: "StorageObjectVersionMutationRequest",
4163
+ responseEnvelope: "athena",
4164
+ responseType: "Record<string, unknown>"
4165
+ },
4166
+ {
4167
+ name: "deleteStorageObjectVersion",
4168
+ method: "POST",
4169
+ path: "/storage/objects/versions/delete",
4170
+ requestType: "StorageObjectVersionMutationRequest",
4171
+ responseEnvelope: "athena",
4172
+ responseType: "Record<string, unknown>"
4173
+ },
4174
+ {
4175
+ name: "createStorageObjectFolder",
4176
+ method: "POST",
4177
+ path: "/storage/objects/folder",
4178
+ requestType: "StorageObjectFolderCreateRequest",
4179
+ responseEnvelope: "athena",
4180
+ responseType: "Record<string, unknown>"
4181
+ },
4182
+ {
4183
+ name: "deleteStorageObjectFolder",
4184
+ method: "POST",
4185
+ path: "/storage/objects/folder/delete",
4186
+ requestType: "StorageObjectFolderDeleteRequest",
4187
+ responseEnvelope: "athena",
4188
+ responseType: "Record<string, unknown>"
4189
+ },
4190
+ {
4191
+ name: "renameStorageObjectFolder",
4192
+ method: "POST",
4193
+ path: "/storage/objects/folder/rename",
4194
+ requestType: "StorageObjectFolderRenameRequest",
4195
+ responseEnvelope: "athena",
4196
+ responseType: "Record<string, unknown>"
4197
+ },
4198
+ {
4199
+ name: "listStorageBuckets",
4200
+ method: "POST",
4201
+ path: "/storage/buckets/list",
4202
+ requestType: "Omit<StorageObjectBaseRequest, 'bucket'>",
4203
+ responseEnvelope: "athena",
4204
+ responseType: "Record<string, unknown>"
4205
+ },
4206
+ {
4207
+ name: "createStorageBucket",
4208
+ method: "POST",
4209
+ path: "/storage/buckets/create",
4210
+ requestType: "StorageObjectBaseRequest",
4211
+ responseEnvelope: "athena",
4212
+ responseType: "Record<string, unknown>"
4213
+ },
4214
+ {
4215
+ name: "deleteStorageBucket",
4216
+ method: "POST",
4217
+ path: "/storage/buckets/delete",
4218
+ requestType: "StorageObjectBaseRequest",
4219
+ responseEnvelope: "athena",
4220
+ responseType: "Record<string, unknown>"
4221
+ },
4222
+ {
4223
+ name: "getStorageBucketLifecycle",
4224
+ method: "POST",
4225
+ path: "/storage/buckets/lifecycle",
4226
+ requestType: "StorageBucketLifecycleRequest",
4227
+ responseEnvelope: "athena",
4228
+ responseType: "Record<string, unknown>"
4229
+ },
4230
+ {
4231
+ name: "setStorageBucketLifecycle",
4232
+ method: "POST",
4233
+ path: "/storage/buckets/lifecycle/set",
4234
+ requestType: "StorageSetBucketLifecycleRequest",
4235
+ responseEnvelope: "athena",
4236
+ responseType: "Record<string, unknown>"
4237
+ },
4238
+ {
4239
+ name: "deleteStorageBucketLifecycle",
4240
+ method: "POST",
4241
+ path: "/storage/buckets/lifecycle/delete",
4242
+ requestType: "StorageBucketLifecycleRequest",
4243
+ responseEnvelope: "athena",
4244
+ responseType: "Record<string, unknown>"
4245
+ },
4246
+ {
4247
+ name: "getStorageBucketPolicy",
4248
+ method: "POST",
4249
+ path: "/storage/buckets/policy",
4250
+ requestType: "StorageBucketPolicyRequest",
4251
+ responseEnvelope: "athena",
4252
+ responseType: "Record<string, unknown>"
4253
+ },
4254
+ {
4255
+ name: "setStorageBucketPolicy",
4256
+ method: "POST",
4257
+ path: "/storage/buckets/policy/set",
4258
+ requestType: "StorageSetBucketPolicyRequest",
4259
+ responseEnvelope: "athena",
4260
+ responseType: "Record<string, unknown>"
4261
+ },
4262
+ {
4263
+ name: "deleteStorageBucketPolicy",
4264
+ method: "POST",
4265
+ path: "/storage/buckets/policy/delete",
4266
+ requestType: "StorageBucketPolicyRequest",
4267
+ responseEnvelope: "athena",
4268
+ responseType: "Record<string, unknown>"
4269
+ },
4270
+ {
4271
+ name: "getStorageBucketPublicAccess",
4272
+ method: "POST",
4273
+ path: "/storage/buckets/public-access",
4274
+ requestType: "StoragePublicAccessBlockRequest",
4275
+ responseEnvelope: "athena",
4276
+ responseType: "Record<string, unknown>"
4277
+ },
4278
+ {
4279
+ name: "setStorageBucketPublicAccess",
4280
+ method: "POST",
4281
+ path: "/storage/buckets/public-access/set",
4282
+ requestType: "StorageSetPublicAccessBlockRequest",
4283
+ responseEnvelope: "athena",
4284
+ responseType: "Record<string, unknown>"
4285
+ },
4286
+ {
4287
+ name: "deleteStorageBucketPublicAccess",
4288
+ method: "POST",
4289
+ path: "/storage/buckets/public-access/delete",
4290
+ requestType: "StoragePublicAccessBlockRequest",
4291
+ responseEnvelope: "athena",
4292
+ responseType: "Record<string, unknown>"
4293
+ },
4294
+ {
4295
+ name: "getStorageBucketCors",
4296
+ method: "POST",
4297
+ path: "/storage/buckets/cors",
4298
+ requestType: "StorageBucketCorsRequest",
4299
+ responseEnvelope: "athena",
4300
+ responseType: "Record<string, unknown>"
4301
+ },
4302
+ {
4303
+ name: "setStorageBucketCors",
4304
+ method: "POST",
4305
+ path: "/storage/buckets/cors/set",
4306
+ requestType: "StorageSetBucketCorsRequest",
4307
+ responseEnvelope: "athena",
4308
+ responseType: "Record<string, unknown>"
4309
+ },
4310
+ {
4311
+ name: "deleteStorageBucketCors",
4312
+ method: "POST",
4313
+ path: "/storage/buckets/cors/delete",
4314
+ requestType: "StorageBucketCorsRequest",
4315
+ responseEnvelope: "athena",
4316
+ responseType: "Record<string, unknown>"
4317
+ },
4318
+ {
4319
+ name: "createStorageMultipartUpload",
4320
+ method: "POST",
4321
+ path: "/storage/multipart/create",
4322
+ requestType: "StorageMultipartCreateRequest",
4323
+ responseEnvelope: "athena",
4324
+ responseType: "Record<string, unknown>"
4325
+ },
4326
+ {
4327
+ name: "signStorageMultipartPart",
4328
+ method: "POST",
4329
+ path: "/storage/multipart/sign-part",
4330
+ requestType: "StorageMultipartSignPartRequest",
4331
+ responseEnvelope: "athena",
4332
+ responseType: "Record<string, unknown>"
4333
+ },
4334
+ {
4335
+ name: "completeStorageMultipartUpload",
4336
+ method: "POST",
4337
+ path: "/storage/multipart/complete",
4338
+ requestType: "StorageMultipartCompleteRequest",
4339
+ responseEnvelope: "athena",
4340
+ responseType: "StorageFileMutationResponse"
4341
+ },
4342
+ {
4343
+ name: "abortStorageMultipartUpload",
4344
+ method: "POST",
4345
+ path: "/storage/multipart/abort",
4346
+ requestType: "StorageMultipartAbortRequest",
4347
+ responseEnvelope: "athena",
4348
+ responseType: "Record<string, unknown>"
4349
+ },
4350
+ {
4351
+ name: "listStorageMultipartParts",
4352
+ method: "POST",
4353
+ path: "/storage/multipart/list-parts",
4354
+ requestType: "StorageMultipartListPartsRequest",
4355
+ responseEnvelope: "athena",
4356
+ responseType: "Record<string, unknown>"
4357
+ },
4358
+ {
4359
+ name: "listStorageAuditEvents",
4360
+ method: "POST",
4361
+ path: "/storage/audit/list",
4362
+ requestType: "StorageAuditQueryRequest",
4363
+ responseEnvelope: "athena",
4364
+ responseType: "StorageAuditListResponse"
4365
+ }
4366
+ ]
4367
+ };
4368
+ var AthenaStorageErrorCode = {
4369
+ InvalidUrl: "INVALID_URL",
4370
+ NetworkError: "NETWORK_ERROR",
4371
+ HttpError: "HTTP_ERROR",
4372
+ InvalidJson: "INVALID_JSON",
4373
+ InvalidAthenaEnvelope: "INVALID_ATHENA_ENVELOPE",
4374
+ UnknownError: "UNKNOWN_ERROR"
4375
+ };
4376
+ var AthenaStorageError = class extends Error {
4377
+ code;
4378
+ athenaCode;
4379
+ kind;
4380
+ category;
4381
+ retryable;
4382
+ status;
4383
+ endpoint;
4384
+ method;
4385
+ requestId;
4386
+ hint;
4387
+ causeDetail;
4388
+ raw;
4389
+ normalized;
4390
+ __athenaNormalizedError;
4391
+ constructor(input) {
4392
+ super(input.message, { cause: input.cause });
4393
+ this.name = "AthenaStorageError";
4394
+ this.code = input.code;
4395
+ this.status = input.status;
4396
+ this.endpoint = input.endpoint;
4397
+ this.method = input.method;
4398
+ this.requestId = input.requestId;
4399
+ this.hint = input.hint;
4400
+ this.causeDetail = causeToString(input.cause);
4401
+ this.raw = input.raw ?? null;
4402
+ this.normalized = normalizeStorageErrorInput(input);
4403
+ this.__athenaNormalizedError = this.normalized;
4404
+ this.athenaCode = this.normalized.code;
4405
+ this.kind = this.normalized.kind;
4406
+ this.category = this.normalized.category;
4407
+ this.retryable = this.normalized.retryable;
4408
+ Object.defineProperty(this, "__athenaNormalizedError", {
4409
+ value: this.normalized,
4410
+ enumerable: false,
4411
+ configurable: false,
4412
+ writable: false
4413
+ });
4414
+ }
4415
+ toDetails() {
4416
+ return {
4417
+ code: this.code,
4418
+ athenaCode: this.athenaCode,
4419
+ kind: this.kind,
4420
+ category: this.category,
4421
+ retryable: this.retryable,
4422
+ message: this.message,
4423
+ status: this.status,
4424
+ endpoint: this.endpoint,
4425
+ method: this.method,
4426
+ requestId: this.requestId,
4427
+ hint: this.hint,
4428
+ cause: this.causeDetail,
4429
+ raw: this.raw
4430
+ };
4431
+ }
4432
+ };
4433
+ function isRecord6(value) {
4434
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4435
+ }
4436
+ function causeToString(cause) {
4437
+ if (cause === void 0 || cause === null) return void 0;
4438
+ if (typeof cause === "string") return cause;
4439
+ if (cause instanceof Error && cause.message.trim()) return cause.message.trim();
4440
+ try {
4441
+ return JSON.stringify(cause);
4442
+ } catch {
4443
+ return String(cause);
4444
+ }
4445
+ }
4446
+ function storageGatewayCode(code) {
4447
+ if (code === "INVALID_URL") return "INVALID_URL";
4448
+ if (code === "NETWORK_ERROR") return "NETWORK_ERROR";
4449
+ if (code === "INVALID_JSON" || code === "INVALID_ATHENA_ENVELOPE") return "INVALID_JSON";
4450
+ if (code === "HTTP_ERROR") return "HTTP_ERROR";
4451
+ return "UNKNOWN_ERROR";
4452
+ }
4453
+ function headerValue(headers, names) {
4454
+ for (const name of names) {
4455
+ const value = headers.get(name);
4456
+ if (value?.trim()) return value.trim();
4457
+ }
4458
+ return void 0;
4459
+ }
4460
+ function storageOperationFromEndpoint(endpoint, method) {
4461
+ const endpointPath = String(endpoint).split("?")[0];
4462
+ for (const candidate of storageSdkManifest.methods) {
4463
+ if (candidate.method !== method) continue;
4464
+ const pattern = `^${candidate.path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\\{[^/]+\\\}/g, "[^/]+")}$`;
4465
+ if (new RegExp(pattern).test(endpointPath)) {
4466
+ return candidate.name;
4467
+ }
4468
+ }
4469
+ return `storage:${method.toLowerCase()}`;
4470
+ }
4471
+ function normalizeStorageErrorInput(input) {
4472
+ return normalizeAthenaError(
4473
+ {
4474
+ data: null,
4475
+ error: {
4476
+ message: input.message,
4477
+ gatewayCode: storageGatewayCode(input.code),
4478
+ status: input.status,
4479
+ raw: input.raw ?? input.cause ?? null
4480
+ },
4481
+ errorDetails: {
4482
+ code: storageGatewayCode(input.code),
4483
+ message: input.message,
4484
+ status: input.status,
4485
+ endpoint: input.endpoint,
4486
+ method: input.method,
4487
+ requestId: input.requestId,
4488
+ hint: input.hint,
4489
+ cause: causeToString(input.cause)
4490
+ },
4491
+ raw: input.raw ?? input.cause ?? null,
4492
+ status: input.status
4493
+ },
4494
+ { operation: storageOperationFromEndpoint(input.endpoint, input.method) }
4495
+ );
4496
+ }
4497
+ function createAthenaStorageError(input) {
4498
+ return new AthenaStorageError(input);
4499
+ }
4500
+ async function notifyStorageError(error, options, runtimeOptions) {
4501
+ const handlers = [runtimeOptions?.onError, options?.onError].filter(
4502
+ (handler) => typeof handler === "function"
4503
+ );
4504
+ for (const handler of handlers) {
4505
+ try {
4506
+ await handler(error);
4507
+ } catch {
4508
+ }
4509
+ }
4510
+ }
4511
+ async function rejectStorageError(input, options, runtimeOptions) {
4512
+ const error = createAthenaStorageError(input);
4513
+ await notifyStorageError(error, options, runtimeOptions);
4514
+ throw error;
4515
+ }
4516
+ function parseResponseBody3(rawText, contentType) {
4517
+ if (!rawText) {
4518
+ return { parsed: null, parseFailed: false };
4519
+ }
4520
+ const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
4521
+ const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
4522
+ if (!looksJson) {
4523
+ return { parsed: rawText, parseFailed: false };
4524
+ }
4525
+ try {
4526
+ return { parsed: JSON.parse(rawText), parseFailed: false };
4527
+ } catch {
4528
+ return { parsed: rawText, parseFailed: true };
4529
+ }
4530
+ }
4531
+ function appendQuery(path, query) {
4532
+ if (!query) return path;
4533
+ const params = new URLSearchParams();
4534
+ for (const [key, value] of Object.entries(query)) {
4535
+ if (value === void 0 || value === null) continue;
4536
+ params.set(key, String(value));
4537
+ }
4538
+ const queryText = params.toString();
4539
+ return queryText ? `${path}?${queryText}` : path;
4540
+ }
4541
+ function storagePath(path) {
4542
+ return path;
4543
+ }
4544
+ function resolveStorageEndpointPath(endpoint, runtimeOptions) {
4545
+ if (!runtimeOptions?.stripBasePath) {
4546
+ return endpoint;
4547
+ }
4548
+ const [pathname, queryText] = String(endpoint).split("?", 2);
4549
+ const trimmedPathname = pathname.startsWith("/storage/") ? pathname.slice("/storage".length) : pathname === "/storage" ? "/" : pathname;
4550
+ const resolvedPath = trimmedPathname.startsWith("/") ? trimmedPathname : `/${trimmedPathname}`;
4551
+ return storagePath(queryText ? `${resolvedPath}?${queryText}` : resolvedPath);
4552
+ }
4553
+ function withPathParam(path, name, value) {
4554
+ return path.replace(`{${name}}`, encodeURIComponent(value));
4555
+ }
4556
+ function resolveErrorMessage3(payload, fallback) {
4557
+ if (isRecord6(payload)) {
4558
+ const message = payload.message ?? payload.error ?? payload.details;
4559
+ if (typeof message === "string" && message.trim()) {
4560
+ return message.trim();
4561
+ }
4562
+ }
4563
+ if (typeof payload === "string" && payload.trim()) {
4564
+ return payload.trim();
4565
+ }
4566
+ return fallback;
4567
+ }
4568
+ function resolveErrorHint2(payload) {
4569
+ if (!isRecord6(payload)) return void 0;
4570
+ const hint = payload.hint ?? payload.suggestion;
4571
+ return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
4572
+ }
4573
+ function resolveErrorCause(payload) {
4574
+ if (!isRecord6(payload)) return void 0;
4575
+ const cause = payload.cause ?? payload.reason;
4576
+ return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
4577
+ }
4578
+ function storageCodeFromUnknown(error) {
4579
+ if (isAthenaGatewayError(error)) {
4580
+ if (error.code === "INVALID_URL") return "INVALID_URL";
4581
+ if (error.code === "NETWORK_ERROR") return "NETWORK_ERROR";
4582
+ if (error.code === "INVALID_JSON") return "INVALID_JSON";
4583
+ if (error.code === "HTTP_ERROR") return "HTTP_ERROR";
4584
+ }
4585
+ return "UNKNOWN_ERROR";
4586
+ }
4587
+ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload, options, runtimeOptions) {
4588
+ let url;
4589
+ let headers;
4590
+ try {
4591
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : runtimeOptions?.baseUrl ? normalizeAthenaGatewayBaseUrl(runtimeOptions.baseUrl) : gateway.baseUrl;
4592
+ url = buildAthenaGatewayUrl(baseUrl, resolveStorageEndpointPath(endpoint, runtimeOptions));
4593
+ headers = gateway.buildHeaders(options);
4594
+ } catch (error) {
4595
+ return rejectStorageError(
4596
+ {
4597
+ code: storageCodeFromUnknown(error),
4598
+ message: error instanceof Error ? error.message : `Athena storage ${method} ${endpoint} failed before sending the request`,
4599
+ status: isAthenaGatewayError(error) ? error.status : 0,
4600
+ endpoint,
4601
+ method,
4602
+ raw: error,
4603
+ requestId: isAthenaGatewayError(error) ? error.requestId : void 0,
4604
+ hint: isAthenaGatewayError(error) ? error.hint : void 0,
4605
+ cause: error
4606
+ },
4607
+ options,
4608
+ runtimeOptions
4089
4609
  );
4090
4610
  }
4091
4611
  const requestInit = {
@@ -4193,8 +4713,8 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
4193
4713
  let url;
4194
4714
  let headers;
4195
4715
  try {
4196
- const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4197
- url = buildAthenaGatewayUrl(baseUrl, endpoint);
4716
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : runtimeOptions?.baseUrl ? normalizeAthenaGatewayBaseUrl(runtimeOptions.baseUrl) : gateway.baseUrl;
4717
+ url = buildAthenaGatewayUrl(baseUrl, resolveStorageEndpointPath(endpoint, runtimeOptions));
4198
4718
  headers = gateway.buildHeaders(options);
4199
4719
  } catch (error) {
4200
4720
  return rejectStorageError(
@@ -4302,7 +4822,7 @@ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
4302
4822
  return fetch(uploadUrl, init);
4303
4823
  }
4304
4824
  function attachManagedUpload(upload) {
4305
- const headers = {};
4825
+ const headers = { ...upload.headers ?? {} };
4306
4826
  return {
4307
4827
  ...upload,
4308
4828
  method: "PUT",
@@ -4348,15 +4868,20 @@ function normalizeUploadUrlRequest(input) {
4348
4868
  file_id: input.file_id ?? input.fileId,
4349
4869
  public: input.public,
4350
4870
  visibility: input.visibility,
4351
- metadata: input.metadata
4871
+ metadata: input.metadata,
4872
+ server_side_encryption: input.server_side_encryption,
4873
+ sse: input.sse,
4874
+ ssekms_key_id: input.ssekms_key_id,
4875
+ kms_key_id: input.kms_key_id,
4876
+ bucket_key_enabled: input.bucket_key_enabled
4352
4877
  };
4353
4878
  }
4354
4879
  async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
4355
4880
  let url;
4356
4881
  let headers;
4357
4882
  try {
4358
- const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4359
- url = buildAthenaGatewayUrl(baseUrl, endpoint);
4883
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : runtimeOptions?.baseUrl ? normalizeAthenaGatewayBaseUrl(runtimeOptions.baseUrl) : gateway.baseUrl;
4884
+ url = buildAthenaGatewayUrl(baseUrl, resolveStorageEndpointPath(endpoint, runtimeOptions));
4360
4885
  headers = gateway.buildHeaders(options);
4361
4886
  } catch (error) {
4362
4887
  return rejectStorageError(
@@ -4480,6 +5005,7 @@ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options,
4480
5005
  return parsedBody.parsed.data;
4481
5006
  }
4482
5007
  function createStorageModule(gateway, runtimeOptions) {
5008
+ const resolvedRuntimeOptions = runtimeOptions;
4483
5009
  const callRaw = (path, method, payload, options) => callStorageEndpoint(
4484
5010
  gateway,
4485
5011
  storagePath(path),
@@ -4487,7 +5013,7 @@ function createStorageModule(gateway, runtimeOptions) {
4487
5013
  "raw",
4488
5014
  payload,
4489
5015
  options,
4490
- runtimeOptions
5016
+ resolvedRuntimeOptions
4491
5017
  );
4492
5018
  const callAthena2 = (path, method, payload, options) => callStorageEndpoint(
4493
5019
  gateway,
@@ -4496,7 +5022,13 @@ function createStorageModule(gateway, runtimeOptions) {
4496
5022
  "athena",
4497
5023
  payload,
4498
5024
  options,
4499
- runtimeOptions
5025
+ resolvedRuntimeOptions
5026
+ );
5027
+ const callStorageFileVisibility = (fileId, method, input, options) => callAthena2(
5028
+ withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId),
5029
+ method,
5030
+ input,
5031
+ options
4500
5032
  );
4501
5033
  const base = {
4502
5034
  listStorageCatalogs(options) {
@@ -4538,7 +5070,7 @@ function createStorageModule(gateway, runtimeOptions) {
4538
5070
  withPathParam("/storage/files/{file_id}/proxy", "file_id", fileId),
4539
5071
  query
4540
5072
  );
4541
- return callStorageBinaryEndpoint(gateway, storagePath(path), "GET", options, runtimeOptions);
5073
+ return callStorageBinaryEndpoint(gateway, storagePath(path), "GET", options, resolvedRuntimeOptions);
4542
5074
  },
4543
5075
  updateStorageFile(fileId, input, options) {
4544
5076
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "PATCH", input, options);
@@ -4547,7 +5079,7 @@ function createStorageModule(gateway, runtimeOptions) {
4547
5079
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
4548
5080
  },
4549
5081
  setStorageFileVisibility(fileId, input, options) {
4550
- return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
5082
+ return callStorageFileVisibility(fileId, "PATCH", input, options);
4551
5083
  },
4552
5084
  deleteStorageFolder(input, options) {
4553
5085
  return callAthena2("/storage/folders/delete", "POST", input, options);
@@ -4585,7 +5117,7 @@ function createStorageModule(gateway, runtimeOptions) {
4585
5117
  storagePath(withPathParam("/storage/files/{file_id}/upload", "file_id", fileId)),
4586
5118
  body,
4587
5119
  options,
4588
- runtimeOptions
5120
+ resolvedRuntimeOptions
4589
5121
  );
4590
5122
  },
4591
5123
  search(input, options) {
@@ -4619,13 +5151,62 @@ function createStorageModule(gateway, runtimeOptions) {
4619
5151
  publicUrl(fileId, options) {
4620
5152
  return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
4621
5153
  },
5154
+ proxyUrl(fileId, query, options) {
5155
+ const path = appendQuery(
5156
+ withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
5157
+ query
5158
+ );
5159
+ return callAthena2(path, "GET", void 0, options);
5160
+ },
4622
5161
  proxy(fileId, query, options) {
4623
5162
  return base.getStorageFileProxy(fileId, query, options);
4624
5163
  },
4625
- visibility: {
5164
+ versions(fileId, options) {
5165
+ return callAthena2(withPathParam("/storage/files/{file_id}/versions", "file_id", fileId), "GET", void 0, options);
5166
+ },
5167
+ restoreVersion(fileId, versionId, options) {
5168
+ return callAthena2(
5169
+ withPathParam(
5170
+ withPathParam("/storage/files/{file_id}/versions/{version_id}/restore", "file_id", fileId),
5171
+ "version_id",
5172
+ versionId
5173
+ ),
5174
+ "POST",
5175
+ {},
5176
+ options
5177
+ );
5178
+ },
5179
+ deleteVersion(fileId, versionId, options) {
5180
+ return callAthena2(
5181
+ withPathParam(
5182
+ withPathParam("/storage/files/{file_id}/versions/{version_id}", "file_id", fileId),
5183
+ "version_id",
5184
+ versionId
5185
+ ),
5186
+ "DELETE",
5187
+ void 0,
5188
+ options
5189
+ );
5190
+ },
5191
+ retention: {
5192
+ get(fileId, query, options) {
5193
+ const path = appendQuery(
5194
+ withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
5195
+ query
5196
+ );
5197
+ return callAthena2(path, "GET", void 0, options);
5198
+ },
4626
5199
  set(fileId, input, options) {
5200
+ return callAthena2(withPathParam("/storage/files/{file_id}/retention", "file_id", fileId), "POST", input, options);
5201
+ }
5202
+ },
5203
+ visibility: {
5204
+ update(fileId, input, options) {
4627
5205
  return base.setStorageFileVisibility(fileId, input, options);
4628
5206
  },
5207
+ set(fileId, input, options) {
5208
+ return callStorageFileVisibility(fileId, "POST", input, options);
5209
+ },
4629
5210
  setMany(input, options) {
4630
5211
  return callAthena2("/storage/files/visibility-many", "POST", input, options);
4631
5212
  }
@@ -4720,6 +5301,18 @@ function createStorageModule(gateway, runtimeOptions) {
4720
5301
  uploadUrl(input, options) {
4721
5302
  return callAthena2("/storage/objects/upload-url", "POST", input, options);
4722
5303
  },
5304
+ versions(input, options) {
5305
+ return callAthena2("/storage/objects/versions", "POST", input, options);
5306
+ },
5307
+ restoreVersion(input, options) {
5308
+ return callAthena2("/storage/objects/versions/restore", "POST", input, options);
5309
+ },
5310
+ deleteVersion(input, options) {
5311
+ return callAthena2("/storage/objects/versions/delete", "POST", input, options);
5312
+ },
5313
+ postPolicy(input, options) {
5314
+ return callAthena2("/storage/objects/post-policy", "POST", input, options);
5315
+ },
4723
5316
  folder: objectFolder
4724
5317
  };
4725
5318
  const bucket = {
@@ -4732,6 +5325,39 @@ function createStorageModule(gateway, runtimeOptions) {
4732
5325
  delete(input, options) {
4733
5326
  return callAthena2("/storage/buckets/delete", "POST", input, options);
4734
5327
  },
5328
+ lifecycle: {
5329
+ get(input, options) {
5330
+ return callAthena2("/storage/buckets/lifecycle", "POST", input, options);
5331
+ },
5332
+ set(input, options) {
5333
+ return callAthena2("/storage/buckets/lifecycle/set", "POST", input, options);
5334
+ },
5335
+ delete(input, options) {
5336
+ return callAthena2("/storage/buckets/lifecycle/delete", "POST", input, options);
5337
+ }
5338
+ },
5339
+ policy: {
5340
+ get(input, options) {
5341
+ return callAthena2("/storage/buckets/policy", "POST", input, options);
5342
+ },
5343
+ set(input, options) {
5344
+ return callAthena2("/storage/buckets/policy/set", "POST", input, options);
5345
+ },
5346
+ delete(input, options) {
5347
+ return callAthena2("/storage/buckets/policy/delete", "POST", input, options);
5348
+ }
5349
+ },
5350
+ publicAccess: {
5351
+ get(input, options) {
5352
+ return callAthena2("/storage/buckets/public-access", "POST", input, options);
5353
+ },
5354
+ set(input, options) {
5355
+ return callAthena2("/storage/buckets/public-access/set", "POST", input, options);
5356
+ },
5357
+ delete(input, options) {
5358
+ return callAthena2("/storage/buckets/public-access/delete", "POST", input, options);
5359
+ }
5360
+ },
4735
5361
  cors: {
4736
5362
  get(input, options) {
4737
5363
  return callAthena2("/storage/buckets/cors", "POST", input, options);
@@ -4781,6 +5407,176 @@ function createStorageModule(gateway, runtimeOptions) {
4781
5407
  };
4782
5408
  }
4783
5409
 
5410
+ // src/client-builder.ts
5411
+ var DEFAULT_BACKEND = { type: "athena" };
5412
+ function toBackendConfig(value) {
5413
+ if (!value) return DEFAULT_BACKEND;
5414
+ return typeof value === "string" ? { type: value } : value;
5415
+ }
5416
+ function mergeHeaders(current, next) {
5417
+ return {
5418
+ ...current ?? {},
5419
+ ...next
5420
+ };
5421
+ }
5422
+ function mergeAuthClientConfig(current, next) {
5423
+ const merged = {
5424
+ ...current ?? {},
5425
+ ...next
5426
+ };
5427
+ if (current?.headers || next.headers) {
5428
+ merged.headers = mergeHeaders(current?.headers, next.headers ?? {});
5429
+ }
5430
+ return merged;
5431
+ }
5432
+ function mergeExperimentalOptions(current, next) {
5433
+ const merged = {
5434
+ ...current ?? {},
5435
+ ...next
5436
+ };
5437
+ if (current?.traceQueries && typeof current.traceQueries === "object" && next.traceQueries && typeof next.traceQueries === "object") {
5438
+ merged.traceQueries = {
5439
+ ...current.traceQueries,
5440
+ ...next.traceQueries
5441
+ };
5442
+ }
5443
+ if (current?.storage || next.storage) {
5444
+ merged.storage = {
5445
+ ...current?.storage ?? {},
5446
+ ...next.storage ?? {}
5447
+ };
5448
+ }
5449
+ return merged;
5450
+ }
5451
+ function resolveBuilderReturn(builder, storageEnabled, strictEnabled) {
5452
+ return builder;
5453
+ }
5454
+ var AthenaClientBuilderImpl = class {
5455
+ constructor(buildClient) {
5456
+ this.buildClient = buildClient;
5457
+ }
5458
+ rootUrl;
5459
+ apiKey;
5460
+ backendConfig = DEFAULT_BACKEND;
5461
+ clientName;
5462
+ defaultHeaders;
5463
+ authConfig;
5464
+ dbUrlOverride;
5465
+ gatewayUrlOverride;
5466
+ authUrlOverride;
5467
+ storageUrlOverride;
5468
+ experimentalOptions;
5469
+ url(url) {
5470
+ this.rootUrl = url;
5471
+ return this;
5472
+ }
5473
+ key(apiKey) {
5474
+ this.apiKey = apiKey;
5475
+ return this;
5476
+ }
5477
+ backend(backend) {
5478
+ this.backendConfig = toBackendConfig(backend);
5479
+ return this;
5480
+ }
5481
+ client(clientName) {
5482
+ this.clientName = clientName;
5483
+ return this;
5484
+ }
5485
+ headers(headers) {
5486
+ this.defaultHeaders = headers;
5487
+ return this;
5488
+ }
5489
+ auth(config) {
5490
+ this.authConfig = mergeAuthClientConfig(this.authConfig, config);
5491
+ return this;
5492
+ }
5493
+ experimental(options) {
5494
+ this.experimentalOptions = mergeExperimentalOptions(this.experimentalOptions, options);
5495
+ if (options.athenaStorageBackend && options.typecheckColumns) {
5496
+ return resolveBuilderReturn(this);
5497
+ }
5498
+ if (options.athenaStorageBackend) {
5499
+ return resolveBuilderReturn(this);
5500
+ }
5501
+ if (options.typecheckColumns) {
5502
+ return resolveBuilderReturn(this);
5503
+ }
5504
+ return this;
5505
+ }
5506
+ options(options) {
5507
+ if (options.client !== void 0) {
5508
+ this.clientName = options.client;
5509
+ }
5510
+ if (options.backend !== void 0) {
5511
+ this.backendConfig = toBackendConfig(options.backend);
5512
+ }
5513
+ if (options.headers !== void 0) {
5514
+ this.defaultHeaders = mergeHeaders(this.defaultHeaders, options.headers);
5515
+ }
5516
+ if (options.auth !== void 0) {
5517
+ this.authConfig = mergeAuthClientConfig(this.authConfig, options.auth);
5518
+ }
5519
+ if (options.db?.url !== void 0 && options.db.url !== null) {
5520
+ this.dbUrlOverride = options.db.url;
5521
+ }
5522
+ if (options.gateway?.url !== void 0 && options.gateway.url !== null) {
5523
+ this.gatewayUrlOverride = options.gateway.url;
5524
+ }
5525
+ if (options.dbUrl !== void 0 && options.dbUrl !== null) {
5526
+ this.dbUrlOverride = options.dbUrl;
5527
+ }
5528
+ if (options.gatewayUrl !== void 0 && options.gatewayUrl !== null) {
5529
+ this.gatewayUrlOverride = options.gatewayUrl;
5530
+ }
5531
+ if (options.authUrl !== void 0 && options.authUrl !== null) {
5532
+ this.authUrlOverride = options.authUrl;
5533
+ }
5534
+ if (options.storage?.url !== void 0 && options.storage.url !== null) {
5535
+ this.storageUrlOverride = options.storage.url;
5536
+ }
5537
+ if (options.storageUrl !== void 0 && options.storageUrl !== null) {
5538
+ this.storageUrlOverride = options.storageUrl;
5539
+ }
5540
+ if (options.experimental !== void 0) {
5541
+ this.experimentalOptions = mergeExperimentalOptions(this.experimentalOptions, options.experimental);
5542
+ }
5543
+ if (options.experimental?.athenaStorageBackend && options.experimental.typecheckColumns) {
5544
+ return resolveBuilderReturn(this);
5545
+ }
5546
+ if (options.experimental?.athenaStorageBackend) {
5547
+ return resolveBuilderReturn(this);
5548
+ }
5549
+ if (options.experimental?.typecheckColumns) {
5550
+ return resolveBuilderReturn(this);
5551
+ }
5552
+ return this;
5553
+ }
5554
+ build() {
5555
+ if (!this.rootUrl && !this.dbUrlOverride && !this.gatewayUrlOverride || !this.apiKey) {
5556
+ throw new Error(
5557
+ "AthenaClient requires key plus either .url() or a db/gateway override before .build()"
5558
+ );
5559
+ }
5560
+ return this.buildClient({
5561
+ url: this.rootUrl,
5562
+ key: this.apiKey,
5563
+ client: this.clientName,
5564
+ backend: this.backendConfig,
5565
+ headers: this.defaultHeaders,
5566
+ db: this.dbUrlOverride ? { url: this.dbUrlOverride } : void 0,
5567
+ gateway: this.gatewayUrlOverride ? { url: this.gatewayUrlOverride } : void 0,
5568
+ auth: this.authConfig,
5569
+ authUrl: this.authUrlOverride,
5570
+ storage: this.storageUrlOverride ? { url: this.storageUrlOverride } : void 0,
5571
+ storageUrl: this.storageUrlOverride,
5572
+ experimental: this.experimentalOptions
5573
+ });
5574
+ }
5575
+ };
5576
+ function createAthenaClientBuilder(buildClient) {
5577
+ return new AthenaClientBuilderImpl(buildClient);
5578
+ }
5579
+
4784
5580
  // src/query-ast.ts
4785
5581
  var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
4786
5582
  var FILTER_OPERATORS = /* @__PURE__ */ new Set([
@@ -5403,161 +6199,258 @@ function createSelectTransportPlan(input) {
5403
6199
  };
5404
6200
  }
5405
6201
 
5406
- // src/client.ts
5407
- var DEFAULT_COLUMNS = "*";
5408
- var SAFE_CAST_PATTERN = /^[a-z_][a-z0-9_]*(?:\[\])?$/i;
5409
- var ATHENA_NORMALIZED_ERROR_KEY = "__athenaNormalizedError";
5410
- var QUERY_TRACE_STACK_SKIP_PATTERNS = [
5411
- "src\\client.ts",
5412
- "src/client.ts",
5413
- "dist\\client.",
5414
- "dist/client.",
5415
- "node_modules\\@xylex-group\\athena",
5416
- "node_modules/@xylex-group/athena",
5417
- "node:internal",
5418
- "internal/process"
5419
- ];
5420
- function formatResult(response) {
5421
- const result = {
5422
- data: response.data ?? null,
5423
- error: null,
5424
- errorDetails: response.errorDetails ?? null,
5425
- status: response.status,
5426
- statusText: response.statusText ?? null,
5427
- raw: response.raw
6202
+ // src/query-debug-ast.ts
6203
+ var ATHENA_DEBUG_AST_KEY = "__athenaDebugAst";
6204
+ function cloneConditions(conditions) {
6205
+ return conditions.map((condition) => ({ ...condition }));
6206
+ }
6207
+ function cloneTableBuilderStateAst(state) {
6208
+ return {
6209
+ conditions: cloneConditions(state.conditions),
6210
+ limit: state.limit,
6211
+ offset: state.offset,
6212
+ order: state.order ? { ...state.order } : void 0,
6213
+ currentPage: state.currentPage,
6214
+ pageSize: state.pageSize,
6215
+ totalPages: state.totalPages
6216
+ };
6217
+ }
6218
+ function cloneRpcBuilderStateAst(state) {
6219
+ return {
6220
+ filters: state.filters.map((filter) => ({ ...filter })),
6221
+ limit: state.limit,
6222
+ offset: state.offset,
6223
+ order: state.order ? { ...state.order } : void 0
6224
+ };
6225
+ }
6226
+ function toSelectTransportAst(plan) {
6227
+ if (plan.kind === "query") {
6228
+ return {
6229
+ mode: "typed-query",
6230
+ endpoint: "/gateway/query",
6231
+ payload: plan.payload
6232
+ };
6233
+ }
6234
+ return {
6235
+ mode: plan.payload.select !== void 0 ? "structured-fetch" : "compiled-fetch",
6236
+ endpoint: "/gateway/fetch",
6237
+ payload: plan.payload
6238
+ };
6239
+ }
6240
+ function resolveDebugTableName(tableName) {
6241
+ return tableName ?? "__unknown_table__";
6242
+ }
6243
+ function buildSelectDebugAst(input) {
6244
+ return {
6245
+ version: 1,
6246
+ kind: "select",
6247
+ tableName: input.tableName,
6248
+ input: {
6249
+ columns: input.columns,
6250
+ state: cloneTableBuilderStateAst(input.state)
6251
+ },
6252
+ transport: toSelectTransportAst(input.plan)
6253
+ };
6254
+ }
6255
+ function buildFindManyCompiledDebugAst(input) {
6256
+ return {
6257
+ version: 1,
6258
+ kind: "findMany",
6259
+ tableName: input.tableName,
6260
+ input: {
6261
+ select: input.options.select,
6262
+ where: input.options.where,
6263
+ orderBy: input.options.orderBy,
6264
+ limit: input.options.limit
6265
+ },
6266
+ compiled: {
6267
+ columns: input.compiledColumns,
6268
+ baseState: cloneTableBuilderStateAst(input.baseState),
6269
+ executionState: cloneTableBuilderStateAst(input.executionState)
6270
+ },
6271
+ transport: planToFindManyTransport(input.plan)
6272
+ };
6273
+ }
6274
+ function buildFindManyDirectDebugAst(input) {
6275
+ return {
6276
+ version: 1,
6277
+ kind: "findMany",
6278
+ tableName: input.tableName,
6279
+ input: {
6280
+ select: input.options.select,
6281
+ where: input.options.where,
6282
+ orderBy: input.options.orderBy,
6283
+ limit: input.options.limit
6284
+ },
6285
+ compiled: {
6286
+ columns: input.compiledColumns,
6287
+ baseState: cloneTableBuilderStateAst(input.baseState),
6288
+ executionState: cloneTableBuilderStateAst(input.executionState)
6289
+ },
6290
+ transport: {
6291
+ mode: "direct-ast-fetch",
6292
+ endpoint: "/gateway/fetch",
6293
+ payload: input.payload
6294
+ }
5428
6295
  };
5429
- if (response.count !== void 0) {
5430
- result.count = response.count;
6296
+ }
6297
+ function planToFindManyTransport(plan) {
6298
+ if (plan.kind === "query") {
6299
+ return {
6300
+ mode: "compiled-query",
6301
+ endpoint: "/gateway/query",
6302
+ payload: plan.payload
6303
+ };
5431
6304
  }
5432
- return result;
6305
+ return {
6306
+ mode: plan.payload.select !== void 0 ? "structured-fetch" : "compiled-fetch",
6307
+ endpoint: "/gateway/fetch",
6308
+ payload: plan.payload
6309
+ };
5433
6310
  }
5434
- var EXPERIMENTAL_READ_RETRY_CONFIG = {
5435
- retries: 2,
5436
- baseDelayMs: 100,
5437
- maxDelayMs: 1e3,
5438
- backoff: "exponential",
5439
- jitter: true
5440
- };
5441
- function attachNormalizedError(result, normalizedError) {
5442
- Object.defineProperty(result, ATHENA_NORMALIZED_ERROR_KEY, {
5443
- value: normalizedError,
5444
- enumerable: false,
5445
- configurable: true,
5446
- writable: false
5447
- });
6311
+ function buildInsertDebugAst(payload) {
6312
+ return {
6313
+ version: 1,
6314
+ kind: "insert",
6315
+ tableName: payload.table_name,
6316
+ input: {
6317
+ values: payload.insert_body,
6318
+ returning: payload.columns,
6319
+ count: payload.count,
6320
+ head: payload.head,
6321
+ defaultToNull: payload.default_to_null
6322
+ },
6323
+ transport: {
6324
+ mode: "insert",
6325
+ endpoint: "/gateway/insert",
6326
+ payload
6327
+ }
6328
+ };
5448
6329
  }
5449
- function createResultFormatter(experimental) {
5450
- return (response, context) => {
5451
- const result = formatResult(response);
5452
- if (response.error == null && response.errorDetails == null) {
5453
- return result;
6330
+ function buildUpsertDebugAst(payload) {
6331
+ return {
6332
+ version: 1,
6333
+ kind: "upsert",
6334
+ tableName: payload.table_name,
6335
+ input: {
6336
+ values: payload.insert_body,
6337
+ updateBody: payload.update_body,
6338
+ onConflict: payload.on_conflict,
6339
+ returning: payload.columns,
6340
+ count: payload.count,
6341
+ head: payload.head,
6342
+ defaultToNull: payload.default_to_null
6343
+ },
6344
+ transport: {
6345
+ mode: "upsert",
6346
+ endpoint: "/gateway/insert",
6347
+ payload
5454
6348
  }
5455
- const normalizedError = normalizeAthenaError(
5456
- {
5457
- ...result,
5458
- error: response.error ?? response.errorDetails?.message ?? null
5459
- },
5460
- context
5461
- );
5462
- result.error = createResultError(response, result, normalizedError);
5463
- attachNormalizedError(result, normalizedError);
5464
- return result;
5465
6349
  };
5466
6350
  }
5467
- async function executeExperimentalRead(experimental, runner) {
5468
- if (!experimental?.retryReads) {
5469
- return runner();
5470
- }
5471
- let lastRetryableResult;
5472
- let lastRetrySignal = null;
5473
- try {
5474
- return await withRetry(
5475
- {
5476
- ...EXPERIMENTAL_READ_RETRY_CONFIG,
5477
- shouldRetry: (error) => error === lastRetrySignal || normalizeAthenaError(error).retryable
5478
- },
5479
- async () => {
5480
- const result = await runner();
5481
- if (result.error?.retryable) {
5482
- lastRetryableResult = result;
5483
- lastRetrySignal = result.error;
5484
- throw lastRetrySignal;
5485
- }
5486
- return result;
5487
- }
5488
- );
5489
- } catch (error) {
5490
- if (lastRetryableResult && error === lastRetrySignal) {
5491
- return lastRetryableResult;
6351
+ function buildUpdateDebugAst(input) {
6352
+ return {
6353
+ version: 1,
6354
+ kind: "update",
6355
+ tableName: resolveDebugTableName(input.payload.table_name),
6356
+ input: {
6357
+ values: input.payload.set,
6358
+ state: cloneTableBuilderStateAst(input.state),
6359
+ returning: input.payload.columns
6360
+ },
6361
+ transport: {
6362
+ mode: "update",
6363
+ endpoint: "/gateway/update",
6364
+ payload: input.payload
5492
6365
  }
5493
- throw error;
5494
- }
6366
+ };
5495
6367
  }
5496
- function isRecord9(value) {
5497
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6368
+ function buildDeleteDebugAst(input) {
6369
+ return {
6370
+ version: 1,
6371
+ kind: "delete",
6372
+ tableName: input.payload.table_name,
6373
+ input: {
6374
+ resourceId: input.payload.resource_id,
6375
+ state: cloneTableBuilderStateAst(input.state),
6376
+ returning: input.payload.columns
6377
+ },
6378
+ transport: {
6379
+ mode: "delete",
6380
+ endpoint: "/gateway/delete",
6381
+ payload: input.payload
6382
+ }
6383
+ };
5498
6384
  }
5499
- function firstNonEmptyString2(...values) {
5500
- for (const value of values) {
5501
- if (typeof value === "string" && value.trim().length > 0) {
5502
- return value.trim();
6385
+ function buildRpcDebugAst(input) {
6386
+ return {
6387
+ version: 1,
6388
+ kind: "rpc",
6389
+ functionName: input.functionName,
6390
+ input: {
6391
+ args: input.args,
6392
+ select: input.selectedColumns,
6393
+ state: cloneRpcBuilderStateAst(input.state)
6394
+ },
6395
+ transport: {
6396
+ mode: input.endpoint === "/gateway/rpc" ? "rpc-post" : "rpc-get",
6397
+ endpoint: input.endpoint,
6398
+ payload: input.payload
5503
6399
  }
5504
- }
5505
- return void 0;
6400
+ };
5506
6401
  }
5507
- function resolveStructuredErrorPayload2(raw) {
5508
- if (!isRecord9(raw)) return null;
5509
- return isRecord9(raw.error) ? raw.error : raw;
6402
+ function buildRawQueryDebugAst(query) {
6403
+ return {
6404
+ version: 1,
6405
+ kind: "query",
6406
+ input: {
6407
+ query
6408
+ },
6409
+ transport: {
6410
+ mode: "raw-query",
6411
+ endpoint: "/gateway/query",
6412
+ payload: {
6413
+ query
6414
+ }
6415
+ }
6416
+ };
5510
6417
  }
5511
- function resolveStructuredErrorDetails(payload, message) {
5512
- if (!payload || !("details" in payload)) {
5513
- return null;
6418
+ function attachAthenaDebugAst(target, ast) {
6419
+ if (!ast) {
6420
+ return;
5514
6421
  }
5515
- const details = payload.details;
5516
- if (details == null) {
5517
- return null;
6422
+ if (!target || typeof target !== "object" && typeof target !== "function") {
6423
+ return;
5518
6424
  }
5519
- if (typeof details === "string" && details.trim() === message.trim()) {
6425
+ Object.defineProperty(target, ATHENA_DEBUG_AST_KEY, {
6426
+ value: ast,
6427
+ enumerable: false,
6428
+ configurable: true,
6429
+ writable: false
6430
+ });
6431
+ }
6432
+ function getAthenaDebugAst(value) {
6433
+ if (!value || typeof value !== "object" && typeof value !== "function") {
5520
6434
  return null;
5521
6435
  }
5522
- return details;
5523
- }
5524
- function createResultError(response, result, normalized) {
5525
- const rawRecord = isRecord9(response.raw) ? response.raw : null;
5526
- const payload = resolveStructuredErrorPayload2(response.raw);
5527
- const message = firstNonEmptyString2(
5528
- response.error,
5529
- payload?.message,
5530
- payload?.error,
5531
- payload?.details,
5532
- response.errorDetails?.message,
5533
- normalized.message
5534
- ) ?? normalized.message;
5535
- const statusText = firstNonEmptyString2(response.statusText, rawRecord?.statusText) ?? null;
5536
- const hint = firstNonEmptyString2(payload?.hint, response.errorDetails?.hint) ?? null;
5537
- const code = firstNonEmptyString2(payload?.code) ?? normalized.code;
5538
- const details = resolveStructuredErrorDetails(payload, message) ?? response.errorDetails?.cause ?? null;
5539
- return {
5540
- message,
5541
- code,
5542
- athenaCode: normalized.code,
5543
- gatewayCode: response.errorDetails?.code ?? null,
5544
- kind: normalized.kind,
5545
- category: normalized.category,
5546
- retryable: normalized.retryable,
5547
- details,
5548
- hint,
5549
- status: result.status,
5550
- statusText,
5551
- constraint: normalized.constraint,
5552
- table: normalized.table,
5553
- operation: normalized.operation,
5554
- endpoint: response.errorDetails?.endpoint,
5555
- method: response.errorDetails?.method,
5556
- requestId: response.errorDetails?.requestId,
5557
- cause: response.errorDetails?.cause,
5558
- raw: result.raw
5559
- };
6436
+ return value[ATHENA_DEBUG_AST_KEY] ?? null;
5560
6437
  }
6438
+
6439
+ // src/query-tracing.ts
6440
+ var QUERY_TRACE_STACK_SKIP_PATTERNS = [
6441
+ "src\\client.ts",
6442
+ "src/client.ts",
6443
+ "src\\query-tracing.ts",
6444
+ "src/query-tracing.ts",
6445
+ "dist\\client.",
6446
+ "dist/client.",
6447
+ "dist\\query-tracing.",
6448
+ "dist/query-tracing.",
6449
+ "node_modules\\@xylex-group\\athena",
6450
+ "node_modules/@xylex-group/athena",
6451
+ "node:internal",
6452
+ "internal/process"
6453
+ ];
5561
6454
  function parseQueryTraceCallsiteFrame(frame) {
5562
6455
  const trimmed = frame.trim();
5563
6456
  if (!trimmed) {
@@ -5662,6 +6555,7 @@ function createQueryTracer(experimental) {
5662
6555
  functionName: context.functionName,
5663
6556
  sql: context.sql,
5664
6557
  payload: context.payload,
6558
+ ast: context.ast,
5665
6559
  options: context.options,
5666
6560
  callsite,
5667
6561
  outcome: {
@@ -5684,27 +6578,204 @@ function createQueryTracer(experimental) {
5684
6578
  functionName: context.functionName,
5685
6579
  sql: context.sql,
5686
6580
  payload: context.payload,
6581
+ ast: context.ast,
5687
6582
  options: context.options,
5688
6583
  callsite,
5689
6584
  thrownError: error
5690
6585
  });
5691
6586
  }
5692
- };
6587
+ };
6588
+ }
6589
+ async function executeWithQueryTrace(tracer, context, runner, callsiteOverride) {
6590
+ const callsite = tracer ? callsiteOverride ?? tracer.captureCallsite() : null;
6591
+ const startedAt = tracer ? Date.now() : 0;
6592
+ try {
6593
+ const result = await runner();
6594
+ attachAthenaDebugAst(result, context.ast);
6595
+ if (tracer) {
6596
+ tracer.publishSuccess(context, result, Date.now() - startedAt, callsite);
6597
+ }
6598
+ return result;
6599
+ } catch (error) {
6600
+ attachAthenaDebugAst(error, context.ast);
6601
+ if (tracer) {
6602
+ tracer.publishFailure(context, error, Date.now() - startedAt, callsite);
6603
+ }
6604
+ throw error;
6605
+ }
6606
+ }
6607
+
6608
+ // src/schema/model-target.ts
6609
+ function normalizeOptionalName(value) {
6610
+ const normalized = value?.trim();
6611
+ return normalized ? normalized : void 0;
6612
+ }
6613
+ function isAthenaModelTarget(value) {
6614
+ if (!value || typeof value !== "object") {
6615
+ return false;
6616
+ }
6617
+ const candidate = value;
6618
+ return Boolean(candidate.meta && Array.isArray(candidate.meta.primaryKey));
6619
+ }
6620
+ function resolveAthenaModelTargetTableName(target, options = {}) {
6621
+ const explicitTableName = normalizeOptionalName(target.meta.tableName);
6622
+ if (explicitTableName) {
6623
+ return explicitTableName;
6624
+ }
6625
+ const schemaName = normalizeOptionalName(target.meta.schema ?? options.fallbackSchema);
6626
+ const modelName = normalizeOptionalName(target.meta.model ?? options.fallbackModel);
6627
+ if (!modelName) {
6628
+ throw new Error(
6629
+ "Athena model target is missing meta.model or meta.tableName. Provide one of those before calling from(model)."
6630
+ );
6631
+ }
6632
+ return schemaName ? `${schemaName}.${modelName}` : modelName;
6633
+ }
6634
+
6635
+ // src/client.ts
6636
+ var DEFAULT_COLUMNS = "*";
6637
+ var SAFE_CAST_PATTERN = /^[a-z_][a-z0-9_]*(?:\[\])?$/i;
6638
+ var ATHENA_NORMALIZED_ERROR_KEY = "__athenaNormalizedError";
6639
+ function formatResult(response) {
6640
+ const result = {
6641
+ data: response.data ?? null,
6642
+ error: null,
6643
+ errorDetails: response.errorDetails ?? null,
6644
+ status: response.status,
6645
+ statusText: response.statusText ?? null,
6646
+ raw: response.raw
6647
+ };
6648
+ if (response.count !== void 0) {
6649
+ result.count = response.count;
6650
+ }
6651
+ return result;
6652
+ }
6653
+ var EXPERIMENTAL_READ_RETRY_CONFIG = {
6654
+ retries: 2,
6655
+ baseDelayMs: 100,
6656
+ maxDelayMs: 1e3,
6657
+ backoff: "exponential",
6658
+ jitter: true
6659
+ };
6660
+ function attachNormalizedError(result, normalizedError) {
6661
+ Object.defineProperty(result, ATHENA_NORMALIZED_ERROR_KEY, {
6662
+ value: normalizedError,
6663
+ enumerable: false,
6664
+ configurable: true,
6665
+ writable: false
6666
+ });
6667
+ }
6668
+ function createResultFormatter(experimental) {
6669
+ return (response, context) => {
6670
+ const result = formatResult(response);
6671
+ if (response.error == null && response.errorDetails == null) {
6672
+ return result;
6673
+ }
6674
+ const normalizedError = normalizeAthenaError(
6675
+ {
6676
+ ...result,
6677
+ error: response.error ?? response.errorDetails?.message ?? null
6678
+ },
6679
+ context
6680
+ );
6681
+ result.error = createResultError(response, result, normalizedError);
6682
+ attachNormalizedError(result, normalizedError);
6683
+ return result;
6684
+ };
6685
+ }
6686
+ async function executeExperimentalRead(experimental, runner) {
6687
+ if (!experimental?.retryReads) {
6688
+ return runner();
6689
+ }
6690
+ let lastRetryableResult;
6691
+ let lastRetrySignal = null;
6692
+ try {
6693
+ return await withRetry(
6694
+ {
6695
+ ...EXPERIMENTAL_READ_RETRY_CONFIG,
6696
+ shouldRetry: (error) => error === lastRetrySignal || normalizeAthenaError(error).retryable
6697
+ },
6698
+ async () => {
6699
+ const result = await runner();
6700
+ if (result.error?.retryable) {
6701
+ lastRetryableResult = result;
6702
+ lastRetrySignal = result.error;
6703
+ throw lastRetrySignal;
6704
+ }
6705
+ return result;
6706
+ }
6707
+ );
6708
+ } catch (error) {
6709
+ if (lastRetryableResult && error === lastRetrySignal) {
6710
+ return lastRetryableResult;
6711
+ }
6712
+ throw error;
6713
+ }
5693
6714
  }
5694
- async function executeWithQueryTrace(tracer, context, runner, callsiteOverride) {
5695
- if (!tracer) {
5696
- return runner();
6715
+ function isRecord9(value) {
6716
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6717
+ }
6718
+ function firstNonEmptyString2(...values) {
6719
+ for (const value of values) {
6720
+ if (typeof value === "string" && value.trim().length > 0) {
6721
+ return value.trim();
6722
+ }
5697
6723
  }
5698
- const callsite = callsiteOverride ?? tracer.captureCallsite();
5699
- const startedAt = Date.now();
5700
- try {
5701
- const result = await runner();
5702
- tracer.publishSuccess(context, result, Date.now() - startedAt, callsite);
5703
- return result;
5704
- } catch (error) {
5705
- tracer.publishFailure(context, error, Date.now() - startedAt, callsite);
5706
- throw error;
6724
+ return void 0;
6725
+ }
6726
+ function resolveStructuredErrorPayload2(raw) {
6727
+ if (!isRecord9(raw)) return null;
6728
+ return isRecord9(raw.error) ? raw.error : raw;
6729
+ }
6730
+ function resolveStructuredErrorDetails(payload, message) {
6731
+ if (!payload || !("details" in payload)) {
6732
+ return null;
6733
+ }
6734
+ const details = payload.details;
6735
+ if (details == null) {
6736
+ return null;
6737
+ }
6738
+ if (typeof details === "string" && details.trim() === message.trim()) {
6739
+ return null;
5707
6740
  }
6741
+ return details;
6742
+ }
6743
+ function createResultError(response, result, normalized) {
6744
+ const rawRecord = isRecord9(response.raw) ? response.raw : null;
6745
+ const payload = resolveStructuredErrorPayload2(response.raw);
6746
+ const message = firstNonEmptyString2(
6747
+ response.error,
6748
+ payload?.message,
6749
+ payload?.error,
6750
+ payload?.details,
6751
+ response.errorDetails?.message,
6752
+ normalized.message
6753
+ ) ?? normalized.message;
6754
+ const statusText = firstNonEmptyString2(response.statusText, rawRecord?.statusText) ?? null;
6755
+ const hint = firstNonEmptyString2(payload?.hint, response.errorDetails?.hint) ?? null;
6756
+ const code = firstNonEmptyString2(payload?.code) ?? normalized.code;
6757
+ const details = resolveStructuredErrorDetails(payload, message) ?? response.errorDetails?.cause ?? null;
6758
+ return {
6759
+ message,
6760
+ code,
6761
+ athenaCode: normalized.code,
6762
+ gatewayCode: response.errorDetails?.code ?? null,
6763
+ kind: normalized.kind,
6764
+ category: normalized.category,
6765
+ retryable: normalized.retryable,
6766
+ details,
6767
+ hint,
6768
+ status: result.status,
6769
+ statusText,
6770
+ constraint: normalized.constraint,
6771
+ table: normalized.table,
6772
+ operation: normalized.operation,
6773
+ endpoint: response.errorDetails?.endpoint,
6774
+ method: response.errorDetails?.method,
6775
+ requestId: response.errorDetails?.requestId,
6776
+ cause: response.errorDetails?.cause,
6777
+ raw: result.raw
6778
+ };
5708
6779
  }
5709
6780
  function toSingleResult(response) {
5710
6781
  const payload = response.data;
@@ -5733,6 +6804,15 @@ function asAthenaJsonObject(value) {
5733
6804
  function asAthenaJsonObjectArray(values) {
5734
6805
  return values;
5735
6806
  }
6807
+ function normalizeSelectColumnsInput(columns) {
6808
+ if (columns === void 0) {
6809
+ return void 0;
6810
+ }
6811
+ if (typeof columns === "string") {
6812
+ return columns;
6813
+ }
6814
+ return [...columns];
6815
+ }
5736
6816
  function createMutationQuery(executor, defaultColumns = DEFAULT_COLUMNS, tracer, initialCallsite) {
5737
6817
  let selectedColumns = defaultColumns === null ? void 0 : defaultColumns;
5738
6818
  let selectedOptions;
@@ -5742,25 +6822,29 @@ function createMutationQuery(executor, defaultColumns = DEFAULT_COLUMNS, tracer,
5742
6822
  const payloadColumns = columns ?? selectedColumns;
5743
6823
  const payloadOptions = options ?? selectedOptions;
5744
6824
  if (!promise) {
5745
- promise = executor(payloadColumns, payloadOptions, callsiteStore.resolve(callsite));
6825
+ promise = executor(
6826
+ normalizeSelectColumnsInput(payloadColumns),
6827
+ payloadOptions,
6828
+ callsiteStore.resolve(callsite)
6829
+ );
5746
6830
  }
5747
6831
  return promise;
5748
6832
  };
5749
6833
  const mutationQuery = {
5750
- select(columns = selectedColumns, options) {
6834
+ select(columns, options) {
5751
6835
  selectedColumns = columns;
5752
6836
  selectedOptions = options ?? selectedOptions;
5753
6837
  return run(columns, options, captureTraceCallsite(tracer));
5754
6838
  },
5755
- returning(columns = selectedColumns, options) {
6839
+ returning(columns, options) {
5756
6840
  return mutationQuery.select(columns, options);
5757
6841
  },
5758
- single(columns = selectedColumns, options) {
6842
+ single(columns, options) {
5759
6843
  selectedColumns = columns;
5760
6844
  selectedOptions = options ?? selectedOptions;
5761
6845
  return run(columns, options, captureTraceCallsite(tracer)).then(toSingleResult);
5762
6846
  },
5763
- maybeSingle(columns = selectedColumns, options) {
6847
+ maybeSingle(columns, options) {
5764
6848
  return mutationQuery.single(columns, options);
5765
6849
  },
5766
6850
  then(onfulfilled, onrejected) {
@@ -6317,7 +7401,10 @@ function createFilterMethods(state, addCondition, self) {
6317
7401
  }
6318
7402
  function toRpcSelect(columns) {
6319
7403
  if (!columns) return void 0;
6320
- return Array.isArray(columns) ? columns.join(",") : columns;
7404
+ if (typeof columns === "string") {
7405
+ return columns;
7406
+ }
7407
+ return columns.join(",");
6321
7408
  }
6322
7409
  function createRpcFilterMethods(filters, self) {
6323
7410
  const addFilter = (operator, column, value) => {
@@ -6366,7 +7453,7 @@ function createRpcFilterMethods(filters, self) {
6366
7453
  }
6367
7454
  };
6368
7455
  }
6369
- function createRpcBuilder(functionName, args, baseOptions, client, formatGatewayResult, tracer, initialCallsite) {
7456
+ function createRpcBuilder(functionName, args, baseOptions, client, formatGatewayResult, tracer, initialCallsite, debugAstEnabled = false) {
6370
7457
  const state = {
6371
7458
  filters: []
6372
7459
  };
@@ -6376,6 +7463,7 @@ function createRpcBuilder(functionName, args, baseOptions, client, formatGateway
6376
7463
  const callsiteStore = createTraceCallsiteStore(tracer, initialCallsite);
6377
7464
  const executeRpc = async (columns, options, callsite) => {
6378
7465
  const mergedOptions = mergeOptions(baseOptions, options);
7466
+ const normalizedSelectedColumns = normalizeSelectColumnsInput(columns);
6379
7467
  const payload = {
6380
7468
  function: functionName,
6381
7469
  args,
@@ -6390,6 +7478,14 @@ function createRpcBuilder(functionName, args, baseOptions, client, formatGateway
6390
7478
  };
6391
7479
  const endpoint = mergedOptions?.get ? `/rpc/${functionName}` : "/gateway/rpc";
6392
7480
  const sql = buildRpcDebugSql(payload);
7481
+ const debugAst = debugAstEnabled ? buildRpcDebugAst({
7482
+ functionName,
7483
+ args,
7484
+ selectedColumns: normalizedSelectedColumns,
7485
+ state,
7486
+ payload,
7487
+ endpoint
7488
+ }) : void 0;
6393
7489
  return executeWithQueryTrace(
6394
7490
  tracer,
6395
7491
  {
@@ -6398,6 +7494,7 @@ function createRpcBuilder(functionName, args, baseOptions, client, formatGateway
6398
7494
  functionName,
6399
7495
  sql,
6400
7496
  payload,
7497
+ ast: debugAst,
6401
7498
  options: mergedOptions
6402
7499
  },
6403
7500
  async () => {
@@ -6418,7 +7515,7 @@ function createRpcBuilder(functionName, args, baseOptions, client, formatGateway
6418
7515
  const builder = {};
6419
7516
  const filterMethods = createRpcFilterMethods(state.filters, builder);
6420
7517
  Object.assign(builder, filterMethods, {
6421
- select(columns = selectedColumns, options) {
7518
+ select(columns, options) {
6422
7519
  selectedColumns = columns;
6423
7520
  selectedOptions = options ?? selectedOptions;
6424
7521
  return run(columns, options, captureTraceCallsite(tracer));
@@ -6463,6 +7560,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6463
7560
  const state = {
6464
7561
  conditions: []
6465
7562
  };
7563
+ const debugAstEnabled = Boolean(experimental?.debugAst);
6466
7564
  const addCondition = (operator, column, value, hints) => {
6467
7565
  const condition = { operator };
6468
7566
  if (column) {
@@ -6506,15 +7604,27 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6506
7604
  addCondition,
6507
7605
  builder
6508
7606
  );
6509
- const runSelect = async (columns = DEFAULT_COLUMNS, options, executionState = snapshotState(), callsite) => {
7607
+ const runSelect = async (columns = DEFAULT_COLUMNS, options, executionState = snapshotState(), callsite, debugAstFactory) => {
7608
+ const runtimeColumns = normalizeSelectColumnsInput(columns) ?? DEFAULT_COLUMNS;
6510
7609
  const resolvedTableName = resolveTableNameForCall(tableName, options?.schema);
6511
7610
  const plan = createSelectTransportPlan({
6512
7611
  tableName: resolvedTableName,
6513
- columns,
7612
+ columns: runtimeColumns,
6514
7613
  state: executionState,
6515
7614
  options,
6516
7615
  buildTypedSelectQuery
6517
7616
  });
7617
+ const debugAst = debugAstEnabled ? debugAstFactory?.({
7618
+ tableName: resolvedTableName,
7619
+ columns: runtimeColumns,
7620
+ executionState,
7621
+ plan
7622
+ }) ?? buildSelectDebugAst({
7623
+ tableName: resolvedTableName,
7624
+ columns: runtimeColumns,
7625
+ state: executionState,
7626
+ plan
7627
+ }) : void 0;
6518
7628
  if (plan.kind === "query") {
6519
7629
  return executeExperimentalRead(
6520
7630
  experimental,
@@ -6526,6 +7636,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6526
7636
  table: resolvedTableName,
6527
7637
  sql: plan.query,
6528
7638
  payload: plan.payload,
7639
+ ast: debugAst,
6529
7640
  options
6530
7641
  },
6531
7642
  async () => {
@@ -6550,6 +7661,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6550
7661
  table: resolvedTableName,
6551
7662
  sql,
6552
7663
  payload: plan.payload,
7664
+ ast: debugAst,
6553
7665
  options
6554
7666
  },
6555
7667
  async () => {
@@ -6563,7 +7675,11 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6563
7675
  const createSelectChain = (columns, options, initialCallsite) => {
6564
7676
  const chain = {};
6565
7677
  const callsiteStore = createTraceCallsiteStore(tracer, initialCallsite);
6566
- const filterMethods2 = createFilterMethods(state, addCondition, chain);
7678
+ const filterMethods2 = createFilterMethods(
7679
+ state,
7680
+ addCondition,
7681
+ chain
7682
+ );
6567
7683
  Object.assign(chain, filterMethods2, {
6568
7684
  async single(cols, opts) {
6569
7685
  const r = await runSelect(
@@ -6650,6 +7766,14 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6650
7766
  limit: executionState.limit,
6651
7767
  order: executionState.order
6652
7768
  });
7769
+ const debugAst = debugAstEnabled ? buildFindManyDirectDebugAst({
7770
+ tableName: resolvedTableName,
7771
+ options,
7772
+ compiledColumns: columns,
7773
+ baseState,
7774
+ executionState,
7775
+ payload
7776
+ }) : void 0;
6653
7777
  return executeExperimentalRead(
6654
7778
  experimental,
6655
7779
  () => executeWithQueryTrace(
@@ -6659,7 +7783,8 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6659
7783
  endpoint: "/gateway/fetch",
6660
7784
  table: resolvedTableName,
6661
7785
  sql,
6662
- payload
7786
+ payload,
7787
+ ast: debugAst
6663
7788
  },
6664
7789
  async () => {
6665
7790
  const response = await client.fetchGateway(
@@ -6675,7 +7800,15 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6675
7800
  columns,
6676
7801
  void 0,
6677
7802
  executionState,
6678
- callsite
7803
+ callsite,
7804
+ debugAstEnabled ? ({ tableName: resolvedTableName, executionState: tracedState, plan }) => buildFindManyCompiledDebugAst({
7805
+ tableName: resolvedTableName,
7806
+ options,
7807
+ compiledColumns: columns,
7808
+ baseState,
7809
+ executionState: tracedState,
7810
+ plan
7811
+ }) : void 0
6679
7812
  );
6680
7813
  },
6681
7814
  insert(values, options) {
@@ -6695,6 +7828,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6695
7828
  payload.default_to_null = mergedOptions.defaultToNull;
6696
7829
  }
6697
7830
  const sql = buildInsertDebugSql(payload);
7831
+ const debugAst = debugAstEnabled ? buildInsertDebugAst(payload) : void 0;
6698
7832
  return executeWithQueryTrace(
6699
7833
  tracer,
6700
7834
  {
@@ -6703,6 +7837,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6703
7837
  table: resolvedTableName,
6704
7838
  sql,
6705
7839
  payload,
7840
+ ast: debugAst,
6706
7841
  options: mergedOptions
6707
7842
  },
6708
7843
  async () => {
@@ -6728,6 +7863,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6728
7863
  payload.default_to_null = mergedOptions.defaultToNull;
6729
7864
  }
6730
7865
  const sql = buildInsertDebugSql(payload);
7866
+ const debugAst = debugAstEnabled ? buildInsertDebugAst(payload) : void 0;
6731
7867
  return executeWithQueryTrace(
6732
7868
  tracer,
6733
7869
  {
@@ -6736,6 +7872,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6736
7872
  table: resolvedTableName,
6737
7873
  sql,
6738
7874
  payload,
7875
+ ast: debugAst,
6739
7876
  options: mergedOptions
6740
7877
  },
6741
7878
  async () => {
@@ -6766,6 +7903,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6766
7903
  payload.default_to_null = mergedOptions.defaultToNull;
6767
7904
  }
6768
7905
  const sql = buildInsertDebugSql(payload);
7906
+ const debugAst = debugAstEnabled ? buildUpsertDebugAst(payload) : void 0;
6769
7907
  return executeWithQueryTrace(
6770
7908
  tracer,
6771
7909
  {
@@ -6774,6 +7912,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6774
7912
  table: resolvedTableName,
6775
7913
  sql,
6776
7914
  payload,
7915
+ ast: debugAst,
6777
7916
  options: mergedOptions
6778
7917
  },
6779
7918
  async () => {
@@ -6801,6 +7940,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6801
7940
  payload.default_to_null = mergedOptions.defaultToNull;
6802
7941
  }
6803
7942
  const sql = buildInsertDebugSql(payload);
7943
+ const debugAst = debugAstEnabled ? buildUpsertDebugAst(payload) : void 0;
6804
7944
  return executeWithQueryTrace(
6805
7945
  tracer,
6806
7946
  {
@@ -6809,6 +7949,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6809
7949
  table: resolvedTableName,
6810
7950
  sql,
6811
7951
  payload,
7952
+ ast: debugAst,
6812
7953
  options: mergedOptions
6813
7954
  },
6814
7955
  async () => {
@@ -6823,7 +7964,8 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6823
7964
  update(values, options) {
6824
7965
  const mutationCallsite = captureTraceCallsite(tracer);
6825
7966
  const executeUpdate = async (columns, selectOptions, callsite) => {
6826
- const filters = state.conditions.length ? [...state.conditions] : void 0;
7967
+ const executionState = snapshotState();
7968
+ const filters = executionState.conditions.length ? [...executionState.conditions] : void 0;
6827
7969
  const mergedOptions = mergeOptions(options, selectOptions);
6828
7970
  const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
6829
7971
  const payload = {
@@ -6832,12 +7974,16 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6832
7974
  conditions: filters,
6833
7975
  strip_nulls: mergedOptions?.stripNulls ?? true
6834
7976
  };
6835
- if (state.order) payload.sort_by = state.order;
6836
- if (state.currentPage !== void 0) payload.current_page = state.currentPage;
6837
- if (state.pageSize !== void 0) payload.page_size = state.pageSize;
6838
- if (state.totalPages !== void 0) payload.total_pages = state.totalPages;
7977
+ if (executionState.order) payload.sort_by = executionState.order;
7978
+ if (executionState.currentPage !== void 0) payload.current_page = executionState.currentPage;
7979
+ if (executionState.pageSize !== void 0) payload.page_size = executionState.pageSize;
7980
+ if (executionState.totalPages !== void 0) payload.total_pages = executionState.totalPages;
6839
7981
  if (columns) payload.columns = columns;
6840
7982
  const sql = buildUpdateDebugSql(payload);
7983
+ const debugAst = debugAstEnabled ? buildUpdateDebugAst({
7984
+ state: executionState,
7985
+ payload
7986
+ }) : void 0;
6841
7987
  return executeWithQueryTrace(
6842
7988
  tracer,
6843
7989
  {
@@ -6846,6 +7992,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6846
7992
  table: resolvedTableName,
6847
7993
  sql,
6848
7994
  payload,
7995
+ ast: debugAst,
6849
7996
  options: mergedOptions
6850
7997
  },
6851
7998
  async () => {
@@ -6869,6 +8016,11 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6869
8016
  }
6870
8017
  const mutationCallsite = captureTraceCallsite(tracer);
6871
8018
  const executeDelete = async (columns, selectOptions, callsite) => {
8019
+ const executionState = snapshotState();
8020
+ const debugState = {
8021
+ ...executionState,
8022
+ conditions: filters ? filters.map((condition) => ({ ...condition })) : []
8023
+ };
6872
8024
  const mergedOptions = mergeOptions(options, selectOptions);
6873
8025
  const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
6874
8026
  const payload = {
@@ -6876,12 +8028,16 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6876
8028
  resource_id: resourceId,
6877
8029
  conditions: filters
6878
8030
  };
6879
- if (state.order) payload.sort_by = state.order;
6880
- if (state.currentPage !== void 0) payload.current_page = state.currentPage;
6881
- if (state.pageSize !== void 0) payload.page_size = state.pageSize;
6882
- if (state.totalPages !== void 0) payload.total_pages = state.totalPages;
8031
+ if (executionState.order) payload.sort_by = executionState.order;
8032
+ if (executionState.currentPage !== void 0) payload.current_page = executionState.currentPage;
8033
+ if (executionState.pageSize !== void 0) payload.page_size = executionState.pageSize;
8034
+ if (executionState.totalPages !== void 0) payload.total_pages = executionState.totalPages;
6883
8035
  if (columns) payload.columns = columns;
6884
8036
  const sql = buildDeleteDebugSql(payload);
8037
+ const debugAst = debugAstEnabled ? buildDeleteDebugAst({
8038
+ state: debugState,
8039
+ payload
8040
+ }) : void 0;
6885
8041
  return executeWithQueryTrace(
6886
8042
  tracer,
6887
8043
  {
@@ -6890,6 +8046,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6890
8046
  table: resolvedTableName,
6891
8047
  sql,
6892
8048
  payload,
8049
+ ast: debugAst,
6893
8050
  options: mergedOptions
6894
8051
  },
6895
8052
  async () => {
@@ -6917,6 +8074,7 @@ function createTableBuilder(tableName, client, formatGatewayResult, tracer, expe
6917
8074
  return builder;
6918
8075
  }
6919
8076
  function createQueryBuilder(client, formatGatewayResult, experimental, tracer) {
8077
+ const debugAstEnabled = Boolean(experimental?.debugAst);
6920
8078
  return async function query(query, options) {
6921
8079
  const normalizedQuery = query.trim();
6922
8080
  if (!normalizedQuery) {
@@ -6933,6 +8091,7 @@ function createQueryBuilder(client, formatGatewayResult, experimental, tracer) {
6933
8091
  endpoint: "/gateway/query",
6934
8092
  sql: normalizedQuery,
6935
8093
  payload,
8094
+ ast: debugAstEnabled ? buildRawQueryDebugAst(normalizedQuery) : void 0,
6936
8095
  options
6937
8096
  },
6938
8097
  async () => {
@@ -6944,6 +8103,96 @@ function createQueryBuilder(client, formatGatewayResult, experimental, tracer) {
6944
8103
  );
6945
8104
  };
6946
8105
  }
8106
+ function resolveClientServiceBaseUrl(value, label) {
8107
+ if (value === void 0 || value === null) {
8108
+ return void 0;
8109
+ }
8110
+ return normalizeAthenaGatewayBaseUrl(value, { label });
8111
+ }
8112
+ function appendServicePath(baseUrl, segment) {
8113
+ const normalizedBaseUrl = normalizeAthenaGatewayBaseUrl(baseUrl, { label: "Athena public base URL" });
8114
+ return `${normalizedBaseUrl}/${segment.replace(/^\/+/, "")}`;
8115
+ }
8116
+ function resolveServiceUrlOverride(value, label) {
8117
+ return resolveClientServiceBaseUrl(value, label);
8118
+ }
8119
+ function resolveServiceUrls(config) {
8120
+ const baseUrl = resolveClientServiceBaseUrl(config.url, "Athena public base URL");
8121
+ return {
8122
+ dbUrl: resolveServiceUrlOverride(config.db?.url, "Athena DB base URL") ?? resolveServiceUrlOverride(config.gateway?.url, "Athena gateway base URL") ?? resolveServiceUrlOverride(config.dbUrl, "Athena DB base URL") ?? resolveServiceUrlOverride(config.gatewayUrl, "Athena gateway base URL") ?? (baseUrl ? appendServicePath(baseUrl, "db") : void 0),
8123
+ authUrl: resolveServiceUrlOverride(config.auth?.url, "Athena auth base URL") ?? resolveServiceUrlOverride(config.auth?.baseUrl, "Athena auth base URL") ?? resolveServiceUrlOverride(config.authUrl, "Athena auth base URL") ?? (baseUrl ? appendServicePath(baseUrl, "auth") : void 0),
8124
+ storageUrl: resolveServiceUrlOverride(config.storage?.url, "Athena storage base URL") ?? resolveServiceUrlOverride(config.storageUrl, "Athena storage base URL") ?? (baseUrl ? appendServicePath(baseUrl, "storage") : void 0)
8125
+ };
8126
+ }
8127
+ function resolveOptionalClientName(value) {
8128
+ if (value === void 0 || value === null) {
8129
+ return void 0;
8130
+ }
8131
+ const normalizedValue = value.trim();
8132
+ return normalizedValue ? normalizedValue : void 0;
8133
+ }
8134
+ function resolveRequiredClientApiKey(value) {
8135
+ if (value === void 0 || value === null) {
8136
+ throw new Error(
8137
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8138
+ );
8139
+ }
8140
+ const normalizedValue = value.trim();
8141
+ if (!normalizedValue) {
8142
+ throw new Error(
8143
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8144
+ );
8145
+ }
8146
+ return normalizedValue;
8147
+ }
8148
+ function normalizeAuthClientConfig(auth, defaultBaseUrl) {
8149
+ if (!auth && defaultBaseUrl === void 0) {
8150
+ return void 0;
8151
+ }
8152
+ const {
8153
+ url,
8154
+ baseUrl,
8155
+ apiKey,
8156
+ bearerToken,
8157
+ ...rest
8158
+ } = auth ?? {};
8159
+ const normalized = {
8160
+ ...rest
8161
+ };
8162
+ const resolvedBaseUrl = resolveClientServiceBaseUrl(
8163
+ url ?? baseUrl ?? defaultBaseUrl,
8164
+ "Athena auth base URL"
8165
+ );
8166
+ if (resolvedBaseUrl !== void 0) {
8167
+ normalized.baseUrl = resolvedBaseUrl;
8168
+ }
8169
+ if (typeof apiKey === "string") {
8170
+ normalized.apiKey = apiKey;
8171
+ }
8172
+ if (typeof bearerToken === "string") {
8173
+ normalized.bearerToken = bearerToken;
8174
+ }
8175
+ return normalized;
8176
+ }
8177
+ function resolveCreateClientConfig(config) {
8178
+ const resolvedUrls = resolveServiceUrls(config);
8179
+ if (!resolvedUrls.dbUrl) {
8180
+ throw new Error(
8181
+ "Athena DB base URL is required. Pass createClient(url, key) for a unified root, or set db.url / gateway.url / gatewayUrl explicitly."
8182
+ );
8183
+ }
8184
+ return {
8185
+ baseUrl: resolvedUrls.dbUrl,
8186
+ apiKey: resolveRequiredClientApiKey(config.key),
8187
+ client: resolveOptionalClientName(config.client),
8188
+ backend: toBackendConfig(config.backend),
8189
+ headers: config.headers,
8190
+ auth: config.auth,
8191
+ authUrl: resolvedUrls.authUrl,
8192
+ storageUrl: resolvedUrls.storageUrl,
8193
+ experimental: config.experimental
8194
+ };
8195
+ }
6947
8196
  function createClientFromConfig(config) {
6948
8197
  const gatewayHeaders = {
6949
8198
  ...config.headers ?? {}
@@ -6960,184 +8209,112 @@ function createClientFromConfig(config) {
6960
8209
  });
6961
8210
  const formatGatewayResult = createResultFormatter(config.experimental);
6962
8211
  const queryTracer = createQueryTracer(config.experimental);
6963
- const auth = createAuthClient(config.auth);
6964
- const from = (table, options) => createTableBuilder(
6965
- resolveTableNameForCall(table, options?.schema),
6966
- gateway,
6967
- formatGatewayResult,
6968
- queryTracer,
6969
- config.experimental
6970
- );
6971
- const rpc = (fn, args, options) => {
6972
- const normalizedFn = fn.trim();
6973
- if (!normalizedFn) {
6974
- throw new Error("rpc requires a function name");
8212
+ const auth = createAuthClient(normalizeAuthClientConfig(config.auth, config.authUrl));
8213
+ function from(tableOrModel, options) {
8214
+ if (isAthenaModelTarget(tableOrModel)) {
8215
+ if (options?.schema !== void 0) {
8216
+ throw new Error(
8217
+ "from(model) does not accept a schema override because the model already defines its target."
8218
+ );
8219
+ }
8220
+ return createTableBuilder(
8221
+ resolveAthenaModelTargetTableName(tableOrModel),
8222
+ gateway,
8223
+ formatGatewayResult,
8224
+ queryTracer,
8225
+ config.experimental
8226
+ );
6975
8227
  }
6976
- return createRpcBuilder(
6977
- normalizedFn,
6978
- args,
6979
- options,
8228
+ const resolvedTableName = resolveTableNameForCall(tableOrModel, options?.schema);
8229
+ return createTableBuilder(
8230
+ resolvedTableName,
6980
8231
  gateway,
6981
8232
  formatGatewayResult,
6982
8233
  queryTracer,
6983
- captureTraceCallsite(queryTracer)
8234
+ config.experimental
6984
8235
  );
6985
- };
6986
- const query = createQueryBuilder(gateway, formatGatewayResult, config.experimental, queryTracer);
6987
- const db = createDbModule({ from, rpc, query });
6988
- const sdkClient = {
6989
- from,
6990
- db,
6991
- rpc,
6992
- query,
6993
- verifyConnection: gateway.verifyConnection,
6994
- auth: auth.auth
6995
- };
6996
- if (config.experimental?.athenaStorageBackend) {
6997
- const storageClient = {
6998
- ...sdkClient,
6999
- storage: createStorageModule(gateway, config.experimental.storage)
7000
- };
7001
- return storageClient;
7002
- }
7003
- return sdkClient;
7004
- }
7005
- var DEFAULT_BACKEND = { type: "athena" };
7006
- function toBackendConfig(b) {
7007
- if (!b) return DEFAULT_BACKEND;
7008
- return typeof b === "string" ? { type: b } : b;
7009
- }
7010
- function mergeAuthClientConfig(current, next) {
7011
- const merged = {
7012
- ...current ?? {},
7013
- ...next
7014
- };
7015
- if (current?.headers || next.headers) {
7016
- merged.headers = {
7017
- ...current?.headers ?? {},
7018
- ...next.headers ?? {}
7019
- };
7020
- }
7021
- return merged;
7022
- }
7023
- function mergeExperimentalOptions(current, next) {
7024
- const merged = {
7025
- ...current ?? {},
7026
- ...next
7027
- };
7028
- if (current?.traceQueries && typeof current.traceQueries === "object" && next.traceQueries && typeof next.traceQueries === "object") {
7029
- merged.traceQueries = {
7030
- ...current.traceQueries,
7031
- ...next.traceQueries
7032
- };
7033
- }
7034
- if (current?.storage || next.storage) {
7035
- merged.storage = {
7036
- ...current?.storage ?? {},
7037
- ...next.storage ?? {}
7038
- };
7039
- }
7040
- return merged;
7041
- }
7042
- var AthenaClientBuilderImpl = class {
7043
- baseUrl;
7044
- apiKey;
7045
- backendConfig = DEFAULT_BACKEND;
7046
- clientName;
7047
- defaultHeaders;
7048
- authConfig;
7049
- experimentalOptions;
7050
- url(url) {
7051
- this.baseUrl = url;
7052
- return this;
7053
- }
7054
- key(apiKey) {
7055
- this.apiKey = apiKey;
7056
- return this;
7057
- }
7058
- backend(backend) {
7059
- this.backendConfig = toBackendConfig(backend);
7060
- return this;
7061
- }
7062
- client(clientName) {
7063
- this.clientName = clientName;
7064
- return this;
7065
- }
7066
- headers(headers) {
7067
- this.defaultHeaders = headers;
7068
- return this;
7069
- }
7070
- auth(config) {
7071
- this.authConfig = mergeAuthClientConfig(this.authConfig, config);
7072
- return this;
7073
- }
7074
- experimental(options) {
7075
- this.experimentalOptions = mergeExperimentalOptions(this.experimentalOptions, options);
7076
- return options.athenaStorageBackend ? this : this;
7077
- }
7078
- options(options) {
7079
- if (options.client !== void 0) {
7080
- this.clientName = options.client;
7081
- }
7082
- if (options.backend !== void 0) {
7083
- this.backendConfig = toBackendConfig(options.backend);
7084
- }
7085
- if (options.headers !== void 0) {
7086
- this.defaultHeaders = {
7087
- ...this.defaultHeaders ?? {},
7088
- ...options.headers
7089
- };
7090
- }
7091
- if (options.auth !== void 0) {
7092
- this.authConfig = mergeAuthClientConfig(this.authConfig, options.auth);
7093
- }
7094
- if (options.experimental !== void 0) {
7095
- this.experimentalOptions = mergeExperimentalOptions(this.experimentalOptions, options.experimental);
7096
- }
7097
- return options.experimental?.athenaStorageBackend ? this : this;
7098
- }
7099
- build() {
7100
- if (!this.baseUrl || !this.apiKey) {
7101
- throw new Error("AthenaClient requires url and key; call .url() and .key() before .build()");
7102
- }
7103
- return createClientFromConfig({
7104
- baseUrl: this.baseUrl,
7105
- apiKey: this.apiKey,
7106
- client: this.clientName,
7107
- backend: this.backendConfig,
7108
- headers: this.defaultHeaders,
7109
- auth: this.authConfig,
7110
- experimental: this.experimentalOptions
7111
- });
7112
8236
  }
7113
- };
7114
- var AthenaClient = class _AthenaClient {
8237
+ const rpc = (fn, args, options) => {
8238
+ const normalizedFn = fn.trim();
8239
+ if (!normalizedFn) {
8240
+ throw new Error("rpc requires a function name");
8241
+ }
8242
+ return createRpcBuilder(
8243
+ normalizedFn,
8244
+ args,
8245
+ options,
8246
+ gateway,
8247
+ formatGatewayResult,
8248
+ queryTracer,
8249
+ captureTraceCallsite(queryTracer),
8250
+ Boolean(config.experimental?.debugAst)
8251
+ );
8252
+ };
8253
+ const query = createQueryBuilder(
8254
+ gateway,
8255
+ formatGatewayResult,
8256
+ config.experimental,
8257
+ queryTracer
8258
+ );
8259
+ const db = createDbModule({ from, rpc, query });
8260
+ const sdkClient = {
8261
+ from,
8262
+ db,
8263
+ rpc,
8264
+ query,
8265
+ verifyConnection: gateway.verifyConnection,
8266
+ auth: auth.auth
8267
+ };
8268
+ if (config.experimental?.athenaStorageBackend) {
8269
+ const storageClient = {
8270
+ ...sdkClient,
8271
+ storage: createStorageModule(gateway, {
8272
+ ...config.experimental.storage,
8273
+ ...config.storageUrl ? {
8274
+ baseUrl: config.storageUrl,
8275
+ stripBasePath: true
8276
+ } : {}
8277
+ })
8278
+ };
8279
+ return storageClient;
8280
+ }
8281
+ return sdkClient;
8282
+ }
8283
+ var AthenaClient = class {
7115
8284
  /** Create a fluent builder for a strongly-typed Athena SDK client. */
7116
8285
  static builder() {
7117
- return new AthenaClientBuilderImpl();
8286
+ return createAthenaClientBuilder((config) => createClientFromConfig(resolveCreateClientConfig(config)));
7118
8287
  }
7119
8288
  /** Build a client from process environment variables. */
7120
8289
  static fromEnvironment() {
7121
- const url = process.env.ATHENA_URL ?? process.env.ATHENA_GATEWAY_URL;
8290
+ const url = process.env.ATHENA_URL;
8291
+ const gatewayUrl = process.env.ATHENA_DB_URL ?? process.env.ATHENA_GATEWAY_URL;
8292
+ const authUrl = process.env.ATHENA_AUTH_URL;
8293
+ const storageUrl = process.env.ATHENA_STORAGE_URL;
7122
8294
  const key = process.env.ATHENA_API_KEY ?? process.env.ATHENA_GATEWAY_API_KEY;
7123
- if (!url || !key) {
8295
+ if (!url && !gatewayUrl || !key) {
7124
8296
  throw new Error(
7125
- "ATHENA_URL and ATHENA_API_KEY (or ATHENA_GATEWAY_URL and ATHENA_GATEWAY_API_KEY) are required"
8297
+ "ATHENA_API_KEY plus ATHENA_URL or ATHENA_GATEWAY_URL (optionally ATHENA_DB_URL, ATHENA_AUTH_URL, ATHENA_STORAGE_URL) are required"
7126
8298
  );
7127
8299
  }
7128
- return _AthenaClient.builder().url(url).key(key).build();
8300
+ return createClient({
8301
+ url,
8302
+ gatewayUrl,
8303
+ authUrl,
8304
+ storageUrl,
8305
+ key
8306
+ });
7129
8307
  }
7130
8308
  };
7131
- function createClient(url, apiKey, options) {
7132
- return createClientFromConfig({
7133
- baseUrl: url,
7134
- apiKey,
7135
- client: options?.client,
7136
- backend: toBackendConfig(options?.backend),
7137
- headers: options?.headers,
7138
- auth: options?.auth,
7139
- experimental: options?.experimental
7140
- });
8309
+ function createClient(configOrUrl, apiKey, options) {
8310
+ if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
8311
+ return createClientFromConfig(resolveCreateClientConfig({
8312
+ url: configOrUrl,
8313
+ key: apiKey ?? "",
8314
+ ...options
8315
+ }));
8316
+ }
8317
+ return createClientFromConfig(resolveCreateClientConfig(configOrUrl));
7141
8318
  }
7142
8319
 
7143
8320
  // src/gateway/types.ts
@@ -7162,6 +8339,379 @@ function defineRegistry(databases) {
7162
8339
  return databases;
7163
8340
  }
7164
8341
 
8342
+ // src/schema/model-form.ts
8343
+ function resolveNullishValue(mode) {
8344
+ if (mode === "undefined") return void 0;
8345
+ if (mode === "null") return null;
8346
+ return "";
8347
+ }
8348
+ function isRecord10(value) {
8349
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
8350
+ }
8351
+ function isNullableColumn(model, key) {
8352
+ const nullable = model.meta.nullable;
8353
+ return nullable?.[key] === true;
8354
+ }
8355
+ function toModelFormDefaults(model, values, options) {
8356
+ const source = values;
8357
+ if (!isRecord10(source)) {
8358
+ return {};
8359
+ }
8360
+ const mode = options?.nullishMode ?? "empty-string";
8361
+ const nullishValue = resolveNullishValue(mode);
8362
+ const result = {};
8363
+ for (const [key, value] of Object.entries(source)) {
8364
+ if (value === null && isNullableColumn(model, key)) {
8365
+ result[key] = nullishValue;
8366
+ continue;
8367
+ }
8368
+ result[key] = value;
8369
+ }
8370
+ return result;
8371
+ }
8372
+ function toModelPayload(model, formValues, options) {
8373
+ const emptyStringAsNull = options?.emptyStringAsNull ?? true;
8374
+ const stripUndefined = options?.stripUndefined ?? true;
8375
+ const result = {};
8376
+ for (const [key, rawValue] of Object.entries(formValues)) {
8377
+ if (rawValue === void 0 && stripUndefined) {
8378
+ continue;
8379
+ }
8380
+ if (emptyStringAsNull && rawValue === "" && isNullableColumn(model, key)) {
8381
+ result[key] = null;
8382
+ continue;
8383
+ }
8384
+ result[key] = rawValue;
8385
+ }
8386
+ return result;
8387
+ }
8388
+ function createModelFormAdapter(model) {
8389
+ return {
8390
+ model,
8391
+ toDefaults(values, options) {
8392
+ return toModelFormDefaults(model, values, options);
8393
+ },
8394
+ toInsert(values, options) {
8395
+ return toModelPayload(model, values, options);
8396
+ },
8397
+ toUpdate(values, options) {
8398
+ return toModelPayload(model, values, options);
8399
+ }
8400
+ };
8401
+ }
8402
+
8403
+ // src/schema/table-columns.ts
8404
+ var COLUMN_CONFIG = /* @__PURE__ */ Symbol("athena.column.config");
8405
+ function createColumnBuilder(config) {
8406
+ return {
8407
+ [COLUMN_CONFIG]: config,
8408
+ optional() {
8409
+ return createColumnBuilder({
8410
+ ...config,
8411
+ nullable: true
8412
+ });
8413
+ },
8414
+ from(columnName) {
8415
+ return createColumnBuilder({
8416
+ ...config,
8417
+ columnName
8418
+ });
8419
+ },
8420
+ defaulted() {
8421
+ return createColumnBuilder({
8422
+ ...config,
8423
+ hasDefault: true
8424
+ });
8425
+ },
8426
+ generated() {
8427
+ return createColumnBuilder({
8428
+ ...config,
8429
+ isGenerated: true
8430
+ });
8431
+ }
8432
+ };
8433
+ }
8434
+ function isColumnBuilder(value) {
8435
+ return value !== null && typeof value === "object" && COLUMN_CONFIG in value;
8436
+ }
8437
+ function getColumnConfig(column) {
8438
+ return column[COLUMN_CONFIG];
8439
+ }
8440
+ function string() {
8441
+ return createColumnBuilder({
8442
+ kind: "string",
8443
+ nullable: false,
8444
+ hasDefault: false,
8445
+ isGenerated: false
8446
+ });
8447
+ }
8448
+ function number() {
8449
+ return createColumnBuilder({
8450
+ kind: "number",
8451
+ nullable: false,
8452
+ hasDefault: false,
8453
+ isGenerated: false
8454
+ });
8455
+ }
8456
+ function boolean() {
8457
+ return createColumnBuilder({
8458
+ kind: "boolean",
8459
+ nullable: false,
8460
+ hasDefault: false,
8461
+ isGenerated: false
8462
+ });
8463
+ }
8464
+ function json(schema) {
8465
+ return createColumnBuilder({
8466
+ kind: "json",
8467
+ nullable: false,
8468
+ hasDefault: false,
8469
+ isGenerated: false,
8470
+ jsonSchema: schema
8471
+ });
8472
+ }
8473
+ function enumeration(values) {
8474
+ if (values.length === 0) {
8475
+ throw new Error("enumeration() requires at least one value");
8476
+ }
8477
+ return createColumnBuilder({
8478
+ kind: "enumeration",
8479
+ nullable: false,
8480
+ hasDefault: false,
8481
+ isGenerated: false,
8482
+ enumValues: values
8483
+ });
8484
+ }
8485
+
8486
+ // src/schema/table-schemas.ts
8487
+ function isScalarFormKind(kind) {
8488
+ return kind === "string" || kind === "number" || kind === "boolean" || kind === "enumeration";
8489
+ }
8490
+ function createBaseSchema(column) {
8491
+ const config = getColumnConfig(column);
8492
+ switch (config.kind) {
8493
+ case "boolean":
8494
+ return z.boolean();
8495
+ case "number":
8496
+ return z.number();
8497
+ case "json":
8498
+ return config.jsonSchema ?? z.unknown();
8499
+ case "enumeration":
8500
+ if (!config.enumValues || config.enumValues.length === 0) {
8501
+ return z.string();
8502
+ }
8503
+ return z.enum(config.enumValues);
8504
+ case "string":
8505
+ default:
8506
+ return z.string();
8507
+ }
8508
+ }
8509
+ function applyNullable(schema, column) {
8510
+ const config = getColumnConfig(column);
8511
+ return config.nullable ? schema.nullable() : schema;
8512
+ }
8513
+ function applyInsertOptional(schema, column) {
8514
+ const config = getColumnConfig(column);
8515
+ return config.nullable || config.hasDefault ? schema.optional() : schema;
8516
+ }
8517
+ function createFormFieldSchema(column) {
8518
+ const config = getColumnConfig(column);
8519
+ const base = createBaseSchema(column);
8520
+ let schema;
8521
+ if (config.nullable && isScalarFormKind(config.kind)) {
8522
+ schema = z.union([base, z.literal("")]).transform((value) => value === "" ? null : value);
8523
+ } else {
8524
+ schema = applyNullable(base, column);
8525
+ }
8526
+ if (config.nullable || config.hasDefault) {
8527
+ schema = schema.optional();
8528
+ }
8529
+ return schema;
8530
+ }
8531
+ function buildTableSchemaBundle(model, columns) {
8532
+ const rowShape = {};
8533
+ const insertShape = {};
8534
+ const updateShape = {};
8535
+ const formShape = {};
8536
+ for (const [columnName, column] of Object.entries(columns)) {
8537
+ const config = getColumnConfig(column);
8538
+ const base = createBaseSchema(column);
8539
+ rowShape[columnName] = applyNullable(base, column);
8540
+ if (config.isGenerated) {
8541
+ continue;
8542
+ }
8543
+ insertShape[columnName] = applyInsertOptional(applyNullable(base, column), column);
8544
+ updateShape[columnName] = applyNullable(base, column).optional();
8545
+ formShape[columnName] = createFormFieldSchema(column);
8546
+ }
8547
+ const rowSchema = z.object(rowShape);
8548
+ const insertSchema = z.object(insertShape);
8549
+ const updateSchema = z.object(updateShape);
8550
+ const formSchema = z.object(formShape).transform((value) => toModelPayload(model, value));
8551
+ return {
8552
+ row: rowSchema,
8553
+ insert: insertSchema,
8554
+ update: updateSchema,
8555
+ form: formSchema
8556
+ };
8557
+ }
8558
+
8559
+ // src/schema/table-builder.ts
8560
+ function assertColumnRecord(columns) {
8561
+ for (const [columnName, column] of Object.entries(columns)) {
8562
+ if (!isColumnBuilder(column)) {
8563
+ throw new Error(`Invalid column definition for "${columnName}"`);
8564
+ }
8565
+ }
8566
+ }
8567
+ function normalizeMappedNameInput(mappedName) {
8568
+ const normalized = mappedName.trim();
8569
+ if (!normalized) {
8570
+ throw new Error("table.from() requires a non-empty table name");
8571
+ }
8572
+ return normalized;
8573
+ }
8574
+ function normalizeSchemaNameInput(schemaName) {
8575
+ const normalized = schemaName.trim();
8576
+ if (!normalized) {
8577
+ throw new Error("table.schema() requires a non-empty schema name");
8578
+ }
8579
+ if (normalized.includes(".")) {
8580
+ throw new Error(
8581
+ 'table.schema() expects a schema name without dots. Use .schema("schema").from("table") or .from("schema.table").'
8582
+ );
8583
+ }
8584
+ return normalized;
8585
+ }
8586
+ function resolveTableTarget(logicalName, mappedName, explicitSchemaName) {
8587
+ const physicalName = (mappedName ?? logicalName).trim();
8588
+ if (!physicalName) {
8589
+ throw new Error("table() requires a non-empty name");
8590
+ }
8591
+ const firstDot = physicalName.indexOf(".");
8592
+ const lastDot = physicalName.lastIndexOf(".");
8593
+ if (firstDot > 0 && firstDot === lastDot) {
8594
+ const inlineSchema = physicalName.slice(0, firstDot).trim();
8595
+ const inlineModel = physicalName.slice(firstDot + 1).trim();
8596
+ if (!inlineSchema || !inlineModel) {
8597
+ throw new Error('table.from() schema-qualified names must look like "schema.table"');
8598
+ }
8599
+ if (explicitSchemaName && explicitSchemaName !== inlineSchema) {
8600
+ throw new Error(
8601
+ `table schema "${explicitSchemaName}" conflicts with mapped table "${physicalName}"`
8602
+ );
8603
+ }
8604
+ return {
8605
+ schema: explicitSchemaName ?? inlineSchema,
8606
+ model: inlineModel,
8607
+ qualifiedName: `${explicitSchemaName ?? inlineSchema}.${inlineModel}`
8608
+ };
8609
+ }
8610
+ if (explicitSchemaName) {
8611
+ return {
8612
+ schema: explicitSchemaName,
8613
+ model: physicalName,
8614
+ qualifiedName: `${explicitSchemaName}.${physicalName}`
8615
+ };
8616
+ }
8617
+ return {
8618
+ model: physicalName,
8619
+ qualifiedName: physicalName
8620
+ };
8621
+ }
8622
+ function toColumnMetadata(column) {
8623
+ const config = getColumnConfig(column);
8624
+ return {
8625
+ kind: config.kind,
8626
+ columnName: config.columnName,
8627
+ nullable: config.nullable,
8628
+ hasDefault: config.hasDefault,
8629
+ isGenerated: config.isGenerated,
8630
+ enumValues: config.enumValues
8631
+ };
8632
+ }
8633
+ function buildNullableMap(columns) {
8634
+ return Object.fromEntries(
8635
+ Object.entries(columns).map(([columnName, column]) => [columnName, getColumnConfig(column).nullable])
8636
+ );
8637
+ }
8638
+ function buildColumnMetadataMap(columns) {
8639
+ return Object.fromEntries(
8640
+ Object.entries(columns).map(([columnName, column]) => [columnName, toColumnMetadata(column)])
8641
+ );
8642
+ }
8643
+ function finalizeTable(name, mappedName, schemaName, columns, primaryKey) {
8644
+ const target = resolveTableTarget(name, mappedName, schemaName);
8645
+ const model = defineModel({
8646
+ meta: {
8647
+ schema: target.schema,
8648
+ model: target.model,
8649
+ primaryKey: [...primaryKey],
8650
+ nullable: buildNullableMap(columns),
8651
+ columns: buildColumnMetadataMap(columns)
8652
+ }
8653
+ });
8654
+ const schemas = buildTableSchemaBundle(model, columns);
8655
+ return Object.assign(model, {
8656
+ kind: "table",
8657
+ name,
8658
+ mappedName,
8659
+ schemaName: target.schema,
8660
+ tableName: target.model,
8661
+ qualifiedName: target.qualifiedName,
8662
+ columns,
8663
+ schemas
8664
+ });
8665
+ }
8666
+ function createColumnsBuilder(name, mappedName, schemaName, columns) {
8667
+ assertColumnRecord(columns);
8668
+ return {
8669
+ name,
8670
+ mappedName,
8671
+ schemaName,
8672
+ columns,
8673
+ from(tableName) {
8674
+ const normalizedTableName = normalizeMappedNameInput(tableName);
8675
+ resolveTableTarget(name, normalizedTableName, schemaName);
8676
+ return createColumnsBuilder(name, normalizedTableName, schemaName, columns);
8677
+ },
8678
+ schema(nextSchemaName) {
8679
+ const normalizedSchemaName = normalizeSchemaNameInput(nextSchemaName);
8680
+ resolveTableTarget(name, mappedName, normalizedSchemaName);
8681
+ return createColumnsBuilder(name, mappedName, normalizedSchemaName, columns);
8682
+ },
8683
+ primaryKey(...keys) {
8684
+ return finalizeTable(name, mappedName, schemaName, columns, keys);
8685
+ }
8686
+ };
8687
+ }
8688
+ function createTableBuilder2(name, mappedName, schemaName) {
8689
+ return {
8690
+ name,
8691
+ mappedName,
8692
+ schemaName,
8693
+ from(tableName) {
8694
+ const normalizedTableName = normalizeMappedNameInput(tableName);
8695
+ resolveTableTarget(name, normalizedTableName, schemaName);
8696
+ return createTableBuilder2(name, normalizedTableName, schemaName);
8697
+ },
8698
+ schema(nextSchemaName) {
8699
+ const normalizedSchemaName = normalizeSchemaNameInput(nextSchemaName);
8700
+ resolveTableTarget(name, mappedName, normalizedSchemaName);
8701
+ return createTableBuilder2(name, mappedName, normalizedSchemaName);
8702
+ },
8703
+ columns(columns) {
8704
+ return createColumnsBuilder(name, mappedName, schemaName, columns);
8705
+ }
8706
+ };
8707
+ }
8708
+ function table(name) {
8709
+ if (!name.trim()) {
8710
+ throw new Error("table() requires a non-empty name");
8711
+ }
8712
+ return createTableBuilder2(name, void 0, void 0);
8713
+ }
8714
+
7165
8715
  // src/schema/typed-client.ts
7166
8716
  var TenantHeaderMapper = class {
7167
8717
  constructor(tenantKeyMap) {
@@ -7201,12 +8751,10 @@ var RegistryNavigator = class {
7201
8751
  return modelDef;
7202
8752
  }
7203
8753
  resolveTableName(schema, model, modelDef) {
7204
- if (modelDef.meta.tableName) {
7205
- return modelDef.meta.tableName;
7206
- }
7207
- const schemaName = modelDef.meta.schema ?? schema;
7208
- const modelName = modelDef.meta.model ?? model;
7209
- return `${schemaName}.${modelName}`;
8754
+ return resolveAthenaModelTargetTableName(modelDef, {
8755
+ fallbackSchema: schema,
8756
+ fallbackModel: model
8757
+ });
7210
8758
  }
7211
8759
  };
7212
8760
  var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
@@ -7233,17 +8781,20 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
7233
8781
  this.clientOptions = {
7234
8782
  backend: input.options?.backend,
7235
8783
  client: input.options?.client,
7236
- headers: input.options?.headers
8784
+ headers: input.options?.headers,
8785
+ experimental: input.options?.experimental
7237
8786
  };
7238
8787
  this.baseClient = createClient(this.url, this.apiKey, {
7239
8788
  backend: this.clientOptions.backend,
7240
8789
  client: this.clientOptions.client,
7241
- headers: this.tenantHeaderMapper.apply(this.clientOptions.headers, tenantContext)
8790
+ headers: this.tenantHeaderMapper.apply(this.clientOptions.headers, tenantContext),
8791
+ experimental: this.clientOptions.experimental
7242
8792
  });
7243
8793
  this.db = this.baseClient.db;
7244
8794
  }
7245
- from(table, options) {
7246
- return this.baseClient.from(table, options);
8795
+ from(tableOrModel, options) {
8796
+ const from = this.baseClient.from;
8797
+ return from(tableOrModel, options);
7247
8798
  }
7248
8799
  rpc(fn, args, options) {
7249
8800
  return this.baseClient.rpc(fn, args, options);
@@ -7265,7 +8816,8 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
7265
8816
  tenantContext: {
7266
8817
  ...this.tenantContext,
7267
8818
  ...context ?? {}
7268
- }
8819
+ },
8820
+ experimental: this.clientOptions.experimental
7269
8821
  }
7270
8822
  });
7271
8823
  }
@@ -7284,67 +8836,6 @@ function createTypedClient(registry, url, apiKey, options) {
7284
8836
  });
7285
8837
  }
7286
8838
 
7287
- // src/schema/model-form.ts
7288
- function resolveNullishValue(mode) {
7289
- if (mode === "undefined") return void 0;
7290
- if (mode === "null") return null;
7291
- return "";
7292
- }
7293
- function isRecord10(value) {
7294
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7295
- }
7296
- function isNullableColumn(model, key) {
7297
- const nullable = model.meta.nullable;
7298
- return nullable?.[key] === true;
7299
- }
7300
- function toModelFormDefaults(model, values, options) {
7301
- const source = values;
7302
- if (!isRecord10(source)) {
7303
- return {};
7304
- }
7305
- const mode = options?.nullishMode ?? "empty-string";
7306
- const nullishValue = resolveNullishValue(mode);
7307
- const result = {};
7308
- for (const [key, value] of Object.entries(source)) {
7309
- if (value === null && isNullableColumn(model, key)) {
7310
- result[key] = nullishValue;
7311
- continue;
7312
- }
7313
- result[key] = value;
7314
- }
7315
- return result;
7316
- }
7317
- function toModelPayload(model, formValues, options) {
7318
- const emptyStringAsNull = options?.emptyStringAsNull ?? true;
7319
- const stripUndefined = options?.stripUndefined ?? true;
7320
- const result = {};
7321
- for (const [key, rawValue] of Object.entries(formValues)) {
7322
- if (rawValue === void 0 && stripUndefined) {
7323
- continue;
7324
- }
7325
- if (emptyStringAsNull && rawValue === "" && isNullableColumn(model, key)) {
7326
- result[key] = null;
7327
- continue;
7328
- }
7329
- result[key] = rawValue;
7330
- }
7331
- return result;
7332
- }
7333
- function createModelFormAdapter(model) {
7334
- return {
7335
- model,
7336
- toDefaults(values, options) {
7337
- return toModelFormDefaults(model, values, options);
7338
- },
7339
- toInsert(values, options) {
7340
- return toModelPayload(model, values, options);
7341
- },
7342
- toUpdate(values, options) {
7343
- return toModelPayload(model, values, options);
7344
- }
7345
- };
7346
- }
7347
-
7348
8839
  // src/generator/schema-selection.ts
7349
8840
  var DEFAULT_POSTGRES_SCHEMAS = ["public"];
7350
8841
  function collectSchemaNames(input) {
@@ -8032,6 +9523,6 @@ async function runSchemaGenerator(options = {}) {
8032
9523
  return throwBrowserUnsupported("runSchemaGenerator");
8033
9524
  }
8034
9525
 
8035
- export { ATHENA_AUTH_BASE_ERROR_CODES, AthenaClient, AthenaError, AthenaErrorCategory, AthenaErrorCode, AthenaErrorKind, AthenaGatewayError, AthenaStorageError, AthenaStorageErrorCode, Backend, DEFAULT_POSTGRES_SCHEMAS, assertInt, athenaAuth, coerceInt, createAthenaStorageError, createAuthClient, createAuthReactEmailInput, createClient, createModelFormAdapter, createPostgresIntrospectionProvider, createTypedClient, defineAthenaAuthConfig, defineAuthEmailTemplate, defineDatabase, defineGeneratorConfig, defineModel, defineRegistry, defineSchema, findGeneratorConfigPath, generateArtifactsFromSnapshot, generatorEnv, identifier, isAthenaGatewayError, isOk, loadGeneratorConfig, normalizeAthenaError, normalizeAthenaGatewayBaseUrl, normalizeGeneratorConfig, normalizeSchemaSelection, parseBooleanFlag2 as parseBooleanFlag, renderAthenaReactEmail, requireAffected, requireSuccess, resolveGeneratorProvider, resolvePostgresColumnType, resolveProviderSchemas, runSchemaGenerator, storageSdkManifest, toModelFormDefaults, toModelPayload, unwrap, unwrapOne, unwrapRows, verifyAthenaGatewayUrl, withRetry };
9526
+ export { ATHENA_AUTH_BASE_ERROR_CODES, AthenaClient, AthenaError, AthenaErrorCategory, AthenaErrorCode, AthenaErrorKind, AthenaGatewayError, AthenaStorageError, AthenaStorageErrorCode, Backend, DEFAULT_POSTGRES_SCHEMAS, assertInt, athenaAuth, boolean, coerceInt, createAthenaStorageError, createAuthClient, createAuthReactEmailInput, createClient, createModelFormAdapter, createPostgresIntrospectionProvider, createTypedClient, defineAthenaAuthConfig, defineAuthEmailTemplate, defineDatabase, defineGeneratorConfig, defineModel, defineRegistry, defineSchema, enumeration, findGeneratorConfigPath, generateArtifactsFromSnapshot, generatorEnv, getAthenaDebugAst, identifier, isAthenaGatewayError, isOk, json, loadGeneratorConfig, normalizeAthenaError, normalizeAthenaGatewayBaseUrl, normalizeGeneratorConfig, normalizeSchemaSelection, number, parseBooleanFlag2 as parseBooleanFlag, renderAthenaReactEmail, requireAffected, requireSuccess, resolveGeneratorProvider, resolvePostgresColumnType, resolveProviderSchemas, runSchemaGenerator, storageSdkManifest, string, table, toModelFormDefaults, toModelPayload, unwrap, unwrapOne, unwrapRows, verifyAthenaGatewayUrl, withRetry };
8036
9527
  //# sourceMappingURL=browser.js.map
8037
9528
  //# sourceMappingURL=browser.js.map