feat: initial github integration with importing projects (#421)

* feat: initial github integration with importing projects

* fix: remove unused args

* chore: remove duplicate col

---------

Co-authored-by: Henry <henry_ball@hotmail.co.uk>
This commit is contained in:
Morfixx
2026-03-02 01:39:25 +03:00
committed by GitHub
parent eeae23a24c
commit 280d8f66dd
11 changed files with 3961 additions and 36 deletions

View File

@@ -46,6 +46,35 @@ export const getProvidersForUser = async (db: dbClient, userId: string) => {
return integration;
};
export const createOrUpdateProvider = async (
db: dbClient,
data: {
userId: string;
provider: string;
accessToken: string;
refreshToken?: string | null;
expiresAt: Date;
},
) => {
await db
.insert(integrations)
.values({
provider: data.provider,
userId: data.userId,
accessToken: data.accessToken,
refreshToken: data.refreshToken ?? null,
expiresAt: data.expiresAt,
})
.onConflictDoUpdate({
target: [integrations.userId, integrations.provider],
set: {
accessToken: data.accessToken,
refreshToken: data.refreshToken ?? null,
expiresAt: data.expiresAt,
},
});
};
export const deleteProviderForUser = async (
db: dbClient,
userId: string,

View File

@@ -14,7 +14,7 @@ import { labels } from "./labels";
import { lists } from "./lists";
import { users } from "./users";
export const importSourceEnum = pgEnum("source", ["trello"]);
export const importSourceEnum = pgEnum("source", ["trello", "github"]);
export const importStatusEnum = pgEnum("status", [
"started",
"success",

View File

@@ -2,6 +2,7 @@ import { relations } from "drizzle-orm";
import {
pgTable,
primaryKey,
text,
timestamp,
uuid,
varchar,
@@ -16,7 +17,7 @@ export const integrations = pgTable(
userId: uuid("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
accessToken: varchar("accessToken", { length: 255 }).notNull(),
accessToken: text("accessToken").notNull(),
refreshToken: varchar("refreshToken", { length: 255 }),
expiresAt: timestamp("expiresAt").notNull(),
createdAt: timestamp("createdAt")