@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
package/dist/utils.d.cts
CHANGED
|
@@ -1,157 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export { A as ATHENA_AUTH_COOKIE_PREFIXES, a as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM, b as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE, c as ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH, d as ATHENA_AUTH_GET_SESSION_PATH, e as ATHENA_AUTH_PATH, f as ATHENA_AUTH_UPSTREAM_ENV_KEYS, g as ATHENA_AUTH_UPSTREAM_URL_ENV_NAMES, h as ATHENA_AUTH_VERIFY_EMAIL_PATH, i as ATHENA_SESSION_DATA_HEADER, j as AUTHENTICATED_REDIRECT_MODE_SET, k as AUTHENTICATED_REDIRECT_VIEW_SET, l as AUTH_DEFAULT_VIEW, m as AUTH_MODE_REDIRECTS, n as AUTH_MODE_SET, o as AUTH_ROUTES, p as AUTH_SESSION_PATH, q as AUTH_TWO_FACTOR_SEGMENT, r as AUTH_VIEW_BY_SEGMENT, s as AthenaAuthClientBaseUrlOptions, t as AthenaAuthUpstreamEnv, u as AthenaAuthUpstreamEnvKey, v as AthenaRequestHeaderOverrideFields, w as AthenaRequestHeaderProfile, x as AuthMode, y as AuthModeRedirects, z as AuthRoutes, B as AuthView, C as BuildAthenaRequestHeadersInput, D as ClearAuthCookiesOptions, E as DEFAULT_ATHENA_AUTH_ORIGIN, F as DEFAULT_ATHENA_AUTH_UPSTREAM_URL, ac as DEFAULT_AUTH_COOKIE_PREFIXES, G as DISABLE_COOKIE_CACHE_QUERY_PARAM, H as DISABLE_COOKIE_CACHE_QUERY_VALUE, I as EnvLike, L as LOCAL_DEV_ORIGIN, a4 as ResolvedRequestHeaderOverrides, S as SESSION_DATA_HEADER, a5 as applyAthenaApiKeyHeaders, a6 as applyAthenaAuthContextHeaders, a7 as applyAthenaPgUriHeaders, ad as asBoolean, ae as asBooleanOrNull, af as asIdentifier, J as asNonEmptyString, ag as asNumber, ah as asRecord, K as asString, ai as asStringArray, M as buildAthenaGatewayHeaders, N as buildAthenaRequestHeaders, a8 as buildServiceRequestHeaders, O as clearAuthCookies, P as createAuthModeRedirects, Q as createAuthRoutes, R as createFreshSessionLookupUrl, aj as firstString, a9 as hasHeaderIgnoreCase, T as isAbsoluteUrl, U as isAuthMode, V as normalizeAthenaAuthBaseUrl, W as readAthenaAuthUpstreamUrlFromEnv, X as readTrimmedString, Y as resolveAthenaAuthClientBaseUrl, Z as resolveAthenaAuthRequestUrl, _ as resolveAthenaAuthUpstreamUrl, $ as resolveAuthModeRedirect, a0 as resolveAuthViewFromSegment, a1 as resolveEmailVerificationCallbackUrl, aa as resolveHeaderValue, ab as resolveRequestHeaderOverrides, a2 as shouldRedirectAuthenticatedAuthMode, a3 as shouldRedirectAuthenticatedAuthView } from './athena-request-headers-DujFFyMU.cjs';
|
|
2
|
+
export { G as GetOriginFromHeadersOptions, g as getOriginFromHeaders, i as isDynamicServerUsageError, p as proxyRequestHeaders, r as readEnv, a as requireEnv } from './proxy-request-headers-DGxdoyA0.cjs';
|
|
3
3
|
export { S as SESSION_COOKIE_PATTERNS, h as hasAuthSessionCookie } from './session-cookie-detection-BqOp9mO6.cjs';
|
|
4
|
-
import
|
|
4
|
+
import './types-Bltx6iL6.cjs';
|
|
5
5
|
|
|
6
6
|
declare function slugify(input: string): string;
|
|
7
7
|
|
|
8
8
|
declare function trimTrailingSlashes(value: string): string;
|
|
9
9
|
|
|
10
|
-
declare function asString(value: unknown): string | null;
|
|
11
|
-
declare function asBoolean(value: unknown): boolean;
|
|
12
|
-
declare function asBooleanOrNull(value: unknown): boolean | null;
|
|
13
|
-
declare function asRecord(value: unknown): Record<string, unknown> | null;
|
|
14
|
-
declare function asIdentifier(value: unknown): string | null;
|
|
15
|
-
declare function firstString(record: Record<string, unknown> | null | undefined, keys: readonly string[]): string | null;
|
|
16
|
-
declare function readTrimmedString(value: unknown): string | null;
|
|
17
|
-
/**
|
|
18
|
-
* Trim a string value; return `undefined` when not a non-empty string.
|
|
19
|
-
*
|
|
20
|
-
* Unlike {@link asString}, does not coerce numbers/bigints.
|
|
21
|
-
* Unlike {@link readTrimmedString}, returns `undefined` instead of `null`
|
|
22
|
-
* (handy for optional fields and `??` defaults).
|
|
23
|
-
*/
|
|
24
|
-
declare function asNonEmptyString(value: unknown): string | undefined;
|
|
25
|
-
declare function asNumber(value: unknown): number | null;
|
|
26
|
-
declare function asStringArray(value: unknown): string[];
|
|
27
|
-
|
|
28
10
|
declare function parseBooleanFlag(rawValue: string | undefined, fallback: boolean): boolean;
|
|
29
11
|
|
|
30
|
-
/**
|
|
31
|
-
* Read the first non-empty trimmed environment variable from a name list.
|
|
32
|
-
*
|
|
33
|
-
* @param names - Candidate env keys in priority order
|
|
34
|
-
* @param env - Optional env map (defaults to `process.env`)
|
|
35
|
-
* @returns Trimmed value of the first key that is set and non-empty
|
|
36
|
-
* @throws {Error} When none of the keys yield a non-empty value
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { requireEnv } from "@xylex-group/athena/utils"
|
|
41
|
-
*
|
|
42
|
-
* const authUrl = requireEnv([
|
|
43
|
-
* "ATHENA_AUTH_UPSTREAM_URL",
|
|
44
|
-
* "ATHENA_AUTH_URL",
|
|
45
|
-
* "NEXT_PUBLIC_ATHENA_AUTH_URL",
|
|
46
|
-
* ])
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
declare function requireEnv(names: readonly string[], env?: EnvLike): string;
|
|
50
|
-
/**
|
|
51
|
-
* Like {@link requireEnv}, but returns `undefined` instead of throwing when
|
|
52
|
-
* none of the keys are set.
|
|
53
|
-
*/
|
|
54
|
-
declare function readEnv(names: readonly string[], env?: EnvLike): string | undefined;
|
|
55
|
-
|
|
56
12
|
declare function isLocalHostname(hostname: string): boolean;
|
|
57
13
|
|
|
58
|
-
/**
|
|
59
|
-
* Request header / Next.js helpers used by middleware and RSC session loaders.
|
|
60
|
-
* Framework-agnostic (no Next imports).
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* True when Next.js threw because the route used dynamic APIs during static
|
|
64
|
-
* generation (`DYNAMIC_SERVER_USAGE` digest or matching message).
|
|
65
|
-
*
|
|
66
|
-
* Catch and rethrow (or handle) so Next can mark the route dynamic.
|
|
67
|
-
*/
|
|
68
|
-
declare function isDynamicServerUsageError(error: unknown): boolean;
|
|
69
|
-
interface GetOriginFromHeadersOptions {
|
|
70
|
-
/**
|
|
71
|
-
* When `x-forwarded-proto` / scheme is missing, use `http` if true else `https`.
|
|
72
|
-
* Typical: `process.env.NODE_ENV !== "production"`.
|
|
73
|
-
*/
|
|
74
|
-
preferHttpWhenMissingProto?: boolean;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Reconstruct public origin from request headers (Origin, or Host + proto).
|
|
78
|
-
*
|
|
79
|
-
* Prefers `Origin`, then `x-forwarded-host` / `host` with
|
|
80
|
-
* `x-forwarded-proto` (first value when comma-separated).
|
|
81
|
-
*/
|
|
82
|
-
declare function getOriginFromHeaders(headersList: {
|
|
83
|
-
get: (name: string) => string | null;
|
|
84
|
-
}, options?: GetOriginFromHeadersOptions): string | null;
|
|
85
|
-
|
|
86
|
-
declare function proxyRequestHeaders(request: Request): Headers;
|
|
87
|
-
|
|
88
|
-
type AthenaRequestHeaderProfile = 'gateway' | 'auth' | 'chat' | 'storage' | 'minimal';
|
|
89
|
-
interface BuildAthenaRequestHeadersInput {
|
|
90
|
-
profile: AthenaRequestHeaderProfile;
|
|
91
|
-
sdkHeaderValue: string;
|
|
92
|
-
apiKey?: string | null;
|
|
93
|
-
/** Overrides the canonical `X-Athena-Key` header value. */
|
|
94
|
-
athenaKey?: string | null;
|
|
95
|
-
client?: string | null;
|
|
96
|
-
userId?: string | null;
|
|
97
|
-
organizationId?: string | null;
|
|
98
|
-
backend?: BackendOption;
|
|
99
|
-
publishEvent?: string | null;
|
|
100
|
-
stripNulls?: boolean;
|
|
101
|
-
bearerToken?: string | null;
|
|
102
|
-
cookie?: string | null;
|
|
103
|
-
sessionToken?: string | null;
|
|
104
|
-
pgUri?: string | null;
|
|
105
|
-
jdbcUrl?: string | null;
|
|
106
|
-
forceNoCache?: boolean;
|
|
107
|
-
configHeaders?: Record<string, string>;
|
|
108
|
-
callHeaders?: Record<string, string>;
|
|
109
|
-
contentType?: string | null;
|
|
110
|
-
accept?: string | null;
|
|
111
|
-
}
|
|
112
|
-
/** Shared config/call fields consumed by gateway, chat, auth, and `client.request(...)`. */
|
|
113
|
-
interface AthenaRequestHeaderOverrideFields {
|
|
114
|
-
apiKey?: string | null;
|
|
115
|
-
athenaKey?: string | null;
|
|
116
|
-
client?: string | null;
|
|
117
|
-
userId?: string | null;
|
|
118
|
-
organizationId?: string | null;
|
|
119
|
-
backend?: BackendOption;
|
|
120
|
-
publishEvent?: string | null;
|
|
121
|
-
stripNulls?: boolean;
|
|
122
|
-
bearerToken?: string | null;
|
|
123
|
-
cookie?: string | null;
|
|
124
|
-
sessionToken?: string | null;
|
|
125
|
-
pgUri?: string | null;
|
|
126
|
-
jdbcUrl?: string | null;
|
|
127
|
-
forceNoCache?: boolean;
|
|
128
|
-
headers?: Record<string, string>;
|
|
129
|
-
}
|
|
130
|
-
type ResolvedRequestHeaderOverrides = Omit<BuildAthenaRequestHeadersInput, 'profile' | 'sdkHeaderValue' | 'contentType' | 'accept'>;
|
|
131
|
-
declare function hasHeaderIgnoreCase(headers: Record<string, string>, targetKey: string): boolean;
|
|
132
|
-
declare function resolveHeaderValue(headers: Record<string, string>, candidates: readonly string[]): string | undefined;
|
|
133
|
-
declare function resolveRequestHeaderOverrides(config: AthenaRequestHeaderOverrideFields, options?: AthenaRequestHeaderOverrideFields, defaults?: Pick<AthenaRequestHeaderOverrideFields, 'client' | 'stripNulls'>): ResolvedRequestHeaderOverrides;
|
|
134
|
-
declare function buildServiceRequestHeaders(profile: Exclude<AthenaRequestHeaderProfile, 'minimal'>, sdkHeaderValue: string, config: AthenaRequestHeaderOverrideFields, options?: AthenaRequestHeaderOverrideFields, extras?: Pick<BuildAthenaRequestHeadersInput, 'contentType' | 'accept'> & {
|
|
135
|
-
client?: string | null;
|
|
136
|
-
stripNulls?: boolean;
|
|
137
|
-
}): Record<string, string>;
|
|
138
|
-
declare function applyAthenaApiKeyHeaders(headers: Record<string, string>, apiKey?: string | null, athenaKey?: string | null): void;
|
|
139
|
-
declare function applyAthenaAuthContextHeaders(headers: Record<string, string>, input: Pick<BuildAthenaRequestHeadersInput, 'bearerToken' | 'cookie' | 'sessionToken' | 'profile' | 'configHeaders' | 'callHeaders'>): void;
|
|
140
|
-
declare function applyAthenaPgUriHeaders(headers: Record<string, string>, input: Pick<BuildAthenaRequestHeadersInput, 'pgUri' | 'jdbcUrl' | 'configHeaders' | 'callHeaders'>): void;
|
|
141
|
-
/**
|
|
142
|
-
* Minimal gateway/data request headers used by many apps before they adopt
|
|
143
|
-
* the full {@link buildAthenaRequestHeaders} profile model.
|
|
144
|
-
*
|
|
145
|
-
* Additive convenience — does not replace client-built headers. Prefer
|
|
146
|
-
* `createClient({ client, key })` so the SDK sets these on every call.
|
|
147
|
-
*/
|
|
148
|
-
declare function buildAthenaGatewayHeaders(input: {
|
|
149
|
-
clientName?: string | null;
|
|
150
|
-
gatewayKey?: string | null;
|
|
151
|
-
headers?: Record<string, string | null | undefined>;
|
|
152
|
-
}): Record<string, string>;
|
|
153
|
-
declare function buildAthenaRequestHeaders(input: BuildAthenaRequestHeadersInput): Record<string, string>;
|
|
154
|
-
|
|
155
14
|
/**
|
|
156
15
|
* Wraps a string in a PostgreSQL dollar-quoted literal.
|
|
157
16
|
*
|
|
@@ -183,4 +42,4 @@ declare function sqlJsonbLiteral(value: unknown): string;
|
|
|
183
42
|
*/
|
|
184
43
|
declare function sqlBigInt(value: bigint | number): string;
|
|
185
44
|
|
|
186
|
-
export {
|
|
45
|
+
export { escapeLikePatternValue, isLocalHostname, parseBooleanFlag, quoteSqlStringLiteral, slugify, sqlBigInt, sqlJsonbLiteral, sqlNullableText, sqlText, trimTrailingSlashes };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,157 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export { A as ATHENA_AUTH_COOKIE_PREFIXES, a as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM, b as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE, c as ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH, d as ATHENA_AUTH_GET_SESSION_PATH, e as ATHENA_AUTH_PATH, f as ATHENA_AUTH_UPSTREAM_ENV_KEYS, g as ATHENA_AUTH_UPSTREAM_URL_ENV_NAMES, h as ATHENA_AUTH_VERIFY_EMAIL_PATH, i as ATHENA_SESSION_DATA_HEADER, j as AUTHENTICATED_REDIRECT_MODE_SET, k as AUTHENTICATED_REDIRECT_VIEW_SET, l as AUTH_DEFAULT_VIEW, m as AUTH_MODE_REDIRECTS, n as AUTH_MODE_SET, o as AUTH_ROUTES, p as AUTH_SESSION_PATH, q as AUTH_TWO_FACTOR_SEGMENT, r as AUTH_VIEW_BY_SEGMENT, s as AthenaAuthClientBaseUrlOptions, t as AthenaAuthUpstreamEnv, u as AthenaAuthUpstreamEnvKey, v as AthenaRequestHeaderOverrideFields, w as AthenaRequestHeaderProfile, x as AuthMode, y as AuthModeRedirects, z as AuthRoutes, B as AuthView, C as BuildAthenaRequestHeadersInput, D as ClearAuthCookiesOptions, E as DEFAULT_ATHENA_AUTH_ORIGIN, F as DEFAULT_ATHENA_AUTH_UPSTREAM_URL, ac as DEFAULT_AUTH_COOKIE_PREFIXES, G as DISABLE_COOKIE_CACHE_QUERY_PARAM, H as DISABLE_COOKIE_CACHE_QUERY_VALUE, I as EnvLike, L as LOCAL_DEV_ORIGIN, a4 as ResolvedRequestHeaderOverrides, S as SESSION_DATA_HEADER, a5 as applyAthenaApiKeyHeaders, a6 as applyAthenaAuthContextHeaders, a7 as applyAthenaPgUriHeaders, ad as asBoolean, ae as asBooleanOrNull, af as asIdentifier, J as asNonEmptyString, ag as asNumber, ah as asRecord, K as asString, ai as asStringArray, M as buildAthenaGatewayHeaders, N as buildAthenaRequestHeaders, a8 as buildServiceRequestHeaders, O as clearAuthCookies, P as createAuthModeRedirects, Q as createAuthRoutes, R as createFreshSessionLookupUrl, aj as firstString, a9 as hasHeaderIgnoreCase, T as isAbsoluteUrl, U as isAuthMode, V as normalizeAthenaAuthBaseUrl, W as readAthenaAuthUpstreamUrlFromEnv, X as readTrimmedString, Y as resolveAthenaAuthClientBaseUrl, Z as resolveAthenaAuthRequestUrl, _ as resolveAthenaAuthUpstreamUrl, $ as resolveAuthModeRedirect, a0 as resolveAuthViewFromSegment, a1 as resolveEmailVerificationCallbackUrl, aa as resolveHeaderValue, ab as resolveRequestHeaderOverrides, a2 as shouldRedirectAuthenticatedAuthMode, a3 as shouldRedirectAuthenticatedAuthView } from './athena-request-headers-C7Jy-c_D.js';
|
|
2
|
+
export { G as GetOriginFromHeadersOptions, g as getOriginFromHeaders, i as isDynamicServerUsageError, p as proxyRequestHeaders, r as readEnv, a as requireEnv } from './proxy-request-headers-m4D2Tduy.js';
|
|
3
3
|
export { S as SESSION_COOKIE_PATTERNS, h as hasAuthSessionCookie } from './session-cookie-detection-BqOp9mO6.js';
|
|
4
|
-
import
|
|
4
|
+
import './types-Bltx6iL6.js';
|
|
5
5
|
|
|
6
6
|
declare function slugify(input: string): string;
|
|
7
7
|
|
|
8
8
|
declare function trimTrailingSlashes(value: string): string;
|
|
9
9
|
|
|
10
|
-
declare function asString(value: unknown): string | null;
|
|
11
|
-
declare function asBoolean(value: unknown): boolean;
|
|
12
|
-
declare function asBooleanOrNull(value: unknown): boolean | null;
|
|
13
|
-
declare function asRecord(value: unknown): Record<string, unknown> | null;
|
|
14
|
-
declare function asIdentifier(value: unknown): string | null;
|
|
15
|
-
declare function firstString(record: Record<string, unknown> | null | undefined, keys: readonly string[]): string | null;
|
|
16
|
-
declare function readTrimmedString(value: unknown): string | null;
|
|
17
|
-
/**
|
|
18
|
-
* Trim a string value; return `undefined` when not a non-empty string.
|
|
19
|
-
*
|
|
20
|
-
* Unlike {@link asString}, does not coerce numbers/bigints.
|
|
21
|
-
* Unlike {@link readTrimmedString}, returns `undefined` instead of `null`
|
|
22
|
-
* (handy for optional fields and `??` defaults).
|
|
23
|
-
*/
|
|
24
|
-
declare function asNonEmptyString(value: unknown): string | undefined;
|
|
25
|
-
declare function asNumber(value: unknown): number | null;
|
|
26
|
-
declare function asStringArray(value: unknown): string[];
|
|
27
|
-
|
|
28
10
|
declare function parseBooleanFlag(rawValue: string | undefined, fallback: boolean): boolean;
|
|
29
11
|
|
|
30
|
-
/**
|
|
31
|
-
* Read the first non-empty trimmed environment variable from a name list.
|
|
32
|
-
*
|
|
33
|
-
* @param names - Candidate env keys in priority order
|
|
34
|
-
* @param env - Optional env map (defaults to `process.env`)
|
|
35
|
-
* @returns Trimmed value of the first key that is set and non-empty
|
|
36
|
-
* @throws {Error} When none of the keys yield a non-empty value
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { requireEnv } from "@xylex-group/athena/utils"
|
|
41
|
-
*
|
|
42
|
-
* const authUrl = requireEnv([
|
|
43
|
-
* "ATHENA_AUTH_UPSTREAM_URL",
|
|
44
|
-
* "ATHENA_AUTH_URL",
|
|
45
|
-
* "NEXT_PUBLIC_ATHENA_AUTH_URL",
|
|
46
|
-
* ])
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
declare function requireEnv(names: readonly string[], env?: EnvLike): string;
|
|
50
|
-
/**
|
|
51
|
-
* Like {@link requireEnv}, but returns `undefined` instead of throwing when
|
|
52
|
-
* none of the keys are set.
|
|
53
|
-
*/
|
|
54
|
-
declare function readEnv(names: readonly string[], env?: EnvLike): string | undefined;
|
|
55
|
-
|
|
56
12
|
declare function isLocalHostname(hostname: string): boolean;
|
|
57
13
|
|
|
58
|
-
/**
|
|
59
|
-
* Request header / Next.js helpers used by middleware and RSC session loaders.
|
|
60
|
-
* Framework-agnostic (no Next imports).
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* True when Next.js threw because the route used dynamic APIs during static
|
|
64
|
-
* generation (`DYNAMIC_SERVER_USAGE` digest or matching message).
|
|
65
|
-
*
|
|
66
|
-
* Catch and rethrow (or handle) so Next can mark the route dynamic.
|
|
67
|
-
*/
|
|
68
|
-
declare function isDynamicServerUsageError(error: unknown): boolean;
|
|
69
|
-
interface GetOriginFromHeadersOptions {
|
|
70
|
-
/**
|
|
71
|
-
* When `x-forwarded-proto` / scheme is missing, use `http` if true else `https`.
|
|
72
|
-
* Typical: `process.env.NODE_ENV !== "production"`.
|
|
73
|
-
*/
|
|
74
|
-
preferHttpWhenMissingProto?: boolean;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Reconstruct public origin from request headers (Origin, or Host + proto).
|
|
78
|
-
*
|
|
79
|
-
* Prefers `Origin`, then `x-forwarded-host` / `host` with
|
|
80
|
-
* `x-forwarded-proto` (first value when comma-separated).
|
|
81
|
-
*/
|
|
82
|
-
declare function getOriginFromHeaders(headersList: {
|
|
83
|
-
get: (name: string) => string | null;
|
|
84
|
-
}, options?: GetOriginFromHeadersOptions): string | null;
|
|
85
|
-
|
|
86
|
-
declare function proxyRequestHeaders(request: Request): Headers;
|
|
87
|
-
|
|
88
|
-
type AthenaRequestHeaderProfile = 'gateway' | 'auth' | 'chat' | 'storage' | 'minimal';
|
|
89
|
-
interface BuildAthenaRequestHeadersInput {
|
|
90
|
-
profile: AthenaRequestHeaderProfile;
|
|
91
|
-
sdkHeaderValue: string;
|
|
92
|
-
apiKey?: string | null;
|
|
93
|
-
/** Overrides the canonical `X-Athena-Key` header value. */
|
|
94
|
-
athenaKey?: string | null;
|
|
95
|
-
client?: string | null;
|
|
96
|
-
userId?: string | null;
|
|
97
|
-
organizationId?: string | null;
|
|
98
|
-
backend?: BackendOption;
|
|
99
|
-
publishEvent?: string | null;
|
|
100
|
-
stripNulls?: boolean;
|
|
101
|
-
bearerToken?: string | null;
|
|
102
|
-
cookie?: string | null;
|
|
103
|
-
sessionToken?: string | null;
|
|
104
|
-
pgUri?: string | null;
|
|
105
|
-
jdbcUrl?: string | null;
|
|
106
|
-
forceNoCache?: boolean;
|
|
107
|
-
configHeaders?: Record<string, string>;
|
|
108
|
-
callHeaders?: Record<string, string>;
|
|
109
|
-
contentType?: string | null;
|
|
110
|
-
accept?: string | null;
|
|
111
|
-
}
|
|
112
|
-
/** Shared config/call fields consumed by gateway, chat, auth, and `client.request(...)`. */
|
|
113
|
-
interface AthenaRequestHeaderOverrideFields {
|
|
114
|
-
apiKey?: string | null;
|
|
115
|
-
athenaKey?: string | null;
|
|
116
|
-
client?: string | null;
|
|
117
|
-
userId?: string | null;
|
|
118
|
-
organizationId?: string | null;
|
|
119
|
-
backend?: BackendOption;
|
|
120
|
-
publishEvent?: string | null;
|
|
121
|
-
stripNulls?: boolean;
|
|
122
|
-
bearerToken?: string | null;
|
|
123
|
-
cookie?: string | null;
|
|
124
|
-
sessionToken?: string | null;
|
|
125
|
-
pgUri?: string | null;
|
|
126
|
-
jdbcUrl?: string | null;
|
|
127
|
-
forceNoCache?: boolean;
|
|
128
|
-
headers?: Record<string, string>;
|
|
129
|
-
}
|
|
130
|
-
type ResolvedRequestHeaderOverrides = Omit<BuildAthenaRequestHeadersInput, 'profile' | 'sdkHeaderValue' | 'contentType' | 'accept'>;
|
|
131
|
-
declare function hasHeaderIgnoreCase(headers: Record<string, string>, targetKey: string): boolean;
|
|
132
|
-
declare function resolveHeaderValue(headers: Record<string, string>, candidates: readonly string[]): string | undefined;
|
|
133
|
-
declare function resolveRequestHeaderOverrides(config: AthenaRequestHeaderOverrideFields, options?: AthenaRequestHeaderOverrideFields, defaults?: Pick<AthenaRequestHeaderOverrideFields, 'client' | 'stripNulls'>): ResolvedRequestHeaderOverrides;
|
|
134
|
-
declare function buildServiceRequestHeaders(profile: Exclude<AthenaRequestHeaderProfile, 'minimal'>, sdkHeaderValue: string, config: AthenaRequestHeaderOverrideFields, options?: AthenaRequestHeaderOverrideFields, extras?: Pick<BuildAthenaRequestHeadersInput, 'contentType' | 'accept'> & {
|
|
135
|
-
client?: string | null;
|
|
136
|
-
stripNulls?: boolean;
|
|
137
|
-
}): Record<string, string>;
|
|
138
|
-
declare function applyAthenaApiKeyHeaders(headers: Record<string, string>, apiKey?: string | null, athenaKey?: string | null): void;
|
|
139
|
-
declare function applyAthenaAuthContextHeaders(headers: Record<string, string>, input: Pick<BuildAthenaRequestHeadersInput, 'bearerToken' | 'cookie' | 'sessionToken' | 'profile' | 'configHeaders' | 'callHeaders'>): void;
|
|
140
|
-
declare function applyAthenaPgUriHeaders(headers: Record<string, string>, input: Pick<BuildAthenaRequestHeadersInput, 'pgUri' | 'jdbcUrl' | 'configHeaders' | 'callHeaders'>): void;
|
|
141
|
-
/**
|
|
142
|
-
* Minimal gateway/data request headers used by many apps before they adopt
|
|
143
|
-
* the full {@link buildAthenaRequestHeaders} profile model.
|
|
144
|
-
*
|
|
145
|
-
* Additive convenience — does not replace client-built headers. Prefer
|
|
146
|
-
* `createClient({ client, key })` so the SDK sets these on every call.
|
|
147
|
-
*/
|
|
148
|
-
declare function buildAthenaGatewayHeaders(input: {
|
|
149
|
-
clientName?: string | null;
|
|
150
|
-
gatewayKey?: string | null;
|
|
151
|
-
headers?: Record<string, string | null | undefined>;
|
|
152
|
-
}): Record<string, string>;
|
|
153
|
-
declare function buildAthenaRequestHeaders(input: BuildAthenaRequestHeadersInput): Record<string, string>;
|
|
154
|
-
|
|
155
14
|
/**
|
|
156
15
|
* Wraps a string in a PostgreSQL dollar-quoted literal.
|
|
157
16
|
*
|
|
@@ -183,4 +42,4 @@ declare function sqlJsonbLiteral(value: unknown): string;
|
|
|
183
42
|
*/
|
|
184
43
|
declare function sqlBigInt(value: bigint | number): string;
|
|
185
44
|
|
|
186
|
-
export {
|
|
45
|
+
export { escapeLikePatternValue, isLocalHostname, parseBooleanFlag, quoteSqlStringLiteral, slugify, sqlBigInt, sqlJsonbLiteral, sqlNullableText, sqlText, trimTrailingSlashes };
|
package/dist/utils.js
CHANGED
|
@@ -626,7 +626,7 @@ var PROFILE_RULES = {
|
|
|
626
626
|
gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
|
|
627
627
|
chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
|
|
628
628
|
storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
|
|
629
|
-
auth: { apiKeys: true, routing:
|
|
629
|
+
auth: { apiKeys: true, routing: true, authMirror: false, authBearer: true, contentType: true },
|
|
630
630
|
minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
|
|
631
631
|
};
|
|
632
632
|
function normalizeHeaderValue(value) {
|
|
@@ -686,7 +686,6 @@ function resolveBackendType(backend) {
|
|
|
686
686
|
function resolveRequestHeaderOverrides(config, options, defaults) {
|
|
687
687
|
return {
|
|
688
688
|
apiKey: options?.apiKey ?? config.apiKey,
|
|
689
|
-
athenaKey: options?.athenaKey ?? config.athenaKey,
|
|
690
689
|
client: options?.client ?? config.client ?? defaults?.client,
|
|
691
690
|
userId: options?.userId ?? config.userId,
|
|
692
691
|
organizationId: options?.organizationId ?? config.organizationId,
|
|
@@ -716,10 +715,10 @@ function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, ex
|
|
|
716
715
|
accept: extras?.accept ?? (rules.accept ? "application/json" : void 0)
|
|
717
716
|
});
|
|
718
717
|
}
|
|
719
|
-
function applyAthenaApiKeyHeaders(headers, apiKey
|
|
720
|
-
const
|
|
721
|
-
if (
|
|
722
|
-
headers["X-Athena-Key"] =
|
|
718
|
+
function applyAthenaApiKeyHeaders(headers, apiKey) {
|
|
719
|
+
const resolvedApiKey = normalizeHeaderValue(apiKey);
|
|
720
|
+
if (resolvedApiKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
721
|
+
headers["X-Athena-Key"] = resolvedApiKey;
|
|
723
722
|
}
|
|
724
723
|
}
|
|
725
724
|
function applyAthenaAuthContextHeaders(headers, input) {
|
|
@@ -802,7 +801,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
802
801
|
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
803
802
|
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
804
803
|
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
805
|
-
const finalAthenaKey =
|
|
804
|
+
const finalAthenaKey = resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
806
805
|
const headers = {
|
|
807
806
|
"X-Athena-Sdk": input.sdkHeaderValue
|
|
808
807
|
};
|
|
@@ -836,7 +835,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
836
835
|
}
|
|
837
836
|
}
|
|
838
837
|
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
839
|
-
applyAthenaApiKeyHeaders(headers,
|
|
838
|
+
applyAthenaApiKeyHeaders(headers, finalAthenaKey);
|
|
840
839
|
}
|
|
841
840
|
applyAthenaAuthContextHeaders(headers, input);
|
|
842
841
|
applyAthenaPgUriHeaders(headers, input);
|