kitcn 0.13.0 → 0.13.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 +1 -1
- package/dist/{backend-core-CXmrWqdi.mjs → backend-core-B4DHUUfg.mjs} +158 -42
- package/dist/cli.mjs +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-TMppDl9g.d.ts → where-clause-compiler-DcEhkJ12.d.ts} +59 -59
- package/package.json +1 -1
- package/skills/convex/references/features/orm.md +9 -0
- package/dist/convex-plugin-tWTDqoKJ.mjs +0 -276
- package/dist/upstream-BUCdbLok.mjs +0 -26
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-
|
|
1
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-DcEhkJ12.js";
|
|
2
2
|
import * as convex_values0 from "convex/values";
|
|
3
3
|
import { GenericId, Infer, Value } from "convex/values";
|
|
4
4
|
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
|
@@ -5662,6 +5662,7 @@ const CONVEX_OUTPUT_NOISE_LINES = [
|
|
|
5662
5662
|
/^Changelog: https:\/\/github\.com\/get-convex\/convex-js\/blob\/main\/CHANGELOG\.md#changelog$/
|
|
5663
5663
|
];
|
|
5664
5664
|
const CONVEX_OUTPUT_LINE_SPLIT_RE = /\r?\n/;
|
|
5665
|
+
const REAL_CONVEX_CLI_PATH = join(dirname(createRequire(import.meta.url).resolve("convex/package.json")), "bin/main.js");
|
|
5665
5666
|
const CLEARED_CONVEX_ENV = {
|
|
5666
5667
|
CONVEX_DEPLOYMENT: void 0,
|
|
5667
5668
|
CONVEX_DEPLOY_KEY: void 0,
|
|
@@ -5683,16 +5684,15 @@ const formatConvexCommandFailure = (args, result) => {
|
|
|
5683
5684
|
return output.length > 0 ? `convex ${args.join(" ")} failed.\n${output}` : `convex ${args.join(" ")} failed.`;
|
|
5684
5685
|
};
|
|
5685
5686
|
const runLocalConvexCommand = async (args, options) => {
|
|
5686
|
-
return normalizeConvexCommandResult(await execa("
|
|
5687
|
+
return normalizeConvexCommandResult(await execa("node", [REAL_CONVEX_CLI_PATH, ...args], {
|
|
5687
5688
|
cwd: options.cwd,
|
|
5688
5689
|
env: {
|
|
5689
5690
|
...process.env,
|
|
5690
5691
|
...CLEARED_CONVEX_ENV,
|
|
5691
5692
|
...options.env
|
|
5692
5693
|
},
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
reject: false
|
|
5694
|
+
reject: false,
|
|
5695
|
+
stdio: "pipe"
|
|
5696
5696
|
}));
|
|
5697
5697
|
};
|
|
5698
5698
|
|
|
@@ -8610,6 +8610,136 @@ function QueryProvider({ children }: { children: ReactNode }) {
|
|
|
8610
8610
|
|
|
8611
8611
|
//#endregion
|
|
8612
8612
|
//#region src/cli/registry/items/auth/auth-schema.template.ts
|
|
8613
|
+
const DEFAULT_MANAGED_AUTH_EXTENSION_TEMPLATE = `// This file is auto-generated. Do not edit this file manually.
|
|
8614
|
+
// To regenerate the schema, run:
|
|
8615
|
+
// \`npx kitcn add auth --yes\`
|
|
8616
|
+
|
|
8617
|
+
import {
|
|
8618
|
+
boolean,
|
|
8619
|
+
convexTable,
|
|
8620
|
+
defineSchemaExtension,
|
|
8621
|
+
index,
|
|
8622
|
+
text,
|
|
8623
|
+
timestamp,
|
|
8624
|
+
} from "kitcn/orm";
|
|
8625
|
+
|
|
8626
|
+
export const userTable = convexTable(
|
|
8627
|
+
"user",
|
|
8628
|
+
{
|
|
8629
|
+
name: text().notNull(),
|
|
8630
|
+
email: text().notNull().unique(),
|
|
8631
|
+
emailVerified: boolean().notNull(),
|
|
8632
|
+
image: text(),
|
|
8633
|
+
createdAt: timestamp().notNull(),
|
|
8634
|
+
updatedAt: timestamp().notNull(),
|
|
8635
|
+
userId: text(),
|
|
8636
|
+
},
|
|
8637
|
+
(userTable) => [
|
|
8638
|
+
index("email_name").on(userTable.email, userTable.name),
|
|
8639
|
+
index("name").on(userTable.name),
|
|
8640
|
+
]
|
|
8641
|
+
);
|
|
8642
|
+
|
|
8643
|
+
export const sessionTable = convexTable(
|
|
8644
|
+
"session",
|
|
8645
|
+
{
|
|
8646
|
+
expiresAt: timestamp().notNull(),
|
|
8647
|
+
token: text().notNull().unique(),
|
|
8648
|
+
createdAt: timestamp().notNull(),
|
|
8649
|
+
updatedAt: timestamp().notNull(),
|
|
8650
|
+
ipAddress: text(),
|
|
8651
|
+
userAgent: text(),
|
|
8652
|
+
userId: text().notNull().references(() => userTable.id),
|
|
8653
|
+
},
|
|
8654
|
+
(sessionTable) => [
|
|
8655
|
+
index("expiresAt").on(sessionTable.expiresAt),
|
|
8656
|
+
index("expiresAt_userId").on(sessionTable.expiresAt, sessionTable.userId),
|
|
8657
|
+
index("userId").on(sessionTable.userId),
|
|
8658
|
+
]
|
|
8659
|
+
);
|
|
8660
|
+
|
|
8661
|
+
export const accountTable = convexTable(
|
|
8662
|
+
"account",
|
|
8663
|
+
{
|
|
8664
|
+
accountId: text().notNull(),
|
|
8665
|
+
providerId: text().notNull(),
|
|
8666
|
+
userId: text().notNull().references(() => userTable.id),
|
|
8667
|
+
accessToken: text(),
|
|
8668
|
+
refreshToken: text(),
|
|
8669
|
+
idToken: text(),
|
|
8670
|
+
accessTokenExpiresAt: timestamp(),
|
|
8671
|
+
refreshTokenExpiresAt: timestamp(),
|
|
8672
|
+
scope: text(),
|
|
8673
|
+
password: text(),
|
|
8674
|
+
createdAt: timestamp().notNull(),
|
|
8675
|
+
updatedAt: timestamp().notNull(),
|
|
8676
|
+
},
|
|
8677
|
+
(accountTable) => [
|
|
8678
|
+
index("accountId").on(accountTable.accountId),
|
|
8679
|
+
index("accountId_providerId").on(accountTable.accountId, accountTable.providerId),
|
|
8680
|
+
index("providerId_userId").on(accountTable.providerId, accountTable.userId),
|
|
8681
|
+
index("userId").on(accountTable.userId),
|
|
8682
|
+
]
|
|
8683
|
+
);
|
|
8684
|
+
|
|
8685
|
+
export const verificationTable = convexTable(
|
|
8686
|
+
"verification",
|
|
8687
|
+
{
|
|
8688
|
+
identifier: text().notNull(),
|
|
8689
|
+
value: text().notNull(),
|
|
8690
|
+
expiresAt: timestamp().notNull(),
|
|
8691
|
+
createdAt: timestamp().notNull(),
|
|
8692
|
+
updatedAt: timestamp().notNull(),
|
|
8693
|
+
},
|
|
8694
|
+
(verificationTable) => [
|
|
8695
|
+
index("expiresAt").on(verificationTable.expiresAt),
|
|
8696
|
+
index("identifier").on(verificationTable.identifier),
|
|
8697
|
+
]
|
|
8698
|
+
);
|
|
8699
|
+
|
|
8700
|
+
export const jwksTable = convexTable(
|
|
8701
|
+
"jwks",
|
|
8702
|
+
{
|
|
8703
|
+
publicKey: text().notNull(),
|
|
8704
|
+
privateKey: text().notNull(),
|
|
8705
|
+
createdAt: timestamp().notNull(),
|
|
8706
|
+
expiresAt: timestamp(),
|
|
8707
|
+
}
|
|
8708
|
+
);
|
|
8709
|
+
|
|
8710
|
+
export function authExtension() {
|
|
8711
|
+
return defineSchemaExtension("auth", {
|
|
8712
|
+
user: userTable,
|
|
8713
|
+
session: sessionTable,
|
|
8714
|
+
account: accountTable,
|
|
8715
|
+
verification: verificationTable,
|
|
8716
|
+
jwks: jwksTable,
|
|
8717
|
+
}).relations((r) => ({
|
|
8718
|
+
user: {
|
|
8719
|
+
sessions: r.many.session({
|
|
8720
|
+
from: r.user.id,
|
|
8721
|
+
to: r.session.userId,
|
|
8722
|
+
}),
|
|
8723
|
+
accounts: r.many.account({
|
|
8724
|
+
from: r.user.id,
|
|
8725
|
+
to: r.account.userId,
|
|
8726
|
+
}),
|
|
8727
|
+
},
|
|
8728
|
+
session: {
|
|
8729
|
+
user: r.one.user({
|
|
8730
|
+
from: r.session.userId,
|
|
8731
|
+
to: r.user.id,
|
|
8732
|
+
}),
|
|
8733
|
+
},
|
|
8734
|
+
account: {
|
|
8735
|
+
user: r.one.user({
|
|
8736
|
+
from: r.account.userId,
|
|
8737
|
+
to: r.user.id,
|
|
8738
|
+
}),
|
|
8739
|
+
},
|
|
8740
|
+
}));
|
|
8741
|
+
}
|
|
8742
|
+
`;
|
|
8613
8743
|
const AUTH_CONVEX_SCHEMA_TEMPLATE = `import { defineTable } from 'convex/server';
|
|
8614
8744
|
import { v } from 'convex/values';
|
|
8615
8745
|
|
|
@@ -8955,29 +9085,6 @@ export function runServerCall<T>(fn: (caller: ServerCaller) => Promise<T> | T) {
|
|
|
8955
9085
|
}
|
|
8956
9086
|
`;
|
|
8957
9087
|
|
|
8958
|
-
//#endregion
|
|
8959
|
-
//#region src/auth/auth-config.ts
|
|
8960
|
-
const createPublicJwks = (jwks, options) => {
|
|
8961
|
-
const keyPairConfig = options?.jwks?.keyPairConfig;
|
|
8962
|
-
const defaultCrv = keyPairConfig && "crv" in keyPairConfig ? keyPairConfig.crv : void 0;
|
|
8963
|
-
return { keys: jwks.map((keySet) => ({
|
|
8964
|
-
alg: keySet.alg ?? options?.jwks?.keyPairConfig?.alg ?? "EdDSA",
|
|
8965
|
-
crv: keySet.crv ?? defaultCrv,
|
|
8966
|
-
...JSON.parse(keySet.publicKey),
|
|
8967
|
-
kid: keySet.id
|
|
8968
|
-
})) };
|
|
8969
|
-
};
|
|
8970
|
-
const getAuthConfigProvider = (opts) => {
|
|
8971
|
-
const parsedJwks = opts?.jwks ? JSON.parse(opts.jwks) : void 0;
|
|
8972
|
-
return {
|
|
8973
|
-
type: "customJwt",
|
|
8974
|
-
issuer: `${process.env.CONVEX_SITE_URL}`,
|
|
8975
|
-
applicationID: "convex",
|
|
8976
|
-
algorithm: "RS256",
|
|
8977
|
-
jwks: parsedJwks ? `data:text/plain;charset=utf-8;base64,${btoa(JSON.stringify(createPublicJwks(parsedJwks)))}` : `${process.env.CONVEX_SITE_URL}${opts?.basePath ?? "/api/auth"}/convex/jwks`
|
|
8978
|
-
};
|
|
8979
|
-
};
|
|
8980
|
-
|
|
8981
9088
|
//#endregion
|
|
8982
9089
|
//#region src/auth/create-schema.ts
|
|
8983
9090
|
const indexFields = {
|
|
@@ -9397,7 +9504,6 @@ const DEFAULT_AUTH_SCHEMA_ENV = {
|
|
|
9397
9504
|
SITE_URL: "http://localhost:3000"
|
|
9398
9505
|
};
|
|
9399
9506
|
const loadGetAuthTables = async () => (await import("better-auth/db")).getAuthTables;
|
|
9400
|
-
const loadConvexAuthPlugin = async () => (await import("./convex-plugin-tWTDqoKJ.mjs")).convex;
|
|
9401
9507
|
const ts$1 = createTypeScriptProxy();
|
|
9402
9508
|
const withAuthSchemaEnv = async (run) => {
|
|
9403
9509
|
const globalScope = globalThis;
|
|
@@ -9493,16 +9599,11 @@ const renderManagedAuthSchemaUnits = async ({ authOptions }) => parseRootSchemaU
|
|
|
9493
9599
|
kind: "extension",
|
|
9494
9600
|
outputPath: "convex/lib/plugins/auth/schema.ts"
|
|
9495
9601
|
}));
|
|
9496
|
-
const
|
|
9497
|
-
const
|
|
9498
|
-
const
|
|
9499
|
-
|
|
9500
|
-
return
|
|
9501
|
-
baseURL: process.env.SITE_URL,
|
|
9502
|
-
emailAndPassword: { enabled: true },
|
|
9503
|
-
plugins: [convex({ authConfig: { providers: [provider] } })],
|
|
9504
|
-
trustedOrigins: [process.env.SITE_URL]
|
|
9505
|
-
}));
|
|
9602
|
+
const renderDefaultManagedAuthSchemaUnits = () => parseRootSchemaUnitsFromExtension(DEFAULT_MANAGED_AUTH_EXTENSION_TEMPLATE);
|
|
9603
|
+
const resolveManagedAuthSchemaUnits = async ({ authDefinitionPath, loadAuthOptions = loadAuthOptionsFromDefinition, renderManagedUnits = renderManagedAuthSchemaUnits }) => {
|
|
9604
|
+
const authOptions = await loadAuthOptions(authDefinitionPath);
|
|
9605
|
+
if (!authOptions) return renderDefaultManagedAuthSchemaUnits();
|
|
9606
|
+
return renderManagedUnits({ authOptions });
|
|
9506
9607
|
};
|
|
9507
9608
|
const loadAuthOptionsFromDefinition = async (authDefinitionPath) => {
|
|
9508
9609
|
if (!fs.existsSync(authDefinitionPath)) return null;
|
|
@@ -9652,7 +9753,7 @@ async function buildAuthSchemaRegistrationPlanFile(params) {
|
|
|
9652
9753
|
if (params.preset === "convex") return buildAuthConvexSchemaPlanFile(params);
|
|
9653
9754
|
const schemaPath = getSchemaFilePath(params.functionsDir);
|
|
9654
9755
|
const source = fs.readFileSync(schemaPath, "utf8");
|
|
9655
|
-
const
|
|
9756
|
+
const authDefinitionPath = resolve(params.functionsDir, "auth.ts");
|
|
9656
9757
|
const authSchemaLock = params.lockfile.plugins.auth?.schema ?? null;
|
|
9657
9758
|
const result = await reconcileRootSchemaOwnership({
|
|
9658
9759
|
claimMatchingManaged: params.applyScope === "schema" && authSchemaLock === null,
|
|
@@ -9664,7 +9765,10 @@ async function buildAuthSchemaRegistrationPlanFile(params) {
|
|
|
9664
9765
|
promptAdapter: params.promptAdapter,
|
|
9665
9766
|
schemaPath,
|
|
9666
9767
|
source,
|
|
9667
|
-
tables: await
|
|
9768
|
+
tables: await resolveManagedAuthSchemaUnits({
|
|
9769
|
+
authDefinitionPath,
|
|
9770
|
+
loadAuthOptions: loadAuthOptionsFromDefinition
|
|
9771
|
+
}),
|
|
9668
9772
|
yes: params.yes
|
|
9669
9773
|
});
|
|
9670
9774
|
return {
|
|
@@ -12562,7 +12666,7 @@ const TS_EXTENSION_RE = /\.ts$/;
|
|
|
12562
12666
|
const LEADING_SLASHES_RE = /^\/+/;
|
|
12563
12667
|
const AGGREGATE_STATE_RELATIVE_PATH = join(".convex", "kitcn", "aggregate-backfill-state.json");
|
|
12564
12668
|
const AGGREGATE_STATE_VERSION = 1;
|
|
12565
|
-
const INIT_SHADCN_PACKAGE_SPEC = "shadcn@4.0
|
|
12669
|
+
const INIT_SHADCN_PACKAGE_SPEC = "shadcn@4.3.0";
|
|
12566
12670
|
const INIT_LOCAL_BOOTSTRAP_TIMEOUT_MS = 3e4;
|
|
12567
12671
|
const LOCAL_BACKEND_NOT_RUNNING_RE = /Local backend isn't running/i;
|
|
12568
12672
|
const INIT_GENERATED_SERVER_STUB_TEMPLATE = `// @ts-nocheck
|
|
@@ -12992,8 +13096,15 @@ async function createProjectWithShadcn(params) {
|
|
|
12992
13096
|
});
|
|
12993
13097
|
}
|
|
12994
13098
|
}
|
|
13099
|
+
function buildMissingShadcnScaffoldMessage(projectDir) {
|
|
13100
|
+
return [
|
|
13101
|
+
"Shadcn exited without creating a supported local scaffold.",
|
|
13102
|
+
"This usually means you chose the Custom preset.",
|
|
13103
|
+
`Run the generated shadcn command from ui.shadcn.com in ${normalizePath(relative(process.cwd(), projectDir) || ".")} then re-run \`kitcn init --yes\` to adopt it.`
|
|
13104
|
+
].join(" ");
|
|
13105
|
+
}
|
|
12995
13106
|
function moveStagedProjectIntoExistingDir(params) {
|
|
12996
|
-
if (!fs.existsSync(params.stagedProjectDir)) throw new Error(
|
|
13107
|
+
if (!fs.existsSync(params.stagedProjectDir)) throw new Error(buildMissingShadcnScaffoldMessage(params.targetDir));
|
|
12997
13108
|
if (!fs.existsSync(params.targetDir) || fs.readdirSync(params.targetDir).length > 0) throw new Error(`Cannot move staged project into non-empty target ${params.targetDir}.`);
|
|
12998
13109
|
for (const entry of fs.readdirSync(params.stagedProjectDir)) fs.renameSync(join(params.stagedProjectDir, entry), join(params.targetDir, entry));
|
|
12999
13110
|
}
|
|
@@ -13928,6 +14039,11 @@ async function runScaffoldCommandFlow(params) {
|
|
|
13928
14039
|
execaFn: params.execaFn
|
|
13929
14040
|
});
|
|
13930
14041
|
const scaffoldProjectDir = resolveShadcnScaffoldProjectDir(params.projectDir, params.template);
|
|
14042
|
+
if (params.template && !resolveProjectScaffoldContext({
|
|
14043
|
+
cwd: scaffoldProjectDir,
|
|
14044
|
+
allowMissing: true,
|
|
14045
|
+
allowUnsupported: true
|
|
14046
|
+
})) throw new Error(buildMissingShadcnScaffoldMessage(scaffoldProjectDir));
|
|
13931
14047
|
return withWorkingDirectory(scaffoldProjectDir, async () => {
|
|
13932
14048
|
const config = params.loadCliConfigFn(params.configPath);
|
|
13933
14049
|
const backend = resolveConfiguredBackend({
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as promptForScaffoldTemplateSelection, A as resolveCodegenTrimSegments, B as runConfiguredCodegen, C as isEntryPoint, Ct as serializeEnvValue, D as parseInitCommandArgs, Dt as logger, E as parseBackendRunJson, F as resolveRunDeps, G as runMigrationFlow, H as runDevSchemaBackfillIfNeeded, I as runAfterScaffoldScript, J as withWorkingDirectory, K as trackProcess, L as runAggregateBackfillFlow, M as resolveDocTopic, N as resolveInitProjectDir, O as readPackageVersions, Ot as highlighter, P as resolveMigrationConfig, Q as promptForPluginSelection, R as runAggregatePruneFlow, S as isConvexDevPreRunConflictFlag, St as resolveAuthEnvState, T as parseArgs, U as runInitCommandFlow, V as runConvexInitIfNeeded, W as runMigrationCreate, X as collectPluginScaffoldTemplates, Y as createSpinner, Z as filterScaffoldTemplatePathMap, _ as formatInfoOutput, _t as applyPlanningDependencyInstall, a as cleanup, at as getPluginCatalogEntry, b as getDevAggregateBackfillStatePath, bt as resolveSupportedDependencyWarnings, c as createCommandEnv, ct as buildPluginInstallPlan, d as extractBackfillCliOptions, dt as collectInstalledPluginKeys, et as resolveAddTemplateDefaults, f as extractConcaveRunTargetArgs, ft as getPluginLockfilePath, g as formatDocsOutput, gt as applyDependencyHintsInstall, h as extractResetCliOptions, ht as resolveSchemaInstalledPlugins, i as buildInitializationPlan, it as resolveTemplatesByIdOrThrow, j as resolveConfiguredBackend, k as resolveBackfillConfig, l as ensureConvexGitignoreEntry, lt as resolvePluginScaffoldRoots, m as extractMigrationDownOptions, mt as readPluginLockfile, n as applyPluginInstallPlanFiles, nt as resolvePresetScaffoldTemplates, o as createBackendAdapter, ot as getSupportedPluginKeys, p as extractMigrationCliOptions, pt as getSchemaFilePath, q as withLocalCodegenEnv, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplateSelectionSource, s as createBackendCommandEnv, st as isSupportedPluginKey, t as applyDependencyInstallPlan, tt as resolvePluginPreset, u as extractBackendRunTargetArgs, ut as assertSchemaFileExists, v as getAggregateBackfillDeploymentKey, vt as applyPluginDependencyInstall, w as isInitialized, wt as stripConvexCommandNoise, x as hasRemoteConvexDeploymentEnv, xt as resolveProjectScaffoldContext, y as getConvexDeploymentCommandEnv, yt as inspectPluginDependencyInstall, z as runBackendFunction } from "./backend-core-
|
|
2
|
+
import { $ as promptForScaffoldTemplateSelection, A as resolveCodegenTrimSegments, B as runConfiguredCodegen, C as isEntryPoint, Ct as serializeEnvValue, D as parseInitCommandArgs, Dt as logger, E as parseBackendRunJson, F as resolveRunDeps, G as runMigrationFlow, H as runDevSchemaBackfillIfNeeded, I as runAfterScaffoldScript, J as withWorkingDirectory, K as trackProcess, L as runAggregateBackfillFlow, M as resolveDocTopic, N as resolveInitProjectDir, O as readPackageVersions, Ot as highlighter, P as resolveMigrationConfig, Q as promptForPluginSelection, R as runAggregatePruneFlow, S as isConvexDevPreRunConflictFlag, St as resolveAuthEnvState, T as parseArgs, U as runInitCommandFlow, V as runConvexInitIfNeeded, W as runMigrationCreate, X as collectPluginScaffoldTemplates, Y as createSpinner, Z as filterScaffoldTemplatePathMap, _ as formatInfoOutput, _t as applyPlanningDependencyInstall, a as cleanup, at as getPluginCatalogEntry, b as getDevAggregateBackfillStatePath, bt as resolveSupportedDependencyWarnings, c as createCommandEnv, ct as buildPluginInstallPlan, d as extractBackfillCliOptions, dt as collectInstalledPluginKeys, et as resolveAddTemplateDefaults, f as extractConcaveRunTargetArgs, ft as getPluginLockfilePath, g as formatDocsOutput, gt as applyDependencyHintsInstall, h as extractResetCliOptions, ht as resolveSchemaInstalledPlugins, i as buildInitializationPlan, it as resolveTemplatesByIdOrThrow, j as resolveConfiguredBackend, k as resolveBackfillConfig, l as ensureConvexGitignoreEntry, lt as resolvePluginScaffoldRoots, m as extractMigrationDownOptions, mt as readPluginLockfile, n as applyPluginInstallPlanFiles, nt as resolvePresetScaffoldTemplates, o as createBackendAdapter, ot as getSupportedPluginKeys, p as extractMigrationCliOptions, pt as getSchemaFilePath, q as withLocalCodegenEnv, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplateSelectionSource, s as createBackendCommandEnv, st as isSupportedPluginKey, t as applyDependencyInstallPlan, tt as resolvePluginPreset, u as extractBackendRunTargetArgs, ut as assertSchemaFileExists, v as getAggregateBackfillDeploymentKey, vt as applyPluginDependencyInstall, w as isInitialized, wt as stripConvexCommandNoise, x as hasRemoteConvexDeploymentEnv, xt as resolveProjectScaffoldContext, y as getConvexDeploymentCommandEnv, yt as inspectPluginDependencyInstall, z as runBackendFunction } from "./backend-core-B4DHUUfg.mjs";
|
|
3
3
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import path, { delimiter, dirname, join, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-DcEhkJ12.js";
|
|
2
2
|
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.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-CNo9ffvI.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
|
package/dist/watcher.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Dt as logger, Et as getConvexConfig, F as resolveRunDeps, Tt as generateMeta, j as resolveConfiguredBackend, q as withLocalCodegenEnv } from "./backend-core-
|
|
2
|
+
import { Dt as logger, Et as getConvexConfig, F as resolveRunDeps, Tt as generateMeta, j as resolveConfiguredBackend, q as withLocalCodegenEnv } from "./backend-core-B4DHUUfg.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
@@ -3717,7 +3717,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3717
3717
|
readonly aggregate_bucket: ConvexTableWithColumns<{
|
|
3718
3718
|
name: "aggregate_bucket";
|
|
3719
3719
|
columns: {
|
|
3720
|
-
|
|
3720
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
3721
3721
|
_: {
|
|
3722
3722
|
notNull: true;
|
|
3723
3723
|
};
|
|
@@ -3727,10 +3727,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3727
3727
|
};
|
|
3728
3728
|
} & {
|
|
3729
3729
|
_: {
|
|
3730
|
-
fieldName: "
|
|
3730
|
+
fieldName: "count";
|
|
3731
3731
|
};
|
|
3732
3732
|
};
|
|
3733
|
-
|
|
3733
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
3734
3734
|
_: {
|
|
3735
3735
|
notNull: true;
|
|
3736
3736
|
};
|
|
@@ -3740,10 +3740,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3740
3740
|
};
|
|
3741
3741
|
} & {
|
|
3742
3742
|
_: {
|
|
3743
|
-
fieldName: "
|
|
3743
|
+
fieldName: "updatedAt";
|
|
3744
3744
|
};
|
|
3745
3745
|
};
|
|
3746
|
-
|
|
3746
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
3747
3747
|
_: {
|
|
3748
3748
|
notNull: true;
|
|
3749
3749
|
};
|
|
@@ -3753,10 +3753,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3753
3753
|
};
|
|
3754
3754
|
} & {
|
|
3755
3755
|
_: {
|
|
3756
|
-
fieldName: "
|
|
3756
|
+
fieldName: "tableKey";
|
|
3757
3757
|
};
|
|
3758
3758
|
};
|
|
3759
|
-
|
|
3759
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
3760
3760
|
_: {
|
|
3761
3761
|
notNull: true;
|
|
3762
3762
|
};
|
|
@@ -3766,14 +3766,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3766
3766
|
};
|
|
3767
3767
|
} & {
|
|
3768
3768
|
_: {
|
|
3769
|
-
fieldName: "
|
|
3769
|
+
fieldName: "indexName";
|
|
3770
3770
|
};
|
|
3771
3771
|
};
|
|
3772
|
-
|
|
3773
|
-
_: {
|
|
3774
|
-
$type: convex_values0.Value[];
|
|
3775
|
-
};
|
|
3776
|
-
} & {
|
|
3772
|
+
keyHash: ConvexTextBuilderInitial<""> & {
|
|
3777
3773
|
_: {
|
|
3778
3774
|
notNull: true;
|
|
3779
3775
|
};
|
|
@@ -3783,10 +3779,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3783
3779
|
};
|
|
3784
3780
|
} & {
|
|
3785
3781
|
_: {
|
|
3786
|
-
fieldName: "
|
|
3782
|
+
fieldName: "keyHash";
|
|
3787
3783
|
};
|
|
3788
3784
|
};
|
|
3789
|
-
|
|
3785
|
+
keyParts: ConvexCustomBuilderInitial<"", convex_values0.VArray<any[], convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>, "required">> & {
|
|
3786
|
+
_: {
|
|
3787
|
+
$type: convex_values0.Value[];
|
|
3788
|
+
};
|
|
3789
|
+
} & {
|
|
3790
3790
|
_: {
|
|
3791
3791
|
notNull: true;
|
|
3792
3792
|
};
|
|
@@ -3796,7 +3796,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3796
3796
|
};
|
|
3797
3797
|
} & {
|
|
3798
3798
|
_: {
|
|
3799
|
-
fieldName: "
|
|
3799
|
+
fieldName: "keyParts";
|
|
3800
3800
|
};
|
|
3801
3801
|
};
|
|
3802
3802
|
sumValues: (NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VRecord<Record<string, any>, convex_values0.VString<string, "required">, convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>, "required", string>>, Record<string, number>>> | NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>>, Record<string, number>>>) & {
|
|
@@ -3839,7 +3839,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3839
3839
|
fieldName: "kind";
|
|
3840
3840
|
};
|
|
3841
3841
|
};
|
|
3842
|
-
|
|
3842
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
3843
3843
|
_: {
|
|
3844
3844
|
notNull: true;
|
|
3845
3845
|
};
|
|
@@ -3849,10 +3849,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3849
3849
|
};
|
|
3850
3850
|
} & {
|
|
3851
3851
|
_: {
|
|
3852
|
-
fieldName: "
|
|
3852
|
+
fieldName: "updatedAt";
|
|
3853
3853
|
};
|
|
3854
3854
|
};
|
|
3855
|
-
|
|
3855
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
3856
3856
|
_: {
|
|
3857
3857
|
notNull: true;
|
|
3858
3858
|
};
|
|
@@ -3862,10 +3862,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3862
3862
|
};
|
|
3863
3863
|
} & {
|
|
3864
3864
|
_: {
|
|
3865
|
-
fieldName: "
|
|
3865
|
+
fieldName: "tableKey";
|
|
3866
3866
|
};
|
|
3867
3867
|
};
|
|
3868
|
-
|
|
3868
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
3869
3869
|
_: {
|
|
3870
3870
|
notNull: true;
|
|
3871
3871
|
};
|
|
@@ -3875,7 +3875,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3875
3875
|
};
|
|
3876
3876
|
} & {
|
|
3877
3877
|
_: {
|
|
3878
|
-
fieldName: "
|
|
3878
|
+
fieldName: "indexName";
|
|
3879
3879
|
};
|
|
3880
3880
|
};
|
|
3881
3881
|
keyHash: ConvexTextBuilderInitial<""> & {
|
|
@@ -4009,7 +4009,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4009
4009
|
fieldName: "value";
|
|
4010
4010
|
};
|
|
4011
4011
|
};
|
|
4012
|
-
|
|
4012
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
4013
4013
|
_: {
|
|
4014
4014
|
notNull: true;
|
|
4015
4015
|
};
|
|
@@ -4019,10 +4019,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4019
4019
|
};
|
|
4020
4020
|
} & {
|
|
4021
4021
|
_: {
|
|
4022
|
-
fieldName: "
|
|
4022
|
+
fieldName: "count";
|
|
4023
4023
|
};
|
|
4024
4024
|
};
|
|
4025
|
-
|
|
4025
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
4026
4026
|
_: {
|
|
4027
4027
|
notNull: true;
|
|
4028
4028
|
};
|
|
@@ -4032,10 +4032,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4032
4032
|
};
|
|
4033
4033
|
} & {
|
|
4034
4034
|
_: {
|
|
4035
|
-
fieldName: "
|
|
4035
|
+
fieldName: "updatedAt";
|
|
4036
4036
|
};
|
|
4037
4037
|
};
|
|
4038
|
-
|
|
4038
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
4039
4039
|
_: {
|
|
4040
4040
|
notNull: true;
|
|
4041
4041
|
};
|
|
@@ -4045,10 +4045,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4045
4045
|
};
|
|
4046
4046
|
} & {
|
|
4047
4047
|
_: {
|
|
4048
|
-
fieldName: "
|
|
4048
|
+
fieldName: "tableKey";
|
|
4049
4049
|
};
|
|
4050
4050
|
};
|
|
4051
|
-
|
|
4051
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
4052
4052
|
_: {
|
|
4053
4053
|
notNull: true;
|
|
4054
4054
|
};
|
|
@@ -4058,10 +4058,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4058
4058
|
};
|
|
4059
4059
|
} & {
|
|
4060
4060
|
_: {
|
|
4061
|
-
fieldName: "
|
|
4061
|
+
fieldName: "indexName";
|
|
4062
4062
|
};
|
|
4063
4063
|
};
|
|
4064
|
-
|
|
4064
|
+
keyHash: ConvexTextBuilderInitial<""> & {
|
|
4065
4065
|
_: {
|
|
4066
4066
|
notNull: true;
|
|
4067
4067
|
};
|
|
@@ -4071,7 +4071,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4071
4071
|
};
|
|
4072
4072
|
} & {
|
|
4073
4073
|
_: {
|
|
4074
|
-
fieldName: "
|
|
4074
|
+
fieldName: "keyHash";
|
|
4075
4075
|
};
|
|
4076
4076
|
};
|
|
4077
4077
|
fieldName: ConvexTextBuilderInitial<""> & {
|
|
@@ -4279,6 +4279,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4279
4279
|
fieldName: "cursor";
|
|
4280
4280
|
};
|
|
4281
4281
|
};
|
|
4282
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
4283
|
+
_: {
|
|
4284
|
+
notNull: true;
|
|
4285
|
+
};
|
|
4286
|
+
} & {
|
|
4287
|
+
_: {
|
|
4288
|
+
tableName: "aggregate_state";
|
|
4289
|
+
};
|
|
4290
|
+
} & {
|
|
4291
|
+
_: {
|
|
4292
|
+
fieldName: "updatedAt";
|
|
4293
|
+
};
|
|
4294
|
+
};
|
|
4282
4295
|
tableKey: ConvexTextBuilderInitial<""> & {
|
|
4283
4296
|
_: {
|
|
4284
4297
|
notNull: true;
|
|
@@ -4357,19 +4370,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4357
4370
|
fieldName: "startedAt";
|
|
4358
4371
|
};
|
|
4359
4372
|
};
|
|
4360
|
-
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
4361
|
-
_: {
|
|
4362
|
-
notNull: true;
|
|
4363
|
-
};
|
|
4364
|
-
} & {
|
|
4365
|
-
_: {
|
|
4366
|
-
tableName: "aggregate_state";
|
|
4367
|
-
};
|
|
4368
|
-
} & {
|
|
4369
|
-
_: {
|
|
4370
|
-
fieldName: "updatedAt";
|
|
4371
|
-
};
|
|
4372
|
-
};
|
|
4373
4373
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
|
4374
4374
|
_: {
|
|
4375
4375
|
tableName: "aggregate_state";
|
|
@@ -4429,7 +4429,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4429
4429
|
fieldName: "direction";
|
|
4430
4430
|
};
|
|
4431
4431
|
};
|
|
4432
|
-
|
|
4432
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
4433
4433
|
_: {
|
|
4434
4434
|
notNull: true;
|
|
4435
4435
|
};
|
|
@@ -4439,29 +4439,29 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4439
4439
|
};
|
|
4440
4440
|
} & {
|
|
4441
4441
|
_: {
|
|
4442
|
-
fieldName: "
|
|
4442
|
+
fieldName: "updatedAt";
|
|
4443
4443
|
};
|
|
4444
4444
|
};
|
|
4445
|
-
|
|
4445
|
+
processed: ConvexNumberBuilderInitial<""> & {
|
|
4446
4446
|
_: {
|
|
4447
|
-
|
|
4447
|
+
notNull: true;
|
|
4448
4448
|
};
|
|
4449
4449
|
} & {
|
|
4450
4450
|
_: {
|
|
4451
|
-
|
|
4451
|
+
tableName: "migration_state";
|
|
4452
4452
|
};
|
|
4453
|
-
}
|
|
4454
|
-
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
4453
|
+
} & {
|
|
4455
4454
|
_: {
|
|
4456
|
-
|
|
4455
|
+
fieldName: "processed";
|
|
4457
4456
|
};
|
|
4458
|
-
}
|
|
4457
|
+
};
|
|
4458
|
+
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
4459
4459
|
_: {
|
|
4460
4460
|
tableName: "migration_state";
|
|
4461
4461
|
};
|
|
4462
4462
|
} & {
|
|
4463
4463
|
_: {
|
|
4464
|
-
fieldName: "
|
|
4464
|
+
fieldName: "startedAt";
|
|
4465
4465
|
};
|
|
4466
4466
|
};
|
|
4467
4467
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
|
@@ -4578,7 +4578,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4578
4578
|
fieldName: "direction";
|
|
4579
4579
|
};
|
|
4580
4580
|
};
|
|
4581
|
-
|
|
4581
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
4582
4582
|
_: {
|
|
4583
4583
|
notNull: true;
|
|
4584
4584
|
};
|
|
@@ -4588,10 +4588,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4588
4588
|
};
|
|
4589
4589
|
} & {
|
|
4590
4590
|
_: {
|
|
4591
|
-
fieldName: "
|
|
4591
|
+
fieldName: "updatedAt";
|
|
4592
4592
|
};
|
|
4593
4593
|
};
|
|
4594
|
-
|
|
4594
|
+
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
4595
4595
|
_: {
|
|
4596
4596
|
notNull: true;
|
|
4597
4597
|
};
|
|
@@ -4601,7 +4601,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4601
4601
|
};
|
|
4602
4602
|
} & {
|
|
4603
4603
|
_: {
|
|
4604
|
-
fieldName: "
|
|
4604
|
+
fieldName: "startedAt";
|
|
4605
4605
|
};
|
|
4606
4606
|
};
|
|
4607
4607
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
package/package.json
CHANGED
|
@@ -75,6 +75,15 @@ parentId: text().references((): AnyColumn => commentsTable.id, {
|
|
|
75
75
|
onDelete: "cascade",
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
+
// Bidirectional CMS revision pointers also work.
|
|
79
|
+
// This shape is valid:
|
|
80
|
+
// - revision.pageLocaleId -> pageLocales.id
|
|
81
|
+
// - pageLocales.currentRevisionId -> pageLocaleRevisions.id
|
|
82
|
+
// - pageLocales.publishedRevisionId -> pageLocaleRevisions.id
|
|
83
|
+
currentRevisionId: id("pageLocaleRevisions").references(
|
|
84
|
+
() => pageLocaleRevisions.id
|
|
85
|
+
);
|
|
86
|
+
|
|
78
87
|
// Table-level (foreignKey builder, for non-id references)
|
|
79
88
|
import { foreignKey } from "kitcn/orm";
|
|
80
89
|
(t) => [foreignKey({ columns: [t.userSlug], foreignColumns: [users.slug] })];
|
|
@@ -1,276 +0,0 @@
|
|
|
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,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
//#region src/internal/upstream/index.ts
|
|
3
|
-
/**
|
|
4
|
-
* omit helps you omit keys from an object more concisely.
|
|
5
|
-
*
|
|
6
|
-
* e.g. `omit({a: v.string(), b: v.number()}, ["a"])` is equivalent to
|
|
7
|
-
* `{b: v.number()}`
|
|
8
|
-
*
|
|
9
|
-
* The alternative could be something like:
|
|
10
|
-
* ```js
|
|
11
|
-
* const obj = { a: v.string(), b: v.number() };
|
|
12
|
-
* // omit does the following
|
|
13
|
-
* const { a, ...rest } = obj;
|
|
14
|
-
* const withoutA = rest;
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @param obj The object to return a copy of without the specified keys.
|
|
18
|
-
* @param keys The keys to omit from the object.
|
|
19
|
-
* @returns A new object with the keys you omitted removed.
|
|
20
|
-
*/
|
|
21
|
-
function omit(obj, keys) {
|
|
22
|
-
return Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k)));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { omit as t };
|