kitcn 0.12.18 → 0.12.20

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.
Files changed (32) hide show
  1. package/dist/aggregate/index.d.ts +1 -1
  2. package/dist/{api-entry-BckXqaLb.js → api-entry-BUAh_K4k.js} +10 -2
  3. package/dist/auth/generated/index.d.ts +1 -1
  4. package/dist/auth/index.d.ts +2 -2
  5. package/dist/auth/index.js +1 -1
  6. package/dist/auth/nextjs/index.d.ts +1 -1
  7. package/dist/{backend-core-CGjsBIOp.mjs → backend-core-C0uwGXLx.mjs} +107 -14
  8. package/dist/{builder-Bh18Y2t0.js → builder-Cb6gloDB.js} +160 -6
  9. package/dist/cli.mjs +1 -1
  10. package/dist/{context-utils-HPC5nXzx.d.ts → context-utils-BvWW0Ilq.d.ts} +8 -1
  11. package/dist/crpc/index.d.ts +2 -2
  12. package/dist/{generated-contract-disabled-Dzx2IRId.d.ts → generated-contract-disabled-21YxPk5W.d.ts} +1 -1
  13. package/dist/{http-types-BS63Nsug.d.ts → http-types-BLFA9zS7.d.ts} +2 -1
  14. package/dist/{middleware-C5P1Q29c.js → middleware-DkIhQXwg.js} +1 -1
  15. package/dist/{middleware-CU0mDiRs.d.ts → middleware-nS_qXecO.d.ts} +1 -1
  16. package/dist/orm/index.d.ts +1 -1
  17. package/dist/plugins/index.d.ts +1 -1
  18. package/dist/plugins/index.js +1 -1
  19. package/dist/{procedure-caller-DL0Ubgky.js → procedure-caller-AjLfkHyF.js} +1 -1
  20. package/dist/{procedure-caller-DloN1DNv.d.ts → procedure-name-D-fDCBlo.d.ts} +28 -128
  21. package/dist/ratelimit/index.d.ts +2 -2
  22. package/dist/ratelimit/index.js +3 -3
  23. package/dist/rsc/index.d.ts +3 -3
  24. package/dist/server/index.d.ts +5 -5
  25. package/dist/server/index.js +4 -4
  26. package/dist/{types-DrB2VeNb.d.ts → types-C6pQrnzD.d.ts} +1 -1
  27. package/dist/{types-BqUIoMfT.d.ts → types-a-RHmrDZ.d.ts} +9 -1
  28. package/dist/watcher.mjs +12 -9
  29. package/dist/{where-clause-compiler-Dw3EVdi6.d.ts → where-clause-compiler-DdjN63Io.d.ts} +23 -23
  30. package/package.json +1 -1
  31. package/skills/convex/SKILL.md +8 -5
  32. package/skills/convex/references/features/auth-organizations.md +7 -2
@@ -3717,6 +3717,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3717
3717
  readonly aggregate_bucket: ConvexTableWithColumns<{
3718
3718
  name: "aggregate_bucket";
3719
3719
  columns: {
3720
+ count: ConvexNumberBuilderInitial<""> & {
3721
+ _: {
3722
+ notNull: true;
3723
+ };
3724
+ } & {
3725
+ _: {
3726
+ tableName: "aggregate_bucket";
3727
+ };
3728
+ } & {
3729
+ _: {
3730
+ fieldName: "count";
3731
+ };
3732
+ };
3720
3733
  tableKey: ConvexTextBuilderInitial<""> & {
3721
3734
  _: {
3722
3735
  notNull: true;
@@ -3786,19 +3799,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3786
3799
  fieldName: "keyParts";
3787
3800
  };
3788
3801
  };
3789
- count: ConvexNumberBuilderInitial<""> & {
3790
- _: {
3791
- notNull: true;
3792
- };
3793
- } & {
3794
- _: {
3795
- tableName: "aggregate_bucket";
3796
- };
3797
- } & {
3798
- _: {
3799
- fieldName: "count";
3800
- };
3801
- };
3802
3802
  sumValues: (NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VRecord<Record<string, any>, convex_values0.VString<string, "required">, convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>, "required", string>>, Record<string, number>>> | NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>>, Record<string, number>>>) & {
3803
3803
  _: {
3804
3804
  tableName: "aggregate_bucket";
@@ -4009,7 +4009,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4009
4009
  fieldName: "value";
4010
4010
  };
4011
4011
  };
4012
- tableKey: ConvexTextBuilderInitial<""> & {
4012
+ count: ConvexNumberBuilderInitial<""> & {
4013
4013
  _: {
4014
4014
  notNull: true;
4015
4015
  };
@@ -4019,10 +4019,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4019
4019
  };
4020
4020
  } & {
4021
4021
  _: {
4022
- fieldName: "tableKey";
4022
+ fieldName: "count";
4023
4023
  };
4024
4024
  };
4025
- indexName: ConvexTextBuilderInitial<""> & {
4025
+ tableKey: ConvexTextBuilderInitial<""> & {
4026
4026
  _: {
4027
4027
  notNull: true;
4028
4028
  };
@@ -4032,10 +4032,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4032
4032
  };
4033
4033
  } & {
4034
4034
  _: {
4035
- fieldName: "indexName";
4035
+ fieldName: "tableKey";
4036
4036
  };
4037
4037
  };
4038
- updatedAt: ConvexNumberBuilderInitial<""> & {
4038
+ indexName: ConvexTextBuilderInitial<""> & {
4039
4039
  _: {
4040
4040
  notNull: true;
4041
4041
  };
@@ -4045,10 +4045,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4045
4045
  };
4046
4046
  } & {
4047
4047
  _: {
4048
- fieldName: "updatedAt";
4048
+ fieldName: "indexName";
4049
4049
  };
4050
4050
  };
4051
- keyHash: ConvexTextBuilderInitial<""> & {
4051
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4052
4052
  _: {
4053
4053
  notNull: true;
4054
4054
  };
@@ -4058,10 +4058,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4058
4058
  };
4059
4059
  } & {
4060
4060
  _: {
4061
- fieldName: "keyHash";
4061
+ fieldName: "updatedAt";
4062
4062
  };
4063
4063
  };
4064
- count: ConvexNumberBuilderInitial<""> & {
4064
+ keyHash: ConvexTextBuilderInitial<""> & {
4065
4065
  _: {
4066
4066
  notNull: true;
4067
4067
  };
@@ -4071,7 +4071,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4071
4071
  };
4072
4072
  } & {
4073
4073
  _: {
4074
- fieldName: "count";
4074
+ fieldName: "keyHash";
4075
4075
  };
4076
4076
  };
4077
4077
  fieldName: ConvexTextBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.12.18",
3
+ "version": "0.12.20",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -54,7 +54,7 @@ Only remember these non-parity deltas:
54
54
  19. On the kitcn auth client path, use `createAuthMutations(authClient)` wrappers so logout unsubscribes auth queries before sign out. Raw Convex preset keeps a smaller plain `authClient`.
55
55
  20. **NEVER** use `ctx.runQuery`/`ctx.runMutation`/`ctx.runAction` directly for module-to-module calls. Use `create<Module>Handler(ctx)` or `create<Module>Caller(ctx)` from `convex/functions/generated/<module>.runtime` instead.
56
56
  21. **`create<Module>Handler(ctx)`** — default choice for queries/mutations. Bypasses input validation, middleware, output validation → zero overhead. Query/mutation ctx only. Import from `./generated/<module>.runtime`.
57
- 22. **`create<Module>Caller(ctx)`** — use in actions and HTTP routes (where handler is unavailable). Goes through validation + middleware. Root caller exposes query+mutation procedures. In `ActionCtx`, action procedures are under `caller.actions.*`; scheduling is under `caller.schedule.now|after|at` with `caller.schedule.cancel(id)`. If your code widened `ctx` to a union like `MutationCtx | ActionCtx`, narrow it before accessing `caller.actions.*` (for example with `requireActionCtx(ctx)`). Import from `./generated/<module>.runtime`. Each caller/handler eagerly loads every procedure in its module (no lazy loading) — split large modules to keep bundles lean.
57
+ 22. **`create<Module>Caller(ctx)`** — use in actions and HTTP routes (where handler is unavailable). Goes through validation + middleware. Root caller exposes query+mutation procedures. In `ActionCtx`, action procedures are under `caller.actions.*`; scheduling is under `caller.schedule.now|after|at` with `caller.schedule.cancel(id)`. Use `requireActionCtx(ctx)` only when the callback truly runs in `ActionCtx` and you need `caller.actions.*`. If the callback can run from `MutationCtx | ActionCtx` or generic scheduler-capable context, keep the seam honest: use `requireSchedulerCtx(ctx)` and `caller.schedule.*` instead of pretending the path is action-only. Import from `./generated/<module>.runtime`. Each caller/handler eagerly loads every procedure in its module (no lazy loading) — split large modules to keep bundles lean.
58
58
  23. API types (`Api`, `ApiInputs`, `ApiOutputs`, `Select`, `Insert`, `TableName`) import from `@convex/api` — no manual `inferApiInputs<typeof api>`.
59
59
  24. HTTP router must export as `httpRouter` (not `appRouter`) for codegen.
60
60
  25. Server wiring imports come from `convex/functions/generated/` directory: `getAuth`, `defineAuth` from `generated/auth`; `initCRPC`, `QueryCtx`, `MutationCtx`, `OrmCtx` from `generated/server`; `create<Module>Caller`, `create<Module>Handler` from `generated/<module>.runtime`. No manual `convex/lib/orm.ts`.
@@ -226,9 +226,10 @@ Builder rules that matter:
226
226
 
227
227
  1. Build `public`, `optional`, `auth`, and `private` procedure families once in `convex/lib/crpc.ts`.
228
228
  2. `.meta(...)` is client-visible via generated API metadata. Never put secrets there.
229
- 3. Resolve session/user once in middleware. Do not re-fetch auth state in every procedure.
230
- 4. Shared `c.middleware()` chains preserve mutation writer types on mutation procedures. If the middleware itself performs writes, type it as mutation-only with `c.middleware<MutationCtx>(...)`.
231
- 5. Keep deeper auth/runtime edge cases in `references/setup/server.md` and `references/features/auth*.md`.
229
+ 3. Middleware receives server-only `procedure` info. When procedures are built from your app `generated/server` helper, standard `export const` queries, mutations, and actions infer `module:function` automatically from file path + export name. Use `.name("module:function")` only to override or cover unusual export shapes.
230
+ 4. Resolve session/user once in middleware. Do not re-fetch auth state in every procedure.
231
+ 5. Shared `c.middleware()` chains preserve mutation writer types on mutation procedures. If the middleware itself performs writes, type it as mutation-only with `c.middleware<MutationCtx>(...)`.
232
+ 6. Keep deeper auth/runtime edge cases in `references/setup/server.md` and `references/features/auth*.md`.
232
233
 
233
234
  ### 3) Query + Mutation Procedure Template
234
235
 
@@ -349,7 +350,9 @@ Key client defaults/deltas:
349
350
  5. For pagination, use `useInfiniteQuery` from `kitcn/react`.
350
351
  6. Prefer typed `queryKey(...)` helpers for cache read/write/fetch ops instead of manual keys.
351
352
  7. For kitcn auth flows, prefer `createAuthMutations(...)` wrappers (not raw auth client calls) to avoid logout race errors. Raw Convex preset keeps the plain auth client path.
352
- 8. Full client/RSC depth lives in `references/features/react.md`.
353
+ 8. For mutation toasts, prefer `error.data?.message` over `error.message`; `data.message` is the clean `CRPCError` payload.
354
+ 9. Prefer one global `QueryClient` mutation `onError` toast with `mutation.meta.errorMessage` / `skipErrorToast` rather than copy-pasting `onError` in every component.
355
+ 10. Full client/RSC depth lives in `references/features/react.md`.
353
356
 
354
357
  ### 8) RSC Patterns (Next.js)
355
358
 
@@ -11,7 +11,7 @@ See [Better Auth Organization Plugin](https://www.better-auth.com/docs/plugins/o
11
11
  ```ts
12
12
  // convex/functions/auth.ts
13
13
  import { organization } from "better-auth/plugins";
14
- import type { ActionCtx } from "./generated/server";
14
+ import { requireSchedulerCtx } from "kitcn/server";
15
15
  import { defineAuth } from "./generated/auth";
16
16
 
17
17
  export default defineAuth((ctx) => ({
@@ -28,12 +28,13 @@ export default defineAuth((ctx) => ({
28
28
  invitationExpiresIn: 48 * 60 * 60, // 48 hours
29
29
  teams: { enabled: true, maximumTeams: 10 },
30
30
  sendInvitationEmail: async (data) => {
31
+ const schedulerCtx = requireSchedulerCtx(ctx);
31
32
  const inviterName = data.inviter.user.name || "Team Admin";
32
33
  const organizationName = data.organization.name;
33
34
  const roleSuffix = data.role ? ` as ${data.role}` : "";
34
35
  const acceptUrl = `${process.env.SITE_URL!}/w/${data.organization.slug}?invite=${data.id}`;
35
36
 
36
- await (ctx as ActionCtx).scheduler.runAfter(
37
+ await schedulerCtx.scheduler.runAfter(
37
38
  0,
38
39
  internal.plugins.email.sendTemplatedEmail,
39
40
  {
@@ -51,6 +52,10 @@ export default defineAuth((ctx) => ({
51
52
  }));
52
53
  ```
53
54
 
55
+ `sendInvitationEmail` can run from mutation-driven auth flows. Use
56
+ `requireSchedulerCtx(ctx)` when you need scheduling. Do not narrow to
57
+ `ActionCtx` unless the callback truly runs only inside an action.
58
+
54
59
  ## Client Config
55
60
 
56
61
  ```ts