@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.
- package/README.md +109 -1402
- package/dist/admin.d.cts +1 -1
- package/dist/admin.d.ts +1 -1
- package/dist/{athena-auth-url-oLux_57a.d.cts → athena-request-headers-C7Jy-c_D.d.ts} +85 -1
- package/dist/{athena-auth-url-oLux_57a.d.ts → athena-request-headers-DujFFyMU.d.cts} +85 -1
- package/dist/billing.cjs +1311 -0
- package/dist/billing.cjs.map +1 -0
- package/dist/billing.d.cts +270 -0
- package/dist/billing.d.ts +270 -0
- package/dist/billing.js +1306 -0
- package/dist/billing.js.map +1 -0
- package/dist/browser.cjs +9695 -9243
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +11 -10
- package/dist/browser.d.ts +11 -10
- package/dist/browser.js +9692 -9241
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +8137 -7286
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -4
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +8137 -7286
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +9718 -9260
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +9711 -9258
- package/dist/index.js.map +1 -1
- package/dist/{model-form-DcH3R7WD.d.ts → model-form-Dh0sisdL.d.ts} +2 -2
- package/dist/{model-form-BE1_Bmdd.d.cts → model-form-oOAJUVd4.d.cts} +2 -2
- package/dist/{module-DFGZXCtt.d.cts → module-CB25egcO.d.cts} +18 -52
- package/dist/module-C_ab-MM1.d.cts +360 -0
- package/dist/module-C_ab-MM1.d.ts +360 -0
- package/dist/{module-Ca3_OQqR.d.ts → module-CkUM6v58.d.ts} +18 -52
- package/dist/next/client.cjs +9116 -8468
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +24 -25
- package/dist/next/client.d.ts +24 -25
- package/dist/next/client.js +9088 -8469
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +8932 -7776
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +62 -43
- package/dist/next/server.d.ts +62 -43
- package/dist/next/server.js +8873 -7777
- package/dist/next/server.js.map +1 -1
- package/dist/{payload-BbSCmILD.d.ts → payload-DWI1rw-e.d.cts} +1 -35
- package/dist/{payload-zXIwKTQf.d.cts → payload-DWI1rw-e.d.ts} +1 -35
- package/dist/{pipeline-DqwehoQV.d.ts → pipeline-B8aN2EHe.d.ts} +1 -1
- package/dist/{pipeline-CwQoD5G9.d.cts → pipeline-D4W-Cc-A.d.cts} +1 -1
- package/dist/proxy-request-headers-DGxdoyA0.d.cts +59 -0
- package/dist/proxy-request-headers-m4D2Tduy.d.ts +59 -0
- package/dist/react.cjs +118 -17
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +46 -16
- package/dist/react.d.ts +46 -16
- package/dist/react.js +117 -18
- package/dist/react.js.map +1 -1
- package/dist/social-providers.cjs +24 -20
- package/dist/social-providers.cjs.map +1 -1
- package/dist/social-providers.d.cts +96 -139
- package/dist/social-providers.d.ts +96 -139
- package/dist/social-providers.js +24 -20
- package/dist/social-providers.js.map +1 -1
- package/dist/{types-eAKAh71s.d.cts → types-AOY-GLu8.d.cts} +27 -54
- package/dist/{types-eAKAh71s.d.ts → types-AOY-GLu8.d.ts} +27 -54
- package/dist/{types-CD6K05JQ.d.ts → types-B75PdABb.d.ts} +3 -3
- package/dist/{types-dHnjluBC.d.cts → types-BBm-kEBL.d.cts} +2 -2
- package/dist/{types-C1swabT5.d.ts → types-BaAMXCqK.d.ts} +2 -2
- package/dist/{types-YQUR7wu0.d.cts → types-Bltx6iL6.d.cts} +3 -5
- package/dist/{types-YQUR7wu0.d.ts → types-Bltx6iL6.d.ts} +3 -5
- package/dist/{types-6H575ITc.d.cts → types-CgCv5o6R.d.cts} +3 -3
- package/dist/utils.cjs +7 -8
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +4 -145
- package/dist/utils.d.ts +4 -145
- package/dist/utils.js +7 -8
- package/dist/utils.js.map +1 -1
- package/dist/{client-wU2J9yqb.d.cts → v3-client-CWfZHcKL.d.cts} +402 -521
- package/dist/{client-uthENhaf.d.ts → v3-client-DZp2NEhK.d.ts} +402 -521
- 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 {
|
|
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 {
|
|
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-
|
|
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-
|
|
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-
|
|
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,
|
|
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,
|
|
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://
|
|
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://
|
|
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:
|
|
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
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
headers["X-Athena-Key"] =
|
|
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 =
|
|
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,
|
|
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: "
|
|
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 = "
|
|
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
|
|
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.
|
|
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
|