-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This PR does basically this: - Adapts CardV2's data structure to allow for cleaner code (voiceflow/creator-app#5878) by moving all the card's data to the type's root and removing the need for redundancy (card.cards, card.card or nasty types like CardV2Card) - Makes the CardV2's description an union of Slate or string (for Audio vs Chat sake) - Create all the Trace types required for the card Co-authored-by: Yauheni <overhawlin@gmail.com> Co-authored-by: Filipe Merker <filipe.merker@voiceflow.com>
- Loading branch information
1 parent
842b6b0
commit f84042f
Showing
15 changed files
with
124 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,60 @@ | ||
import { GeneralRequestButton } from '@base-types/request'; | ||
import { SlateTextValue } from '@base-types/text'; | ||
import { Nullable } from '@voiceflow/common'; | ||
|
||
import { NodeType } from './constants'; | ||
import { BaseNoMatchStepData, BaseNoReplyStepData, BaseStep, BaseStepPorts, BuiltInNextPort, BuiltInNoMatchNoReplyPorts, DataID } from './utils'; | ||
import { | ||
BaseNode, | ||
BaseNoMatchNodeData, | ||
BaseNoMatchStepData, | ||
BaseNoReplyNodeData, | ||
BaseNoReplyStepData, | ||
BaseStep, | ||
BaseStepPorts, | ||
BaseTraceFrame, | ||
BuiltInNextPort, | ||
BuiltInNoMatchNoReplyPorts, | ||
DataID, | ||
NodeNextID, | ||
TraceType, | ||
} from './utils'; | ||
|
||
export interface CardV2Button extends DataID { | ||
name: string; | ||
intent?: Nullable<string>; | ||
} | ||
|
||
export interface CardV2Card<B = CardV2Button> extends DataID { | ||
imageUrl: string | null; | ||
export interface CardV2Data<Button> { | ||
title: string; | ||
description: SlateTextValue; | ||
buttons: B[]; | ||
buttons: Button[]; | ||
imageUrl: string | null; | ||
} | ||
|
||
export interface StepBuiltInPorts extends BuiltInNextPort, BuiltInNoMatchNoReplyPorts {} | ||
|
||
export interface StepPorts extends BaseStepPorts<StepBuiltInPorts, []> {} | ||
|
||
export interface StepData extends BaseNoMatchStepData, BaseNoReplyStepData { | ||
card: CardV2Card; | ||
} | ||
export interface StepData<Button = CardV2Button> extends BaseNoMatchStepData, BaseNoReplyStepData, CardV2Data<Button> {} | ||
|
||
export interface Step<Data = StepData> extends BaseStep<Data, StepPorts> { | ||
type: NodeType.CARD_V2; | ||
} | ||
|
||
type CardDataWithGeneralButton = CardV2Data<GeneralRequestButton>; | ||
export interface Node extends BaseNode, NodeNextID, BaseNoReplyNodeData, BaseNoMatchNodeData, CardDataWithGeneralButton { | ||
type: NodeType.CARD_V2; | ||
isBlocking: boolean; | ||
} | ||
|
||
export interface TraceCardV2Description { | ||
slate: SlateTextValue; | ||
text: string; | ||
} | ||
export interface TraceCardV2 extends CardDataWithGeneralButton { | ||
description: TraceCardV2Description; | ||
} | ||
|
||
export interface TraceFramePayload extends TraceCardV2 {} | ||
export interface TraceFrame extends BaseTraceFrame<TraceFramePayload> { | ||
type: TraceType.CARD_V2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import { BaseNode, Nullable } from '@voiceflow/base-types'; | ||
import { BaseNode, BaseText, Nullable } from '@voiceflow/base-types'; | ||
|
||
import { StepNoMatch, StepNoReply } from './utils'; | ||
import { NodeNoMatch, NodeNoReply, StepNoMatch, StepNoReply } from './utils'; | ||
|
||
export interface StepData extends BaseNode.CardV2.StepData { | ||
description: BaseText.SlateTextValue; | ||
noReply?: Nullable<StepNoReply>; | ||
noMatch?: Nullable<StepNoMatch>; | ||
} | ||
|
||
export interface Step<Data = StepData> extends BaseNode.CardV2.Step<Data> {} | ||
|
||
export interface Node extends BaseNode.CardV2.Node { | ||
description: BaseText.SlateTextValue; | ||
noReply?: Nullable<NodeNoReply>; | ||
noMatch?: Nullable<NodeNoMatch>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { BaseNode, Nullable } from '@voiceflow/base-types'; | ||
|
||
import { NodeNoMatch, NodeNoReply, StepNoMatch, StepNoReply } from './utils'; | ||
|
||
export interface StepData<Voice> extends BaseNode.CardV2.StepData { | ||
description: string; | ||
noReply?: Nullable<StepNoReply<Voice>>; | ||
noMatch?: Nullable<StepNoMatch<Voice>>; | ||
} | ||
|
||
export interface Step<Data = StepData<unknown>> extends BaseNode.CardV2.Step<Data> {} | ||
|
||
export interface Node extends BaseNode.CardV2.Node { | ||
description: string; | ||
noReply?: Nullable<NodeNoReply>; | ||
noMatch?: Nullable<NodeNoMatch>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ChatNode } from '@voiceflow/chat-types'; | ||
|
||
export interface ChatStepData extends ChatNode.CardV2.StepData {} | ||
|
||
export interface ChatStep extends ChatNode.CardV2.Step<ChatStepData> {} | ||
|
||
export interface ChatNode extends ChatNode.CardV2.Node {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BaseNode } from '@voiceflow/base-types'; | ||
|
||
import { ChatNode, ChatStep, ChatStepData } from './chat'; | ||
import { VoiceNode, VoiceStep, VoiceStepData } from './voice'; | ||
|
||
export * from './chat'; | ||
export * from './voice'; | ||
|
||
export type Step = ChatStep | VoiceStep; | ||
|
||
export type StepPorts = BaseNode.CardV2.StepPorts; | ||
|
||
export type StepData = ChatStepData | VoiceStepData; | ||
|
||
export type Node = ChatNode | VoiceNode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { VoiceNode } from '@voiceflow/voice-types'; | ||
import { Voice } from '@voiceflow-types/constants'; | ||
|
||
export interface VoiceStepData extends VoiceNode.CardV2.StepData<Voice> {} | ||
|
||
export interface VoiceStep extends VoiceNode.CardV2.Step<VoiceStepData> {} | ||
|
||
export interface VoiceNode extends VoiceNode.CardV2.Node {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { BaseNode } from '@voiceflow/base-types'; | ||
|
||
import { ChatStep, ChatStepData } from './chat'; | ||
import { ChatNode, ChatStep, ChatStepData } from './chat'; | ||
import { VoiceNode, VoiceStep, VoiceStepData } from './voice'; | ||
|
||
export * from './chat'; | ||
export * from './voice'; | ||
|
||
export type Step = ChatStep; | ||
export type Step = ChatStep | VoiceStep; | ||
|
||
export type StepPorts = BaseNode.CardV2.StepPorts; | ||
|
||
export type StepData = ChatStepData; | ||
export type StepData = ChatStepData | VoiceStepData; | ||
|
||
export type Node = ChatNode | VoiceNode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { VoiceNode } from '@voiceflow/voice-types'; | ||
import { Voice } from '@voiceflow-types/constants'; | ||
|
||
export interface VoiceStepData extends VoiceNode.CardV2.StepData<Voice> {} | ||
|
||
export interface VoiceStep extends VoiceNode.CardV2.Step<VoiceStepData> {} | ||
|
||
export interface VoiceNode extends VoiceNode.CardV2.Node {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters