diff --git a/packages/server/modules/gatekeeper/domain/operations.ts b/packages/server/modules/gatekeeper/domain/operations.ts index 80139ead6..0ee85228d 100644 --- a/packages/server/modules/gatekeeper/domain/operations.ts +++ b/packages/server/modules/gatekeeper/domain/operations.ts @@ -1,3 +1,4 @@ +import { WorkspaceSeat } from '@/modules/gatekeeper/domain/billing' import { WorkspaceFeatureName } from '@/modules/gatekeeper/domain/workspacePricing' import { PlanStatuses, @@ -30,3 +31,7 @@ export type GetWorkspacePlanByProjectId = ({ }: { projectId: string }) => Promise + +export type CreateWorkspaceSeat = ( + args: Pick +) => Promise diff --git a/packages/server/modules/gatekeeper/repositories/workspaceSeat.ts b/packages/server/modules/gatekeeper/repositories/workspaceSeat.ts index b33fa200a..a60c160d4 100644 --- a/packages/server/modules/gatekeeper/repositories/workspaceSeat.ts +++ b/packages/server/modules/gatekeeper/repositories/workspaceSeat.ts @@ -1,4 +1,5 @@ import { WorkspaceSeat } from '@/modules/gatekeeper/domain/billing' +import { CreateWorkspaceSeat } from '@/modules/gatekeeper/domain/operations' import { Knex } from 'knex' const tables = { @@ -17,3 +18,13 @@ export const countSeatsByTypeInWorkspaceFactory = .count('id') return parseInt(count.toString()) } + +export const createWorkspaceSeatFactory = + ({ db }: { db: Knex }): CreateWorkspaceSeat => + async ({ userId, workspaceId, type }) => { + return await tables.workspaceSeats(db).insert({ + workspaceId, + userId, + type + }) + }