@tpitre/story-ui 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -72
- package/dist/cli/deploy.d.ts +0 -7
- package/dist/cli/deploy.d.ts.map +1 -1
- package/dist/cli/deploy.js +10 -421
- package/dist/cli/index.js +0 -0
- package/dist/mcp-server/index.js +7 -8
- package/dist/mcp-server/mcp-stdio-server.js +1 -2
- package/dist/mcp-server/routes/generateStory.d.ts.map +1 -1
- package/dist/mcp-server/routes/generateStory.js +3 -3
- package/dist/mcp-server/routes/generateStoryStream.d.ts.map +1 -1
- package/dist/mcp-server/routes/generateStoryStream.js +3 -3
- package/dist/mcp-server/routes/hybridStories.d.ts +6 -6
- package/dist/mcp-server/routes/hybridStories.d.ts.map +1 -1
- package/dist/mcp-server/routes/hybridStories.js +29 -27
- package/dist/mcp-server/routes/memoryStories.d.ts +7 -7
- package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -1
- package/dist/mcp-server/routes/memoryStories.js +37 -26
- package/dist/story-generator/postgresStoryService.d.ts +56 -0
- package/dist/story-generator/postgresStoryService.d.ts.map +1 -0
- package/dist/story-generator/postgresStoryService.js +240 -0
- package/dist/story-generator/storyServiceFactory.d.ts +22 -0
- package/dist/story-generator/storyServiceFactory.d.ts.map +1 -0
- package/dist/story-generator/storyServiceFactory.js +97 -0
- package/dist/story-generator/storyServiceInterface.d.ts +85 -0
- package/dist/story-generator/storyServiceInterface.d.ts.map +1 -0
- package/dist/story-generator/storyServiceInterface.js +5 -0
- package/dist/templates/StoryUI/StoryUIPanel.d.ts +5 -0
- package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -1
- package/dist/templates/StoryUI/StoryUIPanel.js +18 -3
- package/package.json +6 -6
- package/templates/StoryUI/StoryUIPanel.tsx +28 -3
- package/templates/StoryUI/manager.tsx +444 -213
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/setup.js.map +0 -1
- package/dist/cloudflare-edge/src/mcp-session.js +0 -462
- package/dist/cloudflare-edge/src/types.js +0 -4
- package/dist/cloudflare-edge/src/worker.js +0 -106
- package/dist/cloudflare-pages/vite.config.js +0 -14
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/mcp-server/index.js.map +0 -1
- package/dist/mcp-server/mcp-stdio-server.js.map +0 -1
- package/dist/mcp-server/routes/claude.js.map +0 -1
- package/dist/mcp-server/routes/components.js.map +0 -1
- package/dist/mcp-server/routes/generateStory.js.map +0 -1
- package/dist/mcp-server/routes/hybridStories.js.map +0 -1
- package/dist/mcp-server/routes/memoryStories.js.map +0 -1
- package/dist/mcp-server/routes/storySync.js.map +0 -1
- package/dist/mcp-server/routes/updateStory.js +0 -246
- package/dist/mcp-server/sessionManager.js.map +0 -1
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts +0 -6
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +0 -1
- package/dist/playground/components/AIAssistant/AIAssistant.js +0 -109
- package/dist/playground/components/AIAssistant/AIAssistant.js.map +0 -1
- package/dist/playground/components/AIAssistant/AIAssistant.module.css +0 -166
- package/dist/playground/components/Canvas/Canvas.d.ts +0 -9
- package/dist/playground/components/Canvas/Canvas.d.ts.map +0 -1
- package/dist/playground/components/Canvas/Canvas.js +0 -58
- package/dist/playground/components/Canvas/Canvas.js.map +0 -1
- package/dist/playground/components/Canvas/Canvas.module.css +0 -189
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +0 -9
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +0 -1
- package/dist/playground/components/Canvas/CanvasWithDnd.js +0 -158
- package/dist/playground/components/Canvas/CanvasWithDnd.js.map +0 -1
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts +0 -15
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +0 -1
- package/dist/playground/components/Canvas/ComponentRenderer.js +0 -177
- package/dist/playground/components/Canvas/ComponentRenderer.js.map +0 -1
- package/dist/playground/components/Canvas/DraggableComponent.d.ts +0 -15
- package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +0 -1
- package/dist/playground/components/Canvas/DraggableComponent.js +0 -49
- package/dist/playground/components/Canvas/DraggableComponent.js.map +0 -1
- package/dist/playground/components/Canvas/index.d.ts +0 -9
- package/dist/playground/components/Canvas/index.d.ts.map +0 -1
- package/dist/playground/components/Canvas/index.js +0 -5
- package/dist/playground/components/Canvas/index.js.map +0 -1
- package/dist/playground/components/CodeView/CodeView.d.ts +0 -12
- package/dist/playground/components/CodeView/CodeView.d.ts.map +0 -1
- package/dist/playground/components/CodeView/CodeView.js +0 -77
- package/dist/playground/components/CodeView/CodeView.js.map +0 -1
- package/dist/playground/components/CodeView/CodeView.module.css +0 -178
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +0 -17
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +0 -1
- package/dist/playground/components/ComponentPalette/ComponentPalette.js +0 -138
- package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +0 -1
- package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +0 -217
- package/dist/playground/components/ComponentPalette/index.d.ts +0 -3
- package/dist/playground/components/ComponentPalette/index.d.ts.map +0 -1
- package/dist/playground/components/ComponentPalette/index.js +0 -2
- package/dist/playground/components/ComponentPalette/index.js.map +0 -1
- package/dist/playground/components/DropZone/DropZone.d.ts +0 -17
- package/dist/playground/components/DropZone/DropZone.d.ts.map +0 -1
- package/dist/playground/components/DropZone/DropZone.js +0 -73
- package/dist/playground/components/DropZone/DropZone.js.map +0 -1
- package/dist/playground/components/DropZone/DropZone.module.css +0 -86
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts +0 -10
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +0 -1
- package/dist/playground/components/ExportDialog/ExportDialog.js +0 -57
- package/dist/playground/components/ExportDialog/ExportDialog.js.map +0 -1
- package/dist/playground/components/ExportDialog/ExportDialog.module.css +0 -328
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +0 -134
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +0 -1
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +0 -254
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +0 -1
- package/dist/playground/components/LayoutHelpers/index.d.ts +0 -3
- package/dist/playground/components/LayoutHelpers/index.d.ts.map +0 -1
- package/dist/playground/components/LayoutHelpers/index.js +0 -2
- package/dist/playground/components/LayoutHelpers/index.js.map +0 -1
- package/dist/playground/components/Playground/Playground.d.ts +0 -10
- package/dist/playground/components/Playground/Playground.d.ts.map +0 -1
- package/dist/playground/components/Playground/Playground.js +0 -128
- package/dist/playground/components/Playground/Playground.js.map +0 -1
- package/dist/playground/components/Playground/Playground.module.css +0 -308
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +0 -10
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +0 -1
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +0 -150
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +0 -1
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +0 -155
- package/dist/playground/components/PropertiesPanel/index.d.ts +0 -3
- package/dist/playground/components/PropertiesPanel/index.d.ts.map +0 -1
- package/dist/playground/components/PropertiesPanel/index.js +0 -2
- package/dist/playground/components/PropertiesPanel/index.js.map +0 -1
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +0 -12
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/BooleanEditor.js +0 -14
- package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +0 -12
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/ColorEditor.js +0 -62
- package/dist/playground/components/PropertyEditors/ColorEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts +0 -12
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/IconEditor.js +0 -123
- package/dist/playground/components/PropertyEditors/IconEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +0 -15
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/NumberEditor.js +0 -46
- package/dist/playground/components/PropertyEditors/NumberEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +0 -432
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +0 -19
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/SelectEditor.js +0 -17
- package/dist/playground/components/PropertyEditors/SelectEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +0 -19
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/SpacingEditor.js +0 -162
- package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +0 -214
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts +0 -14
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/TextEditor.js +0 -38
- package/dist/playground/components/PropertyEditors/TextEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +0 -23
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/TokenEditor.js +0 -50
- package/dist/playground/components/PropertyEditors/TokenEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/index.d.ts +0 -20
- package/dist/playground/components/PropertyEditors/index.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/index.js +0 -12
- package/dist/playground/components/PropertyEditors/index.js.map +0 -1
- package/dist/playground/components/TreeView/TreeView.d.ts +0 -10
- package/dist/playground/components/TreeView/TreeView.d.ts.map +0 -1
- package/dist/playground/components/TreeView/TreeView.js +0 -146
- package/dist/playground/components/TreeView/TreeView.js.map +0 -1
- package/dist/playground/components/TreeView/TreeView.module.css +0 -214
- package/dist/playground/components/TreeView/index.d.ts +0 -3
- package/dist/playground/components/TreeView/index.d.ts.map +0 -1
- package/dist/playground/components/TreeView/index.js +0 -2
- package/dist/playground/components/TreeView/index.js.map +0 -1
- package/dist/playground/config/propertyDefinitions.d.ts +0 -73
- package/dist/playground/config/propertyDefinitions.d.ts.map +0 -1
- package/dist/playground/config/propertyDefinitions.js +0 -809
- package/dist/playground/config/propertyDefinitions.js.map +0 -1
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts +0 -38
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/dist/playground/hooks/useKeyboardShortcuts.js +0 -191
- package/dist/playground/hooks/useKeyboardShortcuts.js.map +0 -1
- package/dist/playground/index.d.ts +0 -21
- package/dist/playground/index.d.ts.map +0 -1
- package/dist/playground/index.js +0 -23
- package/dist/playground/index.js.map +0 -1
- package/dist/playground/services/CodeGenerator.d.ts +0 -73
- package/dist/playground/services/CodeGenerator.d.ts.map +0 -1
- package/dist/playground/services/CodeGenerator.js +0 -359
- package/dist/playground/services/CodeGenerator.js.map +0 -1
- package/dist/playground/services/DragDropManager.d.ts +0 -95
- package/dist/playground/services/DragDropManager.d.ts.map +0 -1
- package/dist/playground/services/DragDropManager.js +0 -408
- package/dist/playground/services/DragDropManager.js.map +0 -1
- package/dist/playground/services/StoryParser.d.ts +0 -73
- package/dist/playground/services/StoryParser.d.ts.map +0 -1
- package/dist/playground/services/StoryParser.js +0 -419
- package/dist/playground/services/StoryParser.js.map +0 -1
- package/dist/playground/store/playgroundStore.d.ts +0 -86
- package/dist/playground/store/playgroundStore.d.ts.map +0 -1
- package/dist/playground/store/playgroundStore.js +0 -337
- package/dist/playground/store/playgroundStore.js.map +0 -1
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +0 -13
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundDragDrop.stories.js +0 -227
- package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +0 -1
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +0 -13
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundPhase4.stories.js +0 -334
- package/dist/playground/stories/PlaygroundPhase4.stories.js.map +0 -1
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +0 -14
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundPhase5.stories.js +0 -512
- package/dist/playground/stories/PlaygroundPhase5.stories.js.map +0 -1
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts +0 -13
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundProperties.stories.js +0 -342
- package/dist/playground/stories/PlaygroundProperties.stories.js.map +0 -1
- package/dist/playground/types/index.d.ts +0 -251
- package/dist/playground/types/index.d.ts.map +0 -1
- package/dist/playground/types/index.js +0 -5
- package/dist/playground/types/index.js.map +0 -1
- package/dist/scripts/verify-framework-adapters.js +0 -105
- package/dist/story-generator/componentBlacklist.js.map +0 -1
- package/dist/story-generator/componentDiscovery.js.map +0 -1
- package/dist/story-generator/configLoader.js.map +0 -1
- package/dist/story-generator/considerationsLoader.js.map +0 -1
- package/dist/story-generator/documentation-sources.js.map +0 -1
- package/dist/story-generator/documentationLoader.js.map +0 -1
- package/dist/story-generator/dynamicPackageDiscovery.js.map +0 -1
- package/dist/story-generator/enhancedComponentDiscovery.js.map +0 -1
- package/dist/story-generator/generateStory.js.map +0 -1
- package/dist/story-generator/gitignoreManager.js.map +0 -1
- package/dist/story-generator/inMemoryStoryService.js.map +0 -1
- package/dist/story-generator/logger.js.map +0 -1
- package/dist/story-generator/postProcessStory.js.map +0 -1
- package/dist/story-generator/productionGitignoreManager.js.map +0 -1
- package/dist/story-generator/promptGenerator.js.map +0 -1
- package/dist/story-generator/providerPresets.d.ts +0 -54
- package/dist/story-generator/providerPresets.d.ts.map +0 -1
- package/dist/story-generator/providerPresets.js +0 -214
- package/dist/story-generator/storyHistory.js.map +0 -1
- package/dist/story-generator/storySync.js.map +0 -1
- package/dist/story-generator/storyTracker.js.map +0 -1
- package/dist/story-generator/storyValidator.js.map +0 -1
- package/dist/story-generator/test_validation.d.ts +0 -2
- package/dist/story-generator/test_validation.d.ts.map +0 -1
- package/dist/story-generator/test_validation.js +0 -51
- package/dist/story-generator/universalDesignSystemAdapter.js.map +0 -1
- package/dist/story-generator/urlRedirectService.js.map +0 -1
- package/dist/story-generator/validateStory.js.map +0 -1
- package/dist/story-ui.config.js.map +0 -1
- package/dist/story-ui.config.loader.d.ts +0 -36
- package/dist/story-ui.config.loader.d.ts.map +0 -1
- package/dist/story-ui.config.loader.js +0 -205
- package/dist/story-ui.config.loader.js.map +0 -1
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +0 -807
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +0 -37
- package/dist/temp/package/templates/StoryUI/index.js +0 -2
- package/dist/templates/StoryUI/StoryUIPanel.js.map +0 -1
- package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +0 -1
- package/dist/templates/StoryUI/index.js.map +0 -1
- package/dist/templates/StoryUI/manager.d.ts +0 -14
- package/dist/templates/StoryUI/manager.d.ts.map +0 -1
- package/dist/templates/production-app/src/App.d.ts +0 -10
- package/dist/templates/production-app/src/App.d.ts.map +0 -1
- package/dist/templates/production-app/src/App.js +0 -653
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +0 -24
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +0 -1
- package/dist/templates/production-app/src/LivePreviewRenderer.js +0 -199
- package/dist/templates/production-app/src/componentRegistry.d.ts +0 -20
- package/dist/templates/production-app/src/componentRegistry.d.ts.map +0 -1
- package/dist/templates/production-app/src/componentRegistry.js +0 -316
- package/dist/templates/production-app/src/main.d.ts +0 -9
- package/dist/templates/production-app/src/main.d.ts.map +0 -1
- package/dist/templates/production-app/src/main.js +0 -18
- package/dist/templates/production-app/vite.config.d.ts +0 -3
- package/dist/templates/production-app/vite.config.d.ts.map +0 -1
- package/dist/templates/production-app/vite.config.js +0 -71
- package/dist/test-storybooks/angular-material-storybook/src/main.js +0 -66
- package/dist/test-storybooks/chakra-storybook/vite.config.js +0 -6
- package/dist/test-storybooks/mantine-storybook/vite.config.js +0 -93
- package/dist/test-storybooks/web-components-shoelace/vite.config.js +0 -9
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/mcp-server/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { clearAllStories, getMemoryStats } from './routes/memoryStories.js';
|
|
|
17
17
|
import { getAllStories, getStoryById, getStoryContent, deleteStory } from './routes/hybridStories.js';
|
|
18
18
|
import { getSyncedStories, deleteSyncedStory, clearAllSyncedStories, syncChatHistory, validateChatSession, getSyncedStoryById } from './routes/storySync.js';
|
|
19
19
|
import { setupProductionGitignore } from '../story-generator/productionGitignoreManager.js';
|
|
20
|
-
import {
|
|
20
|
+
import { getStoryService, getStorageType } from '../story-generator/storyServiceFactory.js';
|
|
21
21
|
import { loadUserConfig } from '../story-generator/configLoader.js';
|
|
22
22
|
import { loadConsiderations, considerationsToPrompt } from '../story-generator/considerationsLoader.js';
|
|
23
23
|
import { DocumentationLoader } from '../story-generator/documentationLoader.js';
|
|
@@ -177,14 +177,14 @@ app.post('/story-ui/delete', async (req, res) => {
|
|
|
177
177
|
return res.status(400).json({ error: 'chatId or storyId is required' });
|
|
178
178
|
}
|
|
179
179
|
console.log(`🗑️ Attempting to delete story: ${id}`);
|
|
180
|
-
// First try
|
|
181
|
-
const storyService =
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
console.log(`✅ Deleted story from
|
|
180
|
+
// First try storage service deletion (production mode)
|
|
181
|
+
const storyService = await getStoryService(config);
|
|
182
|
+
const serviceDeleted = await storyService.deleteStory(id);
|
|
183
|
+
if (serviceDeleted) {
|
|
184
|
+
console.log(`✅ Deleted story from ${getStorageType()}: ${id}`);
|
|
185
185
|
return res.json({
|
|
186
186
|
success: true,
|
|
187
|
-
message:
|
|
187
|
+
message: `Story deleted successfully from ${getStorageType()}`
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
// If not found in memory, try file-system deletion (development mode)
|
|
@@ -240,7 +240,6 @@ app.get('/story-ui/redirects.js', (req, res) => {
|
|
|
240
240
|
// Set up production-ready gitignore and directory structure on startup
|
|
241
241
|
const config = loadUserConfig();
|
|
242
242
|
const gitignoreManager = setupProductionGitignore(config);
|
|
243
|
-
const storyService = getInMemoryStoryService(config);
|
|
244
243
|
// Initialize URL redirect service
|
|
245
244
|
const redirectService = new UrlRedirectService(process.cwd());
|
|
246
245
|
const PORT = parseInt(process.env.PORT || '4001', 10);
|
|
@@ -5,7 +5,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextpro
|
|
|
5
5
|
import fetch from 'node-fetch';
|
|
6
6
|
import { loadUserConfig } from '../story-generator/configLoader.js';
|
|
7
7
|
import { EnhancedComponentDiscovery } from '../story-generator/enhancedComponentDiscovery.js';
|
|
8
|
-
|
|
8
|
+
// Story service is now handled by HTTP server routes
|
|
9
9
|
import { SessionManager } from './sessionManager.js';
|
|
10
10
|
import dotenv from 'dotenv';
|
|
11
11
|
import path from 'path';
|
|
@@ -33,7 +33,6 @@ const HTTP_PORT = process.env.VITE_STORY_UI_PORT || process.env.STORY_UI_HTTP_PO
|
|
|
33
33
|
const HTTP_BASE_URL = `http://localhost:${HTTP_PORT}`;
|
|
34
34
|
// Initialize configuration
|
|
35
35
|
const config = loadUserConfig();
|
|
36
|
-
const storyService = getInMemoryStoryService(config);
|
|
37
36
|
const sessionManager = SessionManager.getInstance();
|
|
38
37
|
// Generate a session ID for this MCP connection
|
|
39
38
|
const sessionId = crypto.randomBytes(16).toString('hex');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateStory.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/generateStory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"generateStory.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/generateStory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAwZ5C,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DAigBxE"}
|
|
@@ -5,7 +5,7 @@ import { buildClaudePrompt as buildFlexiblePrompt, buildFrameworkAwarePrompt, de
|
|
|
5
5
|
import { getAdapter } from '../../story-generator/framework-adapters/index.js';
|
|
6
6
|
import { loadUserConfig, validateConfig } from '../../story-generator/configLoader.js';
|
|
7
7
|
import { setupProductionGitignore } from '../../story-generator/productionGitignoreManager.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getStoryService } from '../../story-generator/storyServiceFactory.js';
|
|
9
9
|
import { extractAndValidateCodeBlock, createFallbackStory, validateStoryCode } from '../../story-generator/validateStory.js';
|
|
10
10
|
import { isBlacklistedComponent, isBlacklistedIcon, getBlacklistErrorMessage, ICON_CORRECTIONS } from '../../story-generator/componentBlacklist.js';
|
|
11
11
|
import { StoryTracker } from '../../story-generator/storyTracker.js';
|
|
@@ -377,7 +377,7 @@ export async function generateStoryFromPrompt(req, res) {
|
|
|
377
377
|
}
|
|
378
378
|
// Set up production-ready environment
|
|
379
379
|
const gitignoreManager = setupProductionGitignore(config);
|
|
380
|
-
const storyService =
|
|
380
|
+
const storyService = await getStoryService(config);
|
|
381
381
|
const isProduction = gitignoreManager.isProductionMode();
|
|
382
382
|
// Initialize story tracker for managing updates vs new creations
|
|
383
383
|
const storyTracker = new StoryTracker(config);
|
|
@@ -676,7 +676,7 @@ export async function generateStoryFromPrompt(req, res) {
|
|
|
676
676
|
prompt: isActualUpdate ? conversation.map((msg) => `${msg.role}: ${msg.content}`).join('\n\n') : prompt,
|
|
677
677
|
components: extractComponentsFromContent(fixedFileContents)
|
|
678
678
|
};
|
|
679
|
-
storyService.storeStory(generatedStory);
|
|
679
|
+
await storyService.storeStory(generatedStory);
|
|
680
680
|
// Register with story tracker
|
|
681
681
|
const mapping = {
|
|
682
682
|
title: aiTitle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateStoryStream.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/generateStoryStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"generateStoryStream.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/generateStoryStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAsa5C,wBAAsB,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAge9E"}
|
|
@@ -14,7 +14,7 @@ import { EnhancedComponentDiscovery } from '../../story-generator/enhancedCompon
|
|
|
14
14
|
import { buildClaudePrompt as buildFlexiblePrompt, buildFrameworkAwarePrompt, detectProjectFramework, } from '../../story-generator/promptGenerator.js';
|
|
15
15
|
import { loadUserConfig, validateConfig } from '../../story-generator/configLoader.js';
|
|
16
16
|
import { setupProductionGitignore } from '../../story-generator/productionGitignoreManager.js';
|
|
17
|
-
import {
|
|
17
|
+
import { getStoryService } from '../../story-generator/storyServiceFactory.js';
|
|
18
18
|
import { extractAndValidateCodeBlock, createFallbackStory } from '../../story-generator/validateStory.js';
|
|
19
19
|
import { isBlacklistedComponent, isBlacklistedIcon, getBlacklistErrorMessage, ICON_CORRECTIONS } from '../../story-generator/componentBlacklist.js';
|
|
20
20
|
import { StoryTracker } from '../../story-generator/storyTracker.js';
|
|
@@ -407,7 +407,7 @@ export async function generateStoryFromPromptStream(req, res) {
|
|
|
407
407
|
stream.sendProgress(currentStep, totalSteps, 'components_discovered', `Found ${components.length} components from ${config.importPath}`, { componentCount: components.length });
|
|
408
408
|
// Set up environment
|
|
409
409
|
const gitignoreManager = setupProductionGitignore(config);
|
|
410
|
-
const storyService =
|
|
410
|
+
const storyService = await getStoryService(config);
|
|
411
411
|
const isProduction = gitignoreManager.isProductionMode();
|
|
412
412
|
const storyTracker = new StoryTracker(config);
|
|
413
413
|
const historyManager = new StoryHistoryManager(process.cwd());
|
|
@@ -649,7 +649,7 @@ export async function generateStoryFromPromptStream(req, res) {
|
|
|
649
649
|
: prompt,
|
|
650
650
|
components: extractComponentsFromContent(fixedFileContents)
|
|
651
651
|
};
|
|
652
|
-
storyService.storeStory(generatedStory);
|
|
652
|
+
await storyService.storeStory(generatedStory);
|
|
653
653
|
const mapping = {
|
|
654
654
|
title: aiTitle,
|
|
655
655
|
fileName: finalFileName,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
2
|
/**
|
|
3
|
-
* Get all stories from both memory and file system
|
|
3
|
+
* Get all stories from both memory/database and file system
|
|
4
4
|
*/
|
|
5
|
-
export declare function getAllStories(req: Request, res: Response): void
|
|
5
|
+
export declare function getAllStories(req: Request, res: Response): Promise<void>;
|
|
6
6
|
/**
|
|
7
|
-
* Get a specific story by ID from memory or file system
|
|
7
|
+
* Get a specific story by ID from memory/database or file system
|
|
8
8
|
*/
|
|
9
|
-
export declare function getStoryById(req: Request, res: Response): Response<any, Record<string, any>> | undefined
|
|
9
|
+
export declare function getStoryById(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
10
10
|
/**
|
|
11
11
|
* Get story content by ID
|
|
12
12
|
*/
|
|
13
|
-
export declare function getStoryContent(req: Request, res: Response): Response<any, Record<string, any>> | undefined
|
|
13
|
+
export declare function getStoryContent(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
14
14
|
/**
|
|
15
15
|
* Delete a story by ID
|
|
16
16
|
*/
|
|
17
|
-
export declare function deleteStory(req: Request, res: Response): Response<any, Record<string, any>> | undefined
|
|
17
|
+
export declare function deleteStory(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
18
18
|
//# sourceMappingURL=hybridStories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hybridStories.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/hybridStories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO5C;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"hybridStories.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/hybridStories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO5C;;GAEG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBA6D9D;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DA4D7D;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DA0ChE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DA6C5D"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { getStoryService, getStorageType } from '../../story-generator/storyServiceFactory.js';
|
|
4
4
|
import { loadUserConfig } from '../../story-generator/configLoader.js';
|
|
5
5
|
import { setupProductionGitignore } from '../../story-generator/productionGitignoreManager.js';
|
|
6
6
|
/**
|
|
7
|
-
* Get all stories from both memory and file system
|
|
7
|
+
* Get all stories from both memory/database and file system
|
|
8
8
|
*/
|
|
9
|
-
export function getAllStories(req, res) {
|
|
9
|
+
export async function getAllStories(req, res) {
|
|
10
10
|
try {
|
|
11
11
|
const config = loadUserConfig();
|
|
12
12
|
const gitignoreManager = setupProductionGitignore(config);
|
|
13
|
-
const storyService =
|
|
13
|
+
const storyService = await getStoryService(config);
|
|
14
14
|
let allStories = [];
|
|
15
|
-
// Get stories from memory
|
|
16
|
-
const
|
|
17
|
-
allStories = [...
|
|
15
|
+
// Get stories from storage service (memory or PostgreSQL)
|
|
16
|
+
const storedStories = await storyService.getStoryMetadata();
|
|
17
|
+
allStories = [...storedStories];
|
|
18
18
|
// In development mode, also check file system
|
|
19
19
|
if (!gitignoreManager.isProductionMode() && config.generatedStoriesPath) {
|
|
20
20
|
try {
|
|
@@ -48,7 +48,7 @@ export function getAllStories(req, res) {
|
|
|
48
48
|
};
|
|
49
49
|
});
|
|
50
50
|
// Merge, avoiding duplicates
|
|
51
|
-
const memoryIds = new Set(
|
|
51
|
+
const memoryIds = new Set(storedStories.map(s => s.id));
|
|
52
52
|
const uniqueFileStories = fileStories.filter(s => !memoryIds.has(s.id));
|
|
53
53
|
allStories = [...allStories, ...uniqueFileStories];
|
|
54
54
|
}
|
|
@@ -65,22 +65,24 @@ export function getAllStories(req, res) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Get a specific story by ID from memory or file system
|
|
68
|
+
* Get a specific story by ID from memory/database or file system
|
|
69
69
|
*/
|
|
70
|
-
export function getStoryById(req, res) {
|
|
70
|
+
export async function getStoryById(req, res) {
|
|
71
71
|
try {
|
|
72
72
|
const { id } = req.params;
|
|
73
73
|
const config = loadUserConfig();
|
|
74
74
|
const gitignoreManager = setupProductionGitignore(config);
|
|
75
|
-
const storyService =
|
|
76
|
-
// First try
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
return res.json(
|
|
75
|
+
const storyService = await getStoryService(config);
|
|
76
|
+
// First try storage service
|
|
77
|
+
const storedStory = await storyService.getStory(id);
|
|
78
|
+
if (storedStory) {
|
|
79
|
+
return res.json({
|
|
80
|
+
...storedStory,
|
|
81
|
+
storage: getStorageType()
|
|
82
|
+
});
|
|
80
83
|
}
|
|
81
84
|
// In development, try file system
|
|
82
85
|
if (!gitignoreManager.isProductionMode() && config.generatedStoriesPath) {
|
|
83
|
-
// Try to find by story ID pattern
|
|
84
86
|
const files = fs.readdirSync(config.generatedStoriesPath);
|
|
85
87
|
// Extract hash from story ID (e.g., "story-abc123" -> "abc123")
|
|
86
88
|
const hashMatch = id.match(/^story-([a-f0-9]{8})$/);
|
|
@@ -125,14 +127,14 @@ export function getStoryById(req, res) {
|
|
|
125
127
|
/**
|
|
126
128
|
* Get story content by ID
|
|
127
129
|
*/
|
|
128
|
-
export function getStoryContent(req, res) {
|
|
130
|
+
export async function getStoryContent(req, res) {
|
|
129
131
|
try {
|
|
130
132
|
const { id } = req.params;
|
|
131
133
|
const config = loadUserConfig();
|
|
132
134
|
const gitignoreManager = setupProductionGitignore(config);
|
|
133
|
-
const storyService =
|
|
134
|
-
// First try
|
|
135
|
-
const content = storyService.getStoryContent(id);
|
|
135
|
+
const storyService = await getStoryService(config);
|
|
136
|
+
// First try storage service
|
|
137
|
+
const content = await storyService.getStoryContent(id);
|
|
136
138
|
if (content) {
|
|
137
139
|
res.setHeader('Content-Type', 'text/plain');
|
|
138
140
|
return res.send(content);
|
|
@@ -169,18 +171,18 @@ export function getStoryContent(req, res) {
|
|
|
169
171
|
/**
|
|
170
172
|
* Delete a story by ID
|
|
171
173
|
*/
|
|
172
|
-
export function deleteStory(req, res) {
|
|
174
|
+
export async function deleteStory(req, res) {
|
|
173
175
|
try {
|
|
174
176
|
const { id } = req.params;
|
|
175
177
|
const config = loadUserConfig();
|
|
176
178
|
const gitignoreManager = setupProductionGitignore(config);
|
|
177
|
-
const storyService =
|
|
179
|
+
const storyService = await getStoryService(config);
|
|
178
180
|
console.log(`🗑️ Attempting to delete story: ${id}`);
|
|
179
|
-
// First try
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
182
|
-
console.log(`✅ Deleted story from
|
|
183
|
-
return res.json({ success: true, message:
|
|
181
|
+
// First try storage service
|
|
182
|
+
const serviceDeleted = await storyService.deleteStory(id);
|
|
183
|
+
if (serviceDeleted) {
|
|
184
|
+
console.log(`✅ Deleted story from ${getStorageType()}: ${id}`);
|
|
185
|
+
return res.json({ success: true, message: `Story deleted from ${getStorageType()}` });
|
|
184
186
|
}
|
|
185
187
|
// In development, try file system
|
|
186
188
|
if (!gitignoreManager.isProductionMode() && config.generatedStoriesPath) {
|
|
@@ -2,25 +2,25 @@ import { Request, Response } from 'express';
|
|
|
2
2
|
/**
|
|
3
3
|
* Get all stories metadata
|
|
4
4
|
*/
|
|
5
|
-
export declare function getStoriesMetadata(req: Request, res: Response): void
|
|
5
|
+
export declare function getStoriesMetadata(req: Request, res: Response): Promise<void>;
|
|
6
6
|
/**
|
|
7
7
|
* Get a specific story by ID
|
|
8
8
|
*/
|
|
9
|
-
export declare function getStoryById(req: Request, res: Response): Response<any, Record<string, any>> | undefined
|
|
9
|
+
export declare function getStoryById(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
10
10
|
/**
|
|
11
11
|
* Get story content for Storybook integration
|
|
12
12
|
*/
|
|
13
|
-
export declare function getStoryContent(req: Request, res: Response): Response<any, Record<string, any>> | undefined
|
|
13
|
+
export declare function getStoryContent(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
14
14
|
/**
|
|
15
15
|
* Delete a story by ID
|
|
16
16
|
*/
|
|
17
|
-
export declare function deleteStory(req: Request, res: Response): Response<any, Record<string, any>> | undefined
|
|
17
|
+
export declare function deleteStory(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
18
18
|
/**
|
|
19
19
|
* Clear all stories
|
|
20
20
|
*/
|
|
21
|
-
export declare function clearAllStories(req: Request, res: Response): void
|
|
21
|
+
export declare function clearAllStories(req: Request, res: Response): Promise<void>;
|
|
22
22
|
/**
|
|
23
|
-
* Get
|
|
23
|
+
* Get storage usage statistics
|
|
24
24
|
*/
|
|
25
|
-
export declare function getMemoryStats(req: Request, res: Response): void
|
|
25
|
+
export declare function getMemoryStats(req: Request, res: Response): Promise<void>;
|
|
26
26
|
//# sourceMappingURL=memoryStories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoryStories.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/memoryStories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"memoryStories.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/memoryStories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAmBnE;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DA0B7D;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DAwBhE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DA0B5D;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAkBhE;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAsB/D"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getStoryService, getStorageType } from '../../story-generator/storyServiceFactory.js';
|
|
2
2
|
import { loadUserConfig } from '../../story-generator/configLoader.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get all stories metadata
|
|
5
5
|
*/
|
|
6
|
-
export function getStoriesMetadata(req, res) {
|
|
6
|
+
export async function getStoriesMetadata(req, res) {
|
|
7
7
|
try {
|
|
8
8
|
const config = loadUserConfig();
|
|
9
|
-
const storyService =
|
|
10
|
-
const metadata = storyService.getStoryMetadata();
|
|
9
|
+
const storyService = await getStoryService(config);
|
|
10
|
+
const metadata = await storyService.getStoryMetadata();
|
|
11
11
|
res.json({
|
|
12
12
|
success: true,
|
|
13
13
|
stories: metadata,
|
|
14
|
-
count: metadata.length
|
|
14
|
+
count: metadata.length,
|
|
15
|
+
storage: getStorageType()
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
catch (error) {
|
|
19
|
+
console.error('Error in getStoriesMetadata:', error);
|
|
18
20
|
res.status(500).json({
|
|
19
21
|
success: false,
|
|
20
22
|
error: 'Failed to retrieve stories metadata'
|
|
@@ -24,12 +26,12 @@ export function getStoriesMetadata(req, res) {
|
|
|
24
26
|
/**
|
|
25
27
|
* Get a specific story by ID
|
|
26
28
|
*/
|
|
27
|
-
export function getStoryById(req, res) {
|
|
29
|
+
export async function getStoryById(req, res) {
|
|
28
30
|
try {
|
|
29
31
|
const { id } = req.params;
|
|
30
32
|
const config = loadUserConfig();
|
|
31
|
-
const storyService =
|
|
32
|
-
const story = storyService.getStory(id);
|
|
33
|
+
const storyService = await getStoryService(config);
|
|
34
|
+
const story = await storyService.getStory(id);
|
|
33
35
|
if (!story) {
|
|
34
36
|
return res.status(404).json({
|
|
35
37
|
success: false,
|
|
@@ -38,10 +40,12 @@ export function getStoryById(req, res) {
|
|
|
38
40
|
}
|
|
39
41
|
res.json({
|
|
40
42
|
success: true,
|
|
41
|
-
story
|
|
43
|
+
story,
|
|
44
|
+
storage: getStorageType()
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
catch (error) {
|
|
48
|
+
console.error('Error in getStoryById:', error);
|
|
45
49
|
res.status(500).json({
|
|
46
50
|
success: false,
|
|
47
51
|
error: 'Failed to retrieve story'
|
|
@@ -51,12 +55,12 @@ export function getStoryById(req, res) {
|
|
|
51
55
|
/**
|
|
52
56
|
* Get story content for Storybook integration
|
|
53
57
|
*/
|
|
54
|
-
export function getStoryContent(req, res) {
|
|
58
|
+
export async function getStoryContent(req, res) {
|
|
55
59
|
try {
|
|
56
60
|
const { id } = req.params;
|
|
57
61
|
const config = loadUserConfig();
|
|
58
|
-
const storyService =
|
|
59
|
-
const content = storyService.getStoryContent(id);
|
|
62
|
+
const storyService = await getStoryService(config);
|
|
63
|
+
const content = await storyService.getStoryContent(id);
|
|
60
64
|
if (!content) {
|
|
61
65
|
return res.status(404).json({
|
|
62
66
|
success: false,
|
|
@@ -68,6 +72,7 @@ export function getStoryContent(req, res) {
|
|
|
68
72
|
res.send(content);
|
|
69
73
|
}
|
|
70
74
|
catch (error) {
|
|
75
|
+
console.error('Error in getStoryContent:', error);
|
|
71
76
|
res.status(500).json({
|
|
72
77
|
success: false,
|
|
73
78
|
error: 'Failed to retrieve story content'
|
|
@@ -77,12 +82,12 @@ export function getStoryContent(req, res) {
|
|
|
77
82
|
/**
|
|
78
83
|
* Delete a story by ID
|
|
79
84
|
*/
|
|
80
|
-
export function deleteStory(req, res) {
|
|
85
|
+
export async function deleteStory(req, res) {
|
|
81
86
|
try {
|
|
82
87
|
const { id } = req.params;
|
|
83
88
|
const config = loadUserConfig();
|
|
84
|
-
const storyService =
|
|
85
|
-
const deleted = storyService.deleteStory(id);
|
|
89
|
+
const storyService = await getStoryService(config);
|
|
90
|
+
const deleted = await storyService.deleteStory(id);
|
|
86
91
|
if (!deleted) {
|
|
87
92
|
return res.status(404).json({
|
|
88
93
|
success: false,
|
|
@@ -91,10 +96,12 @@ export function deleteStory(req, res) {
|
|
|
91
96
|
}
|
|
92
97
|
res.json({
|
|
93
98
|
success: true,
|
|
94
|
-
message: 'Story deleted successfully'
|
|
99
|
+
message: 'Story deleted successfully',
|
|
100
|
+
storage: getStorageType()
|
|
95
101
|
});
|
|
96
102
|
}
|
|
97
103
|
catch (error) {
|
|
104
|
+
console.error('Error in deleteStory:', error);
|
|
98
105
|
res.status(500).json({
|
|
99
106
|
success: false,
|
|
100
107
|
error: 'Failed to delete story'
|
|
@@ -104,17 +111,19 @@ export function deleteStory(req, res) {
|
|
|
104
111
|
/**
|
|
105
112
|
* Clear all stories
|
|
106
113
|
*/
|
|
107
|
-
export function clearAllStories(req, res) {
|
|
114
|
+
export async function clearAllStories(req, res) {
|
|
108
115
|
try {
|
|
109
116
|
const config = loadUserConfig();
|
|
110
|
-
const storyService =
|
|
111
|
-
storyService.clearAllStories();
|
|
117
|
+
const storyService = await getStoryService(config);
|
|
118
|
+
await storyService.clearAllStories();
|
|
112
119
|
res.json({
|
|
113
120
|
success: true,
|
|
114
|
-
message: 'All stories cleared successfully'
|
|
121
|
+
message: 'All stories cleared successfully',
|
|
122
|
+
storage: getStorageType()
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
125
|
catch (error) {
|
|
126
|
+
console.error('Error in clearAllStories:', error);
|
|
118
127
|
res.status(500).json({
|
|
119
128
|
success: false,
|
|
120
129
|
error: 'Failed to clear stories'
|
|
@@ -122,26 +131,28 @@ export function clearAllStories(req, res) {
|
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
133
|
/**
|
|
125
|
-
* Get
|
|
134
|
+
* Get storage usage statistics
|
|
126
135
|
*/
|
|
127
|
-
export function getMemoryStats(req, res) {
|
|
136
|
+
export async function getMemoryStats(req, res) {
|
|
128
137
|
try {
|
|
129
138
|
const config = loadUserConfig();
|
|
130
|
-
const storyService =
|
|
131
|
-
const stats = storyService.
|
|
139
|
+
const storyService = await getStoryService(config);
|
|
140
|
+
const stats = await storyService.getStorageStats();
|
|
132
141
|
res.json({
|
|
133
142
|
success: true,
|
|
134
143
|
stats: {
|
|
135
144
|
...stats,
|
|
136
145
|
totalSizeMB: Math.round(stats.totalSizeBytes / 1024 / 1024 * 100) / 100,
|
|
137
146
|
averageSizeKB: Math.round(stats.averageSizeBytes / 1024 * 100) / 100
|
|
138
|
-
}
|
|
147
|
+
},
|
|
148
|
+
storage: getStorageType()
|
|
139
149
|
});
|
|
140
150
|
}
|
|
141
151
|
catch (error) {
|
|
152
|
+
console.error('Error in getMemoryStats:', error);
|
|
142
153
|
res.status(500).json({
|
|
143
154
|
success: false,
|
|
144
|
-
error: 'Failed to retrieve
|
|
155
|
+
error: 'Failed to retrieve storage statistics'
|
|
145
156
|
});
|
|
146
157
|
}
|
|
147
158
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IStoryService, GeneratedStory, StoryMetadata, StorageStats } from './storyServiceInterface.js';
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL Story Service
|
|
4
|
+
* Persistent story storage using PostgreSQL database
|
|
5
|
+
* Designed for Railway PostgreSQL deployments
|
|
6
|
+
*/
|
|
7
|
+
export declare class PostgresStoryService implements IStoryService {
|
|
8
|
+
private pool;
|
|
9
|
+
private initialized;
|
|
10
|
+
constructor(connectionString: string);
|
|
11
|
+
/**
|
|
12
|
+
* Initialize database schema
|
|
13
|
+
*/
|
|
14
|
+
initialize(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Store a generated story
|
|
17
|
+
*/
|
|
18
|
+
storeStory(story: GeneratedStory): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve a story by ID
|
|
21
|
+
*/
|
|
22
|
+
getStory(id: string): Promise<GeneratedStory | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Get all stored stories
|
|
25
|
+
*/
|
|
26
|
+
getAllStories(): Promise<GeneratedStory[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete a story by ID
|
|
29
|
+
*/
|
|
30
|
+
deleteStory(id: string): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Clear all stories
|
|
33
|
+
*/
|
|
34
|
+
clearAllStories(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Get story content for Storybook integration
|
|
37
|
+
*/
|
|
38
|
+
getStoryContent(id: string): Promise<string | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Get story metadata for listing
|
|
41
|
+
*/
|
|
42
|
+
getStoryMetadata(): Promise<StoryMetadata[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Get storage usage statistics
|
|
45
|
+
*/
|
|
46
|
+
getStorageStats(): Promise<StorageStats>;
|
|
47
|
+
/**
|
|
48
|
+
* Count unique components in story content
|
|
49
|
+
*/
|
|
50
|
+
private countComponents;
|
|
51
|
+
/**
|
|
52
|
+
* Close the connection pool
|
|
53
|
+
*/
|
|
54
|
+
close(): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=postgresStoryService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgresStoryService.d.ts","sourceRoot":"","sources":["../../story-generator/postgresStoryService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI7G;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,WAAW,CAAkB;gBAEzB,gBAAgB,EAAE,MAAM;IAUpC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BjC;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAgCtD;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAiC1D;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IA0BhD;;OAEG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB/C;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtC;;OAEG;IACG,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKzD;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAwBlD;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IA4B9C;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|