import {z} from 'zod' export type BatchMasterRightInput = {access_account_relation_types?: boolean | undefined, access_accounts?: boolean | undefined, access_ai_automatizer?: boolean | undefined, access_ai_online_forms?: boolean | undefined, access_ai_record_detail?: boolean | undefined, access_ai_record_enrichment?: boolean | undefined, access_ai_relationship_charts?: boolean | undefined, access_ai_reports?: boolean | undefined, access_ai_smart_field?: boolean | undefined, access_appointment_scheduler?: boolean | undefined, access_appointment_scheduler_management?: boolean | undefined, access_approval_processes?: boolean | undefined, access_approval_processes_management?: boolean | undefined, access_approvals?: boolean | undefined, access_archive?: boolean | undefined, access_audit?: boolean | undefined, access_audit_log?: boolean | undefined, access_bottom_menu_customization?: boolean | undefined, access_bulk_update?: boolean | undefined, access_calling?: boolean | undefined, access_calling_company_phone?: (0 | 1 | 2) | undefined, access_calling_purchase_phone?: boolean | undefined, access_company_emails?: (0 | 1 | 2) | undefined, access_contacts?: boolean | undefined, access_document_management?: boolean | undefined, access_document_management_company?: boolean | undefined, access_document_management_record?: boolean | undefined, access_duplicate_checker?: boolean | undefined, access_email_notification_enforcement?: boolean | undefined, access_email_notification_settings?: Record | undefined, access_entity_account?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_account_copy?: boolean | undefined, access_entity_account_delete?: boolean | undefined, access_entity_account_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_account_private?: boolean | undefined, access_entity_account_tag_create?: boolean | undefined, access_entity_account_types?: (1 | 2) | undefined, access_entity_appointment?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_appointment_delete?: boolean | undefined, access_entity_appointment_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_appointment_tag_create?: boolean | undefined, access_entity_appointment_types?: (1 | 2) | undefined, access_entity_better_navigator?: (0 | 1 | 4) | undefined, access_entity_better_navigator_delete_not_owned?: boolean | undefined, access_entity_better_navigator_delete_owned?: boolean | undefined, access_entity_better_navigator_sharing_custom?: boolean | undefined, access_entity_better_navigator_sharing_public?: boolean | undefined, access_entity_contact?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_contact_copy?: boolean | undefined, access_entity_contact_delete?: boolean | undefined, access_entity_contact_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_contact_private?: boolean | undefined, access_entity_contact_tag_create?: boolean | undefined, access_entity_contact_types?: (1 | 2) | undefined, access_entity_dashboard?: (0 | 1 | 4) | undefined, access_entity_dashboard_delete_not_owned?: boolean | undefined, access_entity_dashboard_delete_owned?: boolean | undefined, access_entity_dashboard_sharing_custom?: boolean | undefined, access_entity_dashboard_sharing_public?: boolean | undefined, access_entity_email_access_level?: (0 | 1) | undefined, access_entity_email_allowed?: Record | undefined, access_entity_email_content_share_mode?: (0 | 1 | 2) | undefined, access_entity_email_delete_not_owned?: boolean | undefined, access_entity_email_link_to_accounts?: (0 | 1 | 2) | undefined, access_entity_email_link_to_accounts_by_domain?: (0 | 1 | 2) | undefined, access_entity_email_link_to_contacts?: (0 | 1 | 2) | undefined, access_entity_email_sequence?: (1 | 2 | 3) | undefined, access_entity_email_template?: (0 | 1 | 4) | undefined, access_entity_email_template_create_delete_folder?: boolean | undefined, access_entity_email_template_delete_not_owned?: boolean | undefined, access_entity_email_template_delete_owned?: boolean | undefined, access_entity_email_template_sharing_custom?: boolean | undefined, access_entity_email_template_sharing_public?: boolean | undefined, access_entity_forecast?: (0 | 1 | 4) | undefined, access_entity_forecast_delete_not_owned?: boolean | undefined, access_entity_forecast_delete_owned?: boolean | undefined, access_entity_forecast_edit_not_owned?: boolean | undefined, access_entity_forecast_sharing_custom?: boolean | undefined, access_entity_forecast_sharing_public?: boolean | undefined, access_entity_form_view?: (0 | 1 | 4) | undefined, access_entity_form_view_delete_not_owned?: boolean | undefined, access_entity_form_view_delete_owned?: boolean | undefined, access_entity_form_view_sharing_custom?: boolean | undefined, access_entity_form_view_sharing_public?: boolean | undefined, access_entity_lead?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_lead_copy?: boolean | undefined, access_entity_lead_delete?: boolean | undefined, access_entity_lead_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_lead_private?: boolean | undefined, access_entity_lead_tag_create?: boolean | undefined, access_entity_lead_types?: (1 | 2) | undefined, access_entity_message_tag_create?: boolean | undefined, access_entity_oppty?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_oppty_copy?: boolean | undefined, access_entity_oppty_delete?: boolean | undefined, access_entity_oppty_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_oppty_private?: boolean | undefined, access_entity_oppty_tag_create?: boolean | undefined, access_entity_pipeline?: (0 | 1 | 2 | 3) | undefined, access_entity_process?: (1 | 2 | 3) | undefined, access_entity_profile?: (0 | 1 | 4) | undefined, access_entity_profile_default_screen_profiles?: Record | undefined, access_entity_profile_delete_not_owned?: boolean | undefined, access_entity_profile_delete_owned?: boolean | undefined, access_entity_profile_sharing_custom?: boolean | undefined, access_entity_profile_sharing_public?: boolean | undefined, access_entity_project?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_project_copy?: boolean | undefined, access_entity_project_delete?: boolean | undefined, access_entity_project_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_project_private?: boolean | undefined, access_entity_project_tag_create?: boolean | undefined, access_entity_quote?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_quote_copy?: boolean | undefined, access_entity_quote_delete?: boolean | undefined, access_entity_quote_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_quote_tag_create?: boolean | undefined, access_entity_quote_types?: (1 | 2) | undefined, access_entity_report?: (0 | 1 | 4) | undefined, access_entity_report_create_delete_folder?: boolean | undefined, access_entity_report_delete_not_owned?: boolean | undefined, access_entity_report_delete_owned?: boolean | undefined, access_entity_report_private?: boolean | undefined, access_entity_report_schedule_create?: boolean | undefined, access_entity_report_schedule_management?: boolean | undefined, access_entity_report_sharing_custom?: boolean | undefined, access_entity_report_sharing_public?: boolean | undefined, access_entity_solution?: boolean | undefined, access_entity_solution_management?: boolean | undefined, access_entity_target?: (0 | 1 | 4) | undefined, access_entity_target_delete_not_owned?: boolean | undefined, access_entity_target_delete_owned?: boolean | undefined, access_entity_task?: (0 | 1 | 2 | 3 | 4) | undefined, access_entity_task_delete?: boolean | undefined, access_entity_task_direction?: (1 | 2 | 3 | 4 | 5 | 6) | undefined, access_entity_task_tag_create?: boolean | undefined, access_entity_task_types?: (1 | 2) | undefined, access_entity_task_unassigned?: boolean | undefined, access_export?: boolean | undefined, access_feeds?: boolean | undefined, access_foreign_currencies?: boolean | undefined, access_form_and_fields?: boolean | undefined, access_global_settings?: boolean | undefined, access_home_screen?: boolean | undefined, access_import?: boolean | undefined, access_insights?: boolean | undefined, access_leads?: boolean | undefined, access_online_forms?: boolean | undefined, access_online_forms_management?: boolean | undefined, access_opportunity?: boolean | undefined, access_pipeline_configuration?: boolean | undefined, access_print?: boolean | undefined, access_products_services?: boolean | undefined, access_projects?: boolean | undefined, access_quotes?: boolean | undefined, access_sales_roles?: boolean | undefined, access_security?: boolean | undefined, access_units?: boolean | undefined, access_user_and_roles?: boolean | undefined, access_whats_app_company_phone?: (0 | 1 | 2) | undefined, bottom_menu_layout?: Record | undefined, name?: string | undefined, revision?: number | undefined, allowed_pipelines?: (Array<{id?: string | undefined}>) | undefined, allowed_lead_types?: (Array<{id?: string | undefined}>) | undefined, allowed_quote_types?: (Array<{id?: string | undefined}>) | undefined, allowed_account_types?: (Array<{id?: string | undefined}>) | undefined, allowed_contact_types?: (Array<{id?: string | undefined}>) | undefined, allowed_task_types?: (Array<{id?: string | undefined}>) | undefined, allowed_appointment_types?: (Array<{id?: string | undefined}>) | undefined, allowed_company_emails?: (Array<{id?: string | undefined}>) | undefined, allowed_company_phones?: (Array<{id?: string | undefined}>) | undefined, custom_entities?: string | undefined, id?: string | undefined}; export type CreateApiEntitiesMasterRightsBatchModifyArgs = {'validation-level'?: number | undefined, 'rollback-method'?: (0 | 1) | undefined, body: Array}; export type CreateApiEntitiesMasterRightsBatchModifyOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const error = z.object({http_status: z.number().int(), code: z.number().int().optional(), name: z.string().optional(), message: z.string().optional(), success: z.boolean()}); export const createApiEntitiesMasterRightsBatchModifyResponse = z.object({success: z.boolean().optional(), data: z.array(z.union([z.string(), error])).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 }; /** * MasterRights.batch_create_or_update * * POST /entities/MasterRights/batch-modify */ export const createApiEntitiesMasterRightsBatchModify = async (args: CreateApiEntitiesMasterRightsBatchModifyArgs, options?: CreateApiEntitiesMasterRightsBatchModifyOptions) => { const {baseUrl = "https://us-east.api.coevera.com/api/v100/rest/spaces/your_space_id", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['validation-level'] != null) query.append("validation-level", String(args['validation-level'])) if (args['rollback-method'] != null) query.append("rollback-method", String(args['rollback-method'])) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/entities/MasterRights/batch-modify${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 validateResponse(createApiEntitiesMasterRightsBatchModifyResponse, await res.json()) };