kitcn 0.32.2 → 0.33.1
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 +109 -0
- package/dist/aggregate/index.d.ts +2 -2
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +16 -16
- package/dist/auth/index.js +1 -1
- package/dist/auth/nextjs/index.d.ts +2 -2
- package/dist/auth/start/server/index.d.ts +2 -2
- package/dist/{builder-Cyd5nCxZ.js → builder-DDYTlmTB.js} +12 -3
- package/dist/caller-factory-C3pcbzo0.d.ts +140 -0
- package/dist/{capabilities-BJm_VSDT.d.ts → capabilities-Bxzoofl4.d.ts} +149 -9
- package/dist/crpc/index.d.ts +3 -2
- package/dist/{generated-contract-disabled-BRm1dNQE.d.ts → generated-contract-disabled-B_EaHGCP.d.ts} +33 -33
- package/dist/{http-types-BhhPZtwa.d.ts → http-types-8FBr10yl.d.ts} +3 -79
- package/dist/{middleware-BBS7oLtT.d.ts → middleware-D2hKJuSZ.d.ts} +1 -1
- package/dist/{middleware-D61Nm-iB.js → middleware-LvZov-hA.js} +1 -1
- package/dist/orm/aggregate-index/index.d.ts +1 -1
- package/dist/orm/aggregate-index/index.js +226 -96
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +364 -108
- package/dist/orm/migrations/index.d.ts +2 -2
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-DgMiD0-a.js → procedure-caller-DgGF_hA8.js} +1 -1
- package/dist/{procedure-name-DPYyLiVS.d.ts → procedure-name-kn-awLk1.d.ts} +12 -142
- package/dist/{query-context-D4z1CnDH.js → query-context-DQLv58LH.js} +34 -1
- package/dist/ratelimit/index.d.ts +2 -2
- package/dist/ratelimit/index.js +2 -2
- package/dist/react/index.d.ts +5 -6
- package/dist/react/index.js +24 -69
- package/dist/rsc/index.d.ts +4 -3
- package/dist/{schema-Bh7AmJwY.js → schema-BF4P0ZjS.js} +322 -1
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.js +2 -2
- package/dist/solid/index.d.ts +5 -6
- package/dist/solid/index.js +20 -66
- package/dist/transformer-BEkxlnss.d.ts +78 -0
- package/dist/{types-BXpu7xIU.d.ts → types-Cl0utsTL.d.ts} +4 -3
- package/dist/{where-clause-compiler-Dgf4lrO-.d.ts → where-clause-compiler-CoPVAVDO.d.ts} +136 -136
- package/package.json +1 -1
- package/skills/kitcn/SKILL.md +2 -1
- package/skills/kitcn/references/features/aggregates.md +13 -0
- package/skills/kitcn/references/features/auth-admin.md +1 -0
- package/skills/kitcn/references/features/orm.md +24 -4
- package/skills/kitcn/references/features/react.md +4 -5
- /package/dist/{context-utils-Cbv4r0AA.d.ts → context-utils-ax351iFc.d.ts} +0 -0
- /package/dist/{token-tlbNKQS0.d.ts → token-CZpDQUHd.d.ts} +0 -0
- /package/dist/{types-Bkeicpo6.d.ts → types-CzGsrLrY.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,114 @@
|
|
|
1
1
|
# kitcn
|
|
2
2
|
|
|
3
|
+
## 0.33.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#462](https://github.com/udecode/kitcn/pull/462) [`41eb956`](https://github.com/udecode/kitcn/commit/41eb9567ebea2ae0b6340624897815f54c51e0aa) Thanks [@zbeyens](https://github.com/zbeyens)! - Fix cRPC live pagination so reactive page splits preserve adjacent page
|
|
8
|
+
boundaries and invalid loaded cursors reset cleanly.
|
|
9
|
+
|
|
10
|
+
## 0.33.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#456](https://github.com/udecode/kitcn/pull/456) [`5b0bd5a`](https://github.com/udecode/kitcn/commit/5b0bd5a1debb4a0e0bb87f79ef1a18f357b614c1) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Breaking changes
|
|
15
|
+
|
|
16
|
+
- Support index-ordered pagination for indexed filters with more than 64 values. Pages follow index order, grouped by the filtered value, rather than creation order. Add `orderBy` and `maxScan` to preserve newest-first paging.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// Before
|
|
20
|
+
const page = await db.query.users.withIndex("by_status").findMany({
|
|
21
|
+
where: { status: { in: manyStatuses } },
|
|
22
|
+
cursor: null,
|
|
23
|
+
limit: 20,
|
|
24
|
+
maxScan: 500,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// After
|
|
28
|
+
const page = await db.query.users.withIndex("by_status").findMany({
|
|
29
|
+
where: { status: { in: manyStatuses } },
|
|
30
|
+
orderBy: { createdAt: "desc" },
|
|
31
|
+
cursor: null,
|
|
32
|
+
limit: 20,
|
|
33
|
+
maxScan: 500,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Patches
|
|
38
|
+
|
|
39
|
+
- Fix authenticated cRPC query results disappearing when a server-rendered page
|
|
40
|
+
hydrates.
|
|
41
|
+
- Fix unnecessary full-table reads for `select()` filters containing more than 64 values.
|
|
42
|
+
- Fix unnecessary full-table reads for long `in` lists combined with another condition, such as `name: { contains: 'x' }`.
|
|
43
|
+
- Improve limited reads with additional conditions so they stop after enough matching rows are found when index order satisfies the requested sort.
|
|
44
|
+
- Support index-bounded reads for indexed `in`, `notIn`, `ne`, and same-field equality `OR` filters regardless of list length.
|
|
45
|
+
- Support pagination without `maxScan` for wide filters whose requested order follows their indexed values; cross-value sorting, such as `orderBy: { createdAt: 'desc' }`, still requires `maxScan` past 64 values.
|
|
46
|
+
|
|
47
|
+
- [#449](https://github.com/udecode/kitcn/pull/449) [`b8df2da`](https://github.com/udecode/kitcn/commit/b8df2da49a8733b545f02b84bb538b1cbef275b0) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Breaking changes
|
|
48
|
+
|
|
49
|
+
- Read a `select().flatMap(relation, { where })` stage through an index that extends the relation's foreign key when the schema declares one. Children arrive in that index's order, so a lowered range field now orders them ahead of creation time, and outstanding page cursors for those queries do not carry over.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Before: every post by the author is read, then filtered, in creation order.
|
|
53
|
+
// After: only the by_author_likes range is read, in numLikes order.
|
|
54
|
+
index("by_author_likes").on(t.authorId, t.numLikes);
|
|
55
|
+
|
|
56
|
+
await ctx.orm.query.users
|
|
57
|
+
.select()
|
|
58
|
+
.flatMap("posts", { includeParent: false, where: { numLikes: { gt: 10 } } })
|
|
59
|
+
.paginate({ cursor: null, limit: 20 });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Patches
|
|
63
|
+
|
|
64
|
+
- Compile a `select().union([{ where }])` source `where` against the table's indexes instead of filtering every scanned row, so an object `where` on an indexed field bounds the read. A source keeps its unanchored read when the lowered one could not supply `interleaveBy`, and a `where` never displaces an index the source or the chain pinned with a range.
|
|
65
|
+
- Report what a caller can actually do when a `predicate(...)` `where` runs over an unbounded pipeline read: a union source names its own `index` option, and a `flatMap` stage names the relation index it needs.
|
|
66
|
+
- Resolve a `select()` union source or `flatMap` stage `where` once per read. A callback `where` runs a single time instead of twice, and an object `where` compiles once instead of once per row.
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- [#455](https://github.com/udecode/kitcn/pull/455) [`a73de28`](https://github.com/udecode/kitcn/commit/a73de28bacf3e518a38762442270d2c54f6989e8) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
|
|
71
|
+
|
|
72
|
+
- Fix `findMany` losing its read bound when a `limit` is combined with `in`, `ne`,
|
|
73
|
+
`notIn` or a same-field `OR` on a table that has RLS enabled, or alongside a
|
|
74
|
+
filter Convex cannot evaluate such as `contains`. Either one used to make the
|
|
75
|
+
query read every row it matched against, so
|
|
76
|
+
`findMany({ where: { ownerId: { in: [a, b] } }, limit: 3 })` read 500 documents
|
|
77
|
+
on a 500-row table and 200 on a 200-row table. It now reads 6 at either size,
|
|
78
|
+
and the count no longer grows with the table.
|
|
79
|
+
- Improve how that `limit` is counted, so it bounds rows the caller can actually
|
|
80
|
+
see: with 80 rows an RLS policy hides sitting in front of the matches,
|
|
81
|
+
`limit: 3` still returns three rows and reads 86 documents instead of 200.
|
|
82
|
+
- Support that bound for an `in` list of any length.
|
|
83
|
+
|
|
84
|
+
Rows and their order are unchanged. A `where` that filters through a relation
|
|
85
|
+
keeps its previous read cost, as does `ne`, `notIn` or `isNotNull` ordered by a
|
|
86
|
+
field no index can serve.
|
|
87
|
+
|
|
88
|
+
- [#450](https://github.com/udecode/kitcn/pull/450) [`781af65`](https://github.com/udecode/kitcn/commit/781af65c6e2f9128362378f0cf358d2c8e509b7d) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
|
|
89
|
+
|
|
90
|
+
- Improve update read costs on `aggregateIndex` and `rankIndex` tables: read
|
|
91
|
+
each row once unless a user `update.before` hook requires a fresh read.
|
|
92
|
+
- Fix CLEARING checks for deletes of already-deleted rows: report the
|
|
93
|
+
transient aggregate-index state instead of `Delete on non-existent doc`.
|
|
94
|
+
|
|
95
|
+
- [#451](https://github.com/udecode/kitcn/pull/451) [`80f7609`](https://github.com/udecode/kitcn/commit/80f7609cb107d23e4688b6877f35787107dd0a39) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
|
|
96
|
+
|
|
97
|
+
- Improve `aggregateIndex` bulk-write read costs by reusing bucket and member
|
|
98
|
+
reads within uninterrupted ORM statements. User hooks and policy callbacks
|
|
99
|
+
end reuse so nested mutation writes remain visible to later maintenance.
|
|
100
|
+
|
|
101
|
+
- [#454](https://github.com/udecode/kitcn/pull/454) [`f399843`](https://github.com/udecode/kitcn/commit/f399843c6bfb46e080558bc22d2cc4a77842cd16) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
|
|
102
|
+
|
|
103
|
+
- Improve bulk aggregate writes by folding shared bucket and extrema updates
|
|
104
|
+
within uninterrupted statements. A 40-row key migration writes two shared
|
|
105
|
+
buckets and two extrema entries, plus forty membership rows.
|
|
106
|
+
- Preserve read-your-own-writes through aggregate reads and nested functions
|
|
107
|
+
called by lifecycle hooks or RLS policies. Reads and callbacks flush pending
|
|
108
|
+
writes; callbacks suspend batching until they settle.
|
|
109
|
+
- Fix mid-statement aggregate reads through `withoutTriggers()` and an ORM
|
|
110
|
+
rebuilt from a hook context to observe the same rows as `ctx.orm`.
|
|
111
|
+
|
|
3
112
|
## 0.32.2
|
|
4
113
|
|
|
5
114
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Vn as ConvexTextBuilderInitial, Zt as ConvexTableWithColumns } from "../capabilities-
|
|
2
|
-
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-
|
|
1
|
+
import { Vn as ConvexTextBuilderInitial, Zt as ConvexTableWithColumns } from "../capabilities-Bxzoofl4.js";
|
|
2
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-CoPVAVDO.js";
|
|
3
3
|
import * as convex_values0 from "convex/values";
|
|
4
4
|
import { GenericId, Infer, Value } from "convex/values";
|
|
5
5
|
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, b as GenericAuthBeforeResult, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../../generated-contract-disabled-
|
|
1
|
+
import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, b as GenericAuthBeforeResult, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../../generated-contract-disabled-B_EaHGCP.js";
|
|
2
2
|
export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-BkNjkDCk.js";
|
|
2
2
|
import { t as GetAuth } from "../types-ex0-J-SC.js";
|
|
3
|
-
import { t as GenericCtx } from "../context-utils-
|
|
4
|
-
import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, _ as updateManyHandler, a as AuthFunctions, b as GenericAuthBeforeResult, c as consumeOneHandler, d as createHandler, f as deleteManyHandler, g as incrementOneHandler, h as findOneHandler, i as getGeneratedAuthDisabledReason, l as countHandler, m as findManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as deleteOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createApi, v as updateOneHandler, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../generated-contract-disabled-
|
|
3
|
+
import { t as GenericCtx } from "../context-utils-ax351iFc.js";
|
|
4
|
+
import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, _ as updateManyHandler, a as AuthFunctions, b as GenericAuthBeforeResult, c as consumeOneHandler, d as createHandler, f as deleteManyHandler, g as incrementOneHandler, h as findOneHandler, i as getGeneratedAuthDisabledReason, l as countHandler, m as findManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as deleteOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createApi, v as updateOneHandler, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../generated-contract-disabled-B_EaHGCP.js";
|
|
5
5
|
import * as convex_values0 from "convex/values";
|
|
6
6
|
import { Infer } from "convex/values";
|
|
7
7
|
import { AuthConfig, DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
|
|
@@ -109,31 +109,31 @@ type AdapterPaginationOptions = PaginationOptions & {
|
|
|
109
109
|
};
|
|
110
110
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
111
111
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
112
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
112
113
|
connector?: "AND" | "OR" | undefined;
|
|
113
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
114
114
|
value: string | number | boolean | string[] | number[] | null;
|
|
115
115
|
field: string;
|
|
116
116
|
}, {
|
|
117
117
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
118
118
|
field: convex_values0.VString<string, "required">;
|
|
119
119
|
mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
|
|
120
|
-
operator: convex_values0.VUnion<"
|
|
120
|
+
operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
|
|
121
121
|
value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
|
|
122
|
-
}, "required", "mode" | "value" | "
|
|
122
|
+
}, "required", "mode" | "value" | "operator" | "field" | "connector">;
|
|
123
123
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
124
|
+
limit?: number | undefined;
|
|
124
125
|
where?: {
|
|
125
126
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
127
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
126
128
|
connector?: "AND" | "OR" | undefined;
|
|
127
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
128
129
|
value: string | number | boolean | string[] | number[] | null;
|
|
129
130
|
field: string;
|
|
130
131
|
}[] | undefined;
|
|
131
|
-
limit?: number | undefined;
|
|
132
|
-
offset?: number | undefined;
|
|
133
132
|
select?: string[] | undefined;
|
|
133
|
+
offset?: number | undefined;
|
|
134
134
|
sortBy?: {
|
|
135
|
-
field: string;
|
|
136
135
|
direction: "asc" | "desc";
|
|
136
|
+
field: string;
|
|
137
137
|
} | undefined;
|
|
138
138
|
model: string;
|
|
139
139
|
}, {
|
|
@@ -142,32 +142,32 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
142
142
|
offset: convex_values0.VFloat64<number | undefined, "optional">;
|
|
143
143
|
select: convex_values0.VArray<string[] | undefined, convex_values0.VString<string, "required">, "optional">;
|
|
144
144
|
sortBy: convex_values0.VObject<{
|
|
145
|
-
field: string;
|
|
146
145
|
direction: "asc" | "desc";
|
|
146
|
+
field: string;
|
|
147
147
|
} | undefined, {
|
|
148
148
|
direction: convex_values0.VUnion<"asc" | "desc", [convex_values0.VLiteral<"asc", "required">, convex_values0.VLiteral<"desc", "required">], "required", never>;
|
|
149
149
|
field: convex_values0.VString<string, "required">;
|
|
150
|
-
}, "optional", "
|
|
150
|
+
}, "optional", "direction" | "field">;
|
|
151
151
|
where: convex_values0.VArray<{
|
|
152
152
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
153
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
153
154
|
connector?: "AND" | "OR" | undefined;
|
|
154
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
155
155
|
value: string | number | boolean | string[] | number[] | null;
|
|
156
156
|
field: string;
|
|
157
157
|
}[] | undefined, convex_values0.VObject<{
|
|
158
158
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
159
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
159
160
|
connector?: "AND" | "OR" | undefined;
|
|
160
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
161
161
|
value: string | number | boolean | string[] | number[] | null;
|
|
162
162
|
field: string;
|
|
163
163
|
}, {
|
|
164
164
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
165
165
|
field: convex_values0.VString<string, "required">;
|
|
166
166
|
mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
|
|
167
|
-
operator: convex_values0.VUnion<"
|
|
167
|
+
operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
|
|
168
168
|
value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
|
|
169
|
-
}, "required", "mode" | "value" | "
|
|
170
|
-
}, "required", "
|
|
169
|
+
}, "required", "mode" | "value" | "operator" | "field" | "connector">, "optional">;
|
|
170
|
+
}, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.direction" | "sortBy.field">;
|
|
171
171
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
172
172
|
declare const checkUniqueFields: <Schema extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
|
|
173
173
|
declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
|
package/dist/auth/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { i as defineAuth, n as createDisabledAuthRuntime, r as getGeneratedAuthD
|
|
|
4
4
|
import { n as createGeneratedFunctionReference, o as isQueryCtx, s as isRunMutationCtx } from "../api-entry-Buvjl9hn.js";
|
|
5
5
|
import { i as customQuery, n as customCtx, r as customMutation } from "../customFunctions-X_B4kET8.js";
|
|
6
6
|
import { C as eq, o as getAggregateIndexes } from "../index-utils-DvK7P6Q1.js";
|
|
7
|
-
import {
|
|
7
|
+
import { c as stream, f as unsetToken, s as mergedStream, t as getByIdWithOrmQueryFallback } from "../query-context-DQLv58LH.js";
|
|
8
8
|
import { n as convex } from "../convex-plugin-AbNQl1Sg.js";
|
|
9
9
|
import { v } from "convex/values";
|
|
10
10
|
import { internalActionGeneric, internalMutationGeneric, internalQueryGeneric, paginationOptsValidator } from "convex/server";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as GetTokenOptions } from "../../token-
|
|
1
|
+
import { r as LazyCaller, t as ConvexContext } from "../../caller-factory-C3pcbzo0.js";
|
|
2
|
+
import { t as GetTokenOptions } from "../../token-CZpDQUHd.js";
|
|
3
3
|
|
|
4
4
|
//#region src/auth-nextjs/index.d.ts
|
|
5
5
|
/** Auth options for server-side calls. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as GetTokenOptions } from "../../../token-
|
|
1
|
+
import { r as LazyCaller, t as ConvexContext } from "../../../caller-factory-C3pcbzo0.js";
|
|
2
|
+
import { t as GetTokenOptions } from "../../../token-CZpDQUHd.js";
|
|
3
3
|
import { FunctionReference, FunctionReturnType, OptionalRestArgs } from "convex/server";
|
|
4
4
|
|
|
5
5
|
//#region src/auth-start/server.d.ts
|
|
@@ -1716,10 +1716,12 @@ function inferProcedureNameFromCallsite() {
|
|
|
1716
1716
|
*/
|
|
1717
1717
|
z$1.object({
|
|
1718
1718
|
cursor: z$1.union([z$1.string(), z$1.null()]),
|
|
1719
|
+
endCursor: z$1.union([z$1.string(), z$1.null()]).optional(),
|
|
1719
1720
|
limit: z$1.number()
|
|
1720
1721
|
});
|
|
1721
1722
|
z$1.object({
|
|
1722
1723
|
cursor: z$1.union([z$1.string(), z$1.null()]).optional(),
|
|
1724
|
+
endCursor: z$1.union([z$1.string(), z$1.null()]).optional(),
|
|
1723
1725
|
limit: z$1.number().optional()
|
|
1724
1726
|
});
|
|
1725
1727
|
/**
|
|
@@ -2120,8 +2122,8 @@ var QueryProcedureBuilder = class QueryProcedureBuilder extends ProcedureBuilder
|
|
|
2120
2122
|
/**
|
|
2121
2123
|
* Add pagination input (chainable before .query())
|
|
2122
2124
|
*
|
|
2123
|
-
* Creates flat { cursor, limit } input like tRPC and auto-wraps
|
|
2124
|
-
* User accesses
|
|
2125
|
+
* Creates flat { cursor, endCursor, limit } input like tRPC and auto-wraps
|
|
2126
|
+
* output. User accesses the pagination fields directly from args.
|
|
2125
2127
|
*
|
|
2126
2128
|
* @param opts.limit - Default/max items per page
|
|
2127
2129
|
* @param opts.item - Zod schema for each item in the page array
|
|
@@ -2129,12 +2131,19 @@ var QueryProcedureBuilder = class QueryProcedureBuilder extends ProcedureBuilder
|
|
|
2129
2131
|
paginated(opts) {
|
|
2130
2132
|
const paginationSchemaWithDefault = z$1.object({
|
|
2131
2133
|
cursor: z$1.union([z$1.string(), z$1.null()]).default(null),
|
|
2134
|
+
endCursor: z$1.union([z$1.string(), z$1.null()]).optional(),
|
|
2132
2135
|
limit: z$1.number().default(opts.limit).transform((n) => Math.min(n, opts.limit))
|
|
2133
2136
|
});
|
|
2134
2137
|
const outputSchema = z$1.object({
|
|
2135
2138
|
continueCursor: z$1.union([z$1.string(), z$1.null()]),
|
|
2136
2139
|
isDone: z$1.boolean(),
|
|
2137
|
-
page: z$1.array(opts.item)
|
|
2140
|
+
page: z$1.array(opts.item),
|
|
2141
|
+
pageStatus: z$1.union([
|
|
2142
|
+
z$1.literal("SplitRecommended"),
|
|
2143
|
+
z$1.literal("SplitRequired"),
|
|
2144
|
+
z$1.null()
|
|
2145
|
+
]).optional(),
|
|
2146
|
+
splitCursor: z$1.union([z$1.string(), z$1.null()]).optional()
|
|
2138
2147
|
});
|
|
2139
2148
|
return new QueryProcedureBuilder({
|
|
2140
2149
|
...this._def,
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { i as DataTransformerOptions } from "./transformer-BEkxlnss.js";
|
|
2
|
+
import { FunctionReference, FunctionReturnType } from "convex/server";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/upstream/index.d.ts
|
|
5
|
+
type EmptyObject = Record<string, never>;
|
|
6
|
+
/**
|
|
7
|
+
* Hack! This type causes TypeScript to simplify how it renders object types.
|
|
8
|
+
*
|
|
9
|
+
* It is functionally the identity for object types, but in practice it can
|
|
10
|
+
* simplify expressions like `A & B`.
|
|
11
|
+
*/
|
|
12
|
+
type Expand<ObjectType extends Record<any, any>> = ObjectType extends Record<any, any> ? { [Key in keyof ObjectType]: ObjectType[Key] } : never;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/server/caller.d.ts
|
|
15
|
+
/** Metadata for a single function */
|
|
16
|
+
type FnMeta = {
|
|
17
|
+
type?: 'query' | 'mutation' | 'action';
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
/** Metadata for all functions in a module */
|
|
21
|
+
type ModuleMeta = Record<string, FnMeta>;
|
|
22
|
+
/** Metadata for all modules - from generated `@convex/api` */
|
|
23
|
+
type CallerMeta = Record<string, ModuleMeta>;
|
|
24
|
+
/** Options for individual caller function calls */
|
|
25
|
+
type CallerOpts = {
|
|
26
|
+
/** Skip query silently when unauthenticated (returns null instead of throwing) */skipUnauth?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type CallerReturn<T, Opts extends CallerOpts | undefined> = Opts extends {
|
|
29
|
+
skipUnauth: true;
|
|
30
|
+
} ? T | null : T;
|
|
31
|
+
type FetchFn<T extends 'query' | 'mutation' | 'action'> = <Fn extends FunctionReference<T>>(fn: Fn, args: Fn['_args'], opts?: CallerOpts) => Promise<FunctionReturnType<Fn> | null>;
|
|
32
|
+
type CreateCallerOptions = {
|
|
33
|
+
fetchQuery: FetchFn<'query'>;
|
|
34
|
+
fetchMutation: FetchFn<'mutation'>;
|
|
35
|
+
fetchAction: FetchFn<'action'>;
|
|
36
|
+
meta: CallerMeta;
|
|
37
|
+
transformer?: DataTransformerOptions;
|
|
38
|
+
};
|
|
39
|
+
type ServerCallerFn<TApi, K extends keyof TApi> = TApi[K] extends FunctionReference<infer T, 'public'> ? T extends 'query' | 'mutation' | 'action' ? keyof TApi[K]['_args'] extends never ? <Opts extends CallerOpts | undefined = undefined>(args?: EmptyObject, opts?: Opts) => Promise<CallerReturn<FunctionReturnType<TApi[K]>, Opts>> : EmptyObject extends TApi[K]['_args'] ? <Opts extends CallerOpts | undefined = undefined>(args?: TApi[K]['_args'], opts?: Opts) => Promise<CallerReturn<FunctionReturnType<TApi[K]>, Opts>> : <Opts extends CallerOpts | undefined = undefined>(args: TApi[K]['_args'], opts?: Opts) => Promise<CallerReturn<FunctionReturnType<TApi[K]>, Opts>> : never : ServerCaller<TApi[K]>;
|
|
40
|
+
type ServerCaller<TApi> = { [K in keyof TApi as K extends string ? K extends `_${string}` ? never : K extends 'http' ? never : K : K]: ServerCallerFn<TApi, K> };
|
|
41
|
+
/**
|
|
42
|
+
* Create a server caller for direct data fetching without React Query.
|
|
43
|
+
*
|
|
44
|
+
* This is detached from React Query cache - data is NOT available in client components.
|
|
45
|
+
* Use for server-only data that doesn't need to be shared with the client.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* // src/lib/convex/rsc.tsx
|
|
50
|
+
* export const caller = createServerCaller(api, {
|
|
51
|
+
* fetchQuery: fetchAuthQuery,
|
|
52
|
+
* fetchMutation: fetchAuthMutation,
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // app/page.tsx (RSC)
|
|
56
|
+
* const posts = await caller.posts.list();
|
|
57
|
+
* return <div>{posts?.length} posts</div>;
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function createServerCaller<TApi extends Record<string, unknown>>(api: TApi, opts: CreateCallerOptions): ServerCaller<TApi>;
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/server/lazy-caller.d.ts
|
|
63
|
+
type CallerContext<TApi> = {
|
|
64
|
+
caller: ServerCaller<TApi>;
|
|
65
|
+
token: string | undefined;
|
|
66
|
+
isAuthenticated: boolean;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Lazy caller with auth helper methods.
|
|
70
|
+
* Context is created on first procedure invocation, not at definition time.
|
|
71
|
+
*/
|
|
72
|
+
type LazyCaller<TApi> = ServerCaller<TApi> & {
|
|
73
|
+
/** Check if user is authenticated */isAuth: () => Promise<boolean>; /** Check if user is unauthenticated */
|
|
74
|
+
isUnauth: () => Promise<boolean>; /** Get the auth token (for RSC prefetching) */
|
|
75
|
+
getToken: () => Promise<string | undefined>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Create a lazy caller that creates context on each procedure invocation.
|
|
79
|
+
* Matches tRPC's `appRouter.createCaller(createTRPCContext)` pattern.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* // server.ts
|
|
84
|
+
* const { createContext, createCaller } = createCallerFactory({...});
|
|
85
|
+
*
|
|
86
|
+
* // rsc.tsx
|
|
87
|
+
* const createRSCContext = cache(async () => {
|
|
88
|
+
* const heads = await headers();
|
|
89
|
+
* return createContext({ headers: heads });
|
|
90
|
+
* });
|
|
91
|
+
* export const caller = createCaller(createRSCContext);
|
|
92
|
+
*
|
|
93
|
+
* // app/page.tsx - single call! Context created lazily
|
|
94
|
+
* const posts = await caller.posts.list();
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
declare function createLazyCaller<TApi extends Record<string, unknown>>(api: TApi, createContext: () => Promise<CallerContext<TApi>>): LazyCaller<TApi>;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/server/caller-factory.d.ts
|
|
100
|
+
type TokenResult = {
|
|
101
|
+
token?: string;
|
|
102
|
+
isFresh?: boolean;
|
|
103
|
+
};
|
|
104
|
+
type GetTokenFn = (siteUrl: string, headers: Headers, opts?: unknown) => Promise<TokenResult>;
|
|
105
|
+
/** Auth options for server-side calls. */
|
|
106
|
+
type AuthOptions = {
|
|
107
|
+
/** Function to extract auth token from request headers. */getToken: GetTokenFn;
|
|
108
|
+
/**
|
|
109
|
+
* Custom function to detect UNAUTHORIZED errors.
|
|
110
|
+
* Set this to resolve those errors to `null` instead of throwing.
|
|
111
|
+
*
|
|
112
|
+
* Refreshing an expired cached token and retrying does not require this:
|
|
113
|
+
* that always falls back to `defaultIsUnauthorized`.
|
|
114
|
+
*/
|
|
115
|
+
isUnauthorized?: (error: unknown) => boolean;
|
|
116
|
+
};
|
|
117
|
+
type CreateCallerFactoryOptions<TApi> = {
|
|
118
|
+
/** Your Convex API object. */api: TApi; /** Convex site URL (must end in `.convex.site`). */
|
|
119
|
+
convexSiteUrl: string;
|
|
120
|
+
/**
|
|
121
|
+
* Convex deployment URL (must end in `.convex.cloud`).
|
|
122
|
+
* Defaults to `convexSiteUrl` with the domain swapped.
|
|
123
|
+
*/
|
|
124
|
+
convexUrl?: string; /** Auth options. Pass to enable authenticated calls with JWT caching. */
|
|
125
|
+
auth?: AuthOptions; /** Optional wire transformer for request/response payloads (always composed with Date). */
|
|
126
|
+
transformer?: DataTransformerOptions;
|
|
127
|
+
};
|
|
128
|
+
type ConvexContext<TApi> = {
|
|
129
|
+
token: string | undefined;
|
|
130
|
+
isAuthenticated: boolean;
|
|
131
|
+
caller: ServerCaller<TApi>;
|
|
132
|
+
};
|
|
133
|
+
declare function createCallerFactory<TApi extends Record<string, unknown>>(opts: CreateCallerFactoryOptions<TApi>): {
|
|
134
|
+
createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
|
|
135
|
+
createContext: (reqOpts: {
|
|
136
|
+
headers: Headers;
|
|
137
|
+
}) => Promise<ConvexContext<TApi>>;
|
|
138
|
+
};
|
|
139
|
+
//#endregion
|
|
140
|
+
export { CallerMeta as a, createServerCaller as c, createLazyCaller as i, EmptyObject as l, createCallerFactory as n, CallerOpts as o, LazyCaller as r, ServerCaller as s, ConvexContext as t, Expand as u };
|