kitcn 0.22.1 → 0.24.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/aggregate/index.d.ts +1 -1
- package/dist/auth/nextjs/index.d.ts +1 -1
- package/dist/auth/nextjs/index.js +1 -1
- package/dist/{builder-Dwy6D2QA.js → builder-CsxVc5xC.js} +110 -57
- package/dist/{caller-factory-DHywSoGZ.js → caller-factory-CWa0ELLD.js} +1 -1
- package/dist/cli.mjs +96 -20
- package/dist/crpc/index.d.ts +3 -3
- package/dist/crpc/index.js +3 -3
- package/dist/{http-types-zsMHb_QN.d.ts → http-types-DXOgaerG.d.ts} +46 -1
- package/dist/{middleware-qzHEHaDy.js → middleware-DUd1Sj39.js} +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-JB9kjYsy.js → procedure-caller-DQxnLBS_.js} +2 -2
- package/dist/{procedure-name-exVcmr_p.d.ts → procedure-name-C20pFZnk.d.ts} +21 -7
- package/dist/{query-options-C_eBSIXG.js → query-options-CzRV4G4N.js} +33 -1
- package/dist/ratelimit/index.d.ts +45 -9
- package/dist/ratelimit/index.js +255 -101
- package/dist/react/index.d.ts +9 -6
- package/dist/react/index.js +81 -18
- package/dist/rsc/index.d.ts +4 -7
- package/dist/rsc/index.js +5 -9
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +3 -3
- package/dist/solid/index.d.ts +9 -6
- package/dist/solid/index.js +81 -18
- package/dist/{transformer-C6pGVHqx.js → transformer-yZuBWo8v.js} +45 -1
- package/dist/{types-jNTcza_a.d.ts → types-BHR7ZKKD.d.ts} +1 -1
- package/dist/{where-clause-compiler-B_H3oio5.d.ts → where-clause-compiler-DW6jy2er.d.ts} +59 -59
- package/package.json +1 -1
- package/skills/kitcn/references/features/http.md +26 -1
- package/skills/kitcn/references/features/ratelimit.md +11 -0
- package/skills/kitcn/references/features/react.md +1 -1
- package/skills/kitcn/references/setup/server.md +35 -5
package/dist/rsc/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as defaultIsUnauthorized } from "../error-Bvo7YEhk.js";
|
|
2
2
|
import { n as getFuncRef, r as getFunctionMeta, t as buildMetaIndex } from "../meta-utils-D9K4fICl.js";
|
|
3
|
-
import { o as encodeWire, s as getTransformer } from "../transformer-
|
|
4
|
-
import { n as convexInfiniteQueryOptions, o as executeHttpRequest, r as convexQuery } from "../query-options-
|
|
3
|
+
import { o as encodeWire, s as getTransformer } from "../transformer-yZuBWo8v.js";
|
|
4
|
+
import { c as HTTP_DEFAULT_STALE_TIME, n as convexInfiniteQueryOptions, o as executeHttpRequest, r as convexQuery, u as buildHttpQueryKey } from "../query-options-CzRV4G4N.js";
|
|
5
5
|
import { convexToJson } from "convex/values";
|
|
6
6
|
import { getFunctionName } from "convex/server";
|
|
7
7
|
import { fetchAction, fetchQuery } from "convex/nextjs";
|
|
@@ -14,11 +14,7 @@ import { hashKey } from "@tanstack/query-core";
|
|
|
14
14
|
*/
|
|
15
15
|
function buildHttpQueryOptions(route, routeKey, args) {
|
|
16
16
|
return {
|
|
17
|
-
queryKey:
|
|
18
|
-
"httpQuery",
|
|
19
|
-
routeKey,
|
|
20
|
-
args
|
|
21
|
-
],
|
|
17
|
+
queryKey: buildHttpQueryKey(routeKey, args),
|
|
22
18
|
meta: {
|
|
23
19
|
path: route.path,
|
|
24
20
|
method: route.method
|
|
@@ -59,7 +55,7 @@ function createRecursiveProxy(api, path, meta) {
|
|
|
59
55
|
const routeKey = path.slice(1).join(".");
|
|
60
56
|
const route = meta._http?.[routeKey];
|
|
61
57
|
if (!route) throw new Error(`HTTP route not found: ${routeKey}`);
|
|
62
|
-
return (args
|
|
58
|
+
return (args) => buildHttpQueryOptions(route, routeKey, args);
|
|
63
59
|
}
|
|
64
60
|
if (prop === "queryOptions") return (args = {}, opts) => {
|
|
65
61
|
return convexQuery(getFuncRef(api, path), args, meta, opts);
|
|
@@ -189,7 +185,7 @@ function createHashFn(fallback = hashKey) {
|
|
|
189
185
|
function getServerQueryClientOptions({ getToken, convexSiteUrl, transformer: transformerOptions } = {}) {
|
|
190
186
|
const transformer = getTransformer(transformerOptions);
|
|
191
187
|
return { queries: {
|
|
192
|
-
staleTime:
|
|
188
|
+
staleTime: HTTP_DEFAULT_STALE_TIME,
|
|
193
189
|
queryFn: async ({ queryKey, meta }) => {
|
|
194
190
|
const [type, ...rest] = queryKey;
|
|
195
191
|
const token = await getToken?.();
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as ActionProcedureBuilder, A as CRPCError, B as RuntimeEnv, C as createProcedureHandlerFactory, Ct as zCustomQuery, D as WithHttpRouter, Dt as zodToConvex, E as typedProcedureResolver, Et as zodOutputToConvexFields, F as getCRPCErrorFromUnknown, G as createLazyCaller, H as ConvexContext, I as getHTTPStatusCodeFromError, J as ServerCaller, K as CallerMeta, L as isCRPCError, M as CRPCErrorData, N as CRPC_ERROR_CODES_BY_KEY, O as inferApiInputs, Ot as zodToConvexFields, P as CRPC_ERROR_CODE_TO_HTTP, Q as getGeneratedValue, R as toCRPCError, S as createProcedureCallerFactory, St as zCustomMutation, T as getGeneratedFunctionReference, Tt as zodOutputToConvex, U as createCallerFactory, V as createEnv, W as LazyCaller, X as createApiLeaf, Y as createServerCaller, Z as createGeneratedFunctionReference, _ as ProcedureSchedulableCallerFromRegistry, _t as ZodValidatorFromConvex, a as CreateProcedureCallerFactoryOptions, at as initCRPC, b as createGenericCallerFactory, bt as withSystemFields, c as GeneratedRegistryCallerFactory, ct as extractPathParams, d as GeneratedRegistryHandlerForContext, dt as ConvexValidatorFromZod, et as CRPCFunctionTypeHint, f as ProcedureActionCallerFromRegistry, ft as ConvexValidatorFromZodOutput, g as ProcedureFromFunctionReference, gt as ZodFromValidatorBase, h as ProcedureDefinition, ht as Zid, i as registerProcedureNameLookup, it as createMiddlewareFactory, j as CRPCErrorCode, k as inferApiOutputs, l as GeneratedRegistryCallerForContext, lt as handleHttpError, m as ProcedureCallerFromRegistry, mt as ZCustomCtx, n as ProcedureNameLookup, nt as ProcedureBuilder, o as GeneratedProcedureRegistry, ot as HttpProcedureBuilder, p as ProcedureCaller, pt as CustomBuilder, q as CallerOpts, r as inferProcedureNameFromCallsite, rt as QueryProcedureBuilder, s as GeneratedProcedureRegistryEntry, st as createHttpProcedureBuilder, t as ProcedureNameEntry, tt as MutationProcedureBuilder, u as GeneratedRegistryHandlerFactory, ut as matchPathParams, v as ProcedureScheduleCallerFromRegistry, vt as convexToZod, w as defineProcedure, wt as zid, x as createGenericHandlerFactory, xt as zCustomAction, y as createGeneratedRegistryRuntime, yt as convexToZodFields, z as CreateEnvOptions } from "../procedure-name-
|
|
2
|
-
import {
|
|
1
|
+
import { $ as ActionProcedureBuilder, A as CRPCError, B as RuntimeEnv, C as createProcedureHandlerFactory, Ct as zCustomQuery, D as WithHttpRouter, Dt as zodToConvex, E as typedProcedureResolver, Et as zodOutputToConvexFields, F as getCRPCErrorFromUnknown, G as createLazyCaller, H as ConvexContext, I as getHTTPStatusCodeFromError, J as ServerCaller, K as CallerMeta, L as isCRPCError, M as CRPCErrorData, N as CRPC_ERROR_CODES_BY_KEY, O as inferApiInputs, Ot as zodToConvexFields, P as CRPC_ERROR_CODE_TO_HTTP, Q as getGeneratedValue, R as toCRPCError, S as createProcedureCallerFactory, St as zCustomMutation, T as getGeneratedFunctionReference, Tt as zodOutputToConvex, U as createCallerFactory, V as createEnv, W as LazyCaller, X as createApiLeaf, Y as createServerCaller, Z as createGeneratedFunctionReference, _ as ProcedureSchedulableCallerFromRegistry, _t as ZodValidatorFromConvex, a as CreateProcedureCallerFactoryOptions, at as initCRPC, b as createGenericCallerFactory, bt as withSystemFields, c as GeneratedRegistryCallerFactory, ct as extractPathParams, d as GeneratedRegistryHandlerForContext, dt as ConvexValidatorFromZod, et as CRPCFunctionTypeHint, f as ProcedureActionCallerFromRegistry, ft as ConvexValidatorFromZodOutput, g as ProcedureFromFunctionReference, gt as ZodFromValidatorBase, h as ProcedureDefinition, ht as Zid, i as registerProcedureNameLookup, it as createMiddlewareFactory, j as CRPCErrorCode, k as inferApiOutputs, l as GeneratedRegistryCallerForContext, lt as handleHttpError, m as ProcedureCallerFromRegistry, mt as ZCustomCtx, n as ProcedureNameLookup, nt as ProcedureBuilder, o as GeneratedProcedureRegistry, ot as HttpProcedureBuilder, p as ProcedureCaller, pt as CustomBuilder, q as CallerOpts, r as inferProcedureNameFromCallsite, rt as QueryProcedureBuilder, s as GeneratedProcedureRegistryEntry, st as createHttpProcedureBuilder, t as ProcedureNameEntry, tt as MutationProcedureBuilder, u as GeneratedRegistryHandlerFactory, ut as matchPathParams, v as ProcedureScheduleCallerFromRegistry, vt as convexToZod, w as defineProcedure, wt as zid, x as createGenericHandlerFactory, xt as zCustomAction, y as createGeneratedRegistryRuntime, yt as convexToZodFields, z as CreateEnvOptions } from "../procedure-name-C20pFZnk.js";
|
|
2
|
+
import { A as HttpProcedureBuilderDef, C as extractRouteMap, D as HttpHandlerOpts, E as HttpActionHandler, M as InferHttpInput, N as ProcedureMeta, O as HttpMethod, S as createHttpRouterFactory, T as HttpActionConstructor, _ as CRPCHttpRouter, b as HttpRouterWithHono, j as HttpRouteDefinition, k as HttpProcedure, v as HttpRouterDef, w as CRPCHonoHandler, x as createHttpRouter, y as HttpRouterRecord } from "../http-types-DXOgaerG.js";
|
|
3
3
|
import { a as MergeZodObjects, c as MiddlewareMarker, d as MiddlewareProcedureType, f as MiddlewareResult, g as UnsetMarker, h as Simplify, i as IntersectIfDefined, l as MiddlewareNext, m as ResolveIfSet, n as AnyMiddlewareBuilder, o as MiddlewareBuilder, p as Overwrite, r as GetRawInputFn, s as MiddlewareFunction, t as AnyMiddleware, u as MiddlewareProcedureInfo } from "../types-CnTpHR1F.js";
|
|
4
4
|
import { a as isMutationCtx, c as isSchedulerCtx, d as requireQueryCtx, f as requireRunMutationCtx, i as isActionCtx, l as requireActionCtx, n as RunMutationCtx, o as isQueryCtx, p as requireSchedulerCtx, r as SchedulerCtx, s as isRunMutationCtx, t as GenericCtx, u as requireMutationCtx } from "../context-utils-BBUtBqjN.js";
|
|
5
5
|
export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCErrorData, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GeneratedRegistryCallerFactory, GeneratedRegistryCallerForContext, GeneratedRegistryHandlerFactory, GeneratedRegistryHandlerForContext, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareProcedureInfo, MiddlewareProcedureType, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureNameEntry, ProcedureNameLookup, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, RuntimeEnv, SchedulerCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGeneratedFunctionReference, createGeneratedRegistryRuntime, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getGeneratedFunctionReference, getGeneratedValue, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, inferProcedureNameFromCallsite, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, isSchedulerCtx, matchPathParams, registerProcedureNameLookup, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, requireSchedulerCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
|
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as isMutationCtx, c as isSchedulerCtx, d as requireQueryCtx, f as requireRunMutationCtx, i as isActionCtx, l as requireActionCtx, n as createGeneratedFunctionReference, o as isQueryCtx, p as requireSchedulerCtx, r as getGeneratedValue, s as isRunMutationCtx, t as createApiLeaf, u as requireMutationCtx } from "../api-entry-N3nBOlI2.js";
|
|
2
|
-
import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-
|
|
3
|
-
import { A as zid, C as toCRPCError, D as zCustomAction, E as withSystemFields, M as zodOutputToConvexFields, N as zodToConvex, O as zCustomMutation, P as zodToConvexFields, S as isCRPCError, T as convexToZodFields, _ as CRPCError, a as createMiddlewareFactory, b as getCRPCErrorFromUnknown, c as registerProcedureNameLookup, d as createHttpRouterFactory, f as extractRouteMap, g as matchPathParams, h as handleHttpError, i as QueryProcedureBuilder, j as zodOutputToConvex, k as zCustomQuery, l as HttpRouterWithHono, m as extractPathParams, n as MutationProcedureBuilder, o as initCRPC, p as createHttpProcedureBuilder, r as ProcedureBuilder, s as inferProcedureNameFromCallsite, t as ActionProcedureBuilder, u as createHttpRouter, v as CRPC_ERROR_CODES_BY_KEY, w as convexToZod, x as getHTTPStatusCodeFromError, y as CRPC_ERROR_CODE_TO_HTTP } from "../builder-
|
|
4
|
-
import { a as createProcedureHandlerFactory, c as typedProcedureResolver, i as createProcedureCallerFactory, l as createEnv, n as createGenericCallerFactory, o as defineProcedure, r as createGenericHandlerFactory, s as getGeneratedFunctionReference, t as createGeneratedRegistryRuntime } from "../procedure-caller-
|
|
2
|
+
import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-CWa0ELLD.js";
|
|
3
|
+
import { A as zid, C as toCRPCError, D as zCustomAction, E as withSystemFields, M as zodOutputToConvexFields, N as zodToConvex, O as zCustomMutation, P as zodToConvexFields, S as isCRPCError, T as convexToZodFields, _ as CRPCError, a as createMiddlewareFactory, b as getCRPCErrorFromUnknown, c as registerProcedureNameLookup, d as createHttpRouterFactory, f as extractRouteMap, g as matchPathParams, h as handleHttpError, i as QueryProcedureBuilder, j as zodOutputToConvex, k as zCustomQuery, l as HttpRouterWithHono, m as extractPathParams, n as MutationProcedureBuilder, o as initCRPC, p as createHttpProcedureBuilder, r as ProcedureBuilder, s as inferProcedureNameFromCallsite, t as ActionProcedureBuilder, u as createHttpRouter, v as CRPC_ERROR_CODES_BY_KEY, w as convexToZod, x as getHTTPStatusCodeFromError, y as CRPC_ERROR_CODE_TO_HTTP } from "../builder-CsxVc5xC.js";
|
|
4
|
+
import { a as createProcedureHandlerFactory, c as typedProcedureResolver, i as createProcedureCallerFactory, l as createEnv, n as createGenericCallerFactory, o as defineProcedure, r as createGenericHandlerFactory, s as getGeneratedFunctionReference, t as createGeneratedRegistryRuntime } from "../procedure-caller-DQxnLBS_.js";
|
|
5
5
|
|
|
6
6
|
export { ActionProcedureBuilder, CRPCError, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, HttpRouterWithHono, MutationProcedureBuilder, ProcedureBuilder, QueryProcedureBuilder, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGeneratedFunctionReference, createGeneratedRegistryRuntime, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getGeneratedFunctionReference, getGeneratedValue, getHTTPStatusCodeFromError, handleHttpError, inferProcedureNameFromCallsite, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, isSchedulerCtx, matchPathParams, registerProcedureNameLookup, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, requireSchedulerCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -580,6 +580,12 @@ interface CRPCHttpRouter<TRecord extends HttpRouterRecord> {
|
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
582
|
//#region src/crpc/http-types.d.ts
|
|
583
|
+
/** Exact cache key for one route + args, as stored in the QueryClient */
|
|
584
|
+
type HttpQueryKey = readonly ['httpQuery', string, unknown];
|
|
585
|
+
/** Route-wide prefix key that matches every args variant of one route */
|
|
586
|
+
type HttpQueryPrefixKey = readonly ['httpQuery', string];
|
|
587
|
+
/** Mutation key for HTTP endpoints */
|
|
588
|
+
type HttpMutationKey = readonly ['httpMutation', string];
|
|
583
589
|
/** Error codes that can be returned from HTTP endpoints */
|
|
584
590
|
type HttpErrorCode = 'BAD_REQUEST' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'METHOD_NOT_SUPPORTED' | 'CONFLICT' | 'UNPROCESSABLE_CONTENT' | 'TOO_MANY_REQUESTS' | 'INTERNAL_SERVER_ERROR' | 'UNKNOWN';
|
|
585
591
|
/** HTTP client error */
|
|
@@ -782,9 +788,6 @@ type InferHttpClientArgs<T> = T extends HttpProcedure<infer TInput, infer _TOutp
|
|
|
782
788
|
}> : HttpInputArgs;
|
|
783
789
|
/** Infer output type from HttpProcedure */
|
|
784
790
|
type InferHttpOutput<T> = T extends HttpProcedure<infer _TInput, infer TOutput, infer _TParams, infer _TQuery> ? TOutput extends UnsetMarker ? unknown : TOutput extends z.ZodTypeAny ? z.infer<TOutput> : unknown : unknown;
|
|
785
|
-
/** Query key with args (3-element) or prefix key without args (2-element) for invalidation */
|
|
786
|
-
type HttpQueryKey = readonly ['httpQuery', string, unknown] | readonly ['httpQuery', string];
|
|
787
|
-
type HttpMutationKey = readonly ['httpMutation', string];
|
|
788
791
|
type ReservedQueryOptions$1 = 'queryKey' | 'queryFn';
|
|
789
792
|
type ReservedMutationOptions$1 = 'mutationFn';
|
|
790
793
|
/** Query options for GET HTTP endpoints - compatible with both createQuery and createSuspenseQuery */
|
|
@@ -803,8 +806,8 @@ type HttpMutationOptions<T extends HttpProcedure> = DistributiveOmit<HttpMutatio
|
|
|
803
806
|
* - mutationOptions: For one-time actions like exports (createMutation)
|
|
804
807
|
*/
|
|
805
808
|
type DecorateHttpQuery<T extends HttpProcedure> = {
|
|
806
|
-
queryOptions: keyof InferHttpInput<T> extends never ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : object extends InferHttpInput<T> ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : (args: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T>; /** Get
|
|
807
|
-
queryKey: (args?: InferHttpClientArgs<T>) => HttpQueryKey; /** Get query filter
|
|
809
|
+
queryOptions: keyof InferHttpInput<T> extends never ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : object extends InferHttpInput<T> ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : (args: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T>; /** Get the exact cache key these args are stored under (getQueryData/setQueryData) */
|
|
810
|
+
queryKey: (args?: InferHttpClientArgs<T>) => HttpQueryKey; /** Get query filter matching every args variant (e.g., invalidateQueries) */
|
|
808
811
|
queryFilter: (args?: InferHttpClientArgs<T>, filters?: DistributiveOmit<QueryFilters, 'queryKey'>) => QueryFilters; /** Mutation options for GET endpoints (exports, downloads - no caching) */
|
|
809
812
|
mutationOptions: (opts?: HttpMutationOptions<T>) => HttpMutationOptsReturn<T>; /** Get mutation key for QueryClient methods */
|
|
810
813
|
mutationKey: () => HttpMutationKey;
|
|
@@ -1609,4 +1612,4 @@ declare function useUploadMutationOptions<TGenerateUrlMutation extends FunctionR
|
|
|
1609
1612
|
*/
|
|
1610
1613
|
declare function createVanillaCRPCProxy<TApi extends Record<string, unknown>>(api: TApi, meta: CallerMeta, convexClient: ConvexClient, transformer?: DataTransformerOptions): VanillaCRPCClient<TApi>;
|
|
1611
1614
|
//#endregion
|
|
1612
|
-
export { AuthMutationError, AuthProvider, AuthStore, AuthStoreState, AuthType, Authenticated, CRPCClient, CRPCHttpOptions, ConvexActionOptions, ConvexAuthBridge, ConvexAuthProvider, ConvexAuthProviderProps, ConvexInfiniteQueryOptions, ConvexInfiniteQueryOptionsWithRef, ConvexProvider, ConvexProviderWithAuth, ConvexQueryClient, ConvexQueryClientOptions, ConvexQueryClientSingletonOptions, ConvexQueryOptions, CreateCRPCContextOptions, DecorateAction, DecorateInfiniteQuery, DecorateMutation, DecorateQuery, FetchAccessTokenContext, FetchAccessTokenFn, HttpCRPCClient, HttpCRPCClientFromRouter, type HttpClientOptions, type HttpFormValue, type HttpInputArgs, HttpMutationKey, HttpProxyOptions, HttpQueryKey, HttpRouteInfo, HttpRouteMap, InfiniteQueryOptsParam, MaybeAuthenticated, MaybeUnauthenticated, MetaContext, PaginationState, PaginationStatus, SolidAuthClient, SolidAuthProviderClient, Unauthenticated, Unsubscribe, UseInfiniteQueryResult, VanillaCRPCClient, VanillaHttpCRPCClient, VanillaHttpCRPCClientFromRouter, VanillaQuery, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getAuthType, getConvexQueryClientSingleton, getQueryClientSingleton, isAuthMutationError, useAuth, useAuthGuard, useAuthSkip, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useConvexAuth, useConvexAuthBridge, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useSafeConvexAuth, useUploadMutationOptions };
|
|
1615
|
+
export { AuthMutationError, AuthProvider, AuthStore, AuthStoreState, AuthType, Authenticated, CRPCClient, CRPCHttpOptions, ConvexActionOptions, ConvexAuthBridge, ConvexAuthProvider, ConvexAuthProviderProps, ConvexInfiniteQueryOptions, ConvexInfiniteQueryOptionsWithRef, ConvexProvider, ConvexProviderWithAuth, ConvexQueryClient, ConvexQueryClientOptions, ConvexQueryClientSingletonOptions, ConvexQueryOptions, CreateCRPCContextOptions, DecorateAction, DecorateInfiniteQuery, DecorateMutation, DecorateQuery, FetchAccessTokenContext, FetchAccessTokenFn, HttpCRPCClient, HttpCRPCClientFromRouter, type HttpClientOptions, type HttpFormValue, type HttpInputArgs, type HttpMutationKey, HttpProxyOptions, type HttpQueryKey, type HttpQueryPrefixKey, HttpRouteInfo, HttpRouteMap, InfiniteQueryOptsParam, MaybeAuthenticated, MaybeUnauthenticated, MetaContext, PaginationState, PaginationStatus, SolidAuthClient, SolidAuthProviderClient, Unauthenticated, Unsubscribe, UseInfiniteQueryResult, VanillaCRPCClient, VanillaHttpCRPCClient, VanillaHttpCRPCClientFromRouter, VanillaQuery, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getAuthType, getConvexQueryClientSingleton, getQueryClientSingleton, isAuthMutationError, useAuth, useAuthGuard, useAuthSkip, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useConvexAuth, useConvexAuthBridge, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useSafeConvexAuth, useUploadMutationOptions };
|
package/dist/solid/index.js
CHANGED
|
@@ -427,6 +427,38 @@ function getFunctionMeta(path, source) {
|
|
|
427
427
|
|
|
428
428
|
//#endregion
|
|
429
429
|
//#region src/crpc/http-types.ts
|
|
430
|
+
/**
|
|
431
|
+
* Build the exact cache key for an HTTP route.
|
|
432
|
+
*
|
|
433
|
+
* Missing args normalize to `{}` so the RSC prefetch, the browser observer, and
|
|
434
|
+
* a hand-written `getQueryData` call all hash to the same key. Every producer
|
|
435
|
+
* of an `httpQuery` cache key goes through here.
|
|
436
|
+
*/
|
|
437
|
+
function buildHttpQueryKey(routeKey, args) {
|
|
438
|
+
return [
|
|
439
|
+
"httpQuery",
|
|
440
|
+
routeKey,
|
|
441
|
+
args ?? {}
|
|
442
|
+
];
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Build the route-wide prefix key.
|
|
446
|
+
*
|
|
447
|
+
* Filters match on prefix, so this matches every args variant of the route.
|
|
448
|
+
* Not a cache key: nothing is ever stored under it.
|
|
449
|
+
*/
|
|
450
|
+
function buildHttpQueryPrefixKey(routeKey) {
|
|
451
|
+
return ["httpQuery", routeKey];
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Freshness window for `crpc.http.*` routes, in milliseconds.
|
|
455
|
+
*
|
|
456
|
+
* HTTP routes are a pull model with no push channel, so hydrated data needs a
|
|
457
|
+
* real freshness window or the browser refetches it on mount. The RSC
|
|
458
|
+
* QueryClient reads the same constant, so the server dedupe window and the
|
|
459
|
+
* client freshness window cannot drift apart.
|
|
460
|
+
*/
|
|
461
|
+
const HTTP_DEFAULT_STALE_TIME = 3e4;
|
|
430
462
|
/** HTTP client error */
|
|
431
463
|
var HttpClientError = class extends Error {
|
|
432
464
|
name = "HttpClientError";
|
|
@@ -579,6 +611,7 @@ const DATE_CODEC_TAG = "$date";
|
|
|
579
611
|
*/
|
|
580
612
|
const dateWireCodec = {
|
|
581
613
|
tag: DATE_CODEC_TAG,
|
|
614
|
+
objectsOnly: true,
|
|
582
615
|
isType: (value) => value instanceof Date,
|
|
583
616
|
encode: (value) => value.getTime(),
|
|
584
617
|
decode: (value) => {
|
|
@@ -587,6 +620,40 @@ const dateWireCodec = {
|
|
|
587
620
|
}
|
|
588
621
|
};
|
|
589
622
|
/**
|
|
623
|
+
* One value per primitive `typeof` result, plus the values the object fast path
|
|
624
|
+
* would otherwise skip.
|
|
625
|
+
*/
|
|
626
|
+
const PRIMITIVE_PROBES = [
|
|
627
|
+
void 0,
|
|
628
|
+
null,
|
|
629
|
+
"",
|
|
630
|
+
0,
|
|
631
|
+
NaN,
|
|
632
|
+
false,
|
|
633
|
+
0n,
|
|
634
|
+
Symbol("kitcn.codec.probe"),
|
|
635
|
+
() => void 0
|
|
636
|
+
];
|
|
637
|
+
/**
|
|
638
|
+
* Falsify an `objectsOnly` declaration against representative primitives.
|
|
639
|
+
*
|
|
640
|
+
* Sampling cannot prove a predicate object-only, so it never *infers* the
|
|
641
|
+
* capability - it only rejects the misdeclarations it can catch
|
|
642
|
+
* (`typeof value === 'bigint'`, `value === null`, ...) before they silently
|
|
643
|
+
* drop a value's wire encoding. A codec that throws on a probe owns that.
|
|
644
|
+
*/
|
|
645
|
+
const assertObjectsOnly = (codec) => {
|
|
646
|
+
for (const probe of PRIMITIVE_PROBES) {
|
|
647
|
+
let claimed = false;
|
|
648
|
+
try {
|
|
649
|
+
claimed = codec.isType(probe);
|
|
650
|
+
} catch {
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
if (claimed) throw new Error(`Wire codec '${codec.tag}' declares objectsOnly, but isType() claims ${probe === null ? "null" : typeof probe}. Drop objectsOnly so the codec keeps receiving non-object values.`);
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
590
657
|
* Build a recursive tagged transformer from codecs.
|
|
591
658
|
*/
|
|
592
659
|
const createTaggedTransformer = (codecs) => {
|
|
@@ -594,9 +661,12 @@ const createTaggedTransformer = (codecs) => {
|
|
|
594
661
|
for (const codec of codecs) {
|
|
595
662
|
if (!codec.tag.startsWith("$")) throw new Error(`Invalid wire codec tag '${codec.tag}'. Tags must start with '$'.`);
|
|
596
663
|
if (codecByTag.has(codec.tag)) throw new Error(`Duplicate wire codec tag '${codec.tag}'.`);
|
|
664
|
+
if (codec.objectsOnly) assertObjectsOnly(codec);
|
|
597
665
|
codecByTag.set(codec.tag, codec);
|
|
598
666
|
}
|
|
667
|
+
const skipNonObjects = codecs.every((codec) => codec.objectsOnly === true);
|
|
599
668
|
const serialize = (value) => {
|
|
669
|
+
if (skipNonObjects && (value === null || typeof value !== "object")) return value;
|
|
600
670
|
for (const codec of codecs) if (codec.isType(value)) return {
|
|
601
671
|
[CODEC_MARKER_KEY]: CODEC_MARKER_VALUE,
|
|
602
672
|
[CODEC_TAG_KEY]: codec.tag,
|
|
@@ -630,6 +700,7 @@ const createTaggedTransformer = (codecs) => {
|
|
|
630
700
|
return value;
|
|
631
701
|
};
|
|
632
702
|
const deserialize = (value) => {
|
|
703
|
+
if (value === null || typeof value !== "object") return value;
|
|
633
704
|
if (Array.isArray(value)) {
|
|
634
705
|
let result;
|
|
635
706
|
for (let index = 0; index < value.length; index += 1) {
|
|
@@ -695,16 +766,20 @@ const normalizeCustomTransformer = (transformer) => {
|
|
|
695
766
|
* - deserialize: default(Date) -> user
|
|
696
767
|
*/
|
|
697
768
|
const composeWithDefault = (transformer) => {
|
|
698
|
-
if (!transformer) return defaultCRPCTransformer;
|
|
769
|
+
if (!transformer || transformer === defaultCRPCTransformer) return defaultCRPCTransformer;
|
|
699
770
|
return {
|
|
700
771
|
serialize: (value) => defaultCRPCTransformer.serialize(transformer.serialize(value)),
|
|
701
772
|
deserialize: (value) => transformer.deserialize(defaultCRPCTransformer.deserialize(value))
|
|
702
773
|
};
|
|
703
774
|
};
|
|
704
775
|
const transformerCache = /* @__PURE__ */ new WeakMap();
|
|
776
|
+
transformerCache.set(DEFAULT_COMBINED_TRANSFORMER, DEFAULT_COMBINED_TRANSFORMER);
|
|
705
777
|
/**
|
|
706
778
|
* Normalize transformer config to split input/output shape.
|
|
707
779
|
* User transformers are additive and always composed with default Date handling.
|
|
780
|
+
*
|
|
781
|
+
* Idempotent: passing a transformer this function already resolved returns it
|
|
782
|
+
* unchanged.
|
|
708
783
|
*/
|
|
709
784
|
const getTransformer = (transformer) => {
|
|
710
785
|
if (!transformer) return DEFAULT_COMBINED_TRANSFORMER;
|
|
@@ -717,6 +792,7 @@ const getTransformer = (transformer) => {
|
|
|
717
792
|
output: composeWithDefault(custom?.output)
|
|
718
793
|
};
|
|
719
794
|
transformerCache.set(cacheKey, resolved);
|
|
795
|
+
transformerCache.set(resolved, resolved);
|
|
720
796
|
return resolved;
|
|
721
797
|
};
|
|
722
798
|
/**
|
|
@@ -781,12 +857,9 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
781
857
|
if (!route) throw new Error(`Unknown HTTP procedure: ${routeKey}`);
|
|
782
858
|
if (route.method !== "GET") throw new Error(`queryOptions is only available for GET endpoints, got ${route.method} for ${routeKey}`);
|
|
783
859
|
return (args, queryOpts) => ({
|
|
860
|
+
staleTime: HTTP_DEFAULT_STALE_TIME,
|
|
784
861
|
...queryOpts,
|
|
785
|
-
queryKey:
|
|
786
|
-
"httpQuery",
|
|
787
|
-
routeKey,
|
|
788
|
-
args
|
|
789
|
-
],
|
|
862
|
+
queryKey: buildHttpQueryKey(routeKey, args),
|
|
790
863
|
queryFn: async () => {
|
|
791
864
|
try {
|
|
792
865
|
return await executeHttpRequest({
|
|
@@ -805,22 +878,12 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
805
878
|
}
|
|
806
879
|
});
|
|
807
880
|
}
|
|
808
|
-
if (prop === "queryKey") return (args) =>
|
|
809
|
-
return args !== void 0 && !(typeof args === "object" && args !== null && Object.keys(args).length === 0) ? [
|
|
810
|
-
"httpQuery",
|
|
811
|
-
routeKey,
|
|
812
|
-
args
|
|
813
|
-
] : ["httpQuery", routeKey];
|
|
814
|
-
};
|
|
881
|
+
if (prop === "queryKey") return (args) => buildHttpQueryKey(routeKey, args);
|
|
815
882
|
if (prop === "queryFilter") return (args, filters) => {
|
|
816
883
|
const hasArgs = args !== void 0 && !(typeof args === "object" && args !== null && Object.keys(args).length === 0);
|
|
817
884
|
return {
|
|
818
885
|
...filters,
|
|
819
|
-
queryKey: hasArgs ?
|
|
820
|
-
"httpQuery",
|
|
821
|
-
routeKey,
|
|
822
|
-
args
|
|
823
|
-
] : ["httpQuery", routeKey]
|
|
886
|
+
queryKey: hasArgs ? buildHttpQueryKey(routeKey, args) : buildHttpQueryPrefixKey(routeKey)
|
|
824
887
|
};
|
|
825
888
|
};
|
|
826
889
|
if (prop === "mutationOptions") {
|
|
@@ -27,6 +27,7 @@ const DATE_CODEC_TAG = "$date";
|
|
|
27
27
|
*/
|
|
28
28
|
const dateWireCodec = {
|
|
29
29
|
tag: DATE_CODEC_TAG,
|
|
30
|
+
objectsOnly: true,
|
|
30
31
|
isType: (value) => value instanceof Date,
|
|
31
32
|
encode: (value) => value.getTime(),
|
|
32
33
|
decode: (value) => {
|
|
@@ -35,6 +36,40 @@ const dateWireCodec = {
|
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
39
|
+
* One value per primitive `typeof` result, plus the values the object fast path
|
|
40
|
+
* would otherwise skip.
|
|
41
|
+
*/
|
|
42
|
+
const PRIMITIVE_PROBES = [
|
|
43
|
+
void 0,
|
|
44
|
+
null,
|
|
45
|
+
"",
|
|
46
|
+
0,
|
|
47
|
+
NaN,
|
|
48
|
+
false,
|
|
49
|
+
0n,
|
|
50
|
+
Symbol("kitcn.codec.probe"),
|
|
51
|
+
() => void 0
|
|
52
|
+
];
|
|
53
|
+
/**
|
|
54
|
+
* Falsify an `objectsOnly` declaration against representative primitives.
|
|
55
|
+
*
|
|
56
|
+
* Sampling cannot prove a predicate object-only, so it never *infers* the
|
|
57
|
+
* capability - it only rejects the misdeclarations it can catch
|
|
58
|
+
* (`typeof value === 'bigint'`, `value === null`, ...) before they silently
|
|
59
|
+
* drop a value's wire encoding. A codec that throws on a probe owns that.
|
|
60
|
+
*/
|
|
61
|
+
const assertObjectsOnly = (codec) => {
|
|
62
|
+
for (const probe of PRIMITIVE_PROBES) {
|
|
63
|
+
let claimed = false;
|
|
64
|
+
try {
|
|
65
|
+
claimed = codec.isType(probe);
|
|
66
|
+
} catch {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (claimed) throw new Error(`Wire codec '${codec.tag}' declares objectsOnly, but isType() claims ${probe === null ? "null" : typeof probe}. Drop objectsOnly so the codec keeps receiving non-object values.`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
38
73
|
* Build a recursive tagged transformer from codecs.
|
|
39
74
|
*/
|
|
40
75
|
const createTaggedTransformer = (codecs) => {
|
|
@@ -42,9 +77,12 @@ const createTaggedTransformer = (codecs) => {
|
|
|
42
77
|
for (const codec of codecs) {
|
|
43
78
|
if (!codec.tag.startsWith("$")) throw new Error(`Invalid wire codec tag '${codec.tag}'. Tags must start with '$'.`);
|
|
44
79
|
if (codecByTag.has(codec.tag)) throw new Error(`Duplicate wire codec tag '${codec.tag}'.`);
|
|
80
|
+
if (codec.objectsOnly) assertObjectsOnly(codec);
|
|
45
81
|
codecByTag.set(codec.tag, codec);
|
|
46
82
|
}
|
|
83
|
+
const skipNonObjects = codecs.every((codec) => codec.objectsOnly === true);
|
|
47
84
|
const serialize = (value) => {
|
|
85
|
+
if (skipNonObjects && (value === null || typeof value !== "object")) return value;
|
|
48
86
|
for (const codec of codecs) if (codec.isType(value)) return {
|
|
49
87
|
[CODEC_MARKER_KEY]: CODEC_MARKER_VALUE,
|
|
50
88
|
[CODEC_TAG_KEY]: codec.tag,
|
|
@@ -78,6 +116,7 @@ const createTaggedTransformer = (codecs) => {
|
|
|
78
116
|
return value;
|
|
79
117
|
};
|
|
80
118
|
const deserialize = (value) => {
|
|
119
|
+
if (value === null || typeof value !== "object") return value;
|
|
81
120
|
if (Array.isArray(value)) {
|
|
82
121
|
let result;
|
|
83
122
|
for (let index = 0; index < value.length; index += 1) {
|
|
@@ -153,16 +192,20 @@ const normalizeCustomTransformer = (transformer) => {
|
|
|
153
192
|
* - deserialize: default(Date) -> user
|
|
154
193
|
*/
|
|
155
194
|
const composeWithDefault = (transformer) => {
|
|
156
|
-
if (!transformer) return defaultCRPCTransformer;
|
|
195
|
+
if (!transformer || transformer === defaultCRPCTransformer) return defaultCRPCTransformer;
|
|
157
196
|
return {
|
|
158
197
|
serialize: (value) => defaultCRPCTransformer.serialize(transformer.serialize(value)),
|
|
159
198
|
deserialize: (value) => transformer.deserialize(defaultCRPCTransformer.deserialize(value))
|
|
160
199
|
};
|
|
161
200
|
};
|
|
162
201
|
const transformerCache = /* @__PURE__ */ new WeakMap();
|
|
202
|
+
transformerCache.set(DEFAULT_COMBINED_TRANSFORMER, DEFAULT_COMBINED_TRANSFORMER);
|
|
163
203
|
/**
|
|
164
204
|
* Normalize transformer config to split input/output shape.
|
|
165
205
|
* User transformers are additive and always composed with default Date handling.
|
|
206
|
+
*
|
|
207
|
+
* Idempotent: passing a transformer this function already resolved returns it
|
|
208
|
+
* unchanged.
|
|
166
209
|
*/
|
|
167
210
|
const getTransformer = (transformer) => {
|
|
168
211
|
if (!transformer) return DEFAULT_COMBINED_TRANSFORMER;
|
|
@@ -175,6 +218,7 @@ const getTransformer = (transformer) => {
|
|
|
175
218
|
output: composeWithDefault(custom?.output)
|
|
176
219
|
};
|
|
177
220
|
transformerCache.set(cacheKey, resolved);
|
|
221
|
+
transformerCache.set(resolved, resolved);
|
|
178
222
|
return resolved;
|
|
179
223
|
};
|
|
180
224
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as CombinedDataTransformer, r as HttpClientError } from "./http-types-DXOgaerG.js";
|
|
2
2
|
import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
|
|
3
3
|
|
|
4
4
|
//#region src/crpc/http-client.d.ts
|