@keboola/api-client-react 27.0.0 → 32.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/AGENTS.md CHANGED
@@ -69,6 +69,12 @@ A keboola client is `{ api, session }`. This package provides the two halves sep
69
69
  in-band rotation, so the host can mirror it (e.g. into a token store). Exposes the session via
70
70
  `useAuth()`.
71
71
 
72
+ `onRestore` fires once with the boot `restore()`'s `{ status }`. The slot that renders cannot
73
+ stand in for it — `expired` and `empty` both land in `anonymousFallback`, and so does a `restored`
74
+ session that carried no project — so an app that wants to say "your session expired" rather than
75
+ show a bare sign-in screen needs this callback. A `restore()` that throws reports `empty`, the
76
+ same value the provider acts on, so a transport failure is never reported as an expiry.
77
+
72
78
  - `useApiClient()` — returns the `api`; **throws** outside `<ApiClientProvider />`. Use it from
73
79
  query/mutation hooks.
74
80
  - `useProject()` / `useStack()` — shortcut hooks for `api.context.project` / `api.context.stack`.
package/CHANGELOG.md ADDED
@@ -0,0 +1,374 @@
1
+ # @keboola/api-client-react
2
+
3
+ ## 32.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `onRestore` to `AuthProvider`, so a consumer can act on the outcome of the boot `restore()`.
8
+
9
+ The provider owns that call and kept the result to itself, but `{ status: 'empty' | 'restored' |
10
+ 'expired' }` are three different things to say to a user and the rendered slot cannot tell them
11
+ apart: `expired` and `empty` both land in `anonymousFallback`, and so does a `restored` session that
12
+ carried no project. An app wanting to say "your session expired" rather than a bare sign-in screen
13
+ had to reconstruct the outcome from `hasPersistedValue()` sampled before mount — which reads a
14
+ cleared-because-corrupt entry, a stack mismatch and a transport failure all as an expiry.
15
+
16
+ A `restore()` that throws reports `empty`, matching what the provider itself acts on, so being
17
+ offline at boot is never dressed up as a session expiry. The callback fires once, including under
18
+ StrictMode's double-invoked effects.
19
+
20
+ ### Patch Changes
21
+
22
+ - Add a `storage.bootstrap` fixture slice — the three responses a client's ready gate needs before
23
+ it is usable (`GET /v2/storage`, `/v2/storage/tokens/verify`, `/v2/storage/dev-branches`).
24
+
25
+ `getStackInfo()`, `verifyStorageToken()` and `getDevBranches()` are typed by
26
+ `@keboola/api-client/storage/types`, so a field the backend adds arrives with `pnpm gen:types`
27
+ rather than being transcribed into every MSW test that bootstraps a client. `getStackInfo()`
28
+ announces every service by default, which is what keeps a test's queue / data-science / vault
29
+ client from being a dummy that throws `ServiceUnavailableError`; pass `services` to narrow it.
30
+
31
+ `@keboola/api-client` gains a runtime `ServiceId` const in `@keboola/api-client/constants`, with
32
+ the `ServiceId` type now derived from it. Announcing every service is exhaustive by construction:
33
+ a service added to the client flows into the fixture without an edit.
34
+
35
+ `@keboola/api-client-react`'s test fixtures now come from the slice; its published output is unchanged.
36
+
37
+ - Updated dependencies:
38
+ - @keboola/api-client@32.0.0
39
+
40
+ ## 31.0.0
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies:
45
+ - @keboola/api-client@31.0.0
46
+
47
+ ## 30.0.0
48
+
49
+ ### Patch Changes
50
+
51
+ - The published tarball now carries a `CHANGELOG.md`, so a consumer can read what changed in a release — breaking changes included — without leaving their `node_modules`.
52
+
53
+ It could not simply be added to `files`. This repo is private, so every reference `@changesets/changelog-github` emits is a dead link for anyone reading from npm: PR links, commit SHAs, author handles, and the Linear and cross-repo links that changeset prose carries. Across the publishable packages that came to 490 PR links, 863 commit links, 490 author credits and 102 dependency-bump blocks.
54
+
55
+ The published file is generated, not maintained. `scripts/public-changelog.mjs` removes those links ahead of the publish and leaves the prose. An identifier the author typed themselves stays as text — `UT-4009`, `connection#8040` — because it is part of the sentence and, without its URL, resolves to nothing outside Keboola. The repo-side `CHANGELOG.md` keeps every link, because that is how a release gets traced internally. It is rewritten only for the moment the tarballs are packed, then restored — which the release also depends on: `changesets/action` reads each changelog back off disk _after_ the publish command returns, to build that version's GitHub Release body, so without the restore the internal releases would carry the public text. A reference the rules do not cover fails the publish rather than shipping.
56
+
57
+ One incidental fix: a hex colour written as `#222529` in changeset prose had been autolinked into a link to issue 222529. Unwrapping restores the colour, so the published notes read as the author wrote them.
58
+
59
+ - Updated dependencies:
60
+ - @keboola/api-client@30.0.0
61
+
62
+ ## 29.0.0
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies:
67
+ - @keboola/api-client@29.0.0
68
+
69
+ ## 28.0.0
70
+
71
+ ### Patch Changes
72
+
73
+ - Build with tsdown instead of tsup. Fixes declaration bundling against the new `@keboola/api-client` output: tsup's dts pass inlined `@keboola/api-client/*` subpath types and leaked unresolvable relative chunk imports into `dist/index.d.ts` (attw red in all four modes); with tsdown, peer dependencies stay external in declarations — subpaths included.
74
+
75
+ - Updated dependencies:
76
+ - @keboola/api-client@28.0.0
77
+
78
+ ## 27.0.0
79
+
80
+ ### Minor Changes
81
+
82
+ - `LegacyAuthProvider` gained an `errorFallback` slot, the counterpart of the one its bearer twin `AuthProvider` already had.
83
+
84
+ It previously asked only `session.isStorageReady()`, so an errored storage build was indistinguishable from a pending one and kept rendering `fallback` — a consumer whose SAPI token had expired showed a loading state forever. It now reads the build state from `debug()`/`subscribe`, renders `errorFallback` on failure (defaulting to `fallback`, so the old behaviour stands when it is omitted) and logs the failure, which nothing else did.
85
+
86
+ ### Patch Changes
87
+
88
+ - Updated dependencies:
89
+ - @keboola/api-client@27.0.0
90
+
91
+ ## 26.0.0
92
+
93
+ ### Patch Changes
94
+
95
+ - These packages now ship their `AGENTS.md` usage contract to npm, so external
96
+ consumers (and their AI agents) can read it at
97
+ `node_modules/@keboola/<name>/AGENTS.md`, version-pinned to the release they
98
+ actually installed.
99
+
100
+ Previously only `@keboola/design` published its `AGENTS.md`; every other package
101
+ omitted it from `files`, so instructions that point agents at that path — such as
102
+ `apps/boilerplate/AGENTS.md` — silently resolved to nothing outside the monorepo.
103
+ No code or type changes.
104
+
105
+ - Updated dependencies:
106
+ - @keboola/api-client@26.0.0
107
+
108
+ ## 25.0.0
109
+
110
+ ### Patch Changes
111
+
112
+ - Updated dependencies:
113
+ - @keboola/api-client@25.0.0
114
+
115
+ ## 24.0.0
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies:
120
+ - @keboola/api-client@24.0.0
121
+
122
+ ## 23.0.0
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies:
127
+ - @keboola/api-client@23.0.0
128
+
129
+ ## 22.0.0
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies:
134
+ - @keboola/api-client@22.0.0
135
+
136
+ ## 21.0.0
137
+
138
+ ### Major Changes
139
+
140
+ - Reshape the SDK lifecycle around two authentication flows behind one product surface.
141
+ - **Breaking:** the entry points are now `createKeboola()` (bearer / OAuth) and `createLegacyKeboola()` (legacy SAPI + management token). Each returns `{ api, session }` — `api` is the flow-agnostic product surface (`auth`, `management`, `storage`, `queue`, `context`, `sdk`, …); `session` is the flow-specific lifecycle (bearer: `authenticate(credential)` → `setProject(id)`; legacy: `authenticateStorage(sapiToken)` / `authenticateManagement(manageToken)`). The old `createApiClient()` / `init()` lifecycle and the `ApiClient` type are removed.
142
+ - **Breaking:** per-service factories take an `auth` strategy instead of a bare token — `createStorageClient({ baseUrl, auth: { type: 'sapi-token', token } })`, `createManagementClient({ baseUrl, auth: { type: 'management-token', token } })` (bearer: `{ type: 'bearer', token }`). `createManagementClient` keeps `withAuthMiddleware` (default `true`; pass `false` for a raw validity-check client).
143
+ - `@keboola/api-client-react` exposes three providers: `ApiClientProvider` (propagates `api` to `useApiClient()`), `LegacyAuthProvider` (drives the legacy session to ready and gates on a fallback), and `AuthProvider` (bearer; finished with the login flow in a follow-up). `useApiClient` / `useProject` / `useStack` return the `api` surface.
144
+ - **Breaking:** the token-less public clients `assets` / `status` are not part of the keboola client — import `createAssetsClient` / `createStatusClient` from `@keboola/api-client/assets` and `@keboola/api-client/status`. `metastore` is a stack-discovered service, exposed as `api.metastore`.
145
+ - `KeboolaError` / `isKeboolaError` are exported from the package root and are the errors the client actually throws (lifecycle gating: `NotReady`, `Unconfigured`, `NoManagementToken`, …).
146
+
147
+ Migration: `const api = createApiClient(); await api.init(opts)` → `const { api, session } = createLegacyKeboola(opts); await session.authenticateStorageAsync(token)` (or `createKeboola` for the bearer flow). Per-service: `createStorageClient({ baseUrl, token })` → `createStorageClient({ baseUrl, auth: { type: 'sapi-token', token } })`.
148
+
149
+ - Give `AuthProvider` one slot per session state, and make the interactive mode's login slot mandatory.
150
+ - **Breaking:** the single `fallback` prop is replaced by three, so a genuine failure is no longer indistinguishable from "not signed in yet": `loadingFallback` (restoring / bootstrapping), `anonymousFallback` (no session — render the sign-in UI), and `errorFallback` (the storage build failed). `children` still render only once the session is scoped and storage is ready.
151
+ - **Breaking:** props are a discriminated union over the two bootstrap modes. Programmatic (`credential` + `projectId`) requires `baseUrl`, since a credential is bound to the stack that issued it. Interactive takes neither credential nor `baseUrl` — the stack comes from the restored session or from the login UI — and **requires** `anonymousFallback`, so omitting the login UI is a compile error instead of a permanently blank screen.
152
+ - `children` may now be a function receiving the scoped `{ projectId, baseUrl }`, so consumers don't re-narrow session state to read the project they landed on.
153
+ - The loading state is seeded from `session.hasPersistedValue()`: with nothing persisted there is nothing to wait for, so the login UI paints on the first render instead of flashing a loader for an empty, network-free restore.
154
+
155
+ ### Minor Changes
156
+
157
+ - Finish the bearer (programmatic) auth flow. `AuthProvider` is now the bearer twin of `LegacyAuthProvider`: it takes `baseUrl` / `credential` / `projectId` (plus optional `onAccessTokenChange` and `fallback`), drives the session to ready on mount, mirrors the rotating access token out via `onAccessTokenChange`, and gates its children behind readiness.
158
+
159
+ - Rework the bearer (OAuth) auth internals for a cleaner separation of concerns. Token handling now lives in a `TokenCredential`-style provider — `getAccessToken({ forceRefresh })` always returns a usable access token, refreshing (deduped) on near-expiry or when forced — consumed by a thin auth middleware that stamps the live token on every request and replays once on a 401. The bearer session config is a discriminated-union state machine (`anonymous` / `authenticated` / `scoped`) that owns its own credential model and the fire-once session-expiry latch: `session.authenticate` now takes a `TokenSet` (`accessToken`, `refreshToken`, `expiresIn`) rather than the full login credential, and `SessionSnapshot.config` is that state union. Also adds a `dedupe` (single-flight) util.
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies:
164
+ - @keboola/api-client@21.0.0
165
+
166
+ ## 20.0.0
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies:
171
+ - @keboola/api-client@20.0.0
172
+
173
+ ## 19.0.0
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies:
178
+ - @keboola/api-client@19.0.0
179
+
180
+ ## 18.0.0
181
+
182
+ ### Major Changes
183
+
184
+ - Discover the metastore service from stack info instead of taking a `metastoreBaseUrl` option.
185
+ - **Breaking:** `metastoreBaseUrl` is removed from `ApiClientOptions`. `createApiClient`/`init()` no longer accept it, and `ApiClientProvider` no longer accepts the `metastoreBaseUrl` prop.
186
+ - `metastore` is now a stack-discovered service client (like `queue`, `vault`, …): its base URL comes from `getStackInfo` service discovery, exposed on the client as `api.metastore` and consumed by the tag SDK. On stacks that don't advertise a metastore service, the client resolves to a lazy no-op that throws only when a metastore method is actually called.
187
+
188
+ Migration: drop `metastoreBaseUrl` from every `createApiClient`/`init()`/`ApiClientProvider` call — the URL is resolved automatically from the stack.
189
+
190
+ ### Patch Changes
191
+
192
+ - Updated dependencies:
193
+ - @keboola/api-client@18.0.0
194
+
195
+ ## 17.0.0
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies:
200
+ - @keboola/api-client@17.0.0
201
+
202
+ ## 16.0.0
203
+
204
+ ### Major Changes
205
+
206
+ - Remove `createDevApiClient` (and, in `@keboola/api-client-react`, `DevApiClientProvider` / `useDevApiClient`).
207
+
208
+ `createDevApiClient` was a stateless pass-through — `{ verify: { storageApiToken, managementApiToken } }` with no lifecycle, no base-URL registry, no `init()`. It doesn't fit the client model; it's just two host-parameterized verify calls. The React dev-provider layer existed only to carry that object through context.
209
+
210
+ Verify a candidate token with the real per-service clients directly (host-parameterized per call, no provider):
211
+ - storage: `createStorageClient({ baseUrl: host, token }).tokens.verify()`
212
+ - management: `createManagementClient({ baseUrl: host, token, withAuthMiddleware: false }).verifyToken()`
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies:
217
+ - @keboola/api-client@16.0.0
218
+
219
+ ## 15.0.0
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies:
224
+ - @keboola/api-client@15.0.0
225
+
226
+ ## 14.0.0
227
+
228
+ ### Patch Changes
229
+
230
+ - Updated dependencies:
231
+ - @keboola/api-client@14.0.0
232
+
233
+ ## 13.0.0
234
+
235
+ ### Patch Changes
236
+
237
+ - Updated dependencies:
238
+ - @keboola/api-client@13.0.0
239
+
240
+ ## 12.0.0
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies:
245
+ - @keboola/api-client@12.0.0
246
+
247
+ ## 11.0.0
248
+
249
+ ### Patch Changes
250
+
251
+ - Updated dependencies:
252
+ - @keboola/api-client@11.0.0
253
+
254
+ ## 10.0.0
255
+
256
+ ### Patch Changes
257
+
258
+ - Updated dependencies:
259
+ - @keboola/api-client@10.0.0
260
+
261
+ ## 9.0.0
262
+
263
+ ### Patch Changes
264
+
265
+ - Updated dependencies:
266
+ - @keboola/api-client@9.0.0
267
+
268
+ ## 8.0.2
269
+
270
+ ### Patch Changes
271
+
272
+ - docs: document the sanctioned non-component data-access pattern (loaders / module-scope services) — use a per-service client or a bootstrap `createApiClient` instance, not the `useApiClient` hook
273
+
274
+ - Updated dependencies:
275
+ - @keboola/api-client@8.0.2
276
+
277
+ ## 8.0.0
278
+
279
+ ### Patch Changes
280
+
281
+ - Updated dependencies:
282
+ - @keboola/api-client@8.0.0
283
+
284
+ ## 7.0.0
285
+
286
+ ### Patch Changes
287
+
288
+ - Updated dependencies:
289
+ - @keboola/api-client@7.0.0
290
+
291
+ ## 6.0.0
292
+
293
+ ### Patch Changes
294
+
295
+ - Updated dependencies:
296
+ - @keboola/api-client@6.0.0
297
+
298
+ ## 5.0.0
299
+
300
+ ### Patch Changes
301
+
302
+ - Updated dependencies:
303
+ - @keboola/api-client@5.0.0
304
+
305
+ ## 4.0.0
306
+
307
+ ### Patch Changes
308
+
309
+ - Updated dependencies:
310
+ - @keboola/api-client@4.0.0
311
+
312
+ ## 3.0.0
313
+
314
+ ### Patch Changes
315
+
316
+ - Updated dependencies:
317
+ - @keboola/api-client@3.0.0
318
+
319
+ ## 2.0.0
320
+
321
+ ### Patch Changes
322
+
323
+ - Re-publish to scrub `workspace:^` from the npm tarball manifests.
324
+
325
+ `@keboola/design@1.2.0` shipped with literal `workspace:^` strings in
326
+ `dependencies` (`codemirror-lang-sfsql`, `codemirror-lang-sql`,
327
+ `tailwind-config`), making `npm install @keboola/design` fail with
328
+ `EUNSUPPORTEDPROTOCOL` — npm has no way to resolve the yarn-only
329
+ workspace protocol against a public registry.
330
+ `@keboola/api-client-react@1.0.1` shipped with the same
331
+ leak in `peerDependencies` (`@keboola/api-client`) — less fatal
332
+ because peerDeps are warnings, not errors, but still wrong.
333
+
334
+ Root cause was the publish workflow invoking plain `npm publish`
335
+ (which doesn't understand `workspace:^`) instead of
336
+ `yarn npm publish` (which rewrites it just-in-time). This changeset
337
+ rides alongside the workflow script fix, so the next release cycle
338
+ republishes both packages cleanly through the corrected path.
339
+
340
+ The other recently-bumped packages (`api-client`, `brand-registry`,
341
+ `brand-audit`, `codemirror-lang-*`, `agent-precheck`,
342
+ `oxlint-config`) don't need patches — they happen to have no
343
+ `@keboola/*` runtime or peer deps, so the bug couldn't bite them.
344
+
345
+ - Updated dependencies:
346
+ - @keboola/api-client@2.0.0
347
+
348
+ ## 1.0.1
349
+
350
+ ### Patch Changes
351
+
352
+ - Re-publish to fix unresolved `workspace:^` protocol references in the npm tarball manifests.
353
+
354
+ The initial bootstrap publishes (2026-05-18 for `@keboola/api-client` and `@keboola/api-client-react`, later for the rest) were run manually with `npm publish` from a maintainer machine. Bare `npm publish` doesn't understand yarn's `workspace:` protocol, so the published `package.json` files shipped with literal `workspace:^` strings in `dependencies`, `peerDependencies`, and `devDependencies`.
355
+
356
+ The blocker is `@keboola/api-client-react@1.0.0`'s `peerDependencies` declaring `@keboola/api-client: workspace:^`. Running `npm install @keboola/api-client-react` from outside the monorepo fails with `EUNSUPPORTEDPROTOCOL` because npm can't resolve the `workspace:` protocol. The same string also appears in `@keboola/api-client`, `@keboola/brand-registry`, and `@keboola/oxlint-config` `devDependencies` — npm ignores those for transitive installs, but they're still wrong in the published manifests and worth cleaning up in the same release.
357
+
358
+ This patch bump triggers a regular changesets-driven release. When `changeset publish` runs in CI, it rewrites `workspace:*` references to the actual resolved version ranges before calling `npm publish`, restoring a consumable npm surface for every package.
359
+
360
+ `@keboola/codemirror-lang-sql` has the same issue but is already covered by an existing pending changeset (`codemirror-lang-sql-publish.md`, minor bump for initial publish setup); the next release will fix it through that bump.
361
+
362
+ No source code or runtime behavior changes. The local `workspace:^` references in source `package.json` files stay (they're correct for monorepo workspace deps; the rewrite happens only at publish time).
363
+
364
+ - Updated dependencies:
365
+ - @keboola/api-client@1.0.1
366
+
367
+ ## 1.0.0
368
+
369
+ ### Patch Changes
370
+
371
+ - Initial publish setup for `@keboola/api-client-react` — React provider + hooks (`useApiClient`, `useProject`, `useStack`, `useDevApiClient`) for the Keboola SDK. Ships dual ESM/CJS bundles via `tsup` with React 18/19 as peer dependencies. Linked with `@keboola/api-client` so both packages release together.
372
+
373
+ - Updated dependencies:
374
+ - @keboola/api-client@1.0.0