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/orm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-
|
|
1
|
+
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-DW6jy2er.js";
|
|
2
2
|
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.js";
|
|
3
3
|
import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CNo9ffvI.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as decodeWire, o as encodeWire } from "./transformer-
|
|
2
|
-
import { _ as CRPCError } from "./builder-
|
|
1
|
+
import { i as decodeWire, o as encodeWire } from "./transformer-yZuBWo8v.js";
|
|
2
|
+
import { _ as CRPCError } from "./builder-CsxVc5xC.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/server/env.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as VRequired } from "./validators-BhsByJeg.js";
|
|
2
|
-
import {
|
|
2
|
+
import { A as HttpProcedureBuilderDef, D as HttpHandlerOpts, L as DataTransformerOptions, N as ProcedureMeta, O as HttpMethod, W as getTransformer, _ as CRPCHttpRouter, f as InferHttpInput, k as HttpProcedure, p as InferHttpOutput, y as HttpRouterRecord } from "./http-types-DXOgaerG.js";
|
|
3
3
|
import { g as UnsetMarker, i as IntersectIfDefined, o as MiddlewareBuilder, p as Overwrite$1, s as MiddlewareFunction, t as AnyMiddleware } from "./types-CnTpHR1F.js";
|
|
4
4
|
import { ConvexError, GenericId, GenericValidator, ObjectType, OptionalProperty, PropertyValidators, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion, Validator, Value as Value$1 } from "convex/values";
|
|
5
5
|
import { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionReference, FunctionReturnType, FunctionVisibility, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, MutationBuilder, QueryBuilder, RegisteredAction, RegisteredMutation, RegisteredQuery, TableNamesInDataModel } from "convex/server";
|
|
@@ -497,14 +497,17 @@ declare function withSystemFields<Table extends string, T extends {
|
|
|
497
497
|
* arguments. If the customization requires arguments, however, the resulting
|
|
498
498
|
* builder will require argument validation too.
|
|
499
499
|
*/
|
|
500
|
-
type CustomBuilder<FuncType extends 'query' | 'mutation' | 'action', CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, InputCtx, Visibility extends FunctionVisibility, ExtraArgs extends Record<string, any>> = <ArgsValidator extends ZodFields | zCore.$ZodObject<any> | void, ReturnsZodValidator extends zCore.$ZodType | ZodFields | void = void, ReturnValue extends
|
|
500
|
+
type CustomBuilder<FuncType extends 'query' | 'mutation' | 'action', CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, InputCtx, Visibility extends FunctionVisibility, ExtraArgs extends Record<string, any>> = <ArgsValidator extends ZodFields | zCore.$ZodObject<any> | void, ReturnsZodValidator extends zCore.$ZodType | ZodFields | void = void, SkipZodReturnsValidation extends boolean = false, ReturnValue extends ReturnValueForHandler<ReturnsZodValidator, SkipZodReturnsValidation> = any>(func: ({
|
|
501
501
|
/**
|
|
502
502
|
* Specify the arguments to the function as a Zod validator.
|
|
503
503
|
*/
|
|
504
504
|
args?: ArgsValidator;
|
|
505
505
|
handler: (ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<ArgsOutput<ArgsValidator>, CustomMadeArgs>) => ReturnValue;
|
|
506
506
|
/**
|
|
507
|
-
* Validates the value returned by the function
|
|
507
|
+
* Validates the value returned by the function, and declares the
|
|
508
|
+
* Convex `returns` validator from the schema's output type. The Zod
|
|
509
|
+
* parse runs first, so the handler returns the schema's *input* type
|
|
510
|
+
* and the client receives its *output* type.
|
|
508
511
|
* Note: you can't pass an object directly without wrapping it
|
|
509
512
|
* in `z.object()`.
|
|
510
513
|
*/
|
|
@@ -514,12 +517,23 @@ type CustomBuilder<FuncType extends 'query' | 'mutation' | 'action', CustomArgsV
|
|
|
514
517
|
* in case you're seeing performance issues with validating twice.
|
|
515
518
|
*/
|
|
516
519
|
skipConvexValidation?: boolean;
|
|
517
|
-
|
|
520
|
+
/**
|
|
521
|
+
* If true, `returns` only declares the Convex validator and the return
|
|
522
|
+
* type - the Zod parse is skipped. The handler's value reaches Convex
|
|
523
|
+
* unchanged, so it must already be the schema's *output* type, which
|
|
524
|
+
* is what the handler is then typed as.
|
|
525
|
+
*
|
|
526
|
+
* For callers that already parse the response themselves. Combined
|
|
527
|
+
* with `skipConvexValidation`, nothing validates the return value.
|
|
528
|
+
*/
|
|
529
|
+
skipZodReturnsValidation?: SkipZodReturnsValidation;
|
|
530
|
+
} & { [key in keyof ExtraArgs as key extends 'args' | 'handler' | 'skipConvexValidation' | 'skipZodReturnsValidation' | 'returns' ? never : key]: ExtraArgs[key] }) | ((ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<ArgsOutput<ArgsValidator>, CustomMadeArgs>) => ReturnValue)) => Registration<FuncType, Visibility, ArgsArrayToObject<CustomArgsValidator extends Record<string, never> ? ArgsInput<ArgsValidator> : ArgsInput<ArgsValidator> extends [infer A] ? [Expand<A & ObjectType<CustomArgsValidator>>] : [ObjectType<CustomArgsValidator>]>, ReturnsZodValidator extends void ? ReturnValue : ReturnValueOutput<ReturnsZodValidator>>;
|
|
518
531
|
type ArgsForHandlerType<OneOrZeroArgs extends [] | [Record<string, any>], CustomMadeArgs extends Record<string, any>> = CustomMadeArgs extends Record<string, never> ? OneOrZeroArgs : OneOrZeroArgs extends [infer A] ? [Expand<A & CustomMadeArgs>] : [CustomMadeArgs];
|
|
519
532
|
type NullToUndefinedOrNull<T> = T extends null ? T | undefined | void : T;
|
|
520
533
|
type Returns<T> = Promise<NullToUndefinedOrNull<T>> | NullToUndefinedOrNull<T>;
|
|
521
534
|
type ReturnValueInput<ReturnsValidator extends zCore.$ZodType | ZodFields | void> = [ReturnsValidator] extends [zCore.$ZodType] ? Returns<zCore.input<ReturnsValidator>> : [ReturnsValidator] extends [ZodFields] ? Returns<zCore.input<zCore.$ZodObject<ReturnsValidator>>> : any;
|
|
522
535
|
type ReturnValueOutput<ReturnsValidator extends zCore.$ZodType | ZodFields | void> = [ReturnsValidator] extends [zCore.$ZodType] ? Returns<zCore.output<ReturnsValidator>> : [ReturnsValidator] extends [ZodFields] ? Returns<zCore.output<zCore.$ZodObject<ReturnsValidator, zCore.$strict>>> : any;
|
|
536
|
+
type ReturnValueForHandler<ReturnsValidator extends zCore.$ZodType | ZodFields | void, SkipZodReturnsValidation extends boolean> = SkipZodReturnsValidation extends true ? ReturnValueOutput<ReturnsValidator> : ReturnValueInput<ReturnsValidator>;
|
|
523
537
|
type ArgsInput<ArgsValidator extends ZodFields | zCore.$ZodObject<any> | void> = [ArgsValidator] extends [zCore.$ZodObject<any>] ? [zCore.input<ArgsValidator>] : ArgsValidator extends Record<string, never> ? [{}] : [ArgsValidator] extends [Record<string, z$1.ZodTypeAny>] ? [zCore.input<zCore.$ZodObject<ArgsValidator, zCore.$strict>>] : OneArgArray;
|
|
524
538
|
type ArgsOutput<ArgsValidator extends ZodFields | zCore.$ZodObject<any> | void> = [ArgsValidator] extends [zCore.$ZodObject<any>] ? [zCore.output<ArgsValidator>] : [ArgsValidator] extends [ZodFields] ? [zCore.output<zCore.$ZodObject<ArgsValidator, zCore.$strict>>] : OneArgArray;
|
|
525
539
|
type Overwrite<T, U> = Omit<T, keyof U> & U;
|
|
@@ -814,7 +828,7 @@ declare class QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides extend
|
|
|
814
828
|
query<TResult>(handler: (opts: {
|
|
815
829
|
ctx: Overwrite$1<TContext, TContextOverrides>;
|
|
816
830
|
input: InferInput<TInput>;
|
|
817
|
-
}) => Promise<TOutput extends z.ZodTypeAny ? z.
|
|
831
|
+
}) => Promise<TOutput extends z.ZodTypeAny ? z.input<TOutput> : TResult>): Record<string, unknown> & CRPCFunctionTypeHint<InferClientInput<TClientInput>, TOutput extends z.ZodTypeAny ? z.output<TOutput> : TResult>;
|
|
818
832
|
/** Mark as internal - returns chainable builder using internal function */
|
|
819
833
|
internal(): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TOutput, TMeta>;
|
|
820
834
|
}
|
|
@@ -842,7 +856,7 @@ declare class MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides ext
|
|
|
842
856
|
mutation<TResult>(handler: (opts: {
|
|
843
857
|
ctx: Overwrite$1<TContext, TContextOverrides>;
|
|
844
858
|
input: InferInput<TInput>;
|
|
845
|
-
}) => Promise<TOutput extends z.ZodTypeAny ? z.
|
|
859
|
+
}) => Promise<TOutput extends z.ZodTypeAny ? z.input<TOutput> : TResult>): Record<string, unknown> & CRPCFunctionTypeHint<InferClientInput<TInput>, TOutput extends z.ZodTypeAny ? z.output<TOutput> : TResult>;
|
|
846
860
|
/** Mark as internal - returns chainable builder using internal function */
|
|
847
861
|
internal(): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
848
862
|
}
|
|
@@ -866,7 +880,7 @@ declare class ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides exten
|
|
|
866
880
|
action<TResult>(handler: (opts: {
|
|
867
881
|
ctx: Overwrite$1<TContext, TContextOverrides>;
|
|
868
882
|
input: InferInput<TInput>;
|
|
869
|
-
}) => Promise<TOutput extends z.ZodTypeAny ? z.
|
|
883
|
+
}) => Promise<TOutput extends z.ZodTypeAny ? z.input<TOutput> : TResult>): Record<string, unknown> & CRPCFunctionTypeHint<InferClientInput<TInput>, TOutput extends z.ZodTypeAny ? z.output<TOutput> : TResult>;
|
|
870
884
|
/** Mark as internal - returns chainable builder using internal function */
|
|
871
885
|
internal(): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
872
886
|
}
|
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import { getFunctionName } from "convex/server";
|
|
2
2
|
|
|
3
3
|
//#region src/crpc/http-types.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build the exact cache key for an HTTP route.
|
|
6
|
+
*
|
|
7
|
+
* Missing args normalize to `{}` so the RSC prefetch, the browser observer, and
|
|
8
|
+
* a hand-written `getQueryData` call all hash to the same key. Every producer
|
|
9
|
+
* of an `httpQuery` cache key goes through here.
|
|
10
|
+
*/
|
|
11
|
+
function buildHttpQueryKey(routeKey, args) {
|
|
12
|
+
return [
|
|
13
|
+
"httpQuery",
|
|
14
|
+
routeKey,
|
|
15
|
+
args ?? {}
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build the route-wide prefix key.
|
|
20
|
+
*
|
|
21
|
+
* Filters match on prefix, so this matches every args variant of the route.
|
|
22
|
+
* Not a cache key: nothing is ever stored under it.
|
|
23
|
+
*/
|
|
24
|
+
function buildHttpQueryPrefixKey(routeKey) {
|
|
25
|
+
return ["httpQuery", routeKey];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Freshness window for `crpc.http.*` routes, in milliseconds.
|
|
29
|
+
*
|
|
30
|
+
* HTTP routes are a pull model with no push channel, so hydrated data needs a
|
|
31
|
+
* real freshness window or the browser refetches it on mount. The RSC
|
|
32
|
+
* QueryClient reads the same constant, so the server dedupe window and the
|
|
33
|
+
* client freshness window cannot drift apart.
|
|
34
|
+
*/
|
|
35
|
+
const HTTP_DEFAULT_STALE_TIME = 3e4;
|
|
4
36
|
/** HTTP client error */
|
|
5
37
|
var HttpClientError = class extends Error {
|
|
6
38
|
name = "HttpClientError";
|
|
@@ -244,4 +276,4 @@ function convexInfiniteQueryOptions(funcRef, args, opts = {}, meta) {
|
|
|
244
276
|
}
|
|
245
277
|
|
|
246
278
|
//#endregion
|
|
247
|
-
export { buildSearchParams as a,
|
|
279
|
+
export { buildSearchParams as a, HTTP_DEFAULT_STALE_TIME as c, buildHttpQueryPrefixKey as d, isHttpClientError as f, RESERVED_KEYS as i, HttpClientError as l, convexInfiniteQueryOptions as n, executeHttpRequest as o, convexQuery as r, replaceUrlParam as s, convexAction as t, buildHttpQueryKey as u };
|
|
@@ -127,6 +127,7 @@ type ConvexQueryBuilder = {
|
|
|
127
127
|
withIndex: (name: any, cb: any) => {
|
|
128
128
|
unique: () => Promise<any>;
|
|
129
129
|
collect: () => Promise<any[]>;
|
|
130
|
+
take: (limit: number) => Promise<any[]>;
|
|
130
131
|
};
|
|
131
132
|
};
|
|
132
133
|
type ConvexRatelimitDbReader = {
|
|
@@ -176,17 +177,36 @@ declare function calculateRatelimit(state: RatelimitState | null, algorithm: Res
|
|
|
176
177
|
*/
|
|
177
178
|
declare function snapshotToState(snapshot: RatelimitSnapshot): RatelimitState;
|
|
178
179
|
//#endregion
|
|
180
|
+
//#region src/ratelimit/maintenance.d.ts
|
|
181
|
+
type CleanupRatelimitStateOptions = {
|
|
182
|
+
before: number;
|
|
183
|
+
limit?: number;
|
|
184
|
+
};
|
|
185
|
+
type CleanupRatelimitStateResult = {
|
|
186
|
+
deleted: number;
|
|
187
|
+
hasMore: boolean;
|
|
188
|
+
};
|
|
189
|
+
/** Deletes one on-demand batch of state older than the caller-owned cutoff. */
|
|
190
|
+
declare function cleanupRatelimitState(db: ConvexRatelimitDbWriter, options: CleanupRatelimitStateOptions): Promise<CleanupRatelimitStateResult>;
|
|
191
|
+
//#endregion
|
|
179
192
|
//#region src/ratelimit/plugin.d.ts
|
|
180
193
|
type MaybePromise<T> = T | Promise<T>;
|
|
181
194
|
type RatelimitBuckets = Record<string, Record<string, ResolvedAlgorithm>>;
|
|
182
195
|
type BucketName<TBuckets extends RatelimitBuckets> = Extract<keyof TBuckets, string>;
|
|
183
196
|
type TierName<TBuckets extends RatelimitBuckets> = Extract<keyof TBuckets[BucketName<TBuckets>], string>;
|
|
184
|
-
|
|
197
|
+
/** What is known before request signals are resolved. */
|
|
198
|
+
type RatelimitRequestArgs<TCtx, TMeta extends object, TUser, TBuckets extends RatelimitBuckets> = {
|
|
185
199
|
ctx: TCtx;
|
|
186
200
|
meta: TMeta;
|
|
187
201
|
user: TUser;
|
|
188
202
|
bucket: BucketName<TBuckets>;
|
|
189
203
|
tier: TierName<TBuckets>;
|
|
204
|
+
};
|
|
205
|
+
/** Signals are resolved once per request and reused as the identifier input. */
|
|
206
|
+
type RatelimitIdentifierArgs<TCtx, TMeta extends object, TUser, TBuckets extends RatelimitBuckets> = RatelimitRequestArgs<TCtx, TMeta, TUser, TBuckets> & {
|
|
207
|
+
signals: LimitRequest | undefined;
|
|
208
|
+
};
|
|
209
|
+
type RatelimitResolvedArgs<TCtx, TMeta extends object, TUser, TBuckets extends RatelimitBuckets> = RatelimitIdentifierArgs<TCtx, TMeta, TUser, TBuckets> & {
|
|
190
210
|
identifier: string;
|
|
191
211
|
};
|
|
192
212
|
type RatelimitPluginOptions<TCtx = unknown, TMeta extends object = object, TUser = unknown, TBuckets extends RatelimitBuckets = RatelimitBuckets> = {
|
|
@@ -199,18 +219,34 @@ type RatelimitPluginOptions<TCtx = unknown, TMeta extends object = object, TUser
|
|
|
199
219
|
ctx: TCtx;
|
|
200
220
|
meta: TMeta;
|
|
201
221
|
}) => MaybePromise<TUser>;
|
|
202
|
-
getIdentifier: (args: {
|
|
203
|
-
ctx: TCtx;
|
|
204
|
-
meta: TMeta;
|
|
205
|
-
user: TUser;
|
|
206
|
-
bucket: BucketName<TBuckets>;
|
|
207
|
-
}) => MaybePromise<string>;
|
|
208
222
|
getTier: (user: TUser) => MaybePromise<TierName<TBuckets>>;
|
|
209
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Resolved once per request, before `getIdentifier`, and reused for the limit
|
|
225
|
+
* call. Read request metadata here rather than in `getIdentifier`, so a
|
|
226
|
+
* guarded mutation pays at most one `ctx.meta.getRequestMetadata()` syscall.
|
|
227
|
+
*/
|
|
228
|
+
getSignals: (args: RatelimitRequestArgs<TCtx, TMeta, TUser, TBuckets>) => MaybePromise<LimitRequest | undefined>;
|
|
229
|
+
/**
|
|
230
|
+
* The rate-limit partition key. Everything sharing a value shares one budget
|
|
231
|
+
* and one `ratelimitState` document, so key unauthenticated traffic by
|
|
232
|
+
* `signals.ip` rather than a constant.
|
|
233
|
+
*/
|
|
234
|
+
getIdentifier: (args: RatelimitIdentifierArgs<TCtx, TMeta, TUser, TBuckets>) => MaybePromise<string>;
|
|
210
235
|
prefix?: string | ((args: RatelimitResolvedArgs<TCtx, TMeta, TUser, TBuckets>) => MaybePromise<string>);
|
|
211
236
|
failureMode?: 'closed' | 'open';
|
|
212
237
|
enableProtection?: boolean;
|
|
213
238
|
denyListThreshold?: number;
|
|
239
|
+
denyList?: RatelimitConfig['denyList'];
|
|
240
|
+
dynamicLimits?: boolean;
|
|
241
|
+
timeout?: number;
|
|
242
|
+
/**
|
|
243
|
+
* Block cache backing store. The plugin builds one `Ratelimit` per guarded
|
|
244
|
+
* mutation, so the default per-instance cache never outlives a request. Pass
|
|
245
|
+
* a longer-lived `Map` only if you accept that a stale block can deny a
|
|
246
|
+
* request a refilled shard could have served, and that a mutation replayed
|
|
247
|
+
* after an OCC conflict can observe entries its first attempt wrote.
|
|
248
|
+
*/
|
|
249
|
+
ephemeralCache?: RatelimitConfig['ephemeralCache'];
|
|
214
250
|
message?: string | ((args: RatelimitResolvedArgs<TCtx, TMeta, TUser, TBuckets>) => MaybePromise<string>);
|
|
215
251
|
};
|
|
216
252
|
type AnyRatelimitPluginOptions = RatelimitPluginOptions<any, any, any, any>;
|
|
@@ -285,4 +321,4 @@ declare const HOUR: number;
|
|
|
285
321
|
declare const DAY: number;
|
|
286
322
|
declare const WEEK: number;
|
|
287
323
|
//#endregion
|
|
288
|
-
export { type CheckRequest, type ConvexQueryBuilder, type ConvexRatelimitDbReader, type ConvexRatelimitDbWriter, DAY, type Duration, type DurationString, type DurationUnit, type DynamicLimitResponse, type EvaluationResult, type FixedWindowAlgorithm, HOUR, type HookAPIOptions, type HookCheckValue, type LimitRequest, MINUTE, RATE_LIMIT_DYNAMIC_TABLE, RATE_LIMIT_HIT_TABLE, RATE_LIMIT_STATE_TABLE, Ratelimit, type RatelimitConfig, RatelimitPlugin, type RatelimitPluginOptions, type RatelimitReason, type RatelimitResponse, type RatelimitRow, type RatelimitShardState, type RatelimitSnapshot, type RatelimitState, type RatelimitStoredState, type RemainingResponse, type ResolvedAlgorithm, SECOND, type SlidingWindowAlgorithm, type TokenBucketAlgorithm, WEEK, applyDynamicLimit, calculateRatelimit, fixedWindow, slidingWindow, snapshotToState, toMs, tokenBucket };
|
|
324
|
+
export { type CheckRequest, type CleanupRatelimitStateOptions, type CleanupRatelimitStateResult, type ConvexQueryBuilder, type ConvexRatelimitDbReader, type ConvexRatelimitDbWriter, DAY, type Duration, type DurationString, type DurationUnit, type DynamicLimitResponse, type EvaluationResult, type FixedWindowAlgorithm, HOUR, type HookAPIOptions, type HookCheckValue, type LimitRequest, MINUTE, RATE_LIMIT_DYNAMIC_TABLE, RATE_LIMIT_HIT_TABLE, RATE_LIMIT_STATE_TABLE, Ratelimit, type RatelimitConfig, RatelimitPlugin, type RatelimitPluginOptions, type RatelimitReason, type RatelimitResponse, type RatelimitRow, type RatelimitShardState, type RatelimitSnapshot, type RatelimitState, type RatelimitStoredState, type RemainingResponse, type ResolvedAlgorithm, SECOND, type SlidingWindowAlgorithm, type TokenBucketAlgorithm, WEEK, applyDynamicLimit, calculateRatelimit, cleanupRatelimitState, fixedWindow, slidingWindow, snapshotToState, toMs, tokenBucket };
|