kitcn 0.12.16 → 0.12.18

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.
@@ -2196,57 +2196,98 @@ const highlighter = {
2196
2196
  };
2197
2197
 
2198
2198
  //#endregion
2199
- //#region src/cli/utils/project-jiti.ts
2200
- const JITI_EXPORT_CONDITION_PRIORITY = [
2201
- "bun",
2202
- "import",
2203
- "module",
2204
- "default",
2205
- "require"
2206
- ];
2207
- const SERVER_PARSER_SHIM_SOURCE = `const createMiddleware = (handler = undefined) => ({
2199
+ //#region src/cli/utils/crpc-builder-stub.ts
2200
+ const CRPC_BUILDER_STUB_SOURCE = `const createMiddleware = (handler = undefined) => ({
2208
2201
  _handler: handler,
2209
- pipe(nextHandler) {
2202
+ pipe(nextHandler = undefined) {
2210
2203
  return createMiddleware(nextHandler);
2211
2204
  },
2212
2205
  });
2213
2206
 
2214
- const createProcedureBuilder = () => {
2207
+ const toMetaObject = (value = undefined) =>
2208
+ value && typeof value === "object" ? value : {};
2209
+
2210
+ const createProcedureExport = (type, state, handler) => ({
2211
+ _crpcMeta: {
2212
+ type,
2213
+ internal: state.internal ?? false,
2214
+ ...toMetaObject(state.meta),
2215
+ },
2216
+ _handler: handler,
2217
+ });
2218
+
2219
+ const createProcedureBuilder = (state = {}) => {
2215
2220
  const builder = {
2216
2221
  internal() {
2217
- return builder;
2222
+ return createProcedureBuilder({ ...state, internal: true });
2218
2223
  },
2219
2224
  use() {
2220
- return builder;
2225
+ return createProcedureBuilder(state);
2221
2226
  },
2222
- meta() {
2223
- return builder;
2227
+ meta(value = undefined) {
2228
+ return createProcedureBuilder({
2229
+ ...state,
2230
+ meta: {
2231
+ ...toMetaObject(state.meta),
2232
+ ...toMetaObject(value),
2233
+ },
2234
+ });
2224
2235
  },
2225
2236
  input() {
2226
- return builder;
2237
+ return createProcedureBuilder(state);
2238
+ },
2239
+ params() {
2240
+ return createProcedureBuilder(state);
2241
+ },
2242
+ searchParams() {
2243
+ return createProcedureBuilder(state);
2244
+ },
2245
+ paginated(options = undefined) {
2246
+ return createProcedureBuilder({
2247
+ ...state,
2248
+ meta:
2249
+ typeof options?.limit === "number"
2250
+ ? {
2251
+ ...toMetaObject(state.meta),
2252
+ limit: options.limit,
2253
+ }
2254
+ : state.meta,
2255
+ });
2227
2256
  },
2228
2257
  output() {
2229
- return builder;
2258
+ return createProcedureBuilder(state);
2230
2259
  },
2231
- query(handler) {
2232
- return {
2233
- _crpcMeta: { type: "query" },
2234
- _handler: handler,
2235
- };
2260
+ form() {
2261
+ return createProcedureBuilder(state);
2236
2262
  },
2237
- mutation(handler) {
2238
- return {
2239
- _crpcMeta: { type: "mutation" },
2240
- _handler: handler,
2241
- };
2263
+ route() {
2264
+ return createProcedureBuilder(state);
2242
2265
  },
2243
- action(handler) {
2244
- return {
2245
- _crpcMeta: { type: "action" },
2246
- _handler: handler,
2247
- };
2266
+ get() {
2267
+ return createProcedureBuilder(state);
2268
+ },
2269
+ post() {
2270
+ return createProcedureBuilder(state);
2271
+ },
2272
+ put() {
2273
+ return createProcedureBuilder(state);
2274
+ },
2275
+ patch() {
2276
+ return createProcedureBuilder(state);
2277
+ },
2278
+ delete() {
2279
+ return createProcedureBuilder(state);
2248
2280
  },
2249
- middleware(handler) {
2281
+ query(handler = undefined) {
2282
+ return createProcedureExport("query", state, handler);
2283
+ },
2284
+ mutation(handler = undefined) {
2285
+ return createProcedureExport("mutation", state, handler);
2286
+ },
2287
+ action(handler = undefined) {
2288
+ return createProcedureExport("action", state, handler);
2289
+ },
2290
+ middleware(handler = undefined) {
2250
2291
  return createMiddleware(handler);
2251
2292
  },
2252
2293
  };
@@ -2264,7 +2305,7 @@ export const initCRPC = {
2264
2305
  context() {
2265
2306
  return this;
2266
2307
  },
2267
- middleware(handler) {
2308
+ middleware(handler = undefined) {
2268
2309
  return createMiddleware(handler);
2269
2310
  },
2270
2311
  create() {
@@ -2279,6 +2320,21 @@ export const initCRPC = {
2279
2320
  },
2280
2321
  };
2281
2322
 
2323
+ export const httpAction = createProcedureBuilder();
2324
+ `;
2325
+
2326
+ //#endregion
2327
+ //#region src/cli/utils/project-jiti.ts
2328
+ const require$2 = createRequire(import.meta.url);
2329
+ const JITI_EXPORT_CONDITION_PRIORITY = [
2330
+ "bun",
2331
+ "import",
2332
+ "module",
2333
+ "default",
2334
+ "require"
2335
+ ];
2336
+ const SERVER_PARSER_SHIM_SOURCE = `${CRPC_BUILDER_STUB_SOURCE}
2337
+
2282
2338
  export class CRPCError extends Error {
2283
2339
  constructor(options = {}) {
2284
2340
  super(options.message ?? options.code ?? "CRPC error");
@@ -2354,11 +2410,42 @@ const ensureServerParserShim = (cwd) => {
2354
2410
  if (!fs.existsSync(shimPath) || fs.readFileSync(shimPath, "utf8") !== SERVER_PARSER_SHIM_SOURCE) fs.writeFileSync(shimPath, SERVER_PARSER_SHIM_SOURCE, "utf8");
2355
2411
  return shimPath;
2356
2412
  };
2413
+ const trimTsconfigWildcardSuffix = (value) => value.endsWith("/*") ? value.slice(0, -2) : value;
2414
+ const loadTypeScript$1 = () => {
2415
+ try {
2416
+ return require$2("typescript");
2417
+ } catch {
2418
+ return null;
2419
+ }
2420
+ };
2421
+ const buildTsconfigPathAliases = (cwd) => {
2422
+ const typescript = loadTypeScript$1();
2423
+ if (!typescript) return {};
2424
+ const configPath = typescript.findConfigFile(cwd, fs.existsSync, "tsconfig.json");
2425
+ if (!configPath) return {};
2426
+ const readResult = typescript.readConfigFile(configPath, typescript.sys.readFile);
2427
+ if (readResult.error) return {};
2428
+ const parsedConfig = typescript.parseJsonConfigFileContent(readResult.config, typescript.sys, path.dirname(configPath));
2429
+ const baseUrl = typeof parsedConfig.options.baseUrl === "string" && parsedConfig.options.baseUrl.length > 0 ? parsedConfig.options.baseUrl : path.dirname(configPath);
2430
+ const paths = parsedConfig.options.paths;
2431
+ if (!paths) return {};
2432
+ const aliases = {};
2433
+ for (const [specifier, targets] of Object.entries(paths)) {
2434
+ const firstTarget = targets[0];
2435
+ if (!firstTarget) continue;
2436
+ const aliasKey = trimTsconfigWildcardSuffix(specifier);
2437
+ const aliasTarget = trimTsconfigWildcardSuffix(firstTarget);
2438
+ if (!aliasKey || aliasKey === "*") continue;
2439
+ aliases[aliasKey] = path.resolve(baseUrl, aliasTarget);
2440
+ }
2441
+ return aliases;
2442
+ };
2357
2443
  const getProjectServerParserShimPath = (cwd = process.cwd()) => ensureServerParserShim(cwd);
2358
2444
  const createProjectJiti = (cwd = process.cwd()) => createJiti(cwd, {
2359
2445
  interopDefault: true,
2360
2446
  moduleCache: false,
2361
2447
  alias: {
2448
+ ...buildTsconfigPathAliases(cwd),
2362
2449
  ...buildLocalPackageExportAliases(cwd, "kitcn"),
2363
2450
  ...buildLocalPackageExportAliases(cwd, "convex"),
2364
2451
  "kitcn/server": getProjectServerParserShimPath(cwd)
@@ -4216,7 +4303,8 @@ function getGeneratedRuntimeOutputFile(functionsDir, moduleName) {
4216
4303
  return path.join(functionsDir, GENERATED_DIR, `${runtimeModuleName}.runtime.ts`);
4217
4304
  }
4218
4305
  function emitGeneratedServerPlaceholderFile() {
4219
- return `// biome-ignore-all format: generated
4306
+ return `// @ts-nocheck
4307
+ // biome-ignore-all format: generated
4220
4308
  /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
4221
4309
  // This file is auto-generated by kitcn
4222
4310
  // Do not edit manually. Run \`kitcn codegen\` to regenerate.
@@ -4232,72 +4320,7 @@ export type MutationCtx = ServerMutationCtx;
4232
4320
  export type ActionCtx = ServerActionCtx;
4233
4321
  export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
4234
4322
 
4235
- const createMiddleware = (handler?: unknown) => ({
4236
- _handler: handler,
4237
- pipe(nextHandler?: unknown) {
4238
- return createMiddleware(nextHandler);
4239
- },
4240
- });
4241
-
4242
- const createProcedureBuilder = () => {
4243
- const builder = {
4244
- internal() {
4245
- return builder;
4246
- },
4247
- use() {
4248
- return builder;
4249
- },
4250
- meta() {
4251
- return builder;
4252
- },
4253
- input() {
4254
- return builder;
4255
- },
4256
- output() {
4257
- return builder;
4258
- },
4259
- query(handler?: unknown) {
4260
- return handler ?? builder;
4261
- },
4262
- mutation(handler?: unknown) {
4263
- return handler ?? builder;
4264
- },
4265
- action(handler?: unknown) {
4266
- return handler ?? builder;
4267
- },
4268
- middleware(handler?: unknown) {
4269
- return createMiddleware(handler);
4270
- },
4271
- };
4272
-
4273
- return builder;
4274
- };
4275
-
4276
- export const initCRPC = {
4277
- meta() {
4278
- return this;
4279
- },
4280
- dataModel() {
4281
- return this;
4282
- },
4283
- context() {
4284
- return this;
4285
- },
4286
- middleware(handler?: unknown) {
4287
- return createMiddleware(handler);
4288
- },
4289
- create() {
4290
- return {
4291
- query: createProcedureBuilder(),
4292
- mutation: createProcedureBuilder(),
4293
- action: createProcedureBuilder(),
4294
- httpAction: createProcedureBuilder(),
4295
- middleware: createMiddleware,
4296
- router: (record = {}) => record,
4297
- };
4298
- },
4299
- };
4300
- export const httpAction = createProcedureBuilder();
4323
+ ${CRPC_BUILDER_STUB_SOURCE}
4301
4324
 
4302
4325
  export function withOrm<Ctx>(ctx: Ctx): Ctx {
4303
4326
  return ctx;
@@ -12319,7 +12342,8 @@ const AGGREGATE_STATE_VERSION = 1;
12319
12342
  const INIT_SHADCN_PACKAGE_SPEC = "shadcn@4.0.1";
12320
12343
  const INIT_LOCAL_BOOTSTRAP_TIMEOUT_MS = 3e4;
12321
12344
  const LOCAL_BACKEND_NOT_RUNNING_RE = /Local backend isn't running/i;
12322
- const INIT_GENERATED_SERVER_STUB_TEMPLATE = `import type {
12345
+ const INIT_GENERATED_SERVER_STUB_TEMPLATE = `// @ts-nocheck
12346
+ import type {
12323
12347
  GenericActionCtx,
12324
12348
  GenericDataModel,
12325
12349
  GenericMutationCtx,
@@ -12331,57 +12355,7 @@ export type MutationCtx = GenericMutationCtx<GenericDataModel>;
12331
12355
  export type ActionCtx = GenericActionCtx<GenericDataModel>;
12332
12356
  export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
12333
12357
 
12334
- const createProcedureBuilder = () => {
12335
- const builder = {
12336
- internal() {
12337
- return builder;
12338
- },
12339
- use() {
12340
- return builder;
12341
- },
12342
- meta() {
12343
- return builder;
12344
- },
12345
- input() {
12346
- return builder;
12347
- },
12348
- output() {
12349
- return builder;
12350
- },
12351
- query(handler?: unknown) {
12352
- return handler ?? builder;
12353
- },
12354
- mutation(handler?: unknown) {
12355
- return handler ?? builder;
12356
- },
12357
- action(handler?: unknown) {
12358
- return handler ?? builder;
12359
- },
12360
- };
12361
-
12362
- return builder;
12363
- };
12364
-
12365
- export const initCRPC = {
12366
- meta() {
12367
- return this;
12368
- },
12369
- dataModel() {
12370
- return this;
12371
- },
12372
- context() {
12373
- return this;
12374
- },
12375
- create() {
12376
- return {
12377
- query: createProcedureBuilder(),
12378
- mutation: createProcedureBuilder(),
12379
- action: createProcedureBuilder(),
12380
- httpAction: createProcedureBuilder(),
12381
- router: (record = {}) => record,
12382
- };
12383
- },
12384
- };
12358
+ ${CRPC_BUILDER_STUB_SOURCE}
12385
12359
  `;
12386
12360
  const INIT_LOCAL_BOOTSTRAP_READY_RE = /(Convex|Concave) functions ready!/i;
12387
12361
  const CONVEX_INIT_CREATED_CONFIG_RE = /Configured a local deployment|Provisioned a .* deployment|saved its name as CONVEX_DEPLOYMENT/i;
@@ -12637,11 +12611,33 @@ function resolveRemoteConvexDeploymentKey(env) {
12637
12611
  if (selfHostedUrl) return `self-hosted-env:${selfHostedUrl}`;
12638
12612
  return "remote-env";
12639
12613
  }
12640
- async function withLocalConvexEnv(sharedDir, fn) {
12614
+ function getLocalParseEnvVars(sharedDir, backend) {
12641
12615
  const { functionsDir } = getConvexConfig(sharedDir);
12642
- const envPath = join(functionsDir, "..", ".env");
12643
- if (!fs.existsSync(envPath)) return fn();
12644
- const envVars = parse(fs.readFileSync(envPath, "utf8"));
12616
+ const rootEnvPath = join(process.cwd(), ".env");
12617
+ const backendEnvPath = join(functionsDir, "..", ".env");
12618
+ const envPaths = backend === "concave" ? [backendEnvPath, rootEnvPath] : [rootEnvPath, backendEnvPath];
12619
+ const mergedEnv = {};
12620
+ for (const envPath of envPaths) {
12621
+ if (!fs.existsSync(envPath)) continue;
12622
+ Object.assign(mergedEnv, parse(fs.readFileSync(envPath, "utf8")));
12623
+ }
12624
+ return mergedEnv;
12625
+ }
12626
+ function getLocalBackendEnvVars(sharedDir, backend) {
12627
+ const { functionsDir } = getConvexConfig(sharedDir);
12628
+ const rootEnvPath = join(process.cwd(), ".env");
12629
+ const backendEnvPath = join(functionsDir, "..", ".env");
12630
+ const envPaths = backend === "concave" ? [backendEnvPath, rootEnvPath] : [backendEnvPath];
12631
+ const mergedEnv = {};
12632
+ for (const envPath of envPaths) {
12633
+ if (!fs.existsSync(envPath)) continue;
12634
+ Object.assign(mergedEnv, parse(fs.readFileSync(envPath, "utf8")));
12635
+ }
12636
+ return mergedEnv;
12637
+ }
12638
+ async function withLocalCodegenEnv(sharedDir, backend, fn) {
12639
+ const envVars = getLocalParseEnvVars(sharedDir, backend);
12640
+ if (Object.keys(envVars).length === 0) return fn();
12645
12641
  const previousValues = /* @__PURE__ */ new Map();
12646
12642
  for (const [key, value] of Object.entries(envVars)) {
12647
12643
  previousValues.set(key, process.env[key]);
@@ -12654,12 +12650,6 @@ async function withLocalConvexEnv(sharedDir, fn) {
12654
12650
  else process.env[key] = value;
12655
12651
  }
12656
12652
  }
12657
- function getLocalConvexEnvVars(sharedDir) {
12658
- const { functionsDir } = getConvexConfig(sharedDir);
12659
- const envPath = join(functionsDir, "..", ".env");
12660
- if (!fs.existsSync(envPath)) return {};
12661
- return parse(fs.readFileSync(envPath, "utf8"));
12662
- }
12663
12653
  function parseInitCommandArgs(args) {
12664
12654
  let yes = false;
12665
12655
  let json = false;
@@ -14155,7 +14145,7 @@ async function runConfiguredCodegenDetailed(params) {
14155
14145
  realConcavePath: params.realConcavePath
14156
14146
  });
14157
14147
  const targetArgs = extractBackendRunTargetArgs(resolvedRuntimeAdapter.publicName, convexCodegenArgs);
14158
- const localConvexEnv = getLocalConvexEnvVars(sharedDir);
14148
+ const localBackendEnv = getLocalBackendEnvVars(sharedDir, resolvedRuntimeAdapter.publicName);
14159
14149
  const authEnvState = autoSyncLocalAuthEnv && resolvedRuntimeAdapter.publicName === "convex" && getAggregateBackfillDeploymentKey(targetArgs) === "local" ? resolveAuthEnvState({
14160
14150
  cwd: process.cwd(),
14161
14151
  sharedDir
@@ -14169,7 +14159,7 @@ async function runConfiguredCodegenDetailed(params) {
14169
14159
  targetArgs
14170
14160
  });
14171
14161
  } catch {}
14172
- await withLocalConvexEnv(sharedDir, async () => {
14162
+ await withLocalCodegenEnv(sharedDir, resolvedRuntimeAdapter.publicName, async () => {
14173
14163
  await generateMetaFn(sharedDir, {
14174
14164
  debug,
14175
14165
  scope: scope ?? "all",
@@ -14184,7 +14174,7 @@ async function runConfiguredCodegenDetailed(params) {
14184
14174
  stdio,
14185
14175
  cwd: process.cwd(),
14186
14176
  env: createBackendCommandEnv({
14187
- ...localConvexEnv,
14177
+ ...localBackendEnv,
14188
14178
  ...env
14189
14179
  }),
14190
14180
  reject: false
@@ -14309,7 +14299,7 @@ async function stopPersistentBootstrapProcess(process) {
14309
14299
  }
14310
14300
  }
14311
14301
  async function runLocalConvexBootstrapForInit(params) {
14312
- const localConvexEnv = getLocalConvexEnvVars(params.sharedDir);
14302
+ const localConvexEnv = getLocalBackendEnvVars(params.sharedDir, params.runtimeAdapter.publicName);
14313
14303
  const bootstrapProcess = params.execaFn(params.runtimeAdapter.command, [...params.runtimeAdapter.argsPrefix, ...params.args], {
14314
14304
  cwd: process.cwd(),
14315
14305
  env: createBackendCommandEnv({
@@ -14434,7 +14424,7 @@ async function runInitializationCodegen(params) {
14434
14424
  });
14435
14425
  try {
14436
14426
  if (bootstrap.exitCode !== 0) throw new Error(formatInitCodegenFailure(`${codegen.stdout}\n${codegen.stderr}\n${bootstrap.stdout}\n${bootstrap.stderr}`));
14437
- await withLocalConvexEnv(params.sharedDir, async () => {
14427
+ await withLocalCodegenEnv(params.sharedDir, runtimeAdapter.publicName, async () => {
14438
14428
  await params.generateMetaFn(params.sharedDir, {
14439
14429
  debug: params.debug,
14440
14430
  scope: params.config.codegen.scope ?? "all",
@@ -15205,4 +15195,4 @@ function isEntryPoint(entry, filename) {
15205
15195
  }
15206
15196
 
15207
15197
  //#endregion
15208
- export { resolvePluginPreset as $, resolveConfiguredBackend as A, runConvexInitIfNeeded as B, isInitialized as C, getConvexConfig as Ct, readPackageVersions as D, parseInitCommandArgs as E, runAfterScaffoldScript as F, trackProcess as G, runInitCommandFlow as H, runAggregateBackfillFlow as I, collectPluginScaffoldTemplates as J, withWorkingDirectory as K, runAggregatePruneFlow as L, resolveInitProjectDir as M, resolveMigrationConfig as N, resolveBackfillConfig as O, resolveRunDeps as P, resolveAddTemplateDefaults as Q, runBackendFunction as R, isEntryPoint as S, generateMeta as St, parseBackendRunJson as T, highlighter as Tt, runMigrationCreate as U, runDevSchemaBackfillIfNeeded as V, runMigrationFlow as W, promptForPluginSelection as X, filterScaffoldTemplatePathMap as Y, promptForScaffoldTemplateSelection as Z, formatInfoOutput as _, inspectPluginDependencyInstall as _t, cleanup as a, isSupportedPluginKey as at, hasRemoteConvexDeploymentEnv as b, serializeEnvValue as bt, createCommandEnv as c, assertSchemaFileExists as ct, extractBackfillCliOptions as d, getSchemaFilePath as dt, resolvePresetScaffoldTemplates as et, extractConcaveRunTargetArgs as f, readPluginLockfile as ft, formatDocsOutput as g, applyPluginDependencyInstall as gt, extractResetCliOptions as h, applyPlanningDependencyInstall as ht, buildInitializationPlan as i, getSupportedPluginKeys as it, resolveDocTopic as j, resolveCodegenTrimSegments as k, ensureConvexGitignoreEntry as l, collectInstalledPluginKeys as lt, extractMigrationDownOptions as m, applyDependencyHintsInstall as mt, applyPluginInstallPlanFiles as n, resolveTemplatesByIdOrThrow as nt, createBackendAdapter as o, buildPluginInstallPlan as ot, extractMigrationCliOptions as p, resolveSchemaInstalledPlugins as pt, createSpinner as q, assertNoRemovedDevPreRunFlag as r, getPluginCatalogEntry as rt, createBackendCommandEnv as s, resolvePluginScaffoldRoots as st, applyDependencyInstallPlan as t, resolveTemplateSelectionSource as tt, extractBackendRunTargetArgs as u, getPluginLockfilePath as ut, getAggregateBackfillDeploymentKey as v, resolveProjectScaffoldContext as vt, parseArgs as w, logger as wt, isConvexDevPreRunConflictFlag as x, stripConvexCommandNoise as xt, getDevAggregateBackfillStatePath as y, resolveAuthEnvState as yt, runConfiguredCodegen as z };
15198
+ export { resolveAddTemplateDefaults as $, resolveConfiguredBackend as A, runConvexInitIfNeeded as B, isInitialized as C, generateMeta as Ct, readPackageVersions as D, parseInitCommandArgs as E, highlighter as Et, runAfterScaffoldScript as F, trackProcess as G, runInitCommandFlow as H, runAggregateBackfillFlow as I, createSpinner as J, withLocalCodegenEnv as K, runAggregatePruneFlow as L, resolveInitProjectDir as M, resolveMigrationConfig as N, resolveBackfillConfig as O, resolveRunDeps as P, promptForScaffoldTemplateSelection as Q, runBackendFunction as R, isEntryPoint as S, stripConvexCommandNoise as St, parseBackendRunJson as T, logger as Tt, runMigrationCreate as U, runDevSchemaBackfillIfNeeded as V, runMigrationFlow as W, filterScaffoldTemplatePathMap as X, collectPluginScaffoldTemplates as Y, promptForPluginSelection as Z, formatInfoOutput as _, applyPluginDependencyInstall as _t, cleanup as a, getSupportedPluginKeys as at, hasRemoteConvexDeploymentEnv as b, resolveAuthEnvState as bt, createCommandEnv as c, resolvePluginScaffoldRoots as ct, extractBackfillCliOptions as d, getPluginLockfilePath as dt, resolvePluginPreset as et, extractConcaveRunTargetArgs as f, getSchemaFilePath as ft, formatDocsOutput as g, applyPlanningDependencyInstall as gt, extractResetCliOptions as h, applyDependencyHintsInstall as ht, buildInitializationPlan as i, getPluginCatalogEntry as it, resolveDocTopic as j, resolveCodegenTrimSegments as k, ensureConvexGitignoreEntry as l, assertSchemaFileExists as lt, extractMigrationDownOptions as m, resolveSchemaInstalledPlugins as mt, applyPluginInstallPlanFiles as n, resolveTemplateSelectionSource as nt, createBackendAdapter as o, isSupportedPluginKey as ot, extractMigrationCliOptions as p, readPluginLockfile as pt, withWorkingDirectory as q, assertNoRemovedDevPreRunFlag as r, resolveTemplatesByIdOrThrow as rt, createBackendCommandEnv as s, buildPluginInstallPlan as st, applyDependencyInstallPlan as t, resolvePresetScaffoldTemplates as tt, extractBackendRunTargetArgs as u, collectInstalledPluginKeys as ut, getAggregateBackfillDeploymentKey as v, inspectPluginDependencyInstall as vt, parseArgs as w, getConvexConfig as wt, isConvexDevPreRunConflictFlag as x, serializeEnvValue as xt, getDevAggregateBackfillStatePath as y, resolveProjectScaffoldContext as yt, runConfiguredCodegen as z };
@@ -731,6 +731,7 @@ var CRPCError = class extends ConvexError {
731
731
  const cause = getCauseFromUnknown(opts.cause);
732
732
  const message = opts.message ?? cause?.message ?? opts.code;
733
733
  super({
734
+ ...opts.data ?? {},
734
735
  code: opts.code,
735
736
  message
736
737
  });
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as resolvePluginPreset, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as collectPluginScaffoldTemplates, K as withWorkingDirectory, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as resolveAddTemplateDefaults, R as runBackendFunction, S as isEntryPoint, T as parseBackendRunJson, Tt as highlighter, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as promptForPluginSelection, Y as filterScaffoldTemplatePathMap, Z as promptForScaffoldTemplateSelection, _ as formatInfoOutput, _t as inspectPluginDependencyInstall, a as cleanup, at as isSupportedPluginKey, b as hasRemoteConvexDeploymentEnv, bt as serializeEnvValue, c as createCommandEnv, ct as assertSchemaFileExists, d as extractBackfillCliOptions, dt as getSchemaFilePath, et as resolvePresetScaffoldTemplates, f as extractConcaveRunTargetArgs, ft as readPluginLockfile, g as formatDocsOutput, gt as applyPluginDependencyInstall, h as extractResetCliOptions, ht as applyPlanningDependencyInstall, i as buildInitializationPlan, it as getSupportedPluginKeys, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as collectInstalledPluginKeys, m as extractMigrationDownOptions, mt as applyDependencyHintsInstall, n as applyPluginInstallPlanFiles, nt as resolveTemplatesByIdOrThrow, o as createBackendAdapter, ot as buildPluginInstallPlan, p as extractMigrationCliOptions, pt as resolveSchemaInstalledPlugins, q as createSpinner, r as assertNoRemovedDevPreRunFlag, rt as getPluginCatalogEntry, s as createBackendCommandEnv, st as resolvePluginScaffoldRoots, t as applyDependencyInstallPlan, tt as resolveTemplateSelectionSource, u as extractBackendRunTargetArgs, ut as getPluginLockfilePath, v as getAggregateBackfillDeploymentKey, vt as resolveProjectScaffoldContext, w as parseArgs, wt as logger, x as isConvexDevPreRunConflictFlag, xt as stripConvexCommandNoise, y as getDevAggregateBackfillStatePath, yt as resolveAuthEnvState, z as runConfiguredCodegen } from "./backend-core-DA9iT-To.mjs";
2
+ import { $ as resolveAddTemplateDefaults, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, Et as highlighter, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as createSpinner, K as withLocalCodegenEnv, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as promptForScaffoldTemplateSelection, R as runBackendFunction, S as isEntryPoint, St as stripConvexCommandNoise, T as parseBackendRunJson, Tt as logger, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as filterScaffoldTemplatePathMap, Y as collectPluginScaffoldTemplates, Z as promptForPluginSelection, _ as formatInfoOutput, _t as applyPluginDependencyInstall, a as cleanup, at as getSupportedPluginKeys, b as hasRemoteConvexDeploymentEnv, bt as resolveAuthEnvState, c as createCommandEnv, ct as resolvePluginScaffoldRoots, d as extractBackfillCliOptions, dt as getPluginLockfilePath, et as resolvePluginPreset, f as extractConcaveRunTargetArgs, ft as getSchemaFilePath, g as formatDocsOutput, gt as applyPlanningDependencyInstall, h as extractResetCliOptions, ht as applyDependencyHintsInstall, i as buildInitializationPlan, it as getPluginCatalogEntry, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as assertSchemaFileExists, m as extractMigrationDownOptions, mt as resolveSchemaInstalledPlugins, n as applyPluginInstallPlanFiles, nt as resolveTemplateSelectionSource, o as createBackendAdapter, ot as isSupportedPluginKey, p as extractMigrationCliOptions, pt as readPluginLockfile, q as withWorkingDirectory, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplatesByIdOrThrow, s as createBackendCommandEnv, st as buildPluginInstallPlan, t as applyDependencyInstallPlan, tt as resolvePresetScaffoldTemplates, u as extractBackendRunTargetArgs, ut as collectInstalledPluginKeys, v as getAggregateBackfillDeploymentKey, vt as inspectPluginDependencyInstall, w as parseArgs, x as isConvexDevPreRunConflictFlag, xt as serializeEnvValue, y as getDevAggregateBackfillStatePath, yt as resolveProjectScaffoldContext, z as runConfiguredCodegen } from "./backend-core-CGjsBIOp.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";
@@ -945,11 +945,13 @@ const handleDevCommand = async (argv, deps) => {
945
945
  silent: true,
946
946
  targetArgs
947
947
  });
948
- await generateMetaFn(sharedDir, {
949
- debug,
950
- silent: true,
951
- scope: "all",
952
- trimSegments
948
+ await withLocalCodegenEnv(sharedDir, backend, async () => {
949
+ await generateMetaFn(sharedDir, {
950
+ debug,
951
+ silent: true,
952
+ scope: "all",
953
+ trimSegments
954
+ });
953
955
  });
954
956
  const { runtime, watcherPath } = resolveWatcherCommand();
955
957
  const watcherProcess = execaFn(runtime, [watcherPath], {
@@ -173,18 +173,10 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
173
173
  };
174
174
  }, Promise<any>>;
175
175
  deleteMany: convex_server0.RegisteredMutation<"internal", {
176
- paginationOpts: {
177
- id?: number;
178
- endCursor?: string | null;
179
- maximumRowsRead?: number;
180
- maximumBytesRead?: number;
181
- numItems: number;
182
- cursor: string | null;
183
- };
184
176
  input: {
185
177
  where?: {
186
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
187
178
  connector?: "AND" | "OR" | undefined;
179
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
188
180
  value: string | number | boolean | string[] | number[] | null;
189
181
  field: string;
190
182
  }[] | undefined;
@@ -193,6 +185,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
193
185
  where?: any[] | undefined;
194
186
  model: string;
195
187
  };
188
+ paginationOpts: {
189
+ id?: number;
190
+ endCursor?: string | null;
191
+ maximumRowsRead?: number;
192
+ maximumBytesRead?: number;
193
+ numItems: number;
194
+ cursor: string | null;
195
+ };
196
196
  }, Promise<{
197
197
  count: number;
198
198
  ids: any[];
@@ -204,8 +204,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
204
204
  deleteOne: convex_server0.RegisteredMutation<"internal", {
205
205
  input: {
206
206
  where?: {
207
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
208
207
  connector?: "AND" | "OR" | undefined;
208
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
209
209
  value: string | number | boolean | string[] | number[] | null;
210
210
  field: string;
211
211
  }[] | undefined;
@@ -216,19 +216,20 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
216
216
  };
217
217
  }, Promise<Record<string, unknown> | undefined>>;
218
218
  findMany: convex_server0.RegisteredQuery<"internal", {
219
- limit?: number | undefined;
220
219
  join?: any;
221
220
  where?: {
222
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
223
221
  connector?: "AND" | "OR" | undefined;
222
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
224
223
  value: string | number | boolean | string[] | number[] | null;
225
224
  field: string;
226
225
  }[] | undefined;
226
+ limit?: number | undefined;
227
227
  offset?: number | undefined;
228
228
  sortBy?: {
229
229
  field: string;
230
230
  direction: "asc" | "desc";
231
231
  } | undefined;
232
+ model: string;
232
233
  paginationOpts: {
233
234
  id?: number;
234
235
  endCursor?: string | null;
@@ -237,47 +238,46 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
237
238
  numItems: number;
238
239
  cursor: string | null;
239
240
  };
240
- model: string;
241
241
  }, Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>>;
242
242
  findOne: convex_server0.RegisteredQuery<"internal", {
243
243
  join?: any;
244
+ select?: string[] | undefined;
244
245
  where?: {
245
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
246
246
  connector?: "AND" | "OR" | undefined;
247
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
247
248
  value: string | number | boolean | string[] | number[] | null;
248
249
  field: string;
249
250
  }[] | undefined;
250
- select?: string[] | undefined;
251
251
  model: string;
252
252
  }, Promise<convex_server0.GenericDocument | null>>;
253
253
  getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
254
254
  rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
255
255
  updateMany: convex_server0.RegisteredMutation<"internal", {
256
- paginationOpts: {
257
- id?: number;
258
- endCursor?: string | null;
259
- maximumRowsRead?: number;
260
- maximumBytesRead?: number;
261
- numItems: number;
262
- cursor: string | null;
263
- };
264
256
  input: {
265
257
  where?: {
266
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
267
258
  connector?: "AND" | "OR" | undefined;
259
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
268
260
  value: string | number | boolean | string[] | number[] | null;
269
261
  field: string;
270
262
  }[] | undefined;
263
+ model: string;
271
264
  update: {
272
265
  [x: string]: unknown;
273
266
  [x: number]: unknown;
274
267
  [x: symbol]: unknown;
275
268
  };
276
- model: string;
277
269
  } | {
278
270
  where?: any[] | undefined;
279
- update: any;
280
271
  model: string;
272
+ update: any;
273
+ };
274
+ paginationOpts: {
275
+ id?: number;
276
+ endCursor?: string | null;
277
+ maximumRowsRead?: number;
278
+ maximumBytesRead?: number;
279
+ numItems: number;
280
+ cursor: string | null;
281
281
  };
282
282
  }, Promise<{
283
283
  count: number;
@@ -290,21 +290,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
290
290
  updateOne: convex_server0.RegisteredMutation<"internal", {
291
291
  input: {
292
292
  where?: {
293
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
294
293
  connector?: "AND" | "OR" | undefined;
294
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
295
295
  value: string | number | boolean | string[] | number[] | null;
296
296
  field: string;
297
297
  }[] | undefined;
298
+ model: string;
298
299
  update: {
299
300
  [x: string]: unknown;
300
301
  [x: number]: unknown;
301
302
  [x: symbol]: unknown;
302
303
  };
303
- model: string;
304
304
  } | {
305
305
  where?: any[] | undefined;
306
- update: any;
307
306
  model: string;
307
+ update: any;
308
308
  };
309
309
  }, Promise<any>>;
310
310
  };
@@ -1,4 +1,4 @@
1
- import { a as createMiddlewareFactory } from "./builder-CBdG5W6A.js";
1
+ import { a as createMiddlewareFactory } from "./builder-Bh18Y2t0.js";
2
2
 
3
3
  //#region src/plugins/middleware.ts
4
4
  const PLUGIN_CONFIG_RESOLVERS = Symbol.for("kitcn:PluginConfigResolvers");