@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.d.cts CHANGED
@@ -1,177 +1,176 @@
1
- import * as _keboola_api_client_storage_types from '@keboola/api-client/storage/types';
2
- import * as _keboola_api_client from '@keboola/api-client';
3
- import { KeboolaApi, BearerSession, LegacySession } from '@keboola/api-client';
4
- import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import { ReactNode } from 'react';
6
-
1
+ import { BearerSession, KeboolaApi, LegacySession } from "@keboola/api-client";
2
+ import { ReactNode } from "react";
3
+ //#region src/context.d.ts
7
4
  declare const useApiClient: () => KeboolaApi;
8
5
  declare const useProject: () => {
9
- hasFeature: (...feature: string[]) => boolean;
10
- hasAdminFeature: (...feature: string[]) => boolean;
11
- hasBackend: (backend: _keboola_api_client_storage_types.Backend) => boolean;
12
- sapiToken: _keboola_api_client_storage_types.StorageToken;
6
+ hasFeature: (...feature: string[]) => boolean;
7
+ hasAdminFeature: (...feature: string[]) => boolean;
8
+ hasBackend: (backend: import("@keboola/api-client/storage/types").Backend) => boolean;
9
+ sapiToken: import("@keboola/api-client/storage/types").StorageToken;
13
10
  };
14
11
  declare const useStack: () => {
15
- services: _keboola_api_client_storage_types.Service[];
16
- features: string[];
17
- components: _keboola_api_client_storage_types.StackComponent[];
18
- hasFeature: (...feature: string[]) => boolean;
19
- getServiceUrl: (serviceId: _keboola_api_client_storage_types.ServiceId) => string | null;
20
- hasService: (serviceId: _keboola_api_client_storage_types.ServiceId) => boolean;
21
- getComponent: (componentId: string) => _keboola_api_client_storage_types.StackComponent | null;
22
- hasComponent: (...componentId: string[]) => boolean;
23
- api: string;
24
- documentation: string;
25
- host: string;
26
- revision: string;
27
- stack: string;
28
- urlTemplates: {
29
- orchestrationJob: string;
30
- };
31
- version: string;
12
+ api: string;
13
+ documentation: string;
14
+ host: string;
15
+ revision: string;
16
+ stack: string;
17
+ urlTemplates: {
18
+ orchestrationJob: string;
19
+ };
20
+ version: string;
21
+ services: import("@keboola/api-client/storage/types").Service[];
22
+ features: string[];
23
+ components: import("@keboola/api-client/storage/types").StackComponent[];
24
+ hasFeature: (...feature: string[]) => boolean;
25
+ getServiceUrl: (serviceId: import("@keboola/api-client/storage/types").ServiceId) => string | null;
26
+ hasService: (serviceId: import("@keboola/api-client/storage/types").ServiceId) => boolean;
27
+ getComponent: (componentId: string) => import("@keboola/api-client/storage/types").StackComponent | null;
28
+ hasComponent: (...componentId: string[]) => boolean;
32
29
  };
33
30
  /** The bearer (OAuth) lifecycle session. Throws outside `<AuthProvider />`. */
34
31
  declare const useAuth: () => {
35
- hasPersistedValue: () => boolean;
36
- setBaseUrl: (baseUrl: string) => void;
37
- isStorageReady: () => boolean;
38
- authenticate: (tokens: {
32
+ hasPersistedValue: () => boolean;
33
+ setBaseUrl: (baseUrl: string) => void;
34
+ isStorageReady: () => boolean;
35
+ authenticate: (tokens: {
36
+ accessToken: string;
37
+ refreshToken: string;
38
+ expiresIn: number;
39
+ }) => void;
40
+ setProject: (projectId: number) => void;
41
+ setProjectAsync: (projectId: number) => Promise<void>;
42
+ clearProject: () => void;
43
+ reset: () => void;
44
+ debugForceRefresh: () => void;
45
+ restore: () => Promise<{
46
+ status: 'empty' | 'restored' | 'expired';
47
+ }>;
48
+ subscribe: (listener: (snapshot: {
49
+ type: 'Bearer';
50
+ config: {
51
+ status: 'anonymous';
52
+ baseUrl: string | null;
53
+ } | {
54
+ status: 'authenticated';
55
+ baseUrl: string;
56
+ credential: {
57
+ accessToken: string;
58
+ refreshToken: string;
59
+ expiresIn: number;
60
+ } & {
61
+ issuedAt: number;
62
+ };
63
+ } | {
64
+ status: 'scoped';
65
+ baseUrl: string;
66
+ credential: {
67
+ accessToken: string;
68
+ refreshToken: string;
69
+ expiresIn: number;
70
+ } & {
71
+ issuedAt: number;
72
+ };
73
+ projectId: number;
74
+ };
75
+ authReady: boolean;
76
+ managementReady: boolean;
77
+ storage: import("@keboola/api-client").AsyncState<unknown>['state'];
78
+ }) => void) => () => void;
79
+ debug: () => {
80
+ type: 'Bearer';
81
+ config: {
82
+ status: 'anonymous';
83
+ baseUrl: string | null;
84
+ } | {
85
+ status: 'authenticated';
86
+ baseUrl: string;
87
+ credential: {
88
+ accessToken: string;
89
+ refreshToken: string;
90
+ expiresIn: number;
91
+ } & {
92
+ issuedAt: number;
93
+ };
94
+ } | {
95
+ status: 'scoped';
96
+ baseUrl: string;
97
+ credential: {
39
98
  accessToken: string;
40
99
  refreshToken: string;
41
100
  expiresIn: number;
42
- }) => void;
43
- setProject: (projectId: number) => void;
44
- setProjectAsync: (projectId: number) => Promise<void>;
45
- clearProject: () => void;
46
- reset: () => void;
47
- debugForceRefresh: () => void;
48
- restore: () => Promise<{
49
- status: "empty" | "restored" | "expired";
50
- }>;
51
- subscribe: (listener: (snapshot: {
52
- type: "Bearer";
53
- config: {
54
- status: "anonymous";
55
- baseUrl: string | null;
56
- } | {
57
- status: "authenticated";
58
- baseUrl: string;
59
- credential: {
60
- accessToken: string;
61
- refreshToken: string;
62
- expiresIn: number;
63
- } & {
64
- issuedAt: number;
65
- };
66
- } | {
67
- status: "scoped";
68
- baseUrl: string;
69
- credential: {
70
- accessToken: string;
71
- refreshToken: string;
72
- expiresIn: number;
73
- } & {
74
- issuedAt: number;
75
- };
76
- projectId: number;
77
- };
78
- authReady: boolean;
79
- managementReady: boolean;
80
- storage: _keboola_api_client.AsyncState<unknown>["state"];
81
- }) => void) => () => void;
82
- debug: () => {
83
- type: "Bearer";
84
- config: {
85
- status: "anonymous";
86
- baseUrl: string | null;
87
- } | {
88
- status: "authenticated";
89
- baseUrl: string;
90
- credential: {
91
- accessToken: string;
92
- refreshToken: string;
93
- expiresIn: number;
94
- } & {
95
- issuedAt: number;
96
- };
97
- } | {
98
- status: "scoped";
99
- baseUrl: string;
100
- credential: {
101
- accessToken: string;
102
- refreshToken: string;
103
- expiresIn: number;
104
- } & {
105
- issuedAt: number;
106
- };
107
- projectId: number;
108
- };
109
- authReady: boolean;
110
- managementReady: boolean;
111
- storage: _keboola_api_client.AsyncState<unknown>["state"];
101
+ } & {
102
+ issuedAt: number;
103
+ };
104
+ projectId: number;
112
105
  };
106
+ authReady: boolean;
107
+ managementReady: boolean;
108
+ storage: import("@keboola/api-client").AsyncState<unknown>['state'];
109
+ };
113
110
  };
114
111
  /** The legacy (SAPI) lifecycle session. Throws outside `<LegacyAuthProvider />`. */
115
112
  declare const useLegacyAuth: () => {
116
- setBaseUrl: (baseUrl: string) => void;
117
- isStorageReady: () => boolean;
118
- authenticateStorage: (sapiToken: string) => void;
119
- authenticateStorageAsync: (sapiToken: string) => Promise<void>;
120
- authenticateManagement: (managementToken: string) => void;
121
- subscribe: (listener: (snapshot: {
122
- type: "Sapi";
123
- config: {
124
- baseUrl: string | null;
125
- sapiToken: string | null;
126
- managementToken: string | null;
127
- };
128
- authReady: boolean;
129
- managementReady: boolean;
130
- storage: _keboola_api_client.AsyncState<unknown>["state"];
131
- }) => void) => () => void;
132
- debug: () => {
133
- type: "Sapi";
134
- config: {
135
- baseUrl: string | null;
136
- sapiToken: string | null;
137
- managementToken: string | null;
138
- };
139
- authReady: boolean;
140
- managementReady: boolean;
141
- storage: _keboola_api_client.AsyncState<unknown>["state"];
113
+ setBaseUrl: (baseUrl: string) => void;
114
+ isStorageReady: () => boolean;
115
+ authenticateStorage: (sapiToken: string) => void;
116
+ authenticateStorageAsync: (sapiToken: string) => Promise<void>;
117
+ authenticateManagement: (managementToken: string) => void;
118
+ subscribe: (listener: (snapshot: {
119
+ type: 'Sapi';
120
+ config: {
121
+ baseUrl: string | null;
122
+ sapiToken: string | null;
123
+ managementToken: string | null;
124
+ };
125
+ authReady: boolean;
126
+ managementReady: boolean;
127
+ storage: import("@keboola/api-client").AsyncState<unknown>['state'];
128
+ }) => void) => () => void;
129
+ debug: () => {
130
+ type: 'Sapi';
131
+ config: {
132
+ baseUrl: string | null;
133
+ sapiToken: string | null;
134
+ managementToken: string | null;
142
135
  };
136
+ authReady: boolean;
137
+ managementReady: boolean;
138
+ storage: import("@keboola/api-client").AsyncState<unknown>['state'];
139
+ };
143
140
  };
144
-
141
+ //#endregion
142
+ //#region src/ApiClientProvider.d.ts
145
143
  type Props$2 = {
146
- /** The flow-agnostic product API — the `api` half of a keboola client. */
147
- api: KeboolaApi;
148
- children: ReactNode;
144
+ /** The flow-agnostic product API — the `api` half of a keboola client. */
145
+ api: KeboolaApi;
146
+ children: ReactNode;
149
147
  };
150
148
  /**
151
149
  * Provides the product API to `useApiClient()`. A pure pass-through: the auth lifecycle (driving
152
150
  * to ready, gating on a fallback) belongs to `AuthProvider` / `LegacyAuthProvider`, which mount
153
151
  * this provider once their session is ready.
154
152
  */
155
- declare const ApiClientProvider: ({ api, children }: Props$2) => react_jsx_runtime.JSX.Element;
156
-
153
+ declare const ApiClientProvider: ({ api, children }: Props$2) => import("react/jsx-runtime").JSX.Element;
154
+ //#endregion
155
+ //#region src/AuthProvider.d.ts
157
156
  type BearerCredential = Parameters<BearerSession['authenticate']>[0];
158
157
  /** The session state guaranteed to exist once the storage build is ready. */
159
158
  type ScopedState = {
160
- projectId: number;
161
- baseUrl: string;
159
+ projectId: number;
160
+ baseUrl: string;
162
161
  };
163
162
  type BaseProps = {
164
- session: BearerSession;
165
- onAccessTokenChange?: (accessToken: string) => void;
166
- /** Rendered while a persisted session is being restored, or the bootstrap is in flight. */
167
- loadingFallback?: ReactNode;
168
- /** Rendered when the storage build fails. */
169
- errorFallback?: ReactNode;
170
- /**
171
- * Rendered only once the session is scoped and the storage build is ready. Pass a function to
172
- * receive the scoped state (the project the session settled on) without re-narrowing it yourself.
173
- */
174
- children: ReactNode | ((scoped: ScopedState) => ReactNode);
163
+ session: BearerSession;
164
+ onAccessTokenChange?: (accessToken: string) => void;
165
+ /** Rendered while a persisted session is being restored, or the bootstrap is in flight. */
166
+ loadingFallback?: ReactNode;
167
+ /** Rendered when the storage build fails. */
168
+ errorFallback?: ReactNode;
169
+ /**
170
+ * Rendered only once the session is scoped and the storage build is ready. Pass a function to
171
+ * receive the scoped state (the project the session settled on) without re-narrowing it yourself.
172
+ */
173
+ children: ReactNode | ((scoped: ScopedState) => ReactNode);
175
174
  };
176
175
  /**
177
176
  * Two mutually exclusive bootstrap modes, discriminated by whether a credential is supplied:
@@ -182,29 +181,32 @@ type BaseProps = {
182
181
  * here (a missing login UI would leave the app on a permanently blank screen).
183
182
  */
184
183
  type Props$1 = BaseProps & ({
185
- credential: BearerCredential;
186
- projectId: number;
187
- baseUrl: string;
188
- anonymousFallback?: never;
184
+ credential: BearerCredential;
185
+ projectId: number;
186
+ baseUrl: string;
187
+ anonymousFallback?: never;
189
188
  } | {
190
- credential?: undefined;
191
- projectId?: undefined;
192
- baseUrl?: never;
193
- anonymousFallback: ReactNode;
189
+ credential?: undefined;
190
+ projectId?: undefined;
191
+ baseUrl?: never;
192
+ anonymousFallback: ReactNode;
194
193
  });
195
- declare const AuthProvider: ({ session, baseUrl, credential, projectId, onAccessTokenChange, loadingFallback, errorFallback, anonymousFallback, children, }: Props$1) => react_jsx_runtime.JSX.Element;
196
-
194
+ declare const AuthProvider: ({ session, baseUrl, credential, projectId, onAccessTokenChange, loadingFallback, errorFallback, anonymousFallback, children }: Props$1) => import("react/jsx-runtime").JSX.Element;
195
+ //#endregion
196
+ //#region src/LegacyAuthProvider.d.ts
197
197
  type Props = {
198
- session: LegacySession;
199
- /** Stack base URL. */
200
- baseUrl: string;
201
- /** SAPI token — drives the storage build to ready. */
202
- storageToken: string;
203
- /** Optional manage-api token — unlocks `api.management`. */
204
- managementToken?: string;
205
- /** Rendered until the storage build reaches ready. */
206
- fallback?: ReactNode;
207
- children: ReactNode;
198
+ session: LegacySession;
199
+ /** Stack base URL. */
200
+ baseUrl: string;
201
+ /** SAPI token — drives the storage build to ready. */
202
+ storageToken: string;
203
+ /** Optional manage-api token — unlocks `api.management`. */
204
+ managementToken?: string;
205
+ /** Rendered until the storage build reaches ready. */
206
+ fallback?: ReactNode;
207
+ /** Rendered when the storage build fails — e.g. the SAPI token is expired or revoked. */
208
+ errorFallback?: ReactNode;
209
+ children: ReactNode;
208
210
  };
209
211
  /**
210
212
  * Owns the legacy (SAPI) lifecycle: on mount it configures the stack and drives the session to
@@ -212,6 +214,7 @@ type Props = {
212
214
  * known up front, so this drives itself (unlike the interactive bearer `AuthProvider`). Exposes the
213
215
  * session via `useLegacyAuth()` and gates `children` behind readiness.
214
216
  */
215
- declare const LegacyAuthProvider: ({ session, baseUrl, storageToken, managementToken, fallback, children, }: Props) => react_jsx_runtime.JSX.Element;
216
-
217
+ declare const LegacyAuthProvider: ({ session, baseUrl, storageToken, managementToken, fallback, errorFallback, children }: Props) => import("react/jsx-runtime").JSX.Element;
218
+ //#endregion
217
219
  export { ApiClientProvider, AuthProvider, LegacyAuthProvider, useApiClient, useAuth, useLegacyAuth, useProject, useStack };
220
+ //# sourceMappingURL=index.d.cts.map