import {z} from 'zod' export type TeamId = number; export type MemberId = number; export type GetApiTeamsTeamIdListAuditLogEventsArgs = {team_id: TeamId, from: number, to: number, memberId?: (MemberId | null) | undefined, action?: ('team:join' | 'team:create' | 'team:update' | 'team:delete' | 'project:create' | 'project:transfer' | 'project:receive' | 'project:update' | 'project:delete' | 'defaultEnvironmentVariable:create' | 'defaultEnvironmentVariable:update' | 'defaultEnvironmentVariable:delete' | 'deployment:create' | 'deployment:delete' | 'member:invite' | 'member:cancelInvitation' | 'member:remove' | 'member:updateRole' | 'project:updateMemberRole' | 'billing:paymentMethod:update' | 'billing:contact:update' | 'billing:address:update' | 'billing:subscription:create' | 'billing:subscription:resume' | 'billing:subscription:cancel' | 'billing:subscription:changePlan' | 'team:token:create' | 'team:token:update' | 'team:token:delete' | 'team:token:view' | 'project:token:create' | 'project:token:update' | 'project:token:delete' | 'project:token:view' | 'deployment:token:create' | 'deployment:token:update' | 'deployment:token:delete' | 'deployment:token:view' | 'member:token:createWithSsoAccess' | 'team:domain:create' | 'team:domain:delete' | 'deployment:customDomain:create' | 'deployment:customDomain:delete' | 'deployment:backups:create' | 'deployment:backups:import' | 'deployment:backups:configurePeriodic' | 'deployment:backups:disablePeriodic' | 'deployment:backups:delete' | 'team:disableExceedingSpendingLimits' | 'billing:spendingLimit:update' | 'team:applyReferralCode' | 'oauthApplication:create' | 'oauthApplication:update' | 'oauthApplication:delete' | 'oauthApplication:verify' | 'oauthApplication:generateClientSecret' | 'integration:workos:team:create' | 'integration:workos:environment:create' | 'integration:workos:environment:delete' | 'integration:workos:environment:retrieveCredentials' | 'integration:workos:team:disconnect' | 'integration:workos:team:inviteMember' | 'integration:workos:projectEnvironment:create' | 'integration:workos:projectEnvironment:delete' | 'integration:workos:projectEnvironment:retrieveCredentials' | 'sso:enable' | 'sso:disable' | 'sso:update' | 'member:loginWithSso' | 'directorySync:enable' | 'directorySync:disable' | 'directorySync:updateGroupMapping' | 'directorySync:deleteGroupMapping' | 'deployment:transfer' | 'deployment:receive' | 'deployment:update' | 'customRole:create' | 'customRole:update' | 'customRole:delete') | undefined, limit?: (number | null) | undefined, cursor?: (string | null) | undefined}; export type GetApiTeamsTeamIdListAuditLogEventsOptions = {baseUrl?: string | undefined, PAT?: string | undefined, fetch?: typeof fetch | undefined}; export const teamId = z.number().int().gte(0); export const memberId = z.number().int().gte(0); export const accessTokenId = z.number().int().gte(0); export const auditLogActor = z.union([z.object({kind: z.literal("system")}), z.object({member_id: memberId, kind: z.literal("member")}), z.object({member_id: memberId.nullable().optional(), token_id: accessTokenId, client_id: z.string().nullable().optional(), kind: z.literal("token")}), z.object({client_id: z.string(), kind: z.literal("integration")})]); export const value = z.unknown(); export const auditLogEventResponse = z.object({teamId: teamId, actor: auditLogActor, action: z.enum(["team:join", "team:create", "team:update", "team:delete", "project:create", "project:transfer", "project:receive", "project:update", "project:delete", "defaultEnvironmentVariable:create", "defaultEnvironmentVariable:update", "defaultEnvironmentVariable:delete", "deployment:create", "deployment:delete", "member:invite", "member:cancelInvitation", "member:remove", "member:updateRole", "project:updateMemberRole", "billing:paymentMethod:update", "billing:contact:update", "billing:address:update", "billing:subscription:create", "billing:subscription:resume", "billing:subscription:cancel", "billing:subscription:changePlan", "team:token:create", "team:token:update", "team:token:delete", "team:token:view", "project:token:create", "project:token:update", "project:token:delete", "project:token:view", "deployment:token:create", "deployment:token:update", "deployment:token:delete", "deployment:token:view", "member:token:createWithSsoAccess", "team:domain:create", "team:domain:delete", "deployment:customDomain:create", "deployment:customDomain:delete", "deployment:backups:create", "deployment:backups:import", "deployment:backups:configurePeriodic", "deployment:backups:disablePeriodic", "deployment:backups:delete", "team:disableExceedingSpendingLimits", "billing:spendingLimit:update", "team:applyReferralCode", "oauthApplication:create", "oauthApplication:update", "oauthApplication:delete", "oauthApplication:verify", "oauthApplication:generateClientSecret", "integration:workos:team:create", "integration:workos:environment:create", "integration:workos:environment:delete", "integration:workos:environment:retrieveCredentials", "integration:workos:team:disconnect", "integration:workos:team:inviteMember", "integration:workos:projectEnvironment:create", "integration:workos:projectEnvironment:delete", "integration:workos:projectEnvironment:retrieveCredentials", "sso:enable", "sso:disable", "sso:update", "member:loginWithSso", "directorySync:enable", "directorySync:disable", "directorySync:updateGroupMapping", "directorySync:deleteGroupMapping", "deployment:transfer", "deployment:receive", "deployment:update", "customRole:create", "customRole:update", "customRole:delete"]), createTime: z.number().int(), metadata: value, clientIp: z.string().nullable().optional(), clientUserAgent: z.string().nullable().optional()}); export const paginationMetadata = z.object({hasMore: z.boolean(), nextCursor: z.string().nullable().optional()}); export const listAuditLogEventsResponse = z.object({items: z.array(auditLogEventResponse), pagination: paginationMetadata}); 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 }; /** * List audit log events * * GET /teams/{team_id}/list_audit_log_events * * Also accepts auth: Team Token */ export const getApiTeamsTeamIdListAuditLogEvents = async (args: GetApiTeamsTeamIdListAuditLogEventsArgs, options?: GetApiTeamsTeamIdListAuditLogEventsOptions) => { const {baseUrl = "https://api.convex.dev/v1", fetch: fetchFn = fetch, PAT} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.memberId != null) query.append("memberId", String(args.memberId)) if (args.action != null) query.append("action", String(args.action)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (PAT !== undefined) headers.set('authorization', `Bearer ${PAT}`) const url = `${baseUrl.replace(/\/+$/, '')}/teams/${encodeURIComponent(String(args.team_id))}/list_audit_log_events${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(listAuditLogEventsResponse, await res.json()) };