@keboola/api-client-react 25.0.0 → 31.0.0

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/dist/index.js CHANGED
@@ -1,126 +1,160 @@
1
- import { createContext, use, useState, useRef, useEffect } from 'react';
2
- import { jsx } from 'react/jsx-runtime';
3
-
4
- // src/context.ts
5
- var MISSING_API_CLIENT_ERROR = "useApiClient must be used within <ApiClientProvider />";
6
- var MISSING_PROJECT_ERROR = "useProject must be used within <ApiClientProvider />";
7
- var MISSING_STACK_ERROR = "useStack must be used within <ApiClientProvider />";
8
- var MISSING_AUTH_ERROR = "useAuth must be used within <AuthProvider />";
9
- var MISSING_LEGACY_AUTH_ERROR = "useLegacyAuth must be used within <LegacyAuthProvider />";
10
- var ApiContext = createContext(null);
11
- var ApiProvider = ApiContext;
12
- var AuthContext = createContext(null);
13
- var AuthContextProvider = AuthContext;
14
- var LegacyAuthContext = createContext(null);
15
- var LegacyAuthContextProvider = LegacyAuthContext;
16
- var useApiClient = () => {
17
- const api = use(ApiContext);
18
- if (api === null) throw new Error(MISSING_API_CLIENT_ERROR);
19
- return api;
1
+ import { createContext, use, useEffect, useRef, useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/context.ts
4
+ const MISSING_API_CLIENT_ERROR = "useApiClient must be used within <ApiClientProvider />";
5
+ const MISSING_PROJECT_ERROR = "useProject must be used within <ApiClientProvider />";
6
+ const MISSING_STACK_ERROR = "useStack must be used within <ApiClientProvider />";
7
+ const MISSING_AUTH_ERROR = "useAuth must be used within <AuthProvider />";
8
+ const MISSING_LEGACY_AUTH_ERROR = "useLegacyAuth must be used within <LegacyAuthProvider />";
9
+ const ApiContext = createContext(null);
10
+ const ApiProvider = ApiContext;
11
+ const AuthContext = createContext(null);
12
+ const AuthContextProvider = AuthContext;
13
+ const LegacyAuthContext = createContext(null);
14
+ const LegacyAuthContextProvider = LegacyAuthContext;
15
+ const useApiClient = () => {
16
+ const api = use(ApiContext);
17
+ if (api === null) throw new Error(MISSING_API_CLIENT_ERROR);
18
+ return api;
20
19
  };
21
- var useProject = () => {
22
- const api = use(ApiContext);
23
- if (api === null) throw new Error(MISSING_PROJECT_ERROR);
24
- return api.context.project;
20
+ const useProject = () => {
21
+ const api = use(ApiContext);
22
+ if (api === null) throw new Error(MISSING_PROJECT_ERROR);
23
+ return api.context.project;
25
24
  };
26
- var useStack = () => {
27
- const api = use(ApiContext);
28
- if (api === null) throw new Error(MISSING_STACK_ERROR);
29
- return api.context.stack;
25
+ const useStack = () => {
26
+ const api = use(ApiContext);
27
+ if (api === null) throw new Error(MISSING_STACK_ERROR);
28
+ return api.context.stack;
30
29
  };
31
- var useAuth = () => {
32
- const session = use(AuthContext);
33
- if (session === null) throw new Error(MISSING_AUTH_ERROR);
34
- return session;
30
+ /** The bearer (OAuth) lifecycle session. Throws outside `<AuthProvider />`. */
31
+ const useAuth = () => {
32
+ const session = use(AuthContext);
33
+ if (session === null) throw new Error(MISSING_AUTH_ERROR);
34
+ return session;
35
35
  };
36
- var useLegacyAuth = () => {
37
- const session = use(LegacyAuthContext);
38
- if (session === null) throw new Error(MISSING_LEGACY_AUTH_ERROR);
39
- return session;
36
+ /** The legacy (SAPI) lifecycle session. Throws outside `<LegacyAuthProvider />`. */
37
+ const useLegacyAuth = () => {
38
+ const session = use(LegacyAuthContext);
39
+ if (session === null) throw new Error(MISSING_LEGACY_AUTH_ERROR);
40
+ return session;
40
41
  };
41
- var ApiClientProvider = ({ api, children }) => /* @__PURE__ */ jsx(ApiProvider, { value: api, children });
42
- var AuthProvider = ({
43
- session,
44
- baseUrl,
45
- credential,
46
- projectId,
47
- onAccessTokenChange,
48
- loadingFallback = null,
49
- errorFallback = null,
50
- anonymousFallback = null,
51
- children
52
- }) => {
53
- const [snapshot, setSnapshot] = useState(() => session.debug());
54
- const [isRestoring, setIsRestoring] = useState(() => session.hasPersistedValue());
55
- const [restoreStatus, setRestoreStatus] = useState(null);
56
- const restoreStartedRef = useRef(false);
57
- useEffect(() => session.subscribe(setSnapshot), [session]);
58
- useEffect(() => {
59
- if (baseUrl === void 0) return;
60
- if (snapshot.config.baseUrl !== null) return;
61
- session.setBaseUrl(baseUrl);
62
- }, [session, baseUrl, snapshot.config.baseUrl]);
63
- useEffect(() => {
64
- if (restoreStartedRef.current) return;
65
- restoreStartedRef.current = true;
66
- session.restore().then((result) => setRestoreStatus(result.status)).catch((error) => {
67
- console.error("Keboola bearer session restore failed", error);
68
- setRestoreStatus("empty");
69
- }).finally(() => setIsRestoring(false));
70
- }, [session]);
71
- useEffect(() => {
72
- if (restoreStatus === null || restoreStatus === "restored") return;
73
- if (credential === void 0) return;
74
- if (snapshot.config.status !== "anonymous") return;
75
- session.authenticate(credential);
76
- }, [session, restoreStatus, credential, snapshot.config.status]);
77
- useEffect(() => {
78
- if (restoreStatus === null || restoreStatus === "restored") return;
79
- if (projectId === void 0) return;
80
- if (snapshot.config.status !== "authenticated") return;
81
- session.setProject(projectId);
82
- }, [session, restoreStatus, projectId, snapshot.config.status]);
83
- const accessToken = snapshot.config.status === "anonymous" ? void 0 : snapshot.config.credential.accessToken;
84
- useEffect(() => {
85
- if (accessToken !== void 0) onAccessTokenChange?.(accessToken);
86
- }, [accessToken, onAccessTokenChange]);
87
- const isProgrammatic = credential !== void 0 && projectId !== void 0;
88
- const content = (() => {
89
- if (snapshot.storage === "ready") {
90
- if (typeof children !== "function") return children;
91
- if (snapshot.config.status !== "scoped") return null;
92
- const { projectId: scopedProjectId, baseUrl: scopedBaseUrl } = snapshot.config;
93
- return children({ projectId: scopedProjectId, baseUrl: scopedBaseUrl });
94
- }
95
- if (snapshot.storage === "errored") return errorFallback;
96
- if (isRestoring || snapshot.storage === "pending" || isProgrammatic) return loadingFallback;
97
- return anonymousFallback;
98
- })();
99
- return /* @__PURE__ */ jsx(AuthContextProvider, { value: session, children: content });
42
+ //#endregion
43
+ //#region src/ApiClientProvider.tsx
44
+ /**
45
+ * Provides the product API to `useApiClient()`. A pure pass-through: the auth lifecycle (driving
46
+ * to ready, gating on a fallback) belongs to `AuthProvider` / `LegacyAuthProvider`, which mount
47
+ * this provider once their session is ready.
48
+ */
49
+ const ApiClientProvider = ({ api, children }) => /* @__PURE__ */ jsx(ApiProvider, {
50
+ value: api,
51
+ children
52
+ });
53
+ //#endregion
54
+ //#region src/AuthProvider.tsx
55
+ const AuthProvider = ({ session, baseUrl, credential, projectId, onAccessTokenChange, loadingFallback = null, errorFallback = null, anonymousFallback = null, children }) => {
56
+ const [snapshot, setSnapshot] = useState(() => session.debug());
57
+ const [isRestoring, setIsRestoring] = useState(() => session.hasPersistedValue());
58
+ const [restoreStatus, setRestoreStatus] = useState(null);
59
+ const restoreStartedRef = useRef(false);
60
+ useEffect(() => session.subscribe(setSnapshot), [session]);
61
+ useEffect(() => {
62
+ if (baseUrl === void 0) return;
63
+ if (snapshot.config.baseUrl !== null) return;
64
+ session.setBaseUrl(baseUrl);
65
+ }, [
66
+ session,
67
+ baseUrl,
68
+ snapshot.config.baseUrl
69
+ ]);
70
+ useEffect(() => {
71
+ if (restoreStartedRef.current) return;
72
+ restoreStartedRef.current = true;
73
+ session.restore().then((result) => setRestoreStatus(result.status)).catch((error) => {
74
+ console.error("Keboola bearer session restore failed", error);
75
+ setRestoreStatus("empty");
76
+ }).finally(() => setIsRestoring(false));
77
+ }, [session]);
78
+ useEffect(() => {
79
+ if (restoreStatus === null || restoreStatus === "restored") return;
80
+ if (credential === void 0) return;
81
+ if (snapshot.config.status !== "anonymous") return;
82
+ session.authenticate(credential);
83
+ }, [
84
+ session,
85
+ restoreStatus,
86
+ credential,
87
+ snapshot.config.status
88
+ ]);
89
+ useEffect(() => {
90
+ if (restoreStatus === null || restoreStatus === "restored") return;
91
+ if (projectId === void 0) return;
92
+ if (snapshot.config.status !== "authenticated") return;
93
+ session.setProject(projectId);
94
+ }, [
95
+ session,
96
+ restoreStatus,
97
+ projectId,
98
+ snapshot.config.status
99
+ ]);
100
+ const accessToken = snapshot.config.status === "anonymous" ? void 0 : snapshot.config.credential.accessToken;
101
+ useEffect(() => {
102
+ if (accessToken !== void 0) onAccessTokenChange?.(accessToken);
103
+ }, [accessToken, onAccessTokenChange]);
104
+ const isProgrammatic = credential !== void 0 && projectId !== void 0;
105
+ const content = (() => {
106
+ if (snapshot.storage === "ready") {
107
+ if (typeof children !== "function") return children;
108
+ if (snapshot.config.status !== "scoped") return null;
109
+ const { projectId: scopedProjectId, baseUrl: scopedBaseUrl } = snapshot.config;
110
+ return children({
111
+ projectId: scopedProjectId,
112
+ baseUrl: scopedBaseUrl
113
+ });
114
+ }
115
+ if (snapshot.storage === "errored") return errorFallback;
116
+ if (isRestoring || snapshot.storage === "pending" || isProgrammatic) return loadingFallback;
117
+ return anonymousFallback;
118
+ })();
119
+ return /* @__PURE__ */ jsx(AuthContextProvider, {
120
+ value: session,
121
+ children: content
122
+ });
100
123
  };
101
- var LegacyAuthProvider = ({
102
- session,
103
- baseUrl,
104
- storageToken,
105
- managementToken,
106
- fallback = null,
107
- children
108
- }) => {
109
- const [isReady, setIsReady] = useState(() => session.isStorageReady());
110
- const startedRef = useRef(false);
111
- useEffect(() => {
112
- const unsubscribe = session.subscribe(() => setIsReady(session.isStorageReady()));
113
- if (!startedRef.current) {
114
- startedRef.current = true;
115
- session.setBaseUrl(baseUrl);
116
- if (managementToken) session.authenticateManagement(managementToken);
117
- void session.authenticateStorageAsync(storageToken).catch((error) => console.error("Keboola session bootstrap failed", error));
118
- }
119
- return unsubscribe;
120
- }, []);
121
- return /* @__PURE__ */ jsx(LegacyAuthContextProvider, { value: session, children: isReady ? children : fallback });
124
+ //#endregion
125
+ //#region src/LegacyAuthProvider.tsx
126
+ /**
127
+ * Owns the legacy (SAPI) lifecycle: on mount it configures the stack and drives the session to
128
+ * ready, rendering `fallback` until the storage build resolves. The backend-injected SAPI token is
129
+ * known up front, so this drives itself (unlike the interactive bearer `AuthProvider`). Exposes the
130
+ * session via `useLegacyAuth()` and gates `children` behind readiness.
131
+ */
132
+ const LegacyAuthProvider = ({ session, baseUrl, storageToken, managementToken, fallback = null, errorFallback = fallback, children }) => {
133
+ const [storageState, setStorageState] = useState(() => session.debug().storage);
134
+ const startedRef = useRef(false);
135
+ useEffect(() => {
136
+ const unsubscribe = session.subscribe((snapshot) => setStorageState(snapshot.storage));
137
+ if (!startedRef.current) {
138
+ startedRef.current = true;
139
+ session.setBaseUrl(baseUrl);
140
+ if (managementToken) session.authenticateManagement(managementToken);
141
+ session.authenticateStorageAsync(storageToken).catch((error) => console.error("Keboola session bootstrap failed", error));
142
+ }
143
+ return unsubscribe;
144
+ }, []);
145
+ useEffect(() => {
146
+ if (storageState === "errored") console.error("Keboola session bootstrap failed: the storage build errored.");
147
+ }, [storageState]);
148
+ return /* @__PURE__ */ jsx(LegacyAuthContextProvider, {
149
+ value: session,
150
+ children: (() => {
151
+ if (storageState === "ready") return children;
152
+ if (storageState === "errored") return errorFallback;
153
+ return fallback;
154
+ })()
155
+ });
122
156
  };
123
-
157
+ //#endregion
124
158
  export { ApiClientProvider, AuthProvider, LegacyAuthProvider, useApiClient, useAuth, useLegacyAuth, useProject, useStack };
125
- //# sourceMappingURL=index.js.map
159
+
126
160
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context.ts","../src/ApiClientProvider.tsx","../src/AuthProvider.tsx","../src/LegacyAuthProvider.tsx"],"names":["jsx","useState","useRef","useEffect"],"mappings":";;;;AAIA,IAAM,wBAAA,GAA2B,wDAAA;AACjC,IAAM,qBAAA,GAAwB,sDAAA;AAC9B,IAAM,mBAAA,GAAsB,oDAAA;AAC5B,IAAM,kBAAA,GAAqB,8CAAA;AAC3B,IAAM,yBAAA,GAA4B,0DAAA;AAIlC,IAAM,UAAA,GAAa,cAAiC,IAAI,CAAA;AACjD,IAAM,WAAA,GAAc,UAAA;AAI3B,IAAM,WAAA,GAAc,cAAoC,IAAI,CAAA;AACrD,IAAM,mBAAA,G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B,eAAe,CAAA;AAGnE,MAAA,KAAK,OAAA,CACF,wBAAA,CAAyB,YAAY,CAAA,CACrC,KAAA,CAAM,CAAC,KAAA,KAAU,OAAA,CAAQ,KAAA,CAAM,kCAAA,EAAoC,KAAK,CAAC,CAAA;AAAA,IAC9E;AAEA,IAAA,OAAO,WAAA;AAAA,EAGT,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACEH,GAAAA,CAAC,yBAAA,EAAA,EAA0B,OAAO,OAAA,EAC/B,QAAA,EAAA,OAAA,GAAU,WAAW,QAAA,EACxB,CAAA;AAEJ","file":"index.js","sourcesContent":["import { createContext, use } from 'react';\n\nimport type { BearerSession, KeboolaApi, LegacySession } from '@keboola/api-client';\n\nconst MISSING_API_CLIENT_ERROR = 'useApiClient must be used within <ApiClientProvider />';\nconst MISSING_PROJECT_ERROR = 'useProject must be used within <ApiClientProvider />';\nconst MISSING_STACK_ERROR = 'useStack must be used within <ApiClientProvider />';\nconst MISSING_AUTH_ERROR = 'useAuth must be used within <AuthProvider />';\nconst MISSING_LEGACY_AUTH_ERROR = 'useLegacyAuth must be used within <LegacyAuthProvider />';\n\n// The product API (`auth` + `management` + every product namespace), flow-agnostic. Both the\n// bearer and legacy flows produce the same `KeboolaApi` surface, so consumers never branch on flow.\nconst ApiContext = createContext<KeboolaApi | null>(null);\nexport const ApiProvider = ApiContext;\n\n// The lifecycle sessions live in their own, flow-specific contexts so the auth surface a component\n// reaches for is explicit. Only the matching provider is mounted per flow.\nconst AuthContext = createContext<BearerSession | null>(null);\nexport const AuthContextProvider = AuthContext;\n\nconst LegacyAuthContext = createContext<LegacySession | null>(null);\nexport const LegacyAuthContextProvider = LegacyAuthContext;\n\nexport const useApiClient = () => {\n const api = use(ApiContext);\n if (api === null) throw new Error(MISSING_API_CLIENT_ERROR);\n return api;\n};\n\nexport const useProject = () => {\n const api = use(ApiContext);\n if (api === null) throw new Error(MISSING_PROJECT_ERROR);\n return api.context.project;\n};\n\nexport const useStack = () => {\n const api = use(ApiContext);\n if (api === null) throw new Error(MISSING_STACK_ERROR);\n return api.context.stack;\n};\n\n/** The bearer (OAuth) lifecycle session. Throws outside `<AuthProvider />`. */\nexport const useAuth = () => {\n const session = use(AuthContext);\n if (session === null) throw new Error(MISSING_AUTH_ERROR);\n return session;\n};\n\n/** The legacy (SAPI) lifecycle session. Throws outside `<LegacyAuthProvider />`. */\nexport const useLegacyAuth = () => {\n const session = use(LegacyAuthContext);\n if (session === null) throw new Error(MISSING_LEGACY_AUTH_ERROR);\n return session;\n};\n","import type { ReactNode } from 'react';\n\nimport type { KeboolaApi } from '@keboola/api-client';\n\nimport { ApiProvider } from './context';\n\ntype Props = {\n /** The flow-agnostic product API — the `api` half of a keboola client. */\n api: KeboolaApi;\n children: ReactNode;\n};\n\n/**\n * Provides the product API to `useApiClient()`. A pure pass-through: the auth lifecycle (driving\n * to ready, gating on a fallback) belongs to `AuthProvider` / `LegacyAuthProvider`, which mount\n * this provider once their session is ready.\n */\nexport const ApiClientProvider = ({ api, children }: Props) => (\n <ApiProvider value={api}>{children}</ApiProvider>\n);\n","import { useEffect, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\n\nimport type { BearerSession } from '@keboola/api-client';\n\nimport { AuthContextProvider } from './context';\n\ntype BearerCredential = Parameters<BearerSession['authenticate']>[0];\ntype Snapshot = ReturnType<BearerSession['debug']>;\ntype RestoreStatus = Awaited<ReturnType<BearerSession['restore']>>['status'];\n\n/** The session state guaranteed to exist once the storage build is ready. */\ntype ScopedState = { projectId: number; baseUrl: string };\n\ntype BaseProps = {\n session: BearerSession;\n onAccessTokenChange?: (accessToken: string) => void;\n /** Rendered while a persisted session is being restored, or the bootstrap is in flight. */\n loadingFallback?: ReactNode;\n /** Rendered when the storage build fails. */\n errorFallback?: ReactNode;\n /**\n * Rendered only once the session is scoped and the storage build is ready. Pass a function to\n * receive the scoped state (the project the session settled on) without re-narrowing it yourself.\n */\n children: ReactNode | ((scoped: ScopedState) => ReactNode);\n};\n\n/**\n * Two mutually exclusive bootstrap modes, discriminated by whether a credential is supplied:\n * - **programmatic** — `credential` + `projectId` given, so `baseUrl` is **required**: a credential\n * is bound to the stack that issued it and `authenticate` refuses an unconfigured session.\n * - **interactive** — none of the three given; the stack comes from the session instead — `restore()`\n * adopts the persisted one, otherwise the login UI sets it. `anonymousFallback` is **required**\n * here (a missing login UI would leave the app on a permanently blank screen).\n */\ntype Props = BaseProps &\n (\n | {\n credential: BearerCredential;\n projectId: number;\n baseUrl: string;\n anonymousFallback?: never;\n }\n | {\n credential?: undefined;\n projectId?: undefined;\n baseUrl?: never;\n anonymousFallback: ReactNode;\n }\n );\n\nexport const AuthProvider = ({\n session,\n baseUrl,\n credential,\n projectId,\n onAccessTokenChange,\n loadingFallback = null,\n errorFallback = null,\n anonymousFallback = null,\n children,\n}: Props) => {\n const [snapshot, setSnapshot] = useState<Snapshot>(() => session.debug());\n const [isRestoring, setIsRestoring] = useState(() => session.hasPersistedValue());\n const [restoreStatus, setRestoreStatus] = useState<RestoreStatus | null>(null);\n const restoreStartedRef = useRef(false);\n\n useEffect(() => session.subscribe(setSnapshot), [session]);\n\n // Programmatic only. Interactive leaves the stack unset: `restore()` adopts the persisted one, and\n // failing that the login UI picks it — so there is nothing to configure up front.\n useEffect(() => {\n if (baseUrl === undefined) return;\n if (snapshot.config.baseUrl !== null) return;\n session.setBaseUrl(baseUrl);\n }, [session, baseUrl, snapshot.config.baseUrl]);\n\n // Runs regardless of whether a stack is configured — with none, `restore()` adopts the stack the\n // persisted session belongs to. (Declared after the effect above, so programmatic mode has already\n // configured its stack by the time this runs.) The ref guards StrictMode's double-invoked effect:\n // `restoreStatus` only lands asynchronously, so it cannot prevent a second synchronous call.\n useEffect(() => {\n if (restoreStartedRef.current) return;\n restoreStartedRef.current = true;\n session\n .restore()\n .then((result) => setRestoreStatus(result.status))\n .catch((error) => {\n console.error('Keboola bearer session restore failed', error);\n setRestoreStatus('empty');\n })\n .finally(() => setIsRestoring(false));\n }, [session]);\n\n useEffect(() => {\n if (restoreStatus === null || restoreStatus === 'restored') return;\n if (credential === undefined) return;\n if (snapshot.config.status !== 'anonymous') return;\n session.authenticate(credential);\n }, [session, restoreStatus, credential, snapshot.config.status]);\n\n useEffect(() => {\n if (restoreStatus === null || restoreStatus === 'restored') return;\n if (projectId === undefined) return;\n if (snapshot.config.status !== 'authenticated') return;\n session.setProject(projectId);\n }, [session, restoreStatus, projectId, snapshot.config.status]);\n\n const accessToken =\n snapshot.config.status === 'anonymous' ? undefined : snapshot.config.credential.accessToken;\n\n useEffect(() => {\n if (accessToken !== undefined) onAccessTokenChange?.(accessToken);\n }, [accessToken, onAccessTokenChange]);\n\n // Programmatic mode drives itself to ready, so it must never fall through to `anonymousFallback`.\n const isProgrammatic = credential !== undefined && projectId !== undefined;\n\n const content = (() => {\n if (snapshot.storage === 'ready') {\n if (typeof children !== 'function') return children;\n // A ready storage build implies a scoped session; narrowing here is for the type checker.\n if (snapshot.config.status !== 'scoped') return null;\n const { projectId: scopedProjectId, baseUrl: scopedBaseUrl } = snapshot.config;\n return children({ projectId: scopedProjectId, baseUrl: scopedBaseUrl });\n }\n if (snapshot.storage === 'errored') return errorFallback;\n if (isRestoring || snapshot.storage === 'pending' || isProgrammatic) return loadingFallback;\n return anonymousFallback;\n })();\n\n return <AuthContextProvider value={session}>{content}</AuthContextProvider>;\n};\n","import { useEffect, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\n\nimport type { LegacySession } from '@keboola/api-client';\n\nimport { LegacyAuthContextProvider } from './context';\n\ntype Props = {\n session: LegacySession;\n /** Stack base URL. */\n baseUrl: string;\n /** SAPI token — drives the storage build to ready. */\n storageToken: string;\n /** Optional manage-api token — unlocks `api.management`. */\n managementToken?: string;\n /** Rendered until the storage build reaches ready. */\n fallback?: ReactNode;\n children: ReactNode;\n};\n\n/**\n * Owns the legacy (SAPI) lifecycle: on mount it configures the stack and drives the session to\n * ready, rendering `fallback` until the storage build resolves. The backend-injected SAPI token is\n * known up front, so this drives itself (unlike the interactive bearer `AuthProvider`). Exposes the\n * session via `useLegacyAuth()` and gates `children` behind readiness.\n */\nexport const LegacyAuthProvider = ({\n session,\n baseUrl,\n storageToken,\n managementToken,\n fallback = null,\n children,\n}: Props) => {\n const [isReady, setIsReady] = useState<boolean>(() => session.isStorageReady());\n // Guards the once-only drive against React StrictMode's double-mounted effect.\n const startedRef = useRef<boolean>(false);\n\n useEffect(() => {\n const unsubscribe = session.subscribe(() => setIsReady(session.isStorageReady()));\n\n if (!startedRef.current) {\n startedRef.current = true;\n session.setBaseUrl(baseUrl);\n if (managementToken) session.authenticateManagement(managementToken);\n // Fire-and-forget: `subscribe` flips `isReady` once the build resolves. A failure leaves the\n // fallback in place; log it so the bootstrap error isn't silent.\n void session\n .authenticateStorageAsync(storageToken)\n .catch((error) => console.error('Keboola session bootstrap failed', error));\n }\n\n return unsubscribe;\n // drive to ready only on initial mount\n // oxlint-disable-next-line react/exhaustive-deps\n }, []);\n\n return (\n <LegacyAuthContextProvider value={session}>\n {isReady ? children : fallback}\n </LegacyAuthContextProvider>\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/context.ts","../src/ApiClientProvider.tsx","../src/AuthProvider.tsx","../src/LegacyAuthProvider.tsx"],"sourcesContent":["import { createContext, use } from 'react';\n\nimport type { BearerSession, KeboolaApi, LegacySession } from '@keboola/api-client';\n\nconst MISSING_API_CLIENT_ERROR = 'useApiClient must be used within <ApiClientProvider />';\nconst MISSING_PROJECT_ERROR = 'useProject must be used within <ApiClientProvider />';\nconst MISSING_STACK_ERROR = 'useStack must be used within <ApiClientProvider />';\nconst MISSING_AUTH_ERROR = 'useAuth must be used within <AuthProvider />';\nconst MISSING_LEGACY_AUTH_ERROR = 'useLegacyAuth must be used within <LegacyAuthProvider />';\n\n// The product API (`auth` + `management` + every product namespace), flow-agnostic. Both the\n// bearer and legacy flows produce the same `KeboolaApi` surface, so consumers never branch on flow.\nconst ApiContext = createContext<KeboolaApi | null>(null);\nexport const ApiProvider = ApiContext;\n\n// The lifecycle sessions live in their own, flow-specific contexts so the auth surface a component\n// reaches for is explicit. Only the matching provider is mounted per flow.\nconst AuthContext = createContext<BearerSession | null>(null);\nexport const AuthContextProvider = AuthContext;\n\nconst LegacyAuthContext = createContext<LegacySession | null>(null);\nexport const LegacyAuthContextProvider = LegacyAuthContext;\n\nexport const useApiClient = () => {\n const api = use(ApiContext);\n if (api === null) throw new Error(MISSING_API_CLIENT_ERROR);\n return api;\n};\n\nexport const useProject = () => {\n const api = use(ApiContext);\n if (api === null) throw new Error(MISSING_PROJECT_ERROR);\n return api.context.project;\n};\n\nexport const useStack = () => {\n const api = use(ApiContext);\n if (api === null) throw new Error(MISSING_STACK_ERROR);\n return api.context.stack;\n};\n\n/** The bearer (OAuth) lifecycle session. Throws outside `<AuthProvider />`. */\nexport const useAuth = () => {\n const session = use(AuthContext);\n if (session === null) throw new Error(MISSING_AUTH_ERROR);\n return session;\n};\n\n/** The legacy (SAPI) lifecycle session. Throws outside `<LegacyAuthProvider />`. */\nexport const useLegacyAuth = () => {\n const session = use(LegacyAuthContext);\n if (session === null) throw new Error(MISSING_LEGACY_AUTH_ERROR);\n return session;\n};\n","import type { ReactNode } from 'react';\n\nimport type { KeboolaApi } from '@keboola/api-client';\n\nimport { ApiProvider } from './context';\n\ntype Props = {\n /** The flow-agnostic product API — the `api` half of a keboola client. */\n api: KeboolaApi;\n children: ReactNode;\n};\n\n/**\n * Provides the product API to `useApiClient()`. A pure pass-through: the auth lifecycle (driving\n * to ready, gating on a fallback) belongs to `AuthProvider` / `LegacyAuthProvider`, which mount\n * this provider once their session is ready.\n */\nexport const ApiClientProvider = ({ api, children }: Props) => (\n <ApiProvider value={api}>{children}</ApiProvider>\n);\n","import { useEffect, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\n\nimport type { BearerSession } from '@keboola/api-client';\n\nimport { AuthContextProvider } from './context';\n\ntype BearerCredential = Parameters<BearerSession['authenticate']>[0];\ntype Snapshot = ReturnType<BearerSession['debug']>;\ntype RestoreStatus = Awaited<ReturnType<BearerSession['restore']>>['status'];\n\n/** The session state guaranteed to exist once the storage build is ready. */\ntype ScopedState = { projectId: number; baseUrl: string };\n\ntype BaseProps = {\n session: BearerSession;\n onAccessTokenChange?: (accessToken: string) => void;\n /** Rendered while a persisted session is being restored, or the bootstrap is in flight. */\n loadingFallback?: ReactNode;\n /** Rendered when the storage build fails. */\n errorFallback?: ReactNode;\n /**\n * Rendered only once the session is scoped and the storage build is ready. Pass a function to\n * receive the scoped state (the project the session settled on) without re-narrowing it yourself.\n */\n children: ReactNode | ((scoped: ScopedState) => ReactNode);\n};\n\n/**\n * Two mutually exclusive bootstrap modes, discriminated by whether a credential is supplied:\n * - **programmatic** — `credential` + `projectId` given, so `baseUrl` is **required**: a credential\n * is bound to the stack that issued it and `authenticate` refuses an unconfigured session.\n * - **interactive** — none of the three given; the stack comes from the session instead — `restore()`\n * adopts the persisted one, otherwise the login UI sets it. `anonymousFallback` is **required**\n * here (a missing login UI would leave the app on a permanently blank screen).\n */\ntype Props = BaseProps &\n (\n | {\n credential: BearerCredential;\n projectId: number;\n baseUrl: string;\n anonymousFallback?: never;\n }\n | {\n credential?: undefined;\n projectId?: undefined;\n baseUrl?: never;\n anonymousFallback: ReactNode;\n }\n );\n\nexport const AuthProvider = ({\n session,\n baseUrl,\n credential,\n projectId,\n onAccessTokenChange,\n loadingFallback = null,\n errorFallback = null,\n anonymousFallback = null,\n children,\n}: Props) => {\n const [snapshot, setSnapshot] = useState<Snapshot>(() => session.debug());\n const [isRestoring, setIsRestoring] = useState(() => session.hasPersistedValue());\n const [restoreStatus, setRestoreStatus] = useState<RestoreStatus | null>(null);\n const restoreStartedRef = useRef(false);\n\n useEffect(() => session.subscribe(setSnapshot), [session]);\n\n // Programmatic only. Interactive leaves the stack unset: `restore()` adopts the persisted one, and\n // failing that the login UI picks it — so there is nothing to configure up front.\n useEffect(() => {\n if (baseUrl === undefined) return;\n if (snapshot.config.baseUrl !== null) return;\n session.setBaseUrl(baseUrl);\n }, [session, baseUrl, snapshot.config.baseUrl]);\n\n // Runs regardless of whether a stack is configured — with none, `restore()` adopts the stack the\n // persisted session belongs to. (Declared after the effect above, so programmatic mode has already\n // configured its stack by the time this runs.) The ref guards StrictMode's double-invoked effect:\n // `restoreStatus` only lands asynchronously, so it cannot prevent a second synchronous call.\n useEffect(() => {\n if (restoreStartedRef.current) return;\n restoreStartedRef.current = true;\n session\n .restore()\n .then((result) => setRestoreStatus(result.status))\n .catch((error) => {\n console.error('Keboola bearer session restore failed', error);\n setRestoreStatus('empty');\n })\n .finally(() => setIsRestoring(false));\n }, [session]);\n\n useEffect(() => {\n if (restoreStatus === null || restoreStatus === 'restored') return;\n if (credential === undefined) return;\n if (snapshot.config.status !== 'anonymous') return;\n session.authenticate(credential);\n }, [session, restoreStatus, credential, snapshot.config.status]);\n\n useEffect(() => {\n if (restoreStatus === null || restoreStatus === 'restored') return;\n if (projectId === undefined) return;\n if (snapshot.config.status !== 'authenticated') return;\n session.setProject(projectId);\n }, [session, restoreStatus, projectId, snapshot.config.status]);\n\n const accessToken =\n snapshot.config.status === 'anonymous' ? undefined : snapshot.config.credential.accessToken;\n\n useEffect(() => {\n if (accessToken !== undefined) onAccessTokenChange?.(accessToken);\n }, [accessToken, onAccessTokenChange]);\n\n // Programmatic mode drives itself to ready, so it must never fall through to `anonymousFallback`.\n const isProgrammatic = credential !== undefined && projectId !== undefined;\n\n const content = (() => {\n if (snapshot.storage === 'ready') {\n if (typeof children !== 'function') return children;\n // A ready storage build implies a scoped session; narrowing here is for the type checker.\n if (snapshot.config.status !== 'scoped') return null;\n const { projectId: scopedProjectId, baseUrl: scopedBaseUrl } = snapshot.config;\n return children({ projectId: scopedProjectId, baseUrl: scopedBaseUrl });\n }\n if (snapshot.storage === 'errored') return errorFallback;\n if (isRestoring || snapshot.storage === 'pending' || isProgrammatic) return loadingFallback;\n return anonymousFallback;\n })();\n\n return <AuthContextProvider value={session}>{content}</AuthContextProvider>;\n};\n","import { useEffect, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\n\nimport type { LegacySession } from '@keboola/api-client';\n\nimport { LegacyAuthContextProvider } from './context';\n\ntype Props = {\n session: LegacySession;\n /** Stack base URL. */\n baseUrl: string;\n /** SAPI token — drives the storage build to ready. */\n storageToken: string;\n /** Optional manage-api token — unlocks `api.management`. */\n managementToken?: string;\n /** Rendered until the storage build reaches ready. */\n fallback?: ReactNode;\n /** Rendered when the storage build fails — e.g. the SAPI token is expired or revoked. */\n errorFallback?: ReactNode;\n children: ReactNode;\n};\n\n/**\n * Owns the legacy (SAPI) lifecycle: on mount it configures the stack and drives the session to\n * ready, rendering `fallback` until the storage build resolves. The backend-injected SAPI token is\n * known up front, so this drives itself (unlike the interactive bearer `AuthProvider`). Exposes the\n * session via `useLegacyAuth()` and gates `children` behind readiness.\n */\nexport const LegacyAuthProvider = ({\n session,\n baseUrl,\n storageToken,\n managementToken,\n fallback = null,\n errorFallback = fallback,\n children,\n}: Props) => {\n // The build state, not just readiness: `errored` and `pending` render differently.\n const [storageState, setStorageState] = useState(() => session.debug().storage);\n // Guards the once-only drive against React StrictMode's double-mounted effect.\n const startedRef = useRef<boolean>(false);\n\n useEffect(() => {\n const unsubscribe = session.subscribe((snapshot) => setStorageState(snapshot.storage));\n\n if (!startedRef.current) {\n startedRef.current = true;\n session.setBaseUrl(baseUrl);\n if (managementToken) session.authenticateManagement(managementToken);\n // Fire-and-forget: `subscribe` moves `storageState` once the build resolves. A failed build\n // resolves rather than rejects, so this catch only covers a synchronous throw.\n void session\n .authenticateStorageAsync(storageToken)\n .catch((error) => console.error('Keboola session bootstrap failed', error));\n }\n\n return unsubscribe;\n // drive to ready only on initial mount\n // oxlint-disable-next-line react/exhaustive-deps\n }, []);\n\n // The only place a failed build is observable — nothing rejects, so without this it is silent.\n useEffect(() => {\n if (storageState === 'errored') {\n console.error('Keboola session bootstrap failed: the storage build errored.');\n }\n }, [storageState]);\n\n const content = (() => {\n if (storageState === 'ready') return children;\n if (storageState === 'errored') return errorFallback;\n return fallback;\n })();\n\n return <LegacyAuthContextProvider value={session}>{content}</LegacyAuthContextProvider>;\n};\n"],"mappings":";;;AAIA,MAAM,2BAA2B;AACjC,MAAM,wBAAwB;AAC9B,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;AAIlC,MAAM,aAAa,cAAiC,IAAI;AACxD,MAAa,cAAc;AAI3B,MAAM,cAAc,cAAoC,IAAI;AAC5D,MAAa,sBAAsB;AAEnC,MAAM,oBAAoB,cAAoC,IAAI;AAClE,MAAa,4BAA4B;AAEzC,MAAa,qBAAqB;CAChC,MAAM,MAAM,IAAI,UAAU;CAC1B,IAAI,QAAQ,MAAM,MAAM,IAAI,MAAM,wBAAwB;CAC1D,OAAO;AACT;AAEA,MAAa,mBAAmB;CAC9B,MAAM,MAAM,IAAI,UAAU;CAC1B,IAAI,QAAQ,MAAM,MAAM,IAAI,MAAM,qBAAqB;CACvD,OAAO,IAAI,QAAQ;AACrB;AAEA,MAAa,iBAAiB;CAC5B,MAAM,MAAM,IAAI,UAAU;CAC1B,IAAI,QAAQ,MAAM,MAAM,IAAI,MAAM,mBAAmB;CACrD,OAAO,IAAI,QAAQ;AACrB;;AAGA,MAAa,gBAAgB;CAC3B,MAAM,UAAU,IAAI,WAAW;CAC/B,IAAI,YAAY,MAAM,MAAM,IAAI,MAAM,kBAAkB;CACxD,OAAO;AACT;;AAGA,MAAa,sBAAsB;CACjC,MAAM,UAAU,IAAI,iBAAiB;CACrC,IAAI,YAAY,MAAM,MAAM,IAAI,MAAM,yBAAyB;CAC/D,OAAO;AACT;;;;;;;;ACpCA,MAAa,qBAAqB,EAAE,KAAK,eACvC,oBAAC,aAAD;CAAa,OAAO;CAAM;AAAsB,CAAA;;;ACkClD,MAAa,gBAAgB,EAC3B,SACA,SACA,YACA,WACA,qBACA,kBAAkB,MAClB,gBAAgB,MAChB,oBAAoB,MACpB,eACW;CACX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SAAS,OAAO;GACrC,IAAI,iBAAiB,WAAW,OAAO;GACvC,OAAO;EACT,EAAA,CAEyD;CAA6B,CAAA;AACxF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keboola/api-client-react",
3
- "version": "25.0.0",
3
+ "version": "31.0.0",
4
4
  "description": "React bindings for @keboola/api-client",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,9 @@
9
9
  "types": "./dist/index.d.ts",
10
10
  "files": [
11
11
  "dist",
12
- "README.md"
12
+ "README.md",
13
+ "CHANGELOG.md",
14
+ "AGENTS.md"
13
15
  ],
14
16
  "publishConfig": {
15
17
  "access": "public"
@@ -49,7 +51,7 @@
49
51
  },
50
52
  "peerDependencies": {
51
53
  "react": "^19.0.0",
52
- "@keboola/api-client": "^25.0.0"
54
+ "@keboola/api-client": "^31.0.0"
53
55
  },
54
56
  "devDependencies": {
55
57
  "@arethetypeswrong/cli": "^0.18.2",
@@ -61,19 +63,18 @@
61
63
  "@types/react-dom": "^19.2.3",
62
64
  "@typescript/native": "npm:typescript@^7.0.2",
63
65
  "@vitejs/plugin-react": "^6.0.0",
64
- "esbuild": "^0.28.1",
65
66
  "jsdom": "^26.1.0",
66
67
  "msw": "^2.14.6",
67
68
  "oxfmt": "^0.57.0",
68
69
  "oxlint": "^1.72.0",
69
70
  "react-dom": "^19.2.7",
70
- "tsup": "^8.5.1",
71
+ "tsdown": "^0.22.14",
71
72
  "typescript": "npm:@typescript/typescript6@^6.0.2",
72
73
  "vite": "^8.1.5",
73
74
  "vitest": "^4.1.10",
74
- "@keboola/api-client": "^25.0.0",
75
- "@keboola/oxlint-config": "^8.1.0",
76
- "@keboola/tsconfig": "^0.2.0"
75
+ "@keboola/api-client": "^31.0.0",
76
+ "@keboola/oxlint-config": "^10.0.2",
77
+ "@keboola/tsconfig": "^0.2.1"
77
78
  },
78
79
  "scripts": {
79
80
  "type-check": "tsc",
@@ -84,8 +85,8 @@
84
85
  "lint:oxlint": "oxlint . --quiet",
85
86
  "lint:format": "oxfmt --check",
86
87
  "transit": "pnpm build",
87
- "build": "tsup",
88
- "build:check": "attw --pack .",
88
+ "build": "tsdown",
89
+ "build:check": "node ../../tooling/check-dist-exports.mjs && attw --pack .",
89
90
  "test": "vitest run --passWithNoTests --reporter=dot"
90
91
  }
91
92
  }