kitcn 0.15.0 → 0.15.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/auth/nextjs/index.d.ts +1 -1
- package/dist/auth/start/index.d.ts +27 -1
- package/dist/auth/start/index.js +27 -1
- package/dist/{backend-core-B091CyHN.mjs → backend-core-BYs_6mO4.mjs} +118 -7
- package/dist/cli.mjs +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/{procedure-caller-DplSC7Us.js → procedure-caller-9m6NBxQu.js} +27 -5
- package/dist/{procedure-name-BCRBr6Po.d.ts → procedure-name-Cy1AxayA.d.ts} +2 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +1 -1
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-DcEhkJ12.d.ts → where-clause-compiler-DLiYI2EF.d.ts} +8 -8
- package/package.json +1 -1
- package/skills/kitcn/references/setup/start.md +34 -0
|
@@ -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-DLiYI2EF.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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as ConvexContext, W as LazyCaller } from "../../procedure-name-Cy1AxayA.js";
|
|
2
2
|
import { t as GetTokenOptions } from "../../token-B9Bjcqug.js";
|
|
3
3
|
|
|
4
4
|
//#region src/auth-nextjs/index.d.ts
|
|
@@ -2,10 +2,36 @@ import { t as GetTokenOptions } from "../../token-B9Bjcqug.js";
|
|
|
2
2
|
import { FunctionReference, FunctionReturnType, OptionalRestArgs } from "convex/server";
|
|
3
3
|
|
|
4
4
|
//#region src/auth-start/index.d.ts
|
|
5
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
6
|
+
type StartLoaderAuthClient = {
|
|
7
|
+
clearAuth: () => void;
|
|
8
|
+
setAuth: (fetchToken: () => Promise<string | null>) => void;
|
|
9
|
+
};
|
|
10
|
+
type StartLoaderServerHttpClient = {
|
|
11
|
+
clearAuth?: () => void;
|
|
12
|
+
setAuth: (token: string) => void;
|
|
13
|
+
};
|
|
14
|
+
type StartLoaderConvexQueryClient = {
|
|
15
|
+
convexClient: StartLoaderAuthClient;
|
|
16
|
+
serverHttpClient?: StartLoaderServerHttpClient;
|
|
17
|
+
};
|
|
18
|
+
type StartLoaderAuthTarget = StartLoaderAuthClient | StartLoaderConvexQueryClient;
|
|
19
|
+
type SyncConvexAuthForStartLoaderOptions = {
|
|
20
|
+
convex: StartLoaderAuthTarget;
|
|
21
|
+
getToken: () => MaybePromise<null | string | undefined>;
|
|
22
|
+
};
|
|
23
|
+
type StartLoaderAuthState = {
|
|
24
|
+
isAuthenticated: boolean;
|
|
25
|
+
token: null | string;
|
|
26
|
+
};
|
|
5
27
|
type ConvexBetterAuthReactStartOptions = Omit<GetTokenOptions, 'forceRefresh'> & {
|
|
6
28
|
convexSiteUrl: string;
|
|
7
29
|
convexUrl: string;
|
|
8
30
|
};
|
|
31
|
+
declare const syncConvexAuthForStartLoader: ({
|
|
32
|
+
convex,
|
|
33
|
+
getToken
|
|
34
|
+
}: SyncConvexAuthForStartLoaderOptions) => Promise<StartLoaderAuthState>;
|
|
9
35
|
declare const convexBetterAuthReactStart: (opts: ConvexBetterAuthReactStartOptions) => {
|
|
10
36
|
getToken: () => Promise<string | undefined>;
|
|
11
37
|
handler: (request: Request) => Promise<Response>;
|
|
@@ -14,4 +40,4 @@ declare const convexBetterAuthReactStart: (opts: ConvexBetterAuthReactStartOptio
|
|
|
14
40
|
fetchAuthAction: <Action extends FunctionReference<"action">>(action: Action, ...args: OptionalRestArgs<Action>) => Promise<FunctionReturnType<Action>>;
|
|
15
41
|
};
|
|
16
42
|
//#endregion
|
|
17
|
-
export { convexBetterAuthReactStart };
|
|
43
|
+
export { MaybePromise, StartLoaderAuthClient, StartLoaderAuthState, StartLoaderAuthTarget, StartLoaderConvexQueryClient, StartLoaderServerHttpClient, SyncConvexAuthForStartLoaderOptions, convexBetterAuthReactStart, syncConvexAuthForStartLoader };
|
package/dist/auth/start/index.js
CHANGED
|
@@ -8,6 +8,32 @@ const fallbackCache = (fn) => fn;
|
|
|
8
8
|
const cache = React.cache ?? fallbackCache;
|
|
9
9
|
const TANSTACK_REACT_START_SERVER = "@tanstack/react-start/server";
|
|
10
10
|
const TRAILING_COLON_RE = /:$/;
|
|
11
|
+
const startLoaderAuthTokens = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
const isStartLoaderConvexQueryClient = (target) => "convexClient" in target;
|
|
13
|
+
const syncConvexAuthForStartLoader = async ({ convex, getToken }) => {
|
|
14
|
+
const authClient = isStartLoaderConvexQueryClient(convex) ? convex.convexClient : convex;
|
|
15
|
+
const serverHttpClient = isStartLoaderConvexQueryClient(convex) ? convex.serverHttpClient : void 0;
|
|
16
|
+
const token = await getToken() ?? null;
|
|
17
|
+
if (startLoaderAuthTokens.get(convex) === token) return {
|
|
18
|
+
isAuthenticated: token !== null,
|
|
19
|
+
token
|
|
20
|
+
};
|
|
21
|
+
startLoaderAuthTokens.set(convex, token);
|
|
22
|
+
if (token === null) {
|
|
23
|
+
authClient.clearAuth();
|
|
24
|
+
serverHttpClient?.clearAuth?.();
|
|
25
|
+
return {
|
|
26
|
+
isAuthenticated: false,
|
|
27
|
+
token
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
authClient.setAuth(async () => token);
|
|
31
|
+
serverHttpClient?.setAuth(token);
|
|
32
|
+
return {
|
|
33
|
+
isAuthenticated: true,
|
|
34
|
+
token
|
|
35
|
+
};
|
|
36
|
+
};
|
|
11
37
|
function setupClient(options) {
|
|
12
38
|
const client = new ConvexHttpClient(options.convexUrl);
|
|
13
39
|
if (options.token !== void 0) client.setAuth(options.token);
|
|
@@ -124,4 +150,4 @@ const convexBetterAuthReactStart = (opts) => {
|
|
|
124
150
|
};
|
|
125
151
|
|
|
126
152
|
//#endregion
|
|
127
|
-
export { convexBetterAuthReactStart };
|
|
153
|
+
export { convexBetterAuthReactStart, syncConvexAuthForStartLoader };
|
|
@@ -7063,7 +7063,69 @@ const BASE_ENV_FIELDS = [{
|
|
|
7063
7063
|
schema: "z.string().default('http://localhost:3000')"
|
|
7064
7064
|
}];
|
|
7065
7065
|
const ENV_SCHEMA_RE = /(const\s+\w+\s*=\s*z\.object\(\{\n)([\s\S]*?)(\n\}\);)/m;
|
|
7066
|
+
const CREATE_ENV_OPTIONS_START_RE = /createEnv\s*\(\s*\{/m;
|
|
7067
|
+
const READ_OPTIONAL_RUNTIME_ENV_PROPERTY_RE = /\breadOptionalRuntimeEnv\s*:/m;
|
|
7068
|
+
const READ_OPTIONAL_RUNTIME_ENV_RE = /(\s*readOptionalRuntimeEnv\s*:\s*\[)([\s\S]*?)(\]\s*,?)/m;
|
|
7069
|
+
const LEADING_WHITESPACE_RE = /^\s*/;
|
|
7070
|
+
const STRING_LITERAL_ARRAY_ENTRY_RE = /^(['"])([^'"]+)\1$/;
|
|
7066
7071
|
const WHITESPACE_RE$1 = /\s/;
|
|
7072
|
+
const findMatchingObjectBraceIndex = (source, openIndex) => {
|
|
7073
|
+
let depth = 0;
|
|
7074
|
+
let quote;
|
|
7075
|
+
let escaped = false;
|
|
7076
|
+
let lineComment = false;
|
|
7077
|
+
let blockComment = false;
|
|
7078
|
+
for (let index = openIndex; index < source.length; index++) {
|
|
7079
|
+
const char = source[index];
|
|
7080
|
+
const nextChar = source[index + 1];
|
|
7081
|
+
if (lineComment) {
|
|
7082
|
+
if (char === "\n" || char === "\r") lineComment = false;
|
|
7083
|
+
continue;
|
|
7084
|
+
}
|
|
7085
|
+
if (blockComment) {
|
|
7086
|
+
if (char === "*" && nextChar === "/") {
|
|
7087
|
+
blockComment = false;
|
|
7088
|
+
index++;
|
|
7089
|
+
}
|
|
7090
|
+
continue;
|
|
7091
|
+
}
|
|
7092
|
+
if (quote) {
|
|
7093
|
+
if (escaped) {
|
|
7094
|
+
escaped = false;
|
|
7095
|
+
continue;
|
|
7096
|
+
}
|
|
7097
|
+
if (char === "\\") {
|
|
7098
|
+
escaped = true;
|
|
7099
|
+
continue;
|
|
7100
|
+
}
|
|
7101
|
+
if (char === quote) quote = void 0;
|
|
7102
|
+
continue;
|
|
7103
|
+
}
|
|
7104
|
+
if (char === "/" && nextChar === "/") {
|
|
7105
|
+
lineComment = true;
|
|
7106
|
+
index++;
|
|
7107
|
+
continue;
|
|
7108
|
+
}
|
|
7109
|
+
if (char === "/" && nextChar === "*") {
|
|
7110
|
+
blockComment = true;
|
|
7111
|
+
index++;
|
|
7112
|
+
continue;
|
|
7113
|
+
}
|
|
7114
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
7115
|
+
quote = char;
|
|
7116
|
+
continue;
|
|
7117
|
+
}
|
|
7118
|
+
if (char === "{") {
|
|
7119
|
+
depth++;
|
|
7120
|
+
continue;
|
|
7121
|
+
}
|
|
7122
|
+
if (char === "}") {
|
|
7123
|
+
depth--;
|
|
7124
|
+
if (depth === 0) return index;
|
|
7125
|
+
}
|
|
7126
|
+
}
|
|
7127
|
+
return -1;
|
|
7128
|
+
};
|
|
7067
7129
|
const resolveEnvBootstrapPlanFileDetails = (templateId) => {
|
|
7068
7130
|
if (templateId === KITCN_CONFIG_TEMPLATE_ID) return {
|
|
7069
7131
|
createReason: "Create kitcn config.",
|
|
@@ -7099,18 +7161,64 @@ const resolveBootstrapEnvFields = (envFields) => {
|
|
|
7099
7161
|
for (const field of envFields) if (!fields.some((existing) => existing.key === field.key)) fields.push(field);
|
|
7100
7162
|
return fields;
|
|
7101
7163
|
};
|
|
7164
|
+
const resolveReadOptionalRuntimeEnvKeys = (fields) => fields.filter((field) => field.readOptionalRuntimeEnv).map((field) => field.key);
|
|
7165
|
+
const renderReadOptionalRuntimeEnvOption = (keys) => {
|
|
7166
|
+
if (keys.length === 0) return "";
|
|
7167
|
+
return ` readOptionalRuntimeEnv: [\n${keys.map((key) => ` '${key}',`).join("\n")}\n ],\n`;
|
|
7168
|
+
};
|
|
7169
|
+
const parseReadOptionalRuntimeEnvKeys = (existingOptionsBody, existingMatch) => {
|
|
7170
|
+
if (existingMatch.index === void 0) return [];
|
|
7171
|
+
const matchEnd = existingMatch.index + existingMatch[0].length;
|
|
7172
|
+
if (!existingMatch[3].includes(",") && existingOptionsBody.slice(matchEnd).trim()) throw new Error("Expected env helper `readOptionalRuntimeEnv` to be an inline array of string literals before adding keys.");
|
|
7173
|
+
const rawEntries = existingMatch[2].trim();
|
|
7174
|
+
if (!rawEntries) return [];
|
|
7175
|
+
const keys = [];
|
|
7176
|
+
const entries = rawEntries.split(",");
|
|
7177
|
+
for (let index = 0; index < entries.length; index++) {
|
|
7178
|
+
const entry = entries[index].trim();
|
|
7179
|
+
if (!entry && index === entries.length - 1) continue;
|
|
7180
|
+
const stringLiteralMatch = entry.match(STRING_LITERAL_ARRAY_ENTRY_RE);
|
|
7181
|
+
if (!stringLiteralMatch) throw new Error("Expected env helper `readOptionalRuntimeEnv` to be an inline array of string literals before adding keys.");
|
|
7182
|
+
keys.push(stringLiteralMatch[2]);
|
|
7183
|
+
}
|
|
7184
|
+
return keys;
|
|
7185
|
+
};
|
|
7186
|
+
const upsertReadOptionalRuntimeEnvOption = (source, keys) => {
|
|
7187
|
+
if (keys.length === 0) return source;
|
|
7188
|
+
const createEnvMatch = source.match(CREATE_ENV_OPTIONS_START_RE);
|
|
7189
|
+
if (!createEnvMatch || createEnvMatch.index === void 0) throw new Error("Expected env helper to call `createEnv({ ... })` before adding `readOptionalRuntimeEnv`.");
|
|
7190
|
+
const insertIndex = createEnvMatch.index + createEnvMatch[0].lastIndexOf("{") + 1;
|
|
7191
|
+
const closingBraceIndex = findMatchingObjectBraceIndex(source, insertIndex - 1);
|
|
7192
|
+
if (closingBraceIndex === -1) throw new Error("Expected env helper `createEnv` options object to close before adding `readOptionalRuntimeEnv`.");
|
|
7193
|
+
const existingOptionsBody = source.slice(insertIndex, closingBraceIndex);
|
|
7194
|
+
const existingMatch = existingOptionsBody.match(READ_OPTIONAL_RUNTIME_ENV_RE);
|
|
7195
|
+
if (!existingMatch && READ_OPTIONAL_RUNTIME_ENV_PROPERTY_RE.test(existingOptionsBody)) throw new Error("Expected env helper `readOptionalRuntimeEnv` to be an inline array before adding keys.");
|
|
7196
|
+
const existingKeys = existingMatch ? parseReadOptionalRuntimeEnvKeys(existingOptionsBody, existingMatch) : [];
|
|
7197
|
+
const option = renderReadOptionalRuntimeEnvOption([...new Set([...existingKeys, ...keys])]);
|
|
7198
|
+
if (existingMatch && existingMatch.index !== void 0) {
|
|
7199
|
+
const replacement = `${existingMatch[1].match(LEADING_WHITESPACE_RE)?.[0] ?? ""}${option.trimStart().trimEnd()}`;
|
|
7200
|
+
const existingOptionStart = insertIndex + existingMatch.index;
|
|
7201
|
+
return `${source.slice(0, existingOptionStart)}${replacement}${source.slice(existingOptionStart + existingMatch[0].length)}`;
|
|
7202
|
+
}
|
|
7203
|
+
const before = source.slice(0, insertIndex);
|
|
7204
|
+
const after = source.slice(insertIndex);
|
|
7205
|
+
if (after.startsWith("\n")) return `${before}\n${option}${after.slice(1)}`;
|
|
7206
|
+
const body = source.slice(insertIndex, closingBraceIndex).trim();
|
|
7207
|
+
return `${before}\n${option}${body.length === 0 ? "" : ` ${body}${body.endsWith(",") ? "" : ","}\n`}${source.slice(closingBraceIndex)}`;
|
|
7208
|
+
};
|
|
7102
7209
|
const renderEnvHelperContent = (envFields, existingContent) => {
|
|
7103
7210
|
const fields = resolveBootstrapEnvFields(envFields);
|
|
7104
|
-
|
|
7211
|
+
const readOptionalRuntimeEnvKeys = resolveReadOptionalRuntimeEnvKeys(fields);
|
|
7212
|
+
if (!existingContent) return `import { createEnv } from 'kitcn/server';\nimport { z } from 'zod';\n\nconst envSchema = z.object({\n${fields.map((field) => ` ${field.key}: ${field.schema},`).join("\n")}\n});\n\nexport const getEnv = createEnv({\n${renderReadOptionalRuntimeEnvOption(readOptionalRuntimeEnvKeys)} schema: envSchema,\n});\n`;
|
|
7105
7213
|
const match = existingContent.match(ENV_SCHEMA_RE);
|
|
7106
7214
|
if (!match) throw new Error("Expected env helper to define `const envSchema = z.object({ ... });`.");
|
|
7107
7215
|
const existingBody = match[2];
|
|
7108
7216
|
const missingFieldLines = fields.filter((field) => {
|
|
7109
7217
|
return !new RegExp(`(^|\\n)\\s*${field.key}\\s*:`, "m").test(existingBody);
|
|
7110
7218
|
}).map((field) => ` ${field.key}: ${field.schema},`);
|
|
7111
|
-
if (missingFieldLines.length === 0) return existingContent;
|
|
7219
|
+
if (missingFieldLines.length === 0) return upsertReadOptionalRuntimeEnvOption(existingContent, readOptionalRuntimeEnvKeys);
|
|
7112
7220
|
const nextBody = `${existingBody}${existingBody.endsWith("\n") ? "" : "\n"}${missingFieldLines.join("\n")}`;
|
|
7113
|
-
return existingContent.replace(ENV_SCHEMA_RE, `${match[1]}${nextBody}${match[3]}`);
|
|
7221
|
+
return upsertReadOptionalRuntimeEnvOption(existingContent.replace(ENV_SCHEMA_RE, `${match[1]}${nextBody}${match[3]}`), readOptionalRuntimeEnvKeys);
|
|
7114
7222
|
};
|
|
7115
7223
|
const renderLocalConvexEnvContent = (envFields, existingContent) => {
|
|
7116
7224
|
const fields = resolveBootstrapEnvFields(envFields).filter((field) => field.bootstrap !== void 0);
|
|
@@ -11970,19 +12078,19 @@ const RESEND_SCHEMA_TEMPLATE = `import {
|
|
|
11970
12078
|
unionOf,
|
|
11971
12079
|
} from "kitcn/orm";
|
|
11972
12080
|
|
|
11973
|
-
export const resendContentTable = convexTable("
|
|
12081
|
+
export const resendContentTable = convexTable("resendContent", {
|
|
11974
12082
|
content: bytes().notNull(),
|
|
11975
12083
|
mimeType: text().notNull(),
|
|
11976
12084
|
filename: text(),
|
|
11977
12085
|
path: text(),
|
|
11978
12086
|
});
|
|
11979
12087
|
|
|
11980
|
-
export const resendNextBatchRunTable = convexTable("
|
|
12088
|
+
export const resendNextBatchRunTable = convexTable("resendNextBatchRun", {
|
|
11981
12089
|
runId: text().notNull(),
|
|
11982
12090
|
});
|
|
11983
12091
|
|
|
11984
12092
|
export const resendDeliveryEventsTable = convexTable(
|
|
11985
|
-
"
|
|
12093
|
+
"resendDeliveryEvents",
|
|
11986
12094
|
{
|
|
11987
12095
|
emailId: text().notNull(),
|
|
11988
12096
|
resendId: text().notNull(),
|
|
@@ -11997,7 +12105,7 @@ export const resendDeliveryEventsTable = convexTable(
|
|
|
11997
12105
|
);
|
|
11998
12106
|
|
|
11999
12107
|
export const resendEmailsTable = convexTable(
|
|
12000
|
-
"
|
|
12108
|
+
"resendEmails",
|
|
12001
12109
|
{
|
|
12002
12110
|
from: text().notNull(),
|
|
12003
12111
|
to: arrayOf(text().notNull()).notNull(),
|
|
@@ -12200,15 +12308,18 @@ const resendRegistryItem = defineInternalRegistryItem({
|
|
|
12200
12308
|
envFields: [
|
|
12201
12309
|
{
|
|
12202
12310
|
key: "RESEND_API_KEY",
|
|
12311
|
+
readOptionalRuntimeEnv: true,
|
|
12203
12312
|
schema: "z.string().optional()",
|
|
12204
12313
|
reminder: { message: "Set before sending email through Resend." }
|
|
12205
12314
|
},
|
|
12206
12315
|
{
|
|
12207
12316
|
key: "RESEND_WEBHOOK_SECRET",
|
|
12317
|
+
readOptionalRuntimeEnv: true,
|
|
12208
12318
|
schema: "z.string().optional()"
|
|
12209
12319
|
},
|
|
12210
12320
|
{
|
|
12211
12321
|
key: "RESEND_FROM_EMAIL",
|
|
12322
|
+
readOptionalRuntimeEnv: true,
|
|
12212
12323
|
schema: "z.string().optional()"
|
|
12213
12324
|
}
|
|
12214
12325
|
],
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as promptForScaffoldTemplateSelection, A as resolveCodegenTrimSegments, At as highlighter, B as runConfiguredCodegen, C as isEntryPoint, Ct as formatDependencyInstallCommand, D as parseInitCommandArgs, E as parseBackendRunJson, Et as stripConvexCommandNoise, 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, P as resolveMigrationConfig, Q as promptForPluginSelection, R as runAggregatePruneFlow, S as isConvexDevPreRunConflictFlag, St as detectPackageManager, T as parseArgs, Tt as serializeEnvValue, 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, kt as logger, 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 resolveAuthEnvState, 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, At as highlighter, B as runConfiguredCodegen, C as isEntryPoint, Ct as formatDependencyInstallCommand, D as parseInitCommandArgs, E as parseBackendRunJson, Et as stripConvexCommandNoise, 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, P as resolveMigrationConfig, Q as promptForPluginSelection, R as runAggregatePruneFlow, S as isConvexDevPreRunConflictFlag, St as detectPackageManager, T as parseArgs, Tt as serializeEnvValue, 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, kt as logger, 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 resolveAuthEnvState, x as hasRemoteConvexDeploymentEnv, xt as resolveProjectScaffoldContext, y as getConvexDeploymentCommandEnv, yt as inspectPluginDependencyInstall, z as runBackendFunction } from "./backend-core-BYs_6mO4.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-DLiYI2EF.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";
|
|
@@ -4,8 +4,13 @@ import { z } from "zod";
|
|
|
4
4
|
|
|
5
5
|
//#region src/server/env.ts
|
|
6
6
|
function createEnv(options) {
|
|
7
|
-
const { schema, runtimeEnv, cache = true, codegenFallback = false } = options;
|
|
7
|
+
const { schema, runtimeEnv, cache = true, codegenFallback = false, readOptionalRuntimeEnv = [] } = options;
|
|
8
|
+
const directOptionalKeys = new Set(readOptionalRuntimeEnv);
|
|
8
9
|
let cached;
|
|
10
|
+
const createInvalidEnvError = () => new CRPCError({
|
|
11
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
12
|
+
message: "Invalid environment variables"
|
|
13
|
+
});
|
|
9
14
|
return () => {
|
|
10
15
|
if (cache && cached) return cached;
|
|
11
16
|
const isCodegenParse = globalThis.__KITCN_CODEGEN__ === true || codegenFallback;
|
|
@@ -14,6 +19,11 @@ function createEnv(options) {
|
|
|
14
19
|
for (const [key, zodType] of Object.entries(schema.shape)) {
|
|
15
20
|
const undefinedParse = zodType.safeParse(void 0);
|
|
16
21
|
if (undefinedParse.success) {
|
|
22
|
+
if (directOptionalKeys.has(key)) {
|
|
23
|
+
if (Object.hasOwn(runtimeEnvSource, key) || Object.getOwnPropertyDescriptor(runtimeEnvSource, key) !== void 0 || key in runtimeEnvSource) runtimeEnvSnapshot[key] = runtimeEnvSource[key];
|
|
24
|
+
else if (!isCodegenParse && undefinedParse.data !== void 0) runtimeEnvSnapshot[key] = runtimeEnvSource[key];
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
17
27
|
if (Object.hasOwn(runtimeEnvSource, key) || Object.getOwnPropertyDescriptor(runtimeEnvSource, key) !== void 0 || key in runtimeEnvSource) runtimeEnvSnapshot[key] = runtimeEnvSource[key];
|
|
18
28
|
else if (!isCodegenParse && undefinedParse.data !== void 0) runtimeEnvSnapshot[key] = runtimeEnvSource[key];
|
|
19
29
|
continue;
|
|
@@ -32,10 +42,22 @@ function createEnv(options) {
|
|
|
32
42
|
...Object.fromEntries(Object.entries(runtimeEnvSnapshot).filter(([, value]) => value !== void 0))
|
|
33
43
|
} : runtimeEnvSnapshot;
|
|
34
44
|
const parsed = schema.safeParse(envForParse);
|
|
35
|
-
if (!parsed.success) throw
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
if (!parsed.success) throw createInvalidEnvError();
|
|
46
|
+
const parsedData = parsed.data;
|
|
47
|
+
for (const key of directOptionalKeys) {
|
|
48
|
+
if (!(key in schema.shape) || parsedData[key] !== void 0) continue;
|
|
49
|
+
Object.defineProperty(parsedData, key, {
|
|
50
|
+
configurable: true,
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: () => {
|
|
53
|
+
const value = runtimeEnvSource[key];
|
|
54
|
+
if (value === void 0) return;
|
|
55
|
+
const result = schema.shape[key].safeParse(value);
|
|
56
|
+
if (!result.success) throw createInvalidEnvError();
|
|
57
|
+
return result.data;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
39
61
|
if (cache) cached = parsed.data;
|
|
40
62
|
return parsed.data;
|
|
41
63
|
};
|
|
@@ -1107,6 +1107,7 @@ type RuntimeEnv = Record<string, string | undefined>;
|
|
|
1107
1107
|
type CreateEnvOptions<TSchema extends z.ZodObject<z.ZodRawShape>> = {
|
|
1108
1108
|
cache?: boolean;
|
|
1109
1109
|
codegenFallback?: boolean;
|
|
1110
|
+
readOptionalRuntimeEnv?: readonly string[];
|
|
1110
1111
|
runtimeEnv?: RuntimeEnv;
|
|
1111
1112
|
schema: TSchema;
|
|
1112
1113
|
};
|
|
@@ -1366,4 +1367,4 @@ type ProcedureNameLookup = Record<string, ProcedureNameEntry[]>;
|
|
|
1366
1367
|
declare function registerProcedureNameLookup(lookup: ProcedureNameLookup, functionsDirHint: string): void;
|
|
1367
1368
|
declare function inferProcedureNameFromCallsite(): string | undefined;
|
|
1368
1369
|
//#endregion
|
|
1369
|
-
export {
|
|
1370
|
+
export { ActionProcedureBuilder as $, CRPCError as A, RuntimeEnv as B, createProcedureHandlerFactory as C, zCustomQuery as Ct, WithHttpRouter as D, zodToConvex as Dt, typedProcedureResolver as E, zodOutputToConvexFields as Et, getCRPCErrorFromUnknown as F, createLazyCaller as G, ConvexContext as H, getHTTPStatusCodeFromError as I, ServerCaller as J, CallerMeta as K, isCRPCError as L, CRPCErrorData as M, CRPC_ERROR_CODES_BY_KEY as N, inferApiInputs as O, zodToConvexFields as Ot, CRPC_ERROR_CODE_TO_HTTP as P, getGeneratedValue as Q, toCRPCError as R, createProcedureCallerFactory as S, zCustomMutation as St, getGeneratedFunctionReference as T, zodOutputToConvex as Tt, createCallerFactory as U, createEnv as V, LazyCaller as W, createApiLeaf as X, createServerCaller as Y, createGeneratedFunctionReference as Z, ProcedureSchedulableCallerFromRegistry as _, ZodValidatorFromConvex as _t, CreateProcedureCallerFactoryOptions as a, initCRPC as at, createGenericCallerFactory as b, withSystemFields as bt, GeneratedRegistryCallerFactory as c, extractPathParams as ct, GeneratedRegistryHandlerForContext as d, ConvexValidatorFromZod as dt, CRPCFunctionTypeHint as et, ProcedureActionCallerFromRegistry as f, ConvexValidatorFromZodOutput as ft, ProcedureFromFunctionReference as g, ZodFromValidatorBase as gt, ProcedureDefinition as h, Zid as ht, registerProcedureNameLookup as i, createMiddlewareFactory as it, CRPCErrorCode as j, inferApiOutputs as k, GeneratedRegistryCallerForContext as l, handleHttpError as lt, ProcedureCallerFromRegistry as m, ZCustomCtx as mt, ProcedureNameLookup as n, ProcedureBuilder as nt, GeneratedProcedureRegistry as o, HttpProcedureBuilder as ot, ProcedureCaller as p, CustomBuilder as pt, CallerOpts as q, inferProcedureNameFromCallsite as r, QueryProcedureBuilder as rt, GeneratedProcedureRegistryEntry as s, createHttpProcedureBuilder as st, ProcedureNameEntry as t, MutationProcedureBuilder as tt, GeneratedRegistryHandlerFactory as u, matchPathParams as ut, ProcedureScheduleCallerFromRegistry as v, convexToZod as vt, defineProcedure as w, zid as wt, createGenericHandlerFactory as x, zCustomAction as xt, createGeneratedRegistryRuntime as y, convexToZodFields as yt, CreateEnvOptions as z };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ActionProcedureBuilder, A as CRPCError, B as RuntimeEnv, C as createProcedureHandlerFactory, Ct as zCustomQuery, D as WithHttpRouter, Dt as zodToConvex, E as typedProcedureResolver, Et as zodOutputToConvexFields, F as getCRPCErrorFromUnknown, G as createLazyCaller, H as ConvexContext, I as getHTTPStatusCodeFromError, J as ServerCaller, K as CallerMeta, L as isCRPCError, M as CRPCErrorData, N as CRPC_ERROR_CODES_BY_KEY, O as inferApiInputs, Ot as zodToConvexFields, P as CRPC_ERROR_CODE_TO_HTTP, Q as getGeneratedValue, R as toCRPCError, S as createProcedureCallerFactory, St as zCustomMutation, T as getGeneratedFunctionReference, Tt as zodOutputToConvex, U as createCallerFactory, V as createEnv, W as LazyCaller, X as createApiLeaf, Y as createServerCaller, Z as createGeneratedFunctionReference, _ as ProcedureSchedulableCallerFromRegistry, _t as ZodValidatorFromConvex, a as CreateProcedureCallerFactoryOptions, at as initCRPC, b as createGenericCallerFactory, bt as withSystemFields, c as GeneratedRegistryCallerFactory, ct as extractPathParams, d as GeneratedRegistryHandlerForContext, dt as ConvexValidatorFromZod, et as CRPCFunctionTypeHint, f as ProcedureActionCallerFromRegistry, ft as ConvexValidatorFromZodOutput, g as ProcedureFromFunctionReference, gt as ZodFromValidatorBase, h as ProcedureDefinition, ht as Zid, i as registerProcedureNameLookup, it as createMiddlewareFactory, j as CRPCErrorCode, k as inferApiOutputs, l as GeneratedRegistryCallerForContext, lt as handleHttpError, m as ProcedureCallerFromRegistry, mt as ZCustomCtx, n as ProcedureNameLookup, nt as ProcedureBuilder, o as GeneratedProcedureRegistry, ot as HttpProcedureBuilder, p as ProcedureCaller, pt as CustomBuilder, q as CallerOpts, r as inferProcedureNameFromCallsite, rt as QueryProcedureBuilder, s as GeneratedProcedureRegistryEntry, st as createHttpProcedureBuilder, t as ProcedureNameEntry, tt as MutationProcedureBuilder, u as GeneratedRegistryHandlerFactory, ut as matchPathParams, v as ProcedureScheduleCallerFromRegistry, vt as convexToZod, w as defineProcedure, wt as zid, x as createGenericHandlerFactory, xt as zCustomAction, y as createGeneratedRegistryRuntime, yt as convexToZodFields, z as CreateEnvOptions } from "../procedure-name-Cy1AxayA.js";
|
|
2
2
|
import { C as HttpProcedure, D as ProcedureMeta, E as InferHttpInput, S as HttpMethod, T as HttpRouteDefinition, _ as extractRouteMap, b as HttpActionHandler, d as CRPCHttpRouter, f as HttpRouterDef, g as createHttpRouterFactory, h as createHttpRouter, m as HttpRouterWithHono, p as HttpRouterRecord, v as CRPCHonoHandler, w as HttpProcedureBuilderDef, x as HttpHandlerOpts, y as HttpActionConstructor } from "../http-types-zsMHb_QN.js";
|
|
3
3
|
import { a as MergeZodObjects, c as MiddlewareMarker, d as MiddlewareProcedureType, f as MiddlewareResult, g as UnsetMarker, h as Simplify, i as IntersectIfDefined, l as MiddlewareNext, m as ResolveIfSet, n as AnyMiddlewareBuilder, o as MiddlewareBuilder, p as Overwrite, r as GetRawInputFn, s as MiddlewareFunction, t as AnyMiddleware, u as MiddlewareProcedureInfo } from "../types-CnTpHR1F.js";
|
|
4
4
|
import { a as isMutationCtx, c as isSchedulerCtx, d as requireQueryCtx, f as requireRunMutationCtx, i as isActionCtx, l as requireActionCtx, n as RunMutationCtx, o as isQueryCtx, p as requireSchedulerCtx, r as SchedulerCtx, s as isRunMutationCtx, t as GenericCtx, u as requireMutationCtx } from "../context-utils-OMkMGhBk.js";
|
|
5
|
-
export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCErrorData, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GeneratedRegistryCallerFactory, GeneratedRegistryCallerForContext, GeneratedRegistryHandlerFactory, GeneratedRegistryHandlerForContext, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareProcedureInfo, MiddlewareProcedureType, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureNameEntry, ProcedureNameLookup, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, SchedulerCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGeneratedFunctionReference, createGeneratedRegistryRuntime, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getGeneratedFunctionReference, getGeneratedValue, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, inferProcedureNameFromCallsite, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, isSchedulerCtx, matchPathParams, registerProcedureNameLookup, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, requireSchedulerCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
|
|
5
|
+
export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCErrorData, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GeneratedRegistryCallerFactory, GeneratedRegistryCallerForContext, GeneratedRegistryHandlerFactory, GeneratedRegistryHandlerForContext, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareProcedureInfo, MiddlewareProcedureType, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureNameEntry, ProcedureNameLookup, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, RuntimeEnv, SchedulerCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGeneratedFunctionReference, createGeneratedRegistryRuntime, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getGeneratedFunctionReference, getGeneratedValue, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, inferProcedureNameFromCallsite, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, isSchedulerCtx, matchPathParams, registerProcedureNameLookup, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, requireSchedulerCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
|
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as isMutationCtx, c as isSchedulerCtx, d as requireQueryCtx, f as requireRunMutationCtx, i as isActionCtx, l as requireActionCtx, n as createGeneratedFunctionReference, o as isQueryCtx, p as requireSchedulerCtx, r as getGeneratedValue, s as isRunMutationCtx, t as createApiLeaf, u as requireMutationCtx } from "../api-entry-N3nBOlI2.js";
|
|
2
2
|
import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-NEfgD5E0.js";
|
|
3
3
|
import { A as zid, C as toCRPCError, D as zCustomAction, E as withSystemFields, M as zodOutputToConvexFields, N as zodToConvex, O as zCustomMutation, P as zodToConvexFields, S as isCRPCError, T as convexToZodFields, _ as CRPCError, a as createMiddlewareFactory, b as getCRPCErrorFromUnknown, c as registerProcedureNameLookup, d as createHttpRouterFactory, f as extractRouteMap, g as matchPathParams, h as handleHttpError, i as QueryProcedureBuilder, j as zodOutputToConvex, k as zCustomQuery, l as HttpRouterWithHono, m as extractPathParams, n as MutationProcedureBuilder, o as initCRPC, p as createHttpProcedureBuilder, r as ProcedureBuilder, s as inferProcedureNameFromCallsite, t as ActionProcedureBuilder, u as createHttpRouter, v as CRPC_ERROR_CODES_BY_KEY, w as convexToZod, x as getHTTPStatusCodeFromError, y as CRPC_ERROR_CODE_TO_HTTP } from "../builder-DBgto1yn.js";
|
|
4
|
-
import { a as createProcedureHandlerFactory, c as typedProcedureResolver, i as createProcedureCallerFactory, l as createEnv, n as createGenericCallerFactory, o as defineProcedure, r as createGenericHandlerFactory, s as getGeneratedFunctionReference, t as createGeneratedRegistryRuntime } from "../procedure-caller-
|
|
4
|
+
import { a as createProcedureHandlerFactory, c as typedProcedureResolver, i as createProcedureCallerFactory, l as createEnv, n as createGenericCallerFactory, o as defineProcedure, r as createGenericHandlerFactory, s as getGeneratedFunctionReference, t as createGeneratedRegistryRuntime } from "../procedure-caller-9m6NBxQu.js";
|
|
5
5
|
|
|
6
6
|
export { ActionProcedureBuilder, CRPCError, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, HttpRouterWithHono, MutationProcedureBuilder, ProcedureBuilder, QueryProcedureBuilder, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGeneratedFunctionReference, createGeneratedRegistryRuntime, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getGeneratedFunctionReference, getGeneratedValue, getHTTPStatusCodeFromError, handleHttpError, inferProcedureNameFromCallsite, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, isSchedulerCtx, matchPathParams, registerProcedureNameLookup, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, requireSchedulerCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
|
package/dist/watcher.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-
|
|
2
|
+
import { Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-BYs_6mO4.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
|
+
updatedAt: 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: "updatedAt";
|
|
3731
3731
|
};
|
|
3732
3732
|
};
|
|
3733
|
-
|
|
3733
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
3734
3734
|
_: {
|
|
3735
3735
|
notNull: true;
|
|
3736
3736
|
};
|
|
@@ -3740,7 +3740,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3740
3740
|
};
|
|
3741
3741
|
} & {
|
|
3742
3742
|
_: {
|
|
3743
|
-
fieldName: "
|
|
3743
|
+
fieldName: "count";
|
|
3744
3744
|
};
|
|
3745
3745
|
};
|
|
3746
3746
|
tableKey: ConvexTextBuilderInitial<""> & {
|
|
@@ -4009,7 +4009,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4009
4009
|
fieldName: "value";
|
|
4010
4010
|
};
|
|
4011
4011
|
};
|
|
4012
|
-
|
|
4012
|
+
updatedAt: 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: "updatedAt";
|
|
4023
4023
|
};
|
|
4024
4024
|
};
|
|
4025
|
-
|
|
4025
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
4026
4026
|
_: {
|
|
4027
4027
|
notNull: true;
|
|
4028
4028
|
};
|
|
@@ -4032,7 +4032,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4032
4032
|
};
|
|
4033
4033
|
} & {
|
|
4034
4034
|
_: {
|
|
4035
|
-
fieldName: "
|
|
4035
|
+
fieldName: "count";
|
|
4036
4036
|
};
|
|
4037
4037
|
};
|
|
4038
4038
|
tableKey: ConvexTextBuilderInitial<""> & {
|
package/package.json
CHANGED
|
@@ -48,6 +48,40 @@ export const {
|
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
For client-side route loaders that fetch protected Convex queries through the
|
|
52
|
+
router `queryClient`, prime the shared Convex client in the root `beforeLoad`
|
|
53
|
+
before child loaders run:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
57
|
+
import { createRootRouteWithContext } from "@tanstack/react-router";
|
|
58
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
59
|
+
import { syncConvexAuthForStartLoader } from "kitcn/auth/start";
|
|
60
|
+
import type { ConvexQueryClient } from "kitcn/react";
|
|
61
|
+
|
|
62
|
+
import { getToken } from "@/lib/convex/auth-server";
|
|
63
|
+
|
|
64
|
+
const getLoaderToken = createServerFn({ method: "GET" }).handler(async () => {
|
|
65
|
+
return await getToken();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const Route = createRootRouteWithContext<{
|
|
69
|
+
convexQueryClient: ConvexQueryClient;
|
|
70
|
+
queryClient: QueryClient;
|
|
71
|
+
}>()({
|
|
72
|
+
beforeLoad: async ({ context }) => {
|
|
73
|
+
return await syncConvexAuthForStartLoader({
|
|
74
|
+
convex: context.convexQueryClient,
|
|
75
|
+
getToken: getLoaderToken,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use `runServerCall` or `fetchAuthQuery` for server-side loaders. Use
|
|
82
|
+
`syncConvexAuthForStartLoader` only for client/router loaders that execute
|
|
83
|
+
shared `ConvexQueryClient` queries before `ConvexAuthProvider` mounts.
|
|
84
|
+
|
|
51
85
|
### 8.B.2 Auth API endpoint
|
|
52
86
|
|
|
53
87
|
**Create:** `src/routes/api/auth/$.ts`
|