kitcn 0.0.1 → 0.12.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/bin/intent.js +3 -0
- package/dist/aggregate/index.d.ts +388 -0
- package/dist/aggregate/index.js +37 -0
- package/dist/api-entry-BckXqaLb.js +66 -0
- package/dist/auth/client/index.d.ts +37 -0
- package/dist/auth/client/index.js +217 -0
- package/dist/auth/config/index.d.ts +45 -0
- package/dist/auth/config/index.js +24 -0
- package/dist/auth/generated/index.d.ts +2 -0
- package/dist/auth/generated/index.js +3 -0
- package/dist/auth/http/index.d.ts +64 -0
- package/dist/auth/http/index.js +461 -0
- package/dist/auth/index.d.ts +221 -0
- package/dist/auth/index.js +1398 -0
- package/dist/auth/nextjs/index.d.ts +50 -0
- package/dist/auth/nextjs/index.js +81 -0
- package/dist/auth-store-Cljlmdmi.js +197 -0
- package/dist/builder-CBdG5W6A.js +1974 -0
- package/dist/caller-factory-cTXNvYdz.js +216 -0
- package/dist/cli.mjs +13255 -0
- package/dist/codegen-lF80HSWu.mjs +3416 -0
- package/dist/context-utils-HPC5nXzx.d.ts +17 -0
- package/dist/create-schema-odyF4kCy.js +156 -0
- package/dist/create-schema-orm-DOyiNDCx.js +246 -0
- package/dist/crpc/index.d.ts +105 -0
- package/dist/crpc/index.js +169 -0
- package/dist/customFunctions-C0voKmtx.js +144 -0
- package/dist/error-BZEnI7Sq.js +41 -0
- package/dist/generated-contract-disabled-Cih4eITO.js +50 -0
- package/dist/generated-contract-disabled-D-sOFy92.d.ts +354 -0
- package/dist/http-types-DqJubRPJ.d.ts +292 -0
- package/dist/meta-utils-0Pu0Nrap.js +117 -0
- package/dist/middleware-BUybuv9n.d.ts +34 -0
- package/dist/middleware-C2qTZ3V7.js +84 -0
- package/dist/orm/index.d.ts +17 -0
- package/dist/orm/index.js +10713 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +3 -0
- package/dist/procedure-caller-DtxLmGwA.d.ts +1467 -0
- package/dist/procedure-caller-MWcxhQDv.js +349 -0
- package/dist/query-context-B8o6-8kC.js +1518 -0
- package/dist/query-context-CFZqIvD7.d.ts +42 -0
- package/dist/query-options-Dw7cOyXl.js +121 -0
- package/dist/ratelimit/index.d.ts +269 -0
- package/dist/ratelimit/index.js +856 -0
- package/dist/ratelimit/react/index.d.ts +76 -0
- package/dist/ratelimit/react/index.js +183 -0
- package/dist/react/index.d.ts +1284 -0
- package/dist/react/index.js +2526 -0
- package/dist/rsc/index.d.ts +276 -0
- package/dist/rsc/index.js +233 -0
- package/dist/runtime-CtvJPkur.js +2453 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +6 -0
- package/dist/solid/index.d.ts +1221 -0
- package/dist/solid/index.js +2940 -0
- package/dist/transformer-DtDhR3Lc.js +194 -0
- package/dist/types-BTb_4BaU.d.ts +42 -0
- package/dist/types-BiJE7qxR.d.ts +4 -0
- package/dist/types-DEJpkIhw.d.ts +88 -0
- package/dist/types-HhO_R6pd.d.ts +213 -0
- package/dist/validators-B7oIJCAp.js +279 -0
- package/dist/validators-vzRKjBJC.d.ts +88 -0
- package/dist/watcher.mjs +96 -0
- package/dist/where-clause-compiler-DdjN63Io.d.ts +4756 -0
- package/package.json +107 -35
- package/skills/convex/SKILL.md +486 -0
- package/skills/convex/references/features/aggregates.md +353 -0
- package/skills/convex/references/features/auth-admin.md +446 -0
- package/skills/convex/references/features/auth-organizations.md +1141 -0
- package/skills/convex/references/features/auth-polar.md +579 -0
- package/skills/convex/references/features/auth.md +470 -0
- package/skills/convex/references/features/create-plugins.md +153 -0
- package/skills/convex/references/features/http.md +676 -0
- package/skills/convex/references/features/migrations.md +162 -0
- package/skills/convex/references/features/orm.md +1166 -0
- package/skills/convex/references/features/react.md +657 -0
- package/skills/convex/references/features/scheduling.md +267 -0
- package/skills/convex/references/features/testing.md +209 -0
- package/skills/convex/references/setup/auth.md +501 -0
- package/skills/convex/references/setup/biome.md +190 -0
- package/skills/convex/references/setup/doc-guidelines.md +145 -0
- package/skills/convex/references/setup/index.md +759 -0
- package/skills/convex/references/setup/next.md +116 -0
- package/skills/convex/references/setup/react.md +175 -0
- package/skills/convex/references/setup/server.md +473 -0
- package/skills/convex/references/setup/start.md +67 -0
- package/LICENSE +0 -21
- package/README.md +0 -0
- package/dist/index.d.mts +0 -5
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -6
- package/dist/index.mjs.map +0 -1
package/bin/intent.js
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-DdjN63Io.js";
|
|
2
|
+
import * as convex_values0 from "convex/values";
|
|
3
|
+
import { GenericId, Infer, Value } from "convex/values";
|
|
4
|
+
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
|
5
|
+
|
|
6
|
+
//#region src/aggregate-core/schema.d.ts
|
|
7
|
+
declare const aggregateStorageTables: {
|
|
8
|
+
readonly aggregate_rank_node: ConvexTableWithColumns<{
|
|
9
|
+
name: "aggregate_rank_node";
|
|
10
|
+
columns: {
|
|
11
|
+
aggregate: ConvexCustomBuilderInitial<"", convex_values0.VObject<{
|
|
12
|
+
count: number;
|
|
13
|
+
sum: number;
|
|
14
|
+
}, {
|
|
15
|
+
count: convex_values0.VFloat64<number, "required">;
|
|
16
|
+
sum: convex_values0.VFloat64<number, "required">;
|
|
17
|
+
}, "required", "count" | "sum">> & {
|
|
18
|
+
_: {
|
|
19
|
+
tableName: "aggregate_rank_node";
|
|
20
|
+
};
|
|
21
|
+
} & {
|
|
22
|
+
_: {
|
|
23
|
+
fieldName: "aggregate";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
items: ConvexCustomBuilderInitial<"", convex_values0.VArray<{
|
|
27
|
+
k: any;
|
|
28
|
+
v: any;
|
|
29
|
+
s: number;
|
|
30
|
+
}[], convex_values0.VObject<{
|
|
31
|
+
k: any;
|
|
32
|
+
v: any;
|
|
33
|
+
s: number;
|
|
34
|
+
}, {
|
|
35
|
+
k: convex_values0.VAny<any, "required", string>;
|
|
36
|
+
v: convex_values0.VAny<any, "required", string>;
|
|
37
|
+
s: convex_values0.VFloat64<number, "required">;
|
|
38
|
+
}, "required", "k" | "v" | "s" | `k.${string}` | `v.${string}`>, "required">> & {
|
|
39
|
+
_: {
|
|
40
|
+
notNull: true;
|
|
41
|
+
};
|
|
42
|
+
} & {
|
|
43
|
+
_: {
|
|
44
|
+
tableName: "aggregate_rank_node";
|
|
45
|
+
};
|
|
46
|
+
} & {
|
|
47
|
+
_: {
|
|
48
|
+
fieldName: "items";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
subtrees: ConvexCustomBuilderInitial<"", convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">> & {
|
|
52
|
+
_: {
|
|
53
|
+
notNull: true;
|
|
54
|
+
};
|
|
55
|
+
} & {
|
|
56
|
+
_: {
|
|
57
|
+
tableName: "aggregate_rank_node";
|
|
58
|
+
};
|
|
59
|
+
} & {
|
|
60
|
+
_: {
|
|
61
|
+
fieldName: "subtrees";
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}, {
|
|
66
|
+
by_creation_time: ["_creationTime"];
|
|
67
|
+
}, {}, {}, {}>;
|
|
68
|
+
readonly aggregate_rank_tree: ConvexTableWithColumns<{
|
|
69
|
+
name: "aggregate_rank_tree";
|
|
70
|
+
columns: {
|
|
71
|
+
aggregateName: ConvexTextBuilderInitial<""> & {
|
|
72
|
+
_: {
|
|
73
|
+
notNull: true;
|
|
74
|
+
};
|
|
75
|
+
} & {
|
|
76
|
+
_: {
|
|
77
|
+
tableName: "aggregate_rank_tree";
|
|
78
|
+
};
|
|
79
|
+
} & {
|
|
80
|
+
_: {
|
|
81
|
+
fieldName: "aggregateName";
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
maxNodeSize: ConvexNumberBuilderInitial<""> & {
|
|
85
|
+
_: {
|
|
86
|
+
notNull: true;
|
|
87
|
+
};
|
|
88
|
+
} & {
|
|
89
|
+
_: {
|
|
90
|
+
tableName: "aggregate_rank_tree";
|
|
91
|
+
};
|
|
92
|
+
} & {
|
|
93
|
+
_: {
|
|
94
|
+
fieldName: "maxNodeSize";
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
namespace: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
|
|
98
|
+
_: {
|
|
99
|
+
tableName: "aggregate_rank_tree";
|
|
100
|
+
};
|
|
101
|
+
} & {
|
|
102
|
+
_: {
|
|
103
|
+
fieldName: "namespace";
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
root: ConvexIdBuilderInitial<"", "aggregate_rank_node"> & {
|
|
107
|
+
_: {
|
|
108
|
+
notNull: true;
|
|
109
|
+
};
|
|
110
|
+
} & {
|
|
111
|
+
_: {
|
|
112
|
+
tableName: "aggregate_rank_tree";
|
|
113
|
+
};
|
|
114
|
+
} & {
|
|
115
|
+
_: {
|
|
116
|
+
fieldName: "root";
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}, {
|
|
121
|
+
by_creation_time: ["_creationTime"];
|
|
122
|
+
by_namespace: ["namespace", "_creationTime"];
|
|
123
|
+
by_aggregate_name: ["aggregateName", "_creationTime"];
|
|
124
|
+
}, {}, {}, {}>;
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/aggregate-core/btree.d.ts
|
|
128
|
+
type Key$2 = Value;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/aggregate-core/positions.d.ts
|
|
131
|
+
type Bound$1<K extends Key$2, ID extends string> = {
|
|
132
|
+
key: K;
|
|
133
|
+
id?: ID;
|
|
134
|
+
inclusive: boolean;
|
|
135
|
+
};
|
|
136
|
+
type SideBounds<K extends Key$2, ID extends string> = {
|
|
137
|
+
lower?: Bound$1<K, ID>;
|
|
138
|
+
upper?: Bound$1<K, ID>;
|
|
139
|
+
};
|
|
140
|
+
type TuplePrefix<K extends unknown[], P extends unknown[] = []> = P['length'] extends K['length'] ? P : P | TuplePrefix<K, [...P, K[P['length']]]>;
|
|
141
|
+
type Bounds$1<K extends Key$2, ID extends string> = SideBounds<K, ID> | (K extends unknown[] ? {
|
|
142
|
+
prefix: TuplePrefix<Extract<K, unknown[]>>;
|
|
143
|
+
} : never) | {
|
|
144
|
+
eq: K;
|
|
145
|
+
};
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/aggregate-core/runtime.d.ts
|
|
148
|
+
type Key = Key$2;
|
|
149
|
+
type Bound<K extends Key, ID extends string> = Bound$1<K, ID>;
|
|
150
|
+
type Bounds<K extends Key, ID extends string> = Bounds$1<K, ID>;
|
|
151
|
+
type AggregateQueryCtx = {
|
|
152
|
+
db: GenericDatabaseReader<any>;
|
|
153
|
+
orm: unknown;
|
|
154
|
+
};
|
|
155
|
+
type AggregateMutationCtx = {
|
|
156
|
+
db: GenericDatabaseWriter<any>;
|
|
157
|
+
orm: unknown;
|
|
158
|
+
};
|
|
159
|
+
type RunQueryCtx = AggregateQueryCtx;
|
|
160
|
+
type RunMutationCtx = AggregateMutationCtx;
|
|
161
|
+
type Item<K extends Key, ID extends string> = {
|
|
162
|
+
id: ID;
|
|
163
|
+
key: K;
|
|
164
|
+
sumValue: number;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Write data to be aggregated, and read aggregated data.
|
|
168
|
+
*/
|
|
169
|
+
declare class Aggregate<K extends Key, ID extends string, TNamespace extends Value | undefined = undefined> {
|
|
170
|
+
protected readonly aggregateName: string;
|
|
171
|
+
constructor(aggregateName: string);
|
|
172
|
+
count(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
|
|
173
|
+
bounds?: Bounds<K, ID>;
|
|
174
|
+
}, TNamespace>): Promise<number>;
|
|
175
|
+
countBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{
|
|
176
|
+
bounds?: Bounds<K, ID>;
|
|
177
|
+
}, TNamespace>): Promise<number[]>;
|
|
178
|
+
sum(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
|
|
179
|
+
bounds?: Bounds<K, ID>;
|
|
180
|
+
}, TNamespace>): Promise<number>;
|
|
181
|
+
sumBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{
|
|
182
|
+
bounds?: Bounds<K, ID>;
|
|
183
|
+
}, TNamespace>): Promise<number[]>;
|
|
184
|
+
at(ctx: RunQueryCtx, offset: number, ...opts: NamespacedOpts<{
|
|
185
|
+
bounds?: Bounds<K, ID>;
|
|
186
|
+
}, TNamespace>): Promise<Item<K, ID>>;
|
|
187
|
+
atBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{
|
|
188
|
+
offset: number;
|
|
189
|
+
bounds?: Bounds<K, ID>;
|
|
190
|
+
}, TNamespace>): Promise<Item<K, ID>[]>;
|
|
191
|
+
indexOf(ctx: RunQueryCtx, key: K, ...opts: NamespacedOpts<{
|
|
192
|
+
bounds?: Bounds<K, ID>;
|
|
193
|
+
id?: ID;
|
|
194
|
+
order?: 'asc' | 'desc';
|
|
195
|
+
}, TNamespace>): Promise<number>;
|
|
196
|
+
offsetOf(ctx: RunQueryCtx, key: K, namespace: TNamespace, id?: ID, bounds?: Bounds<K, ID>): Promise<number>;
|
|
197
|
+
offsetUntil(ctx: RunQueryCtx, key: K, namespace: TNamespace, id?: ID, bounds?: Bounds<K, ID>): Promise<number>;
|
|
198
|
+
min(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
|
|
199
|
+
bounds?: Bounds<K, ID>;
|
|
200
|
+
}, TNamespace>): Promise<Item<K, ID> | null>;
|
|
201
|
+
max(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
|
|
202
|
+
bounds?: Bounds<K, ID>;
|
|
203
|
+
}, TNamespace>): Promise<Item<K, ID> | null>;
|
|
204
|
+
random(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
|
|
205
|
+
bounds?: Bounds<K, ID>;
|
|
206
|
+
}, TNamespace>): Promise<Item<K, ID> | null>;
|
|
207
|
+
paginate(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
|
|
208
|
+
bounds?: Bounds<K, ID>;
|
|
209
|
+
cursor?: string;
|
|
210
|
+
order?: 'asc' | 'desc';
|
|
211
|
+
pageSize?: number;
|
|
212
|
+
}, TNamespace>): Promise<{
|
|
213
|
+
cursor: string;
|
|
214
|
+
isDone: boolean;
|
|
215
|
+
page: Item<K, ID>[];
|
|
216
|
+
}>;
|
|
217
|
+
iter(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
|
|
218
|
+
bounds?: Bounds<K, ID>;
|
|
219
|
+
order?: 'asc' | 'desc';
|
|
220
|
+
pageSize?: number;
|
|
221
|
+
}, TNamespace>): AsyncGenerator<Item<K, ID>, void, undefined>;
|
|
222
|
+
_insert(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID, summand?: number): Promise<void>;
|
|
223
|
+
_delete(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID): Promise<void>;
|
|
224
|
+
_replace(ctx: RunMutationCtx, currentNamespace: TNamespace, currentKey: K, newNamespace: TNamespace, newKey: K, id: ID, summand?: number): Promise<void>;
|
|
225
|
+
_insertIfDoesNotExist(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID, summand?: number): Promise<void>;
|
|
226
|
+
_deleteIfExists(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID): Promise<void>;
|
|
227
|
+
_replaceOrInsert(ctx: RunMutationCtx, currentNamespace: TNamespace, currentKey: K, newNamespace: TNamespace, newKey: K, id: ID, summand?: number): Promise<void>;
|
|
228
|
+
clear(ctx: RunMutationCtx, ...opts: NamespacedOpts<{
|
|
229
|
+
maxNodeSize?: number;
|
|
230
|
+
rootLazy?: boolean;
|
|
231
|
+
}, TNamespace>): Promise<void>;
|
|
232
|
+
makeRootLazy(ctx: RunMutationCtx, namespace: TNamespace): Promise<void>;
|
|
233
|
+
paginateNamespaces(ctx: RunQueryCtx, cursor?: string, pageSize?: number): Promise<{
|
|
234
|
+
cursor: string;
|
|
235
|
+
isDone: boolean;
|
|
236
|
+
page: TNamespace[];
|
|
237
|
+
}>;
|
|
238
|
+
iterNamespaces(ctx: RunQueryCtx, pageSize?: number): AsyncGenerator<TNamespace, void, undefined>;
|
|
239
|
+
clearAll(ctx: RunMutationCtx & RunQueryCtx, opts?: {
|
|
240
|
+
maxNodeSize?: number;
|
|
241
|
+
rootLazy?: boolean;
|
|
242
|
+
}): Promise<void>;
|
|
243
|
+
makeAllRootsLazy(ctx: RunMutationCtx & RunQueryCtx): Promise<void>;
|
|
244
|
+
}
|
|
245
|
+
type DirectAggregateType<K extends Key, ID extends string, TNamespace extends Value | undefined = undefined> = {
|
|
246
|
+
Key: K;
|
|
247
|
+
Id: ID;
|
|
248
|
+
Namespace?: TNamespace;
|
|
249
|
+
};
|
|
250
|
+
type AnyDirectAggregateType$1 = DirectAggregateType<Key, string, Value | undefined>;
|
|
251
|
+
type DirectAggregateNamespace<T extends AnyDirectAggregateType$1> = 'Namespace' extends keyof T ? T['Namespace'] : undefined;
|
|
252
|
+
declare class DirectAggregate$1<T extends AnyDirectAggregateType$1> extends Aggregate<T['Key'], T['Id'], DirectAggregateNamespace<T>> {
|
|
253
|
+
constructor(config: {
|
|
254
|
+
name: string;
|
|
255
|
+
});
|
|
256
|
+
insert(ctx: RunMutationCtx, args: NamespacedArgs<{
|
|
257
|
+
id: T['Id'];
|
|
258
|
+
key: T['Key'];
|
|
259
|
+
sumValue?: number;
|
|
260
|
+
}, DirectAggregateNamespace<T>>): Promise<void>;
|
|
261
|
+
delete(ctx: RunMutationCtx, args: NamespacedArgs<{
|
|
262
|
+
id: T['Id'];
|
|
263
|
+
key: T['Key'];
|
|
264
|
+
}, DirectAggregateNamespace<T>>): Promise<void>;
|
|
265
|
+
replace(ctx: RunMutationCtx, currentItem: NamespacedArgs<{
|
|
266
|
+
id: T['Id'];
|
|
267
|
+
key: T['Key'];
|
|
268
|
+
}, DirectAggregateNamespace<T>>, newItem: NamespacedArgs<{
|
|
269
|
+
key: T['Key'];
|
|
270
|
+
sumValue?: number;
|
|
271
|
+
}, DirectAggregateNamespace<T>>): Promise<void>;
|
|
272
|
+
insertIfDoesNotExist(ctx: RunMutationCtx, args: NamespacedArgs<{
|
|
273
|
+
id: T['Id'];
|
|
274
|
+
key: T['Key'];
|
|
275
|
+
sumValue?: number;
|
|
276
|
+
}, DirectAggregateNamespace<T>>): Promise<void>;
|
|
277
|
+
deleteIfExists(ctx: RunMutationCtx, args: NamespacedArgs<{
|
|
278
|
+
id: T['Id'];
|
|
279
|
+
key: T['Key'];
|
|
280
|
+
}, DirectAggregateNamespace<T>>): Promise<void>;
|
|
281
|
+
replaceOrInsert(ctx: RunMutationCtx, currentItem: NamespacedArgs<{
|
|
282
|
+
id: T['Id'];
|
|
283
|
+
key: T['Key'];
|
|
284
|
+
}, DirectAggregateNamespace<T>>, newItem: NamespacedArgs<{
|
|
285
|
+
key: T['Key'];
|
|
286
|
+
sumValue?: number;
|
|
287
|
+
}, DirectAggregateNamespace<T>>): Promise<void>;
|
|
288
|
+
}
|
|
289
|
+
type TableAggregateType<K extends Key, DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel>, TNamespace extends Value | undefined = undefined> = {
|
|
290
|
+
DataModel: DataModel;
|
|
291
|
+
Key: K;
|
|
292
|
+
Namespace?: TNamespace;
|
|
293
|
+
TableName: TableName;
|
|
294
|
+
};
|
|
295
|
+
type AnyTableAggregateType$1 = TableAggregateType<Key, GenericDataModel, TableNamesInDataModel<GenericDataModel>, Value | undefined>;
|
|
296
|
+
type TableAggregateNamespace<T extends AnyTableAggregateType$1> = 'Namespace' extends keyof T ? T['Namespace'] : undefined;
|
|
297
|
+
type TableAggregateDocument<T extends AnyTableAggregateType$1> = DocumentByName<T['DataModel'], T['TableName']>;
|
|
298
|
+
type TableAggregateId<T extends AnyTableAggregateType$1> = GenericId<T['TableName']>;
|
|
299
|
+
type TableAggregateTrigger<Ctx, T extends AnyTableAggregateType$1> = Trigger<Ctx, T['DataModel'], T['TableName']>;
|
|
300
|
+
declare class TableAggregate$1<T extends AnyTableAggregateType$1> extends Aggregate<T['Key'], GenericId<T['TableName']>, TableAggregateNamespace<T>> {
|
|
301
|
+
constructor(options: {
|
|
302
|
+
name: string;
|
|
303
|
+
table: T['TableName'];
|
|
304
|
+
sortKey: (d: TableAggregateDocument<T>) => T['Key'];
|
|
305
|
+
sumValue?: (d: TableAggregateDocument<T>) => number;
|
|
306
|
+
} & (undefined extends TableAggregateNamespace<T> ? {
|
|
307
|
+
namespace?: (d: TableAggregateDocument<T>) => TableAggregateNamespace<T>;
|
|
308
|
+
} : {
|
|
309
|
+
namespace: (d: TableAggregateDocument<T>) => TableAggregateNamespace<T>;
|
|
310
|
+
}));
|
|
311
|
+
private readonly options;
|
|
312
|
+
insert(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
|
|
313
|
+
delete(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
|
|
314
|
+
replace(ctx: RunMutationCtx, oldDoc: TableAggregateDocument<T>, newDoc: TableAggregateDocument<T>): Promise<void>;
|
|
315
|
+
insertIfDoesNotExist(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
|
|
316
|
+
deleteIfExists(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
|
|
317
|
+
replaceOrInsert(ctx: RunMutationCtx, oldDoc: TableAggregateDocument<T>, newDoc: TableAggregateDocument<T>): Promise<void>;
|
|
318
|
+
indexOfDoc(ctx: RunQueryCtx, doc: TableAggregateDocument<T>, opts?: {
|
|
319
|
+
id?: TableAggregateId<T>;
|
|
320
|
+
bounds?: Bounds<T['Key'], TableAggregateId<T>>;
|
|
321
|
+
order?: 'asc' | 'desc';
|
|
322
|
+
}): Promise<number>;
|
|
323
|
+
trigger<Ctx extends RunMutationCtx>(): TableAggregateTrigger<Ctx, T>;
|
|
324
|
+
idempotentTrigger<Ctx extends RunMutationCtx>(): TableAggregateTrigger<Ctx, T>;
|
|
325
|
+
}
|
|
326
|
+
type Trigger<Ctx, DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel>> = (ctx: Ctx, change: Change<DataModel, TableName>) => Promise<void>;
|
|
327
|
+
type Change<DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel>> = {
|
|
328
|
+
id: GenericId<TableName> | string;
|
|
329
|
+
} & ({
|
|
330
|
+
operation: 'insert';
|
|
331
|
+
oldDoc: null;
|
|
332
|
+
newDoc: DocumentByName<DataModel, TableName>;
|
|
333
|
+
} | {
|
|
334
|
+
operation: 'update';
|
|
335
|
+
oldDoc: DocumentByName<DataModel, TableName>;
|
|
336
|
+
newDoc: DocumentByName<DataModel, TableName>;
|
|
337
|
+
} | {
|
|
338
|
+
operation: 'delete';
|
|
339
|
+
oldDoc: DocumentByName<DataModel, TableName>;
|
|
340
|
+
newDoc: null;
|
|
341
|
+
});
|
|
342
|
+
type NamespacedArgs<Args, TNamespace> = (Args & {
|
|
343
|
+
namespace: TNamespace;
|
|
344
|
+
}) | (TNamespace extends undefined ? Args : never);
|
|
345
|
+
type NamespacedOpts<Opts, TNamespace> = [{
|
|
346
|
+
namespace: TNamespace;
|
|
347
|
+
} & Opts] | (undefined extends TNamespace ? [Opts?] : never);
|
|
348
|
+
type NamespacedOptsBatch<Opts, TNamespace> = Array<undefined extends TNamespace ? Opts : {
|
|
349
|
+
namespace: TNamespace;
|
|
350
|
+
} & Opts>;
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/orm/aggregate.d.ts
|
|
353
|
+
type AggregateTriggerFactoryLike = {
|
|
354
|
+
trigger: () => (ctx: unknown, change: unknown) => Promise<void>;
|
|
355
|
+
};
|
|
356
|
+
type AggregateTriggerCtx<T extends AggregateTriggerFactoryLike> = Parameters<ReturnType<T['trigger']>>[0];
|
|
357
|
+
type AggregateTriggerChange<T extends AggregateTriggerFactoryLike> = Parameters<ReturnType<T['trigger']>>[1];
|
|
358
|
+
type AggregateTriggerOverload<T extends AggregateTriggerFactoryLike> = {
|
|
359
|
+
(): ReturnType<T['trigger']>;
|
|
360
|
+
<TChange, TCtx>(change: TChange, ctx: TCtx): Promise<void>;
|
|
361
|
+
};
|
|
362
|
+
type OrmCompatibleAggregate<T extends AggregateTriggerFactoryLike> = Omit<T, 'trigger'> & {
|
|
363
|
+
trigger: AggregateTriggerOverload<T>;
|
|
364
|
+
};
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/aggregate/index.d.ts
|
|
367
|
+
type Key$1 = Key;
|
|
368
|
+
type AnyDirectAggregateType = DirectAggregateType<Key$1, string, Value | undefined>;
|
|
369
|
+
type AnyTableAggregateType = TableAggregateType<Key$1, any, any, Value | undefined>;
|
|
370
|
+
type CoreTrigger<T extends AnyTableAggregateType> = ReturnType<TableAggregate$1<T>['trigger']>;
|
|
371
|
+
type CoreIdempotentTrigger<T extends AnyTableAggregateType> = ReturnType<TableAggregate$1<T>['idempotentTrigger']>;
|
|
372
|
+
declare class TableAggregate<T extends AnyTableAggregateType> extends TableAggregate$1<T> {
|
|
373
|
+
trigger: {
|
|
374
|
+
(): CoreTrigger<T>;
|
|
375
|
+
<TChange, TCtx>(change: TChange, ctx: TCtx): Promise<void>;
|
|
376
|
+
};
|
|
377
|
+
idempotentTrigger: {
|
|
378
|
+
(): CoreIdempotentTrigger<T>;
|
|
379
|
+
<TChange, TCtx>(change: TChange, ctx: TCtx): Promise<void>;
|
|
380
|
+
};
|
|
381
|
+
constructor(...args: ConstructorParameters<typeof TableAggregate$1>);
|
|
382
|
+
}
|
|
383
|
+
declare class DirectAggregate<T extends AnyDirectAggregateType> extends DirectAggregate$1<T> {}
|
|
384
|
+
declare function createDirectAggregate<T extends AnyDirectAggregateType>(config: {
|
|
385
|
+
name: string;
|
|
386
|
+
}): DirectAggregate<T>;
|
|
387
|
+
//#endregion
|
|
388
|
+
export { type AggregateTriggerChange, type AggregateTriggerCtx, type AggregateTriggerFactoryLike, type Bound, type Bounds, DirectAggregate, type DirectAggregateType, type Item, type Key, type OrmCompatibleAggregate, type RunMutationCtx, type RunQueryCtx, TableAggregate, type TableAggregateType, aggregateStorageTables, createDirectAggregate };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { n as TableAggregate$1, r as aggregateStorageTables, t as DirectAggregate$1 } from "../runtime-CtvJPkur.js";
|
|
2
|
+
|
|
3
|
+
//#region src/aggregate/index.ts
|
|
4
|
+
const wrapTriggerFactory = (methodName, factory) => ((...args) => {
|
|
5
|
+
if (args.length === 0) return factory();
|
|
6
|
+
if (args.length === 2) {
|
|
7
|
+
const [change, ctx] = args;
|
|
8
|
+
return factory()(ctx, change);
|
|
9
|
+
}
|
|
10
|
+
throw new Error(`Invalid aggregate.${methodName} invocation. Use ${methodName}() or ${methodName}(change, ctx).`);
|
|
11
|
+
});
|
|
12
|
+
var TableAggregate = class extends TableAggregate$1 {
|
|
13
|
+
constructor(...args) {
|
|
14
|
+
super(...args);
|
|
15
|
+
const triggerFactory = super.trigger.bind(this);
|
|
16
|
+
const idempotentFactory = super.idempotentTrigger.bind(this);
|
|
17
|
+
Object.defineProperty(this, "trigger", {
|
|
18
|
+
configurable: true,
|
|
19
|
+
enumerable: false,
|
|
20
|
+
value: wrapTriggerFactory("trigger", triggerFactory),
|
|
21
|
+
writable: true
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "idempotentTrigger", {
|
|
24
|
+
configurable: true,
|
|
25
|
+
enumerable: false,
|
|
26
|
+
value: wrapTriggerFactory("idempotentTrigger", idempotentFactory),
|
|
27
|
+
writable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var DirectAggregate = class extends DirectAggregate$1 {};
|
|
32
|
+
function createDirectAggregate(config) {
|
|
33
|
+
return new DirectAggregate(config);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { DirectAggregate, TableAggregate, aggregateStorageTables, createDirectAggregate };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getFunctionName, makeFunctionReference } from "convex/server";
|
|
2
|
+
|
|
3
|
+
//#region src/server/context-utils.ts
|
|
4
|
+
const isQueryCtx = (ctx) => "db" in ctx;
|
|
5
|
+
const isMutationCtx = (ctx) => "db" in ctx && "scheduler" in ctx;
|
|
6
|
+
const isActionCtx = (ctx) => "runAction" in ctx;
|
|
7
|
+
const isRunMutationCtx = (ctx) => "runMutation" in ctx;
|
|
8
|
+
const requireQueryCtx = (ctx) => {
|
|
9
|
+
if (!isQueryCtx(ctx)) throw new Error("Query context required");
|
|
10
|
+
return ctx;
|
|
11
|
+
};
|
|
12
|
+
const requireMutationCtx = (ctx) => {
|
|
13
|
+
if (!isMutationCtx(ctx)) throw new Error("Mutation context required");
|
|
14
|
+
return ctx;
|
|
15
|
+
};
|
|
16
|
+
const requireActionCtx = (ctx) => {
|
|
17
|
+
if (!isActionCtx(ctx)) throw new Error("Action context required");
|
|
18
|
+
return ctx;
|
|
19
|
+
};
|
|
20
|
+
const requireRunMutationCtx = (ctx) => {
|
|
21
|
+
if (!isRunMutationCtx(ctx)) throw new Error("Mutation or action context required");
|
|
22
|
+
return ctx;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/server/api-entry.ts
|
|
27
|
+
function getGeneratedValue(root, path) {
|
|
28
|
+
let current = root;
|
|
29
|
+
for (let index = 0; index < path.length; index += 1) {
|
|
30
|
+
const segment = path[index];
|
|
31
|
+
if (typeof current !== "object" || current === null) throw new Error(`[kitcn] Invalid generated path: ${path.join(".")}`);
|
|
32
|
+
const directValue = current[segment];
|
|
33
|
+
if (directValue !== void 0) {
|
|
34
|
+
current = directValue;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
let matched = false;
|
|
38
|
+
for (let end = path.length - 1; end > index; end -= 1) {
|
|
39
|
+
const collapsedSegment = path.slice(index, end + 1).join("/");
|
|
40
|
+
const collapsedValue = current[collapsedSegment];
|
|
41
|
+
if (collapsedValue === void 0) continue;
|
|
42
|
+
current = collapsedValue;
|
|
43
|
+
index = end;
|
|
44
|
+
matched = true;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
if (!matched) throw new Error(`[kitcn] Invalid generated path: ${path.join(".")}`);
|
|
48
|
+
}
|
|
49
|
+
return current;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build a generated API leaf from a Convex FunctionReference name.
|
|
53
|
+
* Returns a plain FunctionReference-compatible object with attached cRPC metadata.
|
|
54
|
+
*/
|
|
55
|
+
function createApiLeaf(...args) {
|
|
56
|
+
const [fnOrRoot, pathOrMeta, maybeMeta] = args;
|
|
57
|
+
const meta = maybeMeta ?? pathOrMeta;
|
|
58
|
+
const functionRef = makeFunctionReference(getFunctionName(Array.isArray(pathOrMeta) ? getGeneratedValue(fnOrRoot, pathOrMeta) : fnOrRoot));
|
|
59
|
+
return Object.assign(functionRef, meta, { functionRef });
|
|
60
|
+
}
|
|
61
|
+
function createGeneratedFunctionReference(name) {
|
|
62
|
+
return makeFunctionReference(name);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { isMutationCtx as a, requireActionCtx as c, requireRunMutationCtx as d, isActionCtx as i, requireMutationCtx as l, createGeneratedFunctionReference as n, isQueryCtx as o, getGeneratedValue as r, isRunMutationCtx as s, createApiLeaf as t, requireQueryCtx as u };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { convexClient } from "@convex-dev/better-auth/client/plugins";
|
|
3
|
+
import { ConvexReactClient } from "convex/react";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
import { AuthClient, AuthClient as AuthClient$1 } from "@convex-dev/better-auth/react";
|
|
7
|
+
|
|
8
|
+
//#region src/auth-client/convex-auth-provider.d.ts
|
|
9
|
+
type ConvexAuthProviderProps = {
|
|
10
|
+
children: ReactNode; /** Convex client instance */
|
|
11
|
+
client: ConvexReactClient; /** Better Auth client instance */
|
|
12
|
+
authClient: AuthClient$1; /** Initial session token (from SSR) */
|
|
13
|
+
initialToken?: string; /** Callback when mutation called while unauthorized */
|
|
14
|
+
onMutationUnauthorized?: () => void; /** Callback when query called while unauthorized */
|
|
15
|
+
onQueryUnauthorized?: (info: {
|
|
16
|
+
queryName: string;
|
|
17
|
+
}) => void; /** Custom function to detect UNAUTHORIZED errors. Default checks code property. */
|
|
18
|
+
isUnauthorized?: (error: unknown) => boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Unified auth provider for Convex + Better Auth.
|
|
22
|
+
* Handles token sync, HMR persistence, and auth callbacks.
|
|
23
|
+
*
|
|
24
|
+
* Structure: AuthProvider wraps ConvexAuthProviderInner so that
|
|
25
|
+
* useAuthStore() is available when creating fetchAccessToken.
|
|
26
|
+
*/
|
|
27
|
+
declare function ConvexAuthProvider({
|
|
28
|
+
children,
|
|
29
|
+
client,
|
|
30
|
+
authClient,
|
|
31
|
+
initialToken,
|
|
32
|
+
onMutationUnauthorized,
|
|
33
|
+
onQueryUnauthorized,
|
|
34
|
+
isUnauthorized
|
|
35
|
+
}: ConvexAuthProviderProps): react_jsx_runtime0.JSX.Element;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { type AuthClient, ConvexAuthProvider, ConvexAuthProviderProps, convexClient };
|