@tpitre/story-ui 3.3.0 → 3.4.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/dist/cli/index.js +0 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cloudflare-edge/src/mcp-session.js +462 -0
- package/dist/cloudflare-edge/src/types.js +4 -0
- package/dist/cloudflare-edge/src/worker.js +106 -0
- package/dist/cloudflare-pages/vite.config.js +14 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/index.js.map +1 -0
- package/dist/mcp-server/mcp-stdio-server.js.map +1 -0
- package/dist/mcp-server/routes/claude.js.map +1 -0
- package/dist/mcp-server/routes/components.js.map +1 -0
- package/dist/mcp-server/routes/generateStory.js.map +1 -0
- package/dist/mcp-server/routes/hybridStories.d.ts +18 -0
- package/dist/mcp-server/routes/hybridStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/hybridStories.js +216 -0
- package/dist/mcp-server/routes/hybridStories.js.map +1 -0
- package/dist/mcp-server/routes/memoryStories.d.ts +26 -0
- package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/memoryStories.js +158 -0
- package/dist/mcp-server/routes/memoryStories.js.map +1 -0
- package/dist/mcp-server/routes/storySync.d.ts +26 -0
- package/dist/mcp-server/routes/storySync.d.ts.map +1 -0
- package/dist/mcp-server/routes/storySync.js +147 -0
- package/dist/mcp-server/routes/storySync.js.map +1 -0
- package/dist/mcp-server/routes/updateStory.js +246 -0
- package/dist/mcp-server/sessionManager.d.ts +50 -0
- package/dist/mcp-server/sessionManager.d.ts.map +1 -0
- package/dist/mcp-server/sessionManager.js +125 -0
- package/dist/mcp-server/sessionManager.js.map +1 -0
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts +6 -0
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +1 -0
- package/dist/playground/components/AIAssistant/AIAssistant.js +109 -0
- package/dist/playground/components/AIAssistant/AIAssistant.js.map +1 -0
- package/dist/playground/components/AIAssistant/AIAssistant.module.css +166 -0
- package/dist/playground/components/Canvas/Canvas.d.ts +9 -0
- package/dist/playground/components/Canvas/Canvas.d.ts.map +1 -0
- package/dist/playground/components/Canvas/Canvas.js +58 -0
- package/dist/playground/components/Canvas/Canvas.js.map +1 -0
- package/dist/playground/components/Canvas/Canvas.module.css +189 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +9 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +1 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.js +158 -0
- package/dist/playground/components/Canvas/CanvasWithDnd.js.map +1 -0
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts +15 -0
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +1 -0
- package/dist/playground/components/Canvas/ComponentRenderer.js +177 -0
- package/dist/playground/components/Canvas/ComponentRenderer.js.map +1 -0
- package/dist/playground/components/Canvas/DraggableComponent.d.ts +15 -0
- package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +1 -0
- package/dist/playground/components/Canvas/DraggableComponent.js +49 -0
- package/dist/playground/components/Canvas/DraggableComponent.js.map +1 -0
- package/dist/playground/components/Canvas/index.d.ts +9 -0
- package/dist/playground/components/Canvas/index.d.ts.map +1 -0
- package/dist/playground/components/Canvas/index.js +5 -0
- package/dist/playground/components/Canvas/index.js.map +1 -0
- package/dist/playground/components/CodeView/CodeView.d.ts +12 -0
- package/dist/playground/components/CodeView/CodeView.d.ts.map +1 -0
- package/dist/playground/components/CodeView/CodeView.js +77 -0
- package/dist/playground/components/CodeView/CodeView.js.map +1 -0
- package/dist/playground/components/CodeView/CodeView.module.css +178 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +17 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +1 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.js +138 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +1 -0
- package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +217 -0
- package/dist/playground/components/ComponentPalette/index.d.ts +3 -0
- package/dist/playground/components/ComponentPalette/index.d.ts.map +1 -0
- package/dist/playground/components/ComponentPalette/index.js +2 -0
- package/dist/playground/components/ComponentPalette/index.js.map +1 -0
- package/dist/playground/components/DropZone/DropZone.d.ts +17 -0
- package/dist/playground/components/DropZone/DropZone.d.ts.map +1 -0
- package/dist/playground/components/DropZone/DropZone.js +73 -0
- package/dist/playground/components/DropZone/DropZone.js.map +1 -0
- package/dist/playground/components/DropZone/DropZone.module.css +86 -0
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts +10 -0
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +1 -0
- package/dist/playground/components/ExportDialog/ExportDialog.js +57 -0
- package/dist/playground/components/ExportDialog/ExportDialog.js.map +1 -0
- package/dist/playground/components/ExportDialog/ExportDialog.module.css +328 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +134 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +1 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +254 -0
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +1 -0
- package/dist/playground/components/LayoutHelpers/index.d.ts +3 -0
- package/dist/playground/components/LayoutHelpers/index.d.ts.map +1 -0
- package/dist/playground/components/LayoutHelpers/index.js +2 -0
- package/dist/playground/components/LayoutHelpers/index.js.map +1 -0
- package/dist/playground/components/Playground/Playground.d.ts +10 -0
- package/dist/playground/components/Playground/Playground.d.ts.map +1 -0
- package/dist/playground/components/Playground/Playground.js +128 -0
- package/dist/playground/components/Playground/Playground.js.map +1 -0
- package/dist/playground/components/Playground/Playground.module.css +308 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +10 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +1 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +150 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +1 -0
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +155 -0
- package/dist/playground/components/PropertiesPanel/index.d.ts +3 -0
- package/dist/playground/components/PropertiesPanel/index.d.ts.map +1 -0
- package/dist/playground/components/PropertiesPanel/index.js +2 -0
- package/dist/playground/components/PropertiesPanel/index.js.map +1 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +12 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.js +14 -0
- package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +12 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.js +62 -0
- package/dist/playground/components/PropertyEditors/ColorEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts +12 -0
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/IconEditor.js +123 -0
- package/dist/playground/components/PropertyEditors/IconEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +15 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.js +46 -0
- package/dist/playground/components/PropertyEditors/NumberEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +432 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +19 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.js +17 -0
- package/dist/playground/components/PropertyEditors/SelectEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +19 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.js +162 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +214 -0
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts +14 -0
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/TextEditor.js +38 -0
- package/dist/playground/components/PropertyEditors/TextEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +23 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.js +50 -0
- package/dist/playground/components/PropertyEditors/TokenEditor.js.map +1 -0
- package/dist/playground/components/PropertyEditors/index.d.ts +20 -0
- package/dist/playground/components/PropertyEditors/index.d.ts.map +1 -0
- package/dist/playground/components/PropertyEditors/index.js +12 -0
- package/dist/playground/components/PropertyEditors/index.js.map +1 -0
- package/dist/playground/components/TreeView/TreeView.d.ts +10 -0
- package/dist/playground/components/TreeView/TreeView.d.ts.map +1 -0
- package/dist/playground/components/TreeView/TreeView.js +146 -0
- package/dist/playground/components/TreeView/TreeView.js.map +1 -0
- package/dist/playground/components/TreeView/TreeView.module.css +214 -0
- package/dist/playground/components/TreeView/index.d.ts +3 -0
- package/dist/playground/components/TreeView/index.d.ts.map +1 -0
- package/dist/playground/components/TreeView/index.js +2 -0
- package/dist/playground/components/TreeView/index.js.map +1 -0
- package/dist/playground/config/propertyDefinitions.d.ts +73 -0
- package/dist/playground/config/propertyDefinitions.d.ts.map +1 -0
- package/dist/playground/config/propertyDefinitions.js +809 -0
- package/dist/playground/config/propertyDefinitions.js.map +1 -0
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts +38 -0
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/playground/hooks/useKeyboardShortcuts.js +191 -0
- package/dist/playground/hooks/useKeyboardShortcuts.js.map +1 -0
- package/dist/playground/index.d.ts +21 -0
- package/dist/playground/index.d.ts.map +1 -0
- package/dist/playground/index.js +23 -0
- package/dist/playground/index.js.map +1 -0
- package/dist/playground/services/CodeGenerator.d.ts +73 -0
- package/dist/playground/services/CodeGenerator.d.ts.map +1 -0
- package/dist/playground/services/CodeGenerator.js +359 -0
- package/dist/playground/services/CodeGenerator.js.map +1 -0
- package/dist/playground/services/DragDropManager.d.ts +95 -0
- package/dist/playground/services/DragDropManager.d.ts.map +1 -0
- package/dist/playground/services/DragDropManager.js +408 -0
- package/dist/playground/services/DragDropManager.js.map +1 -0
- package/dist/playground/services/StoryParser.d.ts +73 -0
- package/dist/playground/services/StoryParser.d.ts.map +1 -0
- package/dist/playground/services/StoryParser.js +419 -0
- package/dist/playground/services/StoryParser.js.map +1 -0
- package/dist/playground/store/playgroundStore.d.ts +86 -0
- package/dist/playground/store/playgroundStore.d.ts.map +1 -0
- package/dist/playground/store/playgroundStore.js +337 -0
- package/dist/playground/store/playgroundStore.js.map +1 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +13 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.js +227 -0
- package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +1 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +13 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.js +334 -0
- package/dist/playground/stories/PlaygroundPhase4.stories.js.map +1 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +14 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.js +512 -0
- package/dist/playground/stories/PlaygroundPhase5.stories.js.map +1 -0
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts +13 -0
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +1 -0
- package/dist/playground/stories/PlaygroundProperties.stories.js +342 -0
- package/dist/playground/stories/PlaygroundProperties.stories.js.map +1 -0
- package/dist/playground/types/index.d.ts +251 -0
- package/dist/playground/types/index.d.ts.map +1 -0
- package/dist/playground/types/index.js +5 -0
- package/dist/playground/types/index.js.map +1 -0
- package/dist/scripts/verify-framework-adapters.js +105 -0
- package/dist/story-generator/componentBlacklist.js.map +1 -0
- package/dist/story-generator/componentDiscovery.js.map +1 -0
- package/dist/story-generator/configLoader.js.map +1 -0
- package/dist/story-generator/considerationsLoader.js.map +1 -0
- package/dist/story-generator/documentation-sources.js.map +1 -0
- package/dist/story-generator/documentationLoader.js.map +1 -0
- package/dist/story-generator/dynamicPackageDiscovery.js.map +1 -0
- package/dist/story-generator/enhancedComponentDiscovery.js.map +1 -0
- package/dist/story-generator/generateStory.js.map +1 -0
- package/dist/story-generator/gitignoreManager.js.map +1 -0
- package/dist/story-generator/inMemoryStoryService.d.ts +89 -0
- package/dist/story-generator/inMemoryStoryService.d.ts.map +1 -0
- package/dist/story-generator/inMemoryStoryService.js +128 -0
- package/dist/story-generator/inMemoryStoryService.js.map +1 -0
- package/dist/story-generator/logger.js.map +1 -0
- package/dist/story-generator/postProcessStory.js.map +1 -0
- 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/productionGitignoreManager.d.ts +91 -0
- package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -0
- package/dist/story-generator/productionGitignoreManager.js +340 -0
- package/dist/story-generator/productionGitignoreManager.js.map +1 -0
- package/dist/story-generator/promptGenerator.js.map +1 -0
- package/dist/story-generator/providerPresets.d.ts +54 -0
- package/dist/story-generator/providerPresets.d.ts.map +1 -0
- package/dist/story-generator/providerPresets.js +214 -0
- package/dist/story-generator/storyHistory.js.map +1 -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/story-generator/storySync.d.ts +68 -0
- package/dist/story-generator/storySync.d.ts.map +1 -0
- package/dist/story-generator/storySync.js +201 -0
- package/dist/story-generator/storySync.js.map +1 -0
- package/dist/story-generator/storyTracker.js.map +1 -0
- package/dist/story-generator/storyValidator.js.map +1 -0
- package/dist/story-generator/test_validation.d.ts +2 -0
- package/dist/story-generator/test_validation.d.ts.map +1 -0
- package/dist/story-generator/test_validation.js +51 -0
- package/dist/story-generator/universalDesignSystemAdapter.js.map +1 -0
- package/dist/story-generator/urlRedirectService.js.map +1 -0
- package/dist/story-generator/validateStory.js.map +1 -0
- package/dist/story-ui.config.js.map +1 -0
- package/dist/story-ui.config.loader.d.ts +36 -0
- package/dist/story-ui.config.loader.d.ts.map +1 -0
- package/dist/story-ui.config.loader.js +205 -0
- package/dist/story-ui.config.loader.js.map +1 -0
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +807 -0
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +37 -0
- package/dist/temp/package/templates/StoryUI/index.js +2 -0
- package/dist/templates/StoryUI/StoryUIPanel.js.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +1 -0
- package/dist/templates/StoryUI/index.js.map +1 -0
- package/dist/templates/StoryUI/manager.d.ts +14 -0
- package/dist/templates/StoryUI/manager.d.ts.map +1 -0
- package/dist/templates/production-app/src/App.d.ts +10 -0
- package/dist/templates/production-app/src/App.d.ts.map +1 -0
- package/dist/templates/production-app/src/App.js +653 -0
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +24 -0
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +1 -0
- package/dist/templates/production-app/src/LivePreviewRenderer.js +199 -0
- package/dist/templates/production-app/src/componentRegistry.d.ts +20 -0
- package/dist/templates/production-app/src/componentRegistry.d.ts.map +1 -0
- package/dist/templates/production-app/src/componentRegistry.js +316 -0
- package/dist/templates/production-app/src/main.d.ts +9 -0
- package/dist/templates/production-app/src/main.d.ts.map +1 -0
- package/dist/templates/production-app/src/main.js +18 -0
- package/dist/templates/production-app/vite.config.d.ts +3 -0
- package/dist/templates/production-app/vite.config.d.ts.map +1 -0
- package/dist/templates/production-app/vite.config.js +71 -0
- package/dist/test-storybooks/angular-material-storybook/src/main.js +66 -0
- package/dist/test-storybooks/chakra-storybook/vite.config.js +6 -0
- package/dist/test-storybooks/mantine-storybook/vite.config.js +93 -0
- package/dist/test-storybooks/web-components-shoelace/vite.config.js +9 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
|
@@ -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"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
const { Pool } = pg;
|
|
3
|
+
/**
|
|
4
|
+
* PostgreSQL Story Service
|
|
5
|
+
* Persistent story storage using PostgreSQL database
|
|
6
|
+
* Designed for Railway PostgreSQL deployments
|
|
7
|
+
*/
|
|
8
|
+
export class PostgresStoryService {
|
|
9
|
+
constructor(connectionString) {
|
|
10
|
+
this.initialized = false;
|
|
11
|
+
this.pool = new Pool({
|
|
12
|
+
connectionString,
|
|
13
|
+
ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false,
|
|
14
|
+
max: 10,
|
|
15
|
+
idleTimeoutMillis: 30000,
|
|
16
|
+
connectionTimeoutMillis: 10000,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Initialize database schema
|
|
21
|
+
*/
|
|
22
|
+
async initialize() {
|
|
23
|
+
if (this.initialized)
|
|
24
|
+
return;
|
|
25
|
+
const client = await this.pool.connect();
|
|
26
|
+
try {
|
|
27
|
+
await client.query(`
|
|
28
|
+
CREATE TABLE IF NOT EXISTS stories (
|
|
29
|
+
id VARCHAR(255) PRIMARY KEY,
|
|
30
|
+
title VARCHAR(500) NOT NULL,
|
|
31
|
+
description TEXT,
|
|
32
|
+
content TEXT NOT NULL,
|
|
33
|
+
prompt TEXT,
|
|
34
|
+
components TEXT[],
|
|
35
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
36
|
+
last_accessed TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
CREATE INDEX IF NOT EXISTS idx_stories_created_at ON stories(created_at DESC);
|
|
40
|
+
CREATE INDEX IF NOT EXISTS idx_stories_last_accessed ON stories(last_accessed DESC);
|
|
41
|
+
`);
|
|
42
|
+
this.initialized = true;
|
|
43
|
+
console.log('✅ PostgreSQL story service initialized');
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
client.release();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Store a generated story
|
|
51
|
+
*/
|
|
52
|
+
async storeStory(story) {
|
|
53
|
+
await this.initialize();
|
|
54
|
+
const client = await this.pool.connect();
|
|
55
|
+
try {
|
|
56
|
+
await client.query(`INSERT INTO stories (id, title, description, content, prompt, components, created_at, last_accessed)
|
|
57
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
58
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
59
|
+
title = EXCLUDED.title,
|
|
60
|
+
description = EXCLUDED.description,
|
|
61
|
+
content = EXCLUDED.content,
|
|
62
|
+
prompt = EXCLUDED.prompt,
|
|
63
|
+
components = EXCLUDED.components,
|
|
64
|
+
last_accessed = EXCLUDED.last_accessed`, [
|
|
65
|
+
story.id,
|
|
66
|
+
story.title,
|
|
67
|
+
story.description,
|
|
68
|
+
story.content,
|
|
69
|
+
story.prompt || null,
|
|
70
|
+
story.components || [],
|
|
71
|
+
story.createdAt || new Date(),
|
|
72
|
+
new Date()
|
|
73
|
+
]);
|
|
74
|
+
console.log(`✅ Stored story in PostgreSQL: ${story.id}`);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
client.release();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Retrieve a story by ID
|
|
82
|
+
*/
|
|
83
|
+
async getStory(id) {
|
|
84
|
+
await this.initialize();
|
|
85
|
+
const client = await this.pool.connect();
|
|
86
|
+
try {
|
|
87
|
+
// Update last_accessed and return the story
|
|
88
|
+
const result = await client.query(`UPDATE stories SET last_accessed = NOW()
|
|
89
|
+
WHERE id = $1
|
|
90
|
+
RETURNING id, title, description, content, prompt, components, created_at, last_accessed`, [id]);
|
|
91
|
+
if (result.rows.length === 0) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const row = result.rows[0];
|
|
95
|
+
return {
|
|
96
|
+
id: row.id,
|
|
97
|
+
title: row.title,
|
|
98
|
+
description: row.description,
|
|
99
|
+
content: row.content,
|
|
100
|
+
prompt: row.prompt,
|
|
101
|
+
components: row.components || [],
|
|
102
|
+
createdAt: new Date(row.created_at),
|
|
103
|
+
lastAccessed: new Date(row.last_accessed)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
client.release();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get all stored stories
|
|
112
|
+
*/
|
|
113
|
+
async getAllStories() {
|
|
114
|
+
await this.initialize();
|
|
115
|
+
const client = await this.pool.connect();
|
|
116
|
+
try {
|
|
117
|
+
const result = await client.query(`SELECT id, title, description, content, prompt, components, created_at, last_accessed
|
|
118
|
+
FROM stories
|
|
119
|
+
ORDER BY created_at DESC`);
|
|
120
|
+
return result.rows.map(row => ({
|
|
121
|
+
id: row.id,
|
|
122
|
+
title: row.title,
|
|
123
|
+
description: row.description,
|
|
124
|
+
content: row.content,
|
|
125
|
+
prompt: row.prompt,
|
|
126
|
+
components: row.components || [],
|
|
127
|
+
createdAt: new Date(row.created_at),
|
|
128
|
+
lastAccessed: new Date(row.last_accessed)
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
client.release();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Delete a story by ID
|
|
137
|
+
*/
|
|
138
|
+
async deleteStory(id) {
|
|
139
|
+
await this.initialize();
|
|
140
|
+
const client = await this.pool.connect();
|
|
141
|
+
try {
|
|
142
|
+
const result = await client.query(`DELETE FROM stories WHERE id = $1 RETURNING id`, [id]);
|
|
143
|
+
const deleted = result.rowCount !== null && result.rowCount > 0;
|
|
144
|
+
if (deleted) {
|
|
145
|
+
console.log(`✅ Deleted story from PostgreSQL: ${id}`);
|
|
146
|
+
}
|
|
147
|
+
return deleted;
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
client.release();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Clear all stories
|
|
155
|
+
*/
|
|
156
|
+
async clearAllStories() {
|
|
157
|
+
await this.initialize();
|
|
158
|
+
const client = await this.pool.connect();
|
|
159
|
+
try {
|
|
160
|
+
await client.query('TRUNCATE TABLE stories');
|
|
161
|
+
console.log('✅ Cleared all stories from PostgreSQL');
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
client.release();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get story content for Storybook integration
|
|
169
|
+
*/
|
|
170
|
+
async getStoryContent(id) {
|
|
171
|
+
const story = await this.getStory(id);
|
|
172
|
+
return story ? story.content : null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get story metadata for listing
|
|
176
|
+
*/
|
|
177
|
+
async getStoryMetadata() {
|
|
178
|
+
await this.initialize();
|
|
179
|
+
const client = await this.pool.connect();
|
|
180
|
+
try {
|
|
181
|
+
const result = await client.query(`SELECT id, title, description, content, created_at, last_accessed
|
|
182
|
+
FROM stories
|
|
183
|
+
ORDER BY created_at DESC`);
|
|
184
|
+
return result.rows.map(row => ({
|
|
185
|
+
id: row.id,
|
|
186
|
+
title: row.title,
|
|
187
|
+
description: row.description,
|
|
188
|
+
createdAt: new Date(row.created_at),
|
|
189
|
+
lastAccessed: new Date(row.last_accessed),
|
|
190
|
+
componentCount: this.countComponents(row.content)
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
client.release();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get storage usage statistics
|
|
199
|
+
*/
|
|
200
|
+
async getStorageStats() {
|
|
201
|
+
await this.initialize();
|
|
202
|
+
const client = await this.pool.connect();
|
|
203
|
+
try {
|
|
204
|
+
const result = await client.query(`
|
|
205
|
+
SELECT
|
|
206
|
+
COUNT(*)::int as story_count,
|
|
207
|
+
COALESCE(SUM(LENGTH(content)), 0)::bigint as total_size,
|
|
208
|
+
COALESCE(AVG(LENGTH(content)), 0)::int as avg_size,
|
|
209
|
+
MIN(created_at) as oldest,
|
|
210
|
+
MAX(created_at) as newest
|
|
211
|
+
FROM stories
|
|
212
|
+
`);
|
|
213
|
+
const row = result.rows[0];
|
|
214
|
+
return {
|
|
215
|
+
storyCount: row.story_count,
|
|
216
|
+
totalSizeBytes: parseInt(row.total_size) || 0,
|
|
217
|
+
averageSizeBytes: row.avg_size || 0,
|
|
218
|
+
oldestStory: row.oldest ? new Date(row.oldest) : null,
|
|
219
|
+
newestStory: row.newest ? new Date(row.newest) : null
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
client.release();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Count unique components in story content
|
|
228
|
+
*/
|
|
229
|
+
countComponents(content) {
|
|
230
|
+
const componentMatches = content.match(/<[A-Z][A-Za-z0-9]*\s/g);
|
|
231
|
+
return componentMatches ? new Set(componentMatches).size : 0;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Close the connection pool
|
|
235
|
+
*/
|
|
236
|
+
async close() {
|
|
237
|
+
await this.pool.end();
|
|
238
|
+
console.log('PostgreSQL connection pool closed');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { StoryUIConfig } from '../story-ui.config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Production-ready gitignore manager that handles both development and server environments
|
|
4
|
+
*/
|
|
5
|
+
export declare class ProductionGitignoreManager {
|
|
6
|
+
private config;
|
|
7
|
+
private projectRoot;
|
|
8
|
+
private isProduction;
|
|
9
|
+
constructor(config: StoryUIConfig, projectRoot?: string);
|
|
10
|
+
/**
|
|
11
|
+
* Detects if we're running in a production/read-only environment
|
|
12
|
+
*/
|
|
13
|
+
private detectProductionEnvironment;
|
|
14
|
+
/**
|
|
15
|
+
* Tests if we can write to the project root
|
|
16
|
+
*/
|
|
17
|
+
private canWriteToProjectRoot;
|
|
18
|
+
/**
|
|
19
|
+
* Main setup method that adapts to environment
|
|
20
|
+
*/
|
|
21
|
+
setupGitignoreIntegration(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Production environment: Use in-memory story generation
|
|
24
|
+
*/
|
|
25
|
+
private handleProductionEnvironment;
|
|
26
|
+
/**
|
|
27
|
+
* Development environment: Full gitignore management
|
|
28
|
+
*/
|
|
29
|
+
private handleDevelopmentEnvironment;
|
|
30
|
+
/**
|
|
31
|
+
* Validates that production environment is properly configured
|
|
32
|
+
*/
|
|
33
|
+
private validateProductionSetup;
|
|
34
|
+
/**
|
|
35
|
+
* Sets up temporary directory for production story generation
|
|
36
|
+
*/
|
|
37
|
+
private setupTemporaryDirectory;
|
|
38
|
+
/**
|
|
39
|
+
* Gets a writable temporary directory for production
|
|
40
|
+
*/
|
|
41
|
+
getProductionTempDirectory(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Creates the generated directory if it doesn't exist (development only)
|
|
44
|
+
*/
|
|
45
|
+
private ensureGeneratedDirectoryExists;
|
|
46
|
+
/**
|
|
47
|
+
* Ensures the generated stories directory is added to .gitignore (development only)
|
|
48
|
+
*/
|
|
49
|
+
private ensureGeneratedDirectoryIgnored;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the relative path from project root to generated stories directory
|
|
52
|
+
*/
|
|
53
|
+
private getRelativeGeneratedPath;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new .gitignore file with Story UI section
|
|
56
|
+
*/
|
|
57
|
+
private createGitignore;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the generated path is already ignored
|
|
60
|
+
*/
|
|
61
|
+
private isPathIgnored;
|
|
62
|
+
/**
|
|
63
|
+
* Adds ignore rule to existing .gitignore
|
|
64
|
+
*/
|
|
65
|
+
private addIgnoreRule;
|
|
66
|
+
/**
|
|
67
|
+
* Generates the gitignore section for Story UI
|
|
68
|
+
*/
|
|
69
|
+
private generateGitignoreSection;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a README in the generated directory explaining its purpose (development only)
|
|
72
|
+
*/
|
|
73
|
+
private createGeneratedDirectoryReadme;
|
|
74
|
+
/**
|
|
75
|
+
* Cleans up old generated stories (safe for both environments)
|
|
76
|
+
*/
|
|
77
|
+
cleanupOldStories(maxAge?: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the appropriate directory for story generation based on environment
|
|
80
|
+
*/
|
|
81
|
+
getStoryGenerationPath(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if we're in production mode
|
|
84
|
+
*/
|
|
85
|
+
isProductionMode(): boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Convenience function to set up gitignore for Story UI (production-ready)
|
|
89
|
+
*/
|
|
90
|
+
export declare function setupProductionGitignore(config: StoryUIConfig, projectRoot?: string): ProductionGitignoreManager;
|
|
91
|
+
//# sourceMappingURL=productionGitignoreManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productionGitignoreManager.d.ts","sourceRoot":"","sources":["../../story-generator/productionGitignoreManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAU;gBAElB,MAAM,EAAE,aAAa,EAAE,WAAW,GAAE,MAAsB;IAMtE;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAuBnC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAW7B;;OAEG;IACH,yBAAyB,IAAI,IAAI;IAQjC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAUnC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAQpC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAmB/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAY/B;;OAEG;IACH,0BAA0B,IAAI,MAAM;IAuBpC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAStC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IA0BvC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAmBhC;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAOhC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAyCtC;;OAEG;IACH,iBAAiB,CAAC,MAAM,GAAE,MAAgC,GAAG,IAAI;IAoCjE;;OAEG;IACH,sBAAsB,IAAI,MAAM;IAYhC;;OAEG;IACH,gBAAgB,IAAI,OAAO;CAG5B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,0BAA0B,CAIhH"}
|