import { MiniPage, File, CanvasRetrieve } from '../../types/openapi'; /** * Payload for getting instance metadata templates. */ export interface GetInstanceMetadataTemplatesPayload { /** * Ordering of the metadata templates. String containing field name to order by. */ ordering?: string; /** * Page number for pagination. */ page?: number; /** * Number of items per page. */ page_size?: number; /** * Search query for filtering metadata templates. */ search?: string; } /** * Payload for listing files with optional filters. */ export type ListFilesPayload = Partial> & { /** * Range filter for creation date. */ created_at__range?: string; /** * Range filter for expiration date. */ expires_at__range?: string; /** * Range filter for update date. */ updated_at__range?: string; /** * Filter for file IDs. */ id__in?: string; /** * Filter for file types. */ type?: File['type'] | File['type'][]; /** * Filter for content types. */ content_type?: File['content_type'] | File['content_type'][]; }; /** * Payload for sending a notification. */ export interface NotificationPayload { /** * Content of the notification. */ content: string; /** * Type of the notification. */ type?: 'native' | 'alert'; } /** * Payload for executing a query. */ export interface QueryPayload { /** * The query string to execute. */ query: string; /** * Optional arguments for the query. */ args?: string[][]; } export type CRMServiceType = 'salesforce' | 'dynamics' | 'sap'; /** * Payload for executing a query against CRM. */ export interface CRMQueryPayload { /** * The query string to execute. */ query: string; /** * Optional name of the service to be queried. */ service?: CRMServiceType; } /** * Payload for retrieving CRM smart object metadata (iOS only). */ export interface CRMSmartObjectMetadataPayload { /** * The name of the CRM object to retrieve metadata for (e.g., 'Account', 'Contact', 'Opportunity'). */ object: string; /** * Optional record type ID to retrieve metadata for a specific record type. */ record_type_id?: string; } /** * Payload for submitting user feedback. */ export interface SubmitUserFeedbackPayload { /** * Type of feedback being submitted. */ type: 'bug' | 'feedback'; /** * Data associated with the feedback. */ data: Record; } /** * Payload object for opening a file. */ export interface OpenRequestPayload { /** * Id of the file to open. */ fileId?: File['id']; /** * Ids of the files to open and the strategy to open them with. */ files?: { ids: File['id'][]; strategy: 'simultaneous' | 'swap'; }; /** * Id of the canvas section from which the file is opened. */ usedInSectionId?: CanvasRetrieve['id']; /** * Id of the canvas from which the file is opened. */ fromCanvasId?: CanvasRetrieve['id']; /** * Optional, page index to open. Default is `null`. */ pageIndex?: MiniPage['page_index']; /** * Optional, video start timestamp in seconds. Default is `null`. */ startTime?: number; /** * URL of the file content. */ url?: File['content_url']; /** * Indicates if the canvas is in view. */ canvasInView?: boolean; /** * Indicates if the user is in a call. */ isInCall?: boolean; /** * Optional, overrides over the context of the current canvas, useful for injecting file annotation data. Default is {}. */ context?: Record; /** * Search query string within the file. */ search?: string; /** * Indicates if the file should be opened in a new tab. */ newTab?: boolean; /** * Indicates if the app should be opened as overlay. */ isOverlayApp?: boolean; /** * Tracking id for the canvas presentation session. */ canvasCorrelationId?: string; } /** * Payload object for opening an external URL. */ export interface OpenExternalUrlRequestPayload { /** * The URL to open. */ url: string; /** * The target where the URL should be opened. Defaults to '_blank'. */ target?: '_self' | '_blank'; /** * Additional options for opening the URL. */ options?: string; } /** * Payload object for opening a web view that is always on top. */ export interface OpenWebViewAlwaysOnTop { /** * The URL to open in the web view. */ url: string; /** * Settings for the modal window. */ modal_settings: { /** * The width of the modal window. */ width: number; /** * The height of the modal window. */ height: number; /** * The y-coordinate of the modal window. */ y: number; /** * The x-coordinate of the modal window. */ x: number; }; } /** * Payload for iOS sharing dialog. */ export interface SharePayload { /** * Text to be shared. */ text: string; /** * Subject */ subject?: string; /** * Body */ body?: string; } /** * Represents a response to a iOS sharing dialog. */ export type ShareResponse = { /** * Action taken by the user. */ user_action: 'cancelled' | 'shared'; /** * Type of share action. */ activity_type?: string; }; /** * Payload for showing peer session dialog. */ export interface ShowPeerSessionRequestPayload { /** * The x-coordinate of the button that triggered the action. */ x: number; /** * The y-coordinate of the button that triggered the action. */ y: number; } /** * Payload for showing syncbox dialog. */ export interface ShowSyncboxRequestPayload { /** * The x-coordinate of the button that triggered the action. */ x: number; /** * The y-coordinate of the button that triggered the action. */ y: number; } export type FolderListRequest = { search?: string; ordering?: string; filters?: Record; fields?: string; name?: string; page?: number; page_size?: number; id__in?: string[]; }; /** * Represents a single CRM object to be upserted. */ export interface UpsertCRMObject { /** * The name of the CRM table/object to upsert into. */ table_name: string; /** * Array of objects to upsert. Each object is a key-value map of field names to values. * * **Important**: When creating new records, each object must include an explicit identifier field * (e.g., `Id`) passed from the frontend. The backend does not auto-generate IDs. */ objects: Array>; /** * Optional external ID path for identifying records during upsert. * Used to determine if a record should be created or updated. * * **Important**: Always provide this field when performing updates to ensure records are * matched correctly. Without it, the operation may create duplicate records instead of updating existing ones. */ external_id_path?: string; } /** * Payload for upserting CRM objects (iOS only). */ export interface UpsertCRMObjectsPayload { /** * Array of CRM objects to be upserted. */ objects: UpsertCRMObject[]; } /** * Payload for getting CRM smart object validation rules (iOS only). */ export interface CRMSmartObjectValidationRulesPayload { /** * The name of the CRM object (e.g., 'Account', 'Contact', 'Opportunity'). */ object: string; } /** * Payload for getting CRM smart object layout (iOS only). */ export interface CRMSmartObjectLayoutPayload { /** * The name of the CRM object (e.g., 'Account', 'Contact', 'Opportunity'). */ object: string; /** * Optional form factor (e.g., 'Large', 'Medium', 'Small'). */ form_factor?: string; /** * Optional layout type (e.g., 'Full', 'Compact'). */ layout_type?: string; /** * Optional mode (e.g., 'Create', 'Edit', 'View'). */ mode?: string; /** * Optional record type ID. */ record_type_id?: string; } /** * Represents a single CRM object to be deleted. */ export interface CRMDeleteObject { /** * Array of IDs of the records to delete. */ ids: string[]; /** * The name of the CRM table/object to delete from. */ table_name: string; } /** * Payload for deleting CRM objects (iOS only). */ export interface CRMSmartDeleteObjectsPayload { /** * Array of CRM objects to be deleted. */ objects: CRMDeleteObject[]; } /** * Payload for creating CRM records (Web only). * Uses Salesforce REST API to create records. */ export interface CRMCreatePayload { /** * The Salesforce object type (e.g., 'Account', 'Contact', 'Order__c'). */ sobject: string; /** * Array of records to create. Each record is a key-value map of field names to values. * Field names should use Salesforce API names (e.g., 'Account__c', 'Order_Date__c'). */ records: Array>; /** * Optional name of the CRM service to use. */ service?: CRMServiceType; } /** * Payload for upserting CRM records (Web only). * Uses Salesforce REST API to insert or update records based on external ID. */ export interface CRMUpsertPayload { /** * The Salesforce object type (e.g., 'Account', 'Contact', 'Order__c'). */ sobject: string; /** * Array of records to upsert. Each record is a key-value map of field names to values. * Field names should use Salesforce API names (e.g., 'Account__c', 'Order_Date__c'). */ records: Array>; /** * The external ID field used to match existing records for update. * If a record with matching external ID exists, it will be updated; otherwise, a new record is created. */ external_id_field: string; /** * Optional name of the CRM service to use. */ service?: CRMServiceType; } /** * Payload for retrieving CRM object metadata/describe (Web only). * Uses Salesforce REST API to fetch object metadata including fields and picklist values. */ export interface CRMDescribePayload { /** * The Salesforce object type to describe (e.g., 'Account', 'Contact', 'Opportunity'). */ sobject: string; /** * Optional name of the CRM service to use. */ service?: CRMServiceType; } /** * Payload for retrieving CRM object layout (Web only). * Uses Salesforce REST API to fetch object layout information including sections, fields arrangement, and form factors. */ export interface CRMLayoutPayload { /** * The Salesforce object type to get layout for (e.g., 'Account', 'Contact', 'Opportunity'). */ sobject: string; /** * Optional form factor (e.g., 'Large', 'Medium', 'Small'). */ form_factor?: string; /** * Optional layout type (e.g., 'Full', 'Compact'). */ layout_type?: string; /** * Optional mode (e.g., 'Create', 'Edit', 'View'). */ mode?: string; /** * Optional record type ID for record type specific layouts. */ record_type_id?: string; /** * Optional name of the CRM service to use. */ service?: CRMServiceType; } /** * Capabilities of the AI runtime serving `ai.complete` on the current platform. * On iOS this is the native on-device (Gemma) bridge answer — snake_case wire * fields come straight from the native handler. On web there is no local model; * the SDK answers statically with the online (Bedrock) runtime. */ export interface AIRuntimeCapabilities { /** * Whether an AI completion runtime is available right now. */ available: boolean; /** * Whether the runtime works offline (true for the iOS on-device model). */ offline?: boolean; /** * Serving runtime hint, e.g. 'bedrock-online' (web) — iOS reports its model * via `llm_model` instead. */ runtime?: string; /** * The on-device model identifier (iOS only). */ llm_model?: string; /** * Whether the on-device model is currently downloading (iOS only). */ model_downloading?: boolean; /** * Download progress 0-100 while `model_downloading` (iOS only). */ download_progress_percent?: number; /** * Whether an on-device model can be downloaded for this instance (iOS only). */ model_available_for_download?: boolean; /** * Why the runtime is unavailable, when `available` is false (iOS only). */ unavailability_reason?: string; } /** * Payload for an on-device AI completion (`ai.complete`, iOS only). The exact * iOS wire contract — keys are already snake_case, do not rename. */ export interface AICompletePayload { /** * The full prompt to complete. */ prompt: string; /** * Maximum number of tokens to generate. */ max_tokens?: number; /** * Whether to stream the completion (v1 SDK callers should omit/false). */ stream?: boolean; } /** * Result of an on-device AI completion (`ai.complete`, iOS only). */ export interface AICompleteResult { /** * The generated completion text. */ text: string; tokens_generated?: number; elapsed_seconds?: number; time_to_first_token_seconds?: number; } /** * Payload for `piaSearchAnswer` — one high-level question-answering call over * the instance's content, routed on-device (iOS Gemma) or online (next-core * Bedrock route) based on the `pia_search_config` flag mode. */ export interface PiaSearchAnswerPayload { /** * The rep's natural-language question. */ query: string; /** * Instance to search in. Defaults to the env's active instance. */ instance_id?: string; /** * Client-assembled content context (file names/tags/summaries). Used ONLY by * the on-device path — the online route assembles its own context * server-side. */ context_text?: string; /** * Optional narrowing of the online route's candidate pool to these file ids. */ file_ids?: string[]; /** * Token budget for the on-device completion. */ max_tokens?: number; } /** * A single AppsDB entry (next-core `core_appsdb_entries` row / iOS offline mirror record). */ export interface AppsDbEntry { /** * Unique identifier (ULID). */ id: string; /** * Object type the entry belongs to (e.g. `personalfolders`, `favorite`). */ type: string; user_id?: number | null; org_id?: string | null; instance_id?: string | null; /** * Opaque application data. Keys are stored verbatim (no casing transformation). */ data: Record; created_at?: string; updated_at?: string; } /** * Payload for `appsDbGetEntries` — list AppsDB entries of a type. */ export interface AppsDbGetEntriesPayload { /** * The object type to read. On iOS only types allowlisted via the * `offline_appsdb_types` instance/org setting are served from the offline mirror. */ type: string; user_id?: number; instance_id?: string; limit?: number; offset?: number; } /** * Entry-list result shared by `appsDbGetEntries` and `appsDbPsql`. */ export interface AppsDbEntriesResult { entries: AppsDbEntry[]; totalCount?: number; hasMore?: boolean; } /** * Payload for `appsDbUpsertEntry`. With `id` the entry is updated (the server * deep-merges `data`); without `id` a new entry is created. */ export interface AppsDbUpsertEntryPayload { id?: string; type?: string; user_id?: number; instance_id?: string; /** * Create an instance-wide entry with no user attribution (allowlist-gated * server-side, see next-core `appsdb/ownership.ts`). */ no_user_id?: boolean; data: Record; } /** * Payload for `appsDbDeleteEntry`. */ export interface AppsDbDeleteEntryPayload { id: string; } /** * Payload for `appsDbPsql` — a PSQL (SQL-like) query against AppsDB, e.g. * `SELECT * FROM favorite WHERE user_id = 1 AND data.file_id = 'abc'`. */ export interface AppsDbPsqlPayload { query: string; } /** * Unified `piaSearchAnswer` result across both serving paths. */ export interface PiaSearchAnswerResult { /** * The answer text. */ answer: string; /** * File ids (from the candidate context) the answer drew on. Online path only. */ cited_file_ids?: string[]; /** * Model self-reported confidence. Online path only. */ confidence?: 'high' | 'medium' | 'low'; /** * Which runtime produced the answer. */ source: 'on_device' | 'online'; }