@xylex-group/athena 2.4.0 → 2.4.1
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 +73 -2
- package/dist/browser.cjs +331 -100
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +3 -3
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +331 -100
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +377 -92
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +377 -92
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +331 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +331 -100
- package/dist/index.js.map +1 -1
- package/dist/{model-form-GzTqhEzM.d.cts → model-form-4LPnOPAF.d.cts} +8 -4
- package/dist/{model-form-C0FAbOaf.d.ts → model-form-CO4-LmNC.d.ts} +8 -4
- package/dist/{react-email-CQJq92zQ.d.cts → react-email-6mOyxBo4.d.cts} +42 -8
- package/dist/{react-email-BuApZuyG.d.ts → react-email-Buhcpglm.d.ts} +42 -8
- package/dist/react.cjs +84 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +84 -4
- package/dist/react.js.map +1 -1
- package/dist/utils.cjs +131 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +42 -1
- package/dist/utils.d.ts +42 -1
- package/dist/utils.js +117 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { O as AthenaGatewayHookConfig, P as AthenaGatewayHookResult } from './types-09Q4D86N.cjs';
|
|
2
2
|
export { Q as AthenaDeletePayload, V as AthenaFetchPayload, a as AthenaGatewayCallOptions, d as AthenaGatewayErrorCode, e as AthenaGatewayErrorDetails, W as AthenaGatewayResponse, X as AthenaInsertPayload, f as AthenaJsonArray, g as AthenaJsonObject, h as AthenaJsonPrimitive, i as AthenaJsonValue, j as AthenaRpcCallOptions, k as AthenaRpcFilter, l as AthenaRpcFilterOperator, m as AthenaRpcOrder, n as AthenaRpcPayload, Y as AthenaUpdatePayload } from './types-09Q4D86N.cjs';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { ao as AthenaAuthFetchCompatibleInput, e as AthenaAuthCallOptions, Q as AthenaAuthSessionResponse, p as AthenaAuthErrorDetails, L as AthenaAuthResult } from './model-form-4LPnOPAF.cjs';
|
|
4
|
+
export { a3 as AthenaGatewayError, ae as ModelFormAdapter, af as ModelFormDefaults, ag as ModelFormNullishMode, ah as ModelFormValues, ai as ToModelFormDefaultsOptions, aj as ToModelPayloadOptions, ak as createModelFormAdapter, al as isAthenaGatewayError, am as toModelFormDefaults, an as toModelPayload } from './model-form-4LPnOPAF.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { O as AthenaGatewayHookConfig, P as AthenaGatewayHookResult } from './types-09Q4D86N.js';
|
|
2
2
|
export { Q as AthenaDeletePayload, V as AthenaFetchPayload, a as AthenaGatewayCallOptions, d as AthenaGatewayErrorCode, e as AthenaGatewayErrorDetails, W as AthenaGatewayResponse, X as AthenaInsertPayload, f as AthenaJsonArray, g as AthenaJsonObject, h as AthenaJsonPrimitive, i as AthenaJsonValue, j as AthenaRpcCallOptions, k as AthenaRpcFilter, l as AthenaRpcFilterOperator, m as AthenaRpcOrder, n as AthenaRpcPayload, Y as AthenaUpdatePayload } from './types-09Q4D86N.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { ao as AthenaAuthFetchCompatibleInput, e as AthenaAuthCallOptions, Q as AthenaAuthSessionResponse, p as AthenaAuthErrorDetails, L as AthenaAuthResult } from './model-form-CO4-LmNC.js';
|
|
4
|
+
export { a3 as AthenaGatewayError, ae as ModelFormAdapter, af as ModelFormDefaults, ag as ModelFormNullishMode, ah as ModelFormValues, ai as ToModelFormDefaultsOptions, aj as ToModelPayloadOptions, ak as createModelFormAdapter, al as isAthenaGatewayError, am as toModelFormDefaults, an as toModelPayload } from './model-form-CO4-LmNC.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
package/dist/react.js
CHANGED
|
@@ -130,12 +130,47 @@ function buildAthenaGatewayUrl(baseUrl, path) {
|
|
|
130
130
|
return `${baseUrl}${path}`;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
// src/cookies/cookie-utils.ts
|
|
134
|
+
var SECURE_COOKIE_PREFIX = "__Secure-";
|
|
135
|
+
function parseCookies(cookieHeader) {
|
|
136
|
+
const cookies = cookieHeader.split("; ");
|
|
137
|
+
const cookieMap = /* @__PURE__ */ new Map();
|
|
138
|
+
cookies.forEach((cookie) => {
|
|
139
|
+
const [name, value] = cookie.split(/=(.*)/s);
|
|
140
|
+
cookieMap.set(name, value);
|
|
141
|
+
});
|
|
142
|
+
return cookieMap;
|
|
143
|
+
}
|
|
144
|
+
var getSessionCookie = (request, config) => {
|
|
145
|
+
const cookies = (request instanceof Headers || !("headers" in request) ? request : request.headers).get("cookie");
|
|
146
|
+
if (!cookies) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const { cookieName = "session_token", cookiePrefix = "athena-auth" } = {};
|
|
150
|
+
const parsedCookie = parseCookies(cookies);
|
|
151
|
+
const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
|
|
152
|
+
const sessionToken = getCookie(`${cookiePrefix}.${cookieName}`) || getCookie(`${cookiePrefix}-${cookieName}`);
|
|
153
|
+
if (sessionToken) {
|
|
154
|
+
return sessionToken;
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// package.json
|
|
160
|
+
var package_default = {
|
|
161
|
+
version: "2.4.1"
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/sdk-version.ts
|
|
165
|
+
var PACKAGE_VERSION = package_default.version;
|
|
166
|
+
function buildSdkHeaderValue(sdkName) {
|
|
167
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
168
|
+
}
|
|
169
|
+
|
|
133
170
|
// src/gateway/client.ts
|
|
134
171
|
var DEFAULT_CLIENT = "railway_direct";
|
|
135
|
-
var FALLBACK_SDK_VERSION = "1.3.0";
|
|
136
172
|
var SDK_NAME = "xylex-group/athena";
|
|
137
|
-
var
|
|
138
|
-
var SDK_HEADER_VALUE = `${SDK_NAME} ${SDK_VERSION}`;
|
|
173
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
139
174
|
function parseResponseBody(rawText, contentType) {
|
|
140
175
|
if (!rawText) {
|
|
141
176
|
return { parsed: null, parseFailed: false };
|
|
@@ -154,6 +189,37 @@ function parseResponseBody(rawText, contentType) {
|
|
|
154
189
|
function normalizeHeaderValue(value) {
|
|
155
190
|
return value ? value : void 0;
|
|
156
191
|
}
|
|
192
|
+
function resolveHeaderValue(headers, candidates) {
|
|
193
|
+
for (const candidate of candidates) {
|
|
194
|
+
const direct = normalizeHeaderValue(headers[candidate]);
|
|
195
|
+
if (direct) return direct;
|
|
196
|
+
}
|
|
197
|
+
const loweredCandidates = new Set(candidates.map((candidate) => candidate.toLowerCase()));
|
|
198
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
199
|
+
if (!loweredCandidates.has(key.toLowerCase())) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const normalized = normalizeHeaderValue(value);
|
|
203
|
+
if (normalized) return normalized;
|
|
204
|
+
}
|
|
205
|
+
return void 0;
|
|
206
|
+
}
|
|
207
|
+
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
208
|
+
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
209
|
+
if (!authorization) {
|
|
210
|
+
return void 0;
|
|
211
|
+
}
|
|
212
|
+
const match = authorization.match(/^Bearer\s+(.+)$/i);
|
|
213
|
+
const token = match?.[1]?.trim();
|
|
214
|
+
return token ? token : void 0;
|
|
215
|
+
}
|
|
216
|
+
function resolveSessionTokenFromCookieHeader(headers) {
|
|
217
|
+
const cookie = resolveHeaderValue(headers, ["Cookie"]);
|
|
218
|
+
if (!cookie) {
|
|
219
|
+
return void 0;
|
|
220
|
+
}
|
|
221
|
+
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
222
|
+
}
|
|
157
223
|
function isRecord(value) {
|
|
158
224
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
159
225
|
}
|
|
@@ -271,7 +337,7 @@ function buildRpcGetEndpoint(payload) {
|
|
|
271
337
|
status: 0
|
|
272
338
|
});
|
|
273
339
|
}
|
|
274
|
-
query.
|
|
340
|
+
query.append(filter.column, toRpcFilterQueryValue(filter));
|
|
275
341
|
}
|
|
276
342
|
}
|
|
277
343
|
const endpoint = `/rpc/${encodeURIComponent(functionName)}`;
|
|
@@ -317,6 +383,20 @@ function buildHeaders(config, options) {
|
|
|
317
383
|
headers["apikey"] = finalApiKey;
|
|
318
384
|
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
319
385
|
}
|
|
386
|
+
const explicitSessionToken = resolveHeaderValue(extraHeaders, [
|
|
387
|
+
"X-Athena-Auth-Session-Token"
|
|
388
|
+
]);
|
|
389
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
|
|
390
|
+
if (derivedSessionToken) {
|
|
391
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
392
|
+
}
|
|
393
|
+
const explicitBearerToken = resolveHeaderValue(extraHeaders, [
|
|
394
|
+
"X-Athena-Auth-Bearer-Token"
|
|
395
|
+
]);
|
|
396
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
|
|
397
|
+
if (derivedBearerToken) {
|
|
398
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
399
|
+
}
|
|
320
400
|
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
321
401
|
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
322
402
|
if (athenaClientKeys.includes(key)) return;
|