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