Skip to content

Commit

Permalink
feat: channel action trace (PL-41) (#360)
Browse files Browse the repository at this point in the history
<!-- You can erase any parts of this template not applicable to your Pull Request. -->

**Fixes or implements PL-41**

### Brief description. What is this change?

<!-- Build up some context for your teammates on the changes made here and potential tradeoffs made and/or highlight any topics for discussion -->



Co-authored-by: Tyler Stewart <tyler.stewart@voiceflow.com>
  • Loading branch information
trs and trs committed Aug 29, 2022
1 parent f2e38a8 commit 4175b88
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/base-types/src/node/channelAction.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Nullable } from '@voiceflow/common';
import { AnyRecord, Nullable } from '@voiceflow/common';

import { NodeType } from './constants';
import { BaseEvent, BaseNode, BasePort, BasePortList, BaseStep, BaseStepPorts, NodeID } from './utils';

interface StepData<Payload = unknown> {
interface StepData<Payload = AnyRecord> {
stop?: boolean;
payload: Payload;
defaultPath?: number;
Expand All @@ -15,7 +15,7 @@ export interface StepPort<Event = BaseEvent> extends BasePort {

interface StepPorts<Event> extends BaseStepPorts<Record<string, StepPort<Event>>, StepPort<Event>[]> {}

export interface Step<Payload = unknown, Event = BaseEvent> extends BaseStep<StepData<Payload>, StepPorts<Event>, BasePortList<StepPort<Event>>> {
export interface Step<Payload = AnyRecord, Event = BaseEvent> extends BaseStep<StepData<Payload>, StepPorts<Event>, BasePortList<StepPort<Event>>> {
type: NodeType.CHANNEL_ACTION;
}

Expand All @@ -29,7 +29,7 @@ export interface Node<Event = BaseEvent> extends BaseNode {
type: NodeType.CHANNEL_ACTION;
data: {
name: string;
payload: unknown;
payload: AnyRecord;
};
stop: boolean;
defaultPath?: number; // index starting from 0
Expand Down
1 change: 1 addition & 0 deletions packages/base-types/src/node/utils/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum TraceType {
CAROUSEL = 'carousel',
NO_REPLY = 'no-reply',
ENTITY_FILLING = 'entity-filling',
CHANNEL_ACTION = 'channel-action',
}

export interface BaseTraceFramePath<Event extends BaseEvent = BaseEvent> {
Expand Down
14 changes: 12 additions & 2 deletions packages/base-types/src/trace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { BaseTraceFrame, TraceType } from '@base-types/node/utils';
import { TraceFrame as VisualTrace } from '@base-types/node/visual';
import { IntentRequest } from '@base-types/request';
import { Log as RuntimeLog } from '@base-types/runtimeLogs';
import { AnyRecord } from '@voiceflow/common';

export { TraceFrame as CardV2Trace } from '@base-types/node/cardV2';
export { TraceFrame as CarouselTrace } from '@base-types/node/carousel';
export { TraceFrame as ExitTrace } from '@base-types/node/exit';
export { TraceFrame as FlowTrace } from '@base-types/node/flow';
Expand Down Expand Up @@ -77,6 +77,15 @@ export interface LogTrace extends BaseTraceFrame<LogTracePayload> {
type: TraceType.LOG;
}

export interface ChannelActionTracePayload {
name: string;
data: AnyRecord;
}

export interface ChannelActionTrace extends BaseTraceFrame<ChannelActionTracePayload> {
type: TraceType.CHANNEL_ACTION;
}

export type AnyTrace =
| LogTrace
| ExitTrace
Expand All @@ -92,4 +101,5 @@ export type AnyTrace =
| NoReplyTrace
| CarouselTrace
| CardV2Trace
| EntityFillingTrace;
| EntityFillingTrace
| ChannelActionTrace;

0 comments on commit 4175b88

Please sign in to comment.