@xylex-group/athena 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +165 -68
  2. package/dist/browser.cjs +1331 -70
  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 +1325 -71
  7. package/dist/browser.js.map +1 -1
  8. package/dist/cli/index.cjs +1354 -117
  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 +1354 -117
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/{model-form-DMed05gE.d.cts → client-CfAE_QOj.d.cts} +741 -132
  15. package/dist/{model-form-DXPlOnlI.d.ts → client-D6EIJdQS.d.ts} +741 -132
  16. package/dist/index.cjs +1391 -71
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +8 -7
  19. package/dist/index.d.ts +8 -7
  20. package/dist/index.js +1385 -72
  21. package/dist/index.js.map +1 -1
  22. package/dist/model-form-ByvyyvxB.d.ts +96 -0
  23. package/dist/model-form-DACdBLYG.d.cts +96 -0
  24. package/dist/next/client.cjs +7875 -0
  25. package/dist/next/client.cjs.map +1 -0
  26. package/dist/next/client.d.cts +25 -0
  27. package/dist/next/client.d.ts +25 -0
  28. package/dist/next/client.js +7873 -0
  29. package/dist/next/client.js.map +1 -0
  30. package/dist/next/server.cjs +7993 -0
  31. package/dist/next/server.cjs.map +1 -0
  32. package/dist/next/server.d.cts +52 -0
  33. package/dist/next/server.d.ts +52 -0
  34. package/dist/next/server.js +7990 -0
  35. package/dist/next/server.js.map +1 -0
  36. package/dist/{pipeline-D4sJRKqN.d.cts → pipeline-CmUZsXsi.d.cts} +1 -1
  37. package/dist/{pipeline-CkMnhwPI.d.ts → pipeline-DZMsPxUg.d.ts} +1 -1
  38. package/dist/{react-email-DZhDDlEl.d.cts → react-email-BvJ3fj_F.d.cts} +35 -7
  39. package/dist/{react-email-Lrz9A-BW.d.ts → react-email-PLAJuZuO.d.ts} +35 -7
  40. package/dist/react.cjs +30 -1
  41. package/dist/react.cjs.map +1 -1
  42. package/dist/react.d.cts +39 -10
  43. package/dist/react.d.ts +39 -10
  44. package/dist/react.js +30 -2
  45. package/dist/react.js.map +1 -1
  46. package/dist/shared-BW6hoLBY.d.cts +33 -0
  47. package/dist/shared-BiJvoURI.d.ts +33 -0
  48. package/dist/{types-vikz9YIO.d.cts → types-BeZIHduP.d.cts} +5 -1
  49. package/dist/{types-vikz9YIO.d.ts → types-BeZIHduP.d.ts} +5 -1
  50. package/dist/{types-CAtTGGoz.d.cts → types-C-YvfgYh.d.cts} +27 -2
  51. package/dist/{types-BzY6fETM.d.ts → types-CRjDwmtJ.d.ts} +27 -2
  52. package/package.json +37 -49
package/dist/browser.cjs CHANGED
@@ -802,7 +802,7 @@ var getCookieCache = async (request, config) => {
802
802
 
803
803
  // package.json
804
804
  var package_default = {
805
- version: "2.8.0"
805
+ version: "2.9.0"
806
806
  };
807
807
 
808
808
  // src/sdk-version.ts
@@ -815,6 +815,7 @@ function buildSdkHeaderValue(sdkName) {
815
815
  var DEFAULT_CLIENT = "railway_direct";
816
816
  var SDK_NAME = "xylex-group/athena";
817
817
  var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
818
+ var NO_CACHE_HEADER_VALUE = "no-cache";
818
819
  function parseResponseBody(rawText, contentType) {
819
820
  if (!rawText) {
820
821
  return { parsed: null, parseFailed: false };
@@ -833,6 +834,9 @@ function parseResponseBody(rawText, contentType) {
833
834
  function normalizeHeaderValue(value) {
834
835
  return value ? value : void 0;
835
836
  }
837
+ function isCacheControlHeaderName(name) {
838
+ return name.toLowerCase() === "cache-control";
839
+ }
836
840
  function resolveHeaderValue(headers, candidates) {
837
841
  for (const candidate of candidates) {
838
842
  const direct = normalizeHeaderValue(headers[candidate]);
@@ -991,6 +995,7 @@ function buildRpcGetEndpoint(payload) {
991
995
  }
992
996
  function buildHeaders(config, options) {
993
997
  const mergedStripNulls = options?.stripNulls ?? true;
998
+ const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
994
999
  const extraHeaders = {
995
1000
  ...config.headers ?? {},
996
1001
  ...options?.headers ?? {}
@@ -1044,11 +1049,15 @@ function buildHeaders(config, options) {
1044
1049
  const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
1045
1050
  Object.entries(extraHeaders).forEach(([key, value]) => {
1046
1051
  if (athenaClientKeys.includes(key)) return;
1052
+ if (forceNoCache && isCacheControlHeaderName(key)) return;
1047
1053
  const normalized = normalizeHeaderValue(value);
1048
1054
  if (normalized) {
1049
1055
  headers[key] = normalized;
1050
1056
  }
1051
1057
  });
1058
+ if (forceNoCache) {
1059
+ headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
1060
+ }
1052
1061
  return headers;
1053
1062
  }
1054
1063
  function toInvalidUrlResponse(error, endpoint, method) {
@@ -1509,6 +1518,45 @@ function identifier(...segments) {
1509
1518
  return new SqlIdentifierPath(expandedSegments);
1510
1519
  }
1511
1520
 
1521
+ // src/auth/limits.ts
1522
+ var ATHENA_AUTH_MAX_ADMIN_JSON_BYTES = 32 * 1024;
1523
+ var ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH = 8;
1524
+ var ATHENA_AUTH_MAX_TEMPLATE_VARIABLES = 64;
1525
+ var ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH = 128;
1526
+ var ATHENA_AUTH_ADMIN_LIMITS = {
1527
+ maxAdminJsonBytes: ATHENA_AUTH_MAX_ADMIN_JSON_BYTES,
1528
+ maxAdminJsonDepth: ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH,
1529
+ maxTemplateVariables: ATHENA_AUTH_MAX_TEMPLATE_VARIABLES,
1530
+ maxTemplateVariableLength: ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH
1531
+ };
1532
+ function describeTemplateVariableTarget(target) {
1533
+ const normalized = target?.trim();
1534
+ return normalized && normalized.length > 0 ? normalized : "Athena auth admin email template variables";
1535
+ }
1536
+ function assertAthenaAuthTemplateVariables(variables, target) {
1537
+ const label = describeTemplateVariableTarget(target);
1538
+ if (!Array.isArray(variables)) {
1539
+ throw new Error(`${label} must be an array of strings.`);
1540
+ }
1541
+ if (variables.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLES) {
1542
+ throw new Error(
1543
+ `${label} cannot contain more than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLES} entries.`
1544
+ );
1545
+ }
1546
+ variables.forEach((variable, index) => {
1547
+ if (typeof variable !== "string") {
1548
+ throw new Error(
1549
+ `${label} must contain only strings. Received ${typeof variable} at index ${index}.`
1550
+ );
1551
+ }
1552
+ if (variable.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH) {
1553
+ throw new Error(
1554
+ `${label} cannot contain entries longer than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH} characters. Received ${variable.length} characters at index ${index}.`
1555
+ );
1556
+ }
1557
+ });
1558
+ }
1559
+
1512
1560
  // src/auth/react-email.ts
1513
1561
  var reactEmailRenderModulePromise;
1514
1562
  function isRecord2(value) {
@@ -1738,6 +1786,7 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
1738
1786
  var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
1739
1787
  var SDK_NAME2 = "xylex-group/athena-auth";
1740
1788
  var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
1789
+ var NO_CACHE_HEADER_VALUE2 = "no-cache";
1741
1790
  function normalizeBaseUrl(baseUrl) {
1742
1791
  return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
1743
1792
  }
@@ -1747,6 +1796,9 @@ function isRecord3(value) {
1747
1796
  function normalizeHeaderValue2(value) {
1748
1797
  return value ? value : void 0;
1749
1798
  }
1799
+ function isCacheControlHeaderName2(name) {
1800
+ return name.toLowerCase() === "cache-control";
1801
+ }
1750
1802
  function parseResponseBody2(rawText, contentType) {
1751
1803
  if (!rawText) {
1752
1804
  return { parsed: null, parseFailed: false };
@@ -1802,6 +1854,54 @@ function mergeCallOptions(base, override) {
1802
1854
  }
1803
1855
  };
1804
1856
  }
1857
+ function toSessionGuardFailure(sessionResult) {
1858
+ if (sessionResult.status === 401 || sessionResult.data == null) {
1859
+ return {
1860
+ ok: false,
1861
+ reason: "unauthorized",
1862
+ status: 401,
1863
+ error: sessionResult.error ?? "Unauthorized",
1864
+ sessionResult
1865
+ };
1866
+ }
1867
+ return {
1868
+ ok: false,
1869
+ reason: "upstream_error",
1870
+ status: sessionResult.status,
1871
+ error: sessionResult.error ?? "Failed to resolve current session",
1872
+ sessionResult
1873
+ };
1874
+ }
1875
+ function toPermissionGuardFailure(permissionResult, sessionResult) {
1876
+ if (permissionResult.status === 401) {
1877
+ return {
1878
+ ok: false,
1879
+ reason: "unauthorized",
1880
+ status: 401,
1881
+ error: permissionResult.error ?? "Unauthorized",
1882
+ sessionResult,
1883
+ permissionResult
1884
+ };
1885
+ }
1886
+ if (permissionResult.status === 403) {
1887
+ return {
1888
+ ok: false,
1889
+ reason: "forbidden",
1890
+ status: 403,
1891
+ error: permissionResult.error ?? "Forbidden",
1892
+ sessionResult,
1893
+ permissionResult
1894
+ };
1895
+ }
1896
+ return {
1897
+ ok: false,
1898
+ reason: "upstream_error",
1899
+ status: permissionResult.status,
1900
+ error: permissionResult.error ?? "Failed to resolve permission check",
1901
+ sessionResult,
1902
+ permissionResult
1903
+ };
1904
+ }
1805
1905
  function extractFetchOptions(input) {
1806
1906
  if (!input) {
1807
1907
  return {
@@ -1817,6 +1917,7 @@ function extractFetchOptions(input) {
1817
1917
  };
1818
1918
  }
1819
1919
  function buildHeaders2(config, options) {
1920
+ const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
1820
1921
  const headers = {
1821
1922
  "Content-Type": "application/json",
1822
1923
  "X-Athena-Sdk": SDK_HEADER_VALUE2
@@ -1830,16 +1931,30 @@ function buildHeaders2(config, options) {
1830
1931
  if (bearerToken) {
1831
1932
  headers.Authorization = `Bearer ${bearerToken}`;
1832
1933
  }
1934
+ const cookie = options?.cookie ?? config.cookie;
1935
+ if (cookie) {
1936
+ headers.Cookie = cookie;
1937
+ }
1938
+ const sessionToken = options?.sessionToken ?? config.sessionToken;
1939
+ if (sessionToken) {
1940
+ headers["X-Athena-Auth-Session-Token"] = sessionToken;
1941
+ }
1833
1942
  const mergedExtraHeaders = {
1834
1943
  ...config.headers ?? {},
1835
1944
  ...options?.headers ?? {}
1836
1945
  };
1837
1946
  Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
1947
+ if (forceNoCache && isCacheControlHeaderName2(key)) {
1948
+ return;
1949
+ }
1838
1950
  const normalized = normalizeHeaderValue2(value);
1839
1951
  if (normalized) {
1840
1952
  headers[key] = normalized;
1841
1953
  }
1842
1954
  });
1955
+ if (forceNoCache) {
1956
+ headers["Cache-Control"] = NO_CACHE_HEADER_VALUE2;
1957
+ }
1843
1958
  return headers;
1844
1959
  }
1845
1960
  function appendQueryParam(searchParams, key, value) {
@@ -2104,7 +2219,91 @@ function createAuthClient(config = {}) {
2104
2219
  htmlField: "htmlTemplate",
2105
2220
  textField: "textTemplate",
2106
2221
  variablesField: "variables"
2107
- }, withReactEmailRoute(route));
2222
+ }, withReactEmailRoute(route)).then((payload) => {
2223
+ if ("variables" in payload && payload.variables !== void 0 && payload.variables !== null) {
2224
+ assertAthenaAuthTemplateVariables(
2225
+ payload.variables,
2226
+ `${route} variables`
2227
+ );
2228
+ }
2229
+ return payload;
2230
+ });
2231
+ const requireSession = async (input, options) => {
2232
+ const sessionInput = input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0;
2233
+ const sessionResult = await getGeneric(
2234
+ "/get-session",
2235
+ sessionInput,
2236
+ options
2237
+ );
2238
+ if (!sessionResult.ok || sessionResult.data == null) {
2239
+ return toSessionGuardFailure(sessionResult);
2240
+ }
2241
+ return {
2242
+ ok: true,
2243
+ session: sessionResult.data
2244
+ };
2245
+ };
2246
+ const getUser = async (input, options) => {
2247
+ const sessionResult = await getGeneric(
2248
+ "/get-session",
2249
+ input,
2250
+ options
2251
+ );
2252
+ if (!sessionResult.ok) {
2253
+ return {
2254
+ ...sessionResult,
2255
+ data: null
2256
+ };
2257
+ }
2258
+ return {
2259
+ ...sessionResult,
2260
+ data: {
2261
+ user: sessionResult.data?.user ?? null
2262
+ }
2263
+ };
2264
+ };
2265
+ const requirePermission = async (endpoint, input, options) => {
2266
+ const sessionGuard = await requireSession(
2267
+ input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0,
2268
+ options
2269
+ );
2270
+ if (!sessionGuard.ok) {
2271
+ return sessionGuard;
2272
+ }
2273
+ const permissionResult = await postGeneric(
2274
+ endpoint,
2275
+ input,
2276
+ options
2277
+ );
2278
+ if (!permissionResult.ok) {
2279
+ return toPermissionGuardFailure(permissionResult, {
2280
+ ok: true,
2281
+ status: 200,
2282
+ data: sessionGuard.session,
2283
+ error: null,
2284
+ errorDetails: null,
2285
+ raw: sessionGuard.session
2286
+ });
2287
+ }
2288
+ if (!permissionResult.data?.success) {
2289
+ return {
2290
+ ok: false,
2291
+ reason: "forbidden",
2292
+ status: 403,
2293
+ error: permissionResult.data?.error ?? "Forbidden",
2294
+ sessionResult: {
2295
+ ok: true,
2296
+ status: 200,
2297
+ data: sessionGuard.session,
2298
+ error: null,
2299
+ errorDetails: null,
2300
+ raw: sessionGuard.session
2301
+ },
2302
+ permissionResult
2303
+ };
2304
+ }
2305
+ return sessionGuard;
2306
+ };
2108
2307
  const listUserEmailsWithFallback = async (input, options) => {
2109
2308
  const primary = await getWithQuery(
2110
2309
  "/email/list",
@@ -2266,6 +2465,7 @@ function createAuthClient(config = {}) {
2266
2465
  input,
2267
2466
  options
2268
2467
  ),
2468
+ requirePermission: (input, options) => requirePermission("/organization/has-permission", input, options),
2269
2469
  invitation: {
2270
2470
  cancel: (input, options) => executePostWithCompatibleInput(
2271
2471
  resolvedConfig,
@@ -2461,6 +2661,8 @@ function createAuthClient(config = {}) {
2461
2661
  };
2462
2662
  const auth = {
2463
2663
  getSession: (input, options) => getGeneric("/get-session", input, options),
2664
+ getUser,
2665
+ requireSession,
2464
2666
  signOut,
2465
2667
  forgetPassword: (input, options) => postGeneric("/forget-password", input, options),
2466
2668
  resetPassword: authResetPassword,
@@ -2555,6 +2757,7 @@ function createAuthClient(config = {}) {
2555
2757
  }
2556
2758
  },
2557
2759
  hasPermission: (input, options) => postGeneric("/admin/has-permission", input, options),
2760
+ requirePermission: (input, options) => requirePermission("/admin/has-permission", input, options),
2558
2761
  apiKey: {
2559
2762
  create: (input, options) => postGeneric("/admin/api-key/create", input, options)
2560
2763
  },
@@ -2706,6 +2909,8 @@ function createAuthClient(config = {}) {
2706
2909
  input,
2707
2910
  options
2708
2911
  ),
2912
+ getUser,
2913
+ requireSession,
2709
2914
  listSessions: (input, options) => executeGetWithCompatibleInput(
2710
2915
  resolvedConfig,
2711
2916
  { endpoint: "/list-sessions", method: "GET" },
@@ -3398,7 +3603,12 @@ function createStorageFileModule(base, config = {}) {
3398
3603
  content_type: input.content_type ?? source.contentType,
3399
3604
  size_bytes: source.sizeBytes,
3400
3605
  public: input.public,
3401
- metadata: input.metadata
3606
+ metadata: input.metadata,
3607
+ server_side_encryption: input.server_side_encryption,
3608
+ sse: input.sse,
3609
+ ssekms_key_id: input.ssekms_key_id,
3610
+ kms_key_id: input.kms_key_id,
3611
+ bucket_key_enabled: input.bucket_key_enabled
3402
3612
  }
3403
3613
  };
3404
3614
  });
@@ -3409,10 +3619,17 @@ function createStorageFileModule(base, config = {}) {
3409
3619
  for (let index = 0; index < uploadRequests.length; index += 1) {
3410
3620
  const request = uploadRequests[index];
3411
3621
  const uploadUrl = uploadUrls[index];
3412
- const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
3413
- aggregateLoaded[index] = progress.loaded;
3414
- input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3415
- });
3622
+ const response = await putUploadBody(
3623
+ uploadUrl.upload.url,
3624
+ uploadUrl.upload.headers ?? {},
3625
+ request.source,
3626
+ input,
3627
+ options,
3628
+ (progress) => {
3629
+ aggregateLoaded[index] = progress.loaded;
3630
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3631
+ }
3632
+ );
3416
3633
  uploaded.push({
3417
3634
  file: uploadUrl.file,
3418
3635
  upload: uploadUrl.upload,
@@ -3515,8 +3732,9 @@ function validateUploadConstraints(sources, input) {
3515
3732
  }
3516
3733
  }
3517
3734
  }
3518
- async function putUploadBody(url, source, input, options, onProgress) {
3519
- const headers = new Headers(input.uploadHeaders);
3735
+ async function putUploadBody(url, uploadHeaders, source, input, options, onProgress) {
3736
+ const headers = new Headers(uploadHeaders);
3737
+ new Headers(input.uploadHeaders).forEach((value, key) => headers.set(key, value));
3520
3738
  if (source.contentType && !headers.has("Content-Type")) {
3521
3739
  headers.set("Content-Type", source.contentType);
3522
3740
  }
@@ -3803,59 +4021,554 @@ var storageSdkManifest = {
3803
4021
  pathParams: ["file_id"],
3804
4022
  queryParams: ["purpose"],
3805
4023
  responseEnvelope: "athena",
3806
- responseType: "PresignedFileUrlResponse"
4024
+ responseType: "PresignedFileUrlResponse"
4025
+ },
4026
+ {
4027
+ name: "getStorageFileProxy",
4028
+ method: "GET",
4029
+ path: "/storage/files/{file_id}/proxy",
4030
+ pathParams: ["file_id"],
4031
+ queryParams: ["purpose"],
4032
+ responseEnvelope: "raw",
4033
+ responseType: "Response",
4034
+ binary: true
4035
+ },
4036
+ {
4037
+ name: "updateStorageFile",
4038
+ method: "PATCH",
4039
+ path: "/storage/files/{file_id}",
4040
+ pathParams: ["file_id"],
4041
+ requestType: "UpdateStorageFileRequest",
4042
+ responseEnvelope: "athena",
4043
+ responseType: "StorageFileMutationResponse"
4044
+ },
4045
+ {
4046
+ name: "deleteStorageFile",
4047
+ method: "DELETE",
4048
+ path: "/storage/files/{file_id}",
4049
+ pathParams: ["file_id"],
4050
+ responseEnvelope: "athena",
4051
+ responseType: "StorageFileMutationResponse"
4052
+ },
4053
+ {
4054
+ name: "setStorageFileVisibility",
4055
+ method: "PATCH",
4056
+ path: "/storage/files/{file_id}/visibility",
4057
+ pathParams: ["file_id"],
4058
+ requestType: "SetStorageFileVisibilityRequest",
4059
+ responseEnvelope: "athena",
4060
+ responseType: "StorageFileMutationResponse"
4061
+ },
4062
+ {
4063
+ name: "postStorageFileVisibility",
4064
+ method: "POST",
4065
+ path: "/storage/files/{file_id}/visibility",
4066
+ pathParams: ["file_id"],
4067
+ requestType: "SetStorageFileVisibilityRequest",
4068
+ responseEnvelope: "athena",
4069
+ responseType: "StorageFileMutationResponse"
4070
+ },
4071
+ {
4072
+ name: "setManyStorageFileVisibility",
4073
+ method: "POST",
4074
+ path: "/storage/files/visibility-many",
4075
+ requestType: "SetManyStorageFileVisibilityRequest",
4076
+ responseEnvelope: "athena",
4077
+ responseType: "StorageFileMutationManyResponse"
4078
+ },
4079
+ {
4080
+ name: "deleteStorageFolder",
4081
+ method: "POST",
4082
+ path: "/storage/folders/delete",
4083
+ requestType: "DeleteStorageFolderRequest",
4084
+ responseEnvelope: "athena",
4085
+ responseType: "StorageFolderMutationResponse"
4086
+ },
4087
+ {
4088
+ name: "moveStorageFolder",
4089
+ method: "POST",
4090
+ path: "/storage/folders/move",
4091
+ requestType: "MoveStorageFolderRequest",
4092
+ responseEnvelope: "athena",
4093
+ responseType: "StorageFolderMutationResponse"
4094
+ },
4095
+ {
4096
+ name: "searchStorageFiles",
4097
+ method: "POST",
4098
+ path: "/storage/files/search",
4099
+ requestType: "SearchStorageFilesRequest",
4100
+ responseEnvelope: "athena",
4101
+ responseType: "StorageListFilesResponse"
4102
+ },
4103
+ {
4104
+ name: "confirmStorageUpload",
4105
+ method: "POST",
4106
+ path: "/storage/files/{file_id}/confirm-upload",
4107
+ pathParams: ["file_id"],
4108
+ requestType: "ConfirmStorageUploadRequest",
4109
+ responseEnvelope: "athena",
4110
+ responseType: "StorageFileMutationResponse"
4111
+ },
4112
+ {
4113
+ name: "uploadStorageFileBinary",
4114
+ method: "PUT",
4115
+ path: "/storage/files/{file_id}/upload",
4116
+ pathParams: ["file_id"],
4117
+ responseEnvelope: "athena",
4118
+ responseType: "StorageFileMutationResponse",
4119
+ binary: true
4120
+ },
4121
+ {
4122
+ name: "copyStorageFile",
4123
+ method: "POST",
4124
+ path: "/storage/files/{file_id}/copy",
4125
+ pathParams: ["file_id"],
4126
+ requestType: "CopyStorageFileRequest",
4127
+ responseEnvelope: "athena",
4128
+ responseType: "StorageFileMutationResponse"
4129
+ },
4130
+ {
4131
+ name: "deleteManyStorageFiles",
4132
+ method: "POST",
4133
+ path: "/storage/files/delete-many",
4134
+ requestType: "DeleteManyStorageFilesRequest",
4135
+ responseEnvelope: "athena",
4136
+ responseType: "StorageFileMutationManyResponse"
4137
+ },
4138
+ {
4139
+ name: "updateManyStorageFiles",
4140
+ method: "POST",
4141
+ path: "/storage/files/update-many",
4142
+ requestType: "UpdateManyStorageFilesRequest",
4143
+ responseEnvelope: "athena",
4144
+ responseType: "StorageFileMutationManyResponse"
4145
+ },
4146
+ {
4147
+ name: "restoreStorageFile",
4148
+ method: "POST",
4149
+ path: "/storage/files/{file_id}/restore",
4150
+ pathParams: ["file_id"],
4151
+ responseEnvelope: "athena",
4152
+ responseType: "StorageFileMutationResponse"
4153
+ },
4154
+ {
4155
+ name: "purgeStorageFile",
4156
+ method: "DELETE",
4157
+ path: "/storage/files/{file_id}/purge",
4158
+ pathParams: ["file_id"],
4159
+ responseEnvelope: "athena",
4160
+ responseType: "StorageFileMutationResponse"
4161
+ },
4162
+ {
4163
+ name: "getStorageFilePublicUrl",
4164
+ method: "GET",
4165
+ path: "/storage/files/{file_id}/public-url",
4166
+ pathParams: ["file_id"],
4167
+ responseEnvelope: "athena",
4168
+ responseType: "Record<string, unknown>"
4169
+ },
4170
+ {
4171
+ name: "getStorageFileProxyUrl",
4172
+ method: "GET",
4173
+ path: "/storage/files/{file_id}/proxy-url",
4174
+ pathParams: ["file_id"],
4175
+ queryParams: ["purpose"],
4176
+ responseEnvelope: "athena",
4177
+ responseType: "Record<string, unknown>"
4178
+ },
4179
+ {
4180
+ name: "listStorageFileVersions",
4181
+ method: "GET",
4182
+ path: "/storage/files/{file_id}/versions",
4183
+ pathParams: ["file_id"],
4184
+ responseEnvelope: "athena",
4185
+ responseType: "Record<string, unknown>"
4186
+ },
4187
+ {
4188
+ name: "restoreStorageFileVersion",
4189
+ method: "POST",
4190
+ path: "/storage/files/{file_id}/versions/{version_id}/restore",
4191
+ pathParams: ["file_id", "version_id"],
4192
+ responseEnvelope: "athena",
4193
+ responseType: "Record<string, unknown>"
4194
+ },
4195
+ {
4196
+ name: "deleteStorageFileVersion",
4197
+ method: "DELETE",
4198
+ path: "/storage/files/{file_id}/versions/{version_id}",
4199
+ pathParams: ["file_id", "version_id"],
4200
+ responseEnvelope: "athena",
4201
+ responseType: "Record<string, unknown>"
4202
+ },
4203
+ {
4204
+ name: "getStorageFileRetention",
4205
+ method: "GET",
4206
+ path: "/storage/files/{file_id}/retention",
4207
+ pathParams: ["file_id"],
4208
+ queryParams: ["version_id"],
4209
+ responseEnvelope: "athena",
4210
+ responseType: "Record<string, unknown>"
4211
+ },
4212
+ {
4213
+ name: "setStorageFileRetention",
4214
+ method: "POST",
4215
+ path: "/storage/files/{file_id}/retention",
4216
+ pathParams: ["file_id"],
4217
+ requestType: "StorageFileRetentionRequest",
4218
+ responseEnvelope: "athena",
4219
+ responseType: "Record<string, unknown>"
4220
+ },
4221
+ {
4222
+ name: "listStorageFolders",
4223
+ method: "POST",
4224
+ path: "/storage/folders/list",
4225
+ requestType: "ListStorageFoldersRequest",
4226
+ responseEnvelope: "athena",
4227
+ responseType: "Record<string, unknown>"
4228
+ },
4229
+ {
4230
+ name: "treeStorageFolders",
4231
+ method: "POST",
4232
+ path: "/storage/folders/tree",
4233
+ requestType: "TreeStorageFoldersRequest",
4234
+ responseEnvelope: "athena",
4235
+ responseType: "Record<string, unknown>"
4236
+ },
4237
+ {
4238
+ name: "listStoragePermissions",
4239
+ method: "POST",
4240
+ path: "/storage/permissions/list",
4241
+ requestType: "StoragePermissionListRequest",
4242
+ responseEnvelope: "athena",
4243
+ responseType: "StoragePermissionListResponse"
4244
+ },
4245
+ {
4246
+ name: "grantStoragePermission",
4247
+ method: "POST",
4248
+ path: "/storage/permissions/grant",
4249
+ requestType: "StoragePermissionGrantRequest",
4250
+ responseEnvelope: "athena",
4251
+ responseType: "Record<string, unknown>"
4252
+ },
4253
+ {
4254
+ name: "revokeStoragePermission",
4255
+ method: "POST",
4256
+ path: "/storage/permissions/revoke",
4257
+ requestType: "StoragePermissionRevokeRequest",
4258
+ responseEnvelope: "athena",
4259
+ responseType: "Record<string, unknown>"
4260
+ },
4261
+ {
4262
+ name: "checkStoragePermission",
4263
+ method: "POST",
4264
+ path: "/storage/permissions/check",
4265
+ requestType: "StoragePermissionCheckRequest",
4266
+ responseEnvelope: "athena",
4267
+ responseType: "StoragePermissionCheckResponse"
4268
+ },
4269
+ {
4270
+ name: "listStorageObjects",
4271
+ method: "POST",
4272
+ path: "/storage/objects",
4273
+ requestType: "StorageListObjectsRequest",
4274
+ responseEnvelope: "athena",
4275
+ responseType: "Record<string, unknown>"
4276
+ },
4277
+ {
4278
+ name: "headStorageObject",
4279
+ method: "POST",
4280
+ path: "/storage/objects/head",
4281
+ requestType: "StorageObjectRequest",
4282
+ responseEnvelope: "athena",
4283
+ responseType: "Record<string, unknown>"
4284
+ },
4285
+ {
4286
+ name: "existsStorageObject",
4287
+ method: "POST",
4288
+ path: "/storage/objects/exists",
4289
+ requestType: "StorageObjectRequest",
4290
+ responseEnvelope: "athena",
4291
+ responseType: "Record<string, unknown>"
4292
+ },
4293
+ {
4294
+ name: "validateStorageObject",
4295
+ method: "POST",
4296
+ path: "/storage/objects/validate",
4297
+ requestType: "StorageObjectValidateRequest",
4298
+ responseEnvelope: "athena",
4299
+ responseType: "Record<string, unknown>"
4300
+ },
4301
+ {
4302
+ name: "updateStorageObject",
4303
+ method: "POST",
4304
+ path: "/storage/objects/update",
4305
+ requestType: "StorageUpdateObjectRequest",
4306
+ responseEnvelope: "athena",
4307
+ responseType: "Record<string, unknown>"
4308
+ },
4309
+ {
4310
+ name: "copyStorageObject",
4311
+ method: "POST",
4312
+ path: "/storage/objects/copy",
4313
+ requestType: "StorageObjectCopyRequest",
4314
+ responseEnvelope: "athena",
4315
+ responseType: "Record<string, unknown>"
4316
+ },
4317
+ {
4318
+ name: "getStorageObjectUrl",
4319
+ method: "POST",
4320
+ path: "/storage/objects/url",
4321
+ requestType: "StorageObjectRequest",
4322
+ responseEnvelope: "athena",
4323
+ responseType: "Record<string, unknown>"
4324
+ },
4325
+ {
4326
+ name: "getStorageObjectPublicUrl",
4327
+ method: "POST",
4328
+ path: "/storage/objects/public-url",
4329
+ requestType: "StorageObjectPublicUrlRequest",
4330
+ responseEnvelope: "athena",
4331
+ responseType: "Record<string, unknown>"
4332
+ },
4333
+ {
4334
+ name: "deleteStorageObject",
4335
+ method: "POST",
4336
+ path: "/storage/objects/delete",
4337
+ requestType: "StorageObjectRequest",
4338
+ responseEnvelope: "athena",
4339
+ responseType: "Record<string, unknown>"
4340
+ },
4341
+ {
4342
+ name: "createStorageObjectUploadUrl",
4343
+ method: "POST",
4344
+ path: "/storage/objects/upload-url",
4345
+ requestType: "StoragePresignUploadRequest",
4346
+ responseEnvelope: "athena",
4347
+ responseType: "Record<string, unknown>"
4348
+ },
4349
+ {
4350
+ name: "createStorageObjectPostPolicy",
4351
+ method: "POST",
4352
+ path: "/storage/objects/post-policy",
4353
+ requestType: "StorageSignedPostPolicyRequest",
4354
+ responseEnvelope: "athena",
4355
+ responseType: "Record<string, unknown>"
4356
+ },
4357
+ {
4358
+ name: "listStorageObjectVersions",
4359
+ method: "POST",
4360
+ path: "/storage/objects/versions",
4361
+ requestType: "StorageObjectVersionListRequest",
4362
+ responseEnvelope: "athena",
4363
+ responseType: "Record<string, unknown>"
4364
+ },
4365
+ {
4366
+ name: "restoreStorageObjectVersion",
4367
+ method: "POST",
4368
+ path: "/storage/objects/versions/restore",
4369
+ requestType: "StorageObjectVersionMutationRequest",
4370
+ responseEnvelope: "athena",
4371
+ responseType: "Record<string, unknown>"
4372
+ },
4373
+ {
4374
+ name: "deleteStorageObjectVersion",
4375
+ method: "POST",
4376
+ path: "/storage/objects/versions/delete",
4377
+ requestType: "StorageObjectVersionMutationRequest",
4378
+ responseEnvelope: "athena",
4379
+ responseType: "Record<string, unknown>"
4380
+ },
4381
+ {
4382
+ name: "createStorageObjectFolder",
4383
+ method: "POST",
4384
+ path: "/storage/objects/folder",
4385
+ requestType: "StorageObjectFolderCreateRequest",
4386
+ responseEnvelope: "athena",
4387
+ responseType: "Record<string, unknown>"
4388
+ },
4389
+ {
4390
+ name: "deleteStorageObjectFolder",
4391
+ method: "POST",
4392
+ path: "/storage/objects/folder/delete",
4393
+ requestType: "StorageObjectFolderDeleteRequest",
4394
+ responseEnvelope: "athena",
4395
+ responseType: "Record<string, unknown>"
4396
+ },
4397
+ {
4398
+ name: "renameStorageObjectFolder",
4399
+ method: "POST",
4400
+ path: "/storage/objects/folder/rename",
4401
+ requestType: "StorageObjectFolderRenameRequest",
4402
+ responseEnvelope: "athena",
4403
+ responseType: "Record<string, unknown>"
4404
+ },
4405
+ {
4406
+ name: "listStorageBuckets",
4407
+ method: "POST",
4408
+ path: "/storage/buckets/list",
4409
+ requestType: "Omit<StorageObjectBaseRequest, 'bucket'>",
4410
+ responseEnvelope: "athena",
4411
+ responseType: "Record<string, unknown>"
4412
+ },
4413
+ {
4414
+ name: "createStorageBucket",
4415
+ method: "POST",
4416
+ path: "/storage/buckets/create",
4417
+ requestType: "StorageObjectBaseRequest",
4418
+ responseEnvelope: "athena",
4419
+ responseType: "Record<string, unknown>"
4420
+ },
4421
+ {
4422
+ name: "deleteStorageBucket",
4423
+ method: "POST",
4424
+ path: "/storage/buckets/delete",
4425
+ requestType: "StorageObjectBaseRequest",
4426
+ responseEnvelope: "athena",
4427
+ responseType: "Record<string, unknown>"
4428
+ },
4429
+ {
4430
+ name: "getStorageBucketLifecycle",
4431
+ method: "POST",
4432
+ path: "/storage/buckets/lifecycle",
4433
+ requestType: "StorageBucketLifecycleRequest",
4434
+ responseEnvelope: "athena",
4435
+ responseType: "Record<string, unknown>"
4436
+ },
4437
+ {
4438
+ name: "setStorageBucketLifecycle",
4439
+ method: "POST",
4440
+ path: "/storage/buckets/lifecycle/set",
4441
+ requestType: "StorageSetBucketLifecycleRequest",
4442
+ responseEnvelope: "athena",
4443
+ responseType: "Record<string, unknown>"
4444
+ },
4445
+ {
4446
+ name: "deleteStorageBucketLifecycle",
4447
+ method: "POST",
4448
+ path: "/storage/buckets/lifecycle/delete",
4449
+ requestType: "StorageBucketLifecycleRequest",
4450
+ responseEnvelope: "athena",
4451
+ responseType: "Record<string, unknown>"
4452
+ },
4453
+ {
4454
+ name: "getStorageBucketPolicy",
4455
+ method: "POST",
4456
+ path: "/storage/buckets/policy",
4457
+ requestType: "StorageBucketPolicyRequest",
4458
+ responseEnvelope: "athena",
4459
+ responseType: "Record<string, unknown>"
4460
+ },
4461
+ {
4462
+ name: "setStorageBucketPolicy",
4463
+ method: "POST",
4464
+ path: "/storage/buckets/policy/set",
4465
+ requestType: "StorageSetBucketPolicyRequest",
4466
+ responseEnvelope: "athena",
4467
+ responseType: "Record<string, unknown>"
4468
+ },
4469
+ {
4470
+ name: "deleteStorageBucketPolicy",
4471
+ method: "POST",
4472
+ path: "/storage/buckets/policy/delete",
4473
+ requestType: "StorageBucketPolicyRequest",
4474
+ responseEnvelope: "athena",
4475
+ responseType: "Record<string, unknown>"
4476
+ },
4477
+ {
4478
+ name: "getStorageBucketPublicAccess",
4479
+ method: "POST",
4480
+ path: "/storage/buckets/public-access",
4481
+ requestType: "StoragePublicAccessBlockRequest",
4482
+ responseEnvelope: "athena",
4483
+ responseType: "Record<string, unknown>"
4484
+ },
4485
+ {
4486
+ name: "setStorageBucketPublicAccess",
4487
+ method: "POST",
4488
+ path: "/storage/buckets/public-access/set",
4489
+ requestType: "StorageSetPublicAccessBlockRequest",
4490
+ responseEnvelope: "athena",
4491
+ responseType: "Record<string, unknown>"
4492
+ },
4493
+ {
4494
+ name: "deleteStorageBucketPublicAccess",
4495
+ method: "POST",
4496
+ path: "/storage/buckets/public-access/delete",
4497
+ requestType: "StoragePublicAccessBlockRequest",
4498
+ responseEnvelope: "athena",
4499
+ responseType: "Record<string, unknown>"
4500
+ },
4501
+ {
4502
+ name: "getStorageBucketCors",
4503
+ method: "POST",
4504
+ path: "/storage/buckets/cors",
4505
+ requestType: "StorageBucketCorsRequest",
4506
+ responseEnvelope: "athena",
4507
+ responseType: "Record<string, unknown>"
4508
+ },
4509
+ {
4510
+ name: "setStorageBucketCors",
4511
+ method: "POST",
4512
+ path: "/storage/buckets/cors/set",
4513
+ requestType: "StorageSetBucketCorsRequest",
4514
+ responseEnvelope: "athena",
4515
+ responseType: "Record<string, unknown>"
3807
4516
  },
3808
4517
  {
3809
- name: "getStorageFileProxy",
3810
- method: "GET",
3811
- path: "/storage/files/{file_id}/proxy",
3812
- pathParams: ["file_id"],
3813
- queryParams: ["purpose"],
3814
- responseEnvelope: "raw",
3815
- responseType: "Response",
3816
- binary: true
4518
+ name: "deleteStorageBucketCors",
4519
+ method: "POST",
4520
+ path: "/storage/buckets/cors/delete",
4521
+ requestType: "StorageBucketCorsRequest",
4522
+ responseEnvelope: "athena",
4523
+ responseType: "Record<string, unknown>"
3817
4524
  },
3818
4525
  {
3819
- name: "updateStorageFile",
3820
- method: "PATCH",
3821
- path: "/storage/files/{file_id}",
3822
- pathParams: ["file_id"],
3823
- requestType: "UpdateStorageFileRequest",
4526
+ name: "createStorageMultipartUpload",
4527
+ method: "POST",
4528
+ path: "/storage/multipart/create",
4529
+ requestType: "StorageMultipartCreateRequest",
3824
4530
  responseEnvelope: "athena",
3825
- responseType: "StorageFileMutationResponse"
4531
+ responseType: "Record<string, unknown>"
3826
4532
  },
3827
4533
  {
3828
- name: "deleteStorageFile",
3829
- method: "DELETE",
3830
- path: "/storage/files/{file_id}",
3831
- pathParams: ["file_id"],
4534
+ name: "signStorageMultipartPart",
4535
+ method: "POST",
4536
+ path: "/storage/multipart/sign-part",
4537
+ requestType: "StorageMultipartSignPartRequest",
3832
4538
  responseEnvelope: "athena",
3833
- responseType: "StorageFileMutationResponse"
4539
+ responseType: "Record<string, unknown>"
3834
4540
  },
3835
4541
  {
3836
- name: "setStorageFileVisibility",
3837
- method: "PATCH",
3838
- path: "/storage/files/{file_id}/visibility",
3839
- pathParams: ["file_id"],
3840
- requestType: "SetStorageFileVisibilityRequest",
4542
+ name: "completeStorageMultipartUpload",
4543
+ method: "POST",
4544
+ path: "/storage/multipart/complete",
4545
+ requestType: "StorageMultipartCompleteRequest",
3841
4546
  responseEnvelope: "athena",
3842
4547
  responseType: "StorageFileMutationResponse"
3843
4548
  },
3844
4549
  {
3845
- name: "deleteStorageFolder",
4550
+ name: "abortStorageMultipartUpload",
3846
4551
  method: "POST",
3847
- path: "/storage/folders/delete",
3848
- requestType: "DeleteStorageFolderRequest",
4552
+ path: "/storage/multipart/abort",
4553
+ requestType: "StorageMultipartAbortRequest",
3849
4554
  responseEnvelope: "athena",
3850
- responseType: "StorageFolderMutationResponse"
4555
+ responseType: "Record<string, unknown>"
3851
4556
  },
3852
4557
  {
3853
- name: "moveStorageFolder",
4558
+ name: "listStorageMultipartParts",
3854
4559
  method: "POST",
3855
- path: "/storage/folders/move",
3856
- requestType: "MoveStorageFolderRequest",
4560
+ path: "/storage/multipart/list-parts",
4561
+ requestType: "StorageMultipartListPartsRequest",
3857
4562
  responseEnvelope: "athena",
3858
- responseType: "StorageFolderMutationResponse"
4563
+ responseType: "Record<string, unknown>"
4564
+ },
4565
+ {
4566
+ name: "listStorageAuditEvents",
4567
+ method: "POST",
4568
+ path: "/storage/audit/list",
4569
+ requestType: "StorageAuditQueryRequest",
4570
+ responseEnvelope: "athena",
4571
+ responseType: "StorageAuditListResponse"
3859
4572
  }
3860
4573
  ]
3861
4574
  };
@@ -4316,7 +5029,7 @@ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
4316
5029
  return fetch(uploadUrl, init);
4317
5030
  }
4318
5031
  function attachManagedUpload(upload) {
4319
- const headers = {};
5032
+ const headers = { ...upload.headers ?? {} };
4320
5033
  return {
4321
5034
  ...upload,
4322
5035
  method: "PUT",
@@ -4362,7 +5075,12 @@ function normalizeUploadUrlRequest(input) {
4362
5075
  file_id: input.file_id ?? input.fileId,
4363
5076
  public: input.public,
4364
5077
  visibility: input.visibility,
4365
- metadata: input.metadata
5078
+ metadata: input.metadata,
5079
+ server_side_encryption: input.server_side_encryption,
5080
+ sse: input.sse,
5081
+ ssekms_key_id: input.ssekms_key_id,
5082
+ kms_key_id: input.kms_key_id,
5083
+ bucket_key_enabled: input.bucket_key_enabled
4366
5084
  };
4367
5085
  }
4368
5086
  async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
@@ -4513,6 +5231,12 @@ function createStorageModule(gateway, runtimeOptions) {
4513
5231
  options,
4514
5232
  resolvedRuntimeOptions
4515
5233
  );
5234
+ const callStorageFileVisibility = (fileId, method, input, options) => callAthena2(
5235
+ withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId),
5236
+ method,
5237
+ input,
5238
+ options
5239
+ );
4516
5240
  const base = {
4517
5241
  listStorageCatalogs(options) {
4518
5242
  return callRaw("/storage/catalogs", "GET", void 0, options);
@@ -4562,7 +5286,7 @@ function createStorageModule(gateway, runtimeOptions) {
4562
5286
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
4563
5287
  },
4564
5288
  setStorageFileVisibility(fileId, input, options) {
4565
- return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
5289
+ return callStorageFileVisibility(fileId, "PATCH", input, options);
4566
5290
  },
4567
5291
  deleteStorageFolder(input, options) {
4568
5292
  return callAthena2("/storage/folders/delete", "POST", input, options);
@@ -4634,13 +5358,62 @@ function createStorageModule(gateway, runtimeOptions) {
4634
5358
  publicUrl(fileId, options) {
4635
5359
  return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
4636
5360
  },
5361
+ proxyUrl(fileId, query, options) {
5362
+ const path = appendQuery(
5363
+ withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
5364
+ query
5365
+ );
5366
+ return callAthena2(path, "GET", void 0, options);
5367
+ },
4637
5368
  proxy(fileId, query, options) {
4638
5369
  return base.getStorageFileProxy(fileId, query, options);
4639
5370
  },
4640
- visibility: {
5371
+ versions(fileId, options) {
5372
+ return callAthena2(withPathParam("/storage/files/{file_id}/versions", "file_id", fileId), "GET", void 0, options);
5373
+ },
5374
+ restoreVersion(fileId, versionId, options) {
5375
+ return callAthena2(
5376
+ withPathParam(
5377
+ withPathParam("/storage/files/{file_id}/versions/{version_id}/restore", "file_id", fileId),
5378
+ "version_id",
5379
+ versionId
5380
+ ),
5381
+ "POST",
5382
+ {},
5383
+ options
5384
+ );
5385
+ },
5386
+ deleteVersion(fileId, versionId, options) {
5387
+ return callAthena2(
5388
+ withPathParam(
5389
+ withPathParam("/storage/files/{file_id}/versions/{version_id}", "file_id", fileId),
5390
+ "version_id",
5391
+ versionId
5392
+ ),
5393
+ "DELETE",
5394
+ void 0,
5395
+ options
5396
+ );
5397
+ },
5398
+ retention: {
5399
+ get(fileId, query, options) {
5400
+ const path = appendQuery(
5401
+ withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
5402
+ query
5403
+ );
5404
+ return callAthena2(path, "GET", void 0, options);
5405
+ },
4641
5406
  set(fileId, input, options) {
5407
+ return callAthena2(withPathParam("/storage/files/{file_id}/retention", "file_id", fileId), "POST", input, options);
5408
+ }
5409
+ },
5410
+ visibility: {
5411
+ update(fileId, input, options) {
4642
5412
  return base.setStorageFileVisibility(fileId, input, options);
4643
5413
  },
5414
+ set(fileId, input, options) {
5415
+ return callStorageFileVisibility(fileId, "POST", input, options);
5416
+ },
4644
5417
  setMany(input, options) {
4645
5418
  return callAthena2("/storage/files/visibility-many", "POST", input, options);
4646
5419
  }
@@ -4735,6 +5508,18 @@ function createStorageModule(gateway, runtimeOptions) {
4735
5508
  uploadUrl(input, options) {
4736
5509
  return callAthena2("/storage/objects/upload-url", "POST", input, options);
4737
5510
  },
5511
+ versions(input, options) {
5512
+ return callAthena2("/storage/objects/versions", "POST", input, options);
5513
+ },
5514
+ restoreVersion(input, options) {
5515
+ return callAthena2("/storage/objects/versions/restore", "POST", input, options);
5516
+ },
5517
+ deleteVersion(input, options) {
5518
+ return callAthena2("/storage/objects/versions/delete", "POST", input, options);
5519
+ },
5520
+ postPolicy(input, options) {
5521
+ return callAthena2("/storage/objects/post-policy", "POST", input, options);
5522
+ },
4738
5523
  folder: objectFolder
4739
5524
  };
4740
5525
  const bucket = {
@@ -4747,6 +5532,39 @@ function createStorageModule(gateway, runtimeOptions) {
4747
5532
  delete(input, options) {
4748
5533
  return callAthena2("/storage/buckets/delete", "POST", input, options);
4749
5534
  },
5535
+ lifecycle: {
5536
+ get(input, options) {
5537
+ return callAthena2("/storage/buckets/lifecycle", "POST", input, options);
5538
+ },
5539
+ set(input, options) {
5540
+ return callAthena2("/storage/buckets/lifecycle/set", "POST", input, options);
5541
+ },
5542
+ delete(input, options) {
5543
+ return callAthena2("/storage/buckets/lifecycle/delete", "POST", input, options);
5544
+ }
5545
+ },
5546
+ policy: {
5547
+ get(input, options) {
5548
+ return callAthena2("/storage/buckets/policy", "POST", input, options);
5549
+ },
5550
+ set(input, options) {
5551
+ return callAthena2("/storage/buckets/policy/set", "POST", input, options);
5552
+ },
5553
+ delete(input, options) {
5554
+ return callAthena2("/storage/buckets/policy/delete", "POST", input, options);
5555
+ }
5556
+ },
5557
+ publicAccess: {
5558
+ get(input, options) {
5559
+ return callAthena2("/storage/buckets/public-access", "POST", input, options);
5560
+ },
5561
+ set(input, options) {
5562
+ return callAthena2("/storage/buckets/public-access/set", "POST", input, options);
5563
+ },
5564
+ delete(input, options) {
5565
+ return callAthena2("/storage/buckets/public-access/delete", "POST", input, options);
5566
+ }
5567
+ },
4750
5568
  cors: {
4751
5569
  get(input, options) {
4752
5570
  return callAthena2("/storage/buckets/cors", "POST", input, options);
@@ -4848,6 +5666,9 @@ var AthenaClientBuilderImpl = class {
4848
5666
  apiKey;
4849
5667
  backendConfig = DEFAULT_BACKEND;
4850
5668
  clientName;
5669
+ defaultUserId;
5670
+ defaultOrganizationId;
5671
+ forceNoCacheEnabled = false;
4851
5672
  defaultHeaders;
4852
5673
  authConfig;
4853
5674
  dbUrlOverride;
@@ -4896,6 +5717,15 @@ var AthenaClientBuilderImpl = class {
4896
5717
  if (options.client !== void 0) {
4897
5718
  this.clientName = options.client;
4898
5719
  }
5720
+ if (options.userId !== void 0) {
5721
+ this.defaultUserId = options.userId;
5722
+ }
5723
+ if (options.organizationId !== void 0) {
5724
+ this.defaultOrganizationId = options.organizationId;
5725
+ }
5726
+ if (options.forceNoCache !== void 0) {
5727
+ this.forceNoCacheEnabled = options.forceNoCache;
5728
+ }
4899
5729
  if (options.backend !== void 0) {
4900
5730
  this.backendConfig = toBackendConfig(options.backend);
4901
5731
  }
@@ -4950,6 +5780,9 @@ var AthenaClientBuilderImpl = class {
4950
5780
  url: this.rootUrl,
4951
5781
  key: this.apiKey,
4952
5782
  client: this.clientName,
5783
+ userId: this.defaultUserId,
5784
+ organizationId: this.defaultOrganizationId,
5785
+ forceNoCache: this.forceNoCacheEnabled,
4953
5786
  backend: this.backendConfig,
4954
5787
  headers: this.defaultHeaders,
4955
5788
  db: this.dbUrlOverride ? { url: this.dbUrlOverride } : void 0,
@@ -7492,6 +8325,83 @@ function createQueryBuilder(client, formatGatewayResult, experimental, tracer) {
7492
8325
  );
7493
8326
  };
7494
8327
  }
8328
+ var ATHENA_ENV_URL_KEYS = ["ATHENA_URL", "NEXT_PUBLIC_ATHENA_URL"];
8329
+ var ATHENA_ENV_GATEWAY_URL_KEYS = [
8330
+ "ATHENA_DB_URL",
8331
+ "ATHENA_GATEWAY_URL",
8332
+ "NEXT_PUBLIC_ATHENA_DB_API_URL"
8333
+ ];
8334
+ var ATHENA_ENV_AUTH_URL_KEYS = ["ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
8335
+ var ATHENA_ENV_STORAGE_URL_KEYS = ["ATHENA_STORAGE_URL", "NEXT_PUBLIC_ATHENA_STORAGE_URL"];
8336
+ var ATHENA_ENV_KEY_KEYS = [
8337
+ "ATHENA_API_KEY",
8338
+ "NEXT_PUBLIC_ATHENA_API_KEY",
8339
+ "ATHENA_GATEWAY_API_KEY",
8340
+ "X_API_KEY"
8341
+ ];
8342
+ var ATHENA_ENV_CLIENT_KEYS = ["ATHENA_CLIENT", "NEXT_PUBLIC_ATHENA_CLIENT"];
8343
+ function normalizeOptionalString(value) {
8344
+ if (typeof value !== "string") {
8345
+ return void 0;
8346
+ }
8347
+ const normalizedValue = value.trim();
8348
+ return normalizedValue ? normalizedValue : void 0;
8349
+ }
8350
+ function readFirstEnvValue(env, keys) {
8351
+ for (const key of keys) {
8352
+ const value = normalizeOptionalString(env[key]);
8353
+ if (value) {
8354
+ return value;
8355
+ }
8356
+ }
8357
+ return void 0;
8358
+ }
8359
+ function readHeaderBagValue(headers, targetKey) {
8360
+ if (!headers) {
8361
+ return void 0;
8362
+ }
8363
+ if (typeof headers.get === "function") {
8364
+ return normalizeOptionalString(headers.get(targetKey));
8365
+ }
8366
+ const normalizedTargetKey = targetKey.toLowerCase();
8367
+ for (const [key, value] of Object.entries(headers)) {
8368
+ if (key.toLowerCase() !== normalizedTargetKey) {
8369
+ continue;
8370
+ }
8371
+ if (typeof value === "string") {
8372
+ return normalizeOptionalString(value);
8373
+ }
8374
+ return void 0;
8375
+ }
8376
+ return void 0;
8377
+ }
8378
+ function resolveSessionContextOptions(session, options) {
8379
+ const sessionToken = normalizeOptionalString(session?.session?.token);
8380
+ const requestCookie = readHeaderBagValue(options?.requestHeaders, "cookie") ?? readHeaderBagValue(options?.headers, "cookie");
8381
+ const authInput = options?.auth;
8382
+ const resolvedUserId = options?.userId !== void 0 ? options.userId : session?.user?.id;
8383
+ const resolvedOrganizationId = options?.organizationId !== void 0 ? options.organizationId : session?.session?.activeOrganizationId;
8384
+ const resolvedBearerToken = authInput?.bearerToken !== void 0 ? authInput.bearerToken : sessionToken;
8385
+ const resolvedSessionToken = authInput?.sessionToken !== void 0 ? authInput.sessionToken : sessionToken;
8386
+ const resolvedCookie = authInput?.cookie !== void 0 ? authInput.cookie : requestCookie;
8387
+ const auth = authInput !== void 0 || resolvedBearerToken !== void 0 || resolvedSessionToken !== void 0 || resolvedCookie !== void 0 ? {
8388
+ ...authInput ?? {},
8389
+ ...resolvedBearerToken !== void 0 ? { bearerToken: resolvedBearerToken } : {},
8390
+ ...resolvedSessionToken !== void 0 ? { sessionToken: resolvedSessionToken } : {},
8391
+ ...resolvedCookie !== void 0 ? { cookie: resolvedCookie } : {},
8392
+ headers: authInput?.headers ? { ...authInput.headers } : void 0
8393
+ } : void 0;
8394
+ if (resolvedUserId === void 0 && resolvedOrganizationId === void 0 && options?.forceNoCache === void 0 && !options?.headers && !auth) {
8395
+ return void 0;
8396
+ }
8397
+ return {
8398
+ userId: resolvedUserId,
8399
+ organizationId: resolvedOrganizationId,
8400
+ forceNoCache: options?.forceNoCache,
8401
+ headers: options?.headers ? { ...options.headers } : void 0,
8402
+ auth
8403
+ };
8404
+ }
7495
8405
  function resolveClientServiceBaseUrl(value, label) {
7496
8406
  if (value === void 0 || value === null) {
7497
8407
  return void 0;
@@ -7513,21 +8423,143 @@ function resolveServiceUrls(config) {
7513
8423
  storageUrl: resolveServiceUrlOverride(config.storage?.url, "Athena storage base URL") ?? resolveServiceUrlOverride(config.storageUrl, "Athena storage base URL") ?? (baseUrl ? appendServicePath(baseUrl, "storage") : void 0)
7514
8424
  };
7515
8425
  }
8426
+ function resolveOptionalClientName(value) {
8427
+ if (value === void 0 || value === null) {
8428
+ return void 0;
8429
+ }
8430
+ const normalizedValue = value.trim();
8431
+ return normalizedValue ? normalizedValue : void 0;
8432
+ }
8433
+ function resolveRequiredClientApiKey(value) {
8434
+ if (value === void 0 || value === null) {
8435
+ throw new Error(
8436
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8437
+ );
8438
+ }
8439
+ const normalizedValue = value.trim();
8440
+ if (!normalizedValue) {
8441
+ throw new Error(
8442
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8443
+ );
8444
+ }
8445
+ return normalizedValue;
8446
+ }
8447
+ function hasHeaderIgnoreCase(headers, targetKey) {
8448
+ const normalizedTargetKey = targetKey.toLowerCase();
8449
+ return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
8450
+ }
8451
+ function mergeClientHeaders(current, next) {
8452
+ if (!current && !next) {
8453
+ return void 0;
8454
+ }
8455
+ return {
8456
+ ...current ?? {},
8457
+ ...next ?? {}
8458
+ };
8459
+ }
8460
+ function mergeDefinedObject(current, next) {
8461
+ if (!current && !next) {
8462
+ return void 0;
8463
+ }
8464
+ const merged = {
8465
+ ...current ?? {}
8466
+ };
8467
+ const mutableMerged = merged;
8468
+ for (const [key, value] of Object.entries(next ?? {})) {
8469
+ if (value !== void 0) {
8470
+ mutableMerged[key] = value;
8471
+ }
8472
+ }
8473
+ return merged;
8474
+ }
8475
+ function mergeAuthClientOptions(current, next) {
8476
+ const merged = mergeDefinedObject(current, next);
8477
+ if (!merged) {
8478
+ return void 0;
8479
+ }
8480
+ const mergedHeaders = mergeClientHeaders(current?.headers, next?.headers);
8481
+ if (mergedHeaders) {
8482
+ merged.headers = mergedHeaders;
8483
+ }
8484
+ return merged;
8485
+ }
8486
+ function mergeServiceUrlOverrides(current, next) {
8487
+ return mergeDefinedObject(current, next);
8488
+ }
8489
+ function toClientContextOverrides(context) {
8490
+ if (!context) {
8491
+ return void 0;
8492
+ }
8493
+ return {
8494
+ userId: context.userId,
8495
+ organizationId: context.organizationId,
8496
+ forceNoCache: context.forceNoCache,
8497
+ headers: context.headers,
8498
+ auth: context.auth ? {
8499
+ ...context.auth,
8500
+ headers: context.auth.headers ? { ...context.auth.headers } : void 0
8501
+ } : void 0
8502
+ };
8503
+ }
8504
+ function mergeClientOverrideOptions(base, overrides) {
8505
+ if (!overrides) {
8506
+ return {
8507
+ ...base,
8508
+ headers: base.headers ? { ...base.headers } : void 0,
8509
+ auth: base.auth ? {
8510
+ ...base.auth,
8511
+ headers: base.auth.headers ? { ...base.auth.headers } : void 0
8512
+ } : void 0,
8513
+ db: base.db ? { ...base.db } : void 0,
8514
+ gateway: base.gateway ? { ...base.gateway } : void 0,
8515
+ storage: base.storage ? { ...base.storage } : void 0
8516
+ };
8517
+ }
8518
+ const merged = mergeDefinedObject(base, overrides) ?? { ...base };
8519
+ return {
8520
+ ...merged,
8521
+ headers: mergeClientHeaders(base.headers, overrides.headers),
8522
+ auth: mergeAuthClientOptions(base.auth, overrides.auth),
8523
+ db: mergeServiceUrlOverrides(base.db, overrides.db),
8524
+ gateway: mergeServiceUrlOverrides(base.gateway, overrides.gateway),
8525
+ storage: mergeServiceUrlOverrides(base.storage, overrides.storage)
8526
+ };
8527
+ }
7516
8528
  function normalizeAuthClientConfig(auth, defaultBaseUrl) {
7517
8529
  if (!auth && defaultBaseUrl === void 0) {
7518
8530
  return void 0;
7519
8531
  }
7520
- const { url, ...rest } = auth ?? {};
8532
+ const {
8533
+ url,
8534
+ baseUrl,
8535
+ apiKey,
8536
+ bearerToken,
8537
+ cookie,
8538
+ sessionToken,
8539
+ ...rest
8540
+ } = auth ?? {};
7521
8541
  const normalized = {
7522
8542
  ...rest
7523
8543
  };
7524
8544
  const resolvedBaseUrl = resolveClientServiceBaseUrl(
7525
- url ?? rest.baseUrl ?? defaultBaseUrl,
8545
+ url ?? baseUrl ?? defaultBaseUrl,
7526
8546
  "Athena auth base URL"
7527
8547
  );
7528
8548
  if (resolvedBaseUrl !== void 0) {
7529
8549
  normalized.baseUrl = resolvedBaseUrl;
7530
8550
  }
8551
+ if (typeof apiKey === "string") {
8552
+ normalized.apiKey = apiKey;
8553
+ }
8554
+ if (typeof bearerToken === "string") {
8555
+ normalized.bearerToken = bearerToken;
8556
+ }
8557
+ if (typeof cookie === "string") {
8558
+ normalized.cookie = cookie;
8559
+ }
8560
+ if (typeof sessionToken === "string") {
8561
+ normalized.sessionToken = sessionToken;
8562
+ }
7531
8563
  return normalized;
7532
8564
  }
7533
8565
  function resolveCreateClientConfig(config) {
@@ -7539,8 +8571,11 @@ function resolveCreateClientConfig(config) {
7539
8571
  }
7540
8572
  return {
7541
8573
  baseUrl: resolvedUrls.dbUrl,
7542
- apiKey: config.key,
7543
- client: config.client,
8574
+ apiKey: resolveRequiredClientApiKey(config.key),
8575
+ client: resolveOptionalClientName(config.client),
8576
+ userId: config.userId,
8577
+ organizationId: config.organizationId,
8578
+ forceNoCache: config.forceNoCache,
7544
8579
  backend: toBackendConfig(config.backend),
7545
8580
  headers: config.headers,
7546
8581
  auth: config.auth,
@@ -7549,23 +8584,39 @@ function resolveCreateClientConfig(config) {
7549
8584
  experimental: config.experimental
7550
8585
  };
7551
8586
  }
7552
- function createClientFromConfig(config) {
8587
+ function createClientFromInput(sourceConfig) {
8588
+ return createClientFromConfig(resolveCreateClientConfig(sourceConfig), sourceConfig);
8589
+ }
8590
+ function createClientFromConfig(config, sourceConfig) {
8591
+ const normalizedAuthConfig = normalizeAuthClientConfig(config.auth, config.authUrl);
7553
8592
  const gatewayHeaders = {
7554
8593
  ...config.headers ?? {}
7555
8594
  };
7556
- if (config.auth?.bearerToken && gatewayHeaders["X-Athena-Auth-Bearer-Token"] === void 0 && gatewayHeaders["x-athena-auth-bearer-token"] === void 0) {
7557
- gatewayHeaders["X-Athena-Auth-Bearer-Token"] = config.auth.bearerToken;
8595
+ if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Bearer-Token")) {
8596
+ gatewayHeaders["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
8597
+ }
8598
+ if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(gatewayHeaders, "Cookie")) {
8599
+ gatewayHeaders.Cookie = normalizedAuthConfig.cookie;
8600
+ }
8601
+ if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Session-Token")) {
8602
+ gatewayHeaders["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
7558
8603
  }
7559
8604
  const gateway = createAthenaGatewayClient({
7560
8605
  baseUrl: config.baseUrl,
7561
8606
  apiKey: config.apiKey,
7562
8607
  client: config.client,
8608
+ userId: config.userId,
8609
+ organizationId: config.organizationId,
8610
+ forceNoCache: config.forceNoCache,
7563
8611
  backend: config.backend,
7564
8612
  headers: gatewayHeaders
7565
8613
  });
7566
8614
  const formatGatewayResult = createResultFormatter(config.experimental);
7567
8615
  const queryTracer = createQueryTracer(config.experimental);
7568
- const auth = createAuthClient(normalizeAuthClientConfig(config.auth, config.authUrl));
8616
+ const auth = createAuthClient({
8617
+ ...normalizedAuthConfig ?? {},
8618
+ ...config.forceNoCache ? { forceNoCache: true } : {}
8619
+ });
7569
8620
  function from(tableOrModel, options) {
7570
8621
  if (isAthenaModelTarget(tableOrModel)) {
7571
8622
  if (options?.schema !== void 0) {
@@ -7613,17 +8664,45 @@ function createClientFromConfig(config) {
7613
8664
  queryTracer
7614
8665
  );
7615
8666
  const db = createDbModule({ from, rpc, query });
8667
+ const withContext = (context) => createClientFromInput(
8668
+ mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
8669
+ );
8670
+ const withSession = (session, options) => createClientFromInput(
8671
+ mergeClientOverrideOptions(
8672
+ sourceConfig,
8673
+ toClientContextOverrides(resolveSessionContextOptions(session, options))
8674
+ )
8675
+ );
8676
+ const authWithOptions = (options) => createClientFromInput(mergeClientOverrideOptions(sourceConfig, options));
7616
8677
  const sdkClient = {
7617
8678
  from,
7618
8679
  db,
7619
8680
  rpc,
7620
8681
  query,
7621
8682
  verifyConnection: gateway.verifyConnection,
7622
- auth: auth.auth
8683
+ auth: auth.auth,
8684
+ withContext,
8685
+ withSession,
8686
+ withOptions: authWithOptions
7623
8687
  };
7624
8688
  if (config.experimental?.athenaStorageBackend) {
8689
+ const storageWithContext = (context) => createClientFromInput(
8690
+ mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
8691
+ );
8692
+ const storageWithSession = (session, options) => createClientFromInput(
8693
+ mergeClientOverrideOptions(
8694
+ sourceConfig,
8695
+ toClientContextOverrides(resolveSessionContextOptions(session, options))
8696
+ )
8697
+ );
8698
+ const storageWithOptions = (options) => createClientFromInput(
8699
+ mergeClientOverrideOptions(sourceConfig, options)
8700
+ );
7625
8701
  const storageClient = {
7626
8702
  ...sdkClient,
8703
+ withContext: storageWithContext,
8704
+ withSession: storageWithSession,
8705
+ withOptions: storageWithOptions,
7627
8706
  storage: createStorageModule(gateway, {
7628
8707
  ...config.experimental.storage,
7629
8708
  ...config.storageUrl ? {
@@ -7639,38 +8718,42 @@ function createClientFromConfig(config) {
7639
8718
  var AthenaClient = class {
7640
8719
  /** Create a fluent builder for a strongly-typed Athena SDK client. */
7641
8720
  static builder() {
7642
- return createAthenaClientBuilder((config) => createClientFromConfig(resolveCreateClientConfig(config)));
7643
- }
7644
- /** Build a client from process environment variables. */
7645
- static fromEnvironment() {
7646
- const url = process.env.ATHENA_URL;
7647
- const gatewayUrl = process.env.ATHENA_DB_URL ?? process.env.ATHENA_GATEWAY_URL;
7648
- const authUrl = process.env.ATHENA_AUTH_URL;
7649
- const storageUrl = process.env.ATHENA_STORAGE_URL;
7650
- const key = process.env.ATHENA_API_KEY ?? process.env.ATHENA_GATEWAY_API_KEY;
8721
+ return createAthenaClientBuilder((config) => createClientFromInput(config));
8722
+ }
8723
+ static fromEnvironment(options = {}) {
8724
+ const env = options.env ?? process.env;
8725
+ const url = options.url ?? readFirstEnvValue(env, ATHENA_ENV_URL_KEYS);
8726
+ const gatewayUrl = options.gatewayUrl ?? readFirstEnvValue(env, ATHENA_ENV_GATEWAY_URL_KEYS);
8727
+ const authUrl = options.authUrl ?? readFirstEnvValue(env, ATHENA_ENV_AUTH_URL_KEYS);
8728
+ const storageUrl = options.storageUrl ?? readFirstEnvValue(env, ATHENA_ENV_STORAGE_URL_KEYS);
8729
+ const key = options.key ?? readFirstEnvValue(env, ATHENA_ENV_KEY_KEYS);
8730
+ const client = options.client ?? readFirstEnvValue(env, ATHENA_ENV_CLIENT_KEYS);
7651
8731
  if (!url && !gatewayUrl || !key) {
7652
8732
  throw new Error(
7653
- "ATHENA_API_KEY plus ATHENA_URL or ATHENA_GATEWAY_URL (optionally ATHENA_DB_URL, ATHENA_AUTH_URL, ATHENA_STORAGE_URL) are required"
8733
+ "AthenaClient.fromEnvironment() requires an API key plus a public or gateway URL. Supported aliases include ATHENA_API_KEY, NEXT_PUBLIC_ATHENA_API_KEY, ATHENA_GATEWAY_API_KEY, X_API_KEY, ATHENA_URL, NEXT_PUBLIC_ATHENA_URL, ATHENA_GATEWAY_URL, and ATHENA_DB_URL."
7654
8734
  );
7655
8735
  }
8736
+ const { env: _env, ...clientOptions } = options;
7656
8737
  return createClient({
8738
+ ...clientOptions,
7657
8739
  url,
7658
8740
  gatewayUrl,
7659
8741
  authUrl,
7660
8742
  storageUrl,
7661
- key
8743
+ key,
8744
+ client
7662
8745
  });
7663
8746
  }
7664
8747
  };
7665
8748
  function createClient(configOrUrl, apiKey, options) {
7666
- if (typeof configOrUrl === "string") {
7667
- return createClientFromConfig(resolveCreateClientConfig({
8749
+ if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
8750
+ return createClientFromInput({
7668
8751
  url: configOrUrl,
7669
8752
  key: apiKey ?? "",
7670
8753
  ...options
7671
- }));
8754
+ });
7672
8755
  }
7673
- return createClientFromConfig(resolveCreateClientConfig(configOrUrl));
8756
+ return createClientFromInput(configOrUrl);
7674
8757
  }
7675
8758
 
7676
8759
  // src/gateway/types.ts
@@ -8036,6 +9119,9 @@ function createColumnsBuilder(name, mappedName, schemaName, columns) {
8036
9119
  resolveTableTarget(name, mappedName, normalizedSchemaName);
8037
9120
  return createColumnsBuilder(name, mappedName, normalizedSchemaName, columns);
8038
9121
  },
9122
+ withoutPrimaryKey() {
9123
+ return finalizeTable(name, mappedName, schemaName, columns, []);
9124
+ },
8039
9125
  primaryKey(...keys) {
8040
9126
  return finalizeTable(name, mappedName, schemaName, columns, keys);
8041
9127
  }
@@ -8087,6 +9173,59 @@ var TenantHeaderMapper = class {
8087
9173
  return Object.keys(headers).length > 0 ? headers : void 0;
8088
9174
  }
8089
9175
  };
9176
+ function normalizeOptionalString2(value) {
9177
+ if (typeof value !== "string") {
9178
+ return void 0;
9179
+ }
9180
+ const normalizedValue = value.trim();
9181
+ return normalizedValue ? normalizedValue : void 0;
9182
+ }
9183
+ function readHeaderBagValue2(headers, targetKey) {
9184
+ if (!headers) {
9185
+ return void 0;
9186
+ }
9187
+ if (typeof headers.get === "function") {
9188
+ return normalizeOptionalString2(headers.get(targetKey));
9189
+ }
9190
+ const normalizedTargetKey = targetKey.toLowerCase();
9191
+ for (const [key, value] of Object.entries(headers)) {
9192
+ if (key.toLowerCase() !== normalizedTargetKey) {
9193
+ continue;
9194
+ }
9195
+ if (typeof value === "string") {
9196
+ return normalizeOptionalString2(value);
9197
+ }
9198
+ return void 0;
9199
+ }
9200
+ return void 0;
9201
+ }
9202
+ function resolveSessionContextOptions2(session, options) {
9203
+ const sessionToken = normalizeOptionalString2(session?.session?.token);
9204
+ const requestCookie = readHeaderBagValue2(options?.requestHeaders, "cookie") ?? readHeaderBagValue2(options?.headers, "cookie");
9205
+ const authInput = options?.auth;
9206
+ const resolvedUserId = options?.userId !== void 0 ? options.userId : session?.user?.id;
9207
+ const resolvedOrganizationId = options?.organizationId !== void 0 ? options.organizationId : session?.session?.activeOrganizationId;
9208
+ const resolvedBearerToken = authInput?.bearerToken !== void 0 ? authInput.bearerToken : sessionToken;
9209
+ const resolvedSessionToken = authInput?.sessionToken !== void 0 ? authInput.sessionToken : sessionToken;
9210
+ const resolvedCookie = authInput?.cookie !== void 0 ? authInput.cookie : requestCookie;
9211
+ const auth = authInput !== void 0 || resolvedBearerToken !== void 0 || resolvedSessionToken !== void 0 || resolvedCookie !== void 0 ? {
9212
+ ...authInput ?? {},
9213
+ ...resolvedBearerToken !== void 0 ? { bearerToken: resolvedBearerToken } : {},
9214
+ ...resolvedSessionToken !== void 0 ? { sessionToken: resolvedSessionToken } : {},
9215
+ ...resolvedCookie !== void 0 ? { cookie: resolvedCookie } : {},
9216
+ headers: authInput?.headers ? { ...authInput.headers } : void 0
9217
+ } : void 0;
9218
+ if (resolvedUserId === void 0 && resolvedOrganizationId === void 0 && options?.forceNoCache === void 0 && !options?.headers && !auth) {
9219
+ return void 0;
9220
+ }
9221
+ return {
9222
+ userId: resolvedUserId,
9223
+ organizationId: resolvedOrganizationId,
9224
+ forceNoCache: options?.forceNoCache,
9225
+ headers: options?.headers ? { ...options.headers } : void 0,
9226
+ auth
9227
+ };
9228
+ }
8090
9229
  var RegistryNavigator = class {
8091
9230
  constructor(registry) {
8092
9231
  this.registry = registry;
@@ -8138,12 +9277,22 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
8138
9277
  backend: input.options?.backend,
8139
9278
  client: input.options?.client,
8140
9279
  headers: input.options?.headers,
9280
+ forceNoCache: input.options?.forceNoCache,
9281
+ userId: input.options?.userId,
9282
+ organizationId: input.options?.organizationId,
9283
+ auth: input.options?.auth,
9284
+ tenantKeyMap,
9285
+ tenantContext,
8141
9286
  experimental: input.options?.experimental
8142
9287
  };
8143
9288
  this.baseClient = createClient(this.url, this.apiKey, {
8144
9289
  backend: this.clientOptions.backend,
8145
9290
  client: this.clientOptions.client,
8146
9291
  headers: this.tenantHeaderMapper.apply(this.clientOptions.headers, tenantContext),
9292
+ forceNoCache: this.clientOptions.forceNoCache,
9293
+ userId: this.clientOptions.userId,
9294
+ organizationId: this.clientOptions.organizationId,
9295
+ auth: this.clientOptions.auth,
8147
9296
  experimental: this.clientOptions.experimental
8148
9297
  });
8149
9298
  this.db = this.baseClient.db;
@@ -8161,6 +9310,40 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
8161
9310
  verifyConnection(options) {
8162
9311
  return this.baseClient.verifyConnection(options);
8163
9312
  }
9313
+ withContext(context) {
9314
+ const headers = {
9315
+ ...this.clientOptions.headers ?? {},
9316
+ ...context?.headers ?? {}
9317
+ };
9318
+ const auth = this.clientOptions.auth || context?.auth ? {
9319
+ ...this.clientOptions.auth ?? {},
9320
+ ...context?.auth ?? {},
9321
+ headers: this.clientOptions.auth?.headers || context?.auth?.headers ? {
9322
+ ...this.clientOptions.auth?.headers ?? {},
9323
+ ...context?.auth?.headers ?? {}
9324
+ } : void 0
9325
+ } : void 0;
9326
+ return new _TypedAthenaClientImpl({
9327
+ registry: this.registry,
9328
+ url: this.url,
9329
+ apiKey: this.apiKey,
9330
+ options: {
9331
+ ...this.clientOptions,
9332
+ headers: Object.keys(headers).length > 0 ? headers : void 0,
9333
+ auth,
9334
+ tenantKeyMap: this.tenantKeyMap,
9335
+ tenantContext: {
9336
+ ...this.tenantContext
9337
+ },
9338
+ ...context?.userId !== void 0 ? { userId: context.userId } : {},
9339
+ ...context?.organizationId !== void 0 ? { organizationId: context.organizationId } : {},
9340
+ ...context?.forceNoCache !== void 0 ? { forceNoCache: context.forceNoCache } : {}
9341
+ }
9342
+ });
9343
+ }
9344
+ withSession(session, options) {
9345
+ return this.withContext(resolveSessionContextOptions2(session, options));
9346
+ }
8164
9347
  withTenantContext(context) {
8165
9348
  return new _TypedAthenaClientImpl({
8166
9349
  registry: this.registry,
@@ -8221,6 +9404,77 @@ function resolveProviderSchemas(providerConfig) {
8221
9404
  return [...DEFAULT_POSTGRES_SCHEMAS];
8222
9405
  }
8223
9406
 
9407
+ // src/generator/table-selection.ts
9408
+ function normalizeTableSelector(value) {
9409
+ const trimmed = value.trim();
9410
+ return trimmed.length > 0 ? trimmed : void 0;
9411
+ }
9412
+ function normalizeTableSelection(value) {
9413
+ if (typeof value === "string") {
9414
+ return Array.from(
9415
+ new Set(
9416
+ value.split(",").map(normalizeTableSelector).filter((entry) => Boolean(entry))
9417
+ )
9418
+ );
9419
+ }
9420
+ if (Array.isArray(value)) {
9421
+ return Array.from(
9422
+ new Set(
9423
+ value.map((entry) => typeof entry === "string" ? normalizeTableSelector(entry) : void 0).filter((entry) => Boolean(entry))
9424
+ )
9425
+ );
9426
+ }
9427
+ return [];
9428
+ }
9429
+ function matchesTableSelector(schemaName, tableName, selector) {
9430
+ const separatorIndex = selector.indexOf(".");
9431
+ if (separatorIndex < 0) {
9432
+ return tableName === selector;
9433
+ }
9434
+ const selectorSchema = selector.slice(0, separatorIndex).trim();
9435
+ const selectorTable = selector.slice(separatorIndex + 1).trim();
9436
+ return selectorSchema === schemaName && selectorTable === tableName;
9437
+ }
9438
+ function shouldKeepTable(schemaName, tableName, filter) {
9439
+ const included = filter.includeTables.length === 0 || filter.includeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
9440
+ if (!included) {
9441
+ return false;
9442
+ }
9443
+ return !filter.excludeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
9444
+ }
9445
+ function hasTableFilters(filter) {
9446
+ return filter.includeTables.length > 0 || filter.excludeTables.length > 0;
9447
+ }
9448
+ function filterIntrospectionSnapshot(snapshot, filter) {
9449
+ if (!hasTableFilters(filter)) {
9450
+ return snapshot;
9451
+ }
9452
+ const schemas = {};
9453
+ for (const [schemaName, schema] of Object.entries(snapshot.schemas)) {
9454
+ const tables = Object.fromEntries(
9455
+ Object.entries(schema.tables).filter(([tableName]) => shouldKeepTable(schemaName, tableName, filter))
9456
+ );
9457
+ if (Object.keys(tables).length === 0) {
9458
+ continue;
9459
+ }
9460
+ schemas[schemaName] = {
9461
+ ...schema,
9462
+ tables
9463
+ };
9464
+ }
9465
+ if (Object.keys(schemas).length === 0) {
9466
+ const includeLabel = filter.includeTables.length > 0 ? ` includeTables=${filter.includeTables.join(", ")}` : "";
9467
+ const excludeLabel = filter.excludeTables.length > 0 ? ` excludeTables=${filter.excludeTables.join(", ")}` : "";
9468
+ throw new Error(
9469
+ `Generator table filters matched no tables after schema selection.${includeLabel}${excludeLabel}`
9470
+ );
9471
+ }
9472
+ return {
9473
+ ...snapshot,
9474
+ schemas
9475
+ };
9476
+ }
9477
+
8224
9478
  // src/generator/env.ts
8225
9479
  function readEnvStringValue(key) {
8226
9480
  if (typeof process === "undefined" || !process.env) {
@@ -8879,7 +10133,12 @@ async function runSchemaGenerator(options = {}) {
8879
10133
  return throwBrowserUnsupported("runSchemaGenerator");
8880
10134
  }
8881
10135
 
10136
+ exports.ATHENA_AUTH_ADMIN_LIMITS = ATHENA_AUTH_ADMIN_LIMITS;
8882
10137
  exports.ATHENA_AUTH_BASE_ERROR_CODES = ATHENA_AUTH_BASE_ERROR_CODES;
10138
+ exports.ATHENA_AUTH_MAX_ADMIN_JSON_BYTES = ATHENA_AUTH_MAX_ADMIN_JSON_BYTES;
10139
+ exports.ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH = ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH;
10140
+ exports.ATHENA_AUTH_MAX_TEMPLATE_VARIABLES = ATHENA_AUTH_MAX_TEMPLATE_VARIABLES;
10141
+ exports.ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH = ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH;
8883
10142
  exports.AthenaClient = AthenaClient;
8884
10143
  exports.AthenaError = AthenaError;
8885
10144
  exports.AthenaErrorCategory = AthenaErrorCategory;
@@ -8909,6 +10168,7 @@ exports.defineModel = defineModel;
8909
10168
  exports.defineRegistry = defineRegistry;
8910
10169
  exports.defineSchema = defineSchema;
8911
10170
  exports.enumeration = enumeration;
10171
+ exports.filterIntrospectionSnapshot = filterIntrospectionSnapshot;
8912
10172
  exports.findGeneratorConfigPath = findGeneratorConfigPath;
8913
10173
  exports.generateArtifactsFromSnapshot = generateArtifactsFromSnapshot;
8914
10174
  exports.generatorEnv = generatorEnv;
@@ -8922,6 +10182,7 @@ exports.normalizeAthenaError = normalizeAthenaError;
8922
10182
  exports.normalizeAthenaGatewayBaseUrl = normalizeAthenaGatewayBaseUrl;
8923
10183
  exports.normalizeGeneratorConfig = normalizeGeneratorConfig;
8924
10184
  exports.normalizeSchemaSelection = normalizeSchemaSelection;
10185
+ exports.normalizeTableSelection = normalizeTableSelection;
8925
10186
  exports.number = number;
8926
10187
  exports.parseBooleanFlag = parseBooleanFlag2;
8927
10188
  exports.renderAthenaReactEmail = renderAthenaReactEmail;