feat: v2 managed organizations (#19341)
* refactor: allow non unique PlatformBilling customerId * feat: add PlatformBilling managed organizations fields * feat: ManagedOrganization table * refactor: bill overdue based on teamId * refactor: restructure organizations module * wip: organizations endpoints * Revert "wip: organizations endpoints" This reverts commit 0e9e66fc74f31da436f12930c1b6597c650ed621. * refactor: unique index for managed organizations * wip: organizations endpoints * wip: create managed organization * remove unecessary membership check because we have guard * feat: create managed org * feat: get managed org and orgs * feat: update and delete managed orgs * wip: api key logic * feat: allow variable api key length * feat: refresh managed org api key * feat: create managed org OAuth clients using api key * finish merge main * chore: bump platform libraries * tests: fix and add more tests to api-auth.strategy.e2e * refactor: dont request managed org slug and handle metadata as object * revert: billing service and repository update overdue based on sub and customer ids * refactor: v2 OAuth client permissions (#19501) * refactor: v2 permissions as string array * refactor: frontend work with permissions as string * tests: test '*' permissions * fix:managed org creator have profile & test can fetch oauth client * fix: tests * fix: OAuthClientCard on frontend * fix: tests
This commit is contained in:
1 parent
e4ab8d87c4
commit
a44bcafcf2
192 files changed
+9103
-619
No files matched your search
+2
@@ -0,0 +1,2 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "PlatformBilling_customerId_key";
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "PlatformBilling" ADD COLUMN "managerBillingId" INTEGER;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PlatformBilling" ADD CONSTRAINT "PlatformBilling_managerBillingId_fkey" FOREIGN KEY ("managerBillingId") REFERENCES "PlatformBilling"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ManagedOrganization" (
|
||||
"managedOrganizationId" INTEGER NOT NULL,
|
||||
"managerOrganizationId" INTEGER NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ManagedOrganization_managedOrganizationId_key" ON "ManagedOrganization"("managedOrganizationId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ManagedOrganization_managerOrganizationId_idx" ON "ManagedOrganization"("managerOrganizationId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ManagedOrganization" ADD CONSTRAINT "ManagedOrganization_managedOrganizationId_fkey" FOREIGN KEY ("managedOrganizationId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ManagedOrganization" ADD CONSTRAINT "ManagedOrganization_managerOrganizationId_fkey" FOREIGN KEY ("managerOrganizationId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[managerOrganizationId,managedOrganizationId]` on the table `ManagedOrganization` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ManagedOrganization_managerOrganizationId_managedOrganizati_key" ON "ManagedOrganization"("managerOrganizationId", "managedOrganizationId");
|
||||
@@ -488,6 +488,11 @@ model Team {
|
||||
includeManagedEventsInLimits Boolean @default(false)
|
||||
internalNotePresets InternalNotePreset[]
|
||||
|
||||
// note(Lauris): if a Team has parentId it is a team, if parentId is null it is an organization, but if parentId is null and managedOrganization is set,
|
||||
// it means that it is an organization managed by another organization.
|
||||
managedOrganization ManagedOrganization? @relation("ManagedOrganization")
|
||||
managedOrganizations ManagedOrganization[] @relation("ManagerOrganization")
|
||||
|
||||
@@unique([slug, parentId])
|
||||
@@index([parentId])
|
||||
}
|
||||
@@ -1624,10 +1629,23 @@ enum SMSLockState {
|
||||
REVIEW_NEEDED
|
||||
}
|
||||
|
||||
model ManagedOrganization {
|
||||
managedOrganizationId Int @unique
|
||||
managedOrganization Team @relation("ManagedOrganization", fields: [managedOrganizationId], references: [id], onDelete: Cascade)
|
||||
|
||||
managerOrganizationId Int
|
||||
managerOrganization Team @relation("ManagerOrganization", fields: [managerOrganizationId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@unique([managerOrganizationId, managedOrganizationId])
|
||||
@@index([managerOrganizationId])
|
||||
}
|
||||
|
||||
model PlatformBilling {
|
||||
id Int @id @unique // team id
|
||||
|
||||
customerId String @unique
|
||||
customerId String
|
||||
subscriptionId String?
|
||||
plan String @default("none")
|
||||
|
||||
@@ -1635,6 +1653,12 @@ model PlatformBilling {
|
||||
billingCycleEnd Int?
|
||||
overdue Boolean? @default(false)
|
||||
|
||||
// note(Lauris): in case of a platform managed organization's billing record this field points to the manager organization's billing record.
|
||||
managerBillingId Int?
|
||||
managerBilling PlatformBilling? @relation("PlatformManagedBilling", fields: [managerBillingId], references: [id])
|
||||
// note(Lauris): in case of a manager organization's billing record this field points to billing records of its platform managed organizations.
|
||||
managedBillings PlatformBilling[] @relation("PlatformManagedBilling")
|
||||
|
||||
team Team @relation(fields: [id], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user