UNPKG

@arcgis/coding-components

Version:

Contains components for editing code in different languages. The currently supported languages are html, css, json, TypeScript, JavaScript, and Arcade.

79 lines (78 loc) 2.22 kB
/// <reference types="@arcgis/core/interfaces.d.ts" /> /** * Helpers to automate chat with a skill */ type RequestContext = { kind: "ArcadeCodeRequest"; context: { profile_name: string; metadata: Partial<__esri.Field>; }; }; /** successful response */ type ArcadeCodeContext = { kind: "ArcadeCodeResponse"; arcadeCode?: { code: string; }; [key: string]: unknown; }; /** error response but still 200 status */ type ArcgisErrorAsContext = { kind: "ArcgisErrorAsContext"; error: { code: number; message?: string; subCode?: string | null; details?: unknown[]; }; [key: string]: unknown; }; export type ResponseContext = ArcadeCodeContext | ArcgisErrorAsContext; type ChatResponse = { hasMore: boolean; context?: ResponseContext; message?: string; conversationId: string; inquiryId: string; sequenceNumber: string; [key: string]: unknown; }; /** * The skill service will often return an error with a message that contains json. The parsed json has the below shape */ interface ArcadeAssistantErrorResponse { code?: number | string; message: string; subCode?: string | null; details?: unknown[]; source?: string; } export declare class ArcadeAssistantError extends Error implements ArcadeAssistantErrorResponse { code?: number | string; subCode?: string | null; details?: unknown[]; source?: string; constructor({ message, code, subCode, details, source, }: { message: string; code?: number | string; subCode?: string | null; details?: unknown[]; source?: string; }); } /** Helper to automate chat with a skill */ export declare function chatWithSkill(params: { baseUrl: string; skillId: string | null; message: string; authToken: string; previousConversationId?: string | null; context?: RequestContext; }): Promise<ChatResponse[]>; /** * Some error messages from the Arcade Assistant API are not user-friendly. * This function adapts those errors to a more user-friendly message. */ export declare function errorDiagnosticAdapter(error: ArcadeAssistantError): string; export {};