Edit: /tmp/tsx-0/17887-facf75742739bece2faccce69f0030a50f11bc62 (39945B)
{"code":"__filename=\"/opt/canhelp/node_modules/better-auth/dist/plugins/organization/routes/crud-team.mjs\";(()=>{\nvar __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,\"name\",{value,configurable:true});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from===\"object\"||typeof from===\"function\"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,\"default\",{value:mod,enumerable:true}):target,mod));var __toCommonJS=mod=>__copyProps(__defProp({},\"__esModule\",{value:true}),mod);var crud_team_exports={};__export(crud_team_exports,{addTeamMember:()=>addTeamMember,createTeam:()=>createTeam,listOrganizationTeams:()=>listOrganizationTeams,listTeamMembers:()=>listTeamMembers,listUserTeams:()=>listUserTeams,removeTeam:()=>removeTeam,removeTeamMember:()=>removeTeamMember,setActiveTeam:()=>setActiveTeam,updateTeam:()=>updateTeam});module.exports=__toCommonJS(crud_team_exports);var import_to_zod=require(\"../../../db/to-zod.mjs\");var import_db=require(\"../../../db/index.mjs\");var import_cookies=require(\"../../../cookies/index.mjs\");var import_session=require(\"../../../api/routes/session.mjs\");var import_api=require(\"../../../api/index.mjs\");var import_error_codes=require(\"../error-codes.mjs\");var import_adapter=require(\"../adapter.mjs\");var import_call=require(\"../call.mjs\");var import_has_permission=require(\"../has-permission.mjs\");var import_schema=require(\"../schema.mjs\");var import_error=require(\"@better-auth/core/error\");var import_api2=require(\"@better-auth/core/api\");var z=__toESM(require(\"zod\"));const teamBaseSchema=z.object({name:z.string().meta({description:'The name of the team. Eg: \"my-team\"'}),organizationId:z.string().meta({description:'The organization ID which the team will be created in. Defaults to the active organization. Eg: \"organization-id\"'}).optional()});const createTeam=__name(options=>{const additionalFieldsSchema=(0,import_to_zod.toZodSchema)({fields:options?.schema?.team?.additionalFields??{},isClientSide:true});return(0,import_api2.createAuthEndpoint)(\"/organization/create-team\",{method:\"POST\",body:z.object({...teamBaseSchema.shape,...additionalFieldsSchema.shape}),use:[import_call.orgMiddleware],metadata:{$Infer:{body:{}},openapi:{description:\"Create a new team within an organization\",responses:{\"200\":{description:\"Team created successfully\",content:{\"application/json\":{schema:{type:\"object\",properties:{id:{type:\"string\",description:\"Unique identifier of the created team\"},name:{type:\"string\",description:\"Name of the team\"},organizationId:{type:\"string\",description:\"ID of the organization the team belongs to\"},createdAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team was created\"},updatedAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team was last updated\"}},required:[\"id\",\"name\",\"organizationId\",\"createdAt\",\"updatedAt\"]}}}}}}}},async ctx=>{const session=await(0,import_session.getSessionFromCtx)(ctx);const organizationId=ctx.body.organizationId||session?.session.activeOrganizationId;if(!session&&(ctx.request||ctx.headers))throw import_error.APIError.fromStatus(\"UNAUTHORIZED\");if(!organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION);const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,options);if(session){const member=await adapter.findMemberByOrgId({userId:session.user.id,organizationId});if(!member)throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION);if(!await(0,import_has_permission.hasPermission)({role:member.role,options:ctx.context.orgOptions,permissions:{team:[\"create\"]},organizationId},ctx))throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION)}const existingTeams=await adapter.listTeams(organizationId);const maximum=typeof ctx.context.orgOptions.teams?.maximumTeams===\"function\"?await ctx.context.orgOptions.teams?.maximumTeams({organizationId,session},ctx):ctx.context.orgOptions.teams?.maximumTeams;if(maximum?existingTeams.length>=maximum:false)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS);const{name,organizationId:_,...additionalFields}=ctx.body;const organization=await adapter.findOrganizationById(organizationId);if(!organization)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.ORGANIZATION_NOT_FOUND);let teamData={name,organizationId,createdAt:new Date,updatedAt:new Date,...additionalFields};if(options?.organizationHooks?.beforeCreateTeam){const response=await options?.organizationHooks.beforeCreateTeam({team:{name,organizationId,...additionalFields},user:session?.user,organization});if(response&&typeof response===\"object\"&&\"data\"in response)teamData={...teamData,...response.data}}const createdTeam=await adapter.createTeam(teamData);if(options?.organizationHooks?.afterCreateTeam)await options?.organizationHooks.afterCreateTeam({team:createdTeam,user:session?.user,organization});return ctx.json(createdTeam)})},\"createTeam\");const removeTeamBodySchema=z.object({teamId:z.string().meta({description:`The team ID of the team to remove. Eg: \"team-id\"`}),organizationId:z.string().meta({description:`The organization ID which the team falls under. If not provided, it will default to the user's active organization. Eg: \"organization-id\"`}).optional()});const removeTeam=__name(options=>(0,import_api2.createAuthEndpoint)(\"/organization/remove-team\",{method:\"POST\",body:removeTeamBodySchema,use:[import_call.orgMiddleware],metadata:{openapi:{description:\"Remove a team from an organization\",responses:{\"200\":{description:\"Team removed successfully\",content:{\"application/json\":{schema:{type:\"object\",properties:{message:{type:\"string\",description:\"Confirmation message indicating successful removal\",enum:[\"Team removed successfully.\"]}},required:[\"message\"]}}}}}}}},async ctx=>{const session=await(0,import_session.getSessionFromCtx)(ctx);const organizationId=ctx.body.organizationId||session?.session.activeOrganizationId;if(!organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION);if(!session&&(ctx.request||ctx.headers))throw import_error.APIError.fromStatus(\"UNAUTHORIZED\");const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,options);if(session){const member=await adapter.findMemberByOrgId({userId:session.user.id,organizationId});if(!member||session.session?.activeTeamId===ctx.body.teamId)throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM);if(!await(0,import_has_permission.hasPermission)({role:member.role,options:ctx.context.orgOptions,permissions:{team:[\"delete\"]},organizationId},ctx))throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION)}const team=await adapter.findTeamById({teamId:ctx.body.teamId,organizationId});if(!team||team.organizationId!==organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.TEAM_NOT_FOUND);if(!ctx.context.orgOptions.teams?.allowRemovingAllTeams){if((await adapter.listTeams(organizationId)).length<=1)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.UNABLE_TO_REMOVE_LAST_TEAM)}const organization=await adapter.findOrganizationById(organizationId);if(!organization)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.ORGANIZATION_NOT_FOUND);if(options?.organizationHooks?.beforeDeleteTeam)await options?.organizationHooks.beforeDeleteTeam({team,user:session?.user,organization});await adapter.deleteTeam(team.id);if(options?.organizationHooks?.afterDeleteTeam)await options?.organizationHooks.afterDeleteTeam({team,user:session?.user,organization});return ctx.json({message:\"Team removed successfully.\"})}),\"removeTeam\");const updateTeam=__name(options=>{const additionalFieldsSchema=(0,import_to_zod.toZodSchema)({fields:options?.schema?.team?.additionalFields??{},isClientSide:true});return(0,import_api2.createAuthEndpoint)(\"/organization/update-team\",{method:\"POST\",body:z.object({teamId:z.string().meta({description:`The ID of the team to be updated. Eg: \"team-id\"`}),data:z.object({...import_schema.teamSchema.shape,...additionalFieldsSchema.shape}).partial()}),requireHeaders:true,use:[import_call.orgMiddleware,import_call.orgSessionMiddleware],metadata:{$Infer:{body:{}},openapi:{description:\"Update an existing team in an organization\",responses:{\"200\":{description:\"Team updated successfully\",content:{\"application/json\":{schema:{type:\"object\",properties:{id:{type:\"string\",description:\"Unique identifier of the updated team\"},name:{type:\"string\",description:\"Updated name of the team\"},organizationId:{type:\"string\",description:\"ID of the organization the team belongs to\"},createdAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team was created\"},updatedAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team was last updated\"}},required:[\"id\",\"name\",\"organizationId\",\"createdAt\",\"updatedAt\"]}}}}}}}},async ctx=>{const session=ctx.context.session;const organizationId=ctx.body.data.organizationId||session.session.activeOrganizationId;if(!organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION);const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,options);const member=await adapter.findMemberByOrgId({userId:session.user.id,organizationId});if(!member)throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM);if(!await(0,import_has_permission.hasPermission)({role:member.role,options:ctx.context.orgOptions,permissions:{team:[\"update\"]},organizationId},ctx))throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM);const team=await adapter.findTeamById({teamId:ctx.body.teamId,organizationId});if(!team||team.organizationId!==organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.TEAM_NOT_FOUND);const{name,organizationId:__,...additionalFields}=ctx.body.data;const organization=await adapter.findOrganizationById(organizationId);if(!organization)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.ORGANIZATION_NOT_FOUND);const updates={name,...additionalFields};if(options?.organizationHooks?.beforeUpdateTeam){const response=await options?.organizationHooks.beforeUpdateTeam({team,updates,user:session.user,organization});if(response&&typeof response===\"object\"&&\"data\"in response){const modifiedUpdates=response.data;const updatedTeam2=await adapter.updateTeam(team.id,modifiedUpdates);if(options?.organizationHooks?.afterUpdateTeam)await options?.organizationHooks.afterUpdateTeam({team:updatedTeam2,user:session.user,organization});return ctx.json(updatedTeam2)}}const updatedTeam=await adapter.updateTeam(team.id,updates);if(options?.organizationHooks?.afterUpdateTeam)await options?.organizationHooks.afterUpdateTeam({team:updatedTeam,user:session.user,organization});return ctx.json(updatedTeam)})},\"updateTeam\");const listOrganizationTeamsQuerySchema=z.optional(z.object({organizationId:z.string().meta({description:`The organization ID which the teams are under to list. Defaults to the users active organization. Eg: \"organization-id\"`}).optional()}));const listOrganizationTeams=__name(options=>(0,import_api2.createAuthEndpoint)(\"/organization/list-teams\",{method:\"GET\",query:listOrganizationTeamsQuerySchema,metadata:{openapi:{description:\"List all teams in an organization\",responses:{\"200\":{description:\"Teams retrieved successfully\",content:{\"application/json\":{schema:{type:\"array\",items:{type:\"object\",properties:{id:{type:\"string\",description:\"Unique identifier of the team\"},name:{type:\"string\",description:\"Name of the team\"},organizationId:{type:\"string\",description:\"ID of the organization the team belongs to\"},createdAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team was created\"},updatedAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team was last updated\"}},required:[\"id\",\"name\",\"organizationId\",\"createdAt\",\"updatedAt\"]},description:\"Array of team objects within the organization\"}}}}}}},requireHeaders:true,use:[import_call.orgMiddleware,import_call.orgSessionMiddleware]},async ctx=>{const session=ctx.context.session;const organizationId=ctx.query?.organizationId||session?.session.activeOrganizationId;if(!organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION);const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,options);if(!await adapter.findMemberByOrgId({userId:session.user.id,organizationId:organizationId||\"\"}))throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION);const teams=await adapter.listTeams(organizationId);return ctx.json(teams)}),\"listOrganizationTeams\");const setActiveTeamBodySchema=z.object({teamId:z.string().meta({description:\"The team id to set as active. It can be null to unset the active team\"}).nullable().optional()});const setActiveTeam=__name(options=>(0,import_api2.createAuthEndpoint)(\"/organization/set-active-team\",{method:\"POST\",body:setActiveTeamBodySchema,requireHeaders:true,use:[import_call.orgSessionMiddleware,import_call.orgMiddleware],metadata:{openapi:{description:\"Set the active team\",responses:{\"200\":{description:\"Success\",content:{\"application/json\":{schema:{type:\"object\",description:\"The team\",$ref:\"#/components/schemas/Team\"}}}}}}}},async ctx=>{const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,ctx.context.orgOptions);const session=ctx.context.session;if(ctx.body.teamId===null){if(!session.session.activeTeamId)return ctx.json(null);await(0,import_cookies.setSessionCookie)(ctx,{session:await adapter.setActiveTeam(session.session.token,null,ctx),user:session.user});return ctx.json(null)}let teamId;if(!ctx.body.teamId){const sessionTeamId=session.session.activeTeamId;if(!sessionTeamId)return ctx.json(null);else teamId=sessionTeamId}else teamId=ctx.body.teamId;const team=await adapter.findTeamById({teamId});if(!team)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.TEAM_NOT_FOUND);if(!await adapter.findTeamMember({teamId,userId:session.user.id}))throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_TEAM);await(0,import_cookies.setSessionCookie)(ctx,{session:await adapter.setActiveTeam(session.session.token,team.id,ctx),user:session.user});return ctx.json(team)}),\"setActiveTeam\");const listUserTeams=__name(options=>(0,import_api2.createAuthEndpoint)(\"/organization/list-user-teams\",{method:\"GET\",metadata:{openapi:{description:\"List all teams that the current user is a part of.\",responses:{\"200\":{description:\"Teams retrieved successfully\",content:{\"application/json\":{schema:{type:\"array\",items:{type:\"object\",description:\"The team\",$ref:\"#/components/schemas/Team\"},description:\"Array of team objects within the organization\"}}}}}}},requireHeaders:true,use:[import_call.orgMiddleware,import_call.orgSessionMiddleware]},async ctx=>{const session=ctx.context.session;const teams=await(0,import_adapter.getOrgAdapter)(ctx.context,ctx.context.orgOptions).listTeamsByUser({userId:session.user.id});return ctx.json(teams)}),\"listUserTeams\");const listTeamMembersQuerySchema=z.optional(z.object({teamId:z.string().optional().meta({description:\"The team whose members we should return. If this is not provided the members of the current active team get returned.\"})}));const listTeamMembers=__name(options=>(0,import_api2.createAuthEndpoint)(\"/organization/list-team-members\",{method:\"GET\",query:listTeamMembersQuerySchema,metadata:{openapi:{description:\"List the members of the given team.\",responses:{\"200\":{description:\"Teams retrieved successfully\",content:{\"application/json\":{schema:{type:\"array\",items:{type:\"object\",description:\"The team member\",properties:{id:{type:\"string\",description:\"Unique identifier of the team member\"},userId:{type:\"string\",description:\"The user ID of the team member\"},teamId:{type:\"string\",description:\"The team ID of the team the team member is in\"},createdAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team member was created\"}},required:[\"id\",\"userId\",\"teamId\",\"createdAt\"]},description:\"Array of team member objects within the team\"}}}}}}},requireHeaders:true,use:[import_call.orgMiddleware,import_call.orgSessionMiddleware]},async ctx=>{const session=ctx.context.session;const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,ctx.context.orgOptions);const teamId=ctx.query?.teamId||session?.session.activeTeamId;if(!teamId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM);if(!await adapter.findTeamMember({userId:session.user.id,teamId}))throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_TEAM);const members=await adapter.listTeamMembers({teamId});return ctx.json(members)}),\"listTeamMembers\");const addTeamMemberBodySchema=z.object({teamId:z.string().meta({description:\"The team the user should be a member of.\"}),userId:z.coerce.string().meta({description:\"The user Id which represents the user to be added as a member.\"}),organizationId:z.string().meta({description:\"The organization ID which the team falls under. If not provided, it will default to the user's active organization.\"}).optional()});const addTeamMember=__name(options=>(0,import_api2.createAuthEndpoint)(\"/organization/add-team-member\",{method:\"POST\",body:addTeamMemberBodySchema,metadata:{openapi:{description:\"The newly created member\",responses:{\"200\":{description:\"Team member created successfully\",content:{\"application/json\":{schema:{type:\"object\",description:\"The team member\",properties:{id:{type:\"string\",description:\"Unique identifier of the team member\"},userId:{type:\"string\",description:\"The user ID of the team member\"},teamId:{type:\"string\",description:\"The team ID of the team the team member is in\"},createdAt:{type:\"string\",format:\"date-time\",description:\"Timestamp when the team member was created\"}},required:[\"id\",\"userId\",\"teamId\",\"createdAt\"]}}}}}}},requireHeaders:true,use:[import_call.orgMiddleware,import_call.orgSessionMiddleware]},async ctx=>{const session=ctx.context.session;const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,ctx.context.orgOptions);const organizationId=ctx.body.organizationId||session.session.activeOrganizationId;if(!organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION);const currentMember=await adapter.findMemberByOrgId({userId:session.user.id,organizationId});if(!currentMember)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION);if(!await(0,import_has_permission.hasPermission)({role:currentMember.role,options:ctx.context.orgOptions,permissions:{member:[\"update\"]},organizationId},ctx))throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER);if(!await adapter.findMemberByOrgId({userId:ctx.body.userId,organizationId}))throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION);const team=await adapter.findTeamById({teamId:ctx.body.teamId,organizationId});if(!team)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.TEAM_NOT_FOUND);const organization=await adapter.findOrganizationById(organizationId);if(!organization)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.ORGANIZATION_NOT_FOUND);const userBeingAdded=await ctx.context.internalAdapter.findUserById(ctx.body.userId);if(!userBeingAdded)throw import_error.APIError.fromStatus(\"BAD_REQUEST\",{message:\"User not found\"});if(options?.organizationHooks?.beforeAddTeamMember){const response=await options?.organizationHooks.beforeAddTeamMember({teamMember:{teamId:ctx.body.teamId,userId:ctx.body.userId},team,user:userBeingAdded,organization});if(response&&typeof response===\"object\"&&\"data\"in response){}}const teamMember=await adapter.findOrCreateTeamMember({teamId:ctx.body.teamId,userId:ctx.body.userId});if(options?.organizationHooks?.afterAddTeamMember)await options?.organizationHooks.afterAddTeamMember({teamMember,team,user:userBeingAdded,organization});return ctx.json(teamMember)}),\"addTeamMember\");const removeTeamMemberBodySchema=z.object({teamId:z.string().meta({description:\"The team the user should be removed from.\"}),userId:z.coerce.string().meta({description:\"The user which should be removed from the team.\"}),organizationId:z.string().meta({description:\"The organization ID which the team falls under. If not provided, it will default to the user's active organization.\"}).optional()});const removeTeamMember=__name(options=>(0,import_api2.createAuthEndpoint)(\"/organization/remove-team-member\",{method:\"POST\",body:removeTeamMemberBodySchema,metadata:{openapi:{description:\"Remove a member from a team\",responses:{\"200\":{description:\"Team member removed successfully\",content:{\"application/json\":{schema:{type:\"object\",properties:{message:{type:\"string\",description:\"Confirmation message indicating successful removal\",enum:[\"Team member removed successfully.\"]}},required:[\"message\"]}}}}}}},requireHeaders:true,use:[import_call.orgMiddleware,import_call.orgSessionMiddleware]},async ctx=>{const session=ctx.context.session;const adapter=(0,import_adapter.getOrgAdapter)(ctx.context,ctx.context.orgOptions);const organizationId=ctx.body.organizationId||session.session.activeOrganizationId;if(!organizationId)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION);const currentMember=await adapter.findMemberByOrgId({userId:session.user.id,organizationId});if(!currentMember)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION);if(!await(0,import_has_permission.hasPermission)({role:currentMember.role,options:ctx.context.orgOptions,permissions:{member:[\"delete\"]},organizationId},ctx))throw import_error.APIError.from(\"FORBIDDEN\",import_error_codes.ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER);if(!await adapter.findMemberByOrgId({userId:ctx.body.userId,organizationId}))throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION);const team=await adapter.findTeamById({teamId:ctx.body.teamId,organizationId});if(!team)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.TEAM_NOT_FOUND);const organization=await adapter.findOrganizationById(organizationId);if(!organization)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.ORGANIZATION_NOT_FOUND);const userBeingRemoved=await ctx.context.internalAdapter.findUserById(ctx.body.userId);if(!userBeingRemoved)throw import_error.APIError.fromStatus(\"BAD_REQUEST\",{message:\"User not found\"});const teamMember=await adapter.findTeamMember({teamId:ctx.body.teamId,userId:ctx.body.userId});if(!teamMember)throw import_error.APIError.from(\"BAD_REQUEST\",import_error_codes.ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_TEAM);if(options?.organizationHooks?.beforeRemoveTeamMember)await options?.organizationHooks.beforeRemoveTeamMember({teamMember,team,user:userBeingRemoved,organization});await adapter.removeTeamMember({teamId:ctx.body.teamId,userId:ctx.body.userId});if(options?.organizationHooks?.afterRemoveTeamMember)await options?.organizationHooks.afterRemoveTeamMember({teamMember,team,user:userBeingRemoved,organization});return ctx.json({message:\"Team member removed successfully.\"})}),\"removeTeamMember\");0&&(module.exports={addTeamMember,createTeam,listOrganizationTeams,listTeamMembers,listUserTeams,removeTeam,removeTeamMember,setActiveTeam,updateTeam});\n})()\n","warnings":[],"map":{"version":3,"mappings":";i/BAAA,gaAA4B,kCAC5B,cAAO,iCACP,mBAAiC,sCACjC,mBAAkC,2CAClC,eAAO,kCACP,uBAAyC,8BACzC,mBAA8B,0BAC9B,gBAAoD,uBACpD,0BAA8B,iCAC9B,kBAA2B,yBAC3B,iBAAyB,mCACzB,IAAAA,YAAmC,iCACnC,MAAmB,wBAGnB,MAAM,eAAiB,EAAE,OAAO,CAC/B,KAAM,EAAE,OAAO,EAAE,KAAK,CAAE,YAAa,qCAAwC,CAAC,EAC9E,eAAgB,EAAE,OAAO,EAAE,KAAK,CAAE,YAAa,mHAAsH,CAAC,EAAE,SAAS,CAClL,CAAC,EACD,MAAM,WAAa,OAAC,SAAY,CAC/B,MAAM,0BAAyB,2BAAY,CAC1C,OAAQ,SAAS,QAAQ,MAAM,kBAAoB,CAAC,EACpD,aAAc,IACf,CAAC,EACD,SAAO,gCAAmB,4BAA6B,CACtD,OAAQ,OACR,KAAM,EAAE,OAAO,CACd,GAAG,eAAe,MAClB,GAAG,uBAAuB,KAC3B,CAAC,EACD,IA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AAM,sBAAS,KAAK,cAAe,4CAAyB,cAAc,EACrF,MAAM,aAAe,MAAM,QAAQ,qBAAqB,cAAc,EACtE,GAAI,CAAC,aAAc,MAAM,sBAAS,KAAK,cAAe,4CAAyB,sBAAsB,EACrG,MAAM,iBAAmB,MAAM,IAAI,QAAQ,gBAAgB,aAAa,IAAI,KAAK,MAAM,EACvF,GAAI,CAAC,iBAAkB,MAAM,sBAAS,WAAW,cAAe,CAAE,QAAS,gBAAiB,CAAC,EAC7F,MAAM,WAAa,MAAM,QAAQ,eAAe,CAC/C,OAAQ,IAAI,KAAK,OACjB,OAAQ,IAAI,KAAK,MAClB,CAAC,EACD,GAAI,CAAC,WAAY,MAAM,sBAAS,KAAK,cAAe,4CAAyB,gCAAgC,EAC7G,GAAI,SAAS,mBAAmB,uBAAwB,MAAM,SAAS,kBAAkB,uBAAuB,CAC/G,WACA,KACA,KAAM,iBACN,YACD,CAAC,EACD,MAAM,QAAQ,iBAAiB,CAC9B,OAAQ,IAAI,KAAK,OACjB,OAAQ,IAAI,KAAK,MAClB,CAAC,EACD,GAAI,SAAS,mBAAmB,sBAAuB,MAAM,SAAS,kBAAkB,sBAAsB,CAC7G,WACA,KACA,KAAM,iBACN,YACD,CAAC,EACD,OAAO,IAAI,KAAK,CAAE,QAAS,mCAAoC,CAAC,CACjE,CAAC,EAvEwB","names":["import_api","updatedTeam"],"ignoreList":[],"sources":["/opt/canhelp/node_modules/better-auth/dist/plugins/organization/routes/crud-team.mjs"],"sourcesContent":[null]}}