kitcn 0.33.5 → 0.33.7
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 +31 -0
- package/dist/aggregate/index.d.ts +1 -1
- package/dist/auth/client/index.d.ts +74 -1
- package/dist/auth/client/index.js +238 -32
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +19 -19
- package/dist/auth/start/index.js +134 -2
- package/dist/crpc/index.d.ts +2 -2
- package/dist/crpc/index.js +2 -2
- package/dist/{generated-contract-disabled-PdNGvNYP.d.ts → generated-contract-disabled-QZXEzUnd.d.ts} +26 -26
- package/dist/orm/index.d.ts +1 -1
- package/dist/orm/migrations/index.d.ts +1 -1
- package/dist/{query-options-DGG93--5.js → query-options-YkFvau71.js} +6 -2
- package/dist/react/index.d.ts +12 -3
- package/dist/react/index.js +157 -140
- package/dist/rsc/index.d.ts +12 -2
- package/dist/rsc/index.js +1 -1
- package/dist/solid/index.js +4 -1
- package/dist/{auth-store-x3_wvhTR.js → token-gate-CEzbXArg.js} +178 -1
- package/dist/{types-C7JkpfeY.d.ts → types-Bb0kwteA.d.ts} +5 -1
- package/dist/{where-clause-compiler-qH6-NCM9.d.ts → where-clause-compiler-DAqhUREe.d.ts} +67 -67
- package/package.json +1 -1
- package/skills/kitcn/references/features/auth.md +35 -2
- package/skills/kitcn/references/features/react.md +16 -0
|
@@ -64,6 +64,10 @@ declare function replaceUrlParam(url: string, params: Record<string, string>): s
|
|
|
64
64
|
* Handles array values as multiple params with same key (like Hono).
|
|
65
65
|
*/
|
|
66
66
|
declare function buildSearchParams(query: Record<string, string | string[]>): URLSearchParams;
|
|
67
|
+
declare const RECHECK_AUTHORIZATION: unique symbol;
|
|
68
|
+
declare const withAuthorizationRecheck: <T extends {
|
|
69
|
+
[key: string]: string | undefined;
|
|
70
|
+
}>(headers: T, recheck: () => boolean) => T;
|
|
67
71
|
/**
|
|
68
72
|
* Hono-style HTTP request executor.
|
|
69
73
|
* Processes args in the same way as Hono's ClientRequestImpl.fetch().
|
|
@@ -210,4 +214,4 @@ type VanillaAction<T extends FunctionReference<'action'>> = {
|
|
|
210
214
|
mutate: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
211
215
|
};
|
|
212
216
|
//#endregion
|
|
213
|
-
export { HttpInputArgs as A, ReservedMutationOptions as C, VanillaMutation as D, VanillaAction as E,
|
|
217
|
+
export { HttpInputArgs as A, ReservedMutationOptions as C, VanillaMutation as D, VanillaAction as E, executeHttpRequest as F, replaceUrlParam as I, withAuthorizationRecheck as L, RECHECK_AUTHORIZATION as M, RESERVED_KEYS as N, HttpClientOptions as O, buildSearchParams as P, ReservedInfiniteQueryOptions as S, StaticQueryOptsParam as T, IsPaginated as _, BaseInfiniteQueryOptsParam as a, PaginatedFnMeta as b, ConvexMutationKey as c, ConvexQueryMeta as d, EmptyObject as f, InfiniteQueryInput as g, FnMeta as h, BaseConvexQueryOptions as i, HttpProxyBaseOptions as j, HttpFormValue as k, ConvexQueryHookOptions as l, FUNC_REF_SYMBOL as m, BaseConvexActionOptions as n, ConvexActionKey as o, ExtractPaginatedItem as p, BaseConvexInfiniteQueryOptions as r, ConvexInfiniteQueryMeta as s, AuthType as t, ConvexQueryKey as u, Meta as v, ReservedQueryOptions as w, PaginationOpts as x, MutationVariables as y };
|
|
@@ -102,15 +102,6 @@ declare const migrationStorageTables: {
|
|
|
102
102
|
fieldName: "status";
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
|
-
direction: ConvexTextBuilderInitial<""> & {
|
|
106
|
-
_: {
|
|
107
|
-
tableName: "migration_state";
|
|
108
|
-
};
|
|
109
|
-
} & {
|
|
110
|
-
_: {
|
|
111
|
-
fieldName: "direction";
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
105
|
cursor: ConvexTextBuilderInitial<""> & {
|
|
115
106
|
_: {
|
|
116
107
|
tableName: "migration_state";
|
|
@@ -212,6 +203,15 @@ declare const migrationStorageTables: {
|
|
|
212
203
|
fieldName: "applied";
|
|
213
204
|
};
|
|
214
205
|
};
|
|
206
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
207
|
+
_: {
|
|
208
|
+
tableName: "migration_state";
|
|
209
|
+
};
|
|
210
|
+
} & {
|
|
211
|
+
_: {
|
|
212
|
+
fieldName: "direction";
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
215
|
runId: ConvexTextBuilderInitial<""> & {
|
|
216
216
|
_: {
|
|
217
217
|
tableName: "migration_state";
|
|
@@ -256,19 +256,6 @@ declare const migrationStorageTables: {
|
|
|
256
256
|
fieldName: "status";
|
|
257
257
|
};
|
|
258
258
|
};
|
|
259
|
-
direction: ConvexTextBuilderInitial<""> & {
|
|
260
|
-
_: {
|
|
261
|
-
notNull: true;
|
|
262
|
-
};
|
|
263
|
-
} & {
|
|
264
|
-
_: {
|
|
265
|
-
tableName: "migration_run";
|
|
266
|
-
};
|
|
267
|
-
} & {
|
|
268
|
-
_: {
|
|
269
|
-
fieldName: "direction";
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
259
|
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
273
260
|
_: {
|
|
274
261
|
notNull: true;
|
|
@@ -313,6 +300,19 @@ declare const migrationStorageTables: {
|
|
|
313
300
|
fieldName: "lastError";
|
|
314
301
|
};
|
|
315
302
|
};
|
|
303
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
304
|
+
_: {
|
|
305
|
+
notNull: true;
|
|
306
|
+
};
|
|
307
|
+
} & {
|
|
308
|
+
_: {
|
|
309
|
+
tableName: "migration_run";
|
|
310
|
+
};
|
|
311
|
+
} & {
|
|
312
|
+
_: {
|
|
313
|
+
fieldName: "direction";
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
316
|
runId: ConvexTextBuilderInitial<""> & {
|
|
317
317
|
_: {
|
|
318
318
|
notNull: true;
|
|
@@ -1326,11 +1326,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1326
1326
|
readonly aggregate_extrema: ConvexTableWithColumns<{
|
|
1327
1327
|
name: "aggregate_extrema";
|
|
1328
1328
|
columns: {
|
|
1329
|
-
|
|
1330
|
-
_: {
|
|
1331
|
-
$type: convex_values0.Value;
|
|
1332
|
-
};
|
|
1333
|
-
} & {
|
|
1329
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
1334
1330
|
_: {
|
|
1335
1331
|
notNull: true;
|
|
1336
1332
|
};
|
|
@@ -1340,10 +1336,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1340
1336
|
};
|
|
1341
1337
|
} & {
|
|
1342
1338
|
_: {
|
|
1343
|
-
fieldName: "
|
|
1339
|
+
fieldName: "indexName";
|
|
1344
1340
|
};
|
|
1345
1341
|
};
|
|
1346
|
-
|
|
1342
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1347
1343
|
_: {
|
|
1348
1344
|
notNull: true;
|
|
1349
1345
|
};
|
|
@@ -1353,10 +1349,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1353
1349
|
};
|
|
1354
1350
|
} & {
|
|
1355
1351
|
_: {
|
|
1356
|
-
fieldName: "
|
|
1352
|
+
fieldName: "updatedAt";
|
|
1357
1353
|
};
|
|
1358
1354
|
};
|
|
1359
|
-
|
|
1355
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
1360
1356
|
_: {
|
|
1361
1357
|
notNull: true;
|
|
1362
1358
|
};
|
|
@@ -1366,10 +1362,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1366
1362
|
};
|
|
1367
1363
|
} & {
|
|
1368
1364
|
_: {
|
|
1369
|
-
fieldName: "
|
|
1365
|
+
fieldName: "tableKey";
|
|
1370
1366
|
};
|
|
1371
1367
|
};
|
|
1372
|
-
|
|
1368
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
1373
1369
|
_: {
|
|
1374
1370
|
notNull: true;
|
|
1375
1371
|
};
|
|
@@ -1379,10 +1375,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1379
1375
|
};
|
|
1380
1376
|
} & {
|
|
1381
1377
|
_: {
|
|
1382
|
-
fieldName: "
|
|
1378
|
+
fieldName: "count";
|
|
1383
1379
|
};
|
|
1384
1380
|
};
|
|
1385
|
-
|
|
1381
|
+
value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
|
|
1382
|
+
_: {
|
|
1383
|
+
$type: convex_values0.Value;
|
|
1384
|
+
};
|
|
1385
|
+
} & {
|
|
1386
1386
|
_: {
|
|
1387
1387
|
notNull: true;
|
|
1388
1388
|
};
|
|
@@ -1392,7 +1392,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1392
1392
|
};
|
|
1393
1393
|
} & {
|
|
1394
1394
|
_: {
|
|
1395
|
-
fieldName: "
|
|
1395
|
+
fieldName: "value";
|
|
1396
1396
|
};
|
|
1397
1397
|
};
|
|
1398
1398
|
keyHash: ConvexTextBuilderInitial<""> & {
|
|
@@ -1609,15 +1609,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1609
1609
|
fieldName: "kind";
|
|
1610
1610
|
};
|
|
1611
1611
|
};
|
|
1612
|
-
cursor: ConvexTextBuilderInitial<""> & {
|
|
1613
|
-
_: {
|
|
1614
|
-
tableName: "aggregate_state";
|
|
1615
|
-
};
|
|
1616
|
-
} & {
|
|
1617
|
-
_: {
|
|
1618
|
-
fieldName: "cursor";
|
|
1619
|
-
};
|
|
1620
|
-
};
|
|
1621
1612
|
indexName: ConvexTextBuilderInitial<""> & {
|
|
1622
1613
|
_: {
|
|
1623
1614
|
notNull: true;
|
|
@@ -1657,6 +1648,15 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1657
1648
|
fieldName: "metricDefinitionHash";
|
|
1658
1649
|
};
|
|
1659
1650
|
};
|
|
1651
|
+
cursor: ConvexTextBuilderInitial<""> & {
|
|
1652
|
+
_: {
|
|
1653
|
+
tableName: "aggregate_state";
|
|
1654
|
+
};
|
|
1655
|
+
} & {
|
|
1656
|
+
_: {
|
|
1657
|
+
fieldName: "cursor";
|
|
1658
|
+
};
|
|
1659
|
+
};
|
|
1660
1660
|
processed: ConvexNumberBuilderInitial<""> & {
|
|
1661
1661
|
_: {
|
|
1662
1662
|
notNull: true;
|
|
@@ -1751,15 +1751,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1751
1751
|
fieldName: "status";
|
|
1752
1752
|
};
|
|
1753
1753
|
};
|
|
1754
|
-
direction: ConvexTextBuilderInitial<""> & {
|
|
1755
|
-
_: {
|
|
1756
|
-
tableName: "migration_state";
|
|
1757
|
-
};
|
|
1758
|
-
} & {
|
|
1759
|
-
_: {
|
|
1760
|
-
fieldName: "direction";
|
|
1761
|
-
};
|
|
1762
|
-
};
|
|
1763
1754
|
cursor: ConvexTextBuilderInitial<""> & {
|
|
1764
1755
|
_: {
|
|
1765
1756
|
tableName: "migration_state";
|
|
@@ -1861,6 +1852,15 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1861
1852
|
fieldName: "applied";
|
|
1862
1853
|
};
|
|
1863
1854
|
};
|
|
1855
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
1856
|
+
_: {
|
|
1857
|
+
tableName: "migration_state";
|
|
1858
|
+
};
|
|
1859
|
+
} & {
|
|
1860
|
+
_: {
|
|
1861
|
+
fieldName: "direction";
|
|
1862
|
+
};
|
|
1863
|
+
};
|
|
1864
1864
|
runId: ConvexTextBuilderInitial<""> & {
|
|
1865
1865
|
_: {
|
|
1866
1866
|
tableName: "migration_state";
|
|
@@ -1905,19 +1905,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1905
1905
|
fieldName: "status";
|
|
1906
1906
|
};
|
|
1907
1907
|
};
|
|
1908
|
-
direction: ConvexTextBuilderInitial<""> & {
|
|
1909
|
-
_: {
|
|
1910
|
-
notNull: true;
|
|
1911
|
-
};
|
|
1912
|
-
} & {
|
|
1913
|
-
_: {
|
|
1914
|
-
tableName: "migration_run";
|
|
1915
|
-
};
|
|
1916
|
-
} & {
|
|
1917
|
-
_: {
|
|
1918
|
-
fieldName: "direction";
|
|
1919
|
-
};
|
|
1920
|
-
};
|
|
1921
1908
|
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
1922
1909
|
_: {
|
|
1923
1910
|
notNull: true;
|
|
@@ -1962,6 +1949,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1962
1949
|
fieldName: "lastError";
|
|
1963
1950
|
};
|
|
1964
1951
|
};
|
|
1952
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
1953
|
+
_: {
|
|
1954
|
+
notNull: true;
|
|
1955
|
+
};
|
|
1956
|
+
} & {
|
|
1957
|
+
_: {
|
|
1958
|
+
tableName: "migration_run";
|
|
1959
|
+
};
|
|
1960
|
+
} & {
|
|
1961
|
+
_: {
|
|
1962
|
+
fieldName: "direction";
|
|
1963
|
+
};
|
|
1964
|
+
};
|
|
1965
1965
|
runId: ConvexTextBuilderInitial<""> & {
|
|
1966
1966
|
_: {
|
|
1967
1967
|
notNull: true;
|
package/package.json
CHANGED
|
@@ -363,7 +363,7 @@ All from `kitcn/react`:
|
|
|
363
363
|
|------|---------|-------------|
|
|
364
364
|
| `useAuth()` | `{ hasSession, isAuthenticated, isLoading }` | Full auth state |
|
|
365
365
|
| `useMaybeAuth()` | `boolean` | Has token (optimistic, may not be verified) |
|
|
366
|
-
| `useIsAuth()` | `boolean` | Server-verified authentication |
|
|
366
|
+
| `useIsAuth()` | `boolean` | Server-verified authentication (with `optimisticAuth`, also during the optimistic window) |
|
|
367
367
|
| `useAuthGuard()` | `() => boolean` | Guard mutations, returns true if blocked |
|
|
368
368
|
| `useConvexAuthRecovery()` | `{ recover, status, error }` | Rebind Convex auth after a transient token failure |
|
|
369
369
|
|
|
@@ -389,7 +389,7 @@ All from `kitcn/react`:
|
|
|
389
389
|
| Component | Renders when |
|
|
390
390
|
|-----------|-------------|
|
|
391
391
|
| `MaybeAuthenticated` | Has session token (optimistic) |
|
|
392
|
-
| `Authenticated` | Server-verified authenticated |
|
|
392
|
+
| `Authenticated` | Server-verified authenticated (with `optimisticAuth`, also during the optimistic window) |
|
|
393
393
|
| `MaybeUnauthenticated` | No session token (optimistic) |
|
|
394
394
|
| `Unauthenticated` | Server-verified not authenticated |
|
|
395
395
|
|
|
@@ -406,11 +406,44 @@ All from `kitcn/react`:
|
|
|
406
406
|
authClient={authClient}
|
|
407
407
|
convexQueryClient={convexQueryClient} // when using TanStack Query
|
|
408
408
|
initialToken={token} // from SSR (caller.getToken())
|
|
409
|
+
optimisticAuth // opt in: open gates while Convex confirms a held JWT
|
|
410
|
+
onTokenIdentityChange={() => window.location.reload()}
|
|
409
411
|
onMutationUnauthorized={() => router.push('/login')}
|
|
410
412
|
onQueryUnauthorized={({ queryName }) => console.log(`Unauth: ${queryName}`)}
|
|
411
413
|
>
|
|
412
414
|
```
|
|
413
415
|
|
|
416
|
+
`optimisticAuth` only opens auth-bound query gates for a held, unexpired JWT;
|
|
417
|
+
expired, opaque, and refused tokens stay closed. The window ends at the Convex
|
|
418
|
+
client's first auth result; use one `optimisticAuth` setting per client; no
|
|
419
|
+
optimism over a client the Start loader authenticated. Enable
|
|
420
|
+
`onTokenIdentityChange` to refuse a JWT whose `sub` or `sessionId` differs from
|
|
421
|
+
the document identity (whatever its `exp`) before Convex, HTTP or the Start
|
|
422
|
+
loader sees it. On a trip, every mounted provider hands out no token and
|
|
423
|
+
publishes unauthenticated; each guarded one closes its client, then calls the
|
|
424
|
+
callback once, so reload the document there. Browser only, page-wide: later
|
|
425
|
+
providers start tripped, and a guarded one that mounts or shows again on a
|
|
426
|
+
tripped page also closes its client and calls the callback once. Enabling the
|
|
427
|
+
guard on a tripped page delivers that close and callback once too; sign-in
|
|
428
|
+
mutations fail with `TOKEN_IDENTITY_CHANGED`.
|
|
429
|
+
|
|
430
|
+
For multiple provider mounts, pass `tokenIdentityBaseline` as
|
|
431
|
+
`sub|sessionId`, or a getter returning the document's current identity. Every
|
|
432
|
+
admission (SSR, fresh and cached tokens, sign-in, HTTP, Start loader) binds a
|
|
433
|
+
token to the page identity, the provider's own baseline and every mounted
|
|
434
|
+
provider's current getter answer; an opaque session token is only exchanged,
|
|
435
|
+
never handed to Convex. Held tokens are reconciled when a provider joins the
|
|
436
|
+
page and at every admission. A page that never enables the guard is
|
|
437
|
+
unchanged; once a guarded provider establishes the page identity it persists
|
|
438
|
+
until reload, binding every provider and the Start loader, even after that
|
|
439
|
+
provider unmounts. Two kitcn versions or revisions on one page (dev HMR
|
|
440
|
+
across revisions included) are unsupported: no shared page identity until
|
|
441
|
+
reload.
|
|
442
|
+
`onTokenIdentityAdmitted(token)` observes admitted JWTs so the app can update
|
|
443
|
+
that shared baseline. Admission rechecks the baseline after the callback before
|
|
444
|
+
publishing or handing out the token. All three identity options require
|
|
445
|
+
`onTokenIdentityChange`.
|
|
446
|
+
|
|
414
447
|
For `@convex-dev/auth` (React Native):
|
|
415
448
|
```tsx
|
|
416
449
|
import { ConvexProviderWithAuth } from 'kitcn/react';
|
|
@@ -298,6 +298,22 @@ const mutation = useMutation(crpc.user.update.mutationOptions({
|
|
|
298
298
|
|
|
299
299
|
Signature: `crpc.path.mutationOptions(options?)` — standard TanStack mutation options except `mutationFn`.
|
|
300
300
|
|
|
301
|
+
Pass `optimisticUpdate(localStore, args)` to use Convex's optimistic local
|
|
302
|
+
query store. This option is removed before the TanStack options are returned;
|
|
303
|
+
Convex replays it as query data changes and owns rollback when the mutation
|
|
304
|
+
completes.
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
const mutation = useMutation(crpc.todos.rename.mutationOptions({
|
|
308
|
+
optimisticUpdate: (store, args) => {
|
|
309
|
+
const todos = store.getQuery(api.todos.list, {});
|
|
310
|
+
if (todos) store.setQuery(api.todos.list, {}, todos.map((todo) =>
|
|
311
|
+
todo._id === args.id ? { ...todo, title: args.title } : todo
|
|
312
|
+
));
|
|
313
|
+
},
|
|
314
|
+
}));
|
|
315
|
+
```
|
|
316
|
+
|
|
301
317
|
### Mutation Keys
|
|
302
318
|
|
|
303
319
|
```ts
|