@xylex-group/athena 2.14.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +109 -1402
  2. package/dist/admin.d.cts +1 -1
  3. package/dist/admin.d.ts +1 -1
  4. package/dist/{athena-auth-url-oLux_57a.d.cts → athena-request-headers-C7Jy-c_D.d.ts} +85 -1
  5. package/dist/{athena-auth-url-oLux_57a.d.ts → athena-request-headers-DujFFyMU.d.cts} +85 -1
  6. package/dist/billing.cjs +1311 -0
  7. package/dist/billing.cjs.map +1 -0
  8. package/dist/billing.d.cts +270 -0
  9. package/dist/billing.d.ts +270 -0
  10. package/dist/billing.js +1306 -0
  11. package/dist/billing.js.map +1 -0
  12. package/dist/browser.cjs +9695 -9243
  13. package/dist/browser.cjs.map +1 -1
  14. package/dist/browser.d.cts +11 -10
  15. package/dist/browser.d.ts +11 -10
  16. package/dist/browser.js +9692 -9241
  17. package/dist/browser.js.map +1 -1
  18. package/dist/cli/index.cjs +8137 -7286
  19. package/dist/cli/index.cjs.map +1 -1
  20. package/dist/cli/index.d.cts +4 -4
  21. package/dist/cli/index.d.ts +4 -4
  22. package/dist/cli/index.js +8137 -7286
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/index.cjs +9718 -9260
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +11 -10
  27. package/dist/index.d.ts +11 -10
  28. package/dist/index.js +9711 -9258
  29. package/dist/index.js.map +1 -1
  30. package/dist/{model-form-DcH3R7WD.d.ts → model-form-Dh0sisdL.d.ts} +2 -2
  31. package/dist/{model-form-BE1_Bmdd.d.cts → model-form-oOAJUVd4.d.cts} +2 -2
  32. package/dist/{module-DFGZXCtt.d.cts → module-CB25egcO.d.cts} +18 -52
  33. package/dist/module-C_ab-MM1.d.cts +360 -0
  34. package/dist/module-C_ab-MM1.d.ts +360 -0
  35. package/dist/{module-Ca3_OQqR.d.ts → module-CkUM6v58.d.ts} +18 -52
  36. package/dist/next/client.cjs +9116 -8468
  37. package/dist/next/client.cjs.map +1 -1
  38. package/dist/next/client.d.cts +24 -25
  39. package/dist/next/client.d.ts +24 -25
  40. package/dist/next/client.js +9088 -8469
  41. package/dist/next/client.js.map +1 -1
  42. package/dist/next/server.cjs +8932 -7776
  43. package/dist/next/server.cjs.map +1 -1
  44. package/dist/next/server.d.cts +62 -43
  45. package/dist/next/server.d.ts +62 -43
  46. package/dist/next/server.js +8873 -7777
  47. package/dist/next/server.js.map +1 -1
  48. package/dist/{payload-BbSCmILD.d.ts → payload-DWI1rw-e.d.cts} +1 -35
  49. package/dist/{payload-zXIwKTQf.d.cts → payload-DWI1rw-e.d.ts} +1 -35
  50. package/dist/{pipeline-DqwehoQV.d.ts → pipeline-B8aN2EHe.d.ts} +1 -1
  51. package/dist/{pipeline-CwQoD5G9.d.cts → pipeline-D4W-Cc-A.d.cts} +1 -1
  52. package/dist/proxy-request-headers-DGxdoyA0.d.cts +59 -0
  53. package/dist/proxy-request-headers-m4D2Tduy.d.ts +59 -0
  54. package/dist/react.cjs +118 -17
  55. package/dist/react.cjs.map +1 -1
  56. package/dist/react.d.cts +46 -16
  57. package/dist/react.d.ts +46 -16
  58. package/dist/react.js +117 -18
  59. package/dist/react.js.map +1 -1
  60. package/dist/social-providers.cjs +24 -20
  61. package/dist/social-providers.cjs.map +1 -1
  62. package/dist/social-providers.d.cts +96 -139
  63. package/dist/social-providers.d.ts +96 -139
  64. package/dist/social-providers.js +24 -20
  65. package/dist/social-providers.js.map +1 -1
  66. package/dist/{types-eAKAh71s.d.cts → types-AOY-GLu8.d.cts} +27 -54
  67. package/dist/{types-eAKAh71s.d.ts → types-AOY-GLu8.d.ts} +27 -54
  68. package/dist/{types-CD6K05JQ.d.ts → types-B75PdABb.d.ts} +3 -3
  69. package/dist/{types-dHnjluBC.d.cts → types-BBm-kEBL.d.cts} +2 -2
  70. package/dist/{types-C1swabT5.d.ts → types-BaAMXCqK.d.ts} +2 -2
  71. package/dist/{types-YQUR7wu0.d.cts → types-Bltx6iL6.d.cts} +3 -5
  72. package/dist/{types-YQUR7wu0.d.ts → types-Bltx6iL6.d.ts} +3 -5
  73. package/dist/{types-6H575ITc.d.cts → types-CgCv5o6R.d.cts} +3 -3
  74. package/dist/utils.cjs +7 -8
  75. package/dist/utils.cjs.map +1 -1
  76. package/dist/utils.d.cts +4 -145
  77. package/dist/utils.d.ts +4 -145
  78. package/dist/utils.js +7 -8
  79. package/dist/utils.js.map +1 -1
  80. package/dist/{client-wU2J9yqb.d.cts → v3-client-CWfZHcKL.d.cts} +402 -521
  81. package/dist/{client-uthENhaf.d.ts → v3-client-DZp2NEhK.d.ts} +402 -521
  82. package/package.json +15 -3
@@ -1,37 +1,3 @@
1
- import { an as AthenaCreateClientAuthOptions, af as AthenaClientExperimentalOptions, aI as AthenaHeaderBag } from './client-uthENhaf.js';
2
- import { o as BackendConfig, p as BackendType } from './types-YQUR7wu0.js';
3
-
4
- interface AthenaRequestCookiesBag {
5
- getAll(): Array<{
6
- name: string;
7
- value: string;
8
- }>;
9
- }
10
- type AthenaRequestHeadersInput = AthenaHeaderBag | Record<string, string | null | undefined>;
11
- type AthenaRequestCookiesInput = AthenaRequestCookiesBag | string | null | undefined;
12
- type AthenaAdapterExperimentalOptions = Omit<AthenaClientExperimentalOptions, 'athenaStorageBackend'>;
13
- interface AthenaAdapterBaseOptions {
14
- env?: Record<string, string | undefined>;
15
- url?: string | null | undefined;
16
- gatewayUrl?: string | null | undefined;
17
- authUrl?: string | null | undefined;
18
- chatUrl?: string | null | undefined;
19
- chatWsUrl?: string | null | undefined;
20
- storageUrl?: string | null | undefined;
21
- key?: string | null | undefined;
22
- client?: string | null | undefined;
23
- backend?: BackendConfig | BackendType;
24
- headers?: Record<string, string>;
25
- auth?: AthenaCreateClientAuthOptions;
26
- forceNoCache?: boolean;
27
- storage?: boolean;
28
- experimental?: AthenaAdapterExperimentalOptions;
29
- }
30
- interface AthenaServerRequestOptions {
31
- requestHeaders?: AthenaRequestHeadersInput;
32
- requestCookies?: AthenaRequestCookiesInput;
33
- }
34
-
35
1
  /**
36
2
  * Default App Router path for the Athena Auth session cookie bridge.
37
3
  *
@@ -216,4 +182,4 @@ declare function clearAthenaAuthSessionOnAppHost(options?: AthenaAuthSessionBrid
216
182
  */
217
183
  declare function resolveSessionBridgePayload(payload: AthenaAuthSessionBridgeSource | null | undefined): AthenaAuthSessionBridgePayload | null;
218
184
 
219
- export { type AthenaAdapterBaseOptions as A, type AthenaAdapterExperimentalOptions as a, ATHENA_AUTH_SESSION_BRIDGE_ROUTE as b, ATHENA_AUTH_SESSION_COOKIE_NAME as c, ATHENA_AUTH_SESSION_COOKIE_NAMES as d, type AthenaAuthSessionBridgeClientOptions as e, type AthenaAuthSessionBridgePayload as f, type AthenaAuthSessionBridgeSource as g, clearAthenaAuthSessionOnAppHost as h, type AthenaAuthSessionBridgeOptions as i, type AthenaAuthSessionBridgePathOptions as j, type AthenaServerRequestOptions as k, persistAthenaAuthSessionOnAppHost as p, resolveSessionBridgePayload as r };
185
+ export { ATHENA_AUTH_SESSION_BRIDGE_ROUTE as A, ATHENA_AUTH_SESSION_COOKIE_NAME as a, ATHENA_AUTH_SESSION_COOKIE_NAMES as b, type AthenaAuthSessionBridgeClientOptions as c, type AthenaAuthSessionBridgePayload as d, type AthenaAuthSessionBridgeSource as e, clearAthenaAuthSessionOnAppHost as f, type AthenaAuthSessionBridgeOptions as g, type AthenaAuthSessionBridgePathOptions as h, persistAthenaAuthSessionOnAppHost as p, resolveSessionBridgePayload as r };
@@ -1,37 +1,3 @@
1
- import { an as AthenaCreateClientAuthOptions, af as AthenaClientExperimentalOptions, aI as AthenaHeaderBag } from './client-wU2J9yqb.cjs';
2
- import { o as BackendConfig, p as BackendType } from './types-YQUR7wu0.cjs';
3
-
4
- interface AthenaRequestCookiesBag {
5
- getAll(): Array<{
6
- name: string;
7
- value: string;
8
- }>;
9
- }
10
- type AthenaRequestHeadersInput = AthenaHeaderBag | Record<string, string | null | undefined>;
11
- type AthenaRequestCookiesInput = AthenaRequestCookiesBag | string | null | undefined;
12
- type AthenaAdapterExperimentalOptions = Omit<AthenaClientExperimentalOptions, 'athenaStorageBackend'>;
13
- interface AthenaAdapterBaseOptions {
14
- env?: Record<string, string | undefined>;
15
- url?: string | null | undefined;
16
- gatewayUrl?: string | null | undefined;
17
- authUrl?: string | null | undefined;
18
- chatUrl?: string | null | undefined;
19
- chatWsUrl?: string | null | undefined;
20
- storageUrl?: string | null | undefined;
21
- key?: string | null | undefined;
22
- client?: string | null | undefined;
23
- backend?: BackendConfig | BackendType;
24
- headers?: Record<string, string>;
25
- auth?: AthenaCreateClientAuthOptions;
26
- forceNoCache?: boolean;
27
- storage?: boolean;
28
- experimental?: AthenaAdapterExperimentalOptions;
29
- }
30
- interface AthenaServerRequestOptions {
31
- requestHeaders?: AthenaRequestHeadersInput;
32
- requestCookies?: AthenaRequestCookiesInput;
33
- }
34
-
35
1
  /**
36
2
  * Default App Router path for the Athena Auth session cookie bridge.
37
3
  *
@@ -216,4 +182,4 @@ declare function clearAthenaAuthSessionOnAppHost(options?: AthenaAuthSessionBrid
216
182
  */
217
183
  declare function resolveSessionBridgePayload(payload: AthenaAuthSessionBridgeSource | null | undefined): AthenaAuthSessionBridgePayload | null;
218
184
 
219
- export { type AthenaAdapterBaseOptions as A, type AthenaAdapterExperimentalOptions as a, ATHENA_AUTH_SESSION_BRIDGE_ROUTE as b, ATHENA_AUTH_SESSION_COOKIE_NAME as c, ATHENA_AUTH_SESSION_COOKIE_NAMES as d, type AthenaAuthSessionBridgeClientOptions as e, type AthenaAuthSessionBridgePayload as f, type AthenaAuthSessionBridgeSource as g, clearAthenaAuthSessionOnAppHost as h, type AthenaAuthSessionBridgeOptions as i, type AthenaAuthSessionBridgePathOptions as j, type AthenaServerRequestOptions as k, persistAthenaAuthSessionOnAppHost as p, resolveSessionBridgePayload as r };
185
+ export { ATHENA_AUTH_SESSION_BRIDGE_ROUTE as A, ATHENA_AUTH_SESSION_COOKIE_NAME as a, ATHENA_AUTH_SESSION_COOKIE_NAMES as b, type AthenaAuthSessionBridgeClientOptions as c, type AthenaAuthSessionBridgePayload as d, type AthenaAuthSessionBridgeSource as e, clearAthenaAuthSessionOnAppHost as f, type AthenaAuthSessionBridgeOptions as g, type AthenaAuthSessionBridgePathOptions as h, persistAthenaAuthSessionOnAppHost as p, resolveSessionBridgePayload as r };
@@ -1,4 +1,4 @@
1
- import { R as RunGeneratorOptions, d as RunGeneratorResult } from './types-C1swabT5.js';
1
+ import { R as RunGeneratorOptions, d as RunGeneratorResult } from './types-BaAMXCqK.js';
2
2
 
3
3
  /**
4
4
  * End-to-end generator execution: load config, introspect, render, and optionally write files.
@@ -1,4 +1,4 @@
1
- import { R as RunGeneratorOptions, d as RunGeneratorResult } from './types-dHnjluBC.cjs';
1
+ import { R as RunGeneratorOptions, d as RunGeneratorResult } from './types-BBm-kEBL.cjs';
2
2
 
3
3
  /**
4
4
  * End-to-end generator execution: load config, introspect, render, and optionally write files.
@@ -0,0 +1,59 @@
1
+ import { I as EnvLike } from './athena-request-headers-DujFFyMU.cjs';
2
+
3
+ /**
4
+ * Request header / Next.js helpers used by middleware and RSC session loaders.
5
+ * Framework-agnostic (no Next imports).
6
+ */
7
+ /**
8
+ * True when Next.js threw because the route used dynamic APIs during static
9
+ * generation (`DYNAMIC_SERVER_USAGE` digest or matching message).
10
+ *
11
+ * Catch and rethrow (or handle) so Next can mark the route dynamic.
12
+ */
13
+ declare function isDynamicServerUsageError(error: unknown): boolean;
14
+ interface GetOriginFromHeadersOptions {
15
+ /**
16
+ * When `x-forwarded-proto` / scheme is missing, use `http` if true else `https`.
17
+ * Typical: `process.env.NODE_ENV !== "production"`.
18
+ */
19
+ preferHttpWhenMissingProto?: boolean;
20
+ }
21
+ /**
22
+ * Reconstruct public origin from request headers (Origin, or Host + proto).
23
+ *
24
+ * Prefers `Origin`, then `x-forwarded-host` / `host` with
25
+ * `x-forwarded-proto` (first value when comma-separated).
26
+ */
27
+ declare function getOriginFromHeaders(headersList: {
28
+ get: (name: string) => string | null;
29
+ }, options?: GetOriginFromHeadersOptions): string | null;
30
+
31
+ /**
32
+ * Read the first non-empty trimmed environment variable from a name list.
33
+ *
34
+ * @param names - Candidate env keys in priority order
35
+ * @param env - Optional env map (defaults to `process.env`)
36
+ * @returns Trimmed value of the first key that is set and non-empty
37
+ * @throws {Error} When none of the keys yield a non-empty value
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { requireEnv } from "@xylex-group/athena/utils"
42
+ *
43
+ * const authUrl = requireEnv([
44
+ * "ATHENA_AUTH_UPSTREAM_URL",
45
+ * "ATHENA_AUTH_URL",
46
+ * "NEXT_PUBLIC_ATHENA_AUTH_URL",
47
+ * ])
48
+ * ```
49
+ */
50
+ declare function requireEnv(names: readonly string[], env?: EnvLike): string;
51
+ /**
52
+ * Like {@link requireEnv}, but returns `undefined` instead of throwing when
53
+ * none of the keys are set.
54
+ */
55
+ declare function readEnv(names: readonly string[], env?: EnvLike): string | undefined;
56
+
57
+ declare function proxyRequestHeaders(request: Request): Headers;
58
+
59
+ export { type GetOriginFromHeadersOptions as G, requireEnv as a, getOriginFromHeaders as g, isDynamicServerUsageError as i, proxyRequestHeaders as p, readEnv as r };
@@ -0,0 +1,59 @@
1
+ import { I as EnvLike } from './athena-request-headers-C7Jy-c_D.js';
2
+
3
+ /**
4
+ * Request header / Next.js helpers used by middleware and RSC session loaders.
5
+ * Framework-agnostic (no Next imports).
6
+ */
7
+ /**
8
+ * True when Next.js threw because the route used dynamic APIs during static
9
+ * generation (`DYNAMIC_SERVER_USAGE` digest or matching message).
10
+ *
11
+ * Catch and rethrow (or handle) so Next can mark the route dynamic.
12
+ */
13
+ declare function isDynamicServerUsageError(error: unknown): boolean;
14
+ interface GetOriginFromHeadersOptions {
15
+ /**
16
+ * When `x-forwarded-proto` / scheme is missing, use `http` if true else `https`.
17
+ * Typical: `process.env.NODE_ENV !== "production"`.
18
+ */
19
+ preferHttpWhenMissingProto?: boolean;
20
+ }
21
+ /**
22
+ * Reconstruct public origin from request headers (Origin, or Host + proto).
23
+ *
24
+ * Prefers `Origin`, then `x-forwarded-host` / `host` with
25
+ * `x-forwarded-proto` (first value when comma-separated).
26
+ */
27
+ declare function getOriginFromHeaders(headersList: {
28
+ get: (name: string) => string | null;
29
+ }, options?: GetOriginFromHeadersOptions): string | null;
30
+
31
+ /**
32
+ * Read the first non-empty trimmed environment variable from a name list.
33
+ *
34
+ * @param names - Candidate env keys in priority order
35
+ * @param env - Optional env map (defaults to `process.env`)
36
+ * @returns Trimmed value of the first key that is set and non-empty
37
+ * @throws {Error} When none of the keys yield a non-empty value
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { requireEnv } from "@xylex-group/athena/utils"
42
+ *
43
+ * const authUrl = requireEnv([
44
+ * "ATHENA_AUTH_UPSTREAM_URL",
45
+ * "ATHENA_AUTH_URL",
46
+ * "NEXT_PUBLIC_ATHENA_AUTH_URL",
47
+ * ])
48
+ * ```
49
+ */
50
+ declare function requireEnv(names: readonly string[], env?: EnvLike): string;
51
+ /**
52
+ * Like {@link requireEnv}, but returns `undefined` instead of throwing when
53
+ * none of the keys are set.
54
+ */
55
+ declare function readEnv(names: readonly string[], env?: EnvLike): string | undefined;
56
+
57
+ declare function proxyRequestHeaders(request: Request): Headers;
58
+
59
+ export { type GetOriginFromHeadersOptions as G, requireEnv as a, getOriginFromHeaders as g, isDynamicServerUsageError as i, proxyRequestHeaders as p, readEnv as r };
package/dist/react.cjs CHANGED
@@ -86,7 +86,7 @@ function isAthenaGatewayError(error) {
86
86
  }
87
87
 
88
88
  // src/gateway/url.ts
89
- var ATHENA_DEFAULT_BASE_URL = "https://athena-db.com";
89
+ var ATHENA_DEFAULT_BASE_URL = "https://mirror2.athena-cluster.com";
90
90
  function describeReceivedValue(value) {
91
91
  if (value === void 0) return "undefined";
92
92
  if (value === null) return "null";
@@ -109,14 +109,14 @@ function normalizeAthenaGatewayBaseUrl(input, options = {}) {
109
109
  if (candidate === void 0 || candidate === null) {
110
110
  throw invalidBaseUrlError(
111
111
  `${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(input)}.`,
112
- 'Set ATHENA_URL (or pass createClient(url, ...)) to a full URL such as "https://mirror3.athena-db.com".'
112
+ 'Set ATHENA_URL in the explicit env object (or pass createClient({ url, key })) to a full URL such as "https://mirror2.athena-cluster.com".'
113
113
  );
114
114
  }
115
115
  const trimmed = candidate.trim();
116
116
  if (!trimmed) {
117
117
  throw invalidBaseUrlError(
118
118
  `${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
119
- 'Set ATHENA_URL (or pass createClient(url, ...)) to a full URL such as "https://mirror3.athena-db.com".'
119
+ 'Set ATHENA_URL in the explicit env object (or pass createClient({ url, key })) to a full URL such as "https://mirror2.athena-cluster.com".'
120
120
  );
121
121
  }
122
122
  let parsed;
@@ -125,13 +125,13 @@ function normalizeAthenaGatewayBaseUrl(input, options = {}) {
125
125
  } catch {
126
126
  throw invalidBaseUrlError(
127
127
  `${label} must be a valid absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
128
- 'Use a full URL including the protocol, for example "https://mirror3.athena-db.com".'
128
+ 'Use a full URL including the protocol, for example "https://mirror2.athena-cluster.com".'
129
129
  );
130
130
  }
131
131
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
132
132
  throw invalidBaseUrlError(
133
133
  `${label} must use http or https. Received ${JSON.stringify(trimmed)}.`,
134
- 'Use an Athena gateway URL such as "https://mirror3.athena-db.com".'
134
+ 'Use an Athena gateway URL such as "https://mirror2.athena-cluster.com".'
135
135
  );
136
136
  }
137
137
  if (parsed.search || parsed.hash) {
@@ -198,7 +198,7 @@ var PROFILE_RULES = {
198
198
  gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
199
199
  chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
200
200
  storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
201
- auth: { apiKeys: true, routing: false, authMirror: false, authBearer: true, contentType: true },
201
+ auth: { apiKeys: true, routing: true, authMirror: false, authBearer: true, contentType: true },
202
202
  minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
203
203
  };
204
204
  function normalizeHeaderValue(value) {
@@ -258,7 +258,6 @@ function resolveBackendType(backend) {
258
258
  function resolveRequestHeaderOverrides(config, options, defaults) {
259
259
  return {
260
260
  apiKey: options?.apiKey ?? config.apiKey,
261
- athenaKey: options?.athenaKey ?? config.athenaKey,
262
261
  client: options?.client ?? config.client ?? defaults?.client,
263
262
  userId: options?.userId ?? config.userId,
264
263
  organizationId: options?.organizationId ?? config.organizationId,
@@ -288,10 +287,10 @@ function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, ex
288
287
  accept: extras?.accept ?? (rules.accept ? "application/json" : void 0)
289
288
  });
290
289
  }
291
- function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
292
- const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
293
- if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
294
- headers["X-Athena-Key"] = resolvedAthenaKey;
290
+ function applyAthenaApiKeyHeaders(headers, apiKey) {
291
+ const resolvedApiKey = normalizeHeaderValue(apiKey);
292
+ if (resolvedApiKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
293
+ headers["X-Athena-Key"] = resolvedApiKey;
295
294
  }
296
295
  }
297
296
  function applyAthenaAuthContextHeaders(headers, input) {
@@ -355,7 +354,7 @@ function buildAthenaRequestHeaders(input) {
355
354
  const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
356
355
  const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
357
356
  const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
358
- const finalAthenaKey = normalizeHeaderValue(input.athenaKey) ?? resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
357
+ const finalAthenaKey = resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
359
358
  const headers = {
360
359
  "X-Athena-Sdk": input.sdkHeaderValue
361
360
  };
@@ -389,7 +388,7 @@ function buildAthenaRequestHeaders(input) {
389
388
  }
390
389
  }
391
390
  if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
392
- applyAthenaApiKeyHeaders(headers, finalApiKey, finalAthenaKey);
391
+ applyAthenaApiKeyHeaders(headers, finalAthenaKey);
393
392
  }
394
393
  applyAthenaAuthContextHeaders(headers, input);
395
394
  applyAthenaPgUriHeaders(headers, input);
@@ -414,7 +413,7 @@ function buildAthenaRequestHeaders(input) {
414
413
 
415
414
  // package.json
416
415
  var package_default = {
417
- version: "2.14.0"
416
+ version: "3.0.2"
418
417
  };
419
418
 
420
419
  // src/sdk-version.ts
@@ -424,7 +423,7 @@ function buildSdkHeaderValue(sdkName) {
424
423
  }
425
424
 
426
425
  // src/gateway/client.ts
427
- var DEFAULT_CLIENT = "railway_direct";
426
+ var DEFAULT_CLIENT = "DEFAULT_CLIENT";
428
427
  var SDK_NAME = "xylex-group/athena";
429
428
  var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
430
429
  function parseResponseBody(rawText, contentType) {
@@ -841,6 +840,9 @@ function createAthenaGatewayClient(config = {}) {
841
840
  buildHeaders(options) {
842
841
  return buildHeaders(normalizedConfig, options);
843
842
  },
843
+ async resolveCallOptions(options) {
844
+ return options;
845
+ },
844
846
  verifyConnection(options) {
845
847
  return performConnectionCheck(
846
848
  normalizedBaseUrl,
@@ -2002,7 +2004,7 @@ function resolveGetSession(authClient) {
2002
2004
  if ("auth" in authClient && authClient.auth && typeof authClient.auth.getSession === "function") {
2003
2005
  return authClient.auth.getSession;
2004
2006
  }
2005
- throw new Error("useSession requires an auth-capable client (createClient(...).auth or createAuthClient(...))");
2007
+ throw new Error("useSession requires an auth-capable client (createClient(...).auth)");
2006
2008
  }
2007
2009
  function useSession(authClient, options = {}) {
2008
2010
  const enabled = options.enabled ?? true;
@@ -2090,7 +2092,12 @@ function useSession(authClient, options = {}) {
2090
2092
  function useAthenaSessionClient(baseClient, options = {}) {
2091
2093
  const sessionState = useSession(baseClient, options);
2092
2094
  const scopedClient = React.useMemo(
2093
- () => sessionState.data ? baseClient.withSession(sessionState.data) : baseClient,
2095
+ () => sessionState.data ? baseClient.withContext({
2096
+ userId: sessionState.data.user.id,
2097
+ organizationId: sessionState.data.session.activeOrganizationId,
2098
+ bearerToken: sessionState.data.session.token,
2099
+ sessionToken: sessionState.data.session.token
2100
+ }) : baseClient,
2094
2101
  [baseClient, sessionState.data]
2095
2102
  );
2096
2103
  const session = sessionState.data;
@@ -2185,6 +2192,98 @@ function normalizeHookUploadInput(defaults, input, onProgress) {
2185
2192
  function isStorageUploadInput(input) {
2186
2193
  return Boolean(input) && typeof input === "object" && "files" in input && "s3_id" in input;
2187
2194
  }
2195
+ function useStorageFiles(options) {
2196
+ const { storage, input, enabled = true, callOptions, refreshIntervalMs } = options;
2197
+ const [data, setData] = React__namespace.useState(null);
2198
+ const [loading, setLoading] = React__namespace.useState(false);
2199
+ const [error, setError] = React__namespace.useState(null);
2200
+ const requestIdRef = React__namespace.useRef(0);
2201
+ const refetch = React__namespace.useCallback(async () => {
2202
+ if (!input || !enabled) {
2203
+ setData(null);
2204
+ setError(null);
2205
+ setLoading(false);
2206
+ return null;
2207
+ }
2208
+ const requestId = requestIdRef.current + 1;
2209
+ requestIdRef.current = requestId;
2210
+ setLoading(true);
2211
+ setError(null);
2212
+ try {
2213
+ const result = await storage.file.list(input, callOptions);
2214
+ if (requestIdRef.current === requestId) {
2215
+ setData(result);
2216
+ }
2217
+ return result;
2218
+ } catch (listError) {
2219
+ if (requestIdRef.current === requestId) {
2220
+ setError(listError);
2221
+ setData(null);
2222
+ }
2223
+ throw listError;
2224
+ } finally {
2225
+ if (requestIdRef.current === requestId) {
2226
+ setLoading(false);
2227
+ }
2228
+ }
2229
+ }, [callOptions, enabled, input, storage]);
2230
+ React__namespace.useEffect(() => {
2231
+ void refetch().catch(() => {
2232
+ });
2233
+ }, [refetch]);
2234
+ React__namespace.useEffect(() => {
2235
+ if (!enabled || !input || !refreshIntervalMs || refreshIntervalMs <= 0) {
2236
+ return;
2237
+ }
2238
+ const globalObject = globalThis;
2239
+ const timer = globalObject.setInterval(() => {
2240
+ void refetch().catch(() => {
2241
+ });
2242
+ }, refreshIntervalMs);
2243
+ return () => globalObject.clearInterval(timer);
2244
+ }, [enabled, input, refetch, refreshIntervalMs]);
2245
+ return {
2246
+ files: data?.files ?? [],
2247
+ count: data?.count ?? data?.files?.length ?? 0,
2248
+ loading,
2249
+ error,
2250
+ data,
2251
+ refetch
2252
+ };
2253
+ }
2254
+ function useStorageFileDelete(options) {
2255
+ const { storage, onSuccess, onError } = options;
2256
+ const [deleting, setDeleting] = React__namespace.useState(false);
2257
+ const [error, setError] = React__namespace.useState(null);
2258
+ const reset = React__namespace.useCallback(() => {
2259
+ setDeleting(false);
2260
+ setError(null);
2261
+ }, []);
2262
+ const deleteFile = React__namespace.useCallback(
2263
+ async (fileId, callOptions) => {
2264
+ setDeleting(true);
2265
+ setError(null);
2266
+ try {
2267
+ const result = await storage.file.delete(fileId, callOptions);
2268
+ onSuccess?.(result);
2269
+ return result;
2270
+ } catch (deleteError) {
2271
+ setError(deleteError);
2272
+ onError?.(deleteError);
2273
+ throw deleteError;
2274
+ } finally {
2275
+ setDeleting(false);
2276
+ }
2277
+ },
2278
+ [onError, onSuccess, storage]
2279
+ );
2280
+ return {
2281
+ deleting,
2282
+ error,
2283
+ deleteFile,
2284
+ reset
2285
+ };
2286
+ }
2188
2287
 
2189
2288
  // src/schema/model-form.ts
2190
2289
  function resolveNullishValue(mode) {
@@ -2262,6 +2361,8 @@ exports.useAthenaSessionClient = useAthenaSessionClient;
2262
2361
  exports.useMutation = useMutation;
2263
2362
  exports.useQuery = useQuery;
2264
2363
  exports.useSession = useSession;
2364
+ exports.useStorageFileDelete = useStorageFileDelete;
2365
+ exports.useStorageFiles = useStorageFiles;
2265
2366
  exports.useStorageUpload = useStorageUpload;
2266
2367
  //# sourceMappingURL=react.cjs.map
2267
2368
  //# sourceMappingURL=react.cjs.map