@xylex-group/athena 1.9.0 → 2.1.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 +86 -68
- package/bin/athena-js.js +0 -0
- package/dist/browser.cjs +3319 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +25 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +3276 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli/index.cjs +1839 -275
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -2
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +1840 -276
- package/dist/cli/index.js.map +1 -1
- package/dist/client-BX0NQqOn.d.ts +435 -0
- package/dist/client-dpAp-NZK.d.cts +435 -0
- package/dist/cookies.cjs +890 -0
- package/dist/cookies.cjs.map +1 -0
- package/dist/cookies.d.cts +174 -0
- package/dist/cookies.d.ts +174 -0
- package/dist/cookies.js +869 -0
- package/dist/cookies.js.map +1 -0
- package/dist/index.cjs +2724 -1777
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -641
- package/dist/index.d.ts +8 -641
- package/dist/index.js +2725 -1779
- package/dist/index.js.map +1 -1
- package/dist/model-form-2hqmoOUX.d.ts +1284 -0
- package/dist/model-form-Cy-zaO0u.d.cts +1284 -0
- package/dist/pipeline-BOPszLsL.d.ts +8 -0
- package/dist/pipeline-E3FDbs4W.d.cts +8 -0
- package/dist/react.cjs +93 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +38 -4
- package/dist/react.d.ts +38 -4
- package/dist/react.js +93 -1
- package/dist/react.js.map +1 -1
- package/dist/{types-BnzoaNRC.d.cts → types-BaBzjwXr.d.cts} +1 -1
- package/dist/{types-BnzoaNRC.d.ts → types-BaBzjwXr.d.ts} +1 -1
- package/dist/{pipeline-CQgV-Yfo.d.ts → types-CeBPrnGj.d.ts} +2 -7
- package/dist/{pipeline-C-cN0ACi.d.cts → types-CpqL-pZx.d.cts} +2 -7
- package/package.json +36 -17
- package/dist/model-form-Bm_kqCn2.d.ts +0 -92
- package/dist/model-form-DkS48fsh.d.cts +0 -92
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { L as AthenaGatewayHookConfig, N as AthenaGatewayHookResult } from './types-
|
|
2
|
-
export { O as AthenaDeletePayload, P as AthenaFetchPayload,
|
|
3
|
-
|
|
1
|
+
import { L as AthenaGatewayHookConfig, N as AthenaGatewayHookResult } from './types-BaBzjwXr.cjs';
|
|
2
|
+
export { O as AthenaDeletePayload, P as AthenaFetchPayload, a as AthenaGatewayCallOptions, b as AthenaGatewayErrorCode, c as AthenaGatewayErrorDetails, Q as AthenaGatewayResponse, V as AthenaInsertPayload, d as AthenaJsonArray, e as AthenaJsonObject, f as AthenaJsonPrimitive, g as AthenaJsonValue, h as AthenaRpcCallOptions, i as AthenaRpcFilter, j as AthenaRpcFilterOperator, k as AthenaRpcOrder, l as AthenaRpcPayload, W as AthenaUpdatePayload } from './types-BaBzjwXr.cjs';
|
|
3
|
+
import { a7 as AthenaAuthFetchCompatibleInput, b as AthenaAuthCallOptions, y as AthenaAuthSessionResponse, h as AthenaAuthErrorDetails, u as AthenaAuthResult } from './model-form-Cy-zaO0u.cjs';
|
|
4
|
+
export { O as AthenaGatewayError, Z as ModelFormAdapter, _ as ModelFormDefaults, $ as ModelFormNullishMode, a0 as ModelFormValues, a1 as ToModelFormDefaultsOptions, a2 as ToModelPayloadOptions, a3 as createModelFormAdapter, a4 as isAthenaGatewayError, a5 as toModelFormDefaults, a6 as toModelPayload } from './model-form-Cy-zaO0u.cjs';
|
|
4
5
|
import * as react from 'react';
|
|
5
6
|
import { ReactNode } from 'react';
|
|
6
7
|
|
|
@@ -235,4 +236,37 @@ declare function useQuery<TQueryFnData, TData = TQueryFnData>(options: UseQueryO
|
|
|
235
236
|
|
|
236
237
|
declare function useMutation<TVariables, TMutationFnData, TData = TMutationFnData>(options: UseMutationOptions<TVariables, TMutationFnData, TData>): UseMutationResult<TVariables, TData>;
|
|
237
238
|
|
|
238
|
-
|
|
239
|
+
interface UseSessionOptions {
|
|
240
|
+
enabled?: boolean;
|
|
241
|
+
refetchOnMount?: boolean;
|
|
242
|
+
fetchInput?: AthenaAuthFetchCompatibleInput;
|
|
243
|
+
callOptions?: AthenaAuthCallOptions;
|
|
244
|
+
}
|
|
245
|
+
interface UseSessionResult<TSessionData extends AthenaAuthSessionResponse = AthenaAuthSessionResponse> {
|
|
246
|
+
data: TSessionData | null;
|
|
247
|
+
error: AthenaAuthErrorDetails | null;
|
|
248
|
+
isPending: boolean;
|
|
249
|
+
isRefetching: boolean;
|
|
250
|
+
refetch: () => Promise<TSessionData | null>;
|
|
251
|
+
}
|
|
252
|
+
type SessionGetter<TSessionData extends AthenaAuthSessionResponse> = (input?: AthenaAuthFetchCompatibleInput, options?: AthenaAuthCallOptions) => Promise<AthenaAuthResult<TSessionData>>;
|
|
253
|
+
type UseSessionAuthClient<TSessionData extends AthenaAuthSessionResponse = AthenaAuthSessionResponse> = {
|
|
254
|
+
getSession: SessionGetter<TSessionData>;
|
|
255
|
+
} | {
|
|
256
|
+
auth: {
|
|
257
|
+
getSession: SessionGetter<TSessionData>;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
type InferSessionData<TClient> = TClient extends {
|
|
261
|
+
getSession: (...args: unknown[]) => Promise<AthenaAuthResult<infer TSessionData>>;
|
|
262
|
+
} ? TSessionData extends AthenaAuthSessionResponse ? TSessionData : AthenaAuthSessionResponse : TClient extends {
|
|
263
|
+
auth: {
|
|
264
|
+
getSession: (...args: unknown[]) => Promise<AthenaAuthResult<infer TSessionData>>;
|
|
265
|
+
};
|
|
266
|
+
} ? TSessionData extends AthenaAuthSessionResponse ? TSessionData : AthenaAuthSessionResponse : AthenaAuthSessionResponse;
|
|
267
|
+
/**
|
|
268
|
+
* Better Auth style session hook parity for Athena auth clients.
|
|
269
|
+
*/
|
|
270
|
+
declare function useSession<TClient extends UseSessionAuthClient>(authClient: TClient, options?: UseSessionOptions): UseSessionResult<InferSessionData<TClient>>;
|
|
271
|
+
|
|
272
|
+
export { type AthenaCacheMode, type AthenaCachePolicy, AthenaGatewayHookConfig, AthenaGatewayHookResult, type AthenaMutationDefaults, type AthenaMutationEvent, type AthenaMutationRequestLog, type AthenaMutationResultData, type AthenaMutationState, AthenaQueryClient, type AthenaQueryClientConfig, AthenaQueryClientProvider, type AthenaQueryDefaults, type AthenaQueryError, type AthenaQueryEvent, type AthenaQueryRequestLog, type AthenaQueryResult, type AthenaQueryState, type AthenaResponseLike, type AthenaRetryCount, type AthenaRetryDelay, type AthenaRuntimeBaseEvent, type AthenaRuntimeEvent, type AthenaRuntimeEventType, type AthenaStateAdapter, type AthenaUnsubscribe, type QueryKey, type QueryStatus, type UseMutationOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult, type UseSessionOptions, type UseSessionResult, attachStateAdapter, createAthenaQueryClient, useAthenaGateway, useAthenaQueryClient, useMutation, useQuery, useSession };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { L as AthenaGatewayHookConfig, N as AthenaGatewayHookResult } from './types-
|
|
2
|
-
export { O as AthenaDeletePayload, P as AthenaFetchPayload,
|
|
3
|
-
|
|
1
|
+
import { L as AthenaGatewayHookConfig, N as AthenaGatewayHookResult } from './types-BaBzjwXr.js';
|
|
2
|
+
export { O as AthenaDeletePayload, P as AthenaFetchPayload, a as AthenaGatewayCallOptions, b as AthenaGatewayErrorCode, c as AthenaGatewayErrorDetails, Q as AthenaGatewayResponse, V as AthenaInsertPayload, d as AthenaJsonArray, e as AthenaJsonObject, f as AthenaJsonPrimitive, g as AthenaJsonValue, h as AthenaRpcCallOptions, i as AthenaRpcFilter, j as AthenaRpcFilterOperator, k as AthenaRpcOrder, l as AthenaRpcPayload, W as AthenaUpdatePayload } from './types-BaBzjwXr.js';
|
|
3
|
+
import { a7 as AthenaAuthFetchCompatibleInput, b as AthenaAuthCallOptions, y as AthenaAuthSessionResponse, h as AthenaAuthErrorDetails, u as AthenaAuthResult } from './model-form-2hqmoOUX.js';
|
|
4
|
+
export { O as AthenaGatewayError, Z as ModelFormAdapter, _ as ModelFormDefaults, $ as ModelFormNullishMode, a0 as ModelFormValues, a1 as ToModelFormDefaultsOptions, a2 as ToModelPayloadOptions, a3 as createModelFormAdapter, a4 as isAthenaGatewayError, a5 as toModelFormDefaults, a6 as toModelPayload } from './model-form-2hqmoOUX.js';
|
|
4
5
|
import * as react from 'react';
|
|
5
6
|
import { ReactNode } from 'react';
|
|
6
7
|
|
|
@@ -235,4 +236,37 @@ declare function useQuery<TQueryFnData, TData = TQueryFnData>(options: UseQueryO
|
|
|
235
236
|
|
|
236
237
|
declare function useMutation<TVariables, TMutationFnData, TData = TMutationFnData>(options: UseMutationOptions<TVariables, TMutationFnData, TData>): UseMutationResult<TVariables, TData>;
|
|
237
238
|
|
|
238
|
-
|
|
239
|
+
interface UseSessionOptions {
|
|
240
|
+
enabled?: boolean;
|
|
241
|
+
refetchOnMount?: boolean;
|
|
242
|
+
fetchInput?: AthenaAuthFetchCompatibleInput;
|
|
243
|
+
callOptions?: AthenaAuthCallOptions;
|
|
244
|
+
}
|
|
245
|
+
interface UseSessionResult<TSessionData extends AthenaAuthSessionResponse = AthenaAuthSessionResponse> {
|
|
246
|
+
data: TSessionData | null;
|
|
247
|
+
error: AthenaAuthErrorDetails | null;
|
|
248
|
+
isPending: boolean;
|
|
249
|
+
isRefetching: boolean;
|
|
250
|
+
refetch: () => Promise<TSessionData | null>;
|
|
251
|
+
}
|
|
252
|
+
type SessionGetter<TSessionData extends AthenaAuthSessionResponse> = (input?: AthenaAuthFetchCompatibleInput, options?: AthenaAuthCallOptions) => Promise<AthenaAuthResult<TSessionData>>;
|
|
253
|
+
type UseSessionAuthClient<TSessionData extends AthenaAuthSessionResponse = AthenaAuthSessionResponse> = {
|
|
254
|
+
getSession: SessionGetter<TSessionData>;
|
|
255
|
+
} | {
|
|
256
|
+
auth: {
|
|
257
|
+
getSession: SessionGetter<TSessionData>;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
type InferSessionData<TClient> = TClient extends {
|
|
261
|
+
getSession: (...args: unknown[]) => Promise<AthenaAuthResult<infer TSessionData>>;
|
|
262
|
+
} ? TSessionData extends AthenaAuthSessionResponse ? TSessionData : AthenaAuthSessionResponse : TClient extends {
|
|
263
|
+
auth: {
|
|
264
|
+
getSession: (...args: unknown[]) => Promise<AthenaAuthResult<infer TSessionData>>;
|
|
265
|
+
};
|
|
266
|
+
} ? TSessionData extends AthenaAuthSessionResponse ? TSessionData : AthenaAuthSessionResponse : AthenaAuthSessionResponse;
|
|
267
|
+
/**
|
|
268
|
+
* Better Auth style session hook parity for Athena auth clients.
|
|
269
|
+
*/
|
|
270
|
+
declare function useSession<TClient extends UseSessionAuthClient>(authClient: TClient, options?: UseSessionOptions): UseSessionResult<InferSessionData<TClient>>;
|
|
271
|
+
|
|
272
|
+
export { type AthenaCacheMode, type AthenaCachePolicy, AthenaGatewayHookConfig, AthenaGatewayHookResult, type AthenaMutationDefaults, type AthenaMutationEvent, type AthenaMutationRequestLog, type AthenaMutationResultData, type AthenaMutationState, AthenaQueryClient, type AthenaQueryClientConfig, AthenaQueryClientProvider, type AthenaQueryDefaults, type AthenaQueryError, type AthenaQueryEvent, type AthenaQueryRequestLog, type AthenaQueryResult, type AthenaQueryState, type AthenaResponseLike, type AthenaRetryCount, type AthenaRetryDelay, type AthenaRuntimeBaseEvent, type AthenaRuntimeEvent, type AthenaRuntimeEventType, type AthenaStateAdapter, type AthenaUnsubscribe, type QueryKey, type QueryStatus, type UseMutationOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult, type UseSessionOptions, type UseSessionResult, attachStateAdapter, createAthenaQueryClient, useAthenaGateway, useAthenaQueryClient, useMutation, useQuery, useSession };
|
package/dist/react.js
CHANGED
|
@@ -1491,6 +1491,98 @@ function useMutation(options) {
|
|
|
1491
1491
|
lastRequest: snapshot.lastRequest
|
|
1492
1492
|
};
|
|
1493
1493
|
}
|
|
1494
|
+
function resolveGetSession(authClient) {
|
|
1495
|
+
if ("getSession" in authClient && typeof authClient.getSession === "function") {
|
|
1496
|
+
return authClient.getSession;
|
|
1497
|
+
}
|
|
1498
|
+
if ("auth" in authClient && authClient.auth && typeof authClient.auth.getSession === "function") {
|
|
1499
|
+
return authClient.auth.getSession;
|
|
1500
|
+
}
|
|
1501
|
+
throw new Error("useSession requires an auth-capable client (createClient(...).auth or createAuthClient(...))");
|
|
1502
|
+
}
|
|
1503
|
+
function useSession(authClient, options = {}) {
|
|
1504
|
+
const enabled = options.enabled ?? true;
|
|
1505
|
+
const refetchOnMount = options.refetchOnMount ?? true;
|
|
1506
|
+
const [data, setData] = useState(null);
|
|
1507
|
+
const [error, setError] = useState(null);
|
|
1508
|
+
const [isPending, setIsPending] = useState(enabled);
|
|
1509
|
+
const [isRefetching, setIsRefetching] = useState(false);
|
|
1510
|
+
const requestIdRef = useRef(0);
|
|
1511
|
+
const mountedRef = useRef(true);
|
|
1512
|
+
const dataRef = useRef(null);
|
|
1513
|
+
const getSession = resolveGetSession(
|
|
1514
|
+
authClient
|
|
1515
|
+
);
|
|
1516
|
+
useEffect(() => {
|
|
1517
|
+
dataRef.current = data;
|
|
1518
|
+
}, [data]);
|
|
1519
|
+
const toFallbackErrorDetails = (code, message, status) => ({
|
|
1520
|
+
code,
|
|
1521
|
+
message,
|
|
1522
|
+
status
|
|
1523
|
+
});
|
|
1524
|
+
const runFetch = useCallback(async () => {
|
|
1525
|
+
const requestId = ++requestIdRef.current;
|
|
1526
|
+
const hasData = dataRef.current !== null;
|
|
1527
|
+
if (hasData) {
|
|
1528
|
+
setIsRefetching(true);
|
|
1529
|
+
} else {
|
|
1530
|
+
setIsPending(true);
|
|
1531
|
+
}
|
|
1532
|
+
try {
|
|
1533
|
+
const result = await getSession(options.fetchInput, options.callOptions);
|
|
1534
|
+
if (!mountedRef.current || requestId !== requestIdRef.current) {
|
|
1535
|
+
return null;
|
|
1536
|
+
}
|
|
1537
|
+
if (result.ok) {
|
|
1538
|
+
setData(result.data ?? null);
|
|
1539
|
+
setError(null);
|
|
1540
|
+
return result.data ?? null;
|
|
1541
|
+
}
|
|
1542
|
+
setError(
|
|
1543
|
+
result.errorDetails ?? toFallbackErrorDetails(
|
|
1544
|
+
"UNKNOWN_ERROR",
|
|
1545
|
+
result.error ?? "Failed to fetch session",
|
|
1546
|
+
result.status
|
|
1547
|
+
)
|
|
1548
|
+
);
|
|
1549
|
+
return null;
|
|
1550
|
+
} catch (requestError) {
|
|
1551
|
+
if (!mountedRef.current || requestId !== requestIdRef.current) {
|
|
1552
|
+
return null;
|
|
1553
|
+
}
|
|
1554
|
+
const message = requestError instanceof Error ? requestError.message : "Failed to fetch session";
|
|
1555
|
+
setError(toFallbackErrorDetails("NETWORK_ERROR", message, 0));
|
|
1556
|
+
return null;
|
|
1557
|
+
} finally {
|
|
1558
|
+
if (mountedRef.current && requestId === requestIdRef.current) {
|
|
1559
|
+
setIsPending(false);
|
|
1560
|
+
setIsRefetching(false);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
}, [getSession, options.callOptions, options.fetchInput]);
|
|
1564
|
+
useEffect(() => {
|
|
1565
|
+
mountedRef.current = true;
|
|
1566
|
+
if (enabled && refetchOnMount) {
|
|
1567
|
+
void runFetch();
|
|
1568
|
+
} else {
|
|
1569
|
+
setIsPending(false);
|
|
1570
|
+
}
|
|
1571
|
+
return () => {
|
|
1572
|
+
mountedRef.current = false;
|
|
1573
|
+
};
|
|
1574
|
+
}, [enabled, refetchOnMount, runFetch]);
|
|
1575
|
+
const refetch = useCallback(async () => {
|
|
1576
|
+
return await runFetch();
|
|
1577
|
+
}, [runFetch]);
|
|
1578
|
+
return {
|
|
1579
|
+
data,
|
|
1580
|
+
error,
|
|
1581
|
+
isPending,
|
|
1582
|
+
isRefetching,
|
|
1583
|
+
refetch
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1494
1586
|
|
|
1495
1587
|
// src/schema/model-form.ts
|
|
1496
1588
|
function resolveNullishValue(mode) {
|
|
@@ -1553,6 +1645,6 @@ function createModelFormAdapter(model) {
|
|
|
1553
1645
|
};
|
|
1554
1646
|
}
|
|
1555
1647
|
|
|
1556
|
-
export { AthenaGatewayError, AthenaQueryClient, AthenaQueryClientProvider, attachStateAdapter, createAthenaQueryClient, createModelFormAdapter, isAthenaGatewayError, toModelFormDefaults, toModelPayload, useAthenaGateway, useAthenaQueryClient, useMutation, useQuery };
|
|
1648
|
+
export { AthenaGatewayError, AthenaQueryClient, AthenaQueryClientProvider, attachStateAdapter, createAthenaQueryClient, createModelFormAdapter, isAthenaGatewayError, toModelFormDefaults, toModelPayload, useAthenaGateway, useAthenaQueryClient, useMutation, useQuery, useSession };
|
|
1557
1649
|
//# sourceMappingURL=react.js.map
|
|
1558
1650
|
//# sourceMappingURL=react.js.map
|