import {z} from 'zod' export type ProjectUsersPublicAPI = {emailId?: string | undefined, userId?: number | undefined, firstName?: string | undefined, lastName?: string | undefined}; export type RemoveMembersPublicAPIRequestEntity = {members: Array}; export type CreateApi10ProjectsProjectIdRemoveMembersArgs = {projectId: number, body: RemoveMembersPublicAPIRequestEntity}; export type CreateApi10ProjectsProjectIdRemoveMembersOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const projectOwnerUserPublicResponse = z.object({emailId: z.string().optional(), userId: z.number().int().optional(), firstName: z.string().optional(), lastName: z.string().optional()}); export const projectVendorUserPublicAPI = z.object({emailId: z.string().optional(), userId: z.number().int().optional(), firstName: z.string().optional(), lastName: z.string().optional()}); export const projectCustomerUserPublicAPI = z.object({emailId: z.string().optional(), userId: z.number().int().optional(), firstName: z.string().optional(), lastName: z.string().optional()}); export const projectCustomerChampionUserPublicAPI = z.object({emailId: z.string().optional(), userId: z.number().int().optional(), firstName: z.string().optional(), lastName: z.string().optional()}); export const projectResponseMembersResponse = z.object({members: z.array(projectVendorUserPublicAPI).optional(), customers: z.array(projectCustomerUserPublicAPI).optional(), customerChampion: projectCustomerChampionUserPublicAPI.optional()}); export const projectStatusPublicResponse = z.object({value: z.number().int().gte(1).optional(), label: z.string().optional()}); export const projectFieldPublicResponseAPIEntity = z.object({fieldId: z.number().int().gte(1).optional(), fieldLabel: z.string().optional(), fieldValue: z.string().optional(), fieldValueLabel: z.string().optional()}); export const customerCompanyProjectPublicResponse = z.object({companyId: z.number().int().gte(1).optional(), companyName: z.string().optional(), companyUrl: z.string().optional()}); export const projectPartnerCompanyPublicAPIResponseEntity = z.object({companyId: z.number().int().gte(1).optional(), companyName: z.string().optional(), companyUrl: z.string().optional()}); export const projectPublicCreatedByResponse = z.object({emailId: z.string().optional(), userId: z.number().int().optional(), firstName: z.string().optional(), lastName: z.string().optional()}); export const projectPublicUpdatedByResponse = z.object({emailId: z.string().optional(), userId: z.number().int().optional(), firstName: z.string().optional(), lastName: z.string().optional()}); export const fixedFeeFinancialsPublicResponse = z.object({fixedFee: z.number().optional()}); export const projectRateCardPublicResponse = z.object({rateCardId: z.number().int().optional(), rateCardName: z.string().optional()}); export const timeAndMaterialFinancialsPublicResponse = z.object({rateCard: projectRateCardPublicResponse.optional(), projectBudget: z.number().gte(1).optional()}); export const subscriptionFinancialsPublicResponse = z.object({subscriptionFrequency: z.enum(["MONTHLY", "QUARTERLY", "YEARLY", "HALF_YEARLY"]).optional(), subscriptionStartDate: z.string().optional(), periodMinutes: z.number().int().gte(1).optional(), periodBudget: z.number().optional(), noOfPeriods: z.number().int().gte(1).optional()}); export const projectFinancialsMetrics = z.object({actualRevenue: z.number().optional(), estimatedRevenue: z.number().optional(), actualCost: z.number().optional(), estimatedCost: z.number().optional(), actualProfit: z.number().optional(), estimatedProfit: z.number().optional(), actualProfitMargin: z.number().optional(), estimatedProfitMargin: z.number().optional(), estimateAtCompletion: z.number().optional(), estimationToCompletionInHours: z.number().optional()}); export const projectFinancialsPublicResponse = z.object({contractType: z.enum(["FIXED_FEE", "TIME_AND_MATERIAL", "SUBSCRIPTION", "NON_BILLABLE"]).optional(), revenueRecognitionType: z.string().optional(), fixedFeeContract: fixedFeeFinancialsPublicResponse.optional(), timeAndMaterialContract: timeAndMaterialFinancialsPublicResponse.optional(), subscriptionContract: subscriptionFinancialsPublicResponse.optional(), metrics: projectFinancialsMetrics.optional()}); export const projectPublicTeamMembersAPIResponseEntity = z.object({projectId: z.number().int().gte(1).optional(), projectName: z.string().optional(), startDate: z.string().optional(), dueDate: z.string().optional(), createdAt: z.number().int().optional(), updatedAt: z.number().int().optional(), owner: projectOwnerUserPublicResponse.optional(), teamMembers: projectResponseMembersResponse.optional(), status: projectStatusPublicResponse.optional(), fields: z.array(projectFieldPublicResponseAPIEntity).optional(), customer: customerCompanyProjectPublicResponse.optional(), partnerCompanies: z.array(projectPartnerCompanyPublicAPIResponseEntity).optional(), archived: z.boolean().optional(), visibility: z.enum(["EVERYONE", "MEMBERS", "GROUP"]).optional(), createdBy: projectPublicCreatedByResponse.optional(), updatedBy: projectPublicUpdatedByResponse.optional(), currency: z.enum(["AFN", "ALL", "DZD", "ARS", "AMD", "AUD", "AZN", "BHD", "BDT", "BYN", "BZD", "BOB", "BAM", "BWP", "BRL", "GBP", "BND", "BGN", "BIF", "KHR", "CAD", "CVE", "XAF", "CLP", "CNY", "COP", "KMF", "CDF", "CRC", "HRK", "CZK", "DKK", "DJF", "DOP", "EGP", "ERN", "EEK", "ETB", "EUR", "GEL", "GHS", "GTQ", "GNF", "HNL", "HKD", "HUF", "ISK", "INR", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KWD", "LVL", "LBP", "LYD", "LTL", "MOP", "MKD", "MGA", "MYR", "MUR", "MXN", "MDL", "MAD", "MZN", "MMK", "NAD", "NPR", "TWD", "NZD", "NIO", "NGN", "NOK", "OMR", "PKR", "PAB", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SAR", "RSD", "SGD", "SOS", "ZAR", "KRW", "LKR", "SDG", "SEK", "CHF", "SYP", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "USD", "UGX", "UAH", "AED", "UYU", "UZS", "VEF", "VND", "XOF", "YER", "ZMK", "ZWL"]).optional(), financials: projectFinancialsPublicResponse.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Remove members from a project * * POST /1.0/projects/{projectId}/remove-members */ export const createApi10ProjectsProjectIdRemoveMembers = async (args: CreateApi10ProjectsProjectIdRemoveMembersArgs, options?: CreateApi10ProjectsProjectIdRemoveMembersOptions) => { const {baseUrl = "https://api.rocketlane.com/api", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apiKey !== undefined) headers.set("api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/1.0/projects/${encodeURIComponent(String(args.projectId))}/remove-members${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(projectPublicTeamMembersAPIResponseEntity, await res.json()) };