import {z} from 'zod' export type GetApiApiV1ProjectsProjectIdIdentityMembershipsArgs = {offset?: number | undefined, limit?: number | undefined, orderBy?: 'name' | undefined, orderDirection?: ('asc' | 'desc') | undefined, search?: string | undefined, projectId: string}; export type GetApiApiV1ProjectsProjectIdIdentityMembershipsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApiV1ProjectsProjectIdIdentityMembershipsResponse = z.object({identityMemberships: z.array(z.object({id: z.string(), identityId: z.string(), createdAt: z.string(), updatedAt: z.string(), roles: z.array(z.object({id: z.string(), role: z.string(), customRoleId: z.string().nullable().optional(), customRoleName: z.string().nullable().optional(), customRoleSlug: z.string().nullable().optional(), isTemporary: z.boolean(), temporaryMode: z.string().nullable().optional(), temporaryRange: z.string().nullable().optional(), temporaryAccessStartTime: z.string().nullable().optional(), temporaryAccessEndTime: z.string().nullable().optional()})), identity: z.object({name: z.string(), id: z.string(), projectId: z.string().nullable().optional(), orgId: z.string(), authMethods: z.array(z.string())}), project: z.object({name: z.string(), id: z.string()})})), totalCount: z.number()}); 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 }; /** * Return project identity memberships * * GET /api/v1/projects/{projectId}/identity-memberships */ export const getApiApiV1ProjectsProjectIdIdentityMemberships = async (args: GetApiApiV1ProjectsProjectIdIdentityMembershipsArgs, options?: GetApiApiV1ProjectsProjectIdIdentityMembershipsOptions) => { const {baseUrl = "https://us.infisical.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.offset != null) query.append("offset", String(args.offset)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.orderBy != null) query.append("orderBy", String(args.orderBy)) if (args.orderDirection != null) query.append("orderDirection", String(args.orderDirection)) if (args.search != null) query.append("search", String(args.search)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/projects/${encodeURIComponent(String(args.projectId))}/identity-memberships${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiApiV1ProjectsProjectIdIdentityMembershipsResponse, await res.json()) };