-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56f4f67
commit 36648f8
Showing
23 changed files
with
2,481 additions
and
5,279 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
apps/dashboard-app/actions/connections/openai-connections.tsx
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,23 @@ | ||
'use server' | ||
|
||
import { createOpenAI,getOpenAIByAPIKey,getOpenAIByUserId } from '@repo/prisma-db/repo/openAi' | ||
|
||
interface Props { | ||
apiKey: string, | ||
userId: string | ||
} | ||
|
||
export const onOpenAIConnection = async ({apiKey,userId}:Props) => { | ||
if(apiKey){ | ||
const openai_connected = await getOpenAIByAPIKey(apiKey) | ||
if (!openai_connected){ | ||
await createOpenAI({apiKey,openai_connected, userId}) | ||
} | ||
} | ||
|
||
} | ||
|
||
export const getOpenAIConnection = async (userId: string) => { | ||
const connection = await getOpenAIByUserId(userId) | ||
return connection | ||
} |
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,9 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export async function GET(req: NextRequest) { | ||
const apiKey = req.nextUrl.searchParams.get('apiKey'); | ||
if (apiKey) { | ||
return NextResponse.redirect(`${process.env.NEXT_PUBLIC_URL}/dashboard/connections?apiKey=${apiKey}`); | ||
} | ||
return NextResponse.redirect(`${process.env.NEXT_PUBLIC_URL}/dashboard/connections`); | ||
} |
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,87 +1,16 @@ | ||
import { ConnectionProviderProps } from '../providers/connections-provider' | ||
import { z } from 'zod' | ||
|
||
export const EditUserProfileSchema = z.object({ | ||
email: z.string().email('Required'), | ||
name: z.string().min(1, 'Required'), | ||
}) | ||
|
||
export const WorkflowFormSchema = z.object({ | ||
name: z.string().min(1, 'Required'), | ||
description: z.string().min(1, 'Required'), | ||
}) | ||
|
||
export type ConnectionTypes = 'Notion' | ||
export type ConnectionTypes = 'Notion' | 'OpenAI' | ||
|
||
export type Connection = { | ||
title: ConnectionTypes | ||
description: string | ||
image: string | ||
connectionKey: keyof ConnectionProviderProps | ||
accessTokenKey?: string | ||
alwaysTrue?: boolean | ||
slackSpecial?: boolean | ||
} | ||
|
||
export type EditorCanvasTypes = | ||
| 'Email' | ||
| 'Condition' | ||
| 'AI' | ||
| 'Notion' | ||
| 'Custom Webhook' | ||
| 'Google Calendar' | ||
| 'Trigger' | ||
| 'Action' | ||
| 'Wait' | ||
|
||
export type EditorCanvasCardType = { | ||
title: string | ||
description: string | ||
completed: boolean | ||
current: boolean | ||
metadata: any | ||
type: EditorCanvasTypes | ||
} | ||
|
||
export type EditorNodeType = { | ||
id: string | ||
type: EditorCanvasCardType['type'] | ||
position: { | ||
x: number | ||
y: number | ||
} | ||
data: EditorCanvasCardType | ||
} | ||
|
||
export type EditorNode = EditorNodeType | ||
|
||
export type EditorActions = | ||
| { | ||
type: 'LOAD_DATA' | ||
payload: { | ||
elements: EditorNode[] | ||
edges: { | ||
id: string | ||
source: string | ||
target: string | ||
}[] | ||
} | ||
} | ||
| { | ||
type: 'UPDATE_NODE' | ||
payload: { | ||
elements: EditorNode[] | ||
} | ||
} | ||
| { type: 'REDO' } | ||
| { type: 'UNDO' } | ||
| { | ||
type: 'SELECTED_ELEMENT' | ||
payload: { | ||
element: EditorNode | ||
} | ||
} | ||
|
||
export const nodeMapper: Record<string, string> = { | ||
Notion: 'notionNode' | ||
showModal: boolean | ||
formElements?: { | ||
label: string | ||
placeholder: string | ||
type: string | ||
name: string | ||
}[] | ||
} |
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,71 +0,0 @@ | ||
'use client' | ||
import { createContext, useContext, useState } from 'react' | ||
|
||
export type ConnectionProviderProps = { | ||
notionNode: { | ||
accessToken: string | ||
databaseId: string | ||
workspaceName: string | ||
content: '' | ||
} | ||
workflowTemplate: { | ||
notion?: string | ||
} | ||
setNotionNode: React.Dispatch<React.SetStateAction<any>> | ||
setWorkFlowTemplate: React.Dispatch< | ||
React.SetStateAction<{ | ||
discord?: string | ||
notion?: string | ||
slack?: string | ||
}> | ||
> | ||
isLoading: boolean | ||
setIsLoading: React.Dispatch<React.SetStateAction<boolean>> | ||
} | ||
|
||
type ConnectionWithChildProps = { | ||
children: React.ReactNode | ||
} | ||
|
||
const InitialValues: ConnectionProviderProps = { | ||
notionNode: { | ||
accessToken: '', | ||
databaseId: '', | ||
workspaceName: '', | ||
content: '', | ||
}, | ||
workflowTemplate: { | ||
notion: '', | ||
}, | ||
isLoading: false, | ||
setNotionNode: () => undefined, | ||
setIsLoading: () => undefined, | ||
setWorkFlowTemplate: () => undefined, | ||
} | ||
|
||
const ConnectionsContext = createContext(InitialValues) | ||
const { Provider } = ConnectionsContext | ||
|
||
export const ConnectionsProvider = ({ children }: ConnectionWithChildProps) => { | ||
const [notionNode, setNotionNode] = useState(InitialValues.notionNode) | ||
const [isLoading, setIsLoading] = useState(InitialValues.isLoading) | ||
const [workflowTemplate, setWorkFlowTemplate] = useState( | ||
InitialValues.workflowTemplate | ||
) | ||
|
||
const values = { | ||
notionNode, | ||
setNotionNode, | ||
isLoading, | ||
setIsLoading, | ||
workflowTemplate, | ||
setWorkFlowTemplate, | ||
} | ||
|
||
return <Provider value={values}>{children}</Provider> | ||
} | ||
|
||
export const useNodeConnections = () => { | ||
const nodeConnection = useContext(ConnectionsContext) | ||
return { nodeConnection } | ||
} | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.