import {z} from 'zod' export type CreateApiAppsAppSlugProvisioningProfilesProvisioningProfileSlugUploadedArgs = {'app-slug': string, 'provisioning-profile-slug': string}; export type CreateApiAppsAppSlugProvisioningProfilesProvisioningProfileSlugUploadedOptions = {baseUrl?: string | undefined, PersonalAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; export const v0ProvisionProfileResponseItemModel = z.object({expiry_date: z.string().optional(), file_sha256: z.string().optional(), is_expose: z.boolean().optional(), is_protected: z.boolean().optional(), processed: z.boolean().optional(), slug: z.string().optional(), upload_file_name: z.string().optional(), upload_file_size: z.number().int().optional(), uuid: z.string().optional()}); export const v0ProvisionProfileResponseModel = z.object({data: v0ProvisionProfileResponseItemModel.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 }; /** * Confirm a provisioning profile upload * * POST /apps/{app-slug}/provisioning-profiles/{provisioning-profile-slug}/uploaded */ export const createApiAppsAppSlugProvisioningProfilesProvisioningProfileSlugUploaded = async (args: CreateApiAppsAppSlugProvisioningProfilesProvisioningProfileSlugUploadedArgs, options?: CreateApiAppsAppSlugProvisioningProfilesProvisioningProfileSlugUploadedOptions) => { const {baseUrl = "https://api.bitrise.io/v0.1", fetch: fetchFn = fetch, PersonalAccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (PersonalAccessToken !== undefined) headers.set("Authorization", PersonalAccessToken) const url = `${baseUrl.replace(/\/+$/, '')}/apps/${encodeURIComponent(String(args['app-slug']))}/provisioning-profiles/${encodeURIComponent(String(args['provisioning-profile-slug']))}/uploaded${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(v0ProvisionProfileResponseModel, await res.json()) };