♻️ (viewer) Remove barrel exports and flatten folder arch
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { deepParseVariable } from '@/features/variables/utils'
|
||||
import {
|
||||
SessionState,
|
||||
VariableWithValue,
|
||||
@@ -6,6 +5,7 @@ import {
|
||||
ItemType,
|
||||
} from '@typebot.io/schemas'
|
||||
import { isDefined } from '@typebot.io/lib'
|
||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||
|
||||
export const injectVariableValuesInButtonsInputBlock =
|
||||
(variables: SessionState['typebot']['variables']) =>
|
||||
@@ -27,5 +27,5 @@ export const injectVariableValuesInButtonsInputBlock =
|
||||
})),
|
||||
}
|
||||
}
|
||||
return deepParseVariable(variables)(block)
|
||||
return deepParseVariables(variables)(block)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './parseReadableDate'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './validateEmail'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './computePaymentInputRuntimeOptions'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { parseVariables } from '@/features/variables'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import {
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils'
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './formatPhoneNumber'
|
||||
export * from './validatePhoneNumber'
|
||||
@@ -1 +0,0 @@
|
||||
export { validateUrl } from './utils/validateUrl'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils/executeChatwootBlock'
|
||||
@@ -1,9 +1,7 @@
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import {
|
||||
parseVariables,
|
||||
parseCorrectValueType,
|
||||
extractVariablesFromText,
|
||||
} from '@/features/variables'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { extractVariablesFromText } from '@/features/variables/extractVariablesFromText'
|
||||
import { parseGuessedValueType } from '@/features/variables/parseGuessedValueType'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import {
|
||||
ChatwootBlock,
|
||||
ChatwootOptions,
|
||||
@@ -85,7 +83,7 @@ export const executeChatwootBlock = (
|
||||
args: extractVariablesFromText(variables)(chatwootCode).map(
|
||||
(variable) => ({
|
||||
id: variable.id,
|
||||
value: parseCorrectValueType(variable.value),
|
||||
value: parseGuessedValueType(variable.value),
|
||||
})
|
||||
),
|
||||
},
|
||||
@@ -1 +0,0 @@
|
||||
export { executeGoogleAnalyticsBlock } from './utils/executeGoogleAnalyticsBlock'
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import { deepParseVariable } from '@/features/variables'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||
import { GoogleAnalyticsBlock, SessionState } from '@typebot.io/schemas'
|
||||
|
||||
export const executeGoogleAnalyticsBlock = (
|
||||
@@ -10,7 +10,7 @@ export const executeGoogleAnalyticsBlock = (
|
||||
outgoingEdgeId: block.outgoingEdgeId,
|
||||
clientSideActions: [
|
||||
{
|
||||
googleAnalytics: deepParseVariable(variables)(block.options),
|
||||
googleAnalytics: deepParseVariables(variables)(block.options),
|
||||
lastBubbleBlockId,
|
||||
},
|
||||
],
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './executeGoogleSheetBlock'
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import {
|
||||
GoogleSheetsBlock,
|
||||
GoogleSheetsAction,
|
||||
SessionState,
|
||||
} from '@typebot.io/schemas'
|
||||
import { getRow } from './getRow'
|
||||
import { insertRow } from './insertRow'
|
||||
import { updateRow } from './updateRow'
|
||||
import { getRow } from './getRow'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
|
||||
export const executeGoogleSheetBlock = async (
|
||||
state: SessionState,
|
||||
@@ -6,12 +6,13 @@ import {
|
||||
LogicalOperator,
|
||||
ReplyLog,
|
||||
} from '@typebot.io/schemas'
|
||||
import { saveErrorLog } from '@/features/logs/api'
|
||||
import { getAuthenticatedGoogleDoc } from './helpers'
|
||||
import { deepParseVariable, updateVariables } from '@/features/variables'
|
||||
import { isNotEmpty, byId, isDefined } from '@typebot.io/lib'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import type { GoogleSpreadsheetRow } from 'google-spreadsheet'
|
||||
import { getAuthenticatedGoogleDoc } from './helpers/getAuthenticatedGoogleDoc'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { updateVariables } from '@/features/variables/updateVariables'
|
||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||
|
||||
export const getRow = async (
|
||||
state: SessionState,
|
||||
@@ -20,7 +21,7 @@ export const getRow = async (
|
||||
options,
|
||||
}: { outgoingEdgeId?: string; options: GoogleSheetsGetOptions }
|
||||
): Promise<ExecuteIntegrationResponse> => {
|
||||
const { sheetId, cellsToExtract, referenceCell, filter } = deepParseVariable(
|
||||
const { sheetId, cellsToExtract, referenceCell, filter } = deepParseVariables(
|
||||
state.typebot.variables
|
||||
)(options)
|
||||
if (!sheetId) return { outgoingEdgeId }
|
||||
@@ -1,20 +1,6 @@
|
||||
import { parseVariables } from '@/features/variables'
|
||||
import { getAuthenticatedGoogleClient } from '@/lib/google-sheets'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { GoogleSpreadsheet } from 'google-spreadsheet'
|
||||
import { Variable, Cell } from '@typebot.io/schemas'
|
||||
|
||||
export const parseCellValues =
|
||||
(variables: Variable[]) =>
|
||||
(cells: Cell[]): { [key: string]: string } =>
|
||||
cells.reduce((row, cell) => {
|
||||
return !cell.column || !cell.value
|
||||
? row
|
||||
: {
|
||||
...row,
|
||||
[cell.column]: parseVariables(variables)(cell.value),
|
||||
}
|
||||
}, {})
|
||||
|
||||
export const getAuthenticatedGoogleDoc = async ({
|
||||
credentialsId,
|
||||
@@ -0,0 +1,14 @@
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import { Variable, Cell } from '@typebot.io/schemas'
|
||||
|
||||
export const parseCellValues =
|
||||
(variables: Variable[]) =>
|
||||
(cells: Cell[]): { [key: string]: string } =>
|
||||
cells.reduce((row, cell) => {
|
||||
return !cell.column || !cell.value
|
||||
? row
|
||||
: {
|
||||
...row,
|
||||
[cell.column]: parseVariables(variables)(cell.value),
|
||||
}
|
||||
}, {})
|
||||
@@ -3,9 +3,11 @@ import {
|
||||
GoogleSheetsInsertRowOptions,
|
||||
ReplyLog,
|
||||
} from '@typebot.io/schemas'
|
||||
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'
|
||||
import { getAuthenticatedGoogleDoc, parseCellValues } from './helpers'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import { parseCellValues } from './helpers/parseCellValues'
|
||||
import { getAuthenticatedGoogleDoc } from './helpers/getAuthenticatedGoogleDoc'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
|
||||
export const insertRow = async (
|
||||
{ result, typebot: { variables } }: SessionState,
|
||||
@@ -3,11 +3,13 @@ import {
|
||||
GoogleSheetsUpdateRowOptions,
|
||||
ReplyLog,
|
||||
} from '@typebot.io/schemas'
|
||||
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'
|
||||
import { getAuthenticatedGoogleDoc, parseCellValues } from './helpers'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { deepParseVariable } from '@/features/variables'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import { parseCellValues } from './helpers/parseCellValues'
|
||||
import { getAuthenticatedGoogleDoc } from './helpers/getAuthenticatedGoogleDoc'
|
||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
|
||||
export const updateRow = async (
|
||||
{ result, typebot: { variables } }: SessionState,
|
||||
@@ -16,7 +18,7 @@ export const updateRow = async (
|
||||
options,
|
||||
}: { outgoingEdgeId?: string; options: GoogleSheetsUpdateRowOptions }
|
||||
): Promise<ExecuteIntegrationResponse> => {
|
||||
const { sheetId, referenceCell } = deepParseVariable(variables)(options)
|
||||
const { sheetId, referenceCell } = deepParseVariables(variables)(options)
|
||||
if (!options.cellsToUpsert || !sheetId || !referenceCell)
|
||||
return { outgoingEdgeId }
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { saveErrorLog } from '@/features/logs/api'
|
||||
import { transformStringVariablesToList } from '@/features/variables/transformVariablesToList'
|
||||
import { parseVariables, updateVariables } from '@/features/variables/utils'
|
||||
import prisma from '@/lib/prisma'
|
||||
import {
|
||||
SessionState,
|
||||
@@ -16,6 +14,9 @@ import {
|
||||
import { OpenAIApi, Configuration, ChatCompletionRequestMessage } from 'openai'
|
||||
import { isDefined, byId, isNotEmpty } from '@typebot.io/lib'
|
||||
import { decrypt } from '@typebot.io/lib/api/encryption'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { updateVariables } from '@/features/variables/updateVariables'
|
||||
import { parseVariables } from 'bot-engine'
|
||||
|
||||
export const createChatCompletionOpenAI = async (
|
||||
state: SessionState,
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { executeSendEmailBlock } from './utils/executeSendEmailBlock'
|
||||
@@ -1,6 +1,4 @@
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'
|
||||
import { parseVariables } from '@/features/variables'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { render } from '@faire/mjml-react/utils/render'
|
||||
import { DefaultBotNotificationEmail } from '@typebot.io/emails'
|
||||
@@ -17,7 +15,10 @@ import Mail from 'nodemailer/lib/mailer'
|
||||
import { byId, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
|
||||
import { parseAnswers } from '@typebot.io/lib/results'
|
||||
import { decrypt } from '@typebot.io/lib/api'
|
||||
import { defaultFrom, defaultTransportOptions } from '../constants'
|
||||
import { defaultFrom, defaultTransportOptions } from './constants'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
|
||||
export const executeSendEmailBlock = async (
|
||||
{ result, typebot }: SessionState,
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils'
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './executeWebhookBlock'
|
||||
export * from './parseSampleResult'
|
||||
@@ -1,6 +1,3 @@
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'
|
||||
import { parseVariables, updateVariables } from '@/features/variables'
|
||||
import prisma from '@/lib/prisma'
|
||||
import {
|
||||
WebhookBlock,
|
||||
@@ -26,6 +23,11 @@ import { byId, omit } from '@typebot.io/lib'
|
||||
import { parseAnswers } from '@typebot.io/lib/results'
|
||||
import got, { Method, Headers, HTTPError } from 'got'
|
||||
import { parseSampleResult } from './parseSampleResult'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
import { updateVariables } from '@/features/variables/updateVariables'
|
||||
import { parseVariables } from 'bot-engine'
|
||||
|
||||
export const executeWebhookBlock = async (
|
||||
state: SessionState,
|
||||
@@ -1 +0,0 @@
|
||||
export { executeCondition } from './utils/executeCondition'
|
||||
@@ -1,5 +1,3 @@
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import { findUniqueVariableValue, parseVariables } from '@/features/variables'
|
||||
import {
|
||||
Comparison,
|
||||
ComparisonOperators,
|
||||
@@ -9,6 +7,9 @@ import {
|
||||
Variable,
|
||||
} from '@typebot.io/schemas'
|
||||
import { isNotDefined, isDefined } from '@typebot.io/lib'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
import { findUniqueVariableValue } from '@/features/variables/findUniqueVariableValue'
|
||||
import { parseVariables } from 'bot-engine'
|
||||
|
||||
export const executeCondition = (
|
||||
{ typebot: { variables } }: SessionState,
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import {
|
||||
addEdgeToTypebot,
|
||||
createPortalEdge,
|
||||
} from '@/features/chat/api/utils/addEdgeToTypebot'
|
||||
} from '@/features/chat/helpers/addEdgeToTypebot'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { SessionState } from '@typebot.io/schemas'
|
||||
import { JumpBlock } from '@typebot.io/schemas/features/blocks/logic/jump'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { executeRedirect } from './utils/executeRedirect'
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import { parseVariables } from '@/features/variables'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import { RedirectBlock, SessionState } from '@typebot.io/schemas'
|
||||
import { sanitizeUrl } from '@typebot.io/lib'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
|
||||
export const executeRedirect = (
|
||||
{ typebot: { variables } }: SessionState,
|
||||
@@ -1,9 +1,7 @@
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import {
|
||||
parseVariables,
|
||||
parseCorrectValueType,
|
||||
extractVariablesFromText,
|
||||
} from '@/features/variables'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
import { extractVariablesFromText } from '@/features/variables/extractVariablesFromText'
|
||||
import { parseGuessedValueType } from '@/features/variables/parseGuessedValueType'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import { ScriptBlock, SessionState } from '@typebot.io/schemas'
|
||||
|
||||
export const executeScript = (
|
||||
@@ -19,7 +17,7 @@ export const executeScript = (
|
||||
const args = extractVariablesFromText(variables)(block.options.content).map(
|
||||
(variable) => ({
|
||||
id: variable.id,
|
||||
value: parseCorrectValueType(variable.value),
|
||||
value: parseGuessedValueType(variable.value),
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { executeSetVariable } from './utils/executeSetVariable'
|
||||
@@ -1,11 +1,9 @@
|
||||
import { SessionState, SetVariableBlock, Variable } from '@typebot.io/schemas'
|
||||
import { byId } from '@typebot.io/lib'
|
||||
import {
|
||||
parseVariables,
|
||||
parseCorrectValueType,
|
||||
updateVariables,
|
||||
} from '@/features/variables'
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
import { updateVariables } from '@/features/variables/updateVariables'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import { parseGuessedValueType } from '@/features/variables/parseGuessedValueType'
|
||||
|
||||
export const executeSetVariable = async (
|
||||
state: SessionState,
|
||||
@@ -45,7 +43,7 @@ const evaluateSetVariableExpression =
|
||||
)
|
||||
try {
|
||||
const func = Function(...variables.map((v) => v.id), evaluating)
|
||||
return func(...variables.map((v) => parseCorrectValueType(v.value)))
|
||||
return func(...variables.map((v) => parseGuessedValueType(v.value)))
|
||||
} catch (err) {
|
||||
return parseVariables(variables)(str)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from './utils'
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from './executeTypebotLink'
|
||||
export * from './getLinkedTypebots'
|
||||
export * from './getLinkedTypebotsChildren'
|
||||
@@ -1,9 +1,7 @@
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import {
|
||||
addEdgeToTypebot,
|
||||
createPortalEdge,
|
||||
} from '@/features/chat/api/utils/addEdgeToTypebot'
|
||||
import { saveErrorLog } from '@/features/logs/api'
|
||||
} from '@/features/chat/helpers/addEdgeToTypebot'
|
||||
import prisma from '@/lib/prisma'
|
||||
import {
|
||||
TypebotLinkBlock,
|
||||
@@ -12,6 +10,8 @@ import {
|
||||
Variable,
|
||||
} from '@typebot.io/schemas'
|
||||
import { byId } from '@typebot.io/lib'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
|
||||
export const executeTypebotLink = async (
|
||||
state: SessionState,
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import { canReadTypebots } from '@/utils/api/dbRules'
|
||||
import { canReadTypebots } from '@/helpers/api/dbRules'
|
||||
import { User } from '@typebot.io/prisma'
|
||||
import {
|
||||
LogicBlockType,
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import { parseVariables } from '@/features/variables'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import { SessionState, WaitBlock } from '@typebot.io/schemas'
|
||||
|
||||
export const executeWait = async (
|
||||
Reference in New Issue
Block a user