Skip to content

Commit 6f1b4f0

Browse files
authored
Update convex to 1.31.0 (#880)
1 parent 517edcf commit 6f1b4f0

File tree

6 files changed

+22
-67
lines changed

6 files changed

+22
-67
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"dependencies": {
2929
"classnames": "^2.3.2",
30-
"convex": "^1.29.0",
30+
"convex": "^1.31.0",
3131
"convex-helpers": "file:packages/convex-helpers/dist",
3232
"hono": "^4.3.6",
3333
"react": "^19.2.3",
@@ -53,7 +53,7 @@
5353
"@vitejs/plugin-react": "5.1.1",
5454
"@vitest/coverage-v8": "3.2.4",
5555
"chokidar-cli": "3.0.0",
56-
"convex": "1.29.3",
56+
"convex": "1.31.0",
5757
"convex-test": "0.0.39",
5858
"eslint": "9.39.1",
5959
"eslint-plugin-react": "7.37.5",

packages/convex-helpers/server/rowLevelSecurity.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,11 @@ describe("row level security", () => {
128128
await expect(() =>
129129
asB.run(async (ctx) => {
130130
const rls = await withRLS(ctx);
131-
// @ts-expect-error - testing new explicit table name API
132131
return rls.db.delete("notes", noteId);
133132
}),
134133
).rejects.toThrow(/no read access/);
135134
await asA.run(async (ctx) => {
136135
const rls = await withRLS(ctx);
137-
// @ts-expect-error - testing new explicit table name API
138136
return rls.db.delete("notes", noteId);
139137
});
140138
});
@@ -358,7 +356,6 @@ describe("row level security", () => {
358356
);
359357

360358
// Should be able to modify (no modify rule, default allow)
361-
// @ts-expect-error - testing new explicit table name API
362359
await db.patch("publicData", docId, { content: "Modified content" });
363360
});
364361

@@ -381,7 +378,6 @@ describe("row level security", () => {
381378
);
382379

383380
// Should NOT be able to modify (no modify rule, default deny)
384-
// @ts-expect-error - testing new explicit table name API
385381
await db.patch("publicData", docId, {
386382
content: "Blocked modification",
387383
});

packages/convex-helpers/server/rowLevelSecurity.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@ class WrapWriter<Ctx, DataModel extends GenericDataModel>
369369
arg2 !== undefined ? [arg0, arg1, arg2] : [null, arg0, arg1];
370370
await this.checkAuth(tableName, id);
371371
return tableName
372-
? // @ts-expect-error -- patch supports 3 args since convex@1.25.4
373-
this.db.patch(tableName, id, value)
372+
? this.db.patch(tableName, id, value)
374373
: this.db.patch(id, value);
375374
}
376375

@@ -388,8 +387,7 @@ class WrapWriter<Ctx, DataModel extends GenericDataModel>
388387
arg2 !== undefined ? [arg0, arg1, arg2] : [null, arg0, arg1];
389388
await this.checkAuth(tableName, id);
390389
return tableName
391-
? // @ts-expect-error -- replace supports 3 args since convex@1.25.4
392-
this.db.replace(tableName, id, value)
390+
? this.db.replace(tableName, id, value)
393391
: this.db.replace(id, value);
394392
}
395393

@@ -403,10 +401,7 @@ class WrapWriter<Ctx, DataModel extends GenericDataModel>
403401
arg1 !== undefined ? [arg0, arg1] : [null, arg0];
404402
await this.checkAuth(tableName, id);
405403

406-
return tableName
407-
? // @ts-expect-error -- delete supports 2 args since convex@1.25.4
408-
this.db.delete(tableName, id)
409-
: this.db.delete(id);
404+
return tableName ? this.db.delete(tableName, id) : this.db.delete(id);
410405
}
411406

412407
get<TableName extends TableNamesInDataModel<DataModel>>(
@@ -417,7 +412,6 @@ class WrapWriter<Ctx, DataModel extends GenericDataModel>
417412
id: GenericId<TableName>,
418413
): Promise<DocumentByName<DataModel, TableName> | null>;
419414
get(arg0: any, arg1?: any): Promise<any> {
420-
// @ts-expect-error -- get supports 2 args since convex@1.25.4
421415
return this.reader.get(arg0, arg1);
422416
}
423417
query<TableName extends string>(tableName: TableName): QueryInitializer<any> {

packages/convex-helpers/server/triggers.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ triggers.register("usersExplicit", async (ctx, change) => {
5050
if (change.newDoc) {
5151
const fullName = `${change.newDoc.firstName} ${change.newDoc.lastName}`;
5252
if (change.newDoc.fullName !== fullName) {
53-
await ctx.db.patch(
54-
"usersExplicit",
55-
change.id,
56-
// @ts-expect-error -- patch supports 3 args since convex@1.25.4, but the type is marked as internal
57-
{ fullName },
58-
);
53+
await ctx.db.patch("usersExplicit", change.id, { fullName });
5954
}
6055
}
6156
});
@@ -64,10 +59,12 @@ triggers.register("usersExplicitIncorrectTable", async (ctx, change) => {
6459
const fullName = `${change.newDoc.firstName} ${change.newDoc.lastName}`;
6560
if (change.newDoc.fullName !== fullName) {
6661
await ctx.db.patch(
62+
// @ts-expect-error -- this code uses the wrong table name so it shouldn’t typecheck
6763
"users",
6864
change.id,
69-
// @ts-expect-error -- patch supports 3 args since convex@1.25.4, but the type is marked as internal
70-
{ fullName },
65+
{
66+
fullName,
67+
},
7168
);
7269
}
7370
}

packages/convex-helpers/server/triggers.ts

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,7 @@ export class DatabaseWriterWithTriggers<
176176
): Promise<void>;
177177
delete(id: GenericId<TableNamesInDataModel<DataModel>>): Promise<void>;
178178
delete(arg0: any, arg1?: any): Promise<void> {
179-
return this.writer.delete(
180-
arg0,
181-
// @ts-expect-error -- delete supports 2 args since convex@1.25.4, but the type is marked as internal
182-
arg1,
183-
);
179+
return this.writer.delete(arg0, arg1);
184180
}
185181

186182
get<TableName extends TableNamesInDataModel<DataModel>>(
@@ -191,11 +187,7 @@ export class DatabaseWriterWithTriggers<
191187
id: GenericId<TableName>,
192188
): Promise<DocumentByName<DataModel, TableName> | null>;
193189
get(arg0: any, arg1?: any) {
194-
return this.writer.get(
195-
arg0,
196-
// @ts-expect-error -- get supports 2 args since convex@1.25.4, but the type is marked as internal
197-
arg1,
198-
);
190+
return this.writer.get(arg0, arg1);
199191
}
200192

201193
insert<TableName extends TableNamesInDataModel<DataModel>>(
@@ -215,12 +207,7 @@ export class DatabaseWriterWithTriggers<
215207
value: PatchValue<DocumentByName<DataModel, TableName>>,
216208
): Promise<void>;
217209
patch(arg0: any, arg1: any, arg2?: any): Promise<void> {
218-
return this.writer.patch(
219-
arg0,
220-
arg1,
221-
// @ts-expect-error -- patch supports 3 args since convex@1.25.4, but the type is marked as internal
222-
arg2,
223-
);
210+
return this.writer.patch(arg0, arg1, arg2);
224211
}
225212

226213
query<TableName extends TableNamesInDataModel<DataModel>>(
@@ -246,12 +233,7 @@ export class DatabaseWriterWithTriggers<
246233
value: WithOptionalSystemFields<DocumentByName<DataModel, TableName>>,
247234
): Promise<void>;
248235
replace(arg0: any, arg1: any, arg2?: any): Promise<void> {
249-
return this.writer.replace(
250-
arg0,
251-
arg1,
252-
// @ts-expect-error -- replace supports 3 args since convex@1.25.4, but the type is marked as internal
253-
arg2,
254-
);
236+
return this.writer.replace(arg0, arg1, arg2);
255237
}
256238

257239
system: GenericDatabaseWriter<DataModel>["system"];
@@ -302,12 +284,7 @@ export function writerWithTriggers<
302284
isWithinTrigger,
303285
async () => {
304286
const oldDoc = (await innerDb.get(id))!;
305-
await innerDb.patch(
306-
tableName,
307-
id,
308-
// @ts-expect-error -- patch supports 3 args since convex@1.25.4, but the type is marked as internal
309-
value,
310-
);
287+
await innerDb.patch(tableName, id, value);
311288
const newDoc = (await innerDb.get(id))!;
312289
return [undefined, { operation: "update", id, oldDoc, newDoc }];
313290
},
@@ -348,12 +325,7 @@ export function writerWithTriggers<
348325
isWithinTrigger,
349326
async () => {
350327
const oldDoc = (await innerDb.get(id))!;
351-
await innerDb.replace(
352-
tableName,
353-
id,
354-
// @ts-expect-error -- replace supports 3 args since convex@1.25.4, but the type is marked as internal
355-
value,
356-
);
328+
await innerDb.replace(tableName, id, value);
357329
const newDoc = (await innerDb.get(id))!;
358330
return [undefined, { operation: "update", id, oldDoc, newDoc }];
359331
},
@@ -389,11 +361,7 @@ export function writerWithTriggers<
389361
isWithinTrigger,
390362
async () => {
391363
const oldDoc = (await innerDb.get(id))!;
392-
await innerDb.delete(
393-
tableName,
394-
// @ts-expect-error -- delete supports 2 args since convex@1.25.4, but the type is marked as internal
395-
id,
396-
);
364+
await innerDb.delete(tableName, id);
397365
return [undefined, { operation: "delete", id, oldDoc, newDoc: null }];
398366
},
399367
);

0 commit comments

Comments
 (0)