@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
@@ -688,6 +688,77 @@ function resolveProviderSchemas(providerConfig) {
688
688
  return [...DEFAULT_POSTGRES_SCHEMAS];
689
689
  }
690
690
 
691
+ // src/generator/table-selection.ts
692
+ function normalizeTableSelector(value) {
693
+ const trimmed = value.trim();
694
+ return trimmed.length > 0 ? trimmed : void 0;
695
+ }
696
+ function normalizeTableSelection(value) {
697
+ if (typeof value === "string") {
698
+ return Array.from(
699
+ new Set(
700
+ value.split(",").map(normalizeTableSelector).filter((entry) => Boolean(entry))
701
+ )
702
+ );
703
+ }
704
+ if (Array.isArray(value)) {
705
+ return Array.from(
706
+ new Set(
707
+ value.map((entry) => typeof entry === "string" ? normalizeTableSelector(entry) : void 0).filter((entry) => Boolean(entry))
708
+ )
709
+ );
710
+ }
711
+ return [];
712
+ }
713
+ function matchesTableSelector(schemaName, tableName, selector) {
714
+ const separatorIndex = selector.indexOf(".");
715
+ if (separatorIndex < 0) {
716
+ return tableName === selector;
717
+ }
718
+ const selectorSchema = selector.slice(0, separatorIndex).trim();
719
+ const selectorTable = selector.slice(separatorIndex + 1).trim();
720
+ return selectorSchema === schemaName && selectorTable === tableName;
721
+ }
722
+ function shouldKeepTable(schemaName, tableName, filter) {
723
+ const included = filter.includeTables.length === 0 || filter.includeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
724
+ if (!included) {
725
+ return false;
726
+ }
727
+ return !filter.excludeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
728
+ }
729
+ function hasTableFilters(filter) {
730
+ return filter.includeTables.length > 0 || filter.excludeTables.length > 0;
731
+ }
732
+ function filterIntrospectionSnapshot(snapshot, filter) {
733
+ if (!hasTableFilters(filter)) {
734
+ return snapshot;
735
+ }
736
+ const schemas = {};
737
+ for (const [schemaName, schema] of Object.entries(snapshot.schemas)) {
738
+ const tables = Object.fromEntries(
739
+ Object.entries(schema.tables).filter(([tableName]) => shouldKeepTable(schemaName, tableName, filter))
740
+ );
741
+ if (Object.keys(tables).length === 0) {
742
+ continue;
743
+ }
744
+ schemas[schemaName] = {
745
+ ...schema,
746
+ tables
747
+ };
748
+ }
749
+ if (Object.keys(schemas).length === 0) {
750
+ const includeLabel = filter.includeTables.length > 0 ? ` includeTables=${filter.includeTables.join(", ")}` : "";
751
+ const excludeLabel = filter.excludeTables.length > 0 ? ` excludeTables=${filter.excludeTables.join(", ")}` : "";
752
+ throw new Error(
753
+ `Generator table filters matched no tables after schema selection.${includeLabel}${excludeLabel}`
754
+ );
755
+ }
756
+ return {
757
+ ...snapshot,
758
+ schemas
759
+ };
760
+ }
761
+
691
762
  // src/generator/config.ts
692
763
  var POSTGRES_PROTOCOLS = /* @__PURE__ */ new Set(["postgres:", "postgresql:"]);
693
764
  var DEFAULT_CONFIG_CANDIDATES = [
@@ -698,13 +769,20 @@ var DEFAULT_CONFIG_CANDIDATES = [
698
769
  ".athena.config.ts",
699
770
  ".athena.config.js"
700
771
  ];
701
- var DEFAULT_TARGETS = {
772
+ var LEGACY_DEFAULT_TARGETS = {
702
773
  model: "athena/models/{schema_kebab}/{model_kebab}.ts",
703
774
  schema: "athena/schemas/{schema_kebab}.ts",
704
775
  database: "athena/relations.ts",
705
776
  registry: "athena/config.ts"
706
777
  };
707
- var DEFAULT_OUTPUT_FORMAT = "define-model";
778
+ var ATHENA_DIRECT_TARGETS = {
779
+ model: "athena/models/{schema_kebab}/{model_kebab}.ts",
780
+ schema: "athena/schemas/{schema_kebab}.ts",
781
+ database: "athena/relations.ts",
782
+ registry: "athena/registry.generated.ts"
783
+ };
784
+ var DEFAULT_OUTPUT_FORMAT = "table-builder";
785
+ var DEFAULT_OUTPUT_PRESET = "athena-direct";
708
786
  var DEFAULT_NAMING = {
709
787
  modelType: "pascal",
710
788
  modelConst: "camel",
@@ -723,6 +801,10 @@ var DEFAULT_EXPERIMENTAL_FLAGS = {
723
801
  var DEFAULT_INTERNAL_CONFIG = {
724
802
  schemaVersion: 1
725
803
  };
804
+ var DEFAULT_FILTER_CONFIG = {
805
+ includeTables: [],
806
+ excludeTables: []
807
+ };
726
808
  var PROJECT_ENV_FILENAMES = [".env", ".env.local"];
727
809
  var DIRECT_CONNECTION_STRING_ENV_KEYS = [
728
810
  "ATHENA_GENERATOR_PG_URL",
@@ -741,10 +823,13 @@ var GATEWAY_API_KEY_ENV_KEYS = [
741
823
  ];
742
824
  var GENERATOR_SCHEMA_ENV_KEYS = ["ATHENA_GENERATOR_SCHEMAS"];
743
825
  var OUTPUT_FORMAT_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_FORMAT"];
826
+ var OUTPUT_PRESET_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_PRESET"];
744
827
  var MODEL_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_TARGET"];
745
828
  var SCHEMA_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_SCHEMA_TARGET"];
746
829
  var DATABASE_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_DATABASE_TARGET"];
747
830
  var REGISTRY_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_REGISTRY_TARGET"];
831
+ var TABLES_ENV_KEYS = ["ATHENA_GENERATOR_TABLES"];
832
+ var EXCLUDE_TABLES_ENV_KEYS = ["ATHENA_GENERATOR_EXCLUDE_TABLES"];
748
833
  var PLACEHOLDER_MAP_ENV_KEYS = ["ATHENA_GENERATOR_PLACEHOLDER_MAP"];
749
834
  var MODEL_TYPE_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_TYPE", "ATHENA_GENERATOR_MODEL_STYLE"];
750
835
  var MODEL_CONST_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_CONST"];
@@ -759,7 +844,12 @@ var SCYLLA_PROVIDER_CONTRACTS_ENV_KEYS = ["ATHENA_GENERATOR_SCYLLA_PROVIDER_CONT
759
844
  var ENV_ONLY_CONFIG_PATH = "[environment defaults]";
760
845
  var NAMING_STYLE_VALUES = ["preserve", "camel", "pascal", "snake", "kebab"];
761
846
  var OUTPUT_FORMAT_VALUES = ["define-model", "table-builder"];
847
+ var OUTPUT_PRESET_VALUES = ["legacy", "athena-direct"];
762
848
  var BACKEND_TYPE_VALUES = ["athena", "postgrest", "postgresql", "scylladb"];
849
+ var OUTPUT_PRESET_TARGETS = {
850
+ legacy: LEGACY_DEFAULT_TARGETS,
851
+ "athena-direct": ATHENA_DIRECT_TARGETS
852
+ };
763
853
  function normalizeRawEnvValue(rawValue) {
764
854
  if (rawValue.startsWith('"') && rawValue.endsWith('"') && rawValue.length >= 2) {
765
855
  const inner = rawValue.slice(1, -1);
@@ -966,11 +1056,19 @@ function normalizeExperimentalFlags(input) {
966
1056
  )
967
1057
  };
968
1058
  }
1059
+ function normalizeFilterConfig(input) {
1060
+ return {
1061
+ includeTables: normalizeTableSelection(input?.includeTables),
1062
+ excludeTables: normalizeTableSelection(input?.excludeTables)
1063
+ };
1064
+ }
969
1065
  function normalizeOutputConfig(output) {
1066
+ const preset = output?.preset ?? DEFAULT_OUTPUT_PRESET;
970
1067
  return {
971
1068
  format: output?.format ?? DEFAULT_OUTPUT_FORMAT,
1069
+ preset,
972
1070
  targets: {
973
- ...DEFAULT_TARGETS,
1071
+ ...OUTPUT_PRESET_TARGETS[preset],
974
1072
  ...output?.targets ?? {}
975
1073
  },
976
1074
  placeholderMap: {
@@ -1050,6 +1148,10 @@ function normalizeGeneratorConfig(input) {
1050
1148
  ...DEFAULT_NAMING,
1051
1149
  ...input.naming ?? {}
1052
1150
  },
1151
+ filter: {
1152
+ ...DEFAULT_FILTER_CONFIG,
1153
+ ...normalizeFilterConfig(input.filter)
1154
+ },
1053
1155
  features: normalizeFeatureFlags(input.features),
1054
1156
  experimental: normalizeExperimentalFlags(input.experimental),
1055
1157
  internal: {
@@ -1110,16 +1212,18 @@ function importConfigModule(moduleSpecifier) {
1110
1212
  }
1111
1213
  function buildEnvironmentOutputConfig() {
1112
1214
  const format = resolveOptionalOneOf(OUTPUT_FORMAT_ENV_KEYS, OUTPUT_FORMAT_VALUES);
1215
+ const preset = resolveOptionalOneOf(OUTPUT_PRESET_ENV_KEYS, OUTPUT_PRESET_VALUES);
1113
1216
  const modelTarget = resolveFallbackValue(MODEL_TARGET_ENV_KEYS);
1114
1217
  const schemaTarget = resolveFallbackValue(SCHEMA_TARGET_ENV_KEYS);
1115
1218
  const databaseTarget = resolveFallbackValue(DATABASE_TARGET_ENV_KEYS);
1116
1219
  const registryTarget = resolveFallbackValue(REGISTRY_TARGET_ENV_KEYS);
1117
1220
  const placeholderMap = resolveOptionalJson(PLACEHOLDER_MAP_ENV_KEYS);
1118
- if (format === void 0 && modelTarget === void 0 && schemaTarget === void 0 && databaseTarget === void 0 && registryTarget === void 0 && placeholderMap === void 0) {
1221
+ if (format === void 0 && preset === void 0 && modelTarget === void 0 && schemaTarget === void 0 && databaseTarget === void 0 && registryTarget === void 0 && placeholderMap === void 0) {
1119
1222
  return void 0;
1120
1223
  }
1121
1224
  return {
1122
1225
  format,
1226
+ preset,
1123
1227
  targets: {
1124
1228
  ...modelTarget ? { model: modelTarget } : {},
1125
1229
  ...schemaTarget ? { schema: schemaTarget } : {},
@@ -1129,6 +1233,17 @@ function buildEnvironmentOutputConfig() {
1129
1233
  placeholderMap
1130
1234
  };
1131
1235
  }
1236
+ function buildEnvironmentFilterConfig() {
1237
+ const includeTables = resolveFallbackValue(TABLES_ENV_KEYS);
1238
+ const excludeTables = resolveFallbackValue(EXCLUDE_TABLES_ENV_KEYS);
1239
+ if (includeTables === void 0 && excludeTables === void 0) {
1240
+ return void 0;
1241
+ }
1242
+ return {
1243
+ ...includeTables !== void 0 ? { includeTables } : {},
1244
+ ...excludeTables !== void 0 ? { excludeTables } : {}
1245
+ };
1246
+ }
1132
1247
  function buildEnvironmentNamingConfig() {
1133
1248
  const modelType = resolveOptionalOneOf(MODEL_TYPE_ENV_KEYS, NAMING_STYLE_VALUES);
1134
1249
  const modelConst = resolveOptionalOneOf(MODEL_CONST_ENV_KEYS, NAMING_STYLE_VALUES);
@@ -1204,6 +1319,7 @@ function createEnvironmentGeneratorConfig() {
1204
1319
  provider,
1205
1320
  output: buildEnvironmentOutputConfig(),
1206
1321
  naming: buildEnvironmentNamingConfig(),
1322
+ filter: buildEnvironmentFilterConfig(),
1207
1323
  features: buildEnvironmentFeatureFlags(),
1208
1324
  experimental: buildEnvironmentExperimentalFlags()
1209
1325
  };
@@ -1365,7 +1481,7 @@ ${schemaEntries}
1365
1481
  content
1366
1482
  };
1367
1483
  }
1368
- function renderRegistryArtifact(registryPath, databasePath, databaseConstName, registryConstName, databaseName, generatedAt, outputFormat, schemaVersion) {
1484
+ function renderRegistryArtifact(registryPath, databasePath, databaseConstName, registryConstName, databaseName, generatedAt, outputPreset, outputFormat, schemaVersion) {
1369
1485
  const databaseImportPath = toModuleImportPath(registryPath, databasePath);
1370
1486
  const content = `import { defineRegistry } from '@xylex-group/athena'
1371
1487
  import { ${databaseConstName} } from '${databaseImportPath}'
@@ -1374,6 +1490,7 @@ export const __athena_schema_meta = {
1374
1490
  schemaVersion: ${schemaVersion},
1375
1491
  generatedAt: ${escapeStringLiteral(generatedAt)},
1376
1492
  database: ${escapeStringLiteral(databaseName)},
1493
+ outputPreset: ${escapeStringLiteral(outputPreset)},
1377
1494
  outputFormat: ${escapeStringLiteral(outputFormat)},
1378
1495
  } as const
1379
1496
 
@@ -1543,6 +1660,7 @@ function composeGeneratorArtifacts(input) {
1543
1660
  toSafeIdentifier("registry", config.naming.registryConst, "registry"),
1544
1661
  databaseName,
1545
1662
  snapshot.generatedAt,
1663
+ config.output.preset,
1546
1664
  config.output.format,
1547
1665
  config.internal.schemaVersion
1548
1666
  )
@@ -1648,7 +1766,7 @@ export const ${descriptor.tableConstName} = table(${escapeStringLiteral(descript
1648
1766
  .columns({
1649
1767
  ${columnLines}
1650
1768
  })
1651
- .primaryKey(${descriptor.table.primaryKey.map((value) => escapeStringLiteral(value)).join(", ")})
1769
+ ${descriptor.table.primaryKey.length > 0 ? `.primaryKey(${descriptor.table.primaryKey.map((value) => escapeStringLiteral(value)).join(", ")})` : ".withoutPrimaryKey()"}
1652
1770
  ${relationsAssignment ? `${relationsAssignment}` : ""}
1653
1771
  export type ${descriptor.rowTypeName} = RowOf<typeof ${descriptor.tableConstName}>
1654
1772
  export type ${descriptor.insertTypeName} = InsertOf<typeof ${descriptor.tableConstName}>
@@ -1745,11 +1863,12 @@ ${nullableLines}
1745
1863
  }
1746
1864
  function generateArtifactsFromSnapshot(snapshot, config) {
1747
1865
  const normalizedConfig = "internal" in config ? config : normalizeGeneratorConfig(config);
1866
+ const filteredSnapshot = filterIntrospectionSnapshot(snapshot, normalizedConfig.filter);
1748
1867
  if (normalizedConfig.output.format === "table-builder") {
1749
- return generateTableBuilderArtifactsFromSnapshot(snapshot, normalizedConfig);
1868
+ return generateTableBuilderArtifactsFromSnapshot(filteredSnapshot, normalizedConfig);
1750
1869
  }
1751
1870
  return composeGeneratorArtifacts({
1752
- snapshot,
1871
+ snapshot: filteredSnapshot,
1753
1872
  config: normalizedConfig,
1754
1873
  createModelDescriptor({ providerName, databaseName, schemaName, tableName, table }) {
1755
1874
  const modelConstName = toSafeIdentifier(
@@ -1779,7 +1898,7 @@ function generateArtifactsFromSnapshot(snapshot, config) {
1779
1898
  table
1780
1899
  };
1781
1900
  },
1782
- renderModelArtifact: (descriptor) => renderModelArtifact2(snapshot.database, descriptor, normalizedConfig)
1901
+ renderModelArtifact: (descriptor) => renderModelArtifact2(filteredSnapshot.database, descriptor, normalizedConfig)
1783
1902
  });
1784
1903
  }
1785
1904
 
@@ -1885,7 +2004,7 @@ var getSessionCookie = (request, config) => {
1885
2004
 
1886
2005
  // package.json
1887
2006
  var package_default = {
1888
- version: "2.8.0"
2007
+ version: "2.9.0"
1889
2008
  };
1890
2009
 
1891
2010
  // src/sdk-version.ts
@@ -1898,6 +2017,7 @@ function buildSdkHeaderValue(sdkName) {
1898
2017
  var DEFAULT_CLIENT = "railway_direct";
1899
2018
  var SDK_NAME = "xylex-group/athena";
1900
2019
  var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
2020
+ var NO_CACHE_HEADER_VALUE = "no-cache";
1901
2021
  function parseResponseBody(rawText, contentType) {
1902
2022
  if (!rawText) {
1903
2023
  return { parsed: null, parseFailed: false };
@@ -1916,6 +2036,9 @@ function parseResponseBody(rawText, contentType) {
1916
2036
  function normalizeHeaderValue(value) {
1917
2037
  return value ? value : void 0;
1918
2038
  }
2039
+ function isCacheControlHeaderName(name) {
2040
+ return name.toLowerCase() === "cache-control";
2041
+ }
1919
2042
  function resolveHeaderValue(headers, candidates) {
1920
2043
  for (const candidate of candidates) {
1921
2044
  const direct = normalizeHeaderValue(headers[candidate]);
@@ -2074,6 +2197,7 @@ function buildRpcGetEndpoint(payload) {
2074
2197
  }
2075
2198
  function buildHeaders(config, options) {
2076
2199
  const mergedStripNulls = options?.stripNulls ?? true;
2200
+ const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
2077
2201
  const extraHeaders = {
2078
2202
  ...config.headers ?? {},
2079
2203
  ...options?.headers ?? {}
@@ -2127,11 +2251,15 @@ function buildHeaders(config, options) {
2127
2251
  const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
2128
2252
  Object.entries(extraHeaders).forEach(([key, value]) => {
2129
2253
  if (athenaClientKeys.includes(key)) return;
2254
+ if (forceNoCache && isCacheControlHeaderName(key)) return;
2130
2255
  const normalized = normalizeHeaderValue(value);
2131
2256
  if (normalized) {
2132
2257
  headers[key] = normalized;
2133
2258
  }
2134
2259
  });
2260
+ if (forceNoCache) {
2261
+ headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
2262
+ }
2135
2263
  return headers;
2136
2264
  }
2137
2265
  function toInvalidUrlResponse(error, endpoint, method) {
@@ -2571,6 +2699,35 @@ function quoteSelectColumnsExpression(columns) {
2571
2699
  }
2572
2700
  return tokens.map(quoteSelectToken).join(", ");
2573
2701
  }
2702
+ var ATHENA_AUTH_MAX_TEMPLATE_VARIABLES = 64;
2703
+ var ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH = 128;
2704
+ function describeTemplateVariableTarget(target) {
2705
+ const normalized = target?.trim();
2706
+ return normalized && normalized.length > 0 ? normalized : "Athena auth admin email template variables";
2707
+ }
2708
+ function assertAthenaAuthTemplateVariables(variables, target) {
2709
+ const label = describeTemplateVariableTarget(target);
2710
+ if (!Array.isArray(variables)) {
2711
+ throw new Error(`${label} must be an array of strings.`);
2712
+ }
2713
+ if (variables.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLES) {
2714
+ throw new Error(
2715
+ `${label} cannot contain more than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLES} entries.`
2716
+ );
2717
+ }
2718
+ variables.forEach((variable, index) => {
2719
+ if (typeof variable !== "string") {
2720
+ throw new Error(
2721
+ `${label} must contain only strings. Received ${typeof variable} at index ${index}.`
2722
+ );
2723
+ }
2724
+ if (variable.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH) {
2725
+ throw new Error(
2726
+ `${label} cannot contain entries longer than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH} characters. Received ${variable.length} characters at index ${index}.`
2727
+ );
2728
+ }
2729
+ });
2730
+ }
2574
2731
 
2575
2732
  // src/auth/react-email.ts
2576
2733
  var reactEmailRenderModulePromise;
@@ -2760,6 +2917,7 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
2760
2917
  var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
2761
2918
  var SDK_NAME2 = "xylex-group/athena-auth";
2762
2919
  var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
2920
+ var NO_CACHE_HEADER_VALUE2 = "no-cache";
2763
2921
  function normalizeBaseUrl(baseUrl) {
2764
2922
  return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
2765
2923
  }
@@ -2769,6 +2927,9 @@ function isRecord4(value) {
2769
2927
  function normalizeHeaderValue2(value) {
2770
2928
  return value ? value : void 0;
2771
2929
  }
2930
+ function isCacheControlHeaderName2(name) {
2931
+ return name.toLowerCase() === "cache-control";
2932
+ }
2772
2933
  function parseResponseBody2(rawText, contentType) {
2773
2934
  if (!rawText) {
2774
2935
  return { parsed: null, parseFailed: false };
@@ -2824,6 +2985,54 @@ function mergeCallOptions(base, override) {
2824
2985
  }
2825
2986
  };
2826
2987
  }
2988
+ function toSessionGuardFailure(sessionResult) {
2989
+ if (sessionResult.status === 401 || sessionResult.data == null) {
2990
+ return {
2991
+ ok: false,
2992
+ reason: "unauthorized",
2993
+ status: 401,
2994
+ error: sessionResult.error ?? "Unauthorized",
2995
+ sessionResult
2996
+ };
2997
+ }
2998
+ return {
2999
+ ok: false,
3000
+ reason: "upstream_error",
3001
+ status: sessionResult.status,
3002
+ error: sessionResult.error ?? "Failed to resolve current session",
3003
+ sessionResult
3004
+ };
3005
+ }
3006
+ function toPermissionGuardFailure(permissionResult, sessionResult) {
3007
+ if (permissionResult.status === 401) {
3008
+ return {
3009
+ ok: false,
3010
+ reason: "unauthorized",
3011
+ status: 401,
3012
+ error: permissionResult.error ?? "Unauthorized",
3013
+ sessionResult,
3014
+ permissionResult
3015
+ };
3016
+ }
3017
+ if (permissionResult.status === 403) {
3018
+ return {
3019
+ ok: false,
3020
+ reason: "forbidden",
3021
+ status: 403,
3022
+ error: permissionResult.error ?? "Forbidden",
3023
+ sessionResult,
3024
+ permissionResult
3025
+ };
3026
+ }
3027
+ return {
3028
+ ok: false,
3029
+ reason: "upstream_error",
3030
+ status: permissionResult.status,
3031
+ error: permissionResult.error ?? "Failed to resolve permission check",
3032
+ sessionResult,
3033
+ permissionResult
3034
+ };
3035
+ }
2827
3036
  function extractFetchOptions(input) {
2828
3037
  if (!input) {
2829
3038
  return {
@@ -2839,6 +3048,7 @@ function extractFetchOptions(input) {
2839
3048
  };
2840
3049
  }
2841
3050
  function buildHeaders2(config, options) {
3051
+ const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
2842
3052
  const headers = {
2843
3053
  "Content-Type": "application/json",
2844
3054
  "X-Athena-Sdk": SDK_HEADER_VALUE2
@@ -2852,16 +3062,30 @@ function buildHeaders2(config, options) {
2852
3062
  if (bearerToken) {
2853
3063
  headers.Authorization = `Bearer ${bearerToken}`;
2854
3064
  }
3065
+ const cookie = options?.cookie ?? config.cookie;
3066
+ if (cookie) {
3067
+ headers.Cookie = cookie;
3068
+ }
3069
+ const sessionToken = options?.sessionToken ?? config.sessionToken;
3070
+ if (sessionToken) {
3071
+ headers["X-Athena-Auth-Session-Token"] = sessionToken;
3072
+ }
2855
3073
  const mergedExtraHeaders = {
2856
3074
  ...config.headers ?? {},
2857
3075
  ...options?.headers ?? {}
2858
3076
  };
2859
3077
  Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
3078
+ if (forceNoCache && isCacheControlHeaderName2(key)) {
3079
+ return;
3080
+ }
2860
3081
  const normalized = normalizeHeaderValue2(value);
2861
3082
  if (normalized) {
2862
3083
  headers[key] = normalized;
2863
3084
  }
2864
3085
  });
3086
+ if (forceNoCache) {
3087
+ headers["Cache-Control"] = NO_CACHE_HEADER_VALUE2;
3088
+ }
2865
3089
  return headers;
2866
3090
  }
2867
3091
  function appendQueryParam(searchParams, key, value) {
@@ -3126,7 +3350,91 @@ function createAuthClient(config = {}) {
3126
3350
  htmlField: "htmlTemplate",
3127
3351
  textField: "textTemplate",
3128
3352
  variablesField: "variables"
3129
- }, withReactEmailRoute(route));
3353
+ }, withReactEmailRoute(route)).then((payload) => {
3354
+ if ("variables" in payload && payload.variables !== void 0 && payload.variables !== null) {
3355
+ assertAthenaAuthTemplateVariables(
3356
+ payload.variables,
3357
+ `${route} variables`
3358
+ );
3359
+ }
3360
+ return payload;
3361
+ });
3362
+ const requireSession = async (input, options) => {
3363
+ const sessionInput = input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0;
3364
+ const sessionResult = await getGeneric(
3365
+ "/get-session",
3366
+ sessionInput,
3367
+ options
3368
+ );
3369
+ if (!sessionResult.ok || sessionResult.data == null) {
3370
+ return toSessionGuardFailure(sessionResult);
3371
+ }
3372
+ return {
3373
+ ok: true,
3374
+ session: sessionResult.data
3375
+ };
3376
+ };
3377
+ const getUser = async (input, options) => {
3378
+ const sessionResult = await getGeneric(
3379
+ "/get-session",
3380
+ input,
3381
+ options
3382
+ );
3383
+ if (!sessionResult.ok) {
3384
+ return {
3385
+ ...sessionResult,
3386
+ data: null
3387
+ };
3388
+ }
3389
+ return {
3390
+ ...sessionResult,
3391
+ data: {
3392
+ user: sessionResult.data?.user ?? null
3393
+ }
3394
+ };
3395
+ };
3396
+ const requirePermission = async (endpoint, input, options) => {
3397
+ const sessionGuard = await requireSession(
3398
+ input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0,
3399
+ options
3400
+ );
3401
+ if (!sessionGuard.ok) {
3402
+ return sessionGuard;
3403
+ }
3404
+ const permissionResult = await postGeneric(
3405
+ endpoint,
3406
+ input,
3407
+ options
3408
+ );
3409
+ if (!permissionResult.ok) {
3410
+ return toPermissionGuardFailure(permissionResult, {
3411
+ ok: true,
3412
+ status: 200,
3413
+ data: sessionGuard.session,
3414
+ error: null,
3415
+ errorDetails: null,
3416
+ raw: sessionGuard.session
3417
+ });
3418
+ }
3419
+ if (!permissionResult.data?.success) {
3420
+ return {
3421
+ ok: false,
3422
+ reason: "forbidden",
3423
+ status: 403,
3424
+ error: permissionResult.data?.error ?? "Forbidden",
3425
+ sessionResult: {
3426
+ ok: true,
3427
+ status: 200,
3428
+ data: sessionGuard.session,
3429
+ error: null,
3430
+ errorDetails: null,
3431
+ raw: sessionGuard.session
3432
+ },
3433
+ permissionResult
3434
+ };
3435
+ }
3436
+ return sessionGuard;
3437
+ };
3130
3438
  const listUserEmailsWithFallback = async (input, options) => {
3131
3439
  const primary = await getWithQuery(
3132
3440
  "/email/list",
@@ -3288,6 +3596,7 @@ function createAuthClient(config = {}) {
3288
3596
  input,
3289
3597
  options
3290
3598
  ),
3599
+ requirePermission: (input, options) => requirePermission("/organization/has-permission", input, options),
3291
3600
  invitation: {
3292
3601
  cancel: (input, options) => executePostWithCompatibleInput(
3293
3602
  resolvedConfig,
@@ -3483,6 +3792,8 @@ function createAuthClient(config = {}) {
3483
3792
  };
3484
3793
  const auth = {
3485
3794
  getSession: (input, options) => getGeneric("/get-session", input, options),
3795
+ getUser,
3796
+ requireSession,
3486
3797
  signOut,
3487
3798
  forgetPassword: (input, options) => postGeneric("/forget-password", input, options),
3488
3799
  resetPassword: authResetPassword,
@@ -3577,6 +3888,7 @@ function createAuthClient(config = {}) {
3577
3888
  }
3578
3889
  },
3579
3890
  hasPermission: (input, options) => postGeneric("/admin/has-permission", input, options),
3891
+ requirePermission: (input, options) => requirePermission("/admin/has-permission", input, options),
3580
3892
  apiKey: {
3581
3893
  create: (input, options) => postGeneric("/admin/api-key/create", input, options)
3582
3894
  },
@@ -3728,6 +4040,8 @@ function createAuthClient(config = {}) {
3728
4040
  input,
3729
4041
  options
3730
4042
  ),
4043
+ getUser,
4044
+ requireSession,
3731
4045
  listSessions: (input, options) => executeGetWithCompatibleInput(
3732
4046
  resolvedConfig,
3733
4047
  { endpoint: "/list-sessions", method: "GET" },
@@ -3881,7 +4195,12 @@ function createStorageFileModule(base, config = {}) {
3881
4195
  content_type: input.content_type ?? source.contentType,
3882
4196
  size_bytes: source.sizeBytes,
3883
4197
  public: input.public,
3884
- metadata: input.metadata
4198
+ metadata: input.metadata,
4199
+ server_side_encryption: input.server_side_encryption,
4200
+ sse: input.sse,
4201
+ ssekms_key_id: input.ssekms_key_id,
4202
+ kms_key_id: input.kms_key_id,
4203
+ bucket_key_enabled: input.bucket_key_enabled
3885
4204
  }
3886
4205
  };
3887
4206
  });
@@ -3892,10 +4211,17 @@ function createStorageFileModule(base, config = {}) {
3892
4211
  for (let index = 0; index < uploadRequests.length; index += 1) {
3893
4212
  const request = uploadRequests[index];
3894
4213
  const uploadUrl = uploadUrls[index];
3895
- const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
3896
- aggregateLoaded[index] = progress.loaded;
3897
- input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3898
- });
4214
+ const response = await putUploadBody(
4215
+ uploadUrl.upload.url,
4216
+ uploadUrl.upload.headers ?? {},
4217
+ request.source,
4218
+ input,
4219
+ options,
4220
+ (progress) => {
4221
+ aggregateLoaded[index] = progress.loaded;
4222
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
4223
+ }
4224
+ );
3899
4225
  uploaded.push({
3900
4226
  file: uploadUrl.file,
3901
4227
  upload: uploadUrl.upload,
@@ -3998,8 +4324,9 @@ function validateUploadConstraints(sources, input) {
3998
4324
  }
3999
4325
  }
4000
4326
  }
4001
- async function putUploadBody(url, source, input, options, onProgress) {
4002
- const headers = new Headers(input.uploadHeaders);
4327
+ async function putUploadBody(url, uploadHeaders, source, input, options, onProgress) {
4328
+ const headers = new Headers(uploadHeaders);
4329
+ new Headers(input.uploadHeaders).forEach((value, key) => headers.set(key, value));
4003
4330
  if (source.contentType && !headers.has("Content-Type")) {
4004
4331
  headers.set("Content-Type", source.contentType);
4005
4332
  }
@@ -4210,129 +4537,624 @@ var storageSdkManifest = {
4210
4537
  responseType: "{ data: S3CatalogItem[] }"
4211
4538
  },
4212
4539
  {
4213
- name: "createStorageCatalog",
4540
+ name: "createStorageCatalog",
4541
+ method: "POST",
4542
+ path: "/storage/catalogs",
4543
+ requestType: "CreateStorageCatalogRequest",
4544
+ responseEnvelope: "raw",
4545
+ responseType: "S3CatalogItem"
4546
+ },
4547
+ {
4548
+ name: "updateStorageCatalog",
4549
+ method: "PATCH",
4550
+ path: "/storage/catalogs/{id}",
4551
+ pathParams: ["id"],
4552
+ requestType: "UpdateStorageCatalogRequest",
4553
+ responseEnvelope: "raw",
4554
+ responseType: "S3CatalogItem"
4555
+ },
4556
+ {
4557
+ name: "deleteStorageCatalog",
4558
+ method: "DELETE",
4559
+ path: "/storage/catalogs/{id}",
4560
+ pathParams: ["id"],
4561
+ responseEnvelope: "raw",
4562
+ responseType: "{ id: string; deleted: boolean }"
4563
+ },
4564
+ {
4565
+ name: "listStorageCredentials",
4566
+ method: "GET",
4567
+ path: "/storage/credentials",
4568
+ responseEnvelope: "raw",
4569
+ responseType: "{ data: S3CredentialListItem[] }"
4570
+ },
4571
+ {
4572
+ name: "createStorageUploadUrl",
4573
+ method: "POST",
4574
+ path: "/storage/files/upload-url",
4575
+ requestType: "CreateStorageUploadUrlRequest",
4576
+ responseEnvelope: "athena",
4577
+ responseType: "StorageUploadUrlResponse"
4578
+ },
4579
+ {
4580
+ name: "createStorageUploadUrls",
4581
+ method: "POST",
4582
+ path: "/storage/files/upload-urls",
4583
+ requestType: "CreateStorageUploadUrlsRequest",
4584
+ responseEnvelope: "athena",
4585
+ responseType: "StorageBatchUploadUrlResponse"
4586
+ },
4587
+ {
4588
+ name: "listStorageFiles",
4589
+ method: "POST",
4590
+ path: "/storage/files/list",
4591
+ requestType: "ListStorageFilesRequest",
4592
+ responseEnvelope: "athena",
4593
+ responseType: "StorageListFilesResponse"
4594
+ },
4595
+ {
4596
+ name: "getStorageFile",
4597
+ method: "GET",
4598
+ path: "/storage/files/{file_id}",
4599
+ pathParams: ["file_id"],
4600
+ responseEnvelope: "athena",
4601
+ responseType: "StorageFileMutationResponse"
4602
+ },
4603
+ {
4604
+ name: "getStorageFileUrl",
4605
+ method: "GET",
4606
+ path: "/storage/files/{file_id}/url",
4607
+ pathParams: ["file_id"],
4608
+ queryParams: ["purpose"],
4609
+ responseEnvelope: "athena",
4610
+ responseType: "PresignedFileUrlResponse"
4611
+ },
4612
+ {
4613
+ name: "getStorageFileProxy",
4614
+ method: "GET",
4615
+ path: "/storage/files/{file_id}/proxy",
4616
+ pathParams: ["file_id"],
4617
+ queryParams: ["purpose"],
4618
+ responseEnvelope: "raw",
4619
+ responseType: "Response",
4620
+ binary: true
4621
+ },
4622
+ {
4623
+ name: "updateStorageFile",
4624
+ method: "PATCH",
4625
+ path: "/storage/files/{file_id}",
4626
+ pathParams: ["file_id"],
4627
+ requestType: "UpdateStorageFileRequest",
4628
+ responseEnvelope: "athena",
4629
+ responseType: "StorageFileMutationResponse"
4630
+ },
4631
+ {
4632
+ name: "deleteStorageFile",
4633
+ method: "DELETE",
4634
+ path: "/storage/files/{file_id}",
4635
+ pathParams: ["file_id"],
4636
+ responseEnvelope: "athena",
4637
+ responseType: "StorageFileMutationResponse"
4638
+ },
4639
+ {
4640
+ name: "setStorageFileVisibility",
4641
+ method: "PATCH",
4642
+ path: "/storage/files/{file_id}/visibility",
4643
+ pathParams: ["file_id"],
4644
+ requestType: "SetStorageFileVisibilityRequest",
4645
+ responseEnvelope: "athena",
4646
+ responseType: "StorageFileMutationResponse"
4647
+ },
4648
+ {
4649
+ name: "postStorageFileVisibility",
4650
+ method: "POST",
4651
+ path: "/storage/files/{file_id}/visibility",
4652
+ pathParams: ["file_id"],
4653
+ requestType: "SetStorageFileVisibilityRequest",
4654
+ responseEnvelope: "athena",
4655
+ responseType: "StorageFileMutationResponse"
4656
+ },
4657
+ {
4658
+ name: "setManyStorageFileVisibility",
4659
+ method: "POST",
4660
+ path: "/storage/files/visibility-many",
4661
+ requestType: "SetManyStorageFileVisibilityRequest",
4662
+ responseEnvelope: "athena",
4663
+ responseType: "StorageFileMutationManyResponse"
4664
+ },
4665
+ {
4666
+ name: "deleteStorageFolder",
4667
+ method: "POST",
4668
+ path: "/storage/folders/delete",
4669
+ requestType: "DeleteStorageFolderRequest",
4670
+ responseEnvelope: "athena",
4671
+ responseType: "StorageFolderMutationResponse"
4672
+ },
4673
+ {
4674
+ name: "moveStorageFolder",
4675
+ method: "POST",
4676
+ path: "/storage/folders/move",
4677
+ requestType: "MoveStorageFolderRequest",
4678
+ responseEnvelope: "athena",
4679
+ responseType: "StorageFolderMutationResponse"
4680
+ },
4681
+ {
4682
+ name: "searchStorageFiles",
4683
+ method: "POST",
4684
+ path: "/storage/files/search",
4685
+ requestType: "SearchStorageFilesRequest",
4686
+ responseEnvelope: "athena",
4687
+ responseType: "StorageListFilesResponse"
4688
+ },
4689
+ {
4690
+ name: "confirmStorageUpload",
4691
+ method: "POST",
4692
+ path: "/storage/files/{file_id}/confirm-upload",
4693
+ pathParams: ["file_id"],
4694
+ requestType: "ConfirmStorageUploadRequest",
4695
+ responseEnvelope: "athena",
4696
+ responseType: "StorageFileMutationResponse"
4697
+ },
4698
+ {
4699
+ name: "uploadStorageFileBinary",
4700
+ method: "PUT",
4701
+ path: "/storage/files/{file_id}/upload",
4702
+ pathParams: ["file_id"],
4703
+ responseEnvelope: "athena",
4704
+ responseType: "StorageFileMutationResponse",
4705
+ binary: true
4706
+ },
4707
+ {
4708
+ name: "copyStorageFile",
4709
+ method: "POST",
4710
+ path: "/storage/files/{file_id}/copy",
4711
+ pathParams: ["file_id"],
4712
+ requestType: "CopyStorageFileRequest",
4713
+ responseEnvelope: "athena",
4714
+ responseType: "StorageFileMutationResponse"
4715
+ },
4716
+ {
4717
+ name: "deleteManyStorageFiles",
4718
+ method: "POST",
4719
+ path: "/storage/files/delete-many",
4720
+ requestType: "DeleteManyStorageFilesRequest",
4721
+ responseEnvelope: "athena",
4722
+ responseType: "StorageFileMutationManyResponse"
4723
+ },
4724
+ {
4725
+ name: "updateManyStorageFiles",
4726
+ method: "POST",
4727
+ path: "/storage/files/update-many",
4728
+ requestType: "UpdateManyStorageFilesRequest",
4729
+ responseEnvelope: "athena",
4730
+ responseType: "StorageFileMutationManyResponse"
4731
+ },
4732
+ {
4733
+ name: "restoreStorageFile",
4734
+ method: "POST",
4735
+ path: "/storage/files/{file_id}/restore",
4736
+ pathParams: ["file_id"],
4737
+ responseEnvelope: "athena",
4738
+ responseType: "StorageFileMutationResponse"
4739
+ },
4740
+ {
4741
+ name: "purgeStorageFile",
4742
+ method: "DELETE",
4743
+ path: "/storage/files/{file_id}/purge",
4744
+ pathParams: ["file_id"],
4745
+ responseEnvelope: "athena",
4746
+ responseType: "StorageFileMutationResponse"
4747
+ },
4748
+ {
4749
+ name: "getStorageFilePublicUrl",
4750
+ method: "GET",
4751
+ path: "/storage/files/{file_id}/public-url",
4752
+ pathParams: ["file_id"],
4753
+ responseEnvelope: "athena",
4754
+ responseType: "Record<string, unknown>"
4755
+ },
4756
+ {
4757
+ name: "getStorageFileProxyUrl",
4758
+ method: "GET",
4759
+ path: "/storage/files/{file_id}/proxy-url",
4760
+ pathParams: ["file_id"],
4761
+ queryParams: ["purpose"],
4762
+ responseEnvelope: "athena",
4763
+ responseType: "Record<string, unknown>"
4764
+ },
4765
+ {
4766
+ name: "listStorageFileVersions",
4767
+ method: "GET",
4768
+ path: "/storage/files/{file_id}/versions",
4769
+ pathParams: ["file_id"],
4770
+ responseEnvelope: "athena",
4771
+ responseType: "Record<string, unknown>"
4772
+ },
4773
+ {
4774
+ name: "restoreStorageFileVersion",
4775
+ method: "POST",
4776
+ path: "/storage/files/{file_id}/versions/{version_id}/restore",
4777
+ pathParams: ["file_id", "version_id"],
4778
+ responseEnvelope: "athena",
4779
+ responseType: "Record<string, unknown>"
4780
+ },
4781
+ {
4782
+ name: "deleteStorageFileVersion",
4783
+ method: "DELETE",
4784
+ path: "/storage/files/{file_id}/versions/{version_id}",
4785
+ pathParams: ["file_id", "version_id"],
4786
+ responseEnvelope: "athena",
4787
+ responseType: "Record<string, unknown>"
4788
+ },
4789
+ {
4790
+ name: "getStorageFileRetention",
4791
+ method: "GET",
4792
+ path: "/storage/files/{file_id}/retention",
4793
+ pathParams: ["file_id"],
4794
+ queryParams: ["version_id"],
4795
+ responseEnvelope: "athena",
4796
+ responseType: "Record<string, unknown>"
4797
+ },
4798
+ {
4799
+ name: "setStorageFileRetention",
4800
+ method: "POST",
4801
+ path: "/storage/files/{file_id}/retention",
4802
+ pathParams: ["file_id"],
4803
+ requestType: "StorageFileRetentionRequest",
4804
+ responseEnvelope: "athena",
4805
+ responseType: "Record<string, unknown>"
4806
+ },
4807
+ {
4808
+ name: "listStorageFolders",
4809
+ method: "POST",
4810
+ path: "/storage/folders/list",
4811
+ requestType: "ListStorageFoldersRequest",
4812
+ responseEnvelope: "athena",
4813
+ responseType: "Record<string, unknown>"
4814
+ },
4815
+ {
4816
+ name: "treeStorageFolders",
4817
+ method: "POST",
4818
+ path: "/storage/folders/tree",
4819
+ requestType: "TreeStorageFoldersRequest",
4820
+ responseEnvelope: "athena",
4821
+ responseType: "Record<string, unknown>"
4822
+ },
4823
+ {
4824
+ name: "listStoragePermissions",
4825
+ method: "POST",
4826
+ path: "/storage/permissions/list",
4827
+ requestType: "StoragePermissionListRequest",
4828
+ responseEnvelope: "athena",
4829
+ responseType: "StoragePermissionListResponse"
4830
+ },
4831
+ {
4832
+ name: "grantStoragePermission",
4833
+ method: "POST",
4834
+ path: "/storage/permissions/grant",
4835
+ requestType: "StoragePermissionGrantRequest",
4836
+ responseEnvelope: "athena",
4837
+ responseType: "Record<string, unknown>"
4838
+ },
4839
+ {
4840
+ name: "revokeStoragePermission",
4841
+ method: "POST",
4842
+ path: "/storage/permissions/revoke",
4843
+ requestType: "StoragePermissionRevokeRequest",
4844
+ responseEnvelope: "athena",
4845
+ responseType: "Record<string, unknown>"
4846
+ },
4847
+ {
4848
+ name: "checkStoragePermission",
4849
+ method: "POST",
4850
+ path: "/storage/permissions/check",
4851
+ requestType: "StoragePermissionCheckRequest",
4852
+ responseEnvelope: "athena",
4853
+ responseType: "StoragePermissionCheckResponse"
4854
+ },
4855
+ {
4856
+ name: "listStorageObjects",
4857
+ method: "POST",
4858
+ path: "/storage/objects",
4859
+ requestType: "StorageListObjectsRequest",
4860
+ responseEnvelope: "athena",
4861
+ responseType: "Record<string, unknown>"
4862
+ },
4863
+ {
4864
+ name: "headStorageObject",
4865
+ method: "POST",
4866
+ path: "/storage/objects/head",
4867
+ requestType: "StorageObjectRequest",
4868
+ responseEnvelope: "athena",
4869
+ responseType: "Record<string, unknown>"
4870
+ },
4871
+ {
4872
+ name: "existsStorageObject",
4873
+ method: "POST",
4874
+ path: "/storage/objects/exists",
4875
+ requestType: "StorageObjectRequest",
4876
+ responseEnvelope: "athena",
4877
+ responseType: "Record<string, unknown>"
4878
+ },
4879
+ {
4880
+ name: "validateStorageObject",
4881
+ method: "POST",
4882
+ path: "/storage/objects/validate",
4883
+ requestType: "StorageObjectValidateRequest",
4884
+ responseEnvelope: "athena",
4885
+ responseType: "Record<string, unknown>"
4886
+ },
4887
+ {
4888
+ name: "updateStorageObject",
4889
+ method: "POST",
4890
+ path: "/storage/objects/update",
4891
+ requestType: "StorageUpdateObjectRequest",
4892
+ responseEnvelope: "athena",
4893
+ responseType: "Record<string, unknown>"
4894
+ },
4895
+ {
4896
+ name: "copyStorageObject",
4897
+ method: "POST",
4898
+ path: "/storage/objects/copy",
4899
+ requestType: "StorageObjectCopyRequest",
4900
+ responseEnvelope: "athena",
4901
+ responseType: "Record<string, unknown>"
4902
+ },
4903
+ {
4904
+ name: "getStorageObjectUrl",
4905
+ method: "POST",
4906
+ path: "/storage/objects/url",
4907
+ requestType: "StorageObjectRequest",
4908
+ responseEnvelope: "athena",
4909
+ responseType: "Record<string, unknown>"
4910
+ },
4911
+ {
4912
+ name: "getStorageObjectPublicUrl",
4913
+ method: "POST",
4914
+ path: "/storage/objects/public-url",
4915
+ requestType: "StorageObjectPublicUrlRequest",
4916
+ responseEnvelope: "athena",
4917
+ responseType: "Record<string, unknown>"
4918
+ },
4919
+ {
4920
+ name: "deleteStorageObject",
4921
+ method: "POST",
4922
+ path: "/storage/objects/delete",
4923
+ requestType: "StorageObjectRequest",
4924
+ responseEnvelope: "athena",
4925
+ responseType: "Record<string, unknown>"
4926
+ },
4927
+ {
4928
+ name: "createStorageObjectUploadUrl",
4929
+ method: "POST",
4930
+ path: "/storage/objects/upload-url",
4931
+ requestType: "StoragePresignUploadRequest",
4932
+ responseEnvelope: "athena",
4933
+ responseType: "Record<string, unknown>"
4934
+ },
4935
+ {
4936
+ name: "createStorageObjectPostPolicy",
4937
+ method: "POST",
4938
+ path: "/storage/objects/post-policy",
4939
+ requestType: "StorageSignedPostPolicyRequest",
4940
+ responseEnvelope: "athena",
4941
+ responseType: "Record<string, unknown>"
4942
+ },
4943
+ {
4944
+ name: "listStorageObjectVersions",
4945
+ method: "POST",
4946
+ path: "/storage/objects/versions",
4947
+ requestType: "StorageObjectVersionListRequest",
4948
+ responseEnvelope: "athena",
4949
+ responseType: "Record<string, unknown>"
4950
+ },
4951
+ {
4952
+ name: "restoreStorageObjectVersion",
4953
+ method: "POST",
4954
+ path: "/storage/objects/versions/restore",
4955
+ requestType: "StorageObjectVersionMutationRequest",
4956
+ responseEnvelope: "athena",
4957
+ responseType: "Record<string, unknown>"
4958
+ },
4959
+ {
4960
+ name: "deleteStorageObjectVersion",
4961
+ method: "POST",
4962
+ path: "/storage/objects/versions/delete",
4963
+ requestType: "StorageObjectVersionMutationRequest",
4964
+ responseEnvelope: "athena",
4965
+ responseType: "Record<string, unknown>"
4966
+ },
4967
+ {
4968
+ name: "createStorageObjectFolder",
4969
+ method: "POST",
4970
+ path: "/storage/objects/folder",
4971
+ requestType: "StorageObjectFolderCreateRequest",
4972
+ responseEnvelope: "athena",
4973
+ responseType: "Record<string, unknown>"
4974
+ },
4975
+ {
4976
+ name: "deleteStorageObjectFolder",
4977
+ method: "POST",
4978
+ path: "/storage/objects/folder/delete",
4979
+ requestType: "StorageObjectFolderDeleteRequest",
4980
+ responseEnvelope: "athena",
4981
+ responseType: "Record<string, unknown>"
4982
+ },
4983
+ {
4984
+ name: "renameStorageObjectFolder",
4985
+ method: "POST",
4986
+ path: "/storage/objects/folder/rename",
4987
+ requestType: "StorageObjectFolderRenameRequest",
4988
+ responseEnvelope: "athena",
4989
+ responseType: "Record<string, unknown>"
4990
+ },
4991
+ {
4992
+ name: "listStorageBuckets",
4993
+ method: "POST",
4994
+ path: "/storage/buckets/list",
4995
+ requestType: "Omit<StorageObjectBaseRequest, 'bucket'>",
4996
+ responseEnvelope: "athena",
4997
+ responseType: "Record<string, unknown>"
4998
+ },
4999
+ {
5000
+ name: "createStorageBucket",
5001
+ method: "POST",
5002
+ path: "/storage/buckets/create",
5003
+ requestType: "StorageObjectBaseRequest",
5004
+ responseEnvelope: "athena",
5005
+ responseType: "Record<string, unknown>"
5006
+ },
5007
+ {
5008
+ name: "deleteStorageBucket",
5009
+ method: "POST",
5010
+ path: "/storage/buckets/delete",
5011
+ requestType: "StorageObjectBaseRequest",
5012
+ responseEnvelope: "athena",
5013
+ responseType: "Record<string, unknown>"
5014
+ },
5015
+ {
5016
+ name: "getStorageBucketLifecycle",
5017
+ method: "POST",
5018
+ path: "/storage/buckets/lifecycle",
5019
+ requestType: "StorageBucketLifecycleRequest",
5020
+ responseEnvelope: "athena",
5021
+ responseType: "Record<string, unknown>"
5022
+ },
5023
+ {
5024
+ name: "setStorageBucketLifecycle",
5025
+ method: "POST",
5026
+ path: "/storage/buckets/lifecycle/set",
5027
+ requestType: "StorageSetBucketLifecycleRequest",
5028
+ responseEnvelope: "athena",
5029
+ responseType: "Record<string, unknown>"
5030
+ },
5031
+ {
5032
+ name: "deleteStorageBucketLifecycle",
5033
+ method: "POST",
5034
+ path: "/storage/buckets/lifecycle/delete",
5035
+ requestType: "StorageBucketLifecycleRequest",
5036
+ responseEnvelope: "athena",
5037
+ responseType: "Record<string, unknown>"
5038
+ },
5039
+ {
5040
+ name: "getStorageBucketPolicy",
4214
5041
  method: "POST",
4215
- path: "/storage/catalogs",
4216
- requestType: "CreateStorageCatalogRequest",
4217
- responseEnvelope: "raw",
4218
- responseType: "S3CatalogItem"
5042
+ path: "/storage/buckets/policy",
5043
+ requestType: "StorageBucketPolicyRequest",
5044
+ responseEnvelope: "athena",
5045
+ responseType: "Record<string, unknown>"
4219
5046
  },
4220
5047
  {
4221
- name: "updateStorageCatalog",
4222
- method: "PATCH",
4223
- path: "/storage/catalogs/{id}",
4224
- pathParams: ["id"],
4225
- requestType: "UpdateStorageCatalogRequest",
4226
- responseEnvelope: "raw",
4227
- responseType: "S3CatalogItem"
5048
+ name: "setStorageBucketPolicy",
5049
+ method: "POST",
5050
+ path: "/storage/buckets/policy/set",
5051
+ requestType: "StorageSetBucketPolicyRequest",
5052
+ responseEnvelope: "athena",
5053
+ responseType: "Record<string, unknown>"
4228
5054
  },
4229
5055
  {
4230
- name: "deleteStorageCatalog",
4231
- method: "DELETE",
4232
- path: "/storage/catalogs/{id}",
4233
- pathParams: ["id"],
4234
- responseEnvelope: "raw",
4235
- responseType: "{ id: string; deleted: boolean }"
5056
+ name: "deleteStorageBucketPolicy",
5057
+ method: "POST",
5058
+ path: "/storage/buckets/policy/delete",
5059
+ requestType: "StorageBucketPolicyRequest",
5060
+ responseEnvelope: "athena",
5061
+ responseType: "Record<string, unknown>"
4236
5062
  },
4237
5063
  {
4238
- name: "listStorageCredentials",
4239
- method: "GET",
4240
- path: "/storage/credentials",
4241
- responseEnvelope: "raw",
4242
- responseType: "{ data: S3CredentialListItem[] }"
5064
+ name: "getStorageBucketPublicAccess",
5065
+ method: "POST",
5066
+ path: "/storage/buckets/public-access",
5067
+ requestType: "StoragePublicAccessBlockRequest",
5068
+ responseEnvelope: "athena",
5069
+ responseType: "Record<string, unknown>"
4243
5070
  },
4244
5071
  {
4245
- name: "createStorageUploadUrl",
5072
+ name: "setStorageBucketPublicAccess",
4246
5073
  method: "POST",
4247
- path: "/storage/files/upload-url",
4248
- requestType: "CreateStorageUploadUrlRequest",
5074
+ path: "/storage/buckets/public-access/set",
5075
+ requestType: "StorageSetPublicAccessBlockRequest",
4249
5076
  responseEnvelope: "athena",
4250
- responseType: "StorageUploadUrlResponse"
5077
+ responseType: "Record<string, unknown>"
4251
5078
  },
4252
5079
  {
4253
- name: "createStorageUploadUrls",
5080
+ name: "deleteStorageBucketPublicAccess",
4254
5081
  method: "POST",
4255
- path: "/storage/files/upload-urls",
4256
- requestType: "CreateStorageUploadUrlsRequest",
5082
+ path: "/storage/buckets/public-access/delete",
5083
+ requestType: "StoragePublicAccessBlockRequest",
4257
5084
  responseEnvelope: "athena",
4258
- responseType: "StorageBatchUploadUrlResponse"
5085
+ responseType: "Record<string, unknown>"
4259
5086
  },
4260
5087
  {
4261
- name: "listStorageFiles",
5088
+ name: "getStorageBucketCors",
4262
5089
  method: "POST",
4263
- path: "/storage/files/list",
4264
- requestType: "ListStorageFilesRequest",
5090
+ path: "/storage/buckets/cors",
5091
+ requestType: "StorageBucketCorsRequest",
4265
5092
  responseEnvelope: "athena",
4266
- responseType: "StorageListFilesResponse"
5093
+ responseType: "Record<string, unknown>"
4267
5094
  },
4268
5095
  {
4269
- name: "getStorageFile",
4270
- method: "GET",
4271
- path: "/storage/files/{file_id}",
4272
- pathParams: ["file_id"],
5096
+ name: "setStorageBucketCors",
5097
+ method: "POST",
5098
+ path: "/storage/buckets/cors/set",
5099
+ requestType: "StorageSetBucketCorsRequest",
4273
5100
  responseEnvelope: "athena",
4274
- responseType: "StorageFileMutationResponse"
5101
+ responseType: "Record<string, unknown>"
4275
5102
  },
4276
5103
  {
4277
- name: "getStorageFileUrl",
4278
- method: "GET",
4279
- path: "/storage/files/{file_id}/url",
4280
- pathParams: ["file_id"],
4281
- queryParams: ["purpose"],
5104
+ name: "deleteStorageBucketCors",
5105
+ method: "POST",
5106
+ path: "/storage/buckets/cors/delete",
5107
+ requestType: "StorageBucketCorsRequest",
4282
5108
  responseEnvelope: "athena",
4283
- responseType: "PresignedFileUrlResponse"
5109
+ responseType: "Record<string, unknown>"
4284
5110
  },
4285
5111
  {
4286
- name: "getStorageFileProxy",
4287
- method: "GET",
4288
- path: "/storage/files/{file_id}/proxy",
4289
- pathParams: ["file_id"],
4290
- queryParams: ["purpose"],
4291
- responseEnvelope: "raw",
4292
- responseType: "Response",
4293
- binary: true
5112
+ name: "createStorageMultipartUpload",
5113
+ method: "POST",
5114
+ path: "/storage/multipart/create",
5115
+ requestType: "StorageMultipartCreateRequest",
5116
+ responseEnvelope: "athena",
5117
+ responseType: "Record<string, unknown>"
4294
5118
  },
4295
5119
  {
4296
- name: "updateStorageFile",
4297
- method: "PATCH",
4298
- path: "/storage/files/{file_id}",
4299
- pathParams: ["file_id"],
4300
- requestType: "UpdateStorageFileRequest",
5120
+ name: "signStorageMultipartPart",
5121
+ method: "POST",
5122
+ path: "/storage/multipart/sign-part",
5123
+ requestType: "StorageMultipartSignPartRequest",
4301
5124
  responseEnvelope: "athena",
4302
- responseType: "StorageFileMutationResponse"
5125
+ responseType: "Record<string, unknown>"
4303
5126
  },
4304
5127
  {
4305
- name: "deleteStorageFile",
4306
- method: "DELETE",
4307
- path: "/storage/files/{file_id}",
4308
- pathParams: ["file_id"],
5128
+ name: "completeStorageMultipartUpload",
5129
+ method: "POST",
5130
+ path: "/storage/multipart/complete",
5131
+ requestType: "StorageMultipartCompleteRequest",
4309
5132
  responseEnvelope: "athena",
4310
5133
  responseType: "StorageFileMutationResponse"
4311
5134
  },
4312
5135
  {
4313
- name: "setStorageFileVisibility",
4314
- method: "PATCH",
4315
- path: "/storage/files/{file_id}/visibility",
4316
- pathParams: ["file_id"],
4317
- requestType: "SetStorageFileVisibilityRequest",
5136
+ name: "abortStorageMultipartUpload",
5137
+ method: "POST",
5138
+ path: "/storage/multipart/abort",
5139
+ requestType: "StorageMultipartAbortRequest",
4318
5140
  responseEnvelope: "athena",
4319
- responseType: "StorageFileMutationResponse"
5141
+ responseType: "Record<string, unknown>"
4320
5142
  },
4321
5143
  {
4322
- name: "deleteStorageFolder",
5144
+ name: "listStorageMultipartParts",
4323
5145
  method: "POST",
4324
- path: "/storage/folders/delete",
4325
- requestType: "DeleteStorageFolderRequest",
5146
+ path: "/storage/multipart/list-parts",
5147
+ requestType: "StorageMultipartListPartsRequest",
4326
5148
  responseEnvelope: "athena",
4327
- responseType: "StorageFolderMutationResponse"
5149
+ responseType: "Record<string, unknown>"
4328
5150
  },
4329
5151
  {
4330
- name: "moveStorageFolder",
5152
+ name: "listStorageAuditEvents",
4331
5153
  method: "POST",
4332
- path: "/storage/folders/move",
4333
- requestType: "MoveStorageFolderRequest",
5154
+ path: "/storage/audit/list",
5155
+ requestType: "StorageAuditQueryRequest",
4334
5156
  responseEnvelope: "athena",
4335
- responseType: "StorageFolderMutationResponse"
5157
+ responseType: "StorageAuditListResponse"
4336
5158
  }
4337
5159
  ]
4338
5160
  };
@@ -4785,7 +5607,7 @@ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
4785
5607
  return fetch(uploadUrl, init);
4786
5608
  }
4787
5609
  function attachManagedUpload(upload) {
4788
- const headers = {};
5610
+ const headers = { ...upload.headers ?? {} };
4789
5611
  return {
4790
5612
  ...upload,
4791
5613
  method: "PUT",
@@ -4831,7 +5653,12 @@ function normalizeUploadUrlRequest(input) {
4831
5653
  file_id: input.file_id ?? input.fileId,
4832
5654
  public: input.public,
4833
5655
  visibility: input.visibility,
4834
- metadata: input.metadata
5656
+ metadata: input.metadata,
5657
+ server_side_encryption: input.server_side_encryption,
5658
+ sse: input.sse,
5659
+ ssekms_key_id: input.ssekms_key_id,
5660
+ kms_key_id: input.kms_key_id,
5661
+ bucket_key_enabled: input.bucket_key_enabled
4835
5662
  };
4836
5663
  }
4837
5664
  async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
@@ -4982,6 +5809,12 @@ function createStorageModule(gateway, runtimeOptions) {
4982
5809
  options,
4983
5810
  resolvedRuntimeOptions
4984
5811
  );
5812
+ const callStorageFileVisibility = (fileId, method, input, options) => callAthena2(
5813
+ withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId),
5814
+ method,
5815
+ input,
5816
+ options
5817
+ );
4985
5818
  const base = {
4986
5819
  listStorageCatalogs(options) {
4987
5820
  return callRaw("/storage/catalogs", "GET", void 0, options);
@@ -5031,7 +5864,7 @@ function createStorageModule(gateway, runtimeOptions) {
5031
5864
  return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
5032
5865
  },
5033
5866
  setStorageFileVisibility(fileId, input, options) {
5034
- return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
5867
+ return callStorageFileVisibility(fileId, "PATCH", input, options);
5035
5868
  },
5036
5869
  deleteStorageFolder(input, options) {
5037
5870
  return callAthena2("/storage/folders/delete", "POST", input, options);
@@ -5103,13 +5936,62 @@ function createStorageModule(gateway, runtimeOptions) {
5103
5936
  publicUrl(fileId, options) {
5104
5937
  return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
5105
5938
  },
5939
+ proxyUrl(fileId, query, options) {
5940
+ const path = appendQuery(
5941
+ withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
5942
+ query
5943
+ );
5944
+ return callAthena2(path, "GET", void 0, options);
5945
+ },
5106
5946
  proxy(fileId, query, options) {
5107
5947
  return base.getStorageFileProxy(fileId, query, options);
5108
5948
  },
5109
- visibility: {
5949
+ versions(fileId, options) {
5950
+ return callAthena2(withPathParam("/storage/files/{file_id}/versions", "file_id", fileId), "GET", void 0, options);
5951
+ },
5952
+ restoreVersion(fileId, versionId, options) {
5953
+ return callAthena2(
5954
+ withPathParam(
5955
+ withPathParam("/storage/files/{file_id}/versions/{version_id}/restore", "file_id", fileId),
5956
+ "version_id",
5957
+ versionId
5958
+ ),
5959
+ "POST",
5960
+ {},
5961
+ options
5962
+ );
5963
+ },
5964
+ deleteVersion(fileId, versionId, options) {
5965
+ return callAthena2(
5966
+ withPathParam(
5967
+ withPathParam("/storage/files/{file_id}/versions/{version_id}", "file_id", fileId),
5968
+ "version_id",
5969
+ versionId
5970
+ ),
5971
+ "DELETE",
5972
+ void 0,
5973
+ options
5974
+ );
5975
+ },
5976
+ retention: {
5977
+ get(fileId, query, options) {
5978
+ const path = appendQuery(
5979
+ withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
5980
+ query
5981
+ );
5982
+ return callAthena2(path, "GET", void 0, options);
5983
+ },
5110
5984
  set(fileId, input, options) {
5985
+ return callAthena2(withPathParam("/storage/files/{file_id}/retention", "file_id", fileId), "POST", input, options);
5986
+ }
5987
+ },
5988
+ visibility: {
5989
+ update(fileId, input, options) {
5111
5990
  return base.setStorageFileVisibility(fileId, input, options);
5112
5991
  },
5992
+ set(fileId, input, options) {
5993
+ return callStorageFileVisibility(fileId, "POST", input, options);
5994
+ },
5113
5995
  setMany(input, options) {
5114
5996
  return callAthena2("/storage/files/visibility-many", "POST", input, options);
5115
5997
  }
@@ -5204,6 +6086,18 @@ function createStorageModule(gateway, runtimeOptions) {
5204
6086
  uploadUrl(input, options) {
5205
6087
  return callAthena2("/storage/objects/upload-url", "POST", input, options);
5206
6088
  },
6089
+ versions(input, options) {
6090
+ return callAthena2("/storage/objects/versions", "POST", input, options);
6091
+ },
6092
+ restoreVersion(input, options) {
6093
+ return callAthena2("/storage/objects/versions/restore", "POST", input, options);
6094
+ },
6095
+ deleteVersion(input, options) {
6096
+ return callAthena2("/storage/objects/versions/delete", "POST", input, options);
6097
+ },
6098
+ postPolicy(input, options) {
6099
+ return callAthena2("/storage/objects/post-policy", "POST", input, options);
6100
+ },
5207
6101
  folder: objectFolder
5208
6102
  };
5209
6103
  const bucket = {
@@ -5216,6 +6110,39 @@ function createStorageModule(gateway, runtimeOptions) {
5216
6110
  delete(input, options) {
5217
6111
  return callAthena2("/storage/buckets/delete", "POST", input, options);
5218
6112
  },
6113
+ lifecycle: {
6114
+ get(input, options) {
6115
+ return callAthena2("/storage/buckets/lifecycle", "POST", input, options);
6116
+ },
6117
+ set(input, options) {
6118
+ return callAthena2("/storage/buckets/lifecycle/set", "POST", input, options);
6119
+ },
6120
+ delete(input, options) {
6121
+ return callAthena2("/storage/buckets/lifecycle/delete", "POST", input, options);
6122
+ }
6123
+ },
6124
+ policy: {
6125
+ get(input, options) {
6126
+ return callAthena2("/storage/buckets/policy", "POST", input, options);
6127
+ },
6128
+ set(input, options) {
6129
+ return callAthena2("/storage/buckets/policy/set", "POST", input, options);
6130
+ },
6131
+ delete(input, options) {
6132
+ return callAthena2("/storage/buckets/policy/delete", "POST", input, options);
6133
+ }
6134
+ },
6135
+ publicAccess: {
6136
+ get(input, options) {
6137
+ return callAthena2("/storage/buckets/public-access", "POST", input, options);
6138
+ },
6139
+ set(input, options) {
6140
+ return callAthena2("/storage/buckets/public-access/set", "POST", input, options);
6141
+ },
6142
+ delete(input, options) {
6143
+ return callAthena2("/storage/buckets/public-access/delete", "POST", input, options);
6144
+ }
6145
+ },
5219
6146
  cors: {
5220
6147
  get(input, options) {
5221
6148
  return callAthena2("/storage/buckets/cors", "POST", input, options);
@@ -7792,6 +8719,59 @@ function createQueryBuilder(client, formatGatewayResult, experimental, tracer) {
7792
8719
  );
7793
8720
  };
7794
8721
  }
8722
+ function normalizeOptionalString2(value) {
8723
+ if (typeof value !== "string") {
8724
+ return void 0;
8725
+ }
8726
+ const normalizedValue = value.trim();
8727
+ return normalizedValue ? normalizedValue : void 0;
8728
+ }
8729
+ function readHeaderBagValue(headers, targetKey) {
8730
+ if (!headers) {
8731
+ return void 0;
8732
+ }
8733
+ if (typeof headers.get === "function") {
8734
+ return normalizeOptionalString2(headers.get(targetKey));
8735
+ }
8736
+ const normalizedTargetKey = targetKey.toLowerCase();
8737
+ for (const [key, value] of Object.entries(headers)) {
8738
+ if (key.toLowerCase() !== normalizedTargetKey) {
8739
+ continue;
8740
+ }
8741
+ if (typeof value === "string") {
8742
+ return normalizeOptionalString2(value);
8743
+ }
8744
+ return void 0;
8745
+ }
8746
+ return void 0;
8747
+ }
8748
+ function resolveSessionContextOptions(session, options) {
8749
+ const sessionToken = normalizeOptionalString2(session?.session?.token);
8750
+ const requestCookie = readHeaderBagValue(options?.requestHeaders, "cookie") ?? readHeaderBagValue(options?.headers, "cookie");
8751
+ const authInput = options?.auth;
8752
+ const resolvedUserId = options?.userId !== void 0 ? options.userId : session?.user?.id;
8753
+ const resolvedOrganizationId = options?.organizationId !== void 0 ? options.organizationId : session?.session?.activeOrganizationId;
8754
+ const resolvedBearerToken = authInput?.bearerToken !== void 0 ? authInput.bearerToken : sessionToken;
8755
+ const resolvedSessionToken = authInput?.sessionToken !== void 0 ? authInput.sessionToken : sessionToken;
8756
+ const resolvedCookie = authInput?.cookie !== void 0 ? authInput.cookie : requestCookie;
8757
+ const auth = authInput !== void 0 || resolvedBearerToken !== void 0 || resolvedSessionToken !== void 0 || resolvedCookie !== void 0 ? {
8758
+ ...authInput ?? {},
8759
+ ...resolvedBearerToken !== void 0 ? { bearerToken: resolvedBearerToken } : {},
8760
+ ...resolvedSessionToken !== void 0 ? { sessionToken: resolvedSessionToken } : {},
8761
+ ...resolvedCookie !== void 0 ? { cookie: resolvedCookie } : {},
8762
+ headers: authInput?.headers ? { ...authInput.headers } : void 0
8763
+ } : void 0;
8764
+ if (resolvedUserId === void 0 && resolvedOrganizationId === void 0 && options?.forceNoCache === void 0 && !options?.headers && !auth) {
8765
+ return void 0;
8766
+ }
8767
+ return {
8768
+ userId: resolvedUserId,
8769
+ organizationId: resolvedOrganizationId,
8770
+ forceNoCache: options?.forceNoCache,
8771
+ headers: options?.headers ? { ...options.headers } : void 0,
8772
+ auth
8773
+ };
8774
+ }
7795
8775
  function resolveClientServiceBaseUrl(value, label) {
7796
8776
  if (value === void 0 || value === null) {
7797
8777
  return void 0;
@@ -7813,21 +8793,143 @@ function resolveServiceUrls(config) {
7813
8793
  storageUrl: resolveServiceUrlOverride(config.storage?.url, "Athena storage base URL") ?? resolveServiceUrlOverride(config.storageUrl, "Athena storage base URL") ?? (baseUrl ? appendServicePath(baseUrl, "storage") : void 0)
7814
8794
  };
7815
8795
  }
8796
+ function resolveOptionalClientName(value) {
8797
+ if (value === void 0 || value === null) {
8798
+ return void 0;
8799
+ }
8800
+ const normalizedValue = value.trim();
8801
+ return normalizedValue ? normalizedValue : void 0;
8802
+ }
8803
+ function resolveRequiredClientApiKey(value) {
8804
+ if (value === void 0 || value === null) {
8805
+ throw new Error(
8806
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8807
+ );
8808
+ }
8809
+ const normalizedValue = value.trim();
8810
+ if (!normalizedValue) {
8811
+ throw new Error(
8812
+ "Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
8813
+ );
8814
+ }
8815
+ return normalizedValue;
8816
+ }
8817
+ function hasHeaderIgnoreCase(headers, targetKey) {
8818
+ const normalizedTargetKey = targetKey.toLowerCase();
8819
+ return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
8820
+ }
8821
+ function mergeClientHeaders(current, next) {
8822
+ if (!current && !next) {
8823
+ return void 0;
8824
+ }
8825
+ return {
8826
+ ...current ?? {},
8827
+ ...next ?? {}
8828
+ };
8829
+ }
8830
+ function mergeDefinedObject(current, next) {
8831
+ if (!current && !next) {
8832
+ return void 0;
8833
+ }
8834
+ const merged = {
8835
+ ...current ?? {}
8836
+ };
8837
+ const mutableMerged = merged;
8838
+ for (const [key, value] of Object.entries(next ?? {})) {
8839
+ if (value !== void 0) {
8840
+ mutableMerged[key] = value;
8841
+ }
8842
+ }
8843
+ return merged;
8844
+ }
8845
+ function mergeAuthClientOptions(current, next) {
8846
+ const merged = mergeDefinedObject(current, next);
8847
+ if (!merged) {
8848
+ return void 0;
8849
+ }
8850
+ const mergedHeaders = mergeClientHeaders(current?.headers, next?.headers);
8851
+ if (mergedHeaders) {
8852
+ merged.headers = mergedHeaders;
8853
+ }
8854
+ return merged;
8855
+ }
8856
+ function mergeServiceUrlOverrides(current, next) {
8857
+ return mergeDefinedObject(current, next);
8858
+ }
8859
+ function toClientContextOverrides(context) {
8860
+ if (!context) {
8861
+ return void 0;
8862
+ }
8863
+ return {
8864
+ userId: context.userId,
8865
+ organizationId: context.organizationId,
8866
+ forceNoCache: context.forceNoCache,
8867
+ headers: context.headers,
8868
+ auth: context.auth ? {
8869
+ ...context.auth,
8870
+ headers: context.auth.headers ? { ...context.auth.headers } : void 0
8871
+ } : void 0
8872
+ };
8873
+ }
8874
+ function mergeClientOverrideOptions(base, overrides) {
8875
+ if (!overrides) {
8876
+ return {
8877
+ ...base,
8878
+ headers: base.headers ? { ...base.headers } : void 0,
8879
+ auth: base.auth ? {
8880
+ ...base.auth,
8881
+ headers: base.auth.headers ? { ...base.auth.headers } : void 0
8882
+ } : void 0,
8883
+ db: base.db ? { ...base.db } : void 0,
8884
+ gateway: base.gateway ? { ...base.gateway } : void 0,
8885
+ storage: base.storage ? { ...base.storage } : void 0
8886
+ };
8887
+ }
8888
+ const merged = mergeDefinedObject(base, overrides) ?? { ...base };
8889
+ return {
8890
+ ...merged,
8891
+ headers: mergeClientHeaders(base.headers, overrides.headers),
8892
+ auth: mergeAuthClientOptions(base.auth, overrides.auth),
8893
+ db: mergeServiceUrlOverrides(base.db, overrides.db),
8894
+ gateway: mergeServiceUrlOverrides(base.gateway, overrides.gateway),
8895
+ storage: mergeServiceUrlOverrides(base.storage, overrides.storage)
8896
+ };
8897
+ }
7816
8898
  function normalizeAuthClientConfig(auth, defaultBaseUrl) {
7817
8899
  if (!auth && defaultBaseUrl === void 0) {
7818
8900
  return void 0;
7819
8901
  }
7820
- const { url, ...rest } = auth ?? {};
8902
+ const {
8903
+ url,
8904
+ baseUrl,
8905
+ apiKey,
8906
+ bearerToken,
8907
+ cookie,
8908
+ sessionToken,
8909
+ ...rest
8910
+ } = auth ?? {};
7821
8911
  const normalized = {
7822
8912
  ...rest
7823
8913
  };
7824
8914
  const resolvedBaseUrl = resolveClientServiceBaseUrl(
7825
- url ?? rest.baseUrl ?? defaultBaseUrl,
8915
+ url ?? baseUrl ?? defaultBaseUrl,
7826
8916
  "Athena auth base URL"
7827
8917
  );
7828
8918
  if (resolvedBaseUrl !== void 0) {
7829
8919
  normalized.baseUrl = resolvedBaseUrl;
7830
8920
  }
8921
+ if (typeof apiKey === "string") {
8922
+ normalized.apiKey = apiKey;
8923
+ }
8924
+ if (typeof bearerToken === "string") {
8925
+ normalized.bearerToken = bearerToken;
8926
+ }
8927
+ if (typeof cookie === "string") {
8928
+ normalized.cookie = cookie;
8929
+ }
8930
+ if (typeof sessionToken === "string") {
8931
+ normalized.sessionToken = sessionToken;
8932
+ }
7831
8933
  return normalized;
7832
8934
  }
7833
8935
  function resolveCreateClientConfig(config) {
@@ -7839,8 +8941,11 @@ function resolveCreateClientConfig(config) {
7839
8941
  }
7840
8942
  return {
7841
8943
  baseUrl: resolvedUrls.dbUrl,
7842
- apiKey: config.key,
7843
- client: config.client,
8944
+ apiKey: resolveRequiredClientApiKey(config.key),
8945
+ client: resolveOptionalClientName(config.client),
8946
+ userId: config.userId,
8947
+ organizationId: config.organizationId,
8948
+ forceNoCache: config.forceNoCache,
7844
8949
  backend: toBackendConfig(config.backend),
7845
8950
  headers: config.headers,
7846
8951
  auth: config.auth,
@@ -7849,23 +8954,39 @@ function resolveCreateClientConfig(config) {
7849
8954
  experimental: config.experimental
7850
8955
  };
7851
8956
  }
7852
- function createClientFromConfig(config) {
8957
+ function createClientFromInput(sourceConfig) {
8958
+ return createClientFromConfig(resolveCreateClientConfig(sourceConfig), sourceConfig);
8959
+ }
8960
+ function createClientFromConfig(config, sourceConfig) {
8961
+ const normalizedAuthConfig = normalizeAuthClientConfig(config.auth, config.authUrl);
7853
8962
  const gatewayHeaders = {
7854
8963
  ...config.headers ?? {}
7855
8964
  };
7856
- if (config.auth?.bearerToken && gatewayHeaders["X-Athena-Auth-Bearer-Token"] === void 0 && gatewayHeaders["x-athena-auth-bearer-token"] === void 0) {
7857
- gatewayHeaders["X-Athena-Auth-Bearer-Token"] = config.auth.bearerToken;
8965
+ if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Bearer-Token")) {
8966
+ gatewayHeaders["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
8967
+ }
8968
+ if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(gatewayHeaders, "Cookie")) {
8969
+ gatewayHeaders.Cookie = normalizedAuthConfig.cookie;
8970
+ }
8971
+ if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Session-Token")) {
8972
+ gatewayHeaders["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
7858
8973
  }
7859
8974
  const gateway = createAthenaGatewayClient({
7860
8975
  baseUrl: config.baseUrl,
7861
8976
  apiKey: config.apiKey,
7862
8977
  client: config.client,
8978
+ userId: config.userId,
8979
+ organizationId: config.organizationId,
8980
+ forceNoCache: config.forceNoCache,
7863
8981
  backend: config.backend,
7864
8982
  headers: gatewayHeaders
7865
8983
  });
7866
8984
  const formatGatewayResult = createResultFormatter(config.experimental);
7867
8985
  const queryTracer = createQueryTracer(config.experimental);
7868
- const auth = createAuthClient(normalizeAuthClientConfig(config.auth, config.authUrl));
8986
+ const auth = createAuthClient({
8987
+ ...normalizedAuthConfig ?? {},
8988
+ ...config.forceNoCache ? { forceNoCache: true } : {}
8989
+ });
7869
8990
  function from(tableOrModel, options) {
7870
8991
  if (isAthenaModelTarget(tableOrModel)) {
7871
8992
  if (options?.schema !== void 0) {
@@ -7913,17 +9034,45 @@ function createClientFromConfig(config) {
7913
9034
  queryTracer
7914
9035
  );
7915
9036
  const db = createDbModule({ from, rpc, query });
9037
+ const withContext = (context) => createClientFromInput(
9038
+ mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
9039
+ );
9040
+ const withSession = (session, options) => createClientFromInput(
9041
+ mergeClientOverrideOptions(
9042
+ sourceConfig,
9043
+ toClientContextOverrides(resolveSessionContextOptions(session, options))
9044
+ )
9045
+ );
9046
+ const authWithOptions = (options) => createClientFromInput(mergeClientOverrideOptions(sourceConfig, options));
7916
9047
  const sdkClient = {
7917
9048
  from,
7918
9049
  db,
7919
9050
  rpc,
7920
9051
  query,
7921
9052
  verifyConnection: gateway.verifyConnection,
7922
- auth: auth.auth
9053
+ auth: auth.auth,
9054
+ withContext,
9055
+ withSession,
9056
+ withOptions: authWithOptions
7923
9057
  };
7924
9058
  if (config.experimental?.athenaStorageBackend) {
9059
+ const storageWithContext = (context) => createClientFromInput(
9060
+ mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
9061
+ );
9062
+ const storageWithSession = (session, options) => createClientFromInput(
9063
+ mergeClientOverrideOptions(
9064
+ sourceConfig,
9065
+ toClientContextOverrides(resolveSessionContextOptions(session, options))
9066
+ )
9067
+ );
9068
+ const storageWithOptions = (options) => createClientFromInput(
9069
+ mergeClientOverrideOptions(sourceConfig, options)
9070
+ );
7925
9071
  const storageClient = {
7926
9072
  ...sdkClient,
9073
+ withContext: storageWithContext,
9074
+ withSession: storageWithSession,
9075
+ withOptions: storageWithOptions,
7927
9076
  storage: createStorageModule(gateway, {
7928
9077
  ...config.experimental.storage,
7929
9078
  ...config.storageUrl ? {
@@ -7937,14 +9086,14 @@ function createClientFromConfig(config) {
7937
9086
  return sdkClient;
7938
9087
  }
7939
9088
  function createClient(configOrUrl, apiKey, options) {
7940
- if (typeof configOrUrl === "string") {
7941
- return createClientFromConfig(resolveCreateClientConfig({
9089
+ if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
9090
+ return createClientFromInput({
7942
9091
  url: configOrUrl,
7943
9092
  key: apiKey ?? "",
7944
9093
  ...options
7945
- }));
9094
+ });
7946
9095
  }
7947
- return createClientFromConfig(resolveCreateClientConfig(configOrUrl));
9096
+ return createClientFromInput(configOrUrl);
7948
9097
  }
7949
9098
 
7950
9099
  // src/schema/postgres-introspection-core.ts
@@ -8500,16 +9649,25 @@ async function fileExists(path) {
8500
9649
  }
8501
9650
  async function writeArtifacts(files, cwd) {
8502
9651
  const writtenFiles = [];
9652
+ const skippedFiles = [];
8503
9653
  for (const file of files) {
8504
9654
  const absolutePath = path.resolve(cwd, file.path);
8505
9655
  if (!canOverwriteArtifact(file) && await fileExists(absolutePath)) {
9656
+ skippedFiles.push({
9657
+ kind: file.kind,
9658
+ path: file.path,
9659
+ reason: "protected-existing-file"
9660
+ });
8506
9661
  continue;
8507
9662
  }
8508
9663
  await promises.mkdir(path.dirname(absolutePath), { recursive: true });
8509
9664
  await promises.writeFile(absolutePath, file.content, "utf8");
8510
9665
  writtenFiles.push(file.path);
8511
9666
  }
8512
- return writtenFiles;
9667
+ return {
9668
+ writtenFiles,
9669
+ skippedFiles
9670
+ };
8513
9671
  }
8514
9672
  async function runSchemaGenerator(options = {}) {
8515
9673
  const cwd = options.cwd ?? process.cwd();
@@ -8523,11 +9681,13 @@ async function runSchemaGenerator(options = {}) {
8523
9681
  schemas: resolveProviderSchemas(config.provider)
8524
9682
  });
8525
9683
  const generated = generateArtifactsFromSnapshot(snapshot, config);
8526
- const writtenFiles = options.dryRun ? [] : await writeArtifacts(generated.files, cwd);
9684
+ const writeResult = options.dryRun ? { writtenFiles: [], skippedFiles: [] } : await writeArtifacts(generated.files, cwd);
8527
9685
  return {
8528
9686
  ...generated,
8529
9687
  configPath,
8530
- writtenFiles
9688
+ config,
9689
+ writtenFiles: writeResult.writtenFiles,
9690
+ skippedFiles: writeResult.skippedFiles
8531
9691
  };
8532
9692
  }
8533
9693
 
@@ -8555,7 +9715,7 @@ function generateUsage() {
8555
9715
  "",
8556
9716
  "Options:",
8557
9717
  " --config <path> Explicit path to athena.config.ts or athena-js.config.ts",
8558
- " --dry-run Build generated files in memory without writing them to disk",
9718
+ " --dry-run Build generated files in memory without writing them to disk and print mode/target hints",
8559
9719
  " -h, --help Show help for generate",
8560
9720
  "",
8561
9721
  "Config resolution:",
@@ -8569,6 +9729,68 @@ function generateUsage() {
8569
9729
  " athena-js generate --config ./athena.config.ts --dry-run"
8570
9730
  ].join("\n");
8571
9731
  }
9732
+ function normalizePath2(pathValue) {
9733
+ return pathValue.replace(/\\/g, "/");
9734
+ }
9735
+ function isLegacyConfigRegistryTarget(target) {
9736
+ return normalizePath2(target) === "athena/config.ts";
9737
+ }
9738
+ function isFlatSchemaTarget(target) {
9739
+ return normalizePath2(target) === "athena/schema.ts";
9740
+ }
9741
+ function formatProviderLine(result) {
9742
+ const { provider } = result.config;
9743
+ if (provider.kind === "postgres") {
9744
+ const schemaList = Array.isArray(provider.schemas) ? provider.schemas.join(",") : typeof provider.schemas === "string" ? provider.schemas : "public";
9745
+ const database = provider.database ? ` database=${provider.database}` : "";
9746
+ const backend = provider.mode === "gateway" && provider.backend ? ` backend=${provider.backend}` : "";
9747
+ return `[provider] kind=${provider.kind} mode=${provider.mode}${database}${backend} schemas=${schemaList}`;
9748
+ }
9749
+ const datacenter = provider.datacenter ? ` datacenter=${provider.datacenter}` : "";
9750
+ return `[provider] kind=${provider.kind} mode=${provider.mode} keyspace=${provider.keyspace} contactPoints=${provider.contactPoints.join(",")}${datacenter}`;
9751
+ }
9752
+ function formatFilterLine(result) {
9753
+ const { includeTables, excludeTables } = result.config.filter;
9754
+ if (includeTables.length === 0 && excludeTables.length === 0) {
9755
+ return void 0;
9756
+ }
9757
+ return `[filter] include=${includeTables.length > 0 ? includeTables.join(",") : "-"} exclude=${excludeTables.length > 0 ? excludeTables.join(",") : "-"}`;
9758
+ }
9759
+ function formatGeneratorModeLines(result) {
9760
+ const lines = [
9761
+ `[mode] preset=${result.config.output.preset} format=${result.config.output.format} modelTarget=${result.config.output.targets.model}`,
9762
+ formatProviderLine(result),
9763
+ `[targets] schema=${result.config.output.targets.schema} database=${result.config.output.targets.database} registry=${result.config.output.targets.registry}`
9764
+ ];
9765
+ const filterLine = formatFilterLine(result);
9766
+ if (filterLine) {
9767
+ lines.push(filterLine);
9768
+ }
9769
+ if (result.config.output.format === "define-model") {
9770
+ lines.push(
9771
+ '[note] Legacy define-model compatibility output is active. Set output.format="table-builder" or ATHENA_GENERATOR_OUTPUT_FORMAT=table-builder to emit table(...).schema(...).columns(...).primaryKey(...).'
9772
+ );
9773
+ }
9774
+ if (result.config.output.preset === "legacy") {
9775
+ lines.push(
9776
+ '[note] Legacy preset is active. It keeps registry output on athena/config.ts for compatibility; prefer output.preset="athena-direct" for the default safe direct layout.'
9777
+ );
9778
+ }
9779
+ lines.push(
9780
+ "[note] Default generator mode is preset=athena-direct + format=table-builder. experimental.findManyAst only affects runtime findMany(...) transport and does not enable generator table output."
9781
+ );
9782
+ if (isLegacyConfigRegistryTarget(result.config.output.targets.registry)) {
9783
+ lines.push(
9784
+ '[warn] Registry target points at athena/config.ts. That file is often a handwritten runtime seam; prefer output.preset="athena-direct" or output.targets.registry="athena/registry.generated.ts" unless you intentionally need legacy compatibility.'
9785
+ );
9786
+ }
9787
+ if (isFlatSchemaTarget(result.config.output.targets.schema)) {
9788
+ lines.push(
9789
+ "[warn] Schema target points at athena/schema.ts. Prefer schema-scoped output such as athena/schemas/{schema_kebab}.ts."
9790
+ );
9791
+ }
9792
+ return lines;
9793
+ }
8572
9794
  function usage(topic = "root") {
8573
9795
  return topic === "generate" ? generateUsage() : rootUsage();
8574
9796
  }
@@ -8651,6 +9873,12 @@ function formatGeneratorError(error, configPath) {
8651
9873
  }
8652
9874
  return new Error(normalizeErrorMessage(error));
8653
9875
  }
9876
+ function formatSkippedArtifactLine(artifact) {
9877
+ if (artifact.reason === "protected-existing-file") {
9878
+ return ` [skip] ${artifact.path} (existing ${artifact.kind} artifacts are protected from overwrite; delete or retarget the file to regenerate it)`;
9879
+ }
9880
+ return ` [skip] ${artifact.path}`;
9881
+ }
8654
9882
  async function runCLI(argv, runtime = {}) {
8655
9883
  const log = runtime.log ?? console.log;
8656
9884
  const runGenerator = runtime.runGenerator ?? runSchemaGenerator;
@@ -8670,15 +9898,24 @@ async function runCLI(argv, runtime = {}) {
8670
9898
  }
8671
9899
  if (parsed.dryRun) {
8672
9900
  log(`[dry-run] Generated ${result.files.length} files from ${result.configPath}`);
9901
+ for (const line of formatGeneratorModeLines(result)) {
9902
+ log(line);
9903
+ }
8673
9904
  for (const file of result.files) {
8674
9905
  log(` - ${file.path}`);
8675
9906
  }
8676
9907
  return;
8677
9908
  }
8678
9909
  log(`Generated ${result.writtenFiles.length} files from ${result.configPath}`);
9910
+ for (const line of formatGeneratorModeLines(result)) {
9911
+ log(line);
9912
+ }
8679
9913
  for (const filePath of result.writtenFiles) {
8680
9914
  log(` - ${filePath}`);
8681
9915
  }
9916
+ for (const artifact of result.skippedFiles) {
9917
+ log(formatSkippedArtifactLine(artifact));
9918
+ }
8682
9919
  }
8683
9920
 
8684
9921
  exports.parseCommand = parseCommand;