export type UserFixture = {key: string, name: string, email: string, password: string}; export type UserTokenFixture = {key: string, userKey: string, token: string, name?: string | undefined}; export type OrgFixture = {key: string, name: string, description?: string | undefined}; export type OrgUserFixture = {key: string, orgKey: string, userKey: string, role: 'owner' | 'admin' | 'viewer' | 'member' | 'collaborator' | 'billing_manager'}; export type ProjectFixture = {key: string, name: string, orgKey: string, description?: string | undefined}; export type ProjectTokenFixture = {key: string, projectKey: string, token: string, name?: string | undefined}; export type ProjectUserFixture = {key: string, projectKey: string, orgUserKey: string, permLevel: 'admin' | 'maintain' | 'view' | 'none'}; export type SeedDataRequest = {users?: Array | undefined, userTokens?: Array | undefined, orgs?: Array | undefined, orgUsers?: Array | undefined, projects?: Array | undefined, projectTokens?: Array | undefined, projectUsers?: Array | undefined}; export type UpdateApiApiV1FixturesArgs = {body: SeedDataRequest}; export type UpdateApiApiV1FixturesOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sync fixtures * * PUT /api/v1/fixtures * * Also accepts auth: authTokenQuery */ export const updateApiApiV1Fixtures = async (args: UpdateApiApiV1FixturesArgs, options?: UpdateApiApiV1FixturesOptions) => { const {baseUrl = "https://api.uptrace.dev", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/fixtures${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };