kitcn 0.12.27 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate/index.d.ts +1 -1
- package/dist/aggregate/index.js +1 -1
- package/dist/auth/client/index.d.ts +312 -4
- package/dist/auth/client/index.js +17 -5
- package/dist/auth/config/index.d.ts +1 -1
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/generated/index.js +1 -1
- package/dist/auth/http/index.d.ts +12 -9
- package/dist/auth/http/index.js +35 -6
- package/dist/auth/index.d.ts +292 -8
- package/dist/auth/index.js +29 -23
- package/dist/auth/nextjs/index.d.ts +4 -3
- package/dist/auth/nextjs/index.js +9 -4
- package/dist/auth/start/index.d.ts +13 -3
- package/dist/auth/start/index.js +97 -8
- package/dist/{backend-core-DqCCa0nr.mjs → backend-core-CXmrWqdi.mjs} +122 -48
- package/dist/{builder-Cb6gloDB.js → builder-DBgto1yn.js} +4 -3
- package/dist/{caller-factory-cTXNvYdz.js → caller-factory-NEfgD5E0.js} +3 -3
- package/dist/cli.mjs +26 -26
- package/dist/convex-plugin-C3N9BB-J.js +275 -0
- package/dist/convex-plugin-tWTDqoKJ.mjs +276 -0
- package/dist/{create-schema-orm-DOyiNDCx.js → create-schema-orm-B3f2Kc8O.js} +1 -1
- package/dist/crpc/index.d.ts +2 -2
- package/dist/crpc/index.js +3 -3
- package/dist/{customFunctions-C0voKmtx.js → customFunctions-DxEEO4Dq.js} +2 -1
- package/dist/{generated-contract-disabled-21YxPk5W.d.ts → generated-contract-disabled-C_-KWRfT.d.ts} +4 -2
- package/dist/{http-types-BLFA9zS7.d.ts → http-types-zsMHb_QN.d.ts} +2 -2
- package/dist/{middleware-DkIhQXwg.js → middleware-Bg-PdtrI.js} +1 -1
- package/dist/{middleware-nS_qXecO.d.ts → middleware-DrtexzF3.d.ts} +1 -1
- package/dist/orm/index.d.ts +3 -3
- package/dist/orm/index.js +3 -3
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-AjLfkHyF.js → procedure-caller-DplSC7Us.js} +2 -2
- package/dist/{procedure-name-D-fDCBlo.d.ts → procedure-name-BCRBr6Po.d.ts} +3 -3
- package/dist/ratelimit/index.d.ts +2 -2
- package/dist/ratelimit/index.js +3 -3
- package/dist/react/index.d.ts +18 -14
- package/dist/react/index.js +14 -27
- package/dist/rsc/index.d.ts +4 -4
- package/dist/rsc/index.js +4 -4
- package/dist/{runtime-CtvJPkur.js → runtime-i6t-HoZn.js} +1 -1
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +4 -4
- package/dist/solid/index.d.ts +300 -4
- package/dist/token-B9Bjcqug.d.ts +13 -0
- package/dist/token-tpipF-7y.js +47 -0
- package/dist/{types-C6pQrnzD.d.ts → types-YHpe0rsb.d.ts} +1 -1
- package/dist/upstream-BR6sBLg3.js +84 -0
- package/dist/upstream-BUCdbLok.mjs +26 -0
- package/dist/{validators-B7oIJCAp.js → validators-C7LelqTN.js} +2 -84
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-DdjN63Io.d.ts → where-clause-compiler-TMppDl9g.d.ts} +51 -51
- package/package.json +5 -4
- package/skills/convex/references/features/auth.md +20 -0
- package/skills/convex/references/setup/auth.md +2 -0
- package/skills/convex/references/setup/index.md +5 -5
- package/skills/convex/references/setup/server.md +1 -1
- /package/dist/{api-entry-BUAh_K4k.js → api-entry-N3nBOlI2.js} +0 -0
- /package/dist/{context-utils-BvWW0Ilq.d.ts → context-utils-OMkMGhBk.d.ts} +0 -0
- /package/dist/{create-schema-odyF4kCy.js → create-schema-BXrKE2YY.js} +0 -0
- /package/dist/{error-BZEnI7Sq.js → error-Bvo7YEhk.js} +0 -0
- /package/dist/{generated-contract-disabled-Cih4eITO.js → generated-contract-disabled-BXaz7JCE.js} +0 -0
- /package/dist/{meta-utils-0Pu0Nrap.js → meta-utils-D9K4fICl.js} +0 -0
- /package/dist/{query-context-CFZqIvD7.d.ts → query-context-CNo9ffvI.d.ts} +0 -0
- /package/dist/{query-context-B8o6-8kC.js → query-context-ydn9kb6P.js} +0 -0
- /package/dist/{query-options-Dw7cOyXl.js → query-options-C96zLANM.js} +0 -0
- /package/dist/{transformer-DtDhR3Lc.js → transformer-C6pGVHqx.js} +0 -0
- /package/dist/{types-BiJE7qxR.d.ts → types-BCl8gfGy.d.ts} +0 -0
- /package/dist/{types-a-RHmrDZ.d.ts → types-CnTpHR1F.d.ts} +0 -0
- /package/dist/{types-BTb_4BaU.d.ts → types-DF2cg_w0.d.ts} +0 -0
- /package/dist/{validators-vzRKjBJC.d.ts → validators-BhsByJeg.d.ts} +0 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { r as omit } from "./upstream-BR6sBLg3.js";
|
|
2
|
+
import { createAuthEndpoint, createAuthMiddleware, sessionMiddleware } from "better-auth/api";
|
|
3
|
+
import { bearer } from "better-auth/plugins/bearer";
|
|
4
|
+
import { jwt } from "better-auth/plugins/jwt";
|
|
5
|
+
import { oidcProvider } from "better-auth/plugins/oidc-provider";
|
|
6
|
+
|
|
7
|
+
//#region src/auth/internal/convex-plugin.ts
|
|
8
|
+
const JWT_COOKIE_NAME = "convex_jwt";
|
|
9
|
+
const normalizeAfterHooks = (hooks) => {
|
|
10
|
+
return hooks.map((hook) => ({
|
|
11
|
+
...hook,
|
|
12
|
+
matcher: (ctx) => Boolean(hook.matcher(ctx))
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
const getJwksAlg = (authProvider) => {
|
|
16
|
+
const isCustomJwt = "type" in authProvider && authProvider.type === "customJwt";
|
|
17
|
+
if (isCustomJwt && authProvider.algorithm !== "RS256") throw new Error("Only RS256 is supported for custom JWT with Better Auth");
|
|
18
|
+
return isCustomJwt ? authProvider.algorithm : "EdDSA";
|
|
19
|
+
};
|
|
20
|
+
const parseAuthConfig = (authConfig, opts) => {
|
|
21
|
+
const providerConfigs = authConfig.providers.filter((provider) => provider.applicationID === "convex");
|
|
22
|
+
if (providerConfigs.length > 1) throw new Error("Multiple auth providers with applicationID 'convex' detected. Please use only one.");
|
|
23
|
+
const providerConfig = providerConfigs[0];
|
|
24
|
+
if (!providerConfig) throw new Error("No auth provider with applicationID 'convex' found. Please add one to your auth config.");
|
|
25
|
+
if (!("type" in providerConfig) || providerConfig.type !== "customJwt") return providerConfig;
|
|
26
|
+
const isDataUriJwks = providerConfig.jwks?.startsWith("data:text/");
|
|
27
|
+
if (isDataUriJwks && !opts.jwks) throw new Error("Static JWKS detected in auth config, but missing from Convex plugin");
|
|
28
|
+
if (!isDataUriJwks && opts.jwks) console.warn("Static JWKS provided to Convex plugin, but not to auth config. This adds an unnecessary network request for token verification.");
|
|
29
|
+
return providerConfig;
|
|
30
|
+
};
|
|
31
|
+
const convex = (opts) => {
|
|
32
|
+
const jwtExpirationSeconds = opts.jwt?.expirationSeconds ?? opts.jwtExpirationSeconds ?? 900;
|
|
33
|
+
const oidcProvider$1 = oidcProvider({
|
|
34
|
+
loginPage: "/not-used",
|
|
35
|
+
metadata: {
|
|
36
|
+
issuer: `${process.env.CONVEX_SITE_URL}`,
|
|
37
|
+
jwks_uri: `${process.env.CONVEX_SITE_URL}${opts.options?.basePath ?? "/api/auth"}/convex/jwks`
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const providerConfig = parseAuthConfig(opts.authConfig, opts);
|
|
41
|
+
const jwtOptions = {
|
|
42
|
+
jwt: {
|
|
43
|
+
issuer: `${process.env.CONVEX_SITE_URL}`,
|
|
44
|
+
audience: "convex",
|
|
45
|
+
expirationTime: `${jwtExpirationSeconds}s`,
|
|
46
|
+
definePayload: async ({ user, session }) => ({
|
|
47
|
+
...opts.jwt?.definePayload ? await opts.jwt.definePayload({
|
|
48
|
+
session,
|
|
49
|
+
user
|
|
50
|
+
}) : omit(user, ["id", "image"]),
|
|
51
|
+
sessionId: session.id,
|
|
52
|
+
iat: Math.floor(Date.now() / 1e3)
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
jwks: { keyPairConfig: { alg: getJwksAlg(providerConfig) } }
|
|
56
|
+
};
|
|
57
|
+
const jwks = opts.jwks ? JSON.parse(opts.jwks) : void 0;
|
|
58
|
+
const jwt$1 = jwt({
|
|
59
|
+
...jwtOptions,
|
|
60
|
+
adapter: {
|
|
61
|
+
createJwk: async (webKey, ctx) => {
|
|
62
|
+
if (opts.jwks) throw new Error("Not implemented");
|
|
63
|
+
return await ctx.context.adapter.create({
|
|
64
|
+
model: "jwks",
|
|
65
|
+
data: {
|
|
66
|
+
...webKey,
|
|
67
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
getJwks: async (ctx) => {
|
|
72
|
+
if (opts.jwks) return jwks;
|
|
73
|
+
return (await ctx.context.adapter.findMany({
|
|
74
|
+
model: "jwks",
|
|
75
|
+
sortBy: {
|
|
76
|
+
direction: "desc",
|
|
77
|
+
field: "createdAt"
|
|
78
|
+
}
|
|
79
|
+
})).map((key) => ({
|
|
80
|
+
...key,
|
|
81
|
+
createdAt: new Date(key.createdAt),
|
|
82
|
+
...key.expiresAt ? { expiresAt: new Date(key.expiresAt) } : {}
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const bearer$1 = bearer();
|
|
88
|
+
const schema = {
|
|
89
|
+
user: { fields: { userId: {
|
|
90
|
+
type: "string",
|
|
91
|
+
required: false,
|
|
92
|
+
input: false
|
|
93
|
+
} } },
|
|
94
|
+
...jwt$1.schema
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
id: "convex",
|
|
98
|
+
init: (ctx) => {
|
|
99
|
+
const { options } = ctx;
|
|
100
|
+
if (options.basePath !== "/api/auth" && !opts.options?.basePath) console.warn(`Better Auth basePath set to ${options.basePath} but no basePath is set in the Convex plugin. This is probably a mistake.`);
|
|
101
|
+
if (opts.options?.basePath && options.basePath !== opts.options?.basePath) console.warn(`Better Auth basePath ${options.basePath} does not match Convex plugin basePath ${opts.options?.basePath}. This is probably a mistake.`);
|
|
102
|
+
},
|
|
103
|
+
hooks: {
|
|
104
|
+
before: [...bearer$1.hooks.before, {
|
|
105
|
+
matcher: (ctx) => {
|
|
106
|
+
return !ctx.context.adapter.options?.isRunMutationCtx;
|
|
107
|
+
},
|
|
108
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
109
|
+
ctx.query = {
|
|
110
|
+
...ctx.query,
|
|
111
|
+
disableRefresh: true
|
|
112
|
+
};
|
|
113
|
+
ctx.context.internalAdapter.deleteSession = async (..._args) => {};
|
|
114
|
+
const knownSafePaths = ["/api-key/list", "/api-key/get"];
|
|
115
|
+
const noopWrite = (method) => {
|
|
116
|
+
return async (..._args) => {
|
|
117
|
+
if (ctx.path && !knownSafePaths.includes(ctx.path)) console.warn(`[convex-better-auth] Write operation "${method}" skipped in query context for ${ctx.path}`);
|
|
118
|
+
return 0;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
ctx.context.adapter.create = noopWrite("create");
|
|
122
|
+
ctx.context.adapter.update = noopWrite("update");
|
|
123
|
+
ctx.context.adapter.updateMany = noopWrite("updateMany");
|
|
124
|
+
ctx.context.adapter.delete = noopWrite("delete");
|
|
125
|
+
ctx.context.adapter.deleteMany = noopWrite("deleteMany");
|
|
126
|
+
return { context: ctx };
|
|
127
|
+
})
|
|
128
|
+
}],
|
|
129
|
+
after: [
|
|
130
|
+
...normalizeAfterHooks(oidcProvider$1.hooks.after),
|
|
131
|
+
{
|
|
132
|
+
matcher: (ctx) => {
|
|
133
|
+
return Boolean(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/oauth2/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/phone-number/verify") || ctx.path?.startsWith("/siwe/verify") || ctx.path?.startsWith("/update-session") || ctx.path?.startsWith("/get-session") && ctx.context.session);
|
|
134
|
+
},
|
|
135
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
136
|
+
const originalSession = ctx.context.session;
|
|
137
|
+
try {
|
|
138
|
+
ctx.context.session = ctx.context.session ?? ctx.context.newSession;
|
|
139
|
+
const { token } = await jwt$1.endpoints.getToken({
|
|
140
|
+
...ctx,
|
|
141
|
+
headers: {},
|
|
142
|
+
method: "GET",
|
|
143
|
+
returnHeaders: false,
|
|
144
|
+
returnStatus: false
|
|
145
|
+
});
|
|
146
|
+
const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
|
|
147
|
+
ctx.setCookie(jwtCookie.name, token, jwtCookie.attributes);
|
|
148
|
+
} catch (_error) {}
|
|
149
|
+
ctx.context.session = originalSession;
|
|
150
|
+
})
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
matcher: (ctx) => {
|
|
154
|
+
return Boolean(ctx.path?.startsWith("/sign-out") || ctx.path?.startsWith("/delete-user") || ctx.path?.startsWith("/get-session") && !ctx.context.session);
|
|
155
|
+
},
|
|
156
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
157
|
+
const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: 0 });
|
|
158
|
+
ctx.setCookie(jwtCookie.name, "", jwtCookie.attributes);
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
endpoints: {
|
|
164
|
+
getOpenIdConfig: createAuthEndpoint("/convex/.well-known/openid-configuration", {
|
|
165
|
+
method: "GET",
|
|
166
|
+
metadata: { isAction: false }
|
|
167
|
+
}, async (ctx) => {
|
|
168
|
+
return await oidcProvider$1.endpoints.getOpenIdConfig({
|
|
169
|
+
...ctx,
|
|
170
|
+
returnHeaders: false,
|
|
171
|
+
returnStatus: false
|
|
172
|
+
});
|
|
173
|
+
}),
|
|
174
|
+
getJwks: createAuthEndpoint("/convex/jwks", {
|
|
175
|
+
method: "GET",
|
|
176
|
+
metadata: { openapi: {
|
|
177
|
+
description: "Get the JSON Web Key Set",
|
|
178
|
+
responses: { "200": { description: "JSON Web Key Set retrieved successfully" } }
|
|
179
|
+
} }
|
|
180
|
+
}, async (ctx) => {
|
|
181
|
+
return await jwt$1.endpoints.getJwks({
|
|
182
|
+
...ctx,
|
|
183
|
+
returnHeaders: false,
|
|
184
|
+
returnStatus: false
|
|
185
|
+
});
|
|
186
|
+
}),
|
|
187
|
+
getLatestJwks: createAuthEndpoint("/convex/latest-jwks", {
|
|
188
|
+
isAction: true,
|
|
189
|
+
method: "POST",
|
|
190
|
+
metadata: {
|
|
191
|
+
SERVER_ONLY: true,
|
|
192
|
+
openapi: { description: "Delete and regenerate JWKS, and return the new JWKS for static usage" }
|
|
193
|
+
}
|
|
194
|
+
}, async (ctx) => {
|
|
195
|
+
await jwt(jwtOptions).endpoints.getJwks({
|
|
196
|
+
...ctx,
|
|
197
|
+
method: "GET"
|
|
198
|
+
});
|
|
199
|
+
const jwks = await ctx.context.adapter.findMany({
|
|
200
|
+
model: "jwks",
|
|
201
|
+
limit: 1,
|
|
202
|
+
sortBy: {
|
|
203
|
+
direction: "desc",
|
|
204
|
+
field: "createdAt"
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
jwks[0].alg = jwtOptions.jwks.keyPairConfig.alg;
|
|
208
|
+
return jwks;
|
|
209
|
+
}),
|
|
210
|
+
rotateKeys: createAuthEndpoint("/convex/rotate-keys", {
|
|
211
|
+
isAction: true,
|
|
212
|
+
method: "POST",
|
|
213
|
+
metadata: {
|
|
214
|
+
SERVER_ONLY: true,
|
|
215
|
+
openapi: { description: "Delete and regenerate JWKS, and return the new JWKS for static usage" }
|
|
216
|
+
}
|
|
217
|
+
}, async (ctx) => {
|
|
218
|
+
await ctx.context.adapter.deleteMany({
|
|
219
|
+
model: "jwks",
|
|
220
|
+
where: []
|
|
221
|
+
});
|
|
222
|
+
await jwt(jwtOptions).endpoints.getJwks({
|
|
223
|
+
...ctx,
|
|
224
|
+
method: "GET"
|
|
225
|
+
});
|
|
226
|
+
const jwks = await ctx.context.adapter.findMany({
|
|
227
|
+
model: "jwks",
|
|
228
|
+
limit: 1,
|
|
229
|
+
sortBy: {
|
|
230
|
+
direction: "desc",
|
|
231
|
+
field: "createdAt"
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
jwks[0].alg = jwtOptions.jwks.keyPairConfig.alg;
|
|
235
|
+
return jwks;
|
|
236
|
+
}),
|
|
237
|
+
getToken: createAuthEndpoint("/convex/token", {
|
|
238
|
+
method: "GET",
|
|
239
|
+
requireHeaders: true,
|
|
240
|
+
use: [sessionMiddleware],
|
|
241
|
+
metadata: { openapi: { description: "Get a JWT token" } }
|
|
242
|
+
}, async (ctx) => {
|
|
243
|
+
const runEndpoint = async () => {
|
|
244
|
+
const response = await jwt$1.endpoints.getToken({
|
|
245
|
+
...ctx,
|
|
246
|
+
returnHeaders: false,
|
|
247
|
+
returnStatus: false
|
|
248
|
+
});
|
|
249
|
+
const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
|
|
250
|
+
ctx.setCookie(jwtCookie.name, response.token, jwtCookie.attributes);
|
|
251
|
+
return response;
|
|
252
|
+
};
|
|
253
|
+
try {
|
|
254
|
+
return await runEndpoint();
|
|
255
|
+
} catch (error) {
|
|
256
|
+
if (!opts.jwks && error?.code === "ERR_JOSE_NOT_SUPPORTED") {
|
|
257
|
+
if (opts.jwksRotateOnTokenGenerationError) {
|
|
258
|
+
await ctx.context.adapter.deleteMany({
|
|
259
|
+
model: "jwks",
|
|
260
|
+
where: []
|
|
261
|
+
});
|
|
262
|
+
return await runEndpoint();
|
|
263
|
+
}
|
|
264
|
+
console.error("Try temporarily setting jwksRotateOnTokenGenerationError: true on the Convex Better Auth plugin.");
|
|
265
|
+
}
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
},
|
|
270
|
+
schema
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
export { convex as n, JWT_COOKIE_NAME as t };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as omit } from "./upstream-BUCdbLok.mjs";
|
|
3
|
+
import { createAuthEndpoint, createAuthMiddleware, sessionMiddleware } from "better-auth/api";
|
|
4
|
+
import { bearer } from "better-auth/plugins/bearer";
|
|
5
|
+
import { jwt } from "better-auth/plugins/jwt";
|
|
6
|
+
import { oidcProvider } from "better-auth/plugins/oidc-provider";
|
|
7
|
+
|
|
8
|
+
//#region src/auth/internal/convex-plugin.ts
|
|
9
|
+
const JWT_COOKIE_NAME = "convex_jwt";
|
|
10
|
+
const normalizeAfterHooks = (hooks) => {
|
|
11
|
+
return hooks.map((hook) => ({
|
|
12
|
+
...hook,
|
|
13
|
+
matcher: (ctx) => Boolean(hook.matcher(ctx))
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
const getJwksAlg = (authProvider) => {
|
|
17
|
+
const isCustomJwt = "type" in authProvider && authProvider.type === "customJwt";
|
|
18
|
+
if (isCustomJwt && authProvider.algorithm !== "RS256") throw new Error("Only RS256 is supported for custom JWT with Better Auth");
|
|
19
|
+
return isCustomJwt ? authProvider.algorithm : "EdDSA";
|
|
20
|
+
};
|
|
21
|
+
const parseAuthConfig = (authConfig, opts) => {
|
|
22
|
+
const providerConfigs = authConfig.providers.filter((provider) => provider.applicationID === "convex");
|
|
23
|
+
if (providerConfigs.length > 1) throw new Error("Multiple auth providers with applicationID 'convex' detected. Please use only one.");
|
|
24
|
+
const providerConfig = providerConfigs[0];
|
|
25
|
+
if (!providerConfig) throw new Error("No auth provider with applicationID 'convex' found. Please add one to your auth config.");
|
|
26
|
+
if (!("type" in providerConfig) || providerConfig.type !== "customJwt") return providerConfig;
|
|
27
|
+
const isDataUriJwks = providerConfig.jwks?.startsWith("data:text/");
|
|
28
|
+
if (isDataUriJwks && !opts.jwks) throw new Error("Static JWKS detected in auth config, but missing from Convex plugin");
|
|
29
|
+
if (!isDataUriJwks && opts.jwks) console.warn("Static JWKS provided to Convex plugin, but not to auth config. This adds an unnecessary network request for token verification.");
|
|
30
|
+
return providerConfig;
|
|
31
|
+
};
|
|
32
|
+
const convex = (opts) => {
|
|
33
|
+
const jwtExpirationSeconds = opts.jwt?.expirationSeconds ?? opts.jwtExpirationSeconds ?? 900;
|
|
34
|
+
const oidcProvider$1 = oidcProvider({
|
|
35
|
+
loginPage: "/not-used",
|
|
36
|
+
metadata: {
|
|
37
|
+
issuer: `${process.env.CONVEX_SITE_URL}`,
|
|
38
|
+
jwks_uri: `${process.env.CONVEX_SITE_URL}${opts.options?.basePath ?? "/api/auth"}/convex/jwks`
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const providerConfig = parseAuthConfig(opts.authConfig, opts);
|
|
42
|
+
const jwtOptions = {
|
|
43
|
+
jwt: {
|
|
44
|
+
issuer: `${process.env.CONVEX_SITE_URL}`,
|
|
45
|
+
audience: "convex",
|
|
46
|
+
expirationTime: `${jwtExpirationSeconds}s`,
|
|
47
|
+
definePayload: async ({ user, session }) => ({
|
|
48
|
+
...opts.jwt?.definePayload ? await opts.jwt.definePayload({
|
|
49
|
+
session,
|
|
50
|
+
user
|
|
51
|
+
}) : omit(user, ["id", "image"]),
|
|
52
|
+
sessionId: session.id,
|
|
53
|
+
iat: Math.floor(Date.now() / 1e3)
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
jwks: { keyPairConfig: { alg: getJwksAlg(providerConfig) } }
|
|
57
|
+
};
|
|
58
|
+
const jwks = opts.jwks ? JSON.parse(opts.jwks) : void 0;
|
|
59
|
+
const jwt$1 = jwt({
|
|
60
|
+
...jwtOptions,
|
|
61
|
+
adapter: {
|
|
62
|
+
createJwk: async (webKey, ctx) => {
|
|
63
|
+
if (opts.jwks) throw new Error("Not implemented");
|
|
64
|
+
return await ctx.context.adapter.create({
|
|
65
|
+
model: "jwks",
|
|
66
|
+
data: {
|
|
67
|
+
...webKey,
|
|
68
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
getJwks: async (ctx) => {
|
|
73
|
+
if (opts.jwks) return jwks;
|
|
74
|
+
return (await ctx.context.adapter.findMany({
|
|
75
|
+
model: "jwks",
|
|
76
|
+
sortBy: {
|
|
77
|
+
direction: "desc",
|
|
78
|
+
field: "createdAt"
|
|
79
|
+
}
|
|
80
|
+
})).map((key) => ({
|
|
81
|
+
...key,
|
|
82
|
+
createdAt: new Date(key.createdAt),
|
|
83
|
+
...key.expiresAt ? { expiresAt: new Date(key.expiresAt) } : {}
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
const bearer$1 = bearer();
|
|
89
|
+
const schema = {
|
|
90
|
+
user: { fields: { userId: {
|
|
91
|
+
type: "string",
|
|
92
|
+
required: false,
|
|
93
|
+
input: false
|
|
94
|
+
} } },
|
|
95
|
+
...jwt$1.schema
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
id: "convex",
|
|
99
|
+
init: (ctx) => {
|
|
100
|
+
const { options } = ctx;
|
|
101
|
+
if (options.basePath !== "/api/auth" && !opts.options?.basePath) console.warn(`Better Auth basePath set to ${options.basePath} but no basePath is set in the Convex plugin. This is probably a mistake.`);
|
|
102
|
+
if (opts.options?.basePath && options.basePath !== opts.options?.basePath) console.warn(`Better Auth basePath ${options.basePath} does not match Convex plugin basePath ${opts.options?.basePath}. This is probably a mistake.`);
|
|
103
|
+
},
|
|
104
|
+
hooks: {
|
|
105
|
+
before: [...bearer$1.hooks.before, {
|
|
106
|
+
matcher: (ctx) => {
|
|
107
|
+
return !ctx.context.adapter.options?.isRunMutationCtx;
|
|
108
|
+
},
|
|
109
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
110
|
+
ctx.query = {
|
|
111
|
+
...ctx.query,
|
|
112
|
+
disableRefresh: true
|
|
113
|
+
};
|
|
114
|
+
ctx.context.internalAdapter.deleteSession = async (..._args) => {};
|
|
115
|
+
const knownSafePaths = ["/api-key/list", "/api-key/get"];
|
|
116
|
+
const noopWrite = (method) => {
|
|
117
|
+
return async (..._args) => {
|
|
118
|
+
if (ctx.path && !knownSafePaths.includes(ctx.path)) console.warn(`[convex-better-auth] Write operation "${method}" skipped in query context for ${ctx.path}`);
|
|
119
|
+
return 0;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
ctx.context.adapter.create = noopWrite("create");
|
|
123
|
+
ctx.context.adapter.update = noopWrite("update");
|
|
124
|
+
ctx.context.adapter.updateMany = noopWrite("updateMany");
|
|
125
|
+
ctx.context.adapter.delete = noopWrite("delete");
|
|
126
|
+
ctx.context.adapter.deleteMany = noopWrite("deleteMany");
|
|
127
|
+
return { context: ctx };
|
|
128
|
+
})
|
|
129
|
+
}],
|
|
130
|
+
after: [
|
|
131
|
+
...normalizeAfterHooks(oidcProvider$1.hooks.after),
|
|
132
|
+
{
|
|
133
|
+
matcher: (ctx) => {
|
|
134
|
+
return Boolean(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/oauth2/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/phone-number/verify") || ctx.path?.startsWith("/siwe/verify") || ctx.path?.startsWith("/update-session") || ctx.path?.startsWith("/get-session") && ctx.context.session);
|
|
135
|
+
},
|
|
136
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
137
|
+
const originalSession = ctx.context.session;
|
|
138
|
+
try {
|
|
139
|
+
ctx.context.session = ctx.context.session ?? ctx.context.newSession;
|
|
140
|
+
const { token } = await jwt$1.endpoints.getToken({
|
|
141
|
+
...ctx,
|
|
142
|
+
headers: {},
|
|
143
|
+
method: "GET",
|
|
144
|
+
returnHeaders: false,
|
|
145
|
+
returnStatus: false
|
|
146
|
+
});
|
|
147
|
+
const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
|
|
148
|
+
ctx.setCookie(jwtCookie.name, token, jwtCookie.attributes);
|
|
149
|
+
} catch (_error) {}
|
|
150
|
+
ctx.context.session = originalSession;
|
|
151
|
+
})
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
matcher: (ctx) => {
|
|
155
|
+
return Boolean(ctx.path?.startsWith("/sign-out") || ctx.path?.startsWith("/delete-user") || ctx.path?.startsWith("/get-session") && !ctx.context.session);
|
|
156
|
+
},
|
|
157
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
158
|
+
const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: 0 });
|
|
159
|
+
ctx.setCookie(jwtCookie.name, "", jwtCookie.attributes);
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
endpoints: {
|
|
165
|
+
getOpenIdConfig: createAuthEndpoint("/convex/.well-known/openid-configuration", {
|
|
166
|
+
method: "GET",
|
|
167
|
+
metadata: { isAction: false }
|
|
168
|
+
}, async (ctx) => {
|
|
169
|
+
return await oidcProvider$1.endpoints.getOpenIdConfig({
|
|
170
|
+
...ctx,
|
|
171
|
+
returnHeaders: false,
|
|
172
|
+
returnStatus: false
|
|
173
|
+
});
|
|
174
|
+
}),
|
|
175
|
+
getJwks: createAuthEndpoint("/convex/jwks", {
|
|
176
|
+
method: "GET",
|
|
177
|
+
metadata: { openapi: {
|
|
178
|
+
description: "Get the JSON Web Key Set",
|
|
179
|
+
responses: { "200": { description: "JSON Web Key Set retrieved successfully" } }
|
|
180
|
+
} }
|
|
181
|
+
}, async (ctx) => {
|
|
182
|
+
return await jwt$1.endpoints.getJwks({
|
|
183
|
+
...ctx,
|
|
184
|
+
returnHeaders: false,
|
|
185
|
+
returnStatus: false
|
|
186
|
+
});
|
|
187
|
+
}),
|
|
188
|
+
getLatestJwks: createAuthEndpoint("/convex/latest-jwks", {
|
|
189
|
+
isAction: true,
|
|
190
|
+
method: "POST",
|
|
191
|
+
metadata: {
|
|
192
|
+
SERVER_ONLY: true,
|
|
193
|
+
openapi: { description: "Delete and regenerate JWKS, and return the new JWKS for static usage" }
|
|
194
|
+
}
|
|
195
|
+
}, async (ctx) => {
|
|
196
|
+
await jwt(jwtOptions).endpoints.getJwks({
|
|
197
|
+
...ctx,
|
|
198
|
+
method: "GET"
|
|
199
|
+
});
|
|
200
|
+
const jwks = await ctx.context.adapter.findMany({
|
|
201
|
+
model: "jwks",
|
|
202
|
+
limit: 1,
|
|
203
|
+
sortBy: {
|
|
204
|
+
direction: "desc",
|
|
205
|
+
field: "createdAt"
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
jwks[0].alg = jwtOptions.jwks.keyPairConfig.alg;
|
|
209
|
+
return jwks;
|
|
210
|
+
}),
|
|
211
|
+
rotateKeys: createAuthEndpoint("/convex/rotate-keys", {
|
|
212
|
+
isAction: true,
|
|
213
|
+
method: "POST",
|
|
214
|
+
metadata: {
|
|
215
|
+
SERVER_ONLY: true,
|
|
216
|
+
openapi: { description: "Delete and regenerate JWKS, and return the new JWKS for static usage" }
|
|
217
|
+
}
|
|
218
|
+
}, async (ctx) => {
|
|
219
|
+
await ctx.context.adapter.deleteMany({
|
|
220
|
+
model: "jwks",
|
|
221
|
+
where: []
|
|
222
|
+
});
|
|
223
|
+
await jwt(jwtOptions).endpoints.getJwks({
|
|
224
|
+
...ctx,
|
|
225
|
+
method: "GET"
|
|
226
|
+
});
|
|
227
|
+
const jwks = await ctx.context.adapter.findMany({
|
|
228
|
+
model: "jwks",
|
|
229
|
+
limit: 1,
|
|
230
|
+
sortBy: {
|
|
231
|
+
direction: "desc",
|
|
232
|
+
field: "createdAt"
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
jwks[0].alg = jwtOptions.jwks.keyPairConfig.alg;
|
|
236
|
+
return jwks;
|
|
237
|
+
}),
|
|
238
|
+
getToken: createAuthEndpoint("/convex/token", {
|
|
239
|
+
method: "GET",
|
|
240
|
+
requireHeaders: true,
|
|
241
|
+
use: [sessionMiddleware],
|
|
242
|
+
metadata: { openapi: { description: "Get a JWT token" } }
|
|
243
|
+
}, async (ctx) => {
|
|
244
|
+
const runEndpoint = async () => {
|
|
245
|
+
const response = await jwt$1.endpoints.getToken({
|
|
246
|
+
...ctx,
|
|
247
|
+
returnHeaders: false,
|
|
248
|
+
returnStatus: false
|
|
249
|
+
});
|
|
250
|
+
const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
|
|
251
|
+
ctx.setCookie(jwtCookie.name, response.token, jwtCookie.attributes);
|
|
252
|
+
return response;
|
|
253
|
+
};
|
|
254
|
+
try {
|
|
255
|
+
return await runEndpoint();
|
|
256
|
+
} catch (error) {
|
|
257
|
+
if (!opts.jwks && error?.code === "ERR_JOSE_NOT_SUPPORTED") {
|
|
258
|
+
if (opts.jwksRotateOnTokenGenerationError) {
|
|
259
|
+
await ctx.context.adapter.deleteMany({
|
|
260
|
+
model: "jwks",
|
|
261
|
+
where: []
|
|
262
|
+
});
|
|
263
|
+
return await runEndpoint();
|
|
264
|
+
}
|
|
265
|
+
console.error("Try temporarily setting jwksRotateOnTokenGenerationError: true on the Convex Better Auth plugin.");
|
|
266
|
+
}
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
},
|
|
271
|
+
schema
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
//#endregion
|
|
276
|
+
export { convex };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { augmentBetterAuthTables, indexFields } from "./create-schema-
|
|
1
|
+
import { augmentBetterAuthTables, indexFields } from "./create-schema-BXrKE2YY.js";
|
|
2
2
|
|
|
3
3
|
//#region src/auth/create-schema-orm.ts
|
|
4
4
|
const specialFields = (tables) => Object.fromEntries(Object.entries(tables).map(([key, table]) => {
|
package/dist/crpc/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as DataTransformer, F as decodeWire, I as defaultCRPCTransformer, L as encodeWire, M as WireCodec, N as createTaggedTransformer, O as CombinedDataTransformer, P as dateWireCodec, R as getTransformer, a as HttpProcedureCall, c as InferHttpInput, i as HttpErrorCode, j as DataTransformerOptions, k as DATE_CODEC_TAG, l as InferHttpOutput, n as HttpClientError, o as HttpRouteInfo, r as HttpClientFromRouter, s as HttpRouteMap, t as HttpClient, u as isHttpClientError, z as identityTransformer } from "../http-types-
|
|
2
|
-
import { A as HttpInputArgs, C as ReservedMutationOptions, D as VanillaMutation, E as VanillaAction, F as replaceUrlParam, M as RESERVED_KEYS, N as buildSearchParams, O as HttpClientOptions, P as executeHttpRequest, S as ReservedInfiniteQueryOptions, T as StaticQueryOptsParam, _ as IsPaginated, a as BaseInfiniteQueryOptsParam, b as PaginatedFnMeta, c as ConvexMutationKey, d as ConvexQueryMeta, f as EmptyObject, g as InfiniteQueryInput, h as FnMeta, i as BaseConvexQueryOptions, j as HttpProxyBaseOptions, k as HttpFormValue, l as ConvexQueryHookOptions, m as FUNC_REF_SYMBOL, n as BaseConvexActionOptions, o as ConvexActionKey, p as ExtractPaginatedItem, r as BaseConvexInfiniteQueryOptions, s as ConvexInfiniteQueryMeta, t as AuthType, u as ConvexQueryKey, v as Meta, w as ReservedQueryOptions, x as PaginationOpts, y as MutationVariables } from "../types-
|
|
1
|
+
import { A as DataTransformer, F as decodeWire, I as defaultCRPCTransformer, L as encodeWire, M as WireCodec, N as createTaggedTransformer, O as CombinedDataTransformer, P as dateWireCodec, R as getTransformer, a as HttpProcedureCall, c as InferHttpInput, i as HttpErrorCode, j as DataTransformerOptions, k as DATE_CODEC_TAG, l as InferHttpOutput, n as HttpClientError, o as HttpRouteInfo, r as HttpClientFromRouter, s as HttpRouteMap, t as HttpClient, u as isHttpClientError, z as identityTransformer } from "../http-types-zsMHb_QN.js";
|
|
2
|
+
import { A as HttpInputArgs, C as ReservedMutationOptions, D as VanillaMutation, E as VanillaAction, F as replaceUrlParam, M as RESERVED_KEYS, N as buildSearchParams, O as HttpClientOptions, P as executeHttpRequest, S as ReservedInfiniteQueryOptions, T as StaticQueryOptsParam, _ as IsPaginated, a as BaseInfiniteQueryOptsParam, b as PaginatedFnMeta, c as ConvexMutationKey, d as ConvexQueryMeta, f as EmptyObject, g as InfiniteQueryInput, h as FnMeta, i as BaseConvexQueryOptions, j as HttpProxyBaseOptions, k as HttpFormValue, l as ConvexQueryHookOptions, m as FUNC_REF_SYMBOL, n as BaseConvexActionOptions, o as ConvexActionKey, p as ExtractPaginatedItem, r as BaseConvexInfiniteQueryOptions, s as ConvexInfiniteQueryMeta, t as AuthType, u as ConvexQueryKey, v as Meta, w as ReservedQueryOptions, x as PaginationOpts, y as MutationVariables } from "../types-YHpe0rsb.js";
|
|
3
3
|
import { FunctionArgs, FunctionReference } from "convex/server";
|
|
4
4
|
|
|
5
5
|
//#region src/crpc/auth-error.d.ts
|
package/dist/crpc/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as isCRPCErrorCode, i as isCRPCError, n as defaultIsUnauthorized, r as isCRPCClientError, t as CRPCClientError } from "../error-
|
|
2
|
-
import { a as defaultCRPCTransformer, c as identityTransformer, i as decodeWire, n as createTaggedTransformer, o as encodeWire, r as dateWireCodec, s as getTransformer, t as DATE_CODEC_TAG } from "../transformer-
|
|
3
|
-
import { n as convexInfiniteQueryOptions, r as convexQuery, t as convexAction } from "../query-options-
|
|
1
|
+
import { a as isCRPCErrorCode, i as isCRPCError, n as defaultIsUnauthorized, r as isCRPCClientError, t as CRPCClientError } from "../error-Bvo7YEhk.js";
|
|
2
|
+
import { a as defaultCRPCTransformer, c as identityTransformer, i as decodeWire, n as createTaggedTransformer, o as encodeWire, r as dateWireCodec, s as getTransformer, t as DATE_CODEC_TAG } from "../transformer-C6pGVHqx.js";
|
|
3
|
+
import { n as convexInfiniteQueryOptions, r as convexQuery, t as convexAction } from "../query-options-C96zLANM.js";
|
|
4
4
|
|
|
5
5
|
//#region src/crpc/auth-error.ts
|
|
6
6
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as pick, r as omit } from "./upstream-BR6sBLg3.js";
|
|
2
|
+
import { t as addFieldsToValidator } from "./validators-C7LelqTN.js";
|
|
2
3
|
|
|
3
4
|
//#region src/internal/upstream/server/customFunctions.ts
|
|
4
5
|
/**
|
package/dist/{generated-contract-disabled-21YxPk5W.d.ts → generated-contract-disabled-C_-KWRfT.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as GetAuth } from "./types-
|
|
2
|
-
import { t as GenericCtx } from "./context-utils-
|
|
1
|
+
import { t as GetAuth } from "./types-BCl8gfGy.js";
|
|
2
|
+
import { t as GenericCtx } from "./context-utils-OMkMGhBk.js";
|
|
3
3
|
import * as convex_server0 from "convex/server";
|
|
4
4
|
import { DocumentByName, FunctionReference, GenericDataModel, GenericMutationCtx, GenericSchema, SchemaDefinition, TableNamesInDataModel, internalMutationGeneric } from "convex/server";
|
|
5
5
|
import * as better_auth_adapters0 from "better-auth/adapters";
|
|
@@ -218,6 +218,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
218
218
|
findMany: convex_server0.RegisteredQuery<"internal", {
|
|
219
219
|
join?: any;
|
|
220
220
|
where?: {
|
|
221
|
+
mode?: "sensitive" | "insensitive" | undefined;
|
|
221
222
|
connector?: "AND" | "OR" | undefined;
|
|
222
223
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
223
224
|
value: string | number | boolean | string[] | number[] | null;
|
|
@@ -243,6 +244,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
243
244
|
join?: any;
|
|
244
245
|
select?: string[] | undefined;
|
|
245
246
|
where?: {
|
|
247
|
+
mode?: "sensitive" | "insensitive" | undefined;
|
|
246
248
|
connector?: "AND" | "OR" | undefined;
|
|
247
249
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
248
250
|
value: string | number | boolean | string[] | number[] | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as Simplify } from "./types-
|
|
2
|
-
import { g as UnsetMarker, t as AnyMiddleware } from "./types-
|
|
1
|
+
import { o as Simplify } from "./types-DF2cg_w0.js";
|
|
2
|
+
import { g as UnsetMarker, t as AnyMiddleware } from "./types-CnTpHR1F.js";
|
|
3
3
|
import { GenericActionCtx, GenericDataModel, HttpRouter } from "convex/server";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Context, Hono } from "hono";
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-
|
|
2
|
-
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-
|
|
3
|
-
import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-
|
|
1
|
+
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-TMppDl9g.js";
|
|
2
|
+
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.js";
|
|
3
|
+
import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CNo9ffvI.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
|
|
5
5
|
|
|
6
6
|
//#region src/orm/index.d.ts
|