Skip to content

Commit a8b41fc

Browse files
committed
lint
1 parent 21fb738 commit a8b41fc

File tree

2 files changed

+48
-29
lines changed

2 files changed

+48
-29
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default [
1919

2020
parserOptions: {
2121
project: true,
22-
tsconfigRootDir: ".",
22+
tsconfigRootDir: import.meta.dirname,
2323
},
2424
},
2525
},

src/client/index.ts

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import {
22
DocumentByName,
3-
Expand,
4-
FunctionReference,
53
GenericDataModel,
64
GenericMutationCtx,
75
GenericQueryCtx,
86
PaginationOptions,
97
TableNamesInDataModel,
108
} from "convex/server";
119
import { GenericId } from "convex/values";
12-
import { api } from "../component/_generated/api.js";
1310
import type { Serializability } from "../component/lib.js";
1411
import type { ComponentApi } from "../component/_generated/component.js";
1512

16-
export class TableHistory<DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel>> {
13+
export class TableHistory<
14+
DataModel extends GenericDataModel,
15+
TableName extends TableNamesInDataModel<DataModel>,
16+
> {
1717
public options: {
1818
serializability: Serializability;
1919
};
@@ -30,7 +30,7 @@ export class TableHistory<DataModel extends GenericDataModel, TableName extends
3030

3131
/**
3232
* Write a new history entry.
33-
*
33+
*
3434
* @argument attribution an arbitrary object that will be stored with the
3535
* history entry. Attribution can include actor/user identity, reason for
3636
* change, etc.
@@ -39,7 +39,7 @@ export class TableHistory<DataModel extends GenericDataModel, TableName extends
3939
ctx: RunMutationCtx,
4040
id: GenericId<TableName>,
4141
doc: DocumentByName<DataModel, TableName> | null,
42-
attribution: unknown = null,
42+
attribution: unknown = null
4343
) {
4444
return ctx.runMutation(this.component.lib.update, {
4545
id,
@@ -51,38 +51,63 @@ export class TableHistory<DataModel extends GenericDataModel, TableName extends
5151

5252
/**
5353
* Paginate the history of the table, from newest to oldest.
54-
*
54+
*
5555
* @argument maxTs To keep pages contiguous, set `maxTs` to a fixed timestamp
5656
* (milliseconds since epoch, like Date.now()) and keep
5757
* it the same for subsequent pages.
5858
*/
59-
async listHistory(ctx: RunQueryCtx, maxTs: number, paginationOpts: PaginationOptions) {
60-
return ctx.runQuery(this.component.lib.listHistory, { maxTs, paginationOpts });
59+
async listHistory(
60+
ctx: RunQueryCtx,
61+
maxTs: number,
62+
paginationOpts: PaginationOptions
63+
) {
64+
return ctx.runQuery(this.component.lib.listHistory, {
65+
maxTs,
66+
paginationOpts,
67+
});
6168
}
6269
/**
6370
* Paginate the history of a single document, from newest to oldest.
64-
*
71+
*
6572
* @argument maxTs To keep pages contiguous, set `maxTs` to a fixed timestamp
6673
* (milliseconds since epoch, like Date.now()) and keep
6774
* it the same for subsequent pages.
6875
*/
69-
async listDocumentHistory(ctx: RunQueryCtx, id: GenericId<TableName>, maxTs: number, paginationOpts: PaginationOptions) {
70-
return ctx.runQuery(this.component.lib.listDocumentHistory, { id, maxTs, paginationOpts });
76+
async listDocumentHistory(
77+
ctx: RunQueryCtx,
78+
id: GenericId<TableName>,
79+
maxTs: number,
80+
paginationOpts: PaginationOptions
81+
) {
82+
return ctx.runQuery(this.component.lib.listDocumentHistory, {
83+
id,
84+
maxTs,
85+
paginationOpts,
86+
});
7187
}
7288
/**
7389
* Paginate a snapshot of the table at a fixed timestamp.
74-
*
90+
*
7591
* @argument ts the snapshot at which you want to list the table (milliseconds since epoch)
7692
* @argument currentTs a fixed recent timestamp (milliseconds since epoch, like Date.now())
7793
* which should be the same for subsequent pages.
7894
*/
79-
async listSnapshot(ctx: RunQueryCtx, snapshotTs: number, currentTs: number, paginationOpts: PaginationOptions) {
80-
return ctx.runQuery(this.component.lib.listSnapshot, { snapshotTs, currentTs, paginationOpts });
95+
async listSnapshot(
96+
ctx: RunQueryCtx,
97+
snapshotTs: number,
98+
currentTs: number,
99+
paginationOpts: PaginationOptions
100+
) {
101+
return ctx.runQuery(this.component.lib.listSnapshot, {
102+
snapshotTs,
103+
currentTs,
104+
paginationOpts,
105+
});
81106
}
82107

83108
/**
84109
* Delete old history entries.
85-
*
110+
*
86111
* @argument minTsToKeep the timestamp (milliseconds since epoch) of the oldest
87112
* snapshot of history that should be kept.
88113
*/
@@ -96,8 +121,12 @@ export class TableHistory<DataModel extends GenericDataModel, TableName extends
96121
trigger<Ctx extends RunMutationCtx>(): Trigger<Ctx, DataModel, TableName> {
97122
return async (ctx, change) => {
98123
let attribution: unknown = null;
99-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
100-
if ((ctx as any).auth && typeof (ctx as any).auth.getUserIdentity === "function") {
124+
if (
125+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
126+
(ctx as any).auth &&
127+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
128+
typeof (ctx as any).auth.getUserIdentity === "function"
129+
) {
101130
// eslint-disable-next-line @typescript-eslint/no-explicit-any
102131
attribution = await (ctx as any).auth.getUserIdentity();
103132
}
@@ -143,13 +172,3 @@ type RunQueryCtx = {
143172
type RunMutationCtx = {
144173
runMutation: GenericMutationCtx<GenericDataModel>["runMutation"];
145174
};
146-
147-
export type OpaqueIds<T> = T extends GenericId<infer _T>
148-
? string
149-
: T extends (infer U)[]
150-
? OpaqueIds<U>[]
151-
: T extends ArrayBuffer
152-
? ArrayBuffer
153-
: T extends object
154-
? { [K in keyof T]: OpaqueIds<T[K]> }
155-
: T;

0 commit comments

Comments
 (0)