@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/index.js CHANGED
@@ -804,7 +804,7 @@ var getCookieCache = async (request, config) => {
804
804
 
805
805
  // package.json
806
806
  var package_default = {
807
- version: "2.8.0"
807
+ version: "2.9.0"
808
808
  };
809
809
 
810
810
  // src/sdk-version.ts
@@ -817,6 +817,7 @@ function buildSdkHeaderValue(sdkName) {
817
817
  var DEFAULT_CLIENT = "railway_direct";
818
818
  var SDK_NAME = "xylex-group/athena";
819
819
  var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
820
+ var NO_CACHE_HEADER_VALUE = "no-cache";
820
821
  function parseResponseBody(rawText, contentType) {
821
822
  if (!rawText) {
822
823
  return { parsed: null, parseFailed: false };
@@ -835,6 +836,9 @@ function parseResponseBody(rawText, contentType) {
835
836
  function normalizeHeaderValue(value) {
836
837
  return value ? value : void 0;
837
838
  }
839
+ function isCacheControlHeaderName(name) {
840
+ return name.toLowerCase() === "cache-control";
841
+ }
838
842
  function resolveHeaderValue(headers, candidates) {
839
843
  for (const candidate of candidates) {
840
844
  const direct = normalizeHeaderValue(headers[candidate]);
@@ -993,6 +997,7 @@ function buildRpcGetEndpoint(payload) {
993
997
  }
994
998
  function buildHeaders(config, options) {
995
999
  const mergedStripNulls = options?.stripNulls ?? true;
1000
+ const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
996
1001
  const extraHeaders = {
997
1002
  ...config.headers ?? {},
998
1003
  ...options?.headers ?? {}
@@ -1046,11 +1051,15 @@ function buildHeaders(config, options) {
1046
1051
  const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
1047
1052
  Object.entries(extraHeaders).forEach(([key, value]) => {
1048
1053
  if (athenaClientKeys.includes(key)) return;
1054
+ if (forceNoCache && isCacheControlHeaderName(key)) return;
1049
1055
  const normalized = normalizeHeaderValue(value);
1050
1056
  if (normalized) {
1051
1057
  headers[key] = normalized;
1052
1058
  }
1053
1059
  });
1060
+ if (forceNoCache) {
1061
+ headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
1062
+ }
1054
1063
  return headers;
1055
1064
  }
1056
1065
  function toInvalidUrlResponse(error, endpoint, method) {
@@ -1511,6 +1520,45 @@ function identifier(...segments) {
1511
1520
  return new SqlIdentifierPath(expandedSegments);
1512
1521
  }
1513
1522
 
1523
+ // src/auth/limits.ts
1524
+ var ATHENA_AUTH_MAX_ADMIN_JSON_BYTES = 32 * 1024;
1525
+ var ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH = 8;
1526
+ var ATHENA_AUTH_MAX_TEMPLATE_VARIABLES = 64;
1527
+ var ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH = 128;
1528
+ var ATHENA_AUTH_ADMIN_LIMITS = {
1529
+ maxAdminJsonBytes: ATHENA_AUTH_MAX_ADMIN_JSON_BYTES,
1530
+ maxAdminJsonDepth: ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH,
1531
+ maxTemplateVariables: ATHENA_AUTH_MAX_TEMPLATE_VARIABLES,
1532
+ maxTemplateVariableLength: ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH
1533
+ };
1534
+ function describeTemplateVariableTarget(target) {
1535
+ const normalized = target?.trim();
1536
+ return normalized && normalized.length > 0 ? normalized : "Athena auth admin email template variables";
1537
+ }
1538
+ function assertAthenaAuthTemplateVariables(variables, target) {
1539
+ const label = describeTemplateVariableTarget(target);
1540
+ if (!Array.isArray(variables)) {
1541
+ throw new Error(`${label} must be an array of strings.`);
1542
+ }
1543
+ if (variables.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLES) {
1544
+ throw new Error(
1545
+ `${label} cannot contain more than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLES} entries.`
1546
+ );
1547
+ }
1548
+ variables.forEach((variable, index) => {
1549
+ if (typeof variable !== "string") {
1550
+ throw new Error(
1551
+ `${label} must contain only strings. Received ${typeof variable} at index ${index}.`
1552
+ );
1553
+ }
1554
+ if (variable.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH) {
1555
+ throw new Error(
1556
+ `${label} cannot contain entries longer than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH} characters. Received ${variable.length} characters at index ${index}.`
1557
+ );
1558
+ }
1559
+ });
1560
+ }
1561
+
1514
1562
  // src/auth/react-email.ts
1515
1563
  var reactEmailRenderModulePromise;
1516
1564
  function isRecord2(value) {
@@ -1740,6 +1788,7 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
1740
1788
  var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
1741
1789
  var SDK_NAME2 = "xylex-group/athena-auth";
1742
1790
  var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
1791
+ var NO_CACHE_HEADER_VALUE2 = "no-cache";
1743
1792
  function normalizeBaseUrl(baseUrl) {
1744
1793
  return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
1745
1794
  }
@@ -1749,6 +1798,9 @@ function isRecord3(value) {
1749
1798
  function normalizeHeaderValue2(value) {
1750
1799
  return value ? value : void 0;
1751
1800
  }
1801
+ function isCacheControlHeaderName2(name) {
1802
+ return name.toLowerCase() === "cache-control";
1803
+ }
1752
1804
  function parseResponseBody2(rawText, contentType) {
1753
1805
  if (!rawText) {
1754
1806
  return { parsed: null, parseFailed: false };
@@ -1804,6 +1856,54 @@ function mergeCallOptions(base, override) {
1804
1856
  }
1805
1857
  };
1806
1858
  }
1859
+ function toSessionGuardFailure(sessionResult) {
1860
+ if (sessionResult.status === 401 || sessionResult.data == null) {
1861
+ return {
1862
+ ok: false,
1863
+ reason: "unauthorized",
1864
+ status: 401,
1865
+ error: sessionResult.error ?? "Unauthorized",
1866
+ sessionResult
1867
+ };
1868
+ }
1869
+ return {
1870
+ ok: false,
1871
+ reason: "upstream_error",
1872
+ status: sessionResult.status,
1873
+ error: sessionResult.error ?? "Failed to resolve current session",
1874
+ sessionResult
1875
+ };
1876
+ }
1877
+ function toPermissionGuardFailure(permissionResult, sessionResult) {
1878
+ if (permissionResult.status === 401) {
1879
+ return {
1880
+ ok: false,
1881
+ reason: "unauthorized",
1882
+ status: 401,
1883
+ error: permissionResult.error ?? "Unauthorized",
1884
+ sessionResult,
1885
+ permissionResult
1886
+ };
1887
+ }
1888
+ if (permissionResult.status === 403) {
1889
+ return {
1890
+ ok: false,
1891
+ reason: "forbidden",
1892
+ status: 403,
1893
+ error: permissionResult.error ?? "Forbidden",
1894
+ sessionResult,
1895
+ permissionResult
1896
+ };
1897
+ }
1898
+ return {
1899
+ ok: false,
1900
+ reason: "upstream_error",
1901
+ status: permissionResult.status,
1902
+ error: permissionResult.error ?? "Failed to resolve permission check",
1903
+ sessionResult,
1904
+ permissionResult
1905
+ };
1906
+ }
1807
1907
  function extractFetchOptions(input) {
1808
1908
  if (!input) {
1809
1909
  return {
@@ -1819,6 +1919,7 @@ function extractFetchOptions(input) {
1819
1919
  };
1820
1920
  }
1821
1921
  function buildHeaders2(config, options) {
1922
+ const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
1822
1923
  const headers = {
1823
1924
  "Content-Type": "application/json",
1824
1925
  "X-Athena-Sdk": SDK_HEADER_VALUE2
@@ -1832,16 +1933,30 @@ function buildHeaders2(config, options) {
1832
1933
  if (bearerToken) {
1833
1934
  headers.Authorization = `Bearer ${bearerToken}`;
1834
1935
  }
1936
+ const cookie = options?.cookie ?? config.cookie;
1937
+ if (cookie) {
1938
+ headers.Cookie = cookie;
1939
+ }
1940
+ const sessionToken = options?.sessionToken ?? config.sessionToken;
1941
+ if (sessionToken) {
1942
+ headers["X-Athena-Auth-Session-Token"] = sessionToken;
1943
+ }
1835
1944
  const mergedExtraHeaders = {
1836
1945
  ...config.headers ?? {},
1837
1946
  ...options?.headers ?? {}
1838
1947
  };
1839
1948
  Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
1949
+ if (forceNoCache && isCacheControlHeaderName2(key)) {
1950
+ return;
1951
+ }
1840
1952
  const normalized = normalizeHeaderValue2(value);
1841
1953
  if (normalized) {
1842
1954
  headers[key] = normalized;
1843
1955
  }
1844
1956
  });
1957
+ if (forceNoCache) {
1958
+ headers["Cache-Control"] = NO_CACHE_HEADER_VALUE2;
1959
+ }
1845
1960
  return headers;
1846
1961
  }
1847
1962
  function appendQueryParam(searchParams, key, value) {
@@ -2106,7 +2221,91 @@ function createAuthClient(config = {}) {
2106
2221
  htmlField: "htmlTemplate",
2107
2222
  textField: "textTemplate",
2108
2223
  variablesField: "variables"
2109
- }, withReactEmailRoute(route));
2224
+ }, withReactEmailRoute(route)).then((payload) => {
2225
+ if ("variables" in payload && payload.variables !== void 0 && payload.variables !== null) {
2226
+ assertAthenaAuthTemplateVariables(
2227
+ payload.variables,
2228
+ `${route} variables`
2229
+ );
2230
+ }
2231
+ return payload;
2232
+ });
2233
+ const requireSession = async (input, options) => {
2234
+ const sessionInput = input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0;
2235
+ const sessionResult = await getGeneric(
2236
+ "/get-session",
2237
+ sessionInput,
2238
+ options
2239
+ );
2240
+ if (!sessionResult.ok || sessionResult.data == null) {
2241
+ return toSessionGuardFailure(sessionResult);
2242
+ }
2243
+ return {
2244
+ ok: true,
2245
+ session: sessionResult.data
2246
+ };
2247
+ };
2248
+ const getUser = async (input, options) => {
2249
+ const sessionResult = await getGeneric(
2250
+ "/get-session",
2251
+ input,
2252
+ options
2253
+ );
2254
+ if (!sessionResult.ok) {
2255
+ return {
2256
+ ...sessionResult,
2257
+ data: null
2258
+ };
2259
+ }
2260
+ return {
2261
+ ...sessionResult,
2262
+ data: {
2263
+ user: sessionResult.data?.user ?? null
2264
+ }
2265
+ };
2266
+ };
2267
+ const requirePermission = async (endpoint, input, options) => {
2268
+ const sessionGuard = await requireSession(
2269
+ input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0,
2270
+ options
2271
+ );
2272
+ if (!sessionGuard.ok) {
2273
+ return sessionGuard;
2274
+ }
2275
+ const permissionResult = await postGeneric(
2276
+ endpoint,
2277
+ input,
2278
+ options
2279
+ );
2280
+ if (!permissionResult.ok) {
2281
+ return toPermissionGuardFailure(permissionResult, {
2282
+ ok: true,
2283
+ status: 200,
2284
+ data: sessionGuard.session,
2285
+ error: null,
2286
+ errorDetails: null,
2287
+ raw: sessionGuard.session
2288
+ });
2289
+ }
2290
+ if (!permissionResult.data?.success) {
2291
+ return {
2292
+ ok: false,
2293
+ reason: "forbidden",
2294
+ status: 403,
2295
+ error: permissionResult.data?.error ?? "Forbidden",
2296
+ sessionResult: {
2297
+ ok: true,
2298
+ status: 200,
2299
+ data: sessionGuard.session,
2300
+ error: null,
2301
+ errorDetails: null,
2302
+ raw: sessionGuard.session
2303
+ },
2304
+ permissionResult
2305
+ };
2306
+ }
2307
+ return sessionGuard;
2308
+ };
2110
2309
  const listUserEmailsWithFallback = async (input, options) => {
2111
2310
  const primary = await getWithQuery(
2112
2311
  "/email/list",
@@ -2268,6 +2467,7 @@ function createAuthClient(config = {}) {
2268
2467
  input,
2269
2468
  options
2270
2469
  ),
2470
+ requirePermission: (input, options) => requirePermission("/organization/has-permission", input, options),
2271
2471
  invitation: {
2272
2472
  cancel: (input, options) => executePostWithCompatibleInput(
2273
2473
  resolvedConfig,
@@ -2463,6 +2663,8 @@ function createAuthClient(config = {}) {
2463
2663
  };
2464
2664
  const auth = {
2465
2665
  getSession: (input, options) => getGeneric("/get-session", input, options),
2666
+ getUser,
2667
+ requireSession,
2466
2668
  signOut,
2467
2669
  forgetPassword: (input, options) => postGeneric("/forget-password", input, options),
2468
2670
  resetPassword: authResetPassword,
@@ -2557,6 +2759,7 @@ function createAuthClient(config = {}) {
2557
2759
  }
2558
2760
  },
2559
2761
  hasPermission: (input, options) => postGeneric("/admin/has-permission", input, options),
2762
+ requirePermission: (input, options) => requirePermission("/admin/has-permission", input, options),
2560
2763
  apiKey: {
2561
2764
  create: (input, options) => postGeneric("/admin/api-key/create", input, options)
2562
2765
  },
@@ -2708,6 +2911,8 @@ function createAuthClient(config = {}) {
2708
2911
  input,
2709
2912
  options
2710
2913
  ),
2914
+ getUser,
2915
+ requireSession,
2711
2916
  listSessions: (input, options) => executeGetWithCompatibleInput(
2712
2917
  resolvedConfig,
2713
2918
  { endpoint: "/list-sessions", method: "GET" },
@@ -3400,7 +3605,12 @@ function createStorageFileModule(base, config = {}) {
3400
3605
  content_type: input.content_type ?? source.contentType,
3401
3606
  size_bytes: source.sizeBytes,
3402
3607
  public: input.public,
3403
- metadata: input.metadata
3608
+ metadata: input.metadata,
3609
+ server_side_encryption: input.server_side_encryption,
3610
+ sse: input.sse,
3611
+ ssekms_key_id: input.ssekms_key_id,
3612
+ kms_key_id: input.kms_key_id,
3613
+ bucket_key_enabled: input.bucket_key_enabled
3404
3614
  }
3405
3615
  };
3406
3616
  });
@@ -3411,10 +3621,17 @@ function createStorageFileModule(base, config = {}) {
3411
3621
  for (let index = 0; index < uploadRequests.length; index += 1) {
3412
3622
  const request = uploadRequests[index];
3413
3623
  const uploadUrl = uploadUrls[index];
3414
- const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
3415
- aggregateLoaded[index] = progress.loaded;
3416
- input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3417
- });
3624
+ const response = await putUploadBody(
3625
+ uploadUrl.upload.url,
3626
+ uploadUrl.upload.headers ?? {},
3627
+ request.source,
3628
+ input,
3629
+ options,
3630
+ (progress) => {
3631
+ aggregateLoaded[index] = progress.loaded;
3632
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3633
+ }
3634
+ );
3418
3635
  uploaded.push({
3419
3636
  file: uploadUrl.file,
3420
3637
  upload: uploadUrl.upload,
@@ -3517,8 +3734,9 @@ function validateUploadConstraints(sources, input) {
3517
3734
  }
3518
3735
  }
3519
3736
  }
3520
- async function putUploadBody(url, source, input, options, onProgress) {
3521
- const headers = new Headers(input.uploadHeaders);
3737
+ async function putUploadBody(url, uploadHeaders, source, input, options, onProgress) {
3738
+ const headers = new Headers(uploadHeaders);
3739
+ new Headers(input.uploadHeaders).forEach((value, key) => headers.set(key, value));
3522
3740
  if (source.contentType && !headers.has("Content-Type")) {
3523
3741
  headers.set("Content-Type", source.contentType);
3524
3742
  }
@@ -3835,29 +4053,524 @@ var storageSdkManifest = {
3835
4053
  responseType: "StorageFileMutationResponse"
3836
4054
  },
3837
4055
  {
3838
- name: "setStorageFileVisibility",
3839
- method: "PATCH",
3840
- path: "/storage/files/{file_id}/visibility",
3841
- pathParams: ["file_id"],
3842
- requestType: "SetStorageFileVisibilityRequest",
4056
+ name: "setStorageFileVisibility",
4057
+ method: "PATCH",
4058
+ path: "/storage/files/{file_id}/visibility",
4059
+ pathParams: ["file_id"],
4060
+ requestType: "SetStorageFileVisibilityRequest",
4061
+ responseEnvelope: "athena",
4062
+ responseType: "StorageFileMutationResponse"
4063
+ },
4064
+ {
4065
+ name: "postStorageFileVisibility",
4066
+ method: "POST",
4067
+ path: "/storage/files/{file_id}/visibility",
4068
+ pathParams: ["file_id"],
4069
+ requestType: "SetStorageFileVisibilityRequest",
4070
+ responseEnvelope: "athena",
4071
+ responseType: "StorageFileMutationResponse"
4072
+ },
4073
+ {
4074
+ name: "setManyStorageFileVisibility",
4075
+ method: "POST",
4076
+ path: "/storage/files/visibility-many",
4077
+ requestType: "SetManyStorageFileVisibilityRequest",
4078
+ responseEnvelope: "athena",
4079
+ responseType: "StorageFileMutationManyResponse"
4080
+ },
4081
+ {
4082
+ name: "deleteStorageFolder",
4083
+ method: "POST",
4084
+ path: "/storage/folders/delete",
4085
+ requestType: "DeleteStorageFolderRequest",
4086
+ responseEnvelope: "athena",
4087
+ responseType: "StorageFolderMutationResponse"
4088
+ },
4089
+ {
4090
+ name: "moveStorageFolder",
4091
+ method: "POST",
4092
+ path: "/storage/folders/move",
4093
+ requestType: "MoveStorageFolderRequest",
4094
+ responseEnvelope: "athena",
4095
+ responseType: "StorageFolderMutationResponse"
4096
+ },
4097
+ {
4098
+ name: "searchStorageFiles",
4099
+ method: "POST",
4100
+ path: "/storage/files/search",
4101
+ requestType: "SearchStorageFilesRequest",
4102
+ responseEnvelope: "athena",
4103
+ responseType: "StorageListFilesResponse"
4104
+ },
4105
+ {
4106
+ name: "confirmStorageUpload",
4107
+ method: "POST",
4108
+ path: "/storage/files/{file_id}/confirm-upload",
4109
+ pathParams: ["file_id"],
4110
+ requestType: "ConfirmStorageUploadRequest",
4111
+ responseEnvelope: "athena",
4112
+ responseType: "StorageFileMutationResponse"
4113
+ },
4114
+ {
4115
+ name: "uploadStorageFileBinary",
4116
+ method: "PUT",
4117
+ path: "/storage/files/{file_id}/upload",
4118
+ pathParams: ["file_id"],
4119
+ responseEnvelope: "athena",
4120
+ responseType: "StorageFileMutationResponse",
4121
+ binary: true
4122
+ },
4123
+ {
4124
+ name: "copyStorageFile",
4125
+ method: "POST",
4126
+ path: "/storage/files/{file_id}/copy",
4127
+ pathParams: ["file_id"],
4128
+ requestType: "CopyStorageFileRequest",
4129
+ responseEnvelope: "athena",
4130
+ responseType: "StorageFileMutationResponse"
4131
+ },
4132
+ {
4133
+ name: "deleteManyStorageFiles",
4134
+ method: "POST",
4135
+ path: "/storage/files/delete-many",
4136
+ requestType: "DeleteManyStorageFilesRequest",
4137
+ responseEnvelope: "athena",
4138
+ responseType: "StorageFileMutationManyResponse"
4139
+ },
4140
+ {
4141
+ name: "updateManyStorageFiles",
4142
+ method: "POST",
4143
+ path: "/storage/files/update-many",
4144
+ requestType: "UpdateManyStorageFilesRequest",
4145
+ responseEnvelope: "athena",
4146
+ responseType: "StorageFileMutationManyResponse"
4147
+ },
4148
+ {
4149
+ name: "restoreStorageFile",
4150
+ method: "POST",
4151
+ path: "/storage/files/{file_id}/restore",
4152
+ pathParams: ["file_id"],
4153
+ responseEnvelope: "athena",
4154
+ responseType: "StorageFileMutationResponse"
4155
+ },
4156
+ {
4157
+ name: "purgeStorageFile",
4158
+ method: "DELETE",
4159
+ path: "/storage/files/{file_id}/purge",
4160
+ pathParams: ["file_id"],
4161
+ responseEnvelope: "athena",
4162
+ responseType: "StorageFileMutationResponse"
4163
+ },
4164
+ {
4165
+ name: "getStorageFilePublicUrl",
4166
+ method: "GET",
4167
+ path: "/storage/files/{file_id}/public-url",
4168
+ pathParams: ["file_id"],
4169
+ responseEnvelope: "athena",
4170
+ responseType: "Record<string, unknown>"
4171
+ },
4172
+ {
4173
+ name: "getStorageFileProxyUrl",
4174
+ method: "GET",
4175
+ path: "/storage/files/{file_id}/proxy-url",
4176
+ pathParams: ["file_id"],
4177
+ queryParams: ["purpose"],
4178
+ responseEnvelope: "athena",
4179
+ responseType: "Record<string, unknown>"
4180
+ },
4181
+ {
4182
+ name: "listStorageFileVersions",
4183
+ method: "GET",
4184
+ path: "/storage/files/{file_id}/versions",
4185
+ pathParams: ["file_id"],
4186
+ responseEnvelope: "athena",
4187
+ responseType: "Record<string, unknown>"
4188
+ },
4189
+ {
4190
+ name: "restoreStorageFileVersion",
4191
+ method: "POST",
4192
+ path: "/storage/files/{file_id}/versions/{version_id}/restore",
4193
+ pathParams: ["file_id", "version_id"],
4194
+ responseEnvelope: "athena",
4195
+ responseType: "Record<string, unknown>"
4196
+ },
4197
+ {
4198
+ name: "deleteStorageFileVersion",
4199
+ method: "DELETE",
4200
+ path: "/storage/files/{file_id}/versions/{version_id}",
4201
+ pathParams: ["file_id", "version_id"],
4202
+ responseEnvelope: "athena",
4203
+ responseType: "Record<string, unknown>"
4204
+ },
4205
+ {
4206
+ name: "getStorageFileRetention",
4207
+ method: "GET",
4208
+ path: "/storage/files/{file_id}/retention",
4209
+ pathParams: ["file_id"],
4210
+ queryParams: ["version_id"],
4211
+ responseEnvelope: "athena",
4212
+ responseType: "Record<string, unknown>"
4213
+ },
4214
+ {
4215
+ name: "setStorageFileRetention",
4216
+ method: "POST",
4217
+ path: "/storage/files/{file_id}/retention",
4218
+ pathParams: ["file_id"],
4219
+ requestType: "StorageFileRetentionRequest",
4220
+ responseEnvelope: "athena",
4221
+ responseType: "Record<string, unknown>"
4222
+ },
4223
+ {
4224
+ name: "listStorageFolders",
4225
+ method: "POST",
4226
+ path: "/storage/folders/list",
4227
+ requestType: "ListStorageFoldersRequest",
4228
+ responseEnvelope: "athena",
4229
+ responseType: "Record<string, unknown>"
4230
+ },
4231
+ {
4232
+ name: "treeStorageFolders",
4233
+ method: "POST",
4234
+ path: "/storage/folders/tree",
4235
+ requestType: "TreeStorageFoldersRequest",
4236
+ responseEnvelope: "athena",
4237
+ responseType: "Record<string, unknown>"
4238
+ },
4239
+ {
4240
+ name: "listStoragePermissions",
4241
+ method: "POST",
4242
+ path: "/storage/permissions/list",
4243
+ requestType: "StoragePermissionListRequest",
4244
+ responseEnvelope: "athena",
4245
+ responseType: "StoragePermissionListResponse"
4246
+ },
4247
+ {
4248
+ name: "grantStoragePermission",
4249
+ method: "POST",
4250
+ path: "/storage/permissions/grant",
4251
+ requestType: "StoragePermissionGrantRequest",
4252
+ responseEnvelope: "athena",
4253
+ responseType: "Record<string, unknown>"
4254
+ },
4255
+ {
4256
+ name: "revokeStoragePermission",
4257
+ method: "POST",
4258
+ path: "/storage/permissions/revoke",
4259
+ requestType: "StoragePermissionRevokeRequest",
4260
+ responseEnvelope: "athena",
4261
+ responseType: "Record<string, unknown>"
4262
+ },
4263
+ {
4264
+ name: "checkStoragePermission",
4265
+ method: "POST",
4266
+ path: "/storage/permissions/check",
4267
+ requestType: "StoragePermissionCheckRequest",
4268
+ responseEnvelope: "athena",
4269
+ responseType: "StoragePermissionCheckResponse"
4270
+ },
4271
+ {
4272
+ name: "listStorageObjects",
4273
+ method: "POST",
4274
+ path: "/storage/objects",
4275
+ requestType: "StorageListObjectsRequest",
4276
+ responseEnvelope: "athena",
4277
+ responseType: "Record<string, unknown>"
4278
+ },
4279
+ {
4280
+ name: "headStorageObject",
4281
+ method: "POST",
4282
+ path: "/storage/objects/head",
4283
+ requestType: "StorageObjectRequest",
4284
+ responseEnvelope: "athena",
4285
+ responseType: "Record<string, unknown>"
4286
+ },
4287
+ {
4288
+ name: "existsStorageObject",
4289
+ method: "POST",
4290
+ path: "/storage/objects/exists",
4291
+ requestType: "StorageObjectRequest",
4292
+ responseEnvelope: "athena",
4293
+ responseType: "Record<string, unknown>"
4294
+ },
4295
+ {
4296
+ name: "validateStorageObject",
4297
+ method: "POST",
4298
+ path: "/storage/objects/validate",
4299
+ requestType: "StorageObjectValidateRequest",
4300
+ responseEnvelope: "athena",
4301
+ responseType: "Record<string, unknown>"
4302
+ },
4303
+ {
4304
+ name: "updateStorageObject",
4305
+ method: "POST",
4306
+ path: "/storage/objects/update",
4307
+ requestType: "StorageUpdateObjectRequest",
4308
+ responseEnvelope: "athena",
4309
+ responseType: "Record<string, unknown>"
4310
+ },
4311
+ {
4312
+ name: "copyStorageObject",
4313
+ method: "POST",
4314
+ path: "/storage/objects/copy",
4315
+ requestType: "StorageObjectCopyRequest",
4316
+ responseEnvelope: "athena",
4317
+ responseType: "Record<string, unknown>"
4318
+ },
4319
+ {
4320
+ name: "getStorageObjectUrl",
4321
+ method: "POST",
4322
+ path: "/storage/objects/url",
4323
+ requestType: "StorageObjectRequest",
4324
+ responseEnvelope: "athena",
4325
+ responseType: "Record<string, unknown>"
4326
+ },
4327
+ {
4328
+ name: "getStorageObjectPublicUrl",
4329
+ method: "POST",
4330
+ path: "/storage/objects/public-url",
4331
+ requestType: "StorageObjectPublicUrlRequest",
4332
+ responseEnvelope: "athena",
4333
+ responseType: "Record<string, unknown>"
4334
+ },
4335
+ {
4336
+ name: "deleteStorageObject",
4337
+ method: "POST",
4338
+ path: "/storage/objects/delete",
4339
+ requestType: "StorageObjectRequest",
4340
+ responseEnvelope: "athena",
4341
+ responseType: "Record<string, unknown>"
4342
+ },
4343
+ {
4344
+ name: "createStorageObjectUploadUrl",
4345
+ method: "POST",
4346
+ path: "/storage/objects/upload-url",
4347
+ requestType: "StoragePresignUploadRequest",
4348
+ responseEnvelope: "athena",
4349
+ responseType: "Record<string, unknown>"
4350
+ },
4351
+ {
4352
+ name: "createStorageObjectPostPolicy",
4353
+ method: "POST",
4354
+ path: "/storage/objects/post-policy",
4355
+ requestType: "StorageSignedPostPolicyRequest",
4356
+ responseEnvelope: "athena",
4357
+ responseType: "Record<string, unknown>"
4358
+ },
4359
+ {
4360
+ name: "listStorageObjectVersions",
4361
+ method: "POST",
4362
+ path: "/storage/objects/versions",
4363
+ requestType: "StorageObjectVersionListRequest",
4364
+ responseEnvelope: "athena",
4365
+ responseType: "Record<string, unknown>"
4366
+ },
4367
+ {
4368
+ name: "restoreStorageObjectVersion",
4369
+ method: "POST",
4370
+ path: "/storage/objects/versions/restore",
4371
+ requestType: "StorageObjectVersionMutationRequest",
4372
+ responseEnvelope: "athena",
4373
+ responseType: "Record<string, unknown>"
4374
+ },
4375
+ {
4376
+ name: "deleteStorageObjectVersion",
4377
+ method: "POST",
4378
+ path: "/storage/objects/versions/delete",
4379
+ requestType: "StorageObjectVersionMutationRequest",
4380
+ responseEnvelope: "athena",
4381
+ responseType: "Record<string, unknown>"
4382
+ },
4383
+ {
4384
+ name: "createStorageObjectFolder",
4385
+ method: "POST",
4386
+ path: "/storage/objects/folder",
4387
+ requestType: "StorageObjectFolderCreateRequest",
4388
+ responseEnvelope: "athena",
4389
+ responseType: "Record<string, unknown>"
4390
+ },
4391
+ {
4392
+ name: "deleteStorageObjectFolder",
4393
+ method: "POST",
4394
+ path: "/storage/objects/folder/delete",
4395
+ requestType: "StorageObjectFolderDeleteRequest",
4396
+ responseEnvelope: "athena",
4397
+ responseType: "Record<string, unknown>"
4398
+ },
4399
+ {
4400
+ name: "renameStorageObjectFolder",
4401
+ method: "POST",
4402
+ path: "/storage/objects/folder/rename",
4403
+ requestType: "StorageObjectFolderRenameRequest",
4404
+ responseEnvelope: "athena",
4405
+ responseType: "Record<string, unknown>"
4406
+ },
4407
+ {
4408
+ name: "listStorageBuckets",
4409
+ method: "POST",
4410
+ path: "/storage/buckets/list",
4411
+ requestType: "Omit<StorageObjectBaseRequest, 'bucket'>",
4412
+ responseEnvelope: "athena",
4413
+ responseType: "Record<string, unknown>"
4414
+ },
4415
+ {
4416
+ name: "createStorageBucket",
4417
+ method: "POST",
4418
+ path: "/storage/buckets/create",
4419
+ requestType: "StorageObjectBaseRequest",
4420
+ responseEnvelope: "athena",
4421
+ responseType: "Record<string, unknown>"
4422
+ },
4423
+ {
4424
+ name: "deleteStorageBucket",
4425
+ method: "POST",
4426
+ path: "/storage/buckets/delete",
4427
+ requestType: "StorageObjectBaseRequest",
4428
+ responseEnvelope: "athena",
4429
+ responseType: "Record<string, unknown>"
4430
+ },
4431
+ {
4432
+ name: "getStorageBucketLifecycle",
4433
+ method: "POST",
4434
+ path: "/storage/buckets/lifecycle",
4435
+ requestType: "StorageBucketLifecycleRequest",
4436
+ responseEnvelope: "athena",
4437
+ responseType: "Record<string, unknown>"
4438
+ },
4439
+ {
4440
+ name: "setStorageBucketLifecycle",
4441
+ method: "POST",
4442
+ path: "/storage/buckets/lifecycle/set",
4443
+ requestType: "StorageSetBucketLifecycleRequest",
4444
+ responseEnvelope: "athena",
4445
+ responseType: "Record<string, unknown>"
4446
+ },
4447
+ {
4448
+ name: "deleteStorageBucketLifecycle",
4449
+ method: "POST",
4450
+ path: "/storage/buckets/lifecycle/delete",
4451
+ requestType: "StorageBucketLifecycleRequest",
4452
+ responseEnvelope: "athena",
4453
+ responseType: "Record<string, unknown>"
4454
+ },
4455
+ {
4456
+ name: "getStorageBucketPolicy",
4457
+ method: "POST",
4458
+ path: "/storage/buckets/policy",
4459
+ requestType: "StorageBucketPolicyRequest",
4460
+ responseEnvelope: "athena",
4461
+ responseType: "Record<string, unknown>"
4462
+ },
4463
+ {
4464
+ name: "setStorageBucketPolicy",
4465
+ method: "POST",
4466
+ path: "/storage/buckets/policy/set",
4467
+ requestType: "StorageSetBucketPolicyRequest",
4468
+ responseEnvelope: "athena",
4469
+ responseType: "Record<string, unknown>"
4470
+ },
4471
+ {
4472
+ name: "deleteStorageBucketPolicy",
4473
+ method: "POST",
4474
+ path: "/storage/buckets/policy/delete",
4475
+ requestType: "StorageBucketPolicyRequest",
4476
+ responseEnvelope: "athena",
4477
+ responseType: "Record<string, unknown>"
4478
+ },
4479
+ {
4480
+ name: "getStorageBucketPublicAccess",
4481
+ method: "POST",
4482
+ path: "/storage/buckets/public-access",
4483
+ requestType: "StoragePublicAccessBlockRequest",
4484
+ responseEnvelope: "athena",
4485
+ responseType: "Record<string, unknown>"
4486
+ },
4487
+ {
4488
+ name: "setStorageBucketPublicAccess",
4489
+ method: "POST",
4490
+ path: "/storage/buckets/public-access/set",
4491
+ requestType: "StorageSetPublicAccessBlockRequest",
4492
+ responseEnvelope: "athena",
4493
+ responseType: "Record<string, unknown>"
4494
+ },
4495
+ {
4496
+ name: "deleteStorageBucketPublicAccess",
4497
+ method: "POST",
4498
+ path: "/storage/buckets/public-access/delete",
4499
+ requestType: "StoragePublicAccessBlockRequest",
4500
+ responseEnvelope: "athena",
4501
+ responseType: "Record<string, unknown>"
4502
+ },
4503
+ {
4504
+ name: "getStorageBucketCors",
4505
+ method: "POST",
4506
+ path: "/storage/buckets/cors",
4507
+ requestType: "StorageBucketCorsRequest",
4508
+ responseEnvelope: "athena",
4509
+ responseType: "Record<string, unknown>"
4510
+ },
4511
+ {
4512
+ name: "setStorageBucketCors",
4513
+ method: "POST",
4514
+ path: "/storage/buckets/cors/set",
4515
+ requestType: "StorageSetBucketCorsRequest",
4516
+ responseEnvelope: "athena",
4517
+ responseType: "Record<string, unknown>"
4518
+ },
4519
+ {
4520
+ name: "deleteStorageBucketCors",
4521
+ method: "POST",
4522
+ path: "/storage/buckets/cors/delete",
4523
+ requestType: "StorageBucketCorsRequest",
4524
+ responseEnvelope: "athena",
4525
+ responseType: "Record<string, unknown>"
4526
+ },
4527
+ {
4528
+ name: "createStorageMultipartUpload",
4529
+ method: "POST",
4530
+ path: "/storage/multipart/create",
4531
+ requestType: "StorageMultipartCreateRequest",
4532
+ responseEnvelope: "athena",
4533
+ responseType: "Record<string, unknown>"
4534
+ },
4535
+ {
4536
+ name: "signStorageMultipartPart",
4537
+ method: "POST",
4538
+ path: "/storage/multipart/sign-part",
4539
+ requestType: "StorageMultipartSignPartRequest",
4540
+ responseEnvelope: "athena",
4541
+ responseType: "Record<string, unknown>"
4542
+ },
4543
+ {
4544
+ name: "completeStorageMultipartUpload",
4545
+ method: "POST",
4546
+ path: "/storage/multipart/complete",
4547
+ requestType: "StorageMultipartCompleteRequest",
4548
+ responseEnvelope: "athena",
4549
+ responseType: "StorageFileMutationResponse"
4550
+ },
4551
+ {
4552
+ name: "abortStorageMultipartUpload",
4553
+ method: "POST",
4554
+ path: "/storage/multipart/abort",
4555
+ requestType: "StorageMultipartAbortRequest",
3843
4556
  responseEnvelope: "athena",
3844
- responseType: "StorageFileMutationResponse"
4557
+ responseType: "Record<string, unknown>"
3845
4558
  },
3846
4559
  {
3847
- name: "deleteStorageFolder",
4560
+ name: "listStorageMultipartParts",
3848
4561
  method: "POST",
3849
- path: "/storage/folders/delete",
3850
- requestType: "DeleteStorageFolderRequest",
4562
+ path: "/storage/multipart/list-parts",
4563
+ requestType: "StorageMultipartListPartsRequest",
3851
4564
  responseEnvelope: "athena",
3852
- responseType: "StorageFolderMutationResponse"
4565
+ responseType: "Record<string, unknown>"
3853
4566
  },
3854
4567
  {
3855
- name: "moveStorageFolder",
4568
+ name: "listStorageAuditEvents",
3856
4569
  method: "POST",
3857
- path: "/storage/folders/move",
3858
- requestType: "MoveStorageFolderRequest",
4570
+ path: "/storage/audit/list",
4571
+ requestType: "StorageAuditQueryRequest",
3859
4572
  responseEnvelope: "athena",
3860
- responseType: "StorageFolderMutationResponse"
4573
+ responseType: "StorageAuditListResponse"
3861
4574
  }
3862
4575
  ]
3863
4576
  };
@@ -4318,7 +5031,7 @@ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
4318
5031
  return fetch(uploadUrl, init);
4319
5032
  }
4320
5033
  function attachManagedUpload(upload) {
4321
- const headers = {};
5034
+ const headers = { ...upload.headers ?? {} };
4322
5035
  return {
4323
5036
  ...upload,
4324
5037
  method: "PUT",
@@ -4364,7 +5077,12 @@ function normalizeUploadUrlRequest(input) {
4364
5077
  file_id: input.file_id ?? input.fileId,
4365
5078
  public: input.public,
4366
5079
  visibility: input.visibility,
4367
- metadata: input.metadata
5080
+ metadata: input.metadata,
5081
+ server_side_encryption: input.server_side_encryption,
5082
+ sse: input.sse,
5083
+ ssekms_key_id: input.ssekms_key_id,
5084
+ kms_key_id: input.kms_key_id,
5085
+ bucket_key_enabled: input.bucket_key_enabled
4368
5086
  };
4369
5087
  }
4370
5088
  async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
@@ -4515,6 +5233,12 @@ function createStorageModule(gateway, runtimeOptions) {
4515
5233
  options,
4516
5234
  resolvedRuntimeOptions
4517
5235
  );
5236
+ const callStorageFileVisibility = (fileId, method, input, options) => callAthena2(
5237
+ withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId),
5238
+ method,
5239
+ input,
5240
+ options
5241
+ );
4518
5242
  const base = {
4519
5243
  listStorageCatalogs(options) {
4520
5244
  return callRaw("/storage/catalogs", "GET", void 0, options);
@@ -4564,7 +5288,7 @@ function createStorageModule(gateway, runtimeOptions) {
4564
5288
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
4565
5289
  },
4566
5290
  setStorageFileVisibility(fileId, input, options) {
4567
- return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
5291
+ return callStorageFileVisibility(fileId, "PATCH", input, options);
4568
5292
  },
4569
5293
  deleteStorageFolder(input, options) {
4570
5294
  return callAthena2("/storage/folders/delete", "POST", input, options);
@@ -4636,13 +5360,62 @@ function createStorageModule(gateway, runtimeOptions) {
4636
5360
  publicUrl(fileId, options) {
4637
5361
  return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
4638
5362
  },
5363
+ proxyUrl(fileId, query, options) {
5364
+ const path = appendQuery(
5365
+ withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
5366
+ query
5367
+ );
5368
+ return callAthena2(path, "GET", void 0, options);
5369
+ },
4639
5370
  proxy(fileId, query, options) {
4640
5371
  return base.getStorageFileProxy(fileId, query, options);
4641
5372
  },
4642
- visibility: {
5373
+ versions(fileId, options) {
5374
+ return callAthena2(withPathParam("/storage/files/{file_id}/versions", "file_id", fileId), "GET", void 0, options);
5375
+ },
5376
+ restoreVersion(fileId, versionId, options) {
5377
+ return callAthena2(
5378
+ withPathParam(
5379
+ withPathParam("/storage/files/{file_id}/versions/{version_id}/restore", "file_id", fileId),
5380
+ "version_id",
5381
+ versionId
5382
+ ),
5383
+ "POST",
5384
+ {},
5385
+ options
5386
+ );
5387
+ },
5388
+ deleteVersion(fileId, versionId, options) {
5389
+ return callAthena2(
5390
+ withPathParam(
5391
+ withPathParam("/storage/files/{file_id}/versions/{version_id}", "file_id", fileId),
5392
+ "version_id",
5393
+ versionId
5394
+ ),
5395
+ "DELETE",
5396
+ void 0,
5397
+ options
5398
+ );
5399
+ },
5400
+ retention: {
5401
+ get(fileId, query, options) {
5402
+ const path = appendQuery(
5403
+ withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
5404
+ query
5405
+ );
5406
+ return callAthena2(path, "GET", void 0, options);
5407
+ },
4643
5408
  set(fileId, input, options) {
5409
+ return callAthena2(withPathParam("/storage/files/{file_id}/retention", "file_id", fileId), "POST", input, options);
5410
+ }
5411
+ },
5412
+ visibility: {
5413
+ update(fileId, input, options) {
4644
5414
  return base.setStorageFileVisibility(fileId, input, options);
4645
5415
  },
5416
+ set(fileId, input, options) {
5417
+ return callStorageFileVisibility(fileId, "POST", input, options);
5418
+ },
4646
5419
  setMany(input, options) {
4647
5420
  return callAthena2("/storage/files/visibility-many", "POST", input, options);
4648
5421
  }
@@ -4737,6 +5510,18 @@ function createStorageModule(gateway, runtimeOptions) {
4737
5510
  uploadUrl(input, options) {
4738
5511
  return callAthena2("/storage/objects/upload-url", "POST", input, options);
4739
5512
  },
5513
+ versions(input, options) {
5514
+ return callAthena2("/storage/objects/versions", "POST", input, options);
5515
+ },
5516
+ restoreVersion(input, options) {
5517
+ return callAthena2("/storage/objects/versions/restore", "POST", input, options);
5518
+ },
5519
+ deleteVersion(input, options) {
5520
+ return callAthena2("/storage/objects/versions/delete", "POST", input, options);
5521
+ },
5522
+ postPolicy(input, options) {
5523
+ return callAthena2("/storage/objects/post-policy", "POST", input, options);
5524
+ },
4740
5525
  folder: objectFolder
4741
5526
  };
4742
5527
  const bucket = {
@@ -4749,6 +5534,39 @@ function createStorageModule(gateway, runtimeOptions) {
4749
5534
  delete(input, options) {
4750
5535
  return callAthena2("/storage/buckets/delete", "POST", input, options);
4751
5536
  },
5537
+ lifecycle: {
5538
+ get(input, options) {
5539
+ return callAthena2("/storage/buckets/lifecycle", "POST", input, options);
5540
+ },
5541
+ set(input, options) {
5542
+ return callAthena2("/storage/buckets/lifecycle/set", "POST", input, options);
5543
+ },
5544
+ delete(input, options) {
5545
+ return callAthena2("/storage/buckets/lifecycle/delete", "POST", input, options);
5546
+ }
5547
+ },
5548
+ policy: {
5549
+ get(input, options) {
5550
+ return callAthena2("/storage/buckets/policy", "POST", input, options);
5551
+ },
5552
+ set(input, options) {
5553
+ return callAthena2("/storage/buckets/policy/set", "POST", input, options);
5554
+ },
5555
+ delete(input, options) {
5556
+ return callAthena2("/storage/buckets/policy/delete", "POST", input, options);
5557
+ }
5558
+ },
5559
+ publicAccess: {
5560
+ get(input, options) {
5561
+ return callAthena2("/storage/buckets/public-access", "POST", input, options);
5562
+ },
5563
+ set(input, options) {
5564
+ return callAthena2("/storage/buckets/public-access/set", "POST", input, options);
5565
+ },
5566
+ delete(input, options) {
5567
+ return callAthena2("/storage/buckets/public-access/delete", "POST", input, options);
5568
+ }
5569
+ },
4752
5570
  cors: {
4753
5571
  get(input, options) {
4754
5572
  return callAthena2("/storage/buckets/cors", "POST", input, options);
@@ -4850,6 +5668,9 @@ var AthenaClientBuilderImpl = class {
4850
5668
  apiKey;
4851
5669
  backendConfig = DEFAULT_BACKEND;
4852
5670
  clientName;
5671
+ defaultUserId;
5672
+ defaultOrganizationId;
5673
+ forceNoCacheEnabled = false;
4853
5674
  defaultHeaders;
4854
5675
  authConfig;
4855
5676
  dbUrlOverride;
@@ -4898,6 +5719,15 @@ var AthenaClientBuilderImpl = class {
4898
5719
  if (options.client !== void 0) {
4899
5720
  this.clientName = options.client;
4900
5721
  }
5722
+ if (options.userId !== void 0) {
5723
+ this.defaultUserId = options.userId;
5724
+ }
5725
+ if (options.organizationId !== void 0) {
5726
+ this.defaultOrganizationId = options.organizationId;
5727
+ }
5728
+ if (options.forceNoCache !== void 0) {
5729
+ this.forceNoCacheEnabled = options.forceNoCache;
5730
+ }
4901
5731
  if (options.backend !== void 0) {
4902
5732
  this.backendConfig = toBackendConfig(options.backend);
4903
5733
  }
@@ -4952,6 +5782,9 @@ var AthenaClientBuilderImpl = class {
4952
5782
  url: this.rootUrl,
4953
5783
  key: this.apiKey,
4954
5784
  client: this.clientName,
5785
+ userId: this.defaultUserId,
5786
+ organizationId: this.defaultOrganizationId,
5787
+ forceNoCache: this.forceNoCacheEnabled,
4955
5788
  backend: this.backendConfig,
4956
5789
  headers: this.defaultHeaders,
4957
5790
  db: this.dbUrlOverride ? { url: this.dbUrlOverride } : void 0,
@@ -7494,6 +8327,83 @@ function createQueryBuilder(client, formatGatewayResult, experimental, tracer) {
7494
8327
  );
7495
8328
  };
7496
8329
  }
8330
+ var ATHENA_ENV_URL_KEYS = ["ATHENA_URL", "NEXT_PUBLIC_ATHENA_URL"];
8331
+ var ATHENA_ENV_GATEWAY_URL_KEYS = [
8332
+ "ATHENA_DB_URL",
8333
+ "ATHENA_GATEWAY_URL",
8334
+ "NEXT_PUBLIC_ATHENA_DB_API_URL"
8335
+ ];
8336
+ var ATHENA_ENV_AUTH_URL_KEYS = ["ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
8337
+ var ATHENA_ENV_STORAGE_URL_KEYS = ["ATHENA_STORAGE_URL", "NEXT_PUBLIC_ATHENA_STORAGE_URL"];
8338
+ var ATHENA_ENV_KEY_KEYS = [
8339
+ "ATHENA_API_KEY",
8340
+ "NEXT_PUBLIC_ATHENA_API_KEY",
8341
+ "ATHENA_GATEWAY_API_KEY",
8342
+ "X_API_KEY"
8343
+ ];
8344
+ var ATHENA_ENV_CLIENT_KEYS = ["ATHENA_CLIENT", "NEXT_PUBLIC_ATHENA_CLIENT"];
8345
+ function normalizeOptionalString(value) {
8346
+ if (typeof value !== "string") {
8347
+ return void 0;
8348
+ }
8349
+ const normalizedValue = value.trim();
8350
+ return normalizedValue ? normalizedValue : void 0;
8351
+ }
8352
+ function readFirstEnvValue(env, keys) {
8353
+ for (const key of keys) {
8354
+ const value = normalizeOptionalString(env[key]);
8355
+ if (value) {
8356
+ return value;
8357
+ }
8358
+ }
8359
+ return void 0;
8360
+ }
8361
+ function readHeaderBagValue(headers, targetKey) {
8362
+ if (!headers) {
8363
+ return void 0;
8364
+ }
8365
+ if (typeof headers.get === "function") {
8366
+ return normalizeOptionalString(headers.get(targetKey));
8367
+ }
8368
+ const normalizedTargetKey = targetKey.toLowerCase();
8369
+ for (const [key, value] of Object.entries(headers)) {
8370
+ if (key.toLowerCase() !== normalizedTargetKey) {
8371
+ continue;
8372
+ }
8373
+ if (typeof value === "string") {
8374
+ return normalizeOptionalString(value);
8375
+ }
8376
+ return void 0;
8377
+ }
8378
+ return void 0;
8379
+ }
8380
+ function resolveSessionContextOptions(session, options) {
8381
+ const sessionToken = normalizeOptionalString(session?.session?.token);
8382
+ const requestCookie = readHeaderBagValue(options?.requestHeaders, "cookie") ?? readHeaderBagValue(options?.headers, "cookie");
8383
+ const authInput = options?.auth;
8384
+ const resolvedUserId = options?.userId !== void 0 ? options.userId : session?.user?.id;
8385
+ const resolvedOrganizationId = options?.organizationId !== void 0 ? options.organizationId : session?.session?.activeOrganizationId;
8386
+ const resolvedBearerToken = authInput?.bearerToken !== void 0 ? authInput.bearerToken : sessionToken;
8387
+ const resolvedSessionToken = authInput?.sessionToken !== void 0 ? authInput.sessionToken : sessionToken;
8388
+ const resolvedCookie = authInput?.cookie !== void 0 ? authInput.cookie : requestCookie;
8389
+ const auth = authInput !== void 0 || resolvedBearerToken !== void 0 || resolvedSessionToken !== void 0 || resolvedCookie !== void 0 ? {
8390
+ ...authInput ?? {},
8391
+ ...resolvedBearerToken !== void 0 ? { bearerToken: resolvedBearerToken } : {},
8392
+ ...resolvedSessionToken !== void 0 ? { sessionToken: resolvedSessionToken } : {},
8393
+ ...resolvedCookie !== void 0 ? { cookie: resolvedCookie } : {},
8394
+ headers: authInput?.headers ? { ...authInput.headers } : void 0
8395
+ } : void 0;
8396
+ if (resolvedUserId === void 0 && resolvedOrganizationId === void 0 && options?.forceNoCache === void 0 && !options?.headers && !auth) {
8397
+ return void 0;
8398
+ }
8399
+ return {
8400
+ userId: resolvedUserId,
8401
+ organizationId: resolvedOrganizationId,
8402
+ forceNoCache: options?.forceNoCache,
8403
+ headers: options?.headers ? { ...options.headers } : void 0,
8404
+ auth
8405
+ };
8406
+ }
7497
8407
  function resolveClientServiceBaseUrl(value, label) {
7498
8408
  if (value === void 0 || value === null) {
7499
8409
  return void 0;
@@ -7515,21 +8425,143 @@ function resolveServiceUrls(config) {
7515
8425
  storageUrl: resolveServiceUrlOverride(config.storage?.url, "Athena storage base URL") ?? resolveServiceUrlOverride(config.storageUrl, "Athena storage base URL") ?? (baseUrl ? appendServicePath(baseUrl, "storage") : void 0)
7516
8426
  };
7517
8427
  }
8428
+ function resolveOptionalClientName(value) {
8429
+ if (value === void 0 || value === null) {
8430
+ return void 0;
8431
+ }
8432
+ const normalizedValue = value.trim();
8433
+ return normalizedValue ? normalizedValue : void 0;
8434
+ }
8435
+ function resolveRequiredClientApiKey(value) {
8436
+ if (value === void 0 || value === null) {
8437
+ throw new Error(
8438
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8439
+ );
8440
+ }
8441
+ const normalizedValue = value.trim();
8442
+ if (!normalizedValue) {
8443
+ throw new Error(
8444
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8445
+ );
8446
+ }
8447
+ return normalizedValue;
8448
+ }
8449
+ function hasHeaderIgnoreCase(headers, targetKey) {
8450
+ const normalizedTargetKey = targetKey.toLowerCase();
8451
+ return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
8452
+ }
8453
+ function mergeClientHeaders(current, next) {
8454
+ if (!current && !next) {
8455
+ return void 0;
8456
+ }
8457
+ return {
8458
+ ...current ?? {},
8459
+ ...next ?? {}
8460
+ };
8461
+ }
8462
+ function mergeDefinedObject(current, next) {
8463
+ if (!current && !next) {
8464
+ return void 0;
8465
+ }
8466
+ const merged = {
8467
+ ...current ?? {}
8468
+ };
8469
+ const mutableMerged = merged;
8470
+ for (const [key, value] of Object.entries(next ?? {})) {
8471
+ if (value !== void 0) {
8472
+ mutableMerged[key] = value;
8473
+ }
8474
+ }
8475
+ return merged;
8476
+ }
8477
+ function mergeAuthClientOptions(current, next) {
8478
+ const merged = mergeDefinedObject(current, next);
8479
+ if (!merged) {
8480
+ return void 0;
8481
+ }
8482
+ const mergedHeaders = mergeClientHeaders(current?.headers, next?.headers);
8483
+ if (mergedHeaders) {
8484
+ merged.headers = mergedHeaders;
8485
+ }
8486
+ return merged;
8487
+ }
8488
+ function mergeServiceUrlOverrides(current, next) {
8489
+ return mergeDefinedObject(current, next);
8490
+ }
8491
+ function toClientContextOverrides(context) {
8492
+ if (!context) {
8493
+ return void 0;
8494
+ }
8495
+ return {
8496
+ userId: context.userId,
8497
+ organizationId: context.organizationId,
8498
+ forceNoCache: context.forceNoCache,
8499
+ headers: context.headers,
8500
+ auth: context.auth ? {
8501
+ ...context.auth,
8502
+ headers: context.auth.headers ? { ...context.auth.headers } : void 0
8503
+ } : void 0
8504
+ };
8505
+ }
8506
+ function mergeClientOverrideOptions(base, overrides) {
8507
+ if (!overrides) {
8508
+ return {
8509
+ ...base,
8510
+ headers: base.headers ? { ...base.headers } : void 0,
8511
+ auth: base.auth ? {
8512
+ ...base.auth,
8513
+ headers: base.auth.headers ? { ...base.auth.headers } : void 0
8514
+ } : void 0,
8515
+ db: base.db ? { ...base.db } : void 0,
8516
+ gateway: base.gateway ? { ...base.gateway } : void 0,
8517
+ storage: base.storage ? { ...base.storage } : void 0
8518
+ };
8519
+ }
8520
+ const merged = mergeDefinedObject(base, overrides) ?? { ...base };
8521
+ return {
8522
+ ...merged,
8523
+ headers: mergeClientHeaders(base.headers, overrides.headers),
8524
+ auth: mergeAuthClientOptions(base.auth, overrides.auth),
8525
+ db: mergeServiceUrlOverrides(base.db, overrides.db),
8526
+ gateway: mergeServiceUrlOverrides(base.gateway, overrides.gateway),
8527
+ storage: mergeServiceUrlOverrides(base.storage, overrides.storage)
8528
+ };
8529
+ }
7518
8530
  function normalizeAuthClientConfig(auth, defaultBaseUrl) {
7519
8531
  if (!auth && defaultBaseUrl === void 0) {
7520
8532
  return void 0;
7521
8533
  }
7522
- const { url, ...rest } = auth ?? {};
8534
+ const {
8535
+ url,
8536
+ baseUrl,
8537
+ apiKey,
8538
+ bearerToken,
8539
+ cookie,
8540
+ sessionToken,
8541
+ ...rest
8542
+ } = auth ?? {};
7523
8543
  const normalized = {
7524
8544
  ...rest
7525
8545
  };
7526
8546
  const resolvedBaseUrl = resolveClientServiceBaseUrl(
7527
- url ?? rest.baseUrl ?? defaultBaseUrl,
8547
+ url ?? baseUrl ?? defaultBaseUrl,
7528
8548
  "Athena auth base URL"
7529
8549
  );
7530
8550
  if (resolvedBaseUrl !== void 0) {
7531
8551
  normalized.baseUrl = resolvedBaseUrl;
7532
8552
  }
8553
+ if (typeof apiKey === "string") {
8554
+ normalized.apiKey = apiKey;
8555
+ }
8556
+ if (typeof bearerToken === "string") {
8557
+ normalized.bearerToken = bearerToken;
8558
+ }
8559
+ if (typeof cookie === "string") {
8560
+ normalized.cookie = cookie;
8561
+ }
8562
+ if (typeof sessionToken === "string") {
8563
+ normalized.sessionToken = sessionToken;
8564
+ }
7533
8565
  return normalized;
7534
8566
  }
7535
8567
  function resolveCreateClientConfig(config) {
@@ -7541,8 +8573,11 @@ function resolveCreateClientConfig(config) {
7541
8573
  }
7542
8574
  return {
7543
8575
  baseUrl: resolvedUrls.dbUrl,
7544
- apiKey: config.key,
7545
- client: config.client,
8576
+ apiKey: resolveRequiredClientApiKey(config.key),
8577
+ client: resolveOptionalClientName(config.client),
8578
+ userId: config.userId,
8579
+ organizationId: config.organizationId,
8580
+ forceNoCache: config.forceNoCache,
7546
8581
  backend: toBackendConfig(config.backend),
7547
8582
  headers: config.headers,
7548
8583
  auth: config.auth,
@@ -7551,23 +8586,39 @@ function resolveCreateClientConfig(config) {
7551
8586
  experimental: config.experimental
7552
8587
  };
7553
8588
  }
7554
- function createClientFromConfig(config) {
8589
+ function createClientFromInput(sourceConfig) {
8590
+ return createClientFromConfig(resolveCreateClientConfig(sourceConfig), sourceConfig);
8591
+ }
8592
+ function createClientFromConfig(config, sourceConfig) {
8593
+ const normalizedAuthConfig = normalizeAuthClientConfig(config.auth, config.authUrl);
7555
8594
  const gatewayHeaders = {
7556
8595
  ...config.headers ?? {}
7557
8596
  };
7558
- if (config.auth?.bearerToken && gatewayHeaders["X-Athena-Auth-Bearer-Token"] === void 0 && gatewayHeaders["x-athena-auth-bearer-token"] === void 0) {
7559
- gatewayHeaders["X-Athena-Auth-Bearer-Token"] = config.auth.bearerToken;
8597
+ if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Bearer-Token")) {
8598
+ gatewayHeaders["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
8599
+ }
8600
+ if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(gatewayHeaders, "Cookie")) {
8601
+ gatewayHeaders.Cookie = normalizedAuthConfig.cookie;
8602
+ }
8603
+ if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Session-Token")) {
8604
+ gatewayHeaders["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
7560
8605
  }
7561
8606
  const gateway = createAthenaGatewayClient({
7562
8607
  baseUrl: config.baseUrl,
7563
8608
  apiKey: config.apiKey,
7564
8609
  client: config.client,
8610
+ userId: config.userId,
8611
+ organizationId: config.organizationId,
8612
+ forceNoCache: config.forceNoCache,
7565
8613
  backend: config.backend,
7566
8614
  headers: gatewayHeaders
7567
8615
  });
7568
8616
  const formatGatewayResult = createResultFormatter(config.experimental);
7569
8617
  const queryTracer = createQueryTracer(config.experimental);
7570
- const auth = createAuthClient(normalizeAuthClientConfig(config.auth, config.authUrl));
8618
+ const auth = createAuthClient({
8619
+ ...normalizedAuthConfig ?? {},
8620
+ ...config.forceNoCache ? { forceNoCache: true } : {}
8621
+ });
7571
8622
  function from(tableOrModel, options) {
7572
8623
  if (isAthenaModelTarget(tableOrModel)) {
7573
8624
  if (options?.schema !== void 0) {
@@ -7615,17 +8666,45 @@ function createClientFromConfig(config) {
7615
8666
  queryTracer
7616
8667
  );
7617
8668
  const db = createDbModule({ from, rpc, query });
8669
+ const withContext = (context) => createClientFromInput(
8670
+ mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
8671
+ );
8672
+ const withSession = (session, options) => createClientFromInput(
8673
+ mergeClientOverrideOptions(
8674
+ sourceConfig,
8675
+ toClientContextOverrides(resolveSessionContextOptions(session, options))
8676
+ )
8677
+ );
8678
+ const authWithOptions = (options) => createClientFromInput(mergeClientOverrideOptions(sourceConfig, options));
7618
8679
  const sdkClient = {
7619
8680
  from,
7620
8681
  db,
7621
8682
  rpc,
7622
8683
  query,
7623
8684
  verifyConnection: gateway.verifyConnection,
7624
- auth: auth.auth
8685
+ auth: auth.auth,
8686
+ withContext,
8687
+ withSession,
8688
+ withOptions: authWithOptions
7625
8689
  };
7626
8690
  if (config.experimental?.athenaStorageBackend) {
8691
+ const storageWithContext = (context) => createClientFromInput(
8692
+ mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
8693
+ );
8694
+ const storageWithSession = (session, options) => createClientFromInput(
8695
+ mergeClientOverrideOptions(
8696
+ sourceConfig,
8697
+ toClientContextOverrides(resolveSessionContextOptions(session, options))
8698
+ )
8699
+ );
8700
+ const storageWithOptions = (options) => createClientFromInput(
8701
+ mergeClientOverrideOptions(sourceConfig, options)
8702
+ );
7627
8703
  const storageClient = {
7628
8704
  ...sdkClient,
8705
+ withContext: storageWithContext,
8706
+ withSession: storageWithSession,
8707
+ withOptions: storageWithOptions,
7629
8708
  storage: createStorageModule(gateway, {
7630
8709
  ...config.experimental.storage,
7631
8710
  ...config.storageUrl ? {
@@ -7641,38 +8720,42 @@ function createClientFromConfig(config) {
7641
8720
  var AthenaClient = class {
7642
8721
  /** Create a fluent builder for a strongly-typed Athena SDK client. */
7643
8722
  static builder() {
7644
- return createAthenaClientBuilder((config) => createClientFromConfig(resolveCreateClientConfig(config)));
7645
- }
7646
- /** Build a client from process environment variables. */
7647
- static fromEnvironment() {
7648
- const url = process.env.ATHENA_URL;
7649
- const gatewayUrl = process.env.ATHENA_DB_URL ?? process.env.ATHENA_GATEWAY_URL;
7650
- const authUrl = process.env.ATHENA_AUTH_URL;
7651
- const storageUrl = process.env.ATHENA_STORAGE_URL;
7652
- const key = process.env.ATHENA_API_KEY ?? process.env.ATHENA_GATEWAY_API_KEY;
8723
+ return createAthenaClientBuilder((config) => createClientFromInput(config));
8724
+ }
8725
+ static fromEnvironment(options = {}) {
8726
+ const env = options.env ?? process.env;
8727
+ const url = options.url ?? readFirstEnvValue(env, ATHENA_ENV_URL_KEYS);
8728
+ const gatewayUrl = options.gatewayUrl ?? readFirstEnvValue(env, ATHENA_ENV_GATEWAY_URL_KEYS);
8729
+ const authUrl = options.authUrl ?? readFirstEnvValue(env, ATHENA_ENV_AUTH_URL_KEYS);
8730
+ const storageUrl = options.storageUrl ?? readFirstEnvValue(env, ATHENA_ENV_STORAGE_URL_KEYS);
8731
+ const key = options.key ?? readFirstEnvValue(env, ATHENA_ENV_KEY_KEYS);
8732
+ const client = options.client ?? readFirstEnvValue(env, ATHENA_ENV_CLIENT_KEYS);
7653
8733
  if (!url && !gatewayUrl || !key) {
7654
8734
  throw new Error(
7655
- "ATHENA_API_KEY plus ATHENA_URL or ATHENA_GATEWAY_URL (optionally ATHENA_DB_URL, ATHENA_AUTH_URL, ATHENA_STORAGE_URL) are required"
8735
+ "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."
7656
8736
  );
7657
8737
  }
8738
+ const { env: _env, ...clientOptions } = options;
7658
8739
  return createClient({
8740
+ ...clientOptions,
7659
8741
  url,
7660
8742
  gatewayUrl,
7661
8743
  authUrl,
7662
8744
  storageUrl,
7663
- key
8745
+ key,
8746
+ client
7664
8747
  });
7665
8748
  }
7666
8749
  };
7667
8750
  function createClient(configOrUrl, apiKey, options) {
7668
- if (typeof configOrUrl === "string") {
7669
- return createClientFromConfig(resolveCreateClientConfig({
8751
+ if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
8752
+ return createClientFromInput({
7670
8753
  url: configOrUrl,
7671
8754
  key: apiKey ?? "",
7672
8755
  ...options
7673
- }));
8756
+ });
7674
8757
  }
7675
- return createClientFromConfig(resolveCreateClientConfig(configOrUrl));
8758
+ return createClientFromInput(configOrUrl);
7676
8759
  }
7677
8760
 
7678
8761
  // src/gateway/types.ts
@@ -8038,6 +9121,9 @@ function createColumnsBuilder(name, mappedName, schemaName, columns) {
8038
9121
  resolveTableTarget(name, mappedName, normalizedSchemaName);
8039
9122
  return createColumnsBuilder(name, mappedName, normalizedSchemaName, columns);
8040
9123
  },
9124
+ withoutPrimaryKey() {
9125
+ return finalizeTable(name, mappedName, schemaName, columns, []);
9126
+ },
8041
9127
  primaryKey(...keys) {
8042
9128
  return finalizeTable(name, mappedName, schemaName, columns, keys);
8043
9129
  }
@@ -8089,6 +9175,59 @@ var TenantHeaderMapper = class {
8089
9175
  return Object.keys(headers).length > 0 ? headers : void 0;
8090
9176
  }
8091
9177
  };
9178
+ function normalizeOptionalString2(value) {
9179
+ if (typeof value !== "string") {
9180
+ return void 0;
9181
+ }
9182
+ const normalizedValue = value.trim();
9183
+ return normalizedValue ? normalizedValue : void 0;
9184
+ }
9185
+ function readHeaderBagValue2(headers, targetKey) {
9186
+ if (!headers) {
9187
+ return void 0;
9188
+ }
9189
+ if (typeof headers.get === "function") {
9190
+ return normalizeOptionalString2(headers.get(targetKey));
9191
+ }
9192
+ const normalizedTargetKey = targetKey.toLowerCase();
9193
+ for (const [key, value] of Object.entries(headers)) {
9194
+ if (key.toLowerCase() !== normalizedTargetKey) {
9195
+ continue;
9196
+ }
9197
+ if (typeof value === "string") {
9198
+ return normalizeOptionalString2(value);
9199
+ }
9200
+ return void 0;
9201
+ }
9202
+ return void 0;
9203
+ }
9204
+ function resolveSessionContextOptions2(session, options) {
9205
+ const sessionToken = normalizeOptionalString2(session?.session?.token);
9206
+ const requestCookie = readHeaderBagValue2(options?.requestHeaders, "cookie") ?? readHeaderBagValue2(options?.headers, "cookie");
9207
+ const authInput = options?.auth;
9208
+ const resolvedUserId = options?.userId !== void 0 ? options.userId : session?.user?.id;
9209
+ const resolvedOrganizationId = options?.organizationId !== void 0 ? options.organizationId : session?.session?.activeOrganizationId;
9210
+ const resolvedBearerToken = authInput?.bearerToken !== void 0 ? authInput.bearerToken : sessionToken;
9211
+ const resolvedSessionToken = authInput?.sessionToken !== void 0 ? authInput.sessionToken : sessionToken;
9212
+ const resolvedCookie = authInput?.cookie !== void 0 ? authInput.cookie : requestCookie;
9213
+ const auth = authInput !== void 0 || resolvedBearerToken !== void 0 || resolvedSessionToken !== void 0 || resolvedCookie !== void 0 ? {
9214
+ ...authInput ?? {},
9215
+ ...resolvedBearerToken !== void 0 ? { bearerToken: resolvedBearerToken } : {},
9216
+ ...resolvedSessionToken !== void 0 ? { sessionToken: resolvedSessionToken } : {},
9217
+ ...resolvedCookie !== void 0 ? { cookie: resolvedCookie } : {},
9218
+ headers: authInput?.headers ? { ...authInput.headers } : void 0
9219
+ } : void 0;
9220
+ if (resolvedUserId === void 0 && resolvedOrganizationId === void 0 && options?.forceNoCache === void 0 && !options?.headers && !auth) {
9221
+ return void 0;
9222
+ }
9223
+ return {
9224
+ userId: resolvedUserId,
9225
+ organizationId: resolvedOrganizationId,
9226
+ forceNoCache: options?.forceNoCache,
9227
+ headers: options?.headers ? { ...options.headers } : void 0,
9228
+ auth
9229
+ };
9230
+ }
8092
9231
  var RegistryNavigator = class {
8093
9232
  constructor(registry) {
8094
9233
  this.registry = registry;
@@ -8140,12 +9279,22 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
8140
9279
  backend: input.options?.backend,
8141
9280
  client: input.options?.client,
8142
9281
  headers: input.options?.headers,
9282
+ forceNoCache: input.options?.forceNoCache,
9283
+ userId: input.options?.userId,
9284
+ organizationId: input.options?.organizationId,
9285
+ auth: input.options?.auth,
9286
+ tenantKeyMap,
9287
+ tenantContext,
8143
9288
  experimental: input.options?.experimental
8144
9289
  };
8145
9290
  this.baseClient = createClient(this.url, this.apiKey, {
8146
9291
  backend: this.clientOptions.backend,
8147
9292
  client: this.clientOptions.client,
8148
9293
  headers: this.tenantHeaderMapper.apply(this.clientOptions.headers, tenantContext),
9294
+ forceNoCache: this.clientOptions.forceNoCache,
9295
+ userId: this.clientOptions.userId,
9296
+ organizationId: this.clientOptions.organizationId,
9297
+ auth: this.clientOptions.auth,
8149
9298
  experimental: this.clientOptions.experimental
8150
9299
  });
8151
9300
  this.db = this.baseClient.db;
@@ -8163,6 +9312,40 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
8163
9312
  verifyConnection(options) {
8164
9313
  return this.baseClient.verifyConnection(options);
8165
9314
  }
9315
+ withContext(context) {
9316
+ const headers = {
9317
+ ...this.clientOptions.headers ?? {},
9318
+ ...context?.headers ?? {}
9319
+ };
9320
+ const auth = this.clientOptions.auth || context?.auth ? {
9321
+ ...this.clientOptions.auth ?? {},
9322
+ ...context?.auth ?? {},
9323
+ headers: this.clientOptions.auth?.headers || context?.auth?.headers ? {
9324
+ ...this.clientOptions.auth?.headers ?? {},
9325
+ ...context?.auth?.headers ?? {}
9326
+ } : void 0
9327
+ } : void 0;
9328
+ return new _TypedAthenaClientImpl({
9329
+ registry: this.registry,
9330
+ url: this.url,
9331
+ apiKey: this.apiKey,
9332
+ options: {
9333
+ ...this.clientOptions,
9334
+ headers: Object.keys(headers).length > 0 ? headers : void 0,
9335
+ auth,
9336
+ tenantKeyMap: this.tenantKeyMap,
9337
+ tenantContext: {
9338
+ ...this.tenantContext
9339
+ },
9340
+ ...context?.userId !== void 0 ? { userId: context.userId } : {},
9341
+ ...context?.organizationId !== void 0 ? { organizationId: context.organizationId } : {},
9342
+ ...context?.forceNoCache !== void 0 ? { forceNoCache: context.forceNoCache } : {}
9343
+ }
9344
+ });
9345
+ }
9346
+ withSession(session, options) {
9347
+ return this.withContext(resolveSessionContextOptions2(session, options));
9348
+ }
8166
9349
  withTenantContext(context) {
8167
9350
  return new _TypedAthenaClientImpl({
8168
9351
  registry: this.registry,
@@ -8658,6 +9841,77 @@ function resolveProviderSchemas(providerConfig) {
8658
9841
  return [...DEFAULT_POSTGRES_SCHEMAS];
8659
9842
  }
8660
9843
 
9844
+ // src/generator/table-selection.ts
9845
+ function normalizeTableSelector(value) {
9846
+ const trimmed = value.trim();
9847
+ return trimmed.length > 0 ? trimmed : void 0;
9848
+ }
9849
+ function normalizeTableSelection(value) {
9850
+ if (typeof value === "string") {
9851
+ return Array.from(
9852
+ new Set(
9853
+ value.split(",").map(normalizeTableSelector).filter((entry) => Boolean(entry))
9854
+ )
9855
+ );
9856
+ }
9857
+ if (Array.isArray(value)) {
9858
+ return Array.from(
9859
+ new Set(
9860
+ value.map((entry) => typeof entry === "string" ? normalizeTableSelector(entry) : void 0).filter((entry) => Boolean(entry))
9861
+ )
9862
+ );
9863
+ }
9864
+ return [];
9865
+ }
9866
+ function matchesTableSelector(schemaName, tableName, selector) {
9867
+ const separatorIndex = selector.indexOf(".");
9868
+ if (separatorIndex < 0) {
9869
+ return tableName === selector;
9870
+ }
9871
+ const selectorSchema = selector.slice(0, separatorIndex).trim();
9872
+ const selectorTable = selector.slice(separatorIndex + 1).trim();
9873
+ return selectorSchema === schemaName && selectorTable === tableName;
9874
+ }
9875
+ function shouldKeepTable(schemaName, tableName, filter) {
9876
+ const included = filter.includeTables.length === 0 || filter.includeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
9877
+ if (!included) {
9878
+ return false;
9879
+ }
9880
+ return !filter.excludeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
9881
+ }
9882
+ function hasTableFilters(filter) {
9883
+ return filter.includeTables.length > 0 || filter.excludeTables.length > 0;
9884
+ }
9885
+ function filterIntrospectionSnapshot(snapshot, filter) {
9886
+ if (!hasTableFilters(filter)) {
9887
+ return snapshot;
9888
+ }
9889
+ const schemas = {};
9890
+ for (const [schemaName, schema] of Object.entries(snapshot.schemas)) {
9891
+ const tables = Object.fromEntries(
9892
+ Object.entries(schema.tables).filter(([tableName]) => shouldKeepTable(schemaName, tableName, filter))
9893
+ );
9894
+ if (Object.keys(tables).length === 0) {
9895
+ continue;
9896
+ }
9897
+ schemas[schemaName] = {
9898
+ ...schema,
9899
+ tables
9900
+ };
9901
+ }
9902
+ if (Object.keys(schemas).length === 0) {
9903
+ const includeLabel = filter.includeTables.length > 0 ? ` includeTables=${filter.includeTables.join(", ")}` : "";
9904
+ const excludeLabel = filter.excludeTables.length > 0 ? ` excludeTables=${filter.excludeTables.join(", ")}` : "";
9905
+ throw new Error(
9906
+ `Generator table filters matched no tables after schema selection.${includeLabel}${excludeLabel}`
9907
+ );
9908
+ }
9909
+ return {
9910
+ ...snapshot,
9911
+ schemas
9912
+ };
9913
+ }
9914
+
8661
9915
  // src/generator/config.ts
8662
9916
  var POSTGRES_PROTOCOLS = /* @__PURE__ */ new Set(["postgres:", "postgresql:"]);
8663
9917
  var DEFAULT_CONFIG_CANDIDATES = [
@@ -8668,13 +9922,20 @@ var DEFAULT_CONFIG_CANDIDATES = [
8668
9922
  ".athena.config.ts",
8669
9923
  ".athena.config.js"
8670
9924
  ];
8671
- var DEFAULT_TARGETS = {
9925
+ var LEGACY_DEFAULT_TARGETS = {
8672
9926
  model: "athena/models/{schema_kebab}/{model_kebab}.ts",
8673
9927
  schema: "athena/schemas/{schema_kebab}.ts",
8674
9928
  database: "athena/relations.ts",
8675
9929
  registry: "athena/config.ts"
8676
9930
  };
8677
- var DEFAULT_OUTPUT_FORMAT = "define-model";
9931
+ var ATHENA_DIRECT_TARGETS = {
9932
+ model: "athena/models/{schema_kebab}/{model_kebab}.ts",
9933
+ schema: "athena/schemas/{schema_kebab}.ts",
9934
+ database: "athena/relations.ts",
9935
+ registry: "athena/registry.generated.ts"
9936
+ };
9937
+ var DEFAULT_OUTPUT_FORMAT = "table-builder";
9938
+ var DEFAULT_OUTPUT_PRESET = "athena-direct";
8678
9939
  var DEFAULT_NAMING = {
8679
9940
  modelType: "pascal",
8680
9941
  modelConst: "camel",
@@ -8693,6 +9954,10 @@ var DEFAULT_EXPERIMENTAL_FLAGS = {
8693
9954
  var DEFAULT_INTERNAL_CONFIG = {
8694
9955
  schemaVersion: 1
8695
9956
  };
9957
+ var DEFAULT_FILTER_CONFIG = {
9958
+ includeTables: [],
9959
+ excludeTables: []
9960
+ };
8696
9961
  var PROJECT_ENV_FILENAMES = [".env", ".env.local"];
8697
9962
  var DIRECT_CONNECTION_STRING_ENV_KEYS = [
8698
9963
  "ATHENA_GENERATOR_PG_URL",
@@ -8711,10 +9976,13 @@ var GATEWAY_API_KEY_ENV_KEYS = [
8711
9976
  ];
8712
9977
  var GENERATOR_SCHEMA_ENV_KEYS = ["ATHENA_GENERATOR_SCHEMAS"];
8713
9978
  var OUTPUT_FORMAT_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_FORMAT"];
9979
+ var OUTPUT_PRESET_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_PRESET"];
8714
9980
  var MODEL_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_TARGET"];
8715
9981
  var SCHEMA_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_SCHEMA_TARGET"];
8716
9982
  var DATABASE_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_DATABASE_TARGET"];
8717
9983
  var REGISTRY_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_REGISTRY_TARGET"];
9984
+ var TABLES_ENV_KEYS = ["ATHENA_GENERATOR_TABLES"];
9985
+ var EXCLUDE_TABLES_ENV_KEYS = ["ATHENA_GENERATOR_EXCLUDE_TABLES"];
8718
9986
  var PLACEHOLDER_MAP_ENV_KEYS = ["ATHENA_GENERATOR_PLACEHOLDER_MAP"];
8719
9987
  var MODEL_TYPE_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_TYPE", "ATHENA_GENERATOR_MODEL_STYLE"];
8720
9988
  var MODEL_CONST_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_CONST"];
@@ -8729,7 +9997,12 @@ var SCYLLA_PROVIDER_CONTRACTS_ENV_KEYS = ["ATHENA_GENERATOR_SCYLLA_PROVIDER_CONT
8729
9997
  var ENV_ONLY_CONFIG_PATH = "[environment defaults]";
8730
9998
  var NAMING_STYLE_VALUES = ["preserve", "camel", "pascal", "snake", "kebab"];
8731
9999
  var OUTPUT_FORMAT_VALUES = ["define-model", "table-builder"];
10000
+ var OUTPUT_PRESET_VALUES = ["legacy", "athena-direct"];
8732
10001
  var BACKEND_TYPE_VALUES = ["athena", "postgrest", "postgresql", "scylladb"];
10002
+ var OUTPUT_PRESET_TARGETS = {
10003
+ legacy: LEGACY_DEFAULT_TARGETS,
10004
+ "athena-direct": ATHENA_DIRECT_TARGETS
10005
+ };
8733
10006
  function normalizeRawEnvValue(rawValue) {
8734
10007
  if (rawValue.startsWith('"') && rawValue.endsWith('"') && rawValue.length >= 2) {
8735
10008
  const inner = rawValue.slice(1, -1);
@@ -8865,7 +10138,7 @@ function deriveDatabaseNameFromConnectionString(connectionString) {
8865
10138
  return void 0;
8866
10139
  }
8867
10140
  }
8868
- function normalizeOptionalString(value, fallbackKeys) {
10141
+ function normalizeOptionalString3(value, fallbackKeys) {
8869
10142
  if (typeof value === "string") {
8870
10143
  const trimmed = value.trim();
8871
10144
  if (trimmed.length > 0) {
@@ -8875,7 +10148,7 @@ function normalizeOptionalString(value, fallbackKeys) {
8875
10148
  return resolveFallbackValue(fallbackKeys);
8876
10149
  }
8877
10150
  function normalizeRequiredString(value, fieldLabel, fallbackKeys) {
8878
- const resolved = normalizeOptionalString(value, fallbackKeys);
10151
+ const resolved = normalizeOptionalString3(value, fallbackKeys);
8879
10152
  if (resolved) {
8880
10153
  return resolved;
8881
10154
  }
@@ -8936,11 +10209,19 @@ function normalizeExperimentalFlags(input) {
8936
10209
  )
8937
10210
  };
8938
10211
  }
10212
+ function normalizeFilterConfig(input) {
10213
+ return {
10214
+ includeTables: normalizeTableSelection(input?.includeTables),
10215
+ excludeTables: normalizeTableSelection(input?.excludeTables)
10216
+ };
10217
+ }
8939
10218
  function normalizeOutputConfig(output) {
10219
+ const preset = output?.preset ?? DEFAULT_OUTPUT_PRESET;
8940
10220
  return {
8941
10221
  format: output?.format ?? DEFAULT_OUTPUT_FORMAT,
10222
+ preset,
8942
10223
  targets: {
8943
- ...DEFAULT_TARGETS,
10224
+ ...OUTPUT_PRESET_TARGETS[preset],
8944
10225
  ...output?.targets ?? {}
8945
10226
  },
8946
10227
  placeholderMap: {
@@ -8955,7 +10236,7 @@ function normalizeProviderConfig(provider) {
8955
10236
  "provider.connectionString",
8956
10237
  DIRECT_CONNECTION_STRING_ENV_KEYS
8957
10238
  );
8958
- const database = normalizeOptionalString(provider.database, POSTGRES_DATABASE_ENV_KEYS) ?? deriveDatabaseNameFromConnectionString(connectionString);
10239
+ const database = normalizeOptionalString3(provider.database, POSTGRES_DATABASE_ENV_KEYS) ?? deriveDatabaseNameFromConnectionString(connectionString);
8959
10240
  return {
8960
10241
  ...provider,
8961
10242
  connectionString: applyPostgresPasswordFallback(connectionString),
@@ -8974,7 +10255,7 @@ function normalizeProviderConfig(provider) {
8974
10255
  "provider.apiKey",
8975
10256
  GATEWAY_API_KEY_ENV_KEYS
8976
10257
  );
8977
- const database = normalizeOptionalString(provider.database, POSTGRES_DATABASE_ENV_KEYS) ?? "postgres";
10258
+ const database = normalizeOptionalString3(provider.database, POSTGRES_DATABASE_ENV_KEYS) ?? "postgres";
8978
10259
  return {
8979
10260
  ...provider,
8980
10261
  gatewayUrl,
@@ -8989,7 +10270,7 @@ function normalizeProviderConfig(provider) {
8989
10270
  "Generator config is missing provider.contactPoints for scylla direct mode."
8990
10271
  );
8991
10272
  }
8992
- const keyspace = normalizeOptionalString(provider.keyspace, []);
10273
+ const keyspace = normalizeOptionalString3(provider.keyspace, []);
8993
10274
  if (!keyspace) {
8994
10275
  throw new Error(
8995
10276
  "Generator config is missing provider.keyspace for scylla direct mode."
@@ -9000,7 +10281,7 @@ function normalizeProviderConfig(provider) {
9000
10281
  mode: "direct",
9001
10282
  contactPoints: provider.contactPoints.slice(),
9002
10283
  keyspace,
9003
- datacenter: normalizeOptionalString(provider.datacenter, [])
10284
+ datacenter: normalizeOptionalString3(provider.datacenter, [])
9004
10285
  };
9005
10286
  }
9006
10287
  return provider;
@@ -9020,6 +10301,10 @@ function normalizeGeneratorConfig(input) {
9020
10301
  ...DEFAULT_NAMING,
9021
10302
  ...input.naming ?? {}
9022
10303
  },
10304
+ filter: {
10305
+ ...DEFAULT_FILTER_CONFIG,
10306
+ ...normalizeFilterConfig(input.filter)
10307
+ },
9023
10308
  features: normalizeFeatureFlags(input.features),
9024
10309
  experimental: normalizeExperimentalFlags(input.experimental),
9025
10310
  internal: {
@@ -9083,16 +10368,18 @@ function importConfigModule(moduleSpecifier) {
9083
10368
  }
9084
10369
  function buildEnvironmentOutputConfig() {
9085
10370
  const format = resolveOptionalOneOf(OUTPUT_FORMAT_ENV_KEYS, OUTPUT_FORMAT_VALUES);
10371
+ const preset = resolveOptionalOneOf(OUTPUT_PRESET_ENV_KEYS, OUTPUT_PRESET_VALUES);
9086
10372
  const modelTarget = resolveFallbackValue(MODEL_TARGET_ENV_KEYS);
9087
10373
  const schemaTarget = resolveFallbackValue(SCHEMA_TARGET_ENV_KEYS);
9088
10374
  const databaseTarget = resolveFallbackValue(DATABASE_TARGET_ENV_KEYS);
9089
10375
  const registryTarget = resolveFallbackValue(REGISTRY_TARGET_ENV_KEYS);
9090
10376
  const placeholderMap = resolveOptionalJson(PLACEHOLDER_MAP_ENV_KEYS);
9091
- if (format === void 0 && modelTarget === void 0 && schemaTarget === void 0 && databaseTarget === void 0 && registryTarget === void 0 && placeholderMap === void 0) {
10377
+ if (format === void 0 && preset === void 0 && modelTarget === void 0 && schemaTarget === void 0 && databaseTarget === void 0 && registryTarget === void 0 && placeholderMap === void 0) {
9092
10378
  return void 0;
9093
10379
  }
9094
10380
  return {
9095
10381
  format,
10382
+ preset,
9096
10383
  targets: {
9097
10384
  ...modelTarget ? { model: modelTarget } : {},
9098
10385
  ...schemaTarget ? { schema: schemaTarget } : {},
@@ -9102,6 +10389,17 @@ function buildEnvironmentOutputConfig() {
9102
10389
  placeholderMap
9103
10390
  };
9104
10391
  }
10392
+ function buildEnvironmentFilterConfig() {
10393
+ const includeTables = resolveFallbackValue(TABLES_ENV_KEYS);
10394
+ const excludeTables = resolveFallbackValue(EXCLUDE_TABLES_ENV_KEYS);
10395
+ if (includeTables === void 0 && excludeTables === void 0) {
10396
+ return void 0;
10397
+ }
10398
+ return {
10399
+ ...includeTables !== void 0 ? { includeTables } : {},
10400
+ ...excludeTables !== void 0 ? { excludeTables } : {}
10401
+ };
10402
+ }
9105
10403
  function buildEnvironmentNamingConfig() {
9106
10404
  const modelType = resolveOptionalOneOf(MODEL_TYPE_ENV_KEYS, NAMING_STYLE_VALUES);
9107
10405
  const modelConst = resolveOptionalOneOf(MODEL_CONST_ENV_KEYS, NAMING_STYLE_VALUES);
@@ -9148,7 +10446,7 @@ function buildEnvironmentProviderConfig() {
9148
10446
  kind: "postgres",
9149
10447
  mode: "direct",
9150
10448
  connectionString: directConnectionString,
9151
- database: normalizeOptionalString(void 0, POSTGRES_DATABASE_ENV_KEYS),
10449
+ database: normalizeOptionalString3(void 0, POSTGRES_DATABASE_ENV_KEYS),
9152
10450
  schemas: normalizeSchemaSelection(resolveFallbackValue(GENERATOR_SCHEMA_ENV_KEYS))
9153
10451
  };
9154
10452
  }
@@ -9161,7 +10459,7 @@ function buildEnvironmentProviderConfig() {
9161
10459
  mode: "gateway",
9162
10460
  gatewayUrl,
9163
10461
  apiKey,
9164
- database: normalizeOptionalString(void 0, POSTGRES_DATABASE_ENV_KEYS),
10462
+ database: normalizeOptionalString3(void 0, POSTGRES_DATABASE_ENV_KEYS),
9165
10463
  schemas: normalizeSchemaSelection(resolveFallbackValue(GENERATOR_SCHEMA_ENV_KEYS)),
9166
10464
  backend
9167
10465
  };
@@ -9177,6 +10475,7 @@ function createEnvironmentGeneratorConfig() {
9177
10475
  provider,
9178
10476
  output: buildEnvironmentOutputConfig(),
9179
10477
  naming: buildEnvironmentNamingConfig(),
10478
+ filter: buildEnvironmentFilterConfig(),
9180
10479
  features: buildEnvironmentFeatureFlags(),
9181
10480
  experimental: buildEnvironmentExperimentalFlags()
9182
10481
  };
@@ -9662,7 +10961,7 @@ ${schemaEntries}
9662
10961
  content
9663
10962
  };
9664
10963
  }
9665
- function renderRegistryArtifact(registryPath, databasePath, databaseConstName, registryConstName, databaseName, generatedAt, outputFormat, schemaVersion) {
10964
+ function renderRegistryArtifact(registryPath, databasePath, databaseConstName, registryConstName, databaseName, generatedAt, outputPreset, outputFormat, schemaVersion) {
9666
10965
  const databaseImportPath = toModuleImportPath(registryPath, databasePath);
9667
10966
  const content = `import { defineRegistry } from '@xylex-group/athena'
9668
10967
  import { ${databaseConstName} } from '${databaseImportPath}'
@@ -9671,6 +10970,7 @@ export const __athena_schema_meta = {
9671
10970
  schemaVersion: ${schemaVersion},
9672
10971
  generatedAt: ${escapeStringLiteral(generatedAt)},
9673
10972
  database: ${escapeStringLiteral(databaseName)},
10973
+ outputPreset: ${escapeStringLiteral(outputPreset)},
9674
10974
  outputFormat: ${escapeStringLiteral(outputFormat)},
9675
10975
  } as const
9676
10976
 
@@ -9840,6 +11140,7 @@ function composeGeneratorArtifacts(input) {
9840
11140
  toSafeIdentifier("registry", config.naming.registryConst, "registry"),
9841
11141
  databaseName,
9842
11142
  snapshot.generatedAt,
11143
+ config.output.preset,
9843
11144
  config.output.format,
9844
11145
  config.internal.schemaVersion
9845
11146
  )
@@ -9945,7 +11246,7 @@ export const ${descriptor.tableConstName} = table(${escapeStringLiteral(descript
9945
11246
  .columns({
9946
11247
  ${columnLines}
9947
11248
  })
9948
- .primaryKey(${descriptor.table.primaryKey.map((value) => escapeStringLiteral(value)).join(", ")})
11249
+ ${descriptor.table.primaryKey.length > 0 ? `.primaryKey(${descriptor.table.primaryKey.map((value) => escapeStringLiteral(value)).join(", ")})` : ".withoutPrimaryKey()"}
9949
11250
  ${relationsAssignment ? `${relationsAssignment}` : ""}
9950
11251
  export type ${descriptor.rowTypeName} = RowOf<typeof ${descriptor.tableConstName}>
9951
11252
  export type ${descriptor.insertTypeName} = InsertOf<typeof ${descriptor.tableConstName}>
@@ -10042,11 +11343,12 @@ ${nullableLines}
10042
11343
  }
10043
11344
  function generateArtifactsFromSnapshot(snapshot, config) {
10044
11345
  const normalizedConfig = "internal" in config ? config : normalizeGeneratorConfig(config);
11346
+ const filteredSnapshot = filterIntrospectionSnapshot(snapshot, normalizedConfig.filter);
10045
11347
  if (normalizedConfig.output.format === "table-builder") {
10046
- return generateTableBuilderArtifactsFromSnapshot(snapshot, normalizedConfig);
11348
+ return generateTableBuilderArtifactsFromSnapshot(filteredSnapshot, normalizedConfig);
10047
11349
  }
10048
11350
  return composeGeneratorArtifacts({
10049
- snapshot,
11351
+ snapshot: filteredSnapshot,
10050
11352
  config: normalizedConfig,
10051
11353
  createModelDescriptor({ providerName, databaseName, schemaName, tableName, table: table2 }) {
10052
11354
  const modelConstName = toSafeIdentifier(
@@ -10076,7 +11378,7 @@ function generateArtifactsFromSnapshot(snapshot, config) {
10076
11378
  table: table2
10077
11379
  };
10078
11380
  },
10079
- renderModelArtifact: (descriptor) => renderModelArtifact2(snapshot.database, descriptor, normalizedConfig)
11381
+ renderModelArtifact: (descriptor) => renderModelArtifact2(filteredSnapshot.database, descriptor, normalizedConfig)
10080
11382
  });
10081
11383
  }
10082
11384
 
@@ -10196,16 +11498,25 @@ async function fileExists(path) {
10196
11498
  }
10197
11499
  async function writeArtifacts(files, cwd) {
10198
11500
  const writtenFiles = [];
11501
+ const skippedFiles = [];
10199
11502
  for (const file of files) {
10200
11503
  const absolutePath = resolve(cwd, file.path);
10201
11504
  if (!canOverwriteArtifact(file) && await fileExists(absolutePath)) {
11505
+ skippedFiles.push({
11506
+ kind: file.kind,
11507
+ path: file.path,
11508
+ reason: "protected-existing-file"
11509
+ });
10202
11510
  continue;
10203
11511
  }
10204
11512
  await mkdir(dirname(absolutePath), { recursive: true });
10205
11513
  await writeFile(absolutePath, file.content, "utf8");
10206
11514
  writtenFiles.push(file.path);
10207
11515
  }
10208
- return writtenFiles;
11516
+ return {
11517
+ writtenFiles,
11518
+ skippedFiles
11519
+ };
10209
11520
  }
10210
11521
  async function runSchemaGenerator(options = {}) {
10211
11522
  const cwd = options.cwd ?? process.cwd();
@@ -10219,11 +11530,13 @@ async function runSchemaGenerator(options = {}) {
10219
11530
  schemas: resolveProviderSchemas(config.provider)
10220
11531
  });
10221
11532
  const generated = generateArtifactsFromSnapshot(snapshot, config);
10222
- const writtenFiles = options.dryRun ? [] : await writeArtifacts(generated.files, cwd);
11533
+ const writeResult = options.dryRun ? { writtenFiles: [], skippedFiles: [] } : await writeArtifacts(generated.files, cwd);
10223
11534
  return {
10224
11535
  ...generated,
10225
11536
  configPath,
10226
- writtenFiles
11537
+ config,
11538
+ writtenFiles: writeResult.writtenFiles,
11539
+ skippedFiles: writeResult.skippedFiles
10227
11540
  };
10228
11541
  }
10229
11542
 
@@ -10654,6 +11967,6 @@ function athenaAuth(config) {
10654
11967
  return auth;
10655
11968
  }
10656
11969
 
10657
- export { ATHENA_AUTH_BASE_ERROR_CODES, AthenaClient, AthenaError, AthenaErrorCategory, AthenaErrorCode, AthenaErrorKind, AthenaGatewayError, AthenaStorageError, AthenaStorageErrorCode, Backend, DEFAULT_POSTGRES_SCHEMAS, assertInt, athenaAuth, boolean, coerceInt, createAthenaStorageError, createAuthClient, createAuthReactEmailInput, createClient, createModelFormAdapter, createPostgresIntrospectionProvider, createTypedClient, defineAthenaAuthConfig, defineAuthEmailTemplate, defineDatabase, defineGeneratorConfig, defineModel, defineRegistry, defineSchema, enumeration, findGeneratorConfigPath, generateArtifactsFromSnapshot, generatorEnv, getAthenaDebugAst, identifier, isAthenaGatewayError, isOk, json, loadGeneratorConfig, normalizeAthenaError, normalizeAthenaGatewayBaseUrl, normalizeGeneratorConfig, normalizeSchemaSelection, number, parseBooleanFlag2 as parseBooleanFlag, renderAthenaReactEmail, requireAffected, requireSuccess, resolveGeneratorProvider, resolvePostgresColumnType, resolveProviderSchemas, runSchemaGenerator, storageSdkManifest, string, table, toModelFormDefaults, toModelPayload, unwrap, unwrapOne, unwrapRows, verifyAthenaGatewayUrl, withRetry };
11970
+ export { ATHENA_AUTH_ADMIN_LIMITS, ATHENA_AUTH_BASE_ERROR_CODES, ATHENA_AUTH_MAX_ADMIN_JSON_BYTES, ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH, ATHENA_AUTH_MAX_TEMPLATE_VARIABLES, ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH, AthenaClient, AthenaError, AthenaErrorCategory, AthenaErrorCode, AthenaErrorKind, AthenaGatewayError, AthenaStorageError, AthenaStorageErrorCode, Backend, DEFAULT_POSTGRES_SCHEMAS, assertInt, athenaAuth, boolean, coerceInt, createAthenaStorageError, createAuthClient, createAuthReactEmailInput, createClient, createModelFormAdapter, createPostgresIntrospectionProvider, createTypedClient, defineAthenaAuthConfig, defineAuthEmailTemplate, defineDatabase, defineGeneratorConfig, defineModel, defineRegistry, defineSchema, enumeration, filterIntrospectionSnapshot, findGeneratorConfigPath, generateArtifactsFromSnapshot, generatorEnv, getAthenaDebugAst, identifier, isAthenaGatewayError, isOk, json, loadGeneratorConfig, normalizeAthenaError, normalizeAthenaGatewayBaseUrl, normalizeGeneratorConfig, normalizeSchemaSelection, normalizeTableSelection, number, parseBooleanFlag2 as parseBooleanFlag, renderAthenaReactEmail, requireAffected, requireSuccess, resolveGeneratorProvider, resolvePostgresColumnType, resolveProviderSchemas, runSchemaGenerator, storageSdkManifest, string, table, toModelFormDefaults, toModelPayload, unwrap, unwrapOne, unwrapRows, verifyAthenaGatewayUrl, withRetry };
10658
11971
  //# sourceMappingURL=index.js.map
10659
11972
  //# sourceMappingURL=index.js.map