kitcn 0.12.10 → 0.12.11

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/watcher.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as getConvexConfig, r as logger, t as generateMeta } from "./codegen-B60fOYhd.mjs";
2
+ import { N as resolveRunDeps, St as logger, bt as generateMeta, k as resolveConfiguredBackend, xt as getConvexConfig } from "./backend-core-DUsUG58E.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
@@ -8,6 +8,17 @@ function getWatchRoots(functionsDir) {
8
8
  const convexDir = path.dirname(functionsDir);
9
9
  return [functionsDir, path.join(convexDir, "routers")];
10
10
  }
11
+ function parseWatcherBackendEnv(value) {
12
+ if (value === "convex" || value === "concave") return value;
13
+ }
14
+ function resolveWatcherCliCommand(currentFilename = fileURLToPath(import.meta.url)) {
15
+ const currentDir = path.dirname(currentFilename);
16
+ const isTs = currentFilename.endsWith(".ts");
17
+ return {
18
+ cliPath: isTs ? path.join(currentDir, "cli.ts") : path.join(currentDir, "cli.mjs"),
19
+ runtime: isTs ? "bun" : "node"
20
+ };
21
+ }
11
22
  function parseTrimSegmentsEnv(value) {
12
23
  if (!value) return;
13
24
  const parseFromArray = (segments) => {
@@ -26,14 +37,54 @@ function shouldIgnoreWatchPath(watchedPath, functionsDir, outputFile) {
26
37
  const normalizedPath = path.resolve(watchedPath);
27
38
  const normalizedFunctionsDir = path.resolve(functionsDir);
28
39
  const normalizedOutputFile = path.resolve(outputFile);
40
+ const convexGeneratedDir = path.join(normalizedFunctionsDir, "_generated");
29
41
  const generatedDir = path.join(normalizedFunctionsDir, "generated");
30
42
  const generatedFile = path.join(normalizedFunctionsDir, "generated.ts");
31
43
  if (normalizedPath === normalizedOutputFile) return true;
32
44
  if (normalizedPath === generatedFile) return true;
45
+ if (normalizedPath === convexGeneratedDir || normalizedPath.startsWith(`${convexGeneratedDir}${path.sep}`)) return true;
33
46
  if (normalizedPath === generatedDir || normalizedPath.startsWith(`${generatedDir}${path.sep}`)) return true;
34
47
  return normalizedPath.endsWith(".runtime.ts");
35
48
  }
49
+ async function runWatcherCodegen(params, deps = {}) {
50
+ const resolveRunDepsFn = deps.resolveRunDeps ?? resolveRunDeps;
51
+ const resolveConfiguredBackendFn = deps.resolveConfiguredBackendFn ?? resolveConfiguredBackend;
52
+ const { execa: execaFn, generateMeta: generateMetaFn, loadCliConfig: loadCliConfigFn } = resolveRunDepsFn();
53
+ const config = loadCliConfigFn(params.configPath);
54
+ if (resolveConfiguredBackendFn({
55
+ backendArg: params.backendArg,
56
+ config
57
+ }) !== "concave") {
58
+ await generateMetaFn(params.sharedDir, {
59
+ debug: params.debug,
60
+ silent: true,
61
+ scope: params.scope,
62
+ trimSegments: params.trimSegments
63
+ });
64
+ return;
65
+ }
66
+ const { cliPath, runtime } = resolveWatcherCliCommand();
67
+ const args = [
68
+ cliPath,
69
+ "codegen",
70
+ "--backend",
71
+ "concave",
72
+ "--scope",
73
+ params.scope
74
+ ];
75
+ if (params.sharedDir) args.push("--api", params.sharedDir);
76
+ if (params.configPath) args.push("--config", params.configPath);
77
+ if (params.debug) args.push("--debug");
78
+ const result = await execaFn(runtime, args, {
79
+ cwd: process.cwd(),
80
+ reject: false,
81
+ stdio: "pipe"
82
+ });
83
+ if (result.exitCode !== 0) throw new Error(`Watcher codegen failed with exit code ${result.exitCode}.\n${`${result.stdout ?? ""}\n${result.stderr ?? ""}`.trim()}`);
84
+ }
36
85
  async function startWatcher(opts) {
86
+ const backendArg = opts?.backend ?? parseWatcherBackendEnv(process.env.KITCN_BACKEND);
87
+ const configPath = opts?.configPath ?? process.env.KITCN_CONFIG_PATH;
37
88
  const sharedDir = opts?.sharedDir ?? (process.env.KITCN_API_OUTPUT_DIR || void 0);
38
89
  const debug = opts?.debug ?? process.env.KITCN_DEBUG === "1";
39
90
  const scope = opts?.scope ?? process.env.KITCN_CODEGEN_SCOPE ?? "all";
@@ -41,6 +92,7 @@ async function startWatcher(opts) {
41
92
  const debounceMs = opts?.debounceMs ?? 100;
42
93
  const resolveConfig = opts?.getConvexConfig ?? getConvexConfig;
43
94
  const runGenerateMeta = opts?.generateMeta ?? generateMeta;
95
+ const runWatchCodegen = opts?.runWatcherCodegen ?? runWatcherCodegen;
44
96
  const { functionsDir, outputFile } = resolveConfig(sharedDir);
45
97
  const watchRoots = getWatchRoots(functionsDir);
46
98
  const watch = opts?.watch ?? (await import("chokidar")).watch;
@@ -63,7 +115,15 @@ async function startWatcher(opts) {
63
115
  }
64
116
  generateMetaInFlight = true;
65
117
  try {
66
- await runGenerateMeta(sharedDir, createGenerateOptions());
118
+ if (backendArg || configPath) await runWatchCodegen({
119
+ backendArg,
120
+ configPath,
121
+ debug,
122
+ scope,
123
+ sharedDir,
124
+ trimSegments
125
+ });
126
+ else await runGenerateMeta(sharedDir, createGenerateOptions());
67
127
  logger.success("Convex api updated");
68
128
  } catch (error) {
69
129
  logger.error("Watch codegen error:", error);
@@ -93,4 +153,4 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
93
153
  });
94
154
 
95
155
  //#endregion
96
- export { getWatchRoots, shouldIgnoreWatchPath, startWatcher };
156
+ export { getWatchRoots, runWatcherCodegen, shouldIgnoreWatchPath, startWatcher };
@@ -3717,19 +3717,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3717
3717
  readonly aggregate_bucket: ConvexTableWithColumns<{
3718
3718
  name: "aggregate_bucket";
3719
3719
  columns: {
3720
- count: ConvexNumberBuilderInitial<""> & {
3721
- _: {
3722
- notNull: true;
3723
- };
3724
- } & {
3725
- _: {
3726
- tableName: "aggregate_bucket";
3727
- };
3728
- } & {
3729
- _: {
3730
- fieldName: "count";
3731
- };
3732
- };
3733
3720
  tableKey: ConvexTextBuilderInitial<""> & {
3734
3721
  _: {
3735
3722
  notNull: true;
@@ -3799,6 +3786,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3799
3786
  fieldName: "keyParts";
3800
3787
  };
3801
3788
  };
3789
+ count: ConvexNumberBuilderInitial<""> & {
3790
+ _: {
3791
+ notNull: true;
3792
+ };
3793
+ } & {
3794
+ _: {
3795
+ tableName: "aggregate_bucket";
3796
+ };
3797
+ } & {
3798
+ _: {
3799
+ fieldName: "count";
3800
+ };
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>>>) & {
3803
3803
  _: {
3804
3804
  tableName: "aggregate_bucket";
@@ -3826,7 +3826,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3826
3826
  readonly aggregate_member: ConvexTableWithColumns<{
3827
3827
  name: "aggregate_member";
3828
3828
  columns: {
3829
- kind: ConvexTextBuilderInitial<""> & {
3829
+ tableKey: ConvexTextBuilderInitial<""> & {
3830
3830
  _: {
3831
3831
  notNull: true;
3832
3832
  };
@@ -3836,10 +3836,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3836
3836
  };
3837
3837
  } & {
3838
3838
  _: {
3839
- fieldName: "kind";
3839
+ fieldName: "tableKey";
3840
3840
  };
3841
3841
  };
3842
- tableKey: ConvexTextBuilderInitial<""> & {
3842
+ kind: ConvexTextBuilderInitial<""> & {
3843
3843
  _: {
3844
3844
  notNull: true;
3845
3845
  };
@@ -3849,7 +3849,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3849
3849
  };
3850
3850
  } & {
3851
3851
  _: {
3852
- fieldName: "tableKey";
3852
+ fieldName: "kind";
3853
3853
  };
3854
3854
  };
3855
3855
  indexName: ConvexTextBuilderInitial<""> & {
@@ -3992,11 +3992,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3992
3992
  readonly aggregate_extrema: ConvexTableWithColumns<{
3993
3993
  name: "aggregate_extrema";
3994
3994
  columns: {
3995
- value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
3996
- _: {
3997
- $type: convex_values0.Value;
3998
- };
3999
- } & {
3995
+ tableKey: ConvexTextBuilderInitial<""> & {
4000
3996
  _: {
4001
3997
  notNull: true;
4002
3998
  };
@@ -4006,10 +4002,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4006
4002
  };
4007
4003
  } & {
4008
4004
  _: {
4009
- fieldName: "value";
4005
+ fieldName: "tableKey";
4010
4006
  };
4011
4007
  };
4012
- count: ConvexNumberBuilderInitial<""> & {
4008
+ indexName: ConvexTextBuilderInitial<""> & {
4013
4009
  _: {
4014
4010
  notNull: true;
4015
4011
  };
@@ -4019,10 +4015,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4019
4015
  };
4020
4016
  } & {
4021
4017
  _: {
4022
- fieldName: "count";
4018
+ fieldName: "indexName";
4023
4019
  };
4024
4020
  };
4025
- tableKey: ConvexTextBuilderInitial<""> & {
4021
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4026
4022
  _: {
4027
4023
  notNull: true;
4028
4024
  };
@@ -4032,10 +4028,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4032
4028
  };
4033
4029
  } & {
4034
4030
  _: {
4035
- fieldName: "tableKey";
4031
+ fieldName: "updatedAt";
4036
4032
  };
4037
4033
  };
4038
- indexName: ConvexTextBuilderInitial<""> & {
4034
+ value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
4035
+ _: {
4036
+ $type: convex_values0.Value;
4037
+ };
4038
+ } & {
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: "indexName";
4048
+ fieldName: "value";
4049
4049
  };
4050
4050
  };
4051
- updatedAt: ConvexNumberBuilderInitial<""> & {
4051
+ keyHash: 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: "updatedAt";
4061
+ fieldName: "keyHash";
4062
4062
  };
4063
4063
  };
4064
- keyHash: ConvexTextBuilderInitial<""> & {
4064
+ count: ConvexNumberBuilderInitial<""> & {
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: "keyHash";
4074
+ fieldName: "count";
4075
4075
  };
4076
4076
  };
4077
4077
  fieldName: ConvexTextBuilderInitial<""> & {
@@ -4244,7 +4244,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4244
4244
  readonly aggregate_state: ConvexTableWithColumns<{
4245
4245
  name: "aggregate_state";
4246
4246
  columns: {
4247
- kind: ConvexTextBuilderInitial<""> & {
4247
+ tableKey: ConvexTextBuilderInitial<""> & {
4248
4248
  _: {
4249
4249
  notNull: true;
4250
4250
  };
@@ -4254,19 +4254,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4254
4254
  };
4255
4255
  } & {
4256
4256
  _: {
4257
- fieldName: "kind";
4258
- };
4259
- };
4260
- cursor: ConvexTextBuilderInitial<""> & {
4261
- _: {
4262
- tableName: "aggregate_state";
4263
- };
4264
- } & {
4265
- _: {
4266
- fieldName: "cursor";
4257
+ fieldName: "tableKey";
4267
4258
  };
4268
4259
  };
4269
- tableKey: ConvexTextBuilderInitial<""> & {
4260
+ kind: ConvexTextBuilderInitial<""> & {
4270
4261
  _: {
4271
4262
  notNull: true;
4272
4263
  };
@@ -4276,7 +4267,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4276
4267
  };
4277
4268
  } & {
4278
4269
  _: {
4279
- fieldName: "tableKey";
4270
+ fieldName: "kind";
4280
4271
  };
4281
4272
  };
4282
4273
  indexName: ConvexTextBuilderInitial<""> & {
@@ -4331,6 +4322,15 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4331
4322
  fieldName: "status";
4332
4323
  };
4333
4324
  };
4325
+ cursor: ConvexTextBuilderInitial<""> & {
4326
+ _: {
4327
+ tableName: "aggregate_state";
4328
+ };
4329
+ } & {
4330
+ _: {
4331
+ fieldName: "cursor";
4332
+ };
4333
+ };
4334
4334
  processed: ConvexNumberBuilderInitial<""> & {
4335
4335
  _: {
4336
4336
  notNull: true;
@@ -4398,35 +4398,26 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4398
4398
  readonly migration_state: ConvexTableWithColumns<{
4399
4399
  name: "migration_state";
4400
4400
  columns: {
4401
- cursor: ConvexTextBuilderInitial<""> & {
4401
+ status: ConvexTextBuilderInitial<""> & {
4402
4402
  _: {
4403
- tableName: "migration_state";
4403
+ notNull: true;
4404
4404
  };
4405
4405
  } & {
4406
- _: {
4407
- fieldName: "cursor";
4408
- };
4409
- };
4410
- direction: ConvexTextBuilderInitial<""> & {
4411
4406
  _: {
4412
4407
  tableName: "migration_state";
4413
4408
  };
4414
4409
  } & {
4415
4410
  _: {
4416
- fieldName: "direction";
4411
+ fieldName: "status";
4417
4412
  };
4418
4413
  };
4419
- status: ConvexTextBuilderInitial<""> & {
4420
- _: {
4421
- notNull: true;
4422
- };
4423
- } & {
4414
+ cursor: ConvexTextBuilderInitial<""> & {
4424
4415
  _: {
4425
4416
  tableName: "migration_state";
4426
4417
  };
4427
4418
  } & {
4428
4419
  _: {
4429
- fieldName: "status";
4420
+ fieldName: "cursor";
4430
4421
  };
4431
4422
  };
4432
4423
  processed: ConvexNumberBuilderInitial<""> & {
@@ -4521,6 +4512,15 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4521
4512
  fieldName: "applied";
4522
4513
  };
4523
4514
  };
4515
+ direction: ConvexTextBuilderInitial<""> & {
4516
+ _: {
4517
+ tableName: "migration_state";
4518
+ };
4519
+ } & {
4520
+ _: {
4521
+ fieldName: "direction";
4522
+ };
4523
+ };
4524
4524
  runId: ConvexTextBuilderInitial<""> & {
4525
4525
  _: {
4526
4526
  tableName: "migration_state";
@@ -4552,19 +4552,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4552
4552
  readonly migration_run: ConvexTableWithColumns<{
4553
4553
  name: "migration_run";
4554
4554
  columns: {
4555
- direction: ConvexTextBuilderInitial<""> & {
4556
- _: {
4557
- notNull: true;
4558
- };
4559
- } & {
4560
- _: {
4561
- tableName: "migration_run";
4562
- };
4563
- } & {
4564
- _: {
4565
- fieldName: "direction";
4566
- };
4567
- };
4568
4555
  status: ConvexTextBuilderInitial<""> & {
4569
4556
  _: {
4570
4557
  notNull: true;
@@ -4622,6 +4609,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4622
4609
  fieldName: "lastError";
4623
4610
  };
4624
4611
  };
4612
+ direction: ConvexTextBuilderInitial<""> & {
4613
+ _: {
4614
+ notNull: true;
4615
+ };
4616
+ } & {
4617
+ _: {
4618
+ tableName: "migration_run";
4619
+ };
4620
+ } & {
4621
+ _: {
4622
+ fieldName: "direction";
4623
+ };
4624
+ };
4625
4625
  runId: ConvexTextBuilderInitial<""> & {
4626
4626
  _: {
4627
4627
  notNull: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.12.10",
3
+ "version": "0.12.11",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -272,7 +272,15 @@ Repair / remote sync:
272
272
  bunx kitcn env push
273
273
  ```
274
274
 
275
- Use this for `--prod` or explicit repair against an already active deployment.
275
+ Use this to sync static `JWKS` onto the target deployment too.
276
+
277
+ ```bash
278
+ bunx kitcn env push --prod
279
+ bunx kitcn env push --rotate
280
+ ```
281
+
282
+ Use `--prod` for production and `--rotate` when you want fresh keys plus fresh
283
+ `JWKS`. See `/docs/cli/backend#env` for the full env command surface.
276
284
 
277
285
  Rotate later:
278
286