better-convex 0.9.0 → 0.9.2
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 +4 -1
- package/dist/auth/client/index.js +50 -29
- package/dist/auth/index.d.ts +80 -79
- package/dist/auth/index.js +27 -18
- package/dist/auth/nextjs/index.d.ts +5 -3
- package/dist/auth/nextjs/index.js +5 -4
- package/dist/{caller-factory-CCsm4Dut.js → caller-factory-C1uAqm5w.js} +20 -11
- package/dist/cli.mjs +17 -12
- package/dist/{codegen-BS36cYTH.mjs → codegen-CMQIKrqh.mjs} +37 -32
- package/dist/orm/index.d.ts +1 -1
- package/dist/plugins/index.d.ts +4 -4
- package/dist/plugins/ratelimit/index.d.ts +4 -1
- package/dist/{procedure-caller-DYjpq7rG.d.ts → procedure-caller-kZJx_hmP.d.ts} +7 -2
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +7 -4
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-UavDdMUX.d.ts → where-clause-compiler-DjFwXrQn.d.ts} +4 -1
- package/package.json +1 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../validators-BcQFm1oY.js";
|
|
2
|
+
import { Jn as ConvexTextBuilderInitial, Ot as ConvexCustomBuilderInitial, in as ConvexTableWithColumns, vt as ConvexNumberBuilderInitial, xt as ConvexIdBuilderInitial } from "../where-clause-compiler-DjFwXrQn.js";
|
|
3
|
+
import "../query-context-ji7By8u0.js";
|
|
4
|
+
import "../orm/index.js";
|
|
2
5
|
import * as convex_values0 from "convex/values";
|
|
3
6
|
import { GenericId, Infer, Value } from "convex/values";
|
|
4
7
|
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
|
@@ -107,48 +107,69 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
|
|
|
107
107
|
authStore
|
|
108
108
|
]);
|
|
109
109
|
const fetchAccessToken = useCallback(async ({ forceRefreshToken = false } = {}) => {
|
|
110
|
+
const fetchFreshToken = () => {
|
|
111
|
+
if (pendingTokenRef.current) return pendingTokenRef.current;
|
|
112
|
+
pendingTokenRef.current = authClient.convex.token({ fetchOptions: { throw: false } }).then((result) => {
|
|
113
|
+
const jwt = result.data?.token || null;
|
|
114
|
+
if (jwt) {
|
|
115
|
+
const exp = decodeJwtExp(jwt);
|
|
116
|
+
authStore.set("token", jwt);
|
|
117
|
+
authStore.set("expiresAt", exp);
|
|
118
|
+
return jwt;
|
|
119
|
+
}
|
|
120
|
+
authStore.set("token", null);
|
|
121
|
+
authStore.set("expiresAt", null);
|
|
122
|
+
return null;
|
|
123
|
+
}).catch((error) => {
|
|
124
|
+
authStore.set("token", null);
|
|
125
|
+
authStore.set("expiresAt", null);
|
|
126
|
+
console.error("[fetchAccessToken] error", error);
|
|
127
|
+
return null;
|
|
128
|
+
}).finally(() => {
|
|
129
|
+
pendingTokenRef.current = null;
|
|
130
|
+
});
|
|
131
|
+
return pendingTokenRef.current;
|
|
132
|
+
};
|
|
133
|
+
const fetchFreshTokenForced = async () => {
|
|
134
|
+
if (pendingTokenRef.current) {
|
|
135
|
+
const token = await pendingTokenRef.current;
|
|
136
|
+
if (token) return token;
|
|
137
|
+
}
|
|
138
|
+
return fetchFreshToken();
|
|
139
|
+
};
|
|
110
140
|
const currentSession = sessionRef.current;
|
|
111
141
|
const currentIsPending = isPendingRef.current;
|
|
112
142
|
if (!hasActiveSessionData(currentSession)) {
|
|
113
|
-
if (
|
|
114
|
-
authStore.
|
|
115
|
-
authStore.
|
|
143
|
+
if (currentIsPending) {
|
|
144
|
+
if (!forceRefreshToken) return authStore.get("token");
|
|
145
|
+
const cachedToken = authStore.get("token");
|
|
146
|
+
const freshToken = await fetchFreshTokenForced();
|
|
147
|
+
if (!freshToken && cachedToken) {
|
|
148
|
+
authStore.set("token", cachedToken);
|
|
149
|
+
authStore.set("expiresAt", decodeJwtExp(cachedToken));
|
|
150
|
+
return cachedToken;
|
|
151
|
+
}
|
|
152
|
+
return freshToken;
|
|
116
153
|
}
|
|
117
|
-
|
|
154
|
+
authStore.set("token", null);
|
|
155
|
+
authStore.set("expiresAt", null);
|
|
156
|
+
return null;
|
|
118
157
|
}
|
|
119
|
-
const
|
|
158
|
+
const cachedToken_0 = authStore.get("token");
|
|
120
159
|
const expiresAt = authStore.get("expiresAt");
|
|
121
160
|
const timeRemaining = expiresAt ? expiresAt - Date.now() : 0;
|
|
122
|
-
if (!forceRefreshToken &&
|
|
161
|
+
if (!forceRefreshToken && cachedToken_0 && expiresAt && timeRemaining >= 6e4) return cachedToken_0;
|
|
123
162
|
if (!forceRefreshToken && pendingTokenRef.current) return pendingTokenRef.current;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (jwt) {
|
|
127
|
-
const exp = decodeJwtExp(jwt);
|
|
128
|
-
authStore.set("token", jwt);
|
|
129
|
-
authStore.set("expiresAt", exp);
|
|
130
|
-
return jwt;
|
|
131
|
-
}
|
|
132
|
-
authStore.set("token", null);
|
|
133
|
-
authStore.set("expiresAt", null);
|
|
134
|
-
return null;
|
|
135
|
-
}).catch((error) => {
|
|
136
|
-
authStore.set("token", null);
|
|
137
|
-
authStore.set("expiresAt", null);
|
|
138
|
-
console.error("[fetchAccessToken] error", error);
|
|
139
|
-
return null;
|
|
140
|
-
}).finally(() => {
|
|
141
|
-
pendingTokenRef.current = null;
|
|
142
|
-
});
|
|
143
|
-
return pendingTokenRef.current;
|
|
163
|
+
if (forceRefreshToken) return fetchFreshTokenForced();
|
|
164
|
+
return fetchFreshToken();
|
|
144
165
|
}, [authStore, authClient]);
|
|
145
166
|
const useAuth = useCallback(function useConvexAuthHook() {
|
|
146
|
-
const
|
|
167
|
+
const token_0 = authStore.get("token");
|
|
147
168
|
const hasSession_0 = hasActiveSessionData(sessionRef.current);
|
|
148
169
|
const sessionMissing = !hasSession_0 && !isPendingRef.current;
|
|
149
170
|
return {
|
|
150
|
-
isLoading: isPendingRef.current && !
|
|
151
|
-
isAuthenticated: sessionMissing ? false : hasSession_0 ||
|
|
171
|
+
isLoading: isPendingRef.current && !token_0,
|
|
172
|
+
isAuthenticated: sessionMissing ? false : hasSession_0 || token_0 !== null,
|
|
152
173
|
fetchAccessToken
|
|
153
174
|
};
|
|
154
175
|
}, [fetchAccessToken, authStore]);
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import "../validators-BcQFm1oY.js";
|
|
1
2
|
import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-ji7By8u0.js";
|
|
2
3
|
import { t as GetAuth } from "../types-CM67ko7K.js";
|
|
3
|
-
import { A as GenericCtx } from "../procedure-caller-
|
|
4
|
+
import { A as GenericCtx } from "../procedure-caller-kZJx_hmP.js";
|
|
4
5
|
import "../http-types-BK7FuIcR.js";
|
|
5
6
|
import "../server/index.js";
|
|
6
7
|
import * as convex_values0 from "convex/values";
|
|
@@ -182,28 +183,28 @@ type AdapterPaginationOptions = PaginationOptions & {
|
|
|
182
183
|
};
|
|
183
184
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
184
185
|
connector?: "AND" | "OR" | undefined;
|
|
185
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
186
|
-
field: string;
|
|
186
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
187
187
|
value: string | number | boolean | string[] | number[] | null;
|
|
188
|
+
field: string;
|
|
188
189
|
}, {
|
|
189
190
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
190
191
|
field: convex_values0.VString<string, "required">;
|
|
191
|
-
operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
192
|
+
operator: convex_values0.VUnion<"in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "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>;
|
|
192
193
|
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>;
|
|
193
|
-
}, "required", "
|
|
194
|
+
}, "required", "value" | "connector" | "field" | "operator">;
|
|
194
195
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
195
196
|
limit?: number | undefined;
|
|
196
197
|
select?: string[] | undefined;
|
|
197
198
|
offset?: number | undefined;
|
|
198
199
|
sortBy?: {
|
|
199
|
-
field: string;
|
|
200
200
|
direction: "asc" | "desc";
|
|
201
|
+
field: string;
|
|
201
202
|
} | undefined;
|
|
202
203
|
where?: {
|
|
203
204
|
connector?: "AND" | "OR" | undefined;
|
|
204
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
205
|
-
field: string;
|
|
205
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
206
206
|
value: string | number | boolean | string[] | number[] | null;
|
|
207
|
+
field: string;
|
|
207
208
|
}[] | undefined;
|
|
208
209
|
model: string;
|
|
209
210
|
}, {
|
|
@@ -212,29 +213,29 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
212
213
|
offset: convex_values0.VFloat64<number | undefined, "optional">;
|
|
213
214
|
select: convex_values0.VArray<string[] | undefined, convex_values0.VString<string, "required">, "optional">;
|
|
214
215
|
sortBy: convex_values0.VObject<{
|
|
215
|
-
field: string;
|
|
216
216
|
direction: "asc" | "desc";
|
|
217
|
+
field: string;
|
|
217
218
|
} | undefined, {
|
|
218
219
|
direction: convex_values0.VUnion<"asc" | "desc", [convex_values0.VLiteral<"asc", "required">, convex_values0.VLiteral<"desc", "required">], "required", never>;
|
|
219
220
|
field: convex_values0.VString<string, "required">;
|
|
220
|
-
}, "optional", "
|
|
221
|
+
}, "optional", "direction" | "field">;
|
|
221
222
|
where: convex_values0.VArray<{
|
|
222
223
|
connector?: "AND" | "OR" | undefined;
|
|
223
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
224
|
-
field: string;
|
|
224
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
225
225
|
value: string | number | boolean | string[] | number[] | null;
|
|
226
|
+
field: string;
|
|
226
227
|
}[] | undefined, convex_values0.VObject<{
|
|
227
228
|
connector?: "AND" | "OR" | undefined;
|
|
228
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
229
|
-
field: string;
|
|
229
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
230
230
|
value: string | number | boolean | string[] | number[] | null;
|
|
231
|
+
field: string;
|
|
231
232
|
}, {
|
|
232
233
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
233
234
|
field: convex_values0.VString<string, "required">;
|
|
234
|
-
operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
235
|
+
operator: convex_values0.VUnion<"in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "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>;
|
|
235
236
|
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>;
|
|
236
|
-
}, "required", "
|
|
237
|
-
}, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.
|
|
237
|
+
}, "required", "value" | "connector" | "field" | "operator">, "optional">;
|
|
238
|
+
}, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.direction" | "sortBy.field">;
|
|
238
239
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
239
240
|
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>;
|
|
240
241
|
declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => Promise<D | null>;
|
|
@@ -359,26 +360,26 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
359
360
|
};
|
|
360
361
|
}, Promise<any>>;
|
|
361
362
|
deleteMany: convex_server0.RegisteredMutation<"internal", {
|
|
362
|
-
paginationOpts: {
|
|
363
|
-
id?: number;
|
|
364
|
-
endCursor?: string | null;
|
|
365
|
-
maximumRowsRead?: number;
|
|
366
|
-
maximumBytesRead?: number;
|
|
367
|
-
numItems: number;
|
|
368
|
-
cursor: string | null;
|
|
369
|
-
};
|
|
370
363
|
input: {
|
|
371
364
|
where?: {
|
|
372
365
|
connector?: "AND" | "OR" | undefined;
|
|
373
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
374
|
-
field: string;
|
|
366
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
375
367
|
value: string | number | boolean | string[] | number[] | null;
|
|
368
|
+
field: string;
|
|
376
369
|
}[] | undefined;
|
|
377
370
|
model: string;
|
|
378
371
|
} | {
|
|
379
372
|
where?: any[] | undefined;
|
|
380
373
|
model: string;
|
|
381
374
|
};
|
|
375
|
+
paginationOpts: {
|
|
376
|
+
id?: number;
|
|
377
|
+
endCursor?: string | null;
|
|
378
|
+
maximumRowsRead?: number;
|
|
379
|
+
maximumBytesRead?: number;
|
|
380
|
+
numItems: number;
|
|
381
|
+
cursor: string | null;
|
|
382
|
+
};
|
|
382
383
|
}, Promise<{
|
|
383
384
|
count: number;
|
|
384
385
|
ids: any[];
|
|
@@ -391,9 +392,9 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
391
392
|
input: {
|
|
392
393
|
where?: {
|
|
393
394
|
connector?: "AND" | "OR" | undefined;
|
|
394
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
395
|
-
field: string;
|
|
395
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
396
396
|
value: string | number | boolean | string[] | number[] | null;
|
|
397
|
+
field: string;
|
|
397
398
|
}[] | undefined;
|
|
398
399
|
model: string;
|
|
399
400
|
} | {
|
|
@@ -406,14 +407,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
406
407
|
join?: any;
|
|
407
408
|
offset?: number | undefined;
|
|
408
409
|
sortBy?: {
|
|
409
|
-
field: string;
|
|
410
410
|
direction: "asc" | "desc";
|
|
411
|
+
field: string;
|
|
411
412
|
} | undefined;
|
|
412
413
|
where?: {
|
|
413
414
|
connector?: "AND" | "OR" | undefined;
|
|
414
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
415
|
-
field: string;
|
|
415
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
416
416
|
value: string | number | boolean | string[] | number[] | null;
|
|
417
|
+
field: string;
|
|
417
418
|
}[] | undefined;
|
|
418
419
|
paginationOpts: {
|
|
419
420
|
id?: number;
|
|
@@ -430,27 +431,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
430
431
|
select?: string[] | undefined;
|
|
431
432
|
where?: {
|
|
432
433
|
connector?: "AND" | "OR" | undefined;
|
|
433
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
434
|
-
field: string;
|
|
434
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
435
435
|
value: string | number | boolean | string[] | number[] | null;
|
|
436
|
+
field: string;
|
|
436
437
|
}[] | undefined;
|
|
437
438
|
model: string;
|
|
438
439
|
}, Promise<convex_server0.GenericDocument | null>>;
|
|
440
|
+
getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
441
|
+
rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
439
442
|
updateMany: convex_server0.RegisteredMutation<"internal", {
|
|
440
|
-
paginationOpts: {
|
|
441
|
-
id?: number;
|
|
442
|
-
endCursor?: string | null;
|
|
443
|
-
maximumRowsRead?: number;
|
|
444
|
-
maximumBytesRead?: number;
|
|
445
|
-
numItems: number;
|
|
446
|
-
cursor: string | null;
|
|
447
|
-
};
|
|
448
443
|
input: {
|
|
449
444
|
where?: {
|
|
450
445
|
connector?: "AND" | "OR" | undefined;
|
|
451
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
452
|
-
field: string;
|
|
446
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
453
447
|
value: string | number | boolean | string[] | number[] | null;
|
|
448
|
+
field: string;
|
|
454
449
|
}[] | undefined;
|
|
455
450
|
update: {
|
|
456
451
|
[x: string]: unknown;
|
|
@@ -463,6 +458,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
463
458
|
update: any;
|
|
464
459
|
model: string;
|
|
465
460
|
};
|
|
461
|
+
paginationOpts: {
|
|
462
|
+
id?: number;
|
|
463
|
+
endCursor?: string | null;
|
|
464
|
+
maximumRowsRead?: number;
|
|
465
|
+
maximumBytesRead?: number;
|
|
466
|
+
numItems: number;
|
|
467
|
+
cursor: string | null;
|
|
468
|
+
};
|
|
466
469
|
}, Promise<{
|
|
467
470
|
count: number;
|
|
468
471
|
ids: any[];
|
|
@@ -475,9 +478,9 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
475
478
|
input: {
|
|
476
479
|
where?: {
|
|
477
480
|
connector?: "AND" | "OR" | undefined;
|
|
478
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
479
|
-
field: string;
|
|
481
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
480
482
|
value: string | number | boolean | string[] | number[] | null;
|
|
483
|
+
field: string;
|
|
481
484
|
}[] | undefined;
|
|
482
485
|
update: {
|
|
483
486
|
[x: string]: unknown;
|
|
@@ -491,8 +494,6 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
491
494
|
model: string;
|
|
492
495
|
};
|
|
493
496
|
}, Promise<any>>;
|
|
494
|
-
getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
495
|
-
rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
496
497
|
};
|
|
497
498
|
//#endregion
|
|
498
499
|
//#region ../../node_modules/kysely/dist/esm/operation-node/operation-node.d.ts
|
|
@@ -19155,26 +19156,26 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19155
19156
|
};
|
|
19156
19157
|
}, Promise<any>>;
|
|
19157
19158
|
deleteMany: convex_server0.RegisteredMutation<"internal", {
|
|
19158
|
-
paginationOpts: {
|
|
19159
|
-
id?: number;
|
|
19160
|
-
endCursor?: string | null;
|
|
19161
|
-
maximumRowsRead?: number;
|
|
19162
|
-
maximumBytesRead?: number;
|
|
19163
|
-
numItems: number;
|
|
19164
|
-
cursor: string | null;
|
|
19165
|
-
};
|
|
19166
19159
|
input: {
|
|
19167
19160
|
where?: {
|
|
19168
19161
|
connector?: "AND" | "OR" | undefined;
|
|
19169
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
19170
|
-
field: string;
|
|
19162
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19171
19163
|
value: string | number | boolean | string[] | number[] | null;
|
|
19164
|
+
field: string;
|
|
19172
19165
|
}[] | undefined;
|
|
19173
19166
|
model: string;
|
|
19174
19167
|
} | {
|
|
19175
19168
|
where?: any[] | undefined;
|
|
19176
19169
|
model: string;
|
|
19177
19170
|
};
|
|
19171
|
+
paginationOpts: {
|
|
19172
|
+
id?: number;
|
|
19173
|
+
endCursor?: string | null;
|
|
19174
|
+
maximumRowsRead?: number;
|
|
19175
|
+
maximumBytesRead?: number;
|
|
19176
|
+
numItems: number;
|
|
19177
|
+
cursor: string | null;
|
|
19178
|
+
};
|
|
19178
19179
|
}, Promise<{
|
|
19179
19180
|
count: number;
|
|
19180
19181
|
ids: any[];
|
|
@@ -19187,9 +19188,9 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19187
19188
|
input: {
|
|
19188
19189
|
where?: {
|
|
19189
19190
|
connector?: "AND" | "OR" | undefined;
|
|
19190
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
19191
|
-
field: string;
|
|
19191
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19192
19192
|
value: string | number | boolean | string[] | number[] | null;
|
|
19193
|
+
field: string;
|
|
19193
19194
|
}[] | undefined;
|
|
19194
19195
|
model: string;
|
|
19195
19196
|
} | {
|
|
@@ -19202,14 +19203,14 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19202
19203
|
join?: any;
|
|
19203
19204
|
offset?: number | undefined;
|
|
19204
19205
|
sortBy?: {
|
|
19205
|
-
field: string;
|
|
19206
19206
|
direction: "asc" | "desc";
|
|
19207
|
+
field: string;
|
|
19207
19208
|
} | undefined;
|
|
19208
19209
|
where?: {
|
|
19209
19210
|
connector?: "AND" | "OR" | undefined;
|
|
19210
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
19211
|
-
field: string;
|
|
19211
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19212
19212
|
value: string | number | boolean | string[] | number[] | null;
|
|
19213
|
+
field: string;
|
|
19213
19214
|
}[] | undefined;
|
|
19214
19215
|
paginationOpts: {
|
|
19215
19216
|
id?: number;
|
|
@@ -19226,27 +19227,21 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19226
19227
|
select?: string[] | undefined;
|
|
19227
19228
|
where?: {
|
|
19228
19229
|
connector?: "AND" | "OR" | undefined;
|
|
19229
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
19230
|
-
field: string;
|
|
19230
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19231
19231
|
value: string | number | boolean | string[] | number[] | null;
|
|
19232
|
+
field: string;
|
|
19232
19233
|
}[] | undefined;
|
|
19233
19234
|
model: string;
|
|
19234
19235
|
}, Promise<convex_server0.GenericDocument | null>>;
|
|
19236
|
+
getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
19237
|
+
rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
19235
19238
|
updateMany: convex_server0.RegisteredMutation<"internal", {
|
|
19236
|
-
paginationOpts: {
|
|
19237
|
-
id?: number;
|
|
19238
|
-
endCursor?: string | null;
|
|
19239
|
-
maximumRowsRead?: number;
|
|
19240
|
-
maximumBytesRead?: number;
|
|
19241
|
-
numItems: number;
|
|
19242
|
-
cursor: string | null;
|
|
19243
|
-
};
|
|
19244
19239
|
input: {
|
|
19245
19240
|
where?: {
|
|
19246
19241
|
connector?: "AND" | "OR" | undefined;
|
|
19247
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
19248
|
-
field: string;
|
|
19242
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19249
19243
|
value: string | number | boolean | string[] | number[] | null;
|
|
19244
|
+
field: string;
|
|
19250
19245
|
}[] | undefined;
|
|
19251
19246
|
update: {
|
|
19252
19247
|
[x: string]: unknown;
|
|
@@ -19259,6 +19254,14 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19259
19254
|
update: any;
|
|
19260
19255
|
model: string;
|
|
19261
19256
|
};
|
|
19257
|
+
paginationOpts: {
|
|
19258
|
+
id?: number;
|
|
19259
|
+
endCursor?: string | null;
|
|
19260
|
+
maximumRowsRead?: number;
|
|
19261
|
+
maximumBytesRead?: number;
|
|
19262
|
+
numItems: number;
|
|
19263
|
+
cursor: string | null;
|
|
19264
|
+
};
|
|
19262
19265
|
}, Promise<{
|
|
19263
19266
|
count: number;
|
|
19264
19267
|
ids: any[];
|
|
@@ -19271,9 +19274,9 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19271
19274
|
input: {
|
|
19272
19275
|
where?: {
|
|
19273
19276
|
connector?: "AND" | "OR" | undefined;
|
|
19274
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "
|
|
19275
|
-
field: string;
|
|
19277
|
+
operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19276
19278
|
value: string | number | boolean | string[] | number[] | null;
|
|
19279
|
+
field: string;
|
|
19277
19280
|
}[] | undefined;
|
|
19278
19281
|
update: {
|
|
19279
19282
|
[x: string]: unknown;
|
|
@@ -19287,8 +19290,6 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19287
19290
|
model: string;
|
|
19288
19291
|
};
|
|
19289
19292
|
}, Promise<any>>;
|
|
19290
|
-
getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
19291
|
-
rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
19292
19293
|
authEnabled: true;
|
|
19293
19294
|
authClient: {
|
|
19294
19295
|
authFunctions: AuthFunctions;
|
package/dist/auth/index.js
CHANGED
|
@@ -315,7 +315,7 @@ const resolveOrmTable = (ctx, schema, betterAuthSchema, model) => {
|
|
|
315
315
|
const tableName = resolveSchemaTableName(schema, betterAuthSchema, model);
|
|
316
316
|
if (!tableName) return;
|
|
317
317
|
const table = schema.tables[tableName];
|
|
318
|
-
if (!table
|
|
318
|
+
if (!table?._id) return;
|
|
319
319
|
return {
|
|
320
320
|
table,
|
|
321
321
|
tableName
|
|
@@ -409,10 +409,19 @@ const serializeDatesForConvex = (value) => {
|
|
|
409
409
|
return serialized ?? value;
|
|
410
410
|
};
|
|
411
411
|
const toConvexSafe = (value) => serializeDatesForConvex(value);
|
|
412
|
+
const withAuthTimestamps = (data) => {
|
|
413
|
+
if (data.createdAt !== void 0) return data;
|
|
414
|
+
const now = Date.now();
|
|
415
|
+
return {
|
|
416
|
+
...data,
|
|
417
|
+
createdAt: now,
|
|
418
|
+
...data.updatedAt === void 0 ? { updatedAt: now } : {}
|
|
419
|
+
};
|
|
420
|
+
};
|
|
412
421
|
const createHandler = async (ctx, args, schema, betterAuthSchema) => {
|
|
413
422
|
const triggerCtx = args.triggerCtx ?? ctx;
|
|
414
423
|
const tableTriggers = args.tableTriggers;
|
|
415
|
-
const data = serializeDatesForConvex(await applyBeforeHook(args.input.model, "create", args.input.data, tableTriggers?.create?.before, triggerCtx));
|
|
424
|
+
const data = serializeDatesForConvex(withAuthTimestamps(await applyBeforeHook(args.input.model, "create", args.input.data, tableTriggers?.create?.before, triggerCtx)));
|
|
416
425
|
await checkUniqueFields(ctx, schema, betterAuthSchema, args.input.model, data);
|
|
417
426
|
const ormTable = resolveOrmTable(ctx, schema, betterAuthSchema, args.input.model);
|
|
418
427
|
const doc = ormTable ? await ormInsert(ctx, ormTable.table, data) : await (async () => {
|
|
@@ -639,6 +648,7 @@ const createApi = (schema, getAuth, options) => {
|
|
|
639
648
|
}),
|
|
640
649
|
findMany: internalQueryGeneric({
|
|
641
650
|
args: {
|
|
651
|
+
join: v.optional(v.any()),
|
|
642
652
|
limit: v.optional(v.number()),
|
|
643
653
|
model: modelValidator,
|
|
644
654
|
offset: v.optional(v.number()),
|
|
@@ -647,20 +657,31 @@ const createApi = (schema, getAuth, options) => {
|
|
|
647
657
|
direction: v.union(v.literal("asc"), v.literal("desc")),
|
|
648
658
|
field: v.string()
|
|
649
659
|
})),
|
|
650
|
-
where: v.optional(v.array(adapterWhereValidator))
|
|
651
|
-
join: v.optional(v.any())
|
|
660
|
+
where: v.optional(v.array(adapterWhereValidator))
|
|
652
661
|
},
|
|
653
662
|
handler: async (ctx, args) => findManyHandler(ctx, args, schema, getBetterAuthSchema())
|
|
654
663
|
}),
|
|
655
664
|
findOne: internalQueryGeneric({
|
|
656
665
|
args: {
|
|
666
|
+
join: v.optional(v.any()),
|
|
657
667
|
model: modelValidator,
|
|
658
668
|
select: v.optional(v.array(v.string())),
|
|
659
|
-
where: v.optional(v.array(adapterWhereValidator))
|
|
660
|
-
join: v.optional(v.any())
|
|
669
|
+
where: v.optional(v.array(adapterWhereValidator))
|
|
661
670
|
},
|
|
662
671
|
handler: async (ctx, args) => findOneHandler(ctx, args, schema, getBetterAuthSchema())
|
|
663
672
|
}),
|
|
673
|
+
getLatestJwks: internalActionGeneric({
|
|
674
|
+
args: {},
|
|
675
|
+
handler: async (ctx) => {
|
|
676
|
+
return getAuth(ctx).api.getLatestJwks();
|
|
677
|
+
}
|
|
678
|
+
}),
|
|
679
|
+
rotateKeys: internalActionGeneric({
|
|
680
|
+
args: {},
|
|
681
|
+
handler: async (ctx) => {
|
|
682
|
+
return getAuth(ctx).api.rotateKeys();
|
|
683
|
+
}
|
|
684
|
+
}),
|
|
664
685
|
updateMany: mutationBuilder({
|
|
665
686
|
args: {
|
|
666
687
|
input: updateInput,
|
|
@@ -686,18 +707,6 @@ const createApi = (schema, getAuth, options) => {
|
|
|
686
707
|
triggerCtx
|
|
687
708
|
}, schema, getBetterAuthSchema());
|
|
688
709
|
}
|
|
689
|
-
}),
|
|
690
|
-
getLatestJwks: internalActionGeneric({
|
|
691
|
-
args: {},
|
|
692
|
-
handler: async (ctx) => {
|
|
693
|
-
return getAuth(ctx).api.getLatestJwks();
|
|
694
|
-
}
|
|
695
|
-
}),
|
|
696
|
-
rotateKeys: internalActionGeneric({
|
|
697
|
-
args: {},
|
|
698
|
-
handler: async (ctx) => {
|
|
699
|
-
return getAuth(ctx).api.rotateKeys();
|
|
700
|
-
}
|
|
701
710
|
})
|
|
702
711
|
};
|
|
703
712
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../validators-BcQFm1oY.js";
|
|
2
|
+
import { B as ConvexContext, H as LazyCaller } from "../../procedure-caller-kZJx_hmP.js";
|
|
2
3
|
import "../../http-types-BK7FuIcR.js";
|
|
3
4
|
import "../../server/index.js";
|
|
4
5
|
import { GetTokenOptions } from "@convex-dev/better-auth/utils";
|
|
@@ -12,7 +13,8 @@ type AuthOptions = {
|
|
|
12
13
|
};
|
|
13
14
|
type ConvexBetterAuthOptions<TApi> = Omit<GetTokenOptions, 'jwtCache'> & {
|
|
14
15
|
api: TApi;
|
|
15
|
-
convexSiteUrl: string;
|
|
16
|
+
convexSiteUrl: string;
|
|
17
|
+
convexUrl?: string; /** Auth options. JWT caching is enabled by default (set `auth.jwtCache: false` to disable). */
|
|
16
18
|
auth?: AuthOptions;
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
@@ -38,10 +40,10 @@ type ConvexBetterAuthOptions<TApi> = Omit<GetTokenOptions, 'jwtCache'> & {
|
|
|
38
40
|
* ```
|
|
39
41
|
*/
|
|
40
42
|
declare function convexBetterAuth<TApi extends Record<string, unknown>>(opts: ConvexBetterAuthOptions<TApi>): {
|
|
43
|
+
createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
|
|
41
44
|
createContext: (reqOpts: {
|
|
42
45
|
headers: Headers;
|
|
43
46
|
}) => Promise<ConvexContext<TApi>>;
|
|
44
|
-
createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
|
|
45
47
|
handler: {
|
|
46
48
|
GET: (request: Request) => Promise<Response>;
|
|
47
49
|
POST: (request: Request) => Promise<Response>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as defaultIsUnauthorized } from "../../error-CAGGSN5H.js";
|
|
2
|
-
import { t as createCallerFactory } from "../../caller-factory-
|
|
2
|
+
import { t as createCallerFactory } from "../../caller-factory-C1uAqm5w.js";
|
|
3
3
|
import { getToken } from "@convex-dev/better-auth/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/auth-nextjs/index.ts
|
|
@@ -50,7 +50,6 @@ function convexBetterAuth(opts) {
|
|
|
50
50
|
const jwtCacheEnabled = auth.jwtCache !== false;
|
|
51
51
|
const { createContext, createCaller } = createCallerFactory({
|
|
52
52
|
api: opts.api,
|
|
53
|
-
convexSiteUrl: opts.convexSiteUrl,
|
|
54
53
|
auth: jwtCacheEnabled ? {
|
|
55
54
|
getToken: (siteUrl, headers, getTokenOpts) => {
|
|
56
55
|
const mutableHeaders = new Headers(headers);
|
|
@@ -66,11 +65,13 @@ function convexBetterAuth(opts) {
|
|
|
66
65
|
});
|
|
67
66
|
},
|
|
68
67
|
isUnauthorized: auth.isUnauthorized ?? defaultIsUnauthorized
|
|
69
|
-
} : void 0
|
|
68
|
+
} : void 0,
|
|
69
|
+
convexSiteUrl: opts.convexSiteUrl,
|
|
70
|
+
convexUrl: opts.convexUrl
|
|
70
71
|
});
|
|
71
72
|
return {
|
|
72
|
-
createContext,
|
|
73
73
|
createCaller,
|
|
74
|
+
createContext,
|
|
74
75
|
handler: nextJsHandler(opts.convexSiteUrl)
|
|
75
76
|
};
|
|
76
77
|
}
|
|
@@ -116,12 +116,20 @@ function createLazyCaller(api, createContext) {
|
|
|
116
116
|
* Framework-agnostic caller factory.
|
|
117
117
|
* getToken is passed as a parameter - decoupled from @convex-dev/better-auth.
|
|
118
118
|
*/
|
|
119
|
-
const
|
|
119
|
+
const CONVEX_SITE_URL_RE = /\.convex\.site(?=\/|$)/;
|
|
120
|
+
const getArgsAndOptions = (args, token, url) => [args[0], {
|
|
121
|
+
token,
|
|
122
|
+
url
|
|
123
|
+
}];
|
|
120
124
|
const parseConvexSiteUrl = (url) => {
|
|
121
125
|
if (!url) throw new Error("CONVEX_SITE_URL is not set. This must be set in the environment.");
|
|
122
126
|
if (url.endsWith(".convex.cloud")) throw new Error(`CONVEX_SITE_URL should end in .convex.site, not .convex.cloud. Currently set to ${url}.`);
|
|
123
127
|
return url;
|
|
124
128
|
};
|
|
129
|
+
const getConvexUrl = (siteUrl, convexUrl) => {
|
|
130
|
+
if (convexUrl) return convexUrl;
|
|
131
|
+
return siteUrl.replace(CONVEX_SITE_URL_RE, ".convex.cloud");
|
|
132
|
+
};
|
|
125
133
|
/**
|
|
126
134
|
* Framework-agnostic caller factory.
|
|
127
135
|
*
|
|
@@ -137,6 +145,7 @@ const parseConvexSiteUrl = (url) => {
|
|
|
137
145
|
const noAuthGetToken = () => Promise.resolve({ token: void 0 });
|
|
138
146
|
function createCallerFactory(opts) {
|
|
139
147
|
const siteUrl = parseConvexSiteUrl(opts.convexSiteUrl);
|
|
148
|
+
const convexUrl = getConvexUrl(siteUrl, opts.convexUrl);
|
|
140
149
|
const getToken = opts.auth?.getToken ?? noAuthGetToken;
|
|
141
150
|
const isUnauthorized = opts.auth?.isUnauthorized;
|
|
142
151
|
const crpcMeta = buildMetaIndex(opts.api);
|
|
@@ -166,40 +175,40 @@ function createCallerFactory(opts) {
|
|
|
166
175
|
const fetchAuthQuery = async (query, args, callerOpts) => {
|
|
167
176
|
if (callerOpts?.skipUnauth && !tokenResult.token) return null;
|
|
168
177
|
return callWithTokenAndRetry((token) => {
|
|
169
|
-
const argsAndOptions = getArgsAndOptions([args], token);
|
|
178
|
+
const argsAndOptions = getArgsAndOptions([args], token, convexUrl);
|
|
170
179
|
return fetchQuery(query, argsAndOptions[0], argsAndOptions[1]);
|
|
171
180
|
}, tokenResult, reqOpts.headers);
|
|
172
181
|
};
|
|
173
182
|
const fetchAuthMutation = async (mutation, args, callerOpts) => {
|
|
174
183
|
if (callerOpts?.skipUnauth && !tokenResult.token) return null;
|
|
175
184
|
return callWithTokenAndRetry((token) => {
|
|
176
|
-
const argsAndOptions = getArgsAndOptions([args], token);
|
|
185
|
+
const argsAndOptions = getArgsAndOptions([args], token, convexUrl);
|
|
177
186
|
return fetchMutation(mutation, argsAndOptions[0], argsAndOptions[1]);
|
|
178
187
|
}, tokenResult, reqOpts.headers);
|
|
179
188
|
};
|
|
180
189
|
const fetchAuthAction = async (action, args, callerOpts) => {
|
|
181
190
|
if (callerOpts?.skipUnauth && !tokenResult.token) return null;
|
|
182
191
|
return callWithTokenAndRetry((token) => {
|
|
183
|
-
const argsAndOptions = getArgsAndOptions([args], token);
|
|
192
|
+
const argsAndOptions = getArgsAndOptions([args], token, convexUrl);
|
|
184
193
|
return fetchAction(action, argsAndOptions[0], argsAndOptions[1]);
|
|
185
194
|
}, tokenResult, reqOpts.headers);
|
|
186
195
|
};
|
|
187
196
|
return {
|
|
188
|
-
token: tokenResult.token,
|
|
189
|
-
isAuthenticated: !!tokenResult.token,
|
|
190
197
|
caller: createServerCaller(opts.api, {
|
|
191
|
-
fetchQuery: fetchAuthQuery,
|
|
192
|
-
fetchMutation: fetchAuthMutation,
|
|
193
198
|
fetchAction: fetchAuthAction,
|
|
199
|
+
fetchMutation: fetchAuthMutation,
|
|
200
|
+
fetchQuery: fetchAuthQuery,
|
|
194
201
|
meta: crpcMeta,
|
|
195
202
|
transformer: opts.transformer
|
|
196
|
-
})
|
|
203
|
+
}),
|
|
204
|
+
isAuthenticated: !!tokenResult.token,
|
|
205
|
+
token: tokenResult.token
|
|
197
206
|
};
|
|
198
207
|
};
|
|
199
208
|
const createCaller = (ctxFn) => createLazyCaller(opts.api, ctxFn);
|
|
200
209
|
return {
|
|
201
|
-
|
|
202
|
-
|
|
210
|
+
createCaller,
|
|
211
|
+
createContext
|
|
203
212
|
};
|
|
204
213
|
}
|
|
205
214
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as getConvexConfig, t as generateMeta } from "./codegen-
|
|
2
|
+
import { n as getConvexConfig, t as generateMeta } from "./codegen-CMQIKrqh.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import fs from "node:fs";
|
|
@@ -531,17 +531,22 @@ const listConvexHandlerExports = async (entryPoint, jitiInstance) => {
|
|
|
531
531
|
return Array.from(exportNames).sort((a, b) => a.localeCompare(b));
|
|
532
532
|
};
|
|
533
533
|
const scanHandlerExportsByEntry = async (entryPoints) => {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
534
|
+
globalThis.__BETTER_CONVEX_CODEGEN__ = true;
|
|
535
|
+
try {
|
|
536
|
+
const jitiInstance = createJiti(process.cwd(), {
|
|
537
|
+
interopDefault: true,
|
|
538
|
+
moduleCache: false
|
|
539
|
+
});
|
|
540
|
+
const results = await Promise.all(entryPoints.map(async (entryPoint) => ({
|
|
541
|
+
entryPoint,
|
|
542
|
+
exportNames: await listConvexHandlerExports(entryPoint, jitiInstance)
|
|
543
|
+
})));
|
|
544
|
+
const byEntry = /* @__PURE__ */ new Map();
|
|
545
|
+
for (const result of results) if (result.exportNames.length > 0) byEntry.set(result.entryPoint, result.exportNames);
|
|
546
|
+
return byEntry;
|
|
547
|
+
} finally {
|
|
548
|
+
delete globalThis.__BETTER_CONVEX_CODEGEN__;
|
|
549
|
+
}
|
|
545
550
|
};
|
|
546
551
|
const parseArgs$1 = (argv) => {
|
|
547
552
|
const options = {
|
|
@@ -888,40 +888,45 @@ async function generateMeta(outputDir, options) {
|
|
|
888
888
|
if (hasTriggersExport && !hasRelationsExport) throw new Error("Codegen error: schema.ts exports 'triggers' but is missing 'relations'. Export `relations` and define triggers via `defineTriggers(relations, { ... })`.");
|
|
889
889
|
ensureGeneratedSupportPlaceholders(functionsDir, { includeAuth: generateAuth });
|
|
890
890
|
if (generateApi) {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
meta
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
891
|
+
globalThis.__BETTER_CONVEX_CODEGEN__ = true;
|
|
892
|
+
try {
|
|
893
|
+
const jitiInstance = createJiti(process.cwd(), {
|
|
894
|
+
interopDefault: true,
|
|
895
|
+
moduleCache: false
|
|
896
|
+
});
|
|
897
|
+
const files = listFilesRecursive(functionsDir).filter((file) => file.endsWith(".ts") && isValidConvexFile(file));
|
|
898
|
+
createdRuntimePlaceholders = ensureGeneratedRuntimePlaceholders(functionsDir, [...new Set([
|
|
899
|
+
...files.map((file) => file.replace(TS_EXTENSION_RE, "")),
|
|
900
|
+
...hasRelationsExport ? ["generated/server"] : [],
|
|
901
|
+
...generateAuth ? [generatedAuthModuleName] : []
|
|
902
|
+
])]);
|
|
903
|
+
for (const file of files) {
|
|
904
|
+
const filePath = path.join(functionsDir, file);
|
|
905
|
+
const moduleName = file.replace(TS_EXTENSION_RE, "");
|
|
906
|
+
try {
|
|
907
|
+
const { meta: moduleMeta, httpRoutes, procedures } = await parseModuleRuntime(filePath, jitiInstance);
|
|
908
|
+
if (moduleMeta) {
|
|
909
|
+
meta[moduleName] = moduleMeta;
|
|
910
|
+
const fnCount = Object.keys(moduleMeta).length;
|
|
911
|
+
totalFunctions += fnCount;
|
|
912
|
+
if (debug) console.info(` ✓ ${moduleName}: ${fnCount} functions`);
|
|
913
|
+
}
|
|
914
|
+
if (Object.keys(httpRoutes).length > 0 && debug) console.info(` ✓ ${moduleName}: ${Object.keys(httpRoutes).length} HTTP routes`);
|
|
915
|
+
Object.assign(allHttpRoutes, httpRoutes);
|
|
916
|
+
for (const procedure of procedures) procedureEntries.push({
|
|
917
|
+
moduleName,
|
|
918
|
+
exportName: procedure.exportName,
|
|
919
|
+
internal: procedure.internal,
|
|
920
|
+
type: procedure.type,
|
|
921
|
+
kind: "crpc"
|
|
922
|
+
});
|
|
923
|
+
} catch (error) {
|
|
924
|
+
runtimeFilesPreservedFromParseFailures.add(getGeneratedRuntimeOutputFile(functionsDir, moduleName));
|
|
925
|
+
if (debug || file === "http.ts") console.error(` ⚠ Failed to parse ${file}:`, error);
|
|
911
926
|
}
|
|
912
|
-
if (Object.keys(httpRoutes).length > 0 && debug) console.info(` ✓ ${moduleName}: ${Object.keys(httpRoutes).length} HTTP routes`);
|
|
913
|
-
Object.assign(allHttpRoutes, httpRoutes);
|
|
914
|
-
for (const procedure of procedures) procedureEntries.push({
|
|
915
|
-
moduleName,
|
|
916
|
-
exportName: procedure.exportName,
|
|
917
|
-
internal: procedure.internal,
|
|
918
|
-
type: procedure.type,
|
|
919
|
-
kind: "crpc"
|
|
920
|
-
});
|
|
921
|
-
} catch (error) {
|
|
922
|
-
runtimeFilesPreservedFromParseFailures.add(getGeneratedRuntimeOutputFile(functionsDir, moduleName));
|
|
923
|
-
if (debug || file === "http.ts") console.error(` ⚠ Failed to parse ${file}:`, error);
|
|
924
927
|
}
|
|
928
|
+
} finally {
|
|
929
|
+
delete globalThis.__BETTER_CONVEX_CODEGEN__;
|
|
925
930
|
}
|
|
926
931
|
}
|
|
927
932
|
if (generateApi) {
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BcQFm1oY.js";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as DatabaseWithMutations, $n as BuildQueryResult, $r as notBetween, $t as defineRelations, A as MigrationCancelArgs, An as ConvexVectorIndexConfig, Ar as ExpressionVisitor, At as custom, B as MigrationManifestEntry, Bn as ConvexForeignKeyConfig, Br as fieldRef, Bt as ConvexBigIntBuilderInitial, C as OrmBeforeResult, Cn as ConvexRankIndexBuilder, Cr as ReturningResult, Ct as ConvexDateBuilder, D as OrmTriggers, Dn as ConvexSearchIndexConfig, Dr as VectorSearchProvider, Dt as ConvexCustomBuilder, E as OrmTriggerContext, En as ConvexSearchIndexBuilderOn, Er as VectorQueryConfig, Et as date, F as MigrationDefinition, Fn as uniqueIndex, Fr as and, Ft as bytes, G as MigrationStateMap, Gn as foreignKey, Gr as isFieldReference, Gt as ExtractTablesWithRelations, H as MigrationPlan, Hn as ConvexUniqueConstraintBuilderOn, Hr as gte, Ht as CountBackfillChunkArgs, I as MigrationDirection, In as vectorIndex, Ir as between, It as ConvexBooleanBuilder, J as MigrationWriteMode, Jn as ConvexTextBuilderInitial, Jr as like, Jt as RelationsBuilder, K as MigrationStep, Kn as unique, Kr as isNotNull, Kt as ManyConfig, L as MigrationDoc, Ln as ConvexCheckBuilder, Lr as contains, Lt as ConvexBooleanBuilderInitial, M as MigrationRunChunkArgs, Mn as index, Mr as FilterExpression, Mt as objectOf, N as MigrationStatusArgs, Nn as rankIndex, Nr as LogicalExpression, Nt as ConvexBytesBuilder, O as defineTriggers, On as ConvexVectorIndexBuilder, Or as unsetToken, Ot as ConvexCustomBuilderInitial, P as MigrationAppliedState, Pn as searchIndex, Pr as UnaryExpression, Pt as ConvexBytesBuilderInitial, Q as detectMigrationDrift, Qn as AggregateResult, Qr as not, Qt as TablesRelationalConfig, R as MigrationDocContext, Rn as ConvexCheckConfig, Rr as endsWith, Rt as boolean, S as scheduledDeleteFactory, Sn as ConvexIndexBuilderOn, Sr as ReturningAll, St as id, T as OrmTriggerChange, Tn as ConvexSearchIndexBuilder, Tr as UpdateSet, Tt as ConvexDateMode, U as MigrationRunStatus, Un as ConvexUniqueConstraintConfig, Ur as ilike, Ut as CountBackfillKickoffArgs, V as MigrationMigrateOne, Vn as ConvexUniqueConstraintBuilder, Vr as gt, Vt as bigint, W as MigrationSet, Wn as check, Wr as inArray, Wt as CountBackfillStatusArgs, X as defineMigration, Xn as AggregateConfig, Xr as lte, Xt as RelationsBuilderColumnConfig, Y as buildMigrationPlan, Yn as text, Yr as lt, Yt as RelationsBuilderColumnBase, Z as defineMigrationSet, Zn as AggregateFieldValue, Zr as ne, Zt as TableRelationalConfig, _ as OrmWriterCtx, _i as HasDefault, _n as RlsRoleConfig, _r as MutationRunMode, _t as ConvexNumberBuilder, a as TableConfigResult, ai as OrmSchemaPlugin, an as DiscriminatorBuilderConfig, ar as GetColumnData, at as EdgeMetadata, b as scheduledMutationBatchFactory, bi as NotNull, bn as ConvexAggregateIndexBuilderOn, br as PaginatedResult, bt as ConvexIdBuilder, c as OrmNotFoundError, ci as SystemFields, cn as TableConfig, cr as InferSelectModel, ct as ConvexVectorBuilderInitial, d as GenericOrmCtx, di as ColumnBuilderBaseConfig, dn as discriminator, dr as MutationExecuteResult, dt as ConvexTimestampBuilderInitial, ei as notInArray, en as defineRelationsPart, er as BuildRelationResult, et as DatabaseWithQuery, f as OrmApiResult, fi as ColumnBuilderRuntimeConfig, fn as RlsPolicy, fr as MutationExecutionMode, ft as ConvexTimestampMode, g as OrmReaderCtx, gi as DrizzleEntity, gn as RlsRole, gr as MutationReturning, gt as textEnum, h as OrmFunctions, hi as ColumnDataType, hn as rlsPolicy, hr as MutationResult, ht as ConvexTextEnumBuilderInitial, i as desc, ii as Columns, ir as FilterOperators, it as RlsMode, j as MigrationRunArgs, jn as aggregateIndex, jr as FieldReference, jt as json, kn as ConvexVectorIndexBuilderOn, kr as BinaryExpression, kt as arrayOf, l as CreateOrmOptions, li as AnyColumn, ln as convexTable, lr as InsertValue, lt as vector, m as OrmClientWithApi, mi as ColumnBuilderWithTableName, mn as RlsPolicyToOption, mr as MutationPaginatedResult, mt as ConvexTextEnumBuilder, n as defineSchema, ni as startsWith, nn as ConvexDeletionConfig, nr as CountResult, nt as OrmWriter, o as getTableColumns, oi as OrmSchemaPluginTables, on as OrmLifecycleChange, or as InferInsertModel, ot as extractRelationsConfig, p as OrmClientBase, pi as ColumnBuilderTypeConfig, pn as RlsPolicyConfig, pr as MutationPaginateConfig, pt as timestamp, q as MigrationTableName, qn as ConvexTextBuilder, qr as isNull, qt as OneConfig, r as asc, ri as Brand, rn as ConvexTable, rr as DBQueryConfig, rt as RlsContext, s as getTableConfig, si as TableName, sn as OrmLifecycleOperation, sr as InferModelFromColumns, st as ConvexVectorBuilder, t as WhereClauseResult, ti as or, tn as ConvexDeletionBuilder, tr as CountConfig, tt as OrmReader, u as GenericOrm, ui as ColumnBuilder, un as deletion, ur as MutationExecuteConfig, ut as ConvexTimestampBuilder, v as createOrm, vi as IsPrimaryKey, vn as rlsRole, vr as OrderByClause, vt as ConvexNumberBuilderInitial, w as OrmTableTriggers, wn as ConvexRankIndexBuilderOn, wr as ReturningSelection, wt as ConvexDateBuilderInitial, x as ScheduledDeleteArgs, xn as ConvexIndexBuilder, xr as PredicateWhereIndexConfig, xt as ConvexIdBuilderInitial, y as ScheduledMutationBatchArgs, yi as IsUnique, yn as ConvexAggregateIndexBuilder, yr as OrderDirection, yt as integer, z as MigrationDriftIssue, zn as ConvexForeignKeyBuilder, zr as eq, zt as ConvexBigIntBuilder } from "../where-clause-compiler-DjFwXrQn.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-ji7By8u0.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericSchema, SchemaDefinition } from "convex/server";
|
|
5
5
|
export { type AggregateConfig, type AggregateFieldValue, type AggregateResult, type AnyColumn, type BinaryExpression, Brand, type BuildQueryResult, type BuildRelationResult, type ColumnBuilder, type ColumnBuilderBaseConfig, type ColumnBuilderRuntimeConfig, type ColumnBuilderTypeConfig, type ColumnBuilderWithTableName, type ColumnDataType, Columns, type ConvexAggregateIndexBuilder, type ConvexAggregateIndexBuilderOn, type ConvexBigIntBuilder, type ConvexBigIntBuilderInitial, type ConvexBooleanBuilder, type ConvexBooleanBuilderInitial, type ConvexBytesBuilder, type ConvexBytesBuilderInitial, type ConvexCheckBuilder, type ConvexCheckConfig, type ConvexCustomBuilder, type ConvexCustomBuilderInitial, type ConvexDateBuilder, type ConvexDateBuilderInitial, type ConvexDateMode, type ConvexDeletionBuilder, type ConvexDeletionConfig, type ConvexForeignKeyBuilder, type ConvexForeignKeyConfig, type ConvexIdBuilder, type ConvexIdBuilderInitial, type ConvexIndexBuilder, type ConvexIndexBuilderOn, type ConvexNumberBuilder, type ConvexNumberBuilderInitial, type ConvexRankIndexBuilder, type ConvexRankIndexBuilderOn, type ConvexSearchIndexBuilder, type ConvexSearchIndexBuilderOn, type ConvexSearchIndexConfig, type ConvexTable, type ConvexTextBuilder, type ConvexTextBuilderInitial, type ConvexTextEnumBuilder, type ConvexTextEnumBuilderInitial, type ConvexTimestampBuilder, type ConvexTimestampBuilderInitial, type ConvexTimestampMode, type ConvexUniqueConstraintBuilder, type ConvexUniqueConstraintBuilderOn, type ConvexUniqueConstraintConfig, type ConvexVectorBuilder, type ConvexVectorBuilderInitial, type ConvexVectorIndexBuilder, type ConvexVectorIndexBuilderOn, type ConvexVectorIndexConfig, type CountBackfillChunkArgs, type CountBackfillKickoffArgs, type CountBackfillStatusArgs, type CountConfig, type CountResult, type CreateOrmOptions, type DBQueryConfig, type DatabaseWithMutations, type DatabaseWithQuery, type DefineSchemaOptions, type DiscriminatorBuilderConfig, type DocByCtx, type DrizzleEntity, type EdgeMetadata, type ExpressionVisitor, type ExtractTablesWithRelations, type FieldReference, type FilterExpression, type FilterOperators, type GenericOrm, type GenericOrmCtx, type GenericSchema, type GetColumnData, type HasDefault, type InferInsertModel, type InferModelFromColumns, type InferSelectModel, type InsertValue, type IsPrimaryKey, type IsUnique, type LogicalExpression, type LookupByIdResultByCtx, type ManyConfig, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, type MutationExecuteConfig, type MutationExecuteResult, type MutationExecutionMode, type MutationPaginateConfig, type MutationPaginatedResult, type MutationResult, type MutationReturning, type MutationRunMode, type NotNull, type OneConfig, type OrderByClause, type OrderDirection, type OrmApiResult, type OrmBeforeResult, type OrmClientBase, type OrmClientWithApi, type OrmFunctions, type OrmLifecycleChange, type OrmLifecycleOperation, OrmNotFoundError, type OrmReader, type OrmReaderCtx, type OrmSchemaPlugin, OrmSchemaPluginTables, type OrmTableTriggers, type OrmTriggerChange, type OrmTriggerContext, type OrmTriggers, type OrmWriter, type OrmWriterCtx, type PaginatedResult, type PredicateWhereIndexConfig, type QueryCtxWithOptionalOrmQueryTable, type QueryCtxWithOrmQueryTable, type QueryCtxWithPreferredOrmQueryTable, type RelationsBuilder, type RelationsBuilderColumnBase, type RelationsBuilderColumnConfig, type ReturningAll, type ReturningResult, type ReturningSelection, type RlsContext, type RlsMode, RlsPolicy, type RlsPolicyConfig, type RlsPolicyToOption, RlsRole, type RlsRoleConfig, type ScheduledDeleteArgs, type ScheduledMutationBatchArgs, type SchemaDefinition, type SystemFields, type TableConfig, type TableConfigResult, TableName, type TableRelationalConfig, type TablesRelationalConfig, type UnaryExpression, type UpdateSet, type VectorQueryConfig, type VectorSearchProvider, type WhereClauseResult, aggregateIndex, and, arrayOf, asc, between, bigint, boolean, buildMigrationPlan, bytes, check, contains, convexTable, createOrm, custom, date, defineMigration, defineMigrationSet, defineRelations, defineRelationsPart, defineSchema, defineTriggers, deletion, deprecated, desc, detectMigrationDrift, discriminator, endsWith, eq, extractRelationsConfig, fieldRef, foreignKey, getByIdWithOrmQueryFallback, getTableColumns, getTableConfig, gt, gte, id, ilike, inArray, index, integer, isFieldReference, isNotNull, isNull, json, like, lt, lte, ne, not, notBetween, notInArray, objectOf, or, pretend, pretendRequired, rankIndex, rlsPolicy, rlsRole, scheduledDeleteFactory, scheduledMutationBatchFactory, searchIndex, startsWith, text, textEnum, timestamp, unique, uniqueIndex, unsetToken, vector, vectorIndex };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../validators-BcQFm1oY.js";
|
|
2
|
+
import { ai as OrmSchemaPlugin, k as migrationPlugin } from "../where-clause-compiler-DjFwXrQn.js";
|
|
3
|
+
import "../query-context-ji7By8u0.js";
|
|
4
|
+
import "../orm/index.js";
|
|
2
5
|
|
|
3
|
-
//#region src/orm/migrations/schema.d.ts
|
|
4
|
-
declare function migrationPlugin(): OrmSchemaPlugin;
|
|
5
|
-
//#endregion
|
|
6
6
|
//#region src/orm/aggregate-index/schema.d.ts
|
|
7
7
|
declare function aggregatePlugin(): OrmSchemaPlugin;
|
|
8
8
|
//#endregion
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../validators-BcQFm1oY.js";
|
|
2
|
+
import { ai as OrmSchemaPlugin } from "../../where-clause-compiler-DjFwXrQn.js";
|
|
3
|
+
import "../../query-context-ji7By8u0.js";
|
|
4
|
+
import "../../orm/index.js";
|
|
2
5
|
import * as convex_server0 from "convex/server";
|
|
3
6
|
|
|
4
7
|
//#region src/plugins/ratelimit/duration.d.ts
|
|
@@ -1184,7 +1184,12 @@ type AuthOptions = {
|
|
|
1184
1184
|
};
|
|
1185
1185
|
type CreateCallerFactoryOptions<TApi> = {
|
|
1186
1186
|
/** Your Convex API object. */api: TApi; /** Convex site URL (must end in `.convex.site`). */
|
|
1187
|
-
convexSiteUrl: string;
|
|
1187
|
+
convexSiteUrl: string;
|
|
1188
|
+
/**
|
|
1189
|
+
* Convex deployment URL (must end in `.convex.cloud`).
|
|
1190
|
+
* Defaults to `convexSiteUrl` with the domain swapped.
|
|
1191
|
+
*/
|
|
1192
|
+
convexUrl?: string; /** Auth options. Pass to enable authenticated calls with JWT caching. */
|
|
1188
1193
|
auth?: AuthOptions; /** Optional wire transformer for request/response payloads (always composed with Date). */
|
|
1189
1194
|
transformer?: DataTransformerOptions;
|
|
1190
1195
|
};
|
|
@@ -1194,10 +1199,10 @@ type ConvexContext<TApi> = {
|
|
|
1194
1199
|
caller: ServerCaller<TApi>;
|
|
1195
1200
|
};
|
|
1196
1201
|
declare function createCallerFactory<TApi extends Record<string, unknown>>(opts: CreateCallerFactoryOptions<TApi>): {
|
|
1202
|
+
createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
|
|
1197
1203
|
createContext: (reqOpts: {
|
|
1198
1204
|
headers: Headers;
|
|
1199
1205
|
}) => Promise<ConvexContext<TApi>>;
|
|
1200
|
-
createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
|
|
1201
1206
|
};
|
|
1202
1207
|
//#endregion
|
|
1203
1208
|
//#region src/server/context-utils.d.ts
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../validators-BcQFm1oY.js";
|
|
2
|
+
import { $ as QueryProcedureBuilder, A as GenericCtx, B as ConvexContext, C as CRPC_ERROR_CODE_TO_HTTP, Ct as zodToConvex, D as toCRPCError, E as isCRPCError, F as isRunMutationCtx, G as CallerOpts, H as LazyCaller, I as requireActionCtx, J as createApiLeaf, K as ServerCaller, L as requireMutationCtx, M as isActionCtx, N as isMutationCtx, O as CreateEnvOptions, P as isQueryCtx, Q as ProcedureBuilder, R as requireQueryCtx, S as CRPC_ERROR_CODES_BY_KEY, St as zodOutputToConvexFields, T as getHTTPStatusCodeFromError, U as createLazyCaller, V as createCallerFactory, W as CallerMeta, X as CRPCFunctionTypeHint, Y as ActionProcedureBuilder, Z as MutationProcedureBuilder, _ as WithHttpRouter, _t as zCustomAction, a as ProcedureCaller, at as handleHttpError, b as CRPCError, bt as zid, c as ProcedureFromFunctionReference, ct as ConvexValidatorFromZodOutput, d as createGenericCallerFactory, dt as Zid, et as createMiddlewareFactory, f as createGenericHandlerFactory, ft as ZodFromValidatorBase, g as typedProcedureResolver, gt as withSystemFields, h as defineProcedure, ht as convexToZodFields, i as ProcedureActionCallerFromRegistry, it as extractPathParams, j as RunMutationCtx, k as createEnv, l as ProcedureSchedulableCallerFromRegistry, lt as CustomBuilder, m as createProcedureHandlerFactory, mt as convexToZod, n as GeneratedProcedureRegistry, nt as HttpProcedureBuilder, o as ProcedureCallerFromRegistry, ot as matchPathParams, p as createProcedureCallerFactory, pt as ZodValidatorFromConvex, q as createServerCaller, r as GeneratedProcedureRegistryEntry, rt as createHttpProcedureBuilder, s as ProcedureDefinition, st as ConvexValidatorFromZod, t as CreateProcedureCallerFactoryOptions, tt as initCRPC, u as ProcedureScheduleCallerFromRegistry, ut as ZCustomCtx, v as inferApiInputs, vt as zCustomMutation, w as getCRPCErrorFromUnknown, wt as zodToConvexFields, x as CRPCErrorCode, xt as zodOutputToConvex, y as inferApiOutputs, yt as zCustomQuery, z as requireRunMutationCtx } from "../procedure-caller-kZJx_hmP.js";
|
|
2
3
|
import { A as GetRawInputFn, B as Simplify, C as HttpProcedure, D as ProcedureMeta, E as InferHttpInput, F as MiddlewareMarker, I as MiddlewareNext, L as MiddlewareResult, M as MergeZodObjects, N as MiddlewareBuilder, O as AnyMiddleware, P as MiddlewareFunction, R as Overwrite, S as HttpMethod, T as HttpRouteDefinition, V as UnsetMarker, _ as extractRouteMap, b as HttpActionHandler, d as CRPCHttpRouter, f as HttpRouterDef, g as createHttpRouterFactory, h as createHttpRouter, j as IntersectIfDefined, k as AnyMiddlewareBuilder, m as HttpRouterWithHono, p as HttpRouterRecord, v as CRPCHonoHandler, w as HttpProcedureBuilderDef, x as HttpHandlerOpts, y as HttpActionConstructor, z as ResolveIfSet } from "../http-types-BK7FuIcR.js";
|
|
3
4
|
export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, matchPathParams, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
|
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { l as pick, o as vRequired, t as addFieldsToValidator } from "../validators-D_i3BK7v.js";
|
|
2
2
|
import { a as isMutationCtx, c as requireActionCtx, d as requireRunMutationCtx, i as isActionCtx, l as requireMutationCtx, n as customCtx, o as isQueryCtx, s as isRunMutationCtx, t as NoOp, u as requireQueryCtx } from "../customFunctions-RnzME_cJ.js";
|
|
3
3
|
import { i as decodeWire, o as encodeWire, s as getTransformer } from "../transformer-ogg-4d78.js";
|
|
4
|
-
import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-
|
|
4
|
+
import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-C1uAqm5w.js";
|
|
5
5
|
import { ConvexError, v } from "convex/values";
|
|
6
6
|
import { HttpRouter, actionGeneric, getFunctionName, httpActionGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, makeFunctionReference, mutationGeneric, queryGeneric } from "convex/server";
|
|
7
7
|
import * as z$1 from "zod/v4";
|
|
@@ -1985,14 +1985,17 @@ const initCRPC = {
|
|
|
1985
1985
|
//#endregion
|
|
1986
1986
|
//#region src/server/env.ts
|
|
1987
1987
|
function createEnv(options) {
|
|
1988
|
-
const { schema, runtimeEnv = process.env, cache = true, codegenFallback =
|
|
1988
|
+
const { schema, runtimeEnv = process.env, cache = true, codegenFallback = false } = options;
|
|
1989
1989
|
let cached;
|
|
1990
1990
|
return () => {
|
|
1991
1991
|
if (cache && cached) return cached;
|
|
1992
|
-
const envForParse =
|
|
1992
|
+
const envForParse = globalThis.__BETTER_CONVEX_CODEGEN__ === true || codegenFallback ? {
|
|
1993
1993
|
...Object.fromEntries(Object.entries(schema.shape).map(([key, zodType]) => {
|
|
1994
1994
|
const result = zodType.safeParse(void 0);
|
|
1995
|
-
if (!result.success)
|
|
1995
|
+
if (!result.success) {
|
|
1996
|
+
if (zodType instanceof z.ZodEnum && Array.isArray(zodType.options) && zodType.options.length > 0) return [key, zodType.options[0]];
|
|
1997
|
+
return [key, ""];
|
|
1998
|
+
}
|
|
1996
1999
|
return [key, typeof result.data === "string" ? result.data : void 0];
|
|
1997
2000
|
})),
|
|
1998
2001
|
...runtimeEnv
|
package/dist/watcher.mjs
CHANGED
|
@@ -3420,6 +3420,9 @@ type MigrationCancelArgs = {
|
|
|
3420
3420
|
runId?: string;
|
|
3421
3421
|
};
|
|
3422
3422
|
//#endregion
|
|
3423
|
+
//#region src/orm/migrations/schema.d.ts
|
|
3424
|
+
declare function migrationPlugin(): OrmSchemaPlugin;
|
|
3425
|
+
//#endregion
|
|
3423
3426
|
//#region src/orm/triggers.d.ts
|
|
3424
3427
|
type MaybePromise<T> = T | Promise<T>;
|
|
3425
3428
|
type AnyRecord = Record<string, unknown>;
|
|
@@ -3692,4 +3695,4 @@ interface IndexLike {
|
|
|
3692
3695
|
indexName: string;
|
|
3693
3696
|
}
|
|
3694
3697
|
//#endregion
|
|
3695
|
-
export {
|
|
3698
|
+
export { DatabaseWithMutations as $, BuildQueryResult as $n, notBetween as $r, defineRelations as $t, MigrationCancelArgs as A, ConvexVectorIndexConfig as An, ExpressionVisitor as Ar, custom as At, MigrationManifestEntry as B, ConvexForeignKeyConfig as Bn, fieldRef as Br, ConvexBigIntBuilderInitial as Bt, OrmBeforeResult as C, ConvexRankIndexBuilder as Cn, ReturningResult as Cr, ConvexDateBuilder as Ct, OrmTriggers as D, ConvexSearchIndexConfig as Dn, VectorSearchProvider as Dr, ConvexCustomBuilder as Dt, OrmTriggerContext as E, ConvexSearchIndexBuilderOn as En, VectorQueryConfig as Er, date as Et, MigrationDefinition as F, uniqueIndex as Fn, and as Fr, bytes as Ft, MigrationStateMap as G, foreignKey as Gn, isFieldReference as Gr, ExtractTablesWithRelations as Gt, MigrationPlan as H, ConvexUniqueConstraintBuilderOn as Hn, gte as Hr, CountBackfillChunkArgs as Ht, MigrationDirection as I, vectorIndex as In, between as Ir, ConvexBooleanBuilder as It, MigrationWriteMode as J, ConvexTextBuilderInitial as Jn, like as Jr, RelationsBuilder as Jt, MigrationStep as K, unique as Kn, isNotNull as Kr, ManyConfig as Kt, MigrationDoc as L, ConvexCheckBuilder as Ln, contains as Lr, ConvexBooleanBuilderInitial as Lt, MigrationRunChunkArgs as M, index as Mn, FilterExpression$1 as Mr, objectOf as Mt, MigrationStatusArgs as N, rankIndex as Nn, LogicalExpression as Nr, ConvexBytesBuilder as Nt, defineTriggers as O, ConvexVectorIndexBuilder as On, unsetToken as Or, ConvexCustomBuilderInitial as Ot, MigrationAppliedState as P, searchIndex as Pn, UnaryExpression as Pr, ConvexBytesBuilderInitial as Pt, detectMigrationDrift as Q, AggregateResult as Qn, not as Qr, TablesRelationalConfig as Qt, MigrationDocContext as R, ConvexCheckConfig as Rn, endsWith as Rr, boolean as Rt, scheduledDeleteFactory as S, ConvexIndexBuilderOn as Sn, ReturningAll as Sr, id as St, OrmTriggerChange as T, ConvexSearchIndexBuilder as Tn, UpdateSet as Tr, ConvexDateMode as Tt, MigrationRunStatus as U, ConvexUniqueConstraintConfig as Un, ilike as Ur, CountBackfillKickoffArgs as Ut, MigrationMigrateOne as V, ConvexUniqueConstraintBuilder as Vn, gt as Vr, bigint as Vt, MigrationSet as W, check as Wn, inArray as Wr, CountBackfillStatusArgs as Wt, defineMigration as X, AggregateConfig as Xn, lte as Xr, RelationsBuilderColumnConfig as Xt, buildMigrationPlan as Y, text as Yn, lt as Yr, RelationsBuilderColumnBase as Yt, defineMigrationSet as Z, AggregateFieldValue as Zn, ne as Zr, TableRelationalConfig as Zt, OrmWriterCtx as _, HasDefault as _i, RlsRoleConfig as _n, MutationRunMode as _r, ConvexNumberBuilder as _t, TableConfigResult as a, OrmSchemaPlugin as ai, DiscriminatorBuilderConfig as an, GetColumnData as ar, EdgeMetadata as at, scheduledMutationBatchFactory as b, NotNull as bi, ConvexAggregateIndexBuilderOn as bn, PaginatedResult as br, ConvexIdBuilder as bt, OrmNotFoundError as c, SystemFields as ci, TableConfig as cn, InferSelectModel as cr, ConvexVectorBuilderInitial as ct, GenericOrmCtx as d, ColumnBuilderBaseConfig as di, discriminator as dn, MutationExecuteResult as dr, ConvexTimestampBuilderInitial as dt, notInArray as ei, defineRelationsPart as en, BuildRelationResult as er, DatabaseWithQuery as et, OrmApiResult as f, ColumnBuilderRuntimeConfig as fi, RlsPolicy as fn, MutationExecutionMode as fr, ConvexTimestampMode as ft, OrmReaderCtx as g, DrizzleEntity as gi, RlsRole as gn, MutationReturning as gr, textEnum as gt, OrmFunctions as h, ColumnDataType as hi, rlsPolicy as hn, MutationResult as hr, ConvexTextEnumBuilderInitial as ht, desc as i, Columns as ii, ConvexTableWithColumns as in, FilterOperators as ir, RlsMode as it, MigrationRunArgs as j, aggregateIndex as jn, FieldReference as jr, json as jt, migrationPlugin as k, ConvexVectorIndexBuilderOn as kn, BinaryExpression as kr, arrayOf as kt, CreateOrmOptions as l, AnyColumn as li, convexTable as ln, InsertValue as lr, vector as lt, OrmClientWithApi as m, ColumnBuilderWithTableName as mi, RlsPolicyToOption as mn, MutationPaginatedResult as mr, ConvexTextEnumBuilder as mt, defineSchema$1 as n, startsWith as ni, ConvexDeletionConfig as nn, CountResult as nr, OrmWriter as nt, getTableColumns as o, OrmSchemaPluginTables as oi, OrmLifecycleChange as on, InferInsertModel as or, extractRelationsConfig as ot, OrmClientBase as p, ColumnBuilderTypeConfig as pi, RlsPolicyConfig as pn, MutationPaginateConfig as pr, timestamp as pt, MigrationTableName as q, ConvexTextBuilder as qn, isNull as qr, OneConfig as qt, asc as r, Brand as ri, ConvexTable as rn, DBQueryConfig as rr, RlsContext as rt, getTableConfig as s, TableName as si, OrmLifecycleOperation as sn, InferModelFromColumns as sr, ConvexVectorBuilder as st, WhereClauseResult as t, or as ti, ConvexDeletionBuilder as tn, CountConfig as tr, OrmReader as tt, GenericOrm as u, ColumnBuilder as ui, deletion as un, MutationExecuteConfig as ur, ConvexTimestampBuilder as ut, createOrm as v, IsPrimaryKey as vi, rlsRole as vn, OrderByClause as vr, ConvexNumberBuilderInitial as vt, OrmTableTriggers as w, ConvexRankIndexBuilderOn as wn, ReturningSelection as wr, ConvexDateBuilderInitial as wt, ScheduledDeleteArgs as x, ConvexIndexBuilder as xn, PredicateWhereIndexConfig as xr, ConvexIdBuilderInitial as xt, ScheduledMutationBatchArgs as y, IsUnique as yi, ConvexAggregateIndexBuilder as yn, OrderDirection as yr, integer as yt, MigrationDriftIssue as z, ConvexForeignKeyBuilder as zn, eq as zr, ConvexBigIntBuilder as zt };
|