export type UserRole = 'admin' | 'editor' | 'viewer' | 'external' | 'basic'; export type Permission = {role?: UserRole | undefined, team_scopes?: Array | undefined, view_dev_coaching?: boolean | undefined}; export type TeamMembership = {name: string, joined_at?: string | undefined}; export type CustomInfo = {extra_emails?: Array | undefined, extra_ids?: Array | undefined}; export type UserCreationModel = {name: string, email: string, permission?: Permission | undefined, team_membership?: Array | undefined, custom_info?: CustomInfo | undefined}; export type CreateApiApiV1UsersArgs = {body: Array}; export type CreateApiApiV1UsersOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Users Api * * POST /api/v1/users */ export const createApiApiV1Users = async (args: CreateApiApiV1UsersArgs, options?: CreateApiApiV1UsersOptions) => { const {baseUrl = "https://public-api.linearb.io", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIKeyHeader !== undefined) headers.set("x-api-key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/users${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 undefined };