Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin-flow-builder: remove start_up_node #2686

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@
"workspaces": [
"packages/*"
],
"dependencies": {}
"dependencies": {},
"version": "0.23.5-alpha.0"
Iru89 marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion packages/botonic-plugin-flow-builder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/botonic-plugin-flow-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botonic/plugin-flow-builder",
"version": "0.23.4",
"version": "0.23.5",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"description": "Use Flow Builder to show your contents",
Expand Down
10 changes: 3 additions & 7 deletions packages/botonic-plugin-flow-builder/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {
HtKeywordNode,
HtNodeComponent,
HtNodeLink,
HtNodeStartType,
HtNodeWithContent,
HtNodeWithContentType,
HtStartNode,
} from './content-fields/hubtype-fields'
import { FlowBuilderApiOptions } from './types'

Expand Down Expand Up @@ -54,11 +52,9 @@ export class FlowBuilderApi {
}

getStartNode(): HtNodeWithContent {
const startUpNode = this.flow.nodes.find(
node => node.type === HtNodeStartType.STARTUP
) as HtStartNode | undefined
if (!startUpNode) throw new Error('Start-up id must be defined')
return this.getNodeById(startUpNode.target.id)
const startNodeId = this.flow.start_node_id
if (!startNodeId) throw new Error('Start node id must be defined')
return this.getNodeById(startNodeId)
}

getFallbackNode(alternate: boolean): HtNodeWithContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export * from './keyword'
export * from './node-types'
export * from './nodes'
export * from './payload'
export * from './start'
export * from './text'
export * from './url'
export * from './video'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export enum HtNodeWithContentType {
WHATSAPP_BUTTON_LIST = 'whatsapp-button-list',
}

export enum HtNodeStartType {
STARTUP = 'start-up',
}

export enum HtNodeWithoutContentType {
URL = 'url',
PAYLOAD = 'payload',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { HtImageNode } from './image'
import { HtIntentNode } from './intent'
import { HtKeywordNode } from './keyword'
import { HtPayloadNode } from './payload'
import { HtStartNode } from './start'
import { HtTextNode } from './text'
import { HtUrlNode } from './url'
import { HtVideoNode } from './video'
Expand All @@ -26,7 +25,4 @@ export type HtNodeWithContent =

export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode

export type HtNodeComponent =
| HtNodeWithContent
| HtNodeWithoutContent
| HtStartNode
export type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent

This file was deleted.

11 changes: 8 additions & 3 deletions packages/botonic-plugin-flow-builder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ export default class BotonicPluginFlowBuilder implements Plugin {
}
}

getContentsByCode(
async getContentsByCode(
code: string,
locale: string,
prevContents?: FlowContent[]
): Promise<FlowContent[]> {
const node = this.cmsApi.getNodeByCode(code) as HtNodeWithContent
return this.getContentsByNode(node, locale, prevContents)
return await this.getContentsByNode(node, locale, prevContents)
}

async getContentsById(
Expand All @@ -81,7 +81,12 @@ export default class BotonicPluginFlowBuilder implements Plugin {
prevContents?: FlowContent[]
): Promise<FlowContent[]> {
const node = this.cmsApi.getNodeById(id) as HtNodeWithContent
return this.getContentsByNode(node, locale, prevContents)
return await this.getContentsByNode(node, locale, prevContents)
}

async getStartContents(locale: string): Promise<FlowContent[]> {
const startNode = this.cmsApi.getStartNode()
return await this.getContentsByNode(startNode, locale)
}

async getContentsByNode(
Expand Down
Loading