feat: New Organization Schema along with the ability to invite existing users to an organization (#13002)
* Add profile table Copy to profile table Update schema Migrations * wip * Get switcher working * Add organization seeder * wip * Remove dead code * Fix unit tests * relevantProfile -> profile * cache bust * One more comment * Squash migrations * Copy to profile table * Update schema * Fix existing user invite flow * Add profile table * Copy to profile table * Update schema * Format * Add profile table Copy to profile table Update schema Migrations * Format * wip Get switcher working Add organization seeder wip Remove dead code Fix unit tests relevantProfile -> profile cache bust One more comment Squash migrations Copy to profile table Update schema Fix existing user invite flow Add profile table Copy to profile table Update schema chore: small improvements to signup (#13227) * removed features on mobile, better background color * nit * dark mode nits New Crowdin translations by Github Action fix: event reschedule workflow trigger (#13122) * fix event reschedule workflow trigger * uncomment previously failed test * review fix --------- Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: CarinaWolli <[email protected]> chore: added community support to help (#13213) refactor: Abstract `handleSeats` from `handleNewBooking` (#12062) * Refactor createBooking * Type fix * Abstract handleSeats * Create Invitee type * Create OrganizerUser type * Abstract addVideoCallDataToEvt * Abstract createLoggerWithEventDetails * Abstract `handleAppStatus` from handler * Create ReqAppsStatus type * Move `deleteMeeting` and `getCalendar` * Set parameters for `handleSeats` * Typescript refactor * Change function params from req * Type fix --------- Co-authored-by: Morgan <[email protected]> Co-authored-by: Erik <[email protected]> fix: Dynamic group booking org-migration redirect (#13223) * fix: Dynamic group booking redirect * Fix flaky private team test test: Check availability tab and all your functions (teste2e-availability) (#12434) * add changes * add changes * add changes * add changes * Requested changes * Change way to grab element --------- Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: Morgan <[email protected]> Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> fix: Reschedule a cancelled booking (#13170) * fix: Reschedule a cancelled booking * canceled instead of cancelled --------- Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> v3.7.0 test: In Team Event type when location is Organizer Default App and U… (#12939) * test: In Team Event type when location is Organizer Default App and User Metadata is emoty * chore: use variable * fix: type error test: add test for invalid cal video (#13103) * test: add test for invalid cal video * chore: add confirm * chore: fix type error * chore: update code * test: add unit test * chore: type error * chore * chore: type * chore: fix test * chore --------- Co-authored-by: Carina Wollendorfer <[email protected]> chore: add error message for no availability (#13230) * chore: add error message for no default user availability * chore: check only availability * chore: change message * chore: add eventType fix: Team revert with members (#13228) refactor: Refactor seats logic (#12905) * Refactor createBooking * Type fix * Abstract handleSeats * Create Invitee type * Create OrganizerUser type * Abstract addVideoCallDataToEvt * Abstract createLoggerWithEventDetails * Abstract `handleAppStatus` from handler * Create ReqAppsStatus type * Move `deleteMeeting` and `getCalendar` * Set parameters for `handleSeats` * Typescript refactor * Change function params from req * Type fix * Move handleSeats * Abstract lastAttendeeDeleteBooking * Create function for rescheduling seated events * Fix imports on reschedule seats function * Fix imports * Import handleSeats function * Fix rescheduleUid type * Refactor owner reschedule to new time slot * Refactor combine two booking times together * Reschedule as an attendee * Refactor createNewSeat * Remove old handleSeats * Remove lastAttendeeDeleteBooking from handleNewBooking * Test for new attendee right params are passed * Unit test params for reschedule * Typo fix * Clean up * Create new seat test * Test when attendee already signs up for booking * Type fix * Test reschedule move attendee to existing booking * On reschedule create new booking * Test on last attendee cancel booking * Owner reschedule to new time slot * Owner rescheduling, merge two bookings together * Test: when merging more than available seats, then fail * Test: fail when event is full * Remove duplicate E2E tests * Clean up * Rename `addVideoCallDataToEvt` to `addVideoCallDataToEvent` * Refactor `calcAppsStatus` * Assign `evt` to resutl of `addVideoCallDataToEvent` * Use prisma.transaction when moving attendees * Clean create seat call * Use ErrorCode enum * Use attendeeRescheduledSeatedBooking function * Await function * Prevent double triggering of workflows * Use inviteeToAdd in createNewSeat * Remove unused error code * Remove old handleSeats file * Type fix * Type fix * Type fix * Type fix * Type fix * Type fix * Type fix * Type fix --------- Co-authored-by: Morgan <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Erik <[email protected]> feat: Allow admins to filter bookings only by attendee emails (#13236) * chore: Allow admins to filter bookings only by attendee emails * Fix type error Fixed [CAL-2930] Org branding isnt centered in shell #13225 (#13237) Add profile table Copy to profile table Update schema Migrations Format * wip * Add profile relation everywhere * Fix schema * Fix invite handler * Add profileId during eventTypec reation * Get dashboard working with profile relatioon * Add workflow create repository * Add profileId to host * Add profileId to credential table * Add destinationCalendar repository * Add profileId to membership * Revert all profile related changes * Add acme and dunder * Fix membership profileId usgae * Various fixes * Some renaming * Fix failing tests * Debugging next-aut * Consolidate migrations * Testing fixes * Fix unit tests * Self review feedback * PR feedback * Fix orgMigration as well * Add profile schema and copy users to it * Remove migrations from here * Fix type issues * Fix type error after main merge * Remove movedFromUserId * Add missing migration file * Self review addressed * Joe's review addressed * Fix profile switcher --------- Co-authored-by: Joe Au-Yeung <[email protected]>
This commit is contained in:
178 files changed
+4091
-1262
No files matched your search
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[movedToProfileId]` on the table `users` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "profileId" INTEGER;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "movedToProfileId" INTEGER;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Profile" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"uid" TEXT NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"organizationId" INTEGER NOT NULL,
|
||||
"username" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Profile_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Profile_uid_idx" ON "Profile"("uid");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Profile_userId_idx" ON "Profile"("userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Profile_organizationId_idx" ON "Profile"("organizationId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Profile_userId_organizationId_key" ON "Profile"("userId", "organizationId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "users_movedToProfileId_key" ON "users"("movedToProfileId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventType" ADD CONSTRAINT "EventType_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "Profile"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "users" ADD CONSTRAINT "users_movedToProfileId_fkey" FOREIGN KEY ("movedToProfileId") REFERENCES "Profile"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
|
||||
-- Copy Data to Profile table
|
||||
WITH new_profile AS (
|
||||
INSERT INTO "Profile" ("uid", "organizationId", "userId", "username", "updatedAt")
|
||||
SELECT "id" as "uid", "organizationId", "id" AS "userId", "username", NOW()
|
||||
FROM "users"
|
||||
WHERE "organizationId" IS NOT NULL
|
||||
RETURNING "uid", "userId", "id"
|
||||
)
|
||||
UPDATE "users"
|
||||
SET "movedToProfileId" = "new_profile"."id"
|
||||
FROM "new_profile"
|
||||
WHERE "users"."id" = "new_profile"."userId";
|
||||
@@ -47,23 +47,27 @@ model Host {
|
||||
}
|
||||
|
||||
model EventType {
|
||||
id Int @id @default(autoincrement())
|
||||
id Int @id @default(autoincrement())
|
||||
/// @zod.min(1)
|
||||
title String
|
||||
title String
|
||||
/// @zod.custom(imports.eventTypeSlug)
|
||||
slug String
|
||||
description String?
|
||||
position Int @default(0)
|
||||
slug String
|
||||
description String?
|
||||
position Int @default(0)
|
||||
/// @zod.custom(imports.eventTypeLocations)
|
||||
locations Json?
|
||||
locations Json?
|
||||
/// @zod.min(1)
|
||||
length Int
|
||||
offsetStart Int @default(0)
|
||||
hidden Boolean @default(false)
|
||||
hosts Host[]
|
||||
users User[] @relation("user_eventtype")
|
||||
owner User? @relation("owner", fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int?
|
||||
length Int
|
||||
offsetStart Int @default(0)
|
||||
hidden Boolean @default(false)
|
||||
hosts Host[]
|
||||
users User[] @relation("user_eventtype")
|
||||
owner User? @relation("owner", fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int?
|
||||
|
||||
profileId Int?
|
||||
profile Profile? @relation(fields: [profileId], references: [id], onDelete: Cascade)
|
||||
|
||||
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
teamId Int?
|
||||
hashedLink HashedLink?
|
||||
@@ -185,6 +189,7 @@ enum UserPermissionRole {
|
||||
ADMIN
|
||||
}
|
||||
|
||||
// It holds Personal Profiles of a User plus it has email, password and other core things
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String?
|
||||
@@ -260,17 +265,17 @@ model User {
|
||||
accessCodes AccessCode[]
|
||||
bookingRedirects OutOfOfficeEntry[]
|
||||
bookingRedirectsTo OutOfOfficeEntry[] @relation(name: "toUser")
|
||||
// Linking account code for orgs v2
|
||||
//linkedByUserId Int?
|
||||
//linkedBy User? @relation("linked_account", fields: [linkedByUserId], references: [id], onDelete: Cascade)
|
||||
//linkedUsers User[] @relation("linked_account")*/
|
||||
|
||||
// Used to lock the user account
|
||||
locked Boolean @default(false)
|
||||
locked Boolean @default(false)
|
||||
profiles Profile[]
|
||||
movedToProfileId Int?
|
||||
movedToProfile Profile? @relation("moved_to_profile", fields: [movedToProfileId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@unique([email])
|
||||
@@unique([email, username])
|
||||
@@unique([username, organizationId])
|
||||
@@unique([movedToProfileId])
|
||||
@@index([username])
|
||||
@@index([emailVerified])
|
||||
@@index([identityProvider])
|
||||
@@ -278,6 +283,27 @@ model User {
|
||||
@@map(name: "users")
|
||||
}
|
||||
|
||||
// It holds Organization Profiles
|
||||
model Profile {
|
||||
id Int @id @default(autoincrement())
|
||||
// uid allows us to set an identifier chosen by us which is helpful in migration when we create the Profile from User directly.
|
||||
uid String
|
||||
userId Int
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
organizationId Int
|
||||
organization Team @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
username String
|
||||
eventTypes EventType[]
|
||||
movedFromUser User? @relation("moved_to_profile")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([userId, organizationId])
|
||||
@@index([uid])
|
||||
@@index([userId])
|
||||
@@index([organizationId])
|
||||
}
|
||||
|
||||
model Team {
|
||||
id Int @id @default(autoincrement())
|
||||
/// @zod.min(1)
|
||||
@@ -317,6 +343,7 @@ model Team {
|
||||
credentials Credential[]
|
||||
accessCodes AccessCode[]
|
||||
instantMeetingTokens InstantMeetingToken[]
|
||||
orgProfiles Profile[]
|
||||
pendingPayment Boolean @default(false)
|
||||
|
||||
@@unique([slug, parentId])
|
||||
|
||||
+377
-1
@@ -1,4 +1,5 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import type { Membership, Team, User } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { uuid } from "short-uuid";
|
||||
import type z from "zod";
|
||||
|
||||
@@ -6,7 +7,9 @@ import dailyMeta from "@calcom/app-store/dailyvideo/_metadata";
|
||||
import googleMeetMeta from "@calcom/app-store/googlevideo/_metadata";
|
||||
import zoomMeta from "@calcom/app-store/zoomvideo/_metadata";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { hashPassword } from "@calcom/features/auth/lib/hashPassword";
|
||||
import { BookingStatus, MembershipRole } from "@calcom/prisma/enums";
|
||||
import type { Ensure } from "@calcom/types/utils";
|
||||
|
||||
import prisma from ".";
|
||||
import mainAppStore from "./seed-app-store";
|
||||
@@ -75,6 +78,260 @@ async function createTeamAndAddUsers(
|
||||
return team;
|
||||
}
|
||||
|
||||
async function createOrganizationAndAddMembersAndTeams({
|
||||
org: { orgData, members: orgMembers },
|
||||
teams,
|
||||
usersOutsideOrg,
|
||||
}: {
|
||||
org: {
|
||||
orgData: Ensure<Partial<Prisma.TeamCreateInput>, "name" | "slug">;
|
||||
members: {
|
||||
memberData: Ensure<Partial<Prisma.UserCreateInput>, "username" | "name" | "email" | "password">;
|
||||
orgMembership: Partial<Membership>;
|
||||
orgProfile: {
|
||||
username: string;
|
||||
};
|
||||
inTeams: { slug: string; role: MembershipRole }[];
|
||||
}[];
|
||||
};
|
||||
teams: {
|
||||
teamData: Omit<Ensure<Partial<Prisma.TeamCreateInput>, "name" | "slug">, "members">;
|
||||
nonOrgMembers: Ensure<Partial<Prisma.UserCreateInput>, "username" | "name" | "email" | "password">[];
|
||||
}[];
|
||||
usersOutsideOrg: {
|
||||
name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
}[];
|
||||
}) {
|
||||
console.log(`\n🏢 Creating organization "${orgData.name}"`);
|
||||
const orgMembersInDb: (User & {
|
||||
inTeams: { slug: string; role: MembershipRole }[];
|
||||
orgMembership: Partial<Membership>;
|
||||
orgProfile: {
|
||||
username: string;
|
||||
};
|
||||
})[] = [];
|
||||
|
||||
// Create all users first
|
||||
try {
|
||||
for (const member of orgMembers) {
|
||||
const orgMemberInDb = {
|
||||
...(await prisma.user.create({
|
||||
data: {
|
||||
...member.memberData,
|
||||
password: await hashPassword(member.memberData.password),
|
||||
},
|
||||
})),
|
||||
inTeams: member.inTeams,
|
||||
orgMembership: member.orgMembership,
|
||||
orgProfile: member.orgProfile,
|
||||
};
|
||||
|
||||
orgMembersInDb.push(orgMemberInDb);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
if (e.code === "P2002") {
|
||||
console.log(`One of the organization members already exists, skipping the entire seeding`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
usersOutsideOrg.map(async (user) => {
|
||||
return await prisma.user.create({
|
||||
data: {
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
password: await hashPassword(user.username),
|
||||
},
|
||||
});
|
||||
}),
|
||||
]);
|
||||
|
||||
// Create organization with those users as members
|
||||
const orgInDb = await prisma.team.create({
|
||||
data: {
|
||||
...orgData,
|
||||
metadata: {
|
||||
...(orgData.metadata && typeof orgData.metadata === "object" ? orgData.metadata : {}),
|
||||
isOrganization: true,
|
||||
},
|
||||
orgProfiles: {
|
||||
create: orgMembersInDb.map((member) => ({
|
||||
uid: uuid(),
|
||||
username: member.orgProfile.username,
|
||||
user: {
|
||||
connect: {
|
||||
id: member.id,
|
||||
},
|
||||
},
|
||||
})),
|
||||
},
|
||||
members: {
|
||||
create: orgMembersInDb.map((member) => ({
|
||||
user: {
|
||||
connect: {
|
||||
id: member.id,
|
||||
},
|
||||
},
|
||||
role: member.orgMembership.role || "MEMBER",
|
||||
accepted: member.orgMembership.accepted,
|
||||
})),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
members: true,
|
||||
orgProfiles: true,
|
||||
},
|
||||
});
|
||||
|
||||
const orgMembersInDBWithProfileId = await Promise.all(
|
||||
orgMembersInDb.map(async (member) => ({
|
||||
...member,
|
||||
profile: {
|
||||
...member.orgProfile,
|
||||
id: orgInDb.orgProfiles.find((p) => p.userId === member.id)?.id,
|
||||
},
|
||||
}))
|
||||
);
|
||||
|
||||
// For each member create one event
|
||||
for (const member of orgMembersInDBWithProfileId) {
|
||||
await prisma.eventType.create({
|
||||
data: {
|
||||
title: `${member.name} Event`,
|
||||
slug: `${member.username}-event`,
|
||||
length: 15,
|
||||
owner: {
|
||||
connect: {
|
||||
id: member.id,
|
||||
},
|
||||
},
|
||||
profile: {
|
||||
connect: {
|
||||
id: member.profile.id,
|
||||
},
|
||||
},
|
||||
users: {
|
||||
connect: {
|
||||
id: member.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Create schedule for every member
|
||||
await prisma.schedule.create({
|
||||
data: {
|
||||
name: "Working Hours",
|
||||
userId: member.id,
|
||||
availability: {
|
||||
create: {
|
||||
days: [1, 2, 3, 4, 5],
|
||||
startTime: "1970-01-01T09:00:00.000Z",
|
||||
endTime: "1970-01-01T17:00:00.000Z",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const organizationTeams: Team[] = [];
|
||||
|
||||
// Create all the teams in the organization
|
||||
for (let teamIndex = 0; teamIndex < teams.length; teamIndex++) {
|
||||
const nonOrgMembers: User[] = [];
|
||||
const team = teams[teamIndex];
|
||||
for (const nonOrgMember of team.nonOrgMembers) {
|
||||
nonOrgMembers.push(
|
||||
await prisma.user.create({
|
||||
data: {
|
||||
...nonOrgMember,
|
||||
password: await hashPassword(nonOrgMember.password),
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
organizationTeams.push(
|
||||
await prisma.team.create({
|
||||
data: {
|
||||
...team.teamData,
|
||||
parent: {
|
||||
connect: {
|
||||
id: orgInDb.id,
|
||||
},
|
||||
},
|
||||
metadata: team.teamData.metadata || {},
|
||||
members: {
|
||||
create: nonOrgMembers.map((member) => ({
|
||||
user: {
|
||||
connect: {
|
||||
id: member.id,
|
||||
},
|
||||
},
|
||||
role: "MEMBER",
|
||||
accepted: true,
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
const ownerForEvent = orgMembersInDBWithProfileId[0];
|
||||
// Create event for each team
|
||||
await prisma.eventType.create({
|
||||
data: {
|
||||
title: `${team.teamData.name} Event1`,
|
||||
slug: `${team.teamData.slug}-event-1`,
|
||||
length: 15,
|
||||
team: {
|
||||
connect: {
|
||||
id: organizationTeams[teamIndex].id,
|
||||
},
|
||||
},
|
||||
owner: {
|
||||
connect: {
|
||||
id: ownerForEvent.id,
|
||||
},
|
||||
},
|
||||
profile: {
|
||||
connect: {
|
||||
id: ownerForEvent.profile.id,
|
||||
},
|
||||
},
|
||||
users: {
|
||||
connect: {
|
||||
id: ownerForEvent.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Create memberships for all the organization members with the respective teams
|
||||
for (const member of orgMembersInDBWithProfileId) {
|
||||
for (const { slug: teamSlug, role: role } of member.inTeams) {
|
||||
const team = organizationTeams.find((t) => t.slug === teamSlug);
|
||||
if (!team) {
|
||||
throw Error(`Team with slug ${teamSlug} not found`);
|
||||
}
|
||||
await prisma.membership.create({
|
||||
data: {
|
||||
teamId: team.id,
|
||||
userId: member.id,
|
||||
role: role,
|
||||
accepted: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
@@ -116,6 +373,7 @@ async function main() {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
@@ -530,6 +788,124 @@ async function main() {
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
await createOrganizationAndAddMembersAndTeams({
|
||||
org: {
|
||||
orgData: {
|
||||
name: "Acme Inc",
|
||||
slug: "acme",
|
||||
metadata: {
|
||||
isOrganizationVerified: true,
|
||||
orgAutoAcceptEmail: "acme.com",
|
||||
},
|
||||
},
|
||||
members: [
|
||||
{
|
||||
memberData: {
|
||||
email: "[email protected]",
|
||||
password: "owner1-acme",
|
||||
username: "owner1-acme",
|
||||
name: "Owner 1",
|
||||
},
|
||||
orgMembership: {
|
||||
role: "OWNER",
|
||||
accepted: true,
|
||||
},
|
||||
orgProfile: {
|
||||
username: "owner1",
|
||||
},
|
||||
inTeams: [
|
||||
{
|
||||
slug: "team1",
|
||||
role: "ADMIN",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
teams: [
|
||||
{
|
||||
teamData: {
|
||||
name: "Team 1",
|
||||
slug: "team1",
|
||||
},
|
||||
nonOrgMembers: [
|
||||
{
|
||||
email: "[email protected]",
|
||||
password: "non-acme-member-1",
|
||||
username: "non-acme-member-1",
|
||||
name: "NonAcme Member1",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
usersOutsideOrg: [
|
||||
{
|
||||
name: "Jane Doe",
|
||||
email: "[email protected]",
|
||||
username: "jane-outside-org",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await createOrganizationAndAddMembersAndTeams({
|
||||
org: {
|
||||
orgData: {
|
||||
name: "Dunder Mifflin",
|
||||
slug: "dunder-mifflin",
|
||||
metadata: {
|
||||
isOrganizationVerified: true,
|
||||
orgAutoAcceptEmail: "dunder-mifflin.com",
|
||||
},
|
||||
},
|
||||
members: [
|
||||
{
|
||||
memberData: {
|
||||
email: "[email protected]",
|
||||
password: "owner1-dunder",
|
||||
username: "owner1-dunder",
|
||||
name: "Owner 1",
|
||||
},
|
||||
orgMembership: {
|
||||
role: "OWNER",
|
||||
accepted: true,
|
||||
},
|
||||
orgProfile: {
|
||||
username: "owner1",
|
||||
},
|
||||
inTeams: [
|
||||
{
|
||||
slug: "team1",
|
||||
role: "ADMIN",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
teams: [
|
||||
{
|
||||
teamData: {
|
||||
name: "Team 1",
|
||||
slug: "team1",
|
||||
},
|
||||
nonOrgMembers: [
|
||||
{
|
||||
email: "[email protected]",
|
||||
password: "non-dunder-member-1",
|
||||
username: "non-dunder-member-1",
|
||||
name: "NonDunder Member1",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
usersOutsideOrg: [
|
||||
{
|
||||
name: "John Doe",
|
||||
email: "[email protected]",
|
||||
username: "john-outside-org",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -51,7 +51,6 @@ export const userSelect = Prisma.validator<Prisma.UserArgs>()({
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
metadata: true,
|
||||
organizationId: true,
|
||||
...availabilityUserSelect,
|
||||
},
|
||||
});
|
||||
@@ -336,7 +336,7 @@ export type userMetadataType = z.infer<typeof userMetadata>;
|
||||
|
||||
export const teamMetadataSchema = z
|
||||
.object({
|
||||
requestedSlug: z.string(),
|
||||
requestedSlug: z.string().or(z.null()),
|
||||
paymentId: z.string(),
|
||||
subscriptionId: z.string().nullable(),
|
||||
subscriptionItemId: z.string().nullable(),
|
||||
|
||||
Reference in new issue
Block a user