@keboola/api-client-react 27.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/CHANGELOG.md +337 -0
- package/dist/index.cjs +152 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -170
- package/dist/index.d.ts +171 -170
- package/dist/index.js +151 -128
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,177 +1,176 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import { ReactNode } from 'react';
|
|
6
|
-
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { BearerSession, KeboolaApi, LegacySession } from "@keboola/api-client";
|
|
3
|
+
//#region src/context.d.ts
|
|
7
4
|
declare const useApiClient: () => KeboolaApi;
|
|
8
5
|
declare const useProject: () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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) =>
|
|
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
|
-
|
|
161
|
-
|
|
159
|
+
projectId: number;
|
|
160
|
+
baseUrl: string;
|
|
162
161
|
};
|
|
163
162
|
type BaseProps = {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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,31 +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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
credential: BearerCredential;
|
|
185
|
+
projectId: number;
|
|
186
|
+
baseUrl: string;
|
|
187
|
+
anonymousFallback?: never;
|
|
189
188
|
} | {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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;
|
|
210
210
|
};
|
|
211
211
|
/**
|
|
212
212
|
* Owns the legacy (SAPI) lifecycle: on mount it configures the stack and drives the session to
|
|
@@ -214,6 +214,7 @@ type Props = {
|
|
|
214
214
|
* known up front, so this drives itself (unlike the interactive bearer `AuthProvider`). Exposes the
|
|
215
215
|
* session via `useLegacyAuth()` and gates `children` behind readiness.
|
|
216
216
|
*/
|
|
217
|
-
declare const LegacyAuthProvider: ({ session, baseUrl, storageToken, managementToken, fallback, errorFallback, children
|
|
218
|
-
|
|
217
|
+
declare const LegacyAuthProvider: ({ session, baseUrl, storageToken, managementToken, fallback, errorFallback, children }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
218
|
+
//#endregion
|
|
219
219
|
export { ApiClientProvider, AuthProvider, LegacyAuthProvider, useApiClient, useAuth, useLegacyAuth, useProject, useStack };
|
|
220
|
+
//# sourceMappingURL=index.d.ts.map
|