mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-24 13:44:54 +00:00
Generated by Spark: Fix all reported errors.
This commit is contained in:
3121
package-lock.json
generated
3121
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react'
|
||||
import { Toaster } from 'sonner'
|
||||
import { toast, Toaster } from 'sonner'
|
||||
import { Tabs, TabsContent } from '@/components/ui/tabs'
|
||||
import { AppHeader, PageHeader } from '@/components/organisms'
|
||||
import { ProjectDashboard } from '@/components/ProjectDashboard'
|
||||
@@ -65,11 +65,46 @@ function App() {
|
||||
setNextjsConfig,
|
||||
setNpmSettings,
|
||||
setFeatureToggles,
|
||||
lastSaved,
|
||||
getCurrentProject,
|
||||
loadProject,
|
||||
} = useProjectState()
|
||||
|
||||
const [lastSaved] = useState<number | null>(Date.now())
|
||||
|
||||
const getCurrentProject = () => ({
|
||||
name: nextjsConfig.appName,
|
||||
files,
|
||||
models,
|
||||
components,
|
||||
componentTrees,
|
||||
workflows,
|
||||
lambdas,
|
||||
theme,
|
||||
playwrightTests,
|
||||
storybookStories,
|
||||
unitTests,
|
||||
flaskConfig,
|
||||
nextjsConfig,
|
||||
npmSettings,
|
||||
featureToggles,
|
||||
})
|
||||
|
||||
const loadProject = (project: any) => {
|
||||
if (project.files) setFiles(project.files)
|
||||
if (project.models) setModels(project.models)
|
||||
if (project.components) setComponents(project.components)
|
||||
if (project.componentTrees) setComponentTrees(project.componentTrees)
|
||||
if (project.workflows) setWorkflows(project.workflows)
|
||||
if (project.lambdas) setLambdas(project.lambdas)
|
||||
if (project.theme) setTheme(project.theme)
|
||||
if (project.playwrightTests) setPlaywrightTests(project.playwrightTests)
|
||||
if (project.storybookStories) setStorybookStories(project.storybookStories)
|
||||
if (project.unitTests) setUnitTests(project.unitTests)
|
||||
if (project.flaskConfig) setFlaskConfig(project.flaskConfig)
|
||||
if (project.nextjsConfig) setNextjsConfig(project.nextjsConfig)
|
||||
if (project.npmSettings) setNpmSettings(project.npmSettings)
|
||||
if (project.featureToggles) setFeatureToggles(project.featureToggles)
|
||||
toast.success('Project loaded')
|
||||
}
|
||||
|
||||
const {
|
||||
activeFileId,
|
||||
setActiveFileId,
|
||||
@@ -78,7 +113,7 @@ function App() {
|
||||
handleFileClose,
|
||||
} = useFileOperations(files, setFiles)
|
||||
|
||||
const { handleExportProject, exportDialogOpen, setExportDialogOpen, generatedCode, handleDownloadZip } = useProjectExport({
|
||||
const { handleExportProject, exportDialogOpen, setExportDialogOpen, generatedCode, handleDownloadZip } = useProjectExport(
|
||||
files,
|
||||
models,
|
||||
components,
|
||||
@@ -88,8 +123,8 @@ function App() {
|
||||
unitTests,
|
||||
flaskConfig,
|
||||
nextjsConfig,
|
||||
npmSettings,
|
||||
})
|
||||
npmSettings
|
||||
)
|
||||
|
||||
const [activeTab, setActiveTab] = useState('dashboard')
|
||||
const [searchDialogOpen, setSearchDialogOpen] = useState(false)
|
||||
|
||||
@@ -45,11 +45,12 @@ export async function executeAction(
|
||||
|
||||
case 'api':
|
||||
if (action.payload?.endpoint) {
|
||||
const response = await fetch(action.payload.endpoint, {
|
||||
const fetchOptions: RequestInit = {
|
||||
method: action.payload.method || 'GET',
|
||||
headers: action.payload.headers || {},
|
||||
headers: action.payload.headers || undefined,
|
||||
body: action.payload.body ? JSON.stringify(action.payload.body) : undefined,
|
||||
})
|
||||
}
|
||||
const response = await fetch(action.payload.endpoint, fetchOptions)
|
||||
const data = await response.json()
|
||||
if (action.target) {
|
||||
context.updateData(action.target, data)
|
||||
|
||||
@@ -2,15 +2,15 @@ import { z } from 'zod'
|
||||
|
||||
export const ActionSchema = z.object({
|
||||
id: z.string(),
|
||||
type: z.enum(['create', 'update', 'delete', 'navigate', 'api', 'transform', 'custom']),
|
||||
type: z.enum(['create', 'update', 'delete', 'navigate', 'api', 'transform', 'custom'], { message: 'Invalid action type' }),
|
||||
target: z.string().optional(),
|
||||
payload: z.record(z.any()).optional(),
|
||||
payload: z.record(z.string(), z.any()).optional(),
|
||||
handler: z.string().optional(),
|
||||
})
|
||||
|
||||
export const DataSourceSchema = z.object({
|
||||
id: z.string(),
|
||||
type: z.enum(['kv', 'api', 'computed', 'static']),
|
||||
type: z.enum(['kv', 'api', 'computed', 'static'], { message: 'Invalid data source type' }),
|
||||
key: z.string().optional(),
|
||||
endpoint: z.string().optional(),
|
||||
transform: z.string().optional(),
|
||||
@@ -20,11 +20,11 @@ export const DataSourceSchema = z.object({
|
||||
|
||||
export const HookConfigSchema = z.object({
|
||||
name: z.string(),
|
||||
params: z.record(z.any()).optional(),
|
||||
bindings: z.record(z.string()).optional(),
|
||||
params: z.record(z.string(), z.any()).optional(),
|
||||
bindings: z.record(z.string(), z.string()).optional(),
|
||||
})
|
||||
|
||||
export const ComponentPropsSchema = z.record(z.any())
|
||||
export const ComponentPropsSchema = z.record(z.string(), z.any())
|
||||
|
||||
export const ComponentSchema: any = z.object({
|
||||
id: z.string(),
|
||||
@@ -32,12 +32,12 @@ export const ComponentSchema: any = z.object({
|
||||
props: ComponentPropsSchema.optional(),
|
||||
children: z.lazy(() => z.array(ComponentSchema)).optional(),
|
||||
dataBinding: z.string().optional(),
|
||||
eventHandlers: z.record(z.string()).optional(),
|
||||
eventHandlers: z.record(z.string(), z.string()).optional(),
|
||||
})
|
||||
|
||||
export const LayoutSchema = z.object({
|
||||
type: z.enum(['single', 'split', 'grid', 'tabs', 'flex']),
|
||||
direction: z.enum(['horizontal', 'vertical', 'row', 'column']).optional(),
|
||||
type: z.enum(['single', 'split', 'grid', 'tabs', 'flex'], { message: 'Invalid layout type' }),
|
||||
direction: z.enum(['horizontal', 'vertical', 'row', 'column'], { message: 'Invalid layout direction' }).optional(),
|
||||
panels: z.array(z.object({
|
||||
id: z.string(),
|
||||
minSize: z.number().optional(),
|
||||
@@ -56,7 +56,7 @@ export const PageSchemaDefinition = z.object({
|
||||
dataSources: z.array(DataSourceSchema).optional(),
|
||||
actions: z.array(ActionSchema).optional(),
|
||||
hooks: z.array(HookConfigSchema).optional(),
|
||||
seedData: z.record(z.any()).optional(),
|
||||
seedData: z.record(z.string(), z.any()).optional(),
|
||||
permissions: z.array(z.string()).optional(),
|
||||
})
|
||||
|
||||
|
||||
@@ -11,22 +11,22 @@ export const KeyboardShortcutSchema = z.object({
|
||||
export const PanelConfigSchema = z.object({
|
||||
id: z.string(),
|
||||
component: z.string(),
|
||||
props: z.record(z.any()).optional(),
|
||||
props: z.record(z.string(), z.any()).optional(),
|
||||
minSize: z.number().optional(),
|
||||
maxSize: z.number().optional(),
|
||||
})
|
||||
|
||||
export const LayoutConfigSchema = z.object({
|
||||
type: z.enum(['single', 'split', 'grid', 'tabs']),
|
||||
type: z.enum(['single', 'split', 'grid', 'tabs'], { message: 'Invalid layout type' }),
|
||||
panels: z.array(PanelConfigSchema).optional(),
|
||||
direction: z.enum(['horizontal', 'vertical']).optional(),
|
||||
direction: z.enum(['horizontal', 'vertical'], { message: 'Invalid direction' }).optional(),
|
||||
defaultSizes: z.array(z.number()).optional(),
|
||||
})
|
||||
|
||||
export const FeatureConfigSchema = z.object({
|
||||
id: z.string(),
|
||||
enabled: z.boolean(),
|
||||
config: z.record(z.any()).optional(),
|
||||
config: z.record(z.string(), z.any()).optional(),
|
||||
})
|
||||
|
||||
export const PageConfigSchema = z.object({
|
||||
|
||||
@@ -11,12 +11,12 @@ Return a valid JSON object with a single property "component" containing the com
|
||||
{
|
||||
"component": {
|
||||
"id": "unique-id",
|
||||
"type": "Box" (use Material UI component names like Box, Typography, Button, TextField, Grid, Paper, Card, etc.),
|
||||
"type": "Box",
|
||||
"name": "ComponentName",
|
||||
"props": {
|
||||
"sx": { "p": 2 } (Material UI sx props)
|
||||
"sx": { "p": 2 }
|
||||
},
|
||||
"children": [] (array of nested components following same structure)
|
||||
"children": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ Make sure to use appropriate Material UI components and props. Keep the structur
|
||||
static async generatePrismaModel(description: string, existingModels: PrismaModel[]): Promise<PrismaModel | null> {
|
||||
try {
|
||||
const existingModelNames = existingModels.map(m => m.name).join(', ')
|
||||
const prompt = window.spark.llmPrompt`You are a Prisma schema designer. Create a database model based on this description: ${description}
|
||||
|
||||
const prompt = window.spark.llmPrompt`You are a Prisma schema expert. Create a Prisma model based on this description: ${description}
|
||||
|
||||
Existing models in the schema: ${existingModelNames || 'none'}
|
||||
|
||||
@@ -49,7 +50,7 @@ Return a valid JSON object with a single property "model" containing the model s
|
||||
{
|
||||
"model": {
|
||||
"id": "unique-id-here",
|
||||
"name": "ModelName" (PascalCase, singular),
|
||||
"name": "ModelName",
|
||||
"fields": [
|
||||
{
|
||||
"id": "field-id-1",
|
||||
@@ -63,16 +64,14 @@ Return a valid JSON object with a single property "model" containing the model s
|
||||
{
|
||||
"id": "field-id-2",
|
||||
"name": "fieldName",
|
||||
"type": "String" (String, Int, Boolean, DateTime, Float, or existing model name for relations),
|
||||
"type": "String",
|
||||
"isRequired": true,
|
||||
"isUnique": false,
|
||||
"isArray": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Include an id field with uuid() default. Add createdAt and updatedAt DateTime fields with @default(now()) and @updatedAt. Use appropriate field types and relationships.`
|
||||
}`
|
||||
|
||||
const result = await ProtectedLLMService.safeLLMCall(
|
||||
prompt,
|
||||
@@ -112,7 +111,7 @@ Return ONLY the code without any markdown formatting or explanations.`
|
||||
|
||||
const result = await ProtectedLLMService.safeLLMCall(
|
||||
prompt,
|
||||
{ jsonMode: false, priority: 'medium', category: 'generate-code' }
|
||||
{ jsonMode: false, priority: 'high', category: 'generate-code' }
|
||||
)
|
||||
|
||||
return result ? result.trim() : null
|
||||
@@ -164,9 +163,7 @@ Return a valid JSON object with a single property "theme" containing:
|
||||
"spacing": 8,
|
||||
"borderRadius": 4
|
||||
}
|
||||
}
|
||||
|
||||
Choose colors that match the description and ensure good contrast. Use common font stacks.`
|
||||
}`
|
||||
|
||||
const result = await ProtectedLLMService.safeLLMCall(
|
||||
prompt,
|
||||
@@ -217,10 +214,9 @@ Suggest 3-5 common fields that would be useful for this model type. Use camelCas
|
||||
static async explainCode(code: string): Promise<string | null> {
|
||||
try {
|
||||
const prompt = window.spark.llmPrompt`You are a code teacher. Explain what this code does in simple terms:
|
||||
|
||||
${code}
|
||||
|
||||
Provide a clear, concise explanation suitable for developers learning the codebase.`
|
||||
Provide a clear, concise explanation suitable for developers.`
|
||||
|
||||
const result = await ProtectedLLMService.safeLLMCall(
|
||||
prompt,
|
||||
@@ -236,7 +232,7 @@ Provide a clear, concise explanation suitable for developers learning the codeba
|
||||
|
||||
static async generateCompleteApp(description: string): Promise<{ files: ProjectFile[], models: PrismaModel[], theme: Partial<ThemeConfig> } | null> {
|
||||
try {
|
||||
const prompt = window.spark.llmPrompt`You are a full-stack application architect. Design a complete Next.js application based on: ${description}
|
||||
const prompt = window.spark.llmPrompt`You are a full-stack architect. Generate a complete Next.js application structure based on this description: ${description}
|
||||
|
||||
Return a valid JSON object with properties "files", "models", and "theme":
|
||||
{
|
||||
|
||||
@@ -9,14 +9,14 @@ export const DataBindingSchema = z.object({
|
||||
export const EventHandlerSchema = z.object({
|
||||
event: z.string(),
|
||||
action: z.string(),
|
||||
params: z.record(z.any()).optional(),
|
||||
params: z.record(z.string(), z.any()).optional(),
|
||||
})
|
||||
|
||||
export const ComponentSchema: z.ZodType<any> = z.lazy(() =>
|
||||
z.object({
|
||||
id: z.string(),
|
||||
type: z.string(),
|
||||
props: z.record(z.any()).optional(),
|
||||
props: z.record(z.string(), z.any()).optional(),
|
||||
children: z.array(ComponentSchema).optional(),
|
||||
bindings: z.array(DataBindingSchema).optional(),
|
||||
events: z.array(EventHandlerSchema).optional(),
|
||||
@@ -26,7 +26,7 @@ export const ComponentSchema: z.ZodType<any> = z.lazy(() =>
|
||||
|
||||
export const DataSourceSchema = z.object({
|
||||
id: z.string(),
|
||||
type: z.enum(['kv', 'computed', 'static', 'ai']),
|
||||
type: z.enum(['kv', 'computed', 'static', 'ai'], { message: 'Invalid data source type' }),
|
||||
key: z.string().optional(),
|
||||
defaultValue: z.any().optional(),
|
||||
dependencies: z.array(z.string()).optional(),
|
||||
@@ -35,9 +35,9 @@ export const DataSourceSchema = z.object({
|
||||
|
||||
export const ActionConfigSchema = z.object({
|
||||
id: z.string(),
|
||||
type: z.enum(['create', 'update', 'delete', 'navigate', 'ai-generate', 'custom']),
|
||||
type: z.enum(['create', 'update', 'delete', 'navigate', 'ai-generate', 'custom'], { message: 'Invalid action type' }),
|
||||
trigger: z.string(),
|
||||
params: z.record(z.any()).optional(),
|
||||
params: z.record(z.string(), z.any()).optional(),
|
||||
onSuccess: z.string().optional(),
|
||||
onError: z.string().optional(),
|
||||
handler: z.string().optional(),
|
||||
@@ -46,13 +46,13 @@ export const ActionConfigSchema = z.object({
|
||||
export const HookConfigSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
params: z.record(z.any()).optional(),
|
||||
params: z.record(z.string(), z.any()).optional(),
|
||||
exports: z.array(z.string()).optional(),
|
||||
})
|
||||
|
||||
export const LayoutConfigSchema = z.object({
|
||||
type: z.enum(['single', 'split', 'tabs', 'grid']),
|
||||
direction: z.enum(['horizontal', 'vertical']).optional(),
|
||||
type: z.enum(['single', 'split', 'tabs', 'grid'], { message: 'Invalid layout type' }),
|
||||
direction: z.enum(['horizontal', 'vertical'], { message: 'Invalid direction' }).optional(),
|
||||
sizes: z.array(z.number()).optional(),
|
||||
gap: z.number().optional(),
|
||||
})
|
||||
@@ -66,7 +66,7 @@ export const PageSchemaType = z.object({
|
||||
data: z.array(DataSourceSchema).optional(),
|
||||
actions: z.array(ActionConfigSchema).optional(),
|
||||
hooks: z.array(HookConfigSchema).optional(),
|
||||
seedData: z.record(z.any()).optional(),
|
||||
seedData: z.record(z.string(), z.any()).optional(),
|
||||
})
|
||||
|
||||
export type PageSchema = z.infer<typeof PageSchemaType>
|
||||
|
||||
Reference in New Issue
Block a user