feat: add plaid sync

This commit is contained in:
Max Koon
2025-12-15 12:53:35 -05:00
parent c6dd174376
commit 105b0c514f
9 changed files with 212 additions and 76 deletions

View File

@@ -13,6 +13,6 @@
},
"scripts": {
"db:gen": "drizzle-zero generate -s ./src/db/schema/public.ts -o ./src/zero-schema.gen.ts -f && sed -i 's/enableLegacyQueries: true,/enableLegacyQueries: false,/g' src/zero-schema.gen.ts && sed -i 's/enableLegacyMutators: true,/enableLegacyMutators: false,/g' src/zero-schema.gen.ts",
"db:migrate": "drizzle-kit push"
"db:push": "drizzle-kit push"
}
}

View File

@@ -65,6 +65,7 @@ export const plaidAccessTokens = pgTable("plaidAccessToken", {
logoUrl: text("logoUrl").notNull(),
userId: text("user_id").notNull(),
token: text("token").notNull(),
syncCursor: text("sync_cursor"),
createdAt: timestamp("created_at").notNull().defaultNow(),
});

View File

@@ -10,8 +10,10 @@ export function createMutators(authData: AuthData | null) {
link: {
async create() {},
async get(tx: Tx, { link_token }: { link_token: string }) {},
async updateTransactions() {},
async updateBalences() {},
async webhook() {},
async sync() {},
// async updateTransactions() {},
// async updateBalences() {},
async deleteAccounts(tx: Tx, { accountIds }: { accountIds: string[] }) {
isLoggedIn(authData);
for (const id of accountIds) {

View File

@@ -345,6 +345,16 @@ export const schema = {
"token"
>,
},
syncCursor: {
type: "string",
optional: true,
customType: null as unknown as ZeroCustomType<
ZeroSchema,
"plaidAccessTokens",
"syncCursor"
>,
serverName: "sync_cursor",
},
createdAt: {
type: "number",
optional: true,

View File

@@ -40,9 +40,7 @@ export function Transactions() {
<Table.Provider
data={items}
columns={COLUMNS}
shortcuts={[
{ key: "r", handler: () => z.mutate.link.updateTransactions() },
]}
shortcuts={[{ key: "r", handler: () => z.mutate.link.sync() }]}
>
<View style={{ padding: 10, flex: 1 }}>
<View style={{ flexShrink: 0 }}>