better-convex 0.10.2 → 0.10.3

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.
@@ -182,13 +182,13 @@ type AdapterPaginationOptions = PaginationOptions & {
182
182
  };
183
183
  declare const adapterWhereValidator: convex_values0.VObject<{
184
184
  connector?: "AND" | "OR" | undefined;
185
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
185
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
186
186
  value: string | number | boolean | string[] | number[] | null;
187
187
  field: string;
188
188
  }, {
189
189
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
190
190
  field: convex_values0.VString<string, "required">;
191
- operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
191
+ operator: convex_values0.VUnion<"in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
192
192
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
193
193
  }, "required", "value" | "connector" | "field" | "operator">;
194
194
  declare const adapterArgsValidator: convex_values0.VObject<{
@@ -201,7 +201,7 @@ declare const adapterArgsValidator: convex_values0.VObject<{
201
201
  } | undefined;
202
202
  where?: {
203
203
  connector?: "AND" | "OR" | undefined;
204
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
204
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
205
205
  value: string | number | boolean | string[] | number[] | null;
206
206
  field: string;
207
207
  }[] | undefined;
@@ -220,18 +220,18 @@ declare const adapterArgsValidator: convex_values0.VObject<{
220
220
  }, "optional", "direction" | "field">;
221
221
  where: convex_values0.VArray<{
222
222
  connector?: "AND" | "OR" | undefined;
223
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
223
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
224
224
  value: string | number | boolean | string[] | number[] | null;
225
225
  field: string;
226
226
  }[] | undefined, convex_values0.VObject<{
227
227
  connector?: "AND" | "OR" | undefined;
228
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
228
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
229
229
  value: string | number | boolean | string[] | number[] | null;
230
230
  field: string;
231
231
  }, {
232
232
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
233
233
  field: convex_values0.VString<string, "required">;
234
- operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
234
+ operator: convex_values0.VUnion<"in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
235
235
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
236
236
  }, "required", "value" | "connector" | "field" | "operator">, "optional">;
237
237
  }, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.direction" | "sortBy.field">;
@@ -359,18 +359,10 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
359
359
  };
360
360
  }, Promise<any>>;
361
361
  deleteMany: convex_server0.RegisteredMutation<"internal", {
362
- paginationOpts: {
363
- id?: number;
364
- endCursor?: string | null;
365
- maximumRowsRead?: number;
366
- maximumBytesRead?: number;
367
- numItems: number;
368
- cursor: string | null;
369
- };
370
362
  input: {
371
363
  where?: {
372
364
  connector?: "AND" | "OR" | undefined;
373
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
365
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
374
366
  value: string | number | boolean | string[] | number[] | null;
375
367
  field: string;
376
368
  }[] | undefined;
@@ -379,6 +371,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
379
371
  where?: any[] | undefined;
380
372
  model: string;
381
373
  };
374
+ paginationOpts: {
375
+ id?: number;
376
+ endCursor?: string | null;
377
+ maximumRowsRead?: number;
378
+ maximumBytesRead?: number;
379
+ numItems: number;
380
+ cursor: string | null;
381
+ };
382
382
  }, Promise<{
383
383
  count: number;
384
384
  ids: any[];
@@ -391,7 +391,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
391
391
  input: {
392
392
  where?: {
393
393
  connector?: "AND" | "OR" | undefined;
394
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
394
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
395
395
  value: string | number | boolean | string[] | number[] | null;
396
396
  field: string;
397
397
  }[] | undefined;
@@ -402,8 +402,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
402
402
  };
403
403
  }, Promise<Record<string, unknown> | undefined>>;
404
404
  findMany: convex_server0.RegisteredQuery<"internal", {
405
- join?: any;
406
405
  limit?: number | undefined;
406
+ join?: any;
407
407
  offset?: number | undefined;
408
408
  sortBy?: {
409
409
  direction: "asc" | "desc";
@@ -411,7 +411,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
411
411
  } | undefined;
412
412
  where?: {
413
413
  connector?: "AND" | "OR" | undefined;
414
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
414
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
415
415
  value: string | number | boolean | string[] | number[] | null;
416
416
  field: string;
417
417
  }[] | undefined;
@@ -430,7 +430,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
430
430
  select?: string[] | undefined;
431
431
  where?: {
432
432
  connector?: "AND" | "OR" | undefined;
433
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
433
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
434
434
  value: string | number | boolean | string[] | number[] | null;
435
435
  field: string;
436
436
  }[] | undefined;
@@ -439,18 +439,10 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
439
439
  getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
440
440
  rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
441
441
  updateMany: convex_server0.RegisteredMutation<"internal", {
442
- paginationOpts: {
443
- id?: number;
444
- endCursor?: string | null;
445
- maximumRowsRead?: number;
446
- maximumBytesRead?: number;
447
- numItems: number;
448
- cursor: string | null;
449
- };
450
442
  input: {
451
443
  where?: {
452
444
  connector?: "AND" | "OR" | undefined;
453
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
445
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
454
446
  value: string | number | boolean | string[] | number[] | null;
455
447
  field: string;
456
448
  }[] | undefined;
@@ -465,6 +457,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
465
457
  update: any;
466
458
  model: string;
467
459
  };
460
+ paginationOpts: {
461
+ id?: number;
462
+ endCursor?: string | null;
463
+ maximumRowsRead?: number;
464
+ maximumBytesRead?: number;
465
+ numItems: number;
466
+ cursor: string | null;
467
+ };
468
468
  }, Promise<{
469
469
  count: number;
470
470
  ids: any[];
@@ -477,7 +477,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
477
477
  input: {
478
478
  where?: {
479
479
  connector?: "AND" | "OR" | undefined;
480
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
480
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
481
481
  value: string | number | boolean | string[] | number[] | null;
482
482
  field: string;
483
483
  }[] | undefined;
@@ -19155,18 +19155,10 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19155
19155
  };
19156
19156
  }, Promise<any>>;
19157
19157
  deleteMany: convex_server0.RegisteredMutation<"internal", {
19158
- paginationOpts: {
19159
- id?: number;
19160
- endCursor?: string | null;
19161
- maximumRowsRead?: number;
19162
- maximumBytesRead?: number;
19163
- numItems: number;
19164
- cursor: string | null;
19165
- };
19166
19158
  input: {
19167
19159
  where?: {
19168
19160
  connector?: "AND" | "OR" | undefined;
19169
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19161
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19170
19162
  value: string | number | boolean | string[] | number[] | null;
19171
19163
  field: string;
19172
19164
  }[] | undefined;
@@ -19175,6 +19167,14 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19175
19167
  where?: any[] | undefined;
19176
19168
  model: string;
19177
19169
  };
19170
+ paginationOpts: {
19171
+ id?: number;
19172
+ endCursor?: string | null;
19173
+ maximumRowsRead?: number;
19174
+ maximumBytesRead?: number;
19175
+ numItems: number;
19176
+ cursor: string | null;
19177
+ };
19178
19178
  }, Promise<{
19179
19179
  count: number;
19180
19180
  ids: any[];
@@ -19187,7 +19187,7 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19187
19187
  input: {
19188
19188
  where?: {
19189
19189
  connector?: "AND" | "OR" | undefined;
19190
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19190
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19191
19191
  value: string | number | boolean | string[] | number[] | null;
19192
19192
  field: string;
19193
19193
  }[] | undefined;
@@ -19198,8 +19198,8 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19198
19198
  };
19199
19199
  }, Promise<Record<string, unknown> | undefined>>;
19200
19200
  findMany: convex_server0.RegisteredQuery<"internal", {
19201
- join?: any;
19202
19201
  limit?: number | undefined;
19202
+ join?: any;
19203
19203
  offset?: number | undefined;
19204
19204
  sortBy?: {
19205
19205
  direction: "asc" | "desc";
@@ -19207,7 +19207,7 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19207
19207
  } | undefined;
19208
19208
  where?: {
19209
19209
  connector?: "AND" | "OR" | undefined;
19210
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19210
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19211
19211
  value: string | number | boolean | string[] | number[] | null;
19212
19212
  field: string;
19213
19213
  }[] | undefined;
@@ -19226,7 +19226,7 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19226
19226
  select?: string[] | undefined;
19227
19227
  where?: {
19228
19228
  connector?: "AND" | "OR" | undefined;
19229
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19229
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19230
19230
  value: string | number | boolean | string[] | number[] | null;
19231
19231
  field: string;
19232
19232
  }[] | undefined;
@@ -19235,18 +19235,10 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19235
19235
  getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
19236
19236
  rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
19237
19237
  updateMany: convex_server0.RegisteredMutation<"internal", {
19238
- paginationOpts: {
19239
- id?: number;
19240
- endCursor?: string | null;
19241
- maximumRowsRead?: number;
19242
- maximumBytesRead?: number;
19243
- numItems: number;
19244
- cursor: string | null;
19245
- };
19246
19238
  input: {
19247
19239
  where?: {
19248
19240
  connector?: "AND" | "OR" | undefined;
19249
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19241
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19250
19242
  value: string | number | boolean | string[] | number[] | null;
19251
19243
  field: string;
19252
19244
  }[] | undefined;
@@ -19261,6 +19253,14 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19261
19253
  update: any;
19262
19254
  model: string;
19263
19255
  };
19256
+ paginationOpts: {
19257
+ id?: number;
19258
+ endCursor?: string | null;
19259
+ maximumRowsRead?: number;
19260
+ maximumBytesRead?: number;
19261
+ numItems: number;
19262
+ cursor: string | null;
19263
+ };
19264
19264
  }, Promise<{
19265
19265
  count: number;
19266
19266
  ids: any[];
@@ -19273,7 +19273,7 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19273
19273
  input: {
19274
19274
  where?: {
19275
19275
  connector?: "AND" | "OR" | undefined;
19276
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19276
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19277
19277
  value: string | number | boolean | string[] | number[] | null;
19278
19278
  field: string;
19279
19279
  }[] | undefined;
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as getConvexConfig, t as generateMeta } from "./codegen-CJiil63j.mjs";
2
+ import { n as getConvexConfig, t as generateMeta } from "./codegen-69-_7r9o.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash } from "node:crypto";
5
5
  import fs from "node:fs";
@@ -240,6 +240,10 @@ function getSchemaImportPath(outputFile, functionsDir) {
240
240
  const schemaFile = path.join(functionsDir, "schema");
241
241
  return ensureRelativeImportPath(normalizeImportPath(path.relative(path.dirname(outputFile), schemaFile)));
242
242
  }
243
+ function getTriggersImportPath(outputFile, functionsDir) {
244
+ const triggersFile = path.join(functionsDir, "triggers");
245
+ return ensureRelativeImportPath(normalizeImportPath(path.relative(path.dirname(outputFile), triggersFile)));
246
+ }
243
247
  function getServerTypesImportPath(outputFile, functionsDir) {
244
248
  const serverTypesFile = path.join(functionsDir, "_generated", "server");
245
249
  return ensureRelativeImportPath(normalizeImportPath(path.relative(path.dirname(outputFile), serverTypesFile)));
@@ -368,17 +372,19 @@ function listGeneratedRuntimeFiles(functionsDir) {
368
372
  if (!fs.existsSync(generatedDir)) return [];
369
373
  return listFilesRecursive(generatedDir).filter((file) => file.endsWith(".runtime.ts")).map((file) => path.join(generatedDir, file));
370
374
  }
371
- function emitGeneratedServerFile(outputFile, functionsDir, hasRelationsExport, hasTriggersExport, hasMigrationsManifest) {
375
+ function emitGeneratedServerFile(outputFile, functionsDir, hasRelationsExport, hasTriggersExport, triggersImportSource, hasMigrationsManifest) {
372
376
  const asSingleQuotedImport = (importPath) => `'${importPath.replaceAll("'", "\\'")}'`;
373
377
  const serverTypesImportPath = getServerTypesImportPath(outputFile, functionsDir);
374
378
  const dataModelImportPath = getDataModelImportPath(outputFile, functionsDir);
375
379
  const runtimeApiImportPath = getRuntimeApiImportPath(outputFile, functionsDir);
376
380
  const schemaImportPath = getSchemaImportPath(outputFile, functionsDir);
381
+ const triggersImportPath = getTriggersImportPath(outputFile, functionsDir);
377
382
  const migrationsManifestImportPath = getModuleImportPath(outputFile, functionsDir, "migrations/manifest");
378
383
  const serverTypesImportLiteral = asSingleQuotedImport(serverTypesImportPath);
379
384
  const dataModelImportLiteral = asSingleQuotedImport(dataModelImportPath);
380
385
  const runtimeApiImportLiteral = asSingleQuotedImport(runtimeApiImportPath);
381
386
  const schemaImportLiteral = asSingleQuotedImport(schemaImportPath);
387
+ const triggersImportLiteral = asSingleQuotedImport(triggersImportPath);
382
388
  const migrationsManifestImportLiteral = asSingleQuotedImport(migrationsManifestImportPath);
383
389
  if (!hasRelationsExport) return `// biome-ignore-all format: generated
384
390
  // This file is auto-generated by better-convex
@@ -399,7 +405,7 @@ export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
399
405
  export const initCRPC = baseInitCRPC.dataModel<DataModel>();
400
406
  `;
401
407
  const ormFunctionsAccessor = getAccessPath("(internal as unknown as Record<string, any>)", getModuleNameFromOutputFile(outputFile, functionsDir).split("/").filter(Boolean));
402
- const schemaNamedImports = hasTriggersExport ? "relations, triggers" : "relations";
408
+ const schemaNamedImports = hasTriggersExport && triggersImportSource === "schema" ? "relations, triggers" : "relations";
403
409
  const triggersConfigLine = hasTriggersExport ? " triggers,\n" : "";
404
410
  return `// biome-ignore-all format: generated
405
411
  // This file is auto-generated by better-convex
@@ -416,6 +422,7 @@ import type {
416
422
  } from ${serverTypesImportLiteral};
417
423
  import { internalMutation } from ${serverTypesImportLiteral};
418
424
  import schema, { ${schemaNamedImports} } from ${schemaImportLiteral};
425
+ ${hasTriggersExport && triggersImportSource === "triggers" ? `import { triggers } from ${triggersImportLiteral};\n` : ""}
419
426
  ${hasMigrationsManifest ? `import { migrations } from ${migrationsManifestImportLiteral};\n` : ""}
420
427
 
421
428
  const ormFunctions = ${ormFunctionsAccessor} as OrmFunctions;
@@ -959,9 +966,12 @@ async function generateMeta(outputDir, options) {
959
966
  hasAuthDefaultExport
960
967
  };
961
968
  const hasRelationsExport = hasNamedExport(path.join(functionsDir, "schema.ts"), "relations");
962
- const hasTriggersExport = hasNamedExport(path.join(functionsDir, "schema.ts"), "triggers");
969
+ const hasSchemaTriggersExport = hasNamedExport(path.join(functionsDir, "schema.ts"), "triggers");
970
+ const hasDedicatedTriggersExport = hasNamedExport(path.join(functionsDir, "triggers.ts"), "triggers");
971
+ const hasTriggersExport = hasSchemaTriggersExport || hasDedicatedTriggersExport;
972
+ const triggersImportSource = hasDedicatedTriggersExport ? "triggers" : "schema";
963
973
  const hasMigrationsManifest = fs.existsSync(path.join(functionsDir, "migrations", "manifest.ts"));
964
- if (hasTriggersExport && !hasRelationsExport) throw new Error("Codegen error: schema.ts exports 'triggers' but is missing 'relations'. Export `relations` and define triggers via `defineTriggers(relations, { ... })`.");
974
+ if (hasTriggersExport && !hasRelationsExport) throw new Error("Codegen error: triggers require a 'relations' export from schema.ts. Export `relations` from schema.ts and define triggers via `defineTriggers(relations, { ... })` in schema.ts or triggers.ts.");
965
975
  ensureGeneratedSupportPlaceholders(functionsDir, { includeAuth: generateAuth });
966
976
  if (generateApi) {
967
977
  globalThis.__BETTER_CONVEX_CODEGEN__ = true;
@@ -1062,7 +1072,7 @@ ${optionalTypeExports}
1062
1072
  if (!fs.existsSync(outputDirname)) fs.mkdirSync(outputDirname, { recursive: true });
1063
1073
  fs.writeFileSync(outputFile, output);
1064
1074
  } else fs.rmSync(outputFile, { force: true });
1065
- const serverOutput = emitGeneratedServerFile(serverOutputFile, functionsDir, hasRelationsExport, hasTriggersExport, hasMigrationsManifest);
1075
+ const serverOutput = emitGeneratedServerFile(serverOutputFile, functionsDir, hasRelationsExport, hasTriggersExport, triggersImportSource, hasMigrationsManifest);
1066
1076
  const generatedOutputDirname = path.dirname(serverOutputFile);
1067
1077
  if (!fs.existsSync(generatedOutputDirname)) fs.mkdirSync(generatedOutputDirname, { recursive: true });
1068
1078
  fs.writeFileSync(serverOutputFile, serverOutput);
package/dist/watcher.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as getConvexConfig, t as generateMeta } from "./codegen-CJiil63j.mjs";
2
+ import { n as getConvexConfig, t as generateMeta } from "./codegen-69-_7r9o.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-convex",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Better Convex - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",