@voiceflow/base-types
Version:
Voiceflow base project types
47 lines • 2.54 kB
TypeScript
import type { Nullable } from '@voiceflow/common';
import type { BaseCommand } from './base';
import type { BaseEvent } from './event';
export declare enum CommandType {
JUMP = "jump",
PUSH = "push"
}
export interface TypedBaseCommand extends BaseCommand {
type: CommandType;
}
export interface WithEventMatching<Event extends BaseEvent = BaseEvent> {
event: Event;
}
export interface WithSiftOnMatching {
on: Record<string, unknown>;
}
export interface WithJump extends TypedBaseCommand {
type: CommandType.JUMP;
nextID: Nullable<string>;
diagramID?: Nullable<string>;
platform?: string;
}
export interface WithPush extends TypedBaseCommand {
type: CommandType.PUSH;
diagramID: Nullable<string>;
platform?: string;
}
export interface JumpEventMatchedCommand<Event extends BaseEvent = BaseEvent> extends WithJump, WithEventMatching<Event> {
}
export interface PushEventMatchedCommand<Event extends BaseEvent = BaseEvent> extends WithPush, WithEventMatching<Event> {
}
export interface JumpOnMatchedCommand extends WithJump, WithSiftOnMatching {
}
export interface PushOnMatchedCommand extends WithPush, WithSiftOnMatching {
}
export type EventMatchedCommand<Event extends BaseEvent = BaseEvent> = JumpEventMatchedCommand<Event> | PushEventMatchedCommand<Event>;
export type OnMatchedCommand = JumpOnMatchedCommand | PushOnMatchedCommand;
export type AnyCommand<Event extends BaseEvent = BaseEvent> = EventMatchedCommand<Event> | OnMatchedCommand;
export declare const isWithJump: (command: BaseCommand) => command is WithJump;
export declare const isWithPush: (command: BaseCommand) => command is WithPush;
export declare const isWithEventMatching: <TEvent extends BaseEvent = BaseEvent>(command: BaseCommand) => command is EventMatchedCommand<TEvent>;
export declare const isWithOnMatching: (command: BaseCommand) => command is OnMatchedCommand;
export declare const isJumpEventMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
export declare const isPushEventMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
export declare const isJumpOnMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
export declare const isPushOnMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
//# sourceMappingURL=command.d.ts.map