Skip to content

Commit

Permalink
refactor: converting trace types into v3 traces and adding markup type
Browse files Browse the repository at this point in the history
  • Loading branch information
zhihil committed Jul 19, 2023
1 parent 679fae8 commit 591a9f6
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 19 deletions.
3 changes: 3 additions & 0 deletions packages/base-types/src/markup/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type MarkupNode = string | { attributes: Record<string, unknown>; text: Markup };

export type Markup = Array<MarkupNode>;
5 changes: 2 additions & 3 deletions packages/base-types/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ export * as Visual from './visual';
export * as Zapier from './zapier';

// Voiceflow V3
export * as Image from './image';
export * as JSON from './json';
export * as Video from './video';
export * as Image from '../trace/v3/image';
export * as Video from '../trace/v3/video';

export interface NextOnlyNode extends BaseNode, NodeNextID {
type: '_next';
Expand Down
20 changes: 7 additions & 13 deletions packages/base-types/src/trace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ import { TraceFrame as CardV2Trace } from '@base-types/node/cardV2';
import { TraceFrame as CarouselTrace } from '@base-types/node/carousel';
import { TraceFrame as ExitTrace } from '@base-types/node/exit';
import { TraceFrame as FlowTrace } from '@base-types/node/flow';
// Voiceflow V3
import { TraceFrame as ImageTrace } from '@base-types/node/image';
import { TraceFrame as ChoiceTrace } from '@base-types/node/interaction';
import { TraceFrame as JSONTrace } from '@base-types/node/json';
import { TraceFrame as SpeakTrace } from '@base-types/node/speak';
import { TraceFrame as StreamTrace } from '@base-types/node/stream';
import { TraceFrame as TextTrace } from '@base-types/node/text';
import { BaseTraceFrame, TraceType } from '@base-types/node/utils';
import { TraceFrame as VideoTrace } from '@base-types/node/video';
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';

import * as V3 from './v3';

export { TraceFrame as CardV2 } from '@base-types/node/cardV2';
export { TraceFrame as Carousel } from '@base-types/node/carousel';
export { TraceFrame as End } from '@base-types/node/exit';
Expand All @@ -28,12 +26,7 @@ export { BaseTraceFrame, TraceType } from '@base-types/node/utils/trace';
export { TraceFrame as Visual } from '@base-types/node/visual';

// Voiceflow V3
export { TraceFrame as ImageTrace } from '@base-types/node/image';
export { TraceFrame as Image } from '@base-types/node/image';
export { TraceFrame as JSONTrace } from '@base-types/node/json';
export { TraceFrame as JSON } from '@base-types/node/json';
export { TraceFrame as VideoTrace } from '@base-types/node/video';
export { TraceFrame as Video } from '@base-types/node/video';
export * as V3 from './v3';

/** @deprecated */
export { TraceFrame as CarouselTrace } from '@base-types/node/carousel';
Expand Down Expand Up @@ -134,6 +127,7 @@ export type AnyTrace =
| EntityFillingTrace
| ChannelActionTrace
// V3 traces
| ImageTrace
| JSONTrace
| VideoTrace;
| V3.ImageTrace
| V3.JSONTrace
| V3.VideoTrace
| V3.TextTrace;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseTraceFrame, TraceType } from './utils';
import { BaseTraceFrame, TraceType } from '../../node/utils';

interface StepData {
url: string;
Expand Down
4 changes: 4 additions & 0 deletions packages/base-types/src/trace/v3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { TraceFrame as ImageTrace } from './image';
export { TraceFrame as JSONTrace } from './json';
export { TraceFrame as TextTrace } from './text';
export { TraceFrame as VideoTrace } from './video';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseTraceFrame, TraceType } from './utils';
import { BaseTraceFrame, TraceType } from '../../node/utils';

interface StepData {
json: unknown;
Expand Down
11 changes: 11 additions & 0 deletions packages/base-types/src/trace/v3/text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Markup } from '@base-types/markup';

import { BaseTraceFrame, TraceType } from '../../node/utils';

interface StepData {
content: Markup;
}

export interface TraceFrame extends BaseTraceFrame<StepData> {
type: TraceType.TEXT;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseTraceFrame, TraceType } from './utils';
import { BaseTraceFrame, TraceType } from '../../node/utils';

interface StepData {
url: string;
Expand Down

0 comments on commit 591a9f6

Please sign in to comment.