feat: simplify SOP to immediate-effect configuration
This commit is contained in:
121
sdk/dist/index.d.ts
vendored
Normal file
121
sdk/dist/index.d.ts
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
export type ScenarioInput = Record<string, unknown>;
|
||||
export type OutputField = {
|
||||
key: string;
|
||||
name: string;
|
||||
type: string;
|
||||
source: string;
|
||||
value: unknown;
|
||||
};
|
||||
export type ResultField = {
|
||||
key: string;
|
||||
name: string;
|
||||
type: string;
|
||||
required?: boolean;
|
||||
options?: unknown[];
|
||||
fields?: ResultField[];
|
||||
items?: Omit<ResultField, 'key' | 'name'>;
|
||||
};
|
||||
export type ResultSchema = {
|
||||
fields: ResultField[];
|
||||
};
|
||||
export type NodeField = {
|
||||
key: string;
|
||||
name: string;
|
||||
type: string;
|
||||
required: boolean;
|
||||
options: unknown[];
|
||||
validation: Record<string, unknown>;
|
||||
};
|
||||
export type PresentationField = {
|
||||
key: string;
|
||||
label: string;
|
||||
kind: 'text' | 'image';
|
||||
value: unknown;
|
||||
};
|
||||
export type NodePresentation = {
|
||||
summary: PresentationField[];
|
||||
items: Array<{
|
||||
fields: PresentationField[];
|
||||
}>;
|
||||
opening?: {
|
||||
title: string;
|
||||
content: string;
|
||||
};
|
||||
};
|
||||
export type KnowledgeCollectionOption = {
|
||||
value: string;
|
||||
label: string;
|
||||
parents?: string[];
|
||||
suggested?: boolean;
|
||||
};
|
||||
export type KnowledgeCollectionStep = {
|
||||
field_key: string;
|
||||
name: string;
|
||||
required: boolean;
|
||||
multiple: boolean;
|
||||
from_field?: string;
|
||||
options: KnowledgeCollectionOption[];
|
||||
};
|
||||
export type KnowledgeCollection = {
|
||||
context_fields: NodeField[];
|
||||
context_title?: string;
|
||||
context_hint?: string;
|
||||
selection_title?: string;
|
||||
selection_hint?: string;
|
||||
steps: KnowledgeCollectionStep[];
|
||||
};
|
||||
export type NodeView = {
|
||||
node_key: string;
|
||||
type: string;
|
||||
title: string;
|
||||
content: string;
|
||||
fields?: NodeField[];
|
||||
presentation?: NodePresentation;
|
||||
outputs?: unknown[];
|
||||
collection?: KnowledgeCollection;
|
||||
};
|
||||
export type ScenarioState = {
|
||||
run_id: number;
|
||||
external_ref: string;
|
||||
status: string;
|
||||
final_result?: Record<string, unknown> | null;
|
||||
result_schema: ResultSchema;
|
||||
session_token?: string;
|
||||
node: NodeView;
|
||||
outputs: OutputField[];
|
||||
};
|
||||
export type SDKEvent = 'ready' | 'node_change' | 'form_submit' | 'finish' | 'error';
|
||||
export type CreateOptions = {
|
||||
baseURL?: string;
|
||||
publicKey: string;
|
||||
scenarioKey: string;
|
||||
sopId?: number;
|
||||
input?: ScenarioInput;
|
||||
initialValues?: ScenarioInput;
|
||||
externalRef?: string;
|
||||
};
|
||||
export type FinishOptions = {
|
||||
result?: string;
|
||||
finalResult?: Record<string, unknown> | null;
|
||||
};
|
||||
export declare class SalesScenario {
|
||||
private readonly options;
|
||||
private token;
|
||||
private state?;
|
||||
private handlers;
|
||||
constructor(options: CreateOptions);
|
||||
start(): Promise<ScenarioState>;
|
||||
getState(): ScenarioState;
|
||||
getCurrentNode(): Promise<ScenarioState>;
|
||||
submit(values: ScenarioInput): Promise<ScenarioState>;
|
||||
next(): Promise<ScenarioState>;
|
||||
finish(options?: FinishOptions): Promise<ScenarioState>;
|
||||
reset(): Promise<ScenarioState>;
|
||||
destroy(): void;
|
||||
on(event: SDKEvent, handler: (payload: unknown) => void): () => boolean;
|
||||
private update;
|
||||
private setState;
|
||||
private emit;
|
||||
private request;
|
||||
}
|
||||
export declare function create(options: CreateOptions): SalesScenario;
|
||||
Reference in New Issue
Block a user