@bubblelab/bubble-core 0.1.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/LICENSE.txt +202 -0
- package/dist/bubble-bundle.d.ts +2021 -0
- package/dist/bubble-factory.d.ts +161 -0
- package/dist/bubble-factory.d.ts.map +1 -0
- package/dist/bubble-factory.js +426 -0
- package/dist/bubble-factory.js.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts +19 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.js +23 -0
- package/dist/bubble-flow/bubble-flow-class.js.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts +15 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js +63 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js.map +1 -0
- package/dist/bubble-flow/sample/error-ts.d.ts +23 -0
- package/dist/bubble-flow/sample/error-ts.d.ts.map +1 -0
- package/dist/bubble-flow/sample/error-ts.js +31 -0
- package/dist/bubble-flow/sample/error-ts.js.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts +10 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.js +13 -0
- package/dist/bubble-flow/sample/sanitytest.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts +19 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js +23 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts +10 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.js +18 -0
- package/dist/bubble-flow/sample/simple-webhook.js.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts +29 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js +150 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts +10 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.js +59 -0
- package/dist/bubble-flow/sample/slack-v0.1.js.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts +10 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.js +59 -0
- package/dist/bubble-flow/sample/slackagenttest.js.map +1 -0
- package/dist/bubble-trigger/index.d.ts +2 -0
- package/dist/bubble-trigger/index.d.ts.map +1 -0
- package/dist/bubble-trigger/index.js +2 -0
- package/dist/bubble-trigger/index.js.map +1 -0
- package/dist/bubble-trigger/types.d.ts +87 -0
- package/dist/bubble-trigger/types.d.ts.map +1 -0
- package/dist/bubble-trigger/types.js +14 -0
- package/dist/bubble-trigger/types.js.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts +428 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.js +881 -0
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -0
- package/dist/bubbles/service-bubble/gmail.d.ts +3073 -0
- package/dist/bubbles/service-bubble/gmail.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/gmail.js +908 -0
- package/dist/bubbles/service-bubble/gmail.js.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts +3377 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.js +527 -0
- package/dist/bubbles/service-bubble/google-calendar.js.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts +1152 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.js +943 -0
- package/dist/bubbles/service-bubble/google-drive.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts +1811 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.js +904 -0
- package/dist/bubbles/service-bubble/google-sheets.js.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts +74 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.js +67 -0
- package/dist/bubbles/service-bubble/hello-world.js.map +1 -0
- package/dist/bubbles/service-bubble/http.d.ts +134 -0
- package/dist/bubbles/service-bubble/http.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/http.js +184 -0
- package/dist/bubbles/service-bubble/http.js.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts +180 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.js +448 -0
- package/dist/bubbles/service-bubble/postgresql.js.map +1 -0
- package/dist/bubbles/service-bubble/resend.d.ts +301 -0
- package/dist/bubbles/service-bubble/resend.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/resend.js +253 -0
- package/dist/bubbles/service-bubble/resend.js.map +1 -0
- package/dist/bubbles/service-bubble/slack.d.ts +5869 -0
- package/dist/bubbles/service-bubble/slack.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/slack.js +1536 -0
- package/dist/bubbles/service-bubble/slack.js.map +1 -0
- package/dist/bubbles/service-bubble/storage.d.ts +571 -0
- package/dist/bubbles/service-bubble/storage.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/storage.js +504 -0
- package/dist/bubbles/service-bubble/storage.js.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +308 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js +285 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +416 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js +570 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +99 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +645 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +112 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js +82 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +413 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js +327 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +122 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js +343 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +131 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js +147 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts +257 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.js +238 -0
- package/dist/bubbles/tool-bubble/tool-template.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts +8 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js +65 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts +125 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js +169 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +218 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js +255 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js +175 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +228 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js +214 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js +155 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +114 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +777 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts +97 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js +327 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +303 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js +297 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts +157 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js +310 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +543 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js +628 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +679 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js +604 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +1011 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js +841 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +883 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +781 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +300 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js +508 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +731 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js +690 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +401 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js +382 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts +144 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js +124 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/BubbleLogger.d.ts +146 -0
- package/dist/logging/BubbleLogger.d.ts.map +1 -0
- package/dist/logging/BubbleLogger.js +472 -0
- package/dist/logging/BubbleLogger.js.map +1 -0
- package/dist/logging/StreamingBubbleLogger.d.ts +85 -0
- package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -0
- package/dist/logging/StreamingBubbleLogger.js +340 -0
- package/dist/logging/StreamingBubbleLogger.js.map +1 -0
- package/dist/types/ai-models.d.ts +4 -0
- package/dist/types/ai-models.d.ts.map +1 -0
- package/dist/types/ai-models.js +14 -0
- package/dist/types/ai-models.js.map +1 -0
- package/dist/types/available-tools.d.ts +4 -0
- package/dist/types/available-tools.d.ts.map +1 -0
- package/dist/types/available-tools.js +19 -0
- package/dist/types/available-tools.js.map +1 -0
- package/dist/types/base-bubble-class.d.ts +47 -0
- package/dist/types/base-bubble-class.d.ts.map +1 -0
- package/dist/types/base-bubble-class.js +212 -0
- package/dist/types/base-bubble-class.js.map +1 -0
- package/dist/types/bubble-errors.d.ts +44 -0
- package/dist/types/bubble-errors.d.ts.map +1 -0
- package/dist/types/bubble-errors.js +51 -0
- package/dist/types/bubble-errors.js.map +1 -0
- package/dist/types/bubble.d.ts +73 -0
- package/dist/types/bubble.d.ts.map +1 -0
- package/dist/types/bubble.js +2 -0
- package/dist/types/bubble.js.map +1 -0
- package/dist/types/credentials.d.ts +6 -0
- package/dist/types/credentials.d.ts.map +1 -0
- package/dist/types/credentials.js +6 -0
- package/dist/types/credentials.js.map +1 -0
- package/dist/types/service-bubble-class.d.ts +31 -0
- package/dist/types/service-bubble-class.d.ts.map +1 -0
- package/dist/types/service-bubble-class.js +36 -0
- package/dist/types/service-bubble-class.js.map +1 -0
- package/dist/types/streaming-events.d.ts +18 -0
- package/dist/types/streaming-events.d.ts.map +1 -0
- package/dist/types/streaming-events.js +5 -0
- package/dist/types/streaming-events.js.map +1 -0
- package/dist/types/tool-bubble-class.d.ts +19 -0
- package/dist/types/tool-bubble-class.d.ts.map +1 -0
- package/dist/types/tool-bubble-class.js +48 -0
- package/dist/types/tool-bubble-class.js.map +1 -0
- package/dist/types/workflow-bubble-class.d.ts +25 -0
- package/dist/types/workflow-bubble-class.d.ts.map +1 -0
- package/dist/types/workflow-bubble-class.js +30 -0
- package/dist/types/workflow-bubble-class.js.map +1 -0
- package/dist/utils/bubbleflow-parser.d.ts +32 -0
- package/dist/utils/bubbleflow-parser.d.ts.map +1 -0
- package/dist/utils/bubbleflow-parser.js +332 -0
- package/dist/utils/bubbleflow-parser.js.map +1 -0
- package/dist/utils/bubbleflow-validation.d.ts +9 -0
- package/dist/utils/bubbleflow-validation.d.ts.map +1 -0
- package/dist/utils/bubbleflow-validation.js +116 -0
- package/dist/utils/bubbleflow-validation.js.map +1 -0
- package/dist/utils/json-parsing.d.ts +20 -0
- package/dist/utils/json-parsing.d.ts.map +1 -0
- package/dist/utils/json-parsing.js +394 -0
- package/dist/utils/json-parsing.js.map +1 -0
- package/dist/utils/mock-data-generator.d.ts +43 -0
- package/dist/utils/mock-data-generator.d.ts.map +1 -0
- package/dist/utils/mock-data-generator.js +312 -0
- package/dist/utils/mock-data-generator.js.map +1 -0
- package/dist/utils/param-helper.d.ts +2 -0
- package/dist/utils/param-helper.d.ts.map +1 -0
- package/dist/utils/param-helper.js +5 -0
- package/dist/utils/param-helper.js.map +1 -0
- package/dist/utils/source-bubble-parser.d.ts +31 -0
- package/dist/utils/source-bubble-parser.d.ts.map +1 -0
- package/dist/utils/source-bubble-parser.js +231 -0
- package/dist/utils/source-bubble-parser.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATE DOCUMENT WORKFLOW
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive workflow that converts markdown documents into structured formats
|
|
5
|
+
* like HTML tables, CSV, or Excel files. Uses AI analysis to extract and organize
|
|
6
|
+
* data from unstructured markdown text into tabular formats.
|
|
7
|
+
*
|
|
8
|
+
* This workflow combines:
|
|
9
|
+
* 1. AI agent analysis for data extraction from markdown documents
|
|
10
|
+
* 2. JSON schema generation for structured data representation
|
|
11
|
+
* 3. Format conversion to HTML, CSV, or Excel
|
|
12
|
+
*
|
|
13
|
+
* Returns structured data and downloadable files in the requested format.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { WorkflowBubble } from '../../types/workflow-bubble-class.js';
|
|
17
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
18
|
+
import { AIAgentBubble } from '../service-bubble/ai-agent.js';
|
|
19
|
+
import { AvailableModels } from '../../types/ai-models.js';
|
|
20
|
+
/**
|
|
21
|
+
* System prompt for document analysis and data extraction
|
|
22
|
+
*/
|
|
23
|
+
const DOCUMENT_ANALYSIS_PROMPT = `You are an expert document analysis and data extraction specialist. Your task is to analyze markdown documents and extract structured data based on user requirements.
|
|
24
|
+
|
|
25
|
+
IMPORTANT CONTEXT:
|
|
26
|
+
- Current date: ${new Date().toISOString().split('T')[0]} (YYYY-MM-DD format)
|
|
27
|
+
- Current year: ${new Date().getFullYear()}
|
|
28
|
+
- When interpreting dates, assume they are from recent years (2020s) unless explicitly stated otherwise
|
|
29
|
+
- Use proper 4-digit years (e.g., 2024, 2025) not abbreviated years (e.g., 24, 25)
|
|
30
|
+
|
|
31
|
+
Your process:
|
|
32
|
+
1. Read and understand the provided markdown documents
|
|
33
|
+
2. Identify data points that match the user's output requirements
|
|
34
|
+
3. Extract relevant information and organize it into rows and columns
|
|
35
|
+
4. For each extracted row, ALWAYS include which source document it came from
|
|
36
|
+
5. Generate a consistent JSON structure with the extracted data
|
|
37
|
+
|
|
38
|
+
Guidelines:
|
|
39
|
+
- Each row should represent one logical entity (e.g., expense, invoice, person, etc.)
|
|
40
|
+
- Column names should be descriptive and consistent
|
|
41
|
+
- ALWAYS include a "source_document_index" column indicating which page/document section each row was extracted from (use page numbers from the document headers)
|
|
42
|
+
- Handle variations in data format gracefully
|
|
43
|
+
- If data is missing, use empty strings rather than omitting fields
|
|
44
|
+
- Maintain data relationships and context where possible
|
|
45
|
+
- Be precise with data types (numbers, dates, text)
|
|
46
|
+
- For dates, always use YYYY-MM-DD format and assume recent years (2020s) unless context suggests otherwise
|
|
47
|
+
|
|
48
|
+
Return format: JSON object with:
|
|
49
|
+
- columns: Array of column definitions with name, type, and description
|
|
50
|
+
- rows: Array of data rows matching the column structure
|
|
51
|
+
- metadata: Summary information about the extraction
|
|
52
|
+
|
|
53
|
+
CRITICAL TYPE REQUIREMENTS:
|
|
54
|
+
- Column "type" field MUST be one of: "string", "number", "integer", "float", "date", "boolean"
|
|
55
|
+
- Row values MUST be primitives: string, number, boolean, or null (never objects or arrays)
|
|
56
|
+
- Date values should be strings in YYYY-MM-DD format
|
|
57
|
+
- Boolean values should be true/false, not "true"/"false" strings
|
|
58
|
+
- Numeric values should be actual numbers, not quoted strings
|
|
59
|
+
|
|
60
|
+
Example output format:
|
|
61
|
+
{
|
|
62
|
+
"columns": [
|
|
63
|
+
{"name": "vendor", "type": "string", "description": "Company or person paid"},
|
|
64
|
+
{"name": "amount", "type": "number", "description": "Payment amount in dollars"},
|
|
65
|
+
{"name": "date", "type": "date", "description": "Transaction date"},
|
|
66
|
+
{"name": "is_recurring", "type": "boolean", "description": "Whether this is a recurring expense"},
|
|
67
|
+
{"name": "source_document_index", "type": "number", "description": "Source document index"}
|
|
68
|
+
],
|
|
69
|
+
"rows": [
|
|
70
|
+
{"vendor": "Office Supplies Inc", "amount": 156.78, "date": "2024-01-15", "is_recurring": false, "source_document_index": 0},
|
|
71
|
+
{"vendor": "Monthly Software", "amount": 99.99, "date": "2024-01-01", "is_recurring": true, "source_document_index": 1}
|
|
72
|
+
],
|
|
73
|
+
"metadata": {
|
|
74
|
+
"extractedCount": 2,
|
|
75
|
+
"confidence": 0.95
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Focus on accuracy and consistency in data extraction while following the user's specific requirements for the output structure.`;
|
|
80
|
+
/**
|
|
81
|
+
* Parameters schema for Generate Document workflow
|
|
82
|
+
*/
|
|
83
|
+
const GenerateDocumentWorkflowParamsSchema = z.object({
|
|
84
|
+
documents: z
|
|
85
|
+
.array(z.object({
|
|
86
|
+
content: z.string().min(1, 'Document content cannot be empty'),
|
|
87
|
+
index: z.number().min(0, 'Document index must be non-negative'),
|
|
88
|
+
metadata: z
|
|
89
|
+
.object({
|
|
90
|
+
originalFilename: z.string().optional(),
|
|
91
|
+
pageCount: z.number().optional(),
|
|
92
|
+
uploadedImages: z
|
|
93
|
+
.array(z.object({
|
|
94
|
+
pageNumber: z.number(),
|
|
95
|
+
fileName: z.string(),
|
|
96
|
+
fileUrl: z.string().optional(),
|
|
97
|
+
}))
|
|
98
|
+
.optional(),
|
|
99
|
+
})
|
|
100
|
+
.optional(),
|
|
101
|
+
}))
|
|
102
|
+
.min(1, 'At least one document is required')
|
|
103
|
+
.describe('Array of document objects with content, index, and metadata'),
|
|
104
|
+
outputDescription: z
|
|
105
|
+
.string()
|
|
106
|
+
.min(10, 'Output description must be at least 10 characters')
|
|
107
|
+
.describe('Description of what the user wants to extract (e.g., "expense tracking with vendor, amount, date, category")'),
|
|
108
|
+
outputFormat: z
|
|
109
|
+
.enum(['html', 'csv', 'json'])
|
|
110
|
+
.default('html')
|
|
111
|
+
.describe('Output format for the structured data'),
|
|
112
|
+
aiOptions: z
|
|
113
|
+
.object({
|
|
114
|
+
model: AvailableModels.default('google/gemini-2.5-flash').describe('AI model to use for document analysis'),
|
|
115
|
+
temperature: z
|
|
116
|
+
.number()
|
|
117
|
+
.min(0)
|
|
118
|
+
.max(2)
|
|
119
|
+
.default(0.1)
|
|
120
|
+
.describe('Temperature for AI responses (lower = more consistent)'),
|
|
121
|
+
maxTokens: z
|
|
122
|
+
.number()
|
|
123
|
+
.positive()
|
|
124
|
+
.default(50000)
|
|
125
|
+
.describe('Maximum tokens for AI response'),
|
|
126
|
+
jsonMode: z
|
|
127
|
+
.boolean()
|
|
128
|
+
.default(true)
|
|
129
|
+
.describe('Enable JSON mode to ensure clean JSON output'),
|
|
130
|
+
})
|
|
131
|
+
.default({
|
|
132
|
+
model: 'google/gemini-2.5-flash',
|
|
133
|
+
temperature: 0.1,
|
|
134
|
+
maxTokens: 50000,
|
|
135
|
+
jsonMode: true,
|
|
136
|
+
})
|
|
137
|
+
.describe('AI agent configuration options'),
|
|
138
|
+
credentials: z
|
|
139
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('Credentials for AI model access (GOOGLE_GEMINI_CRED, OPENAI_CRED, etc.)'),
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* Result schema for Generate Document workflow
|
|
145
|
+
*/
|
|
146
|
+
const GenerateDocumentWorkflowResultSchema = z.object({
|
|
147
|
+
columns: z
|
|
148
|
+
.array(z.object({
|
|
149
|
+
name: z.string().describe('Column name'),
|
|
150
|
+
type: z
|
|
151
|
+
.enum(['string', 'number', 'integer', 'float', 'date', 'boolean'])
|
|
152
|
+
.describe('Data type of the column'),
|
|
153
|
+
description: z
|
|
154
|
+
.string()
|
|
155
|
+
.describe('Description of what this column contains'),
|
|
156
|
+
}))
|
|
157
|
+
.describe('Column definitions for the structured data'),
|
|
158
|
+
rows: z
|
|
159
|
+
.array(z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])))
|
|
160
|
+
.describe('Array of data rows extracted from documents'),
|
|
161
|
+
metadata: z
|
|
162
|
+
.object({
|
|
163
|
+
totalDocuments: z.number().describe('Number of documents processed'),
|
|
164
|
+
totalRows: z.number().describe('Number of data rows extracted'),
|
|
165
|
+
totalColumns: z.number().describe('Number of columns in the result'),
|
|
166
|
+
processingTime: z.number().describe('Processing time in milliseconds'),
|
|
167
|
+
extractedFrom: z
|
|
168
|
+
.array(z.string())
|
|
169
|
+
.describe('Summary of document sources'),
|
|
170
|
+
})
|
|
171
|
+
.describe('Metadata about the extraction process'),
|
|
172
|
+
generatedFiles: z
|
|
173
|
+
.object({
|
|
174
|
+
html: z.string().optional().describe('Generated HTML table'),
|
|
175
|
+
csv: z.string().optional().describe('Generated CSV data'),
|
|
176
|
+
json: z.string().optional().describe('Generated JSON data'),
|
|
177
|
+
})
|
|
178
|
+
.describe('Generated files in requested formats'),
|
|
179
|
+
aiAnalysis: z
|
|
180
|
+
.object({
|
|
181
|
+
model: z.string().describe('AI model used'),
|
|
182
|
+
iterations: z.number().describe('Number of AI iterations'),
|
|
183
|
+
processingTime: z.number().optional().describe('AI processing time'),
|
|
184
|
+
})
|
|
185
|
+
.describe('AI analysis metadata'),
|
|
186
|
+
success: z.boolean().describe('Whether the workflow completed successfully'),
|
|
187
|
+
error: z.string().describe('Error message if workflow failed'),
|
|
188
|
+
});
|
|
189
|
+
/**
|
|
190
|
+
* Generate Document Workflow
|
|
191
|
+
* Converts markdown documents into structured formats using AI analysis
|
|
192
|
+
*/
|
|
193
|
+
export class GenerateDocumentWorkflow extends WorkflowBubble {
|
|
194
|
+
static type = 'workflow';
|
|
195
|
+
static bubbleName = 'generate-document-workflow';
|
|
196
|
+
static schema = GenerateDocumentWorkflowParamsSchema;
|
|
197
|
+
static resultSchema = GenerateDocumentWorkflowResultSchema;
|
|
198
|
+
static shortDescription = 'Generate Document workflow: convert markdown to structured formats using AI';
|
|
199
|
+
static longDescription = `
|
|
200
|
+
Comprehensive document generation workflow that transforms unstructured markdown content into structured data formats:
|
|
201
|
+
|
|
202
|
+
**Process:**
|
|
203
|
+
1. Analyze markdown documents using AI to understand content and structure
|
|
204
|
+
2. Extract data points based on user requirements and output description
|
|
205
|
+
3. Generate consistent column definitions and data rows
|
|
206
|
+
4. Convert to requested format (HTML table, CSV, JSON)
|
|
207
|
+
|
|
208
|
+
**Features:**
|
|
209
|
+
- Multi-document processing with content consolidation
|
|
210
|
+
- AI-powered data extraction and structuring
|
|
211
|
+
- Flexible output format support (HTML, CSV, JSON)
|
|
212
|
+
- Configurable AI model selection and parameters
|
|
213
|
+
- Comprehensive metadata and analysis tracking
|
|
214
|
+
- Error handling and validation
|
|
215
|
+
|
|
216
|
+
**Common Use Cases:**
|
|
217
|
+
- **Expense Management**: Extract vendor, amount, date, category from receipts
|
|
218
|
+
- **Invoice Processing**: Structure billing information into tables
|
|
219
|
+
- **Contact Lists**: Organize people and contact information
|
|
220
|
+
- **Inventory Management**: Extract product details and quantities
|
|
221
|
+
- **Research Data**: Structure findings and references
|
|
222
|
+
|
|
223
|
+
**Input**: Array of markdown documents + output requirements description
|
|
224
|
+
**Output**: Structured data in requested format with metadata and analysis
|
|
225
|
+
`;
|
|
226
|
+
static alias = 'generate-doc';
|
|
227
|
+
constructor(params, context) {
|
|
228
|
+
super(params, context);
|
|
229
|
+
}
|
|
230
|
+
async performAction() {
|
|
231
|
+
const startTime = Date.now();
|
|
232
|
+
console.log('[GenerateDocumentWorkflow] Starting document analysis and generation');
|
|
233
|
+
console.log('[GenerateDocumentWorkflow] Processing', this.params.documents.length, 'documents');
|
|
234
|
+
console.log('[GenerateDocumentWorkflow] Output format:', this.params.outputFormat);
|
|
235
|
+
console.log('[GenerateDocumentWorkflow] Full params:', JSON.stringify(this.params, null, 2));
|
|
236
|
+
try {
|
|
237
|
+
// Step 1: Prepare documents for AI analysis
|
|
238
|
+
console.log('[GenerateDocumentWorkflow] Step 1: Preparing documents for analysis...');
|
|
239
|
+
// Renumber pages sequentially across all documents
|
|
240
|
+
let globalPageNumber = 1;
|
|
241
|
+
const documentsContext = this.params.documents
|
|
242
|
+
.map((doc) => {
|
|
243
|
+
// Replace page headers with sequential numbering
|
|
244
|
+
let processedContent = doc.content;
|
|
245
|
+
// Debug: log original content
|
|
246
|
+
console.log(`[DEBUG] Document ${doc.index} original pages:`, processedContent.match(/--- Page \d+ ---/g));
|
|
247
|
+
// Better approach: replace with placeholders first, then replace placeholders with sequential numbers
|
|
248
|
+
const pageHeaders = processedContent.match(/--- Page \d+ ---/g) || [];
|
|
249
|
+
// Step 1: Replace all page headers with unique placeholders
|
|
250
|
+
for (let i = 0; i < pageHeaders.length; i++) {
|
|
251
|
+
processedContent = processedContent.replace(/--- Page \d+ ---/, `###PLACEHOLDER_${i}###`);
|
|
252
|
+
}
|
|
253
|
+
// Step 2: Replace placeholders with sequential page numbers
|
|
254
|
+
for (let i = 0; i < pageHeaders.length; i++) {
|
|
255
|
+
processedContent = processedContent.replace(`###PLACEHOLDER_${i}###`, `--- Page ${globalPageNumber} ---`);
|
|
256
|
+
console.log(`[DEBUG] Set placeholder ${i} to Page ${globalPageNumber}`);
|
|
257
|
+
globalPageNumber++;
|
|
258
|
+
}
|
|
259
|
+
// Debug: log final content
|
|
260
|
+
console.log(`[DEBUG] Document ${doc.index} final pages:`, processedContent.match(/--- Page \d+ ---/g));
|
|
261
|
+
// If no page headers found, treat entire document as one page
|
|
262
|
+
if (pageHeaders.length === 0) {
|
|
263
|
+
processedContent = `--- Page ${globalPageNumber} ---\n\n${processedContent}`;
|
|
264
|
+
globalPageNumber++;
|
|
265
|
+
}
|
|
266
|
+
return `\n\n--- Document ${doc.index} ---\n${processedContent}`;
|
|
267
|
+
})
|
|
268
|
+
.join('\n');
|
|
269
|
+
console.log(`[GenerateDocumentWorkflow] Renumbered pages sequentially: 1 to ${globalPageNumber - 1}`);
|
|
270
|
+
console.log('[FINAL DOCUMENTS CONTEXT]:');
|
|
271
|
+
console.log(documentsContext);
|
|
272
|
+
const enhancedPrompt = DOCUMENT_ANALYSIS_PROMPT +
|
|
273
|
+
`
|
|
274
|
+
|
|
275
|
+
Documents to analyze:
|
|
276
|
+
${documentsContext}
|
|
277
|
+
|
|
278
|
+
User requirements:
|
|
279
|
+
${this.params.outputDescription}
|
|
280
|
+
|
|
281
|
+
CRITICAL: For the source_document_index column, you MUST use ONLY THE NUMERIC PAGE NUMBER from the "--- Page X ---" headers in the documents above.
|
|
282
|
+
- Look for "--- Page 1 ---", "--- Page 2 ---", etc. headers
|
|
283
|
+
- Extract ONLY the number (1, 2, 3, etc.) as the source_document_index value
|
|
284
|
+
- DO NOT include the word "Page" - use only the numeric value
|
|
285
|
+
|
|
286
|
+
Please extract structured data that matches the user's requirements. Return a JSON object with:
|
|
287
|
+
- columns: Array of {name, type, description} for each data field (MUST include source_document_index column)
|
|
288
|
+
- rows: Array of objects with data extracted from the documents (each row MUST include the correct page number as source_document_index)
|
|
289
|
+
- metadata: Summary information about the extraction
|
|
290
|
+
|
|
291
|
+
EXAMPLE: If data is extracted from "--- Page 2 ---", then source_document_index should be 2 (number), not "Page 2" (string) or 0.
|
|
292
|
+
|
|
293
|
+
Be thorough but precise in your extraction.`;
|
|
294
|
+
// Step 2: AI analysis
|
|
295
|
+
console.log('[GenerateDocumentWorkflow] Step 2: Performing AI analysis...');
|
|
296
|
+
const aiAgent = new AIAgentBubble({
|
|
297
|
+
message: `Please analyze the provided markdown documents and extract structured data according to the user's requirements.
|
|
298
|
+
|
|
299
|
+
Focus on:
|
|
300
|
+
1. Identifying data points that match the output description
|
|
301
|
+
2. Creating consistent column definitions with VALID types ("string", "number", "integer", "float", "date", "boolean")
|
|
302
|
+
3. Extracting all relevant data rows with PRIMITIVE values only (no objects or arrays)
|
|
303
|
+
4. Providing accurate metadata
|
|
304
|
+
|
|
305
|
+
CRITICAL:
|
|
306
|
+
- Column types must be exact strings: "string", "number", "integer", "float", "date", "boolean"
|
|
307
|
+
- Row values must be primitives: actual numbers (not "123"), booleans (not "true"), dates as strings ("2024-01-15"), or null
|
|
308
|
+
- Never use objects, arrays, or complex types in row data
|
|
309
|
+
|
|
310
|
+
Return only the JSON object as specified in the system prompt, no additional text.`,
|
|
311
|
+
systemPrompt: enhancedPrompt,
|
|
312
|
+
model: {
|
|
313
|
+
model: this.params.aiOptions?.model || 'google/gemini-2.5-flash',
|
|
314
|
+
temperature: this.params.aiOptions?.temperature || 0.1,
|
|
315
|
+
maxTokens: this.params.aiOptions?.maxTokens || 50000,
|
|
316
|
+
jsonMode: this.params.aiOptions?.jsonMode ?? true,
|
|
317
|
+
},
|
|
318
|
+
credentials: this.params.credentials,
|
|
319
|
+
tools: [], // No tools needed for this analysis
|
|
320
|
+
maxIterations: 3,
|
|
321
|
+
}, this.context);
|
|
322
|
+
const aiResult = await aiAgent.action();
|
|
323
|
+
if (!aiResult.success) {
|
|
324
|
+
throw new Error(`AI analysis failed: ${aiResult.error}`);
|
|
325
|
+
}
|
|
326
|
+
console.log('[GenerateDocumentWorkflow] AI analysis completed');
|
|
327
|
+
// Step 3: Parse AI response and structure results
|
|
328
|
+
console.log('[GenerateDocumentWorkflow] Step 3: Processing AI results...');
|
|
329
|
+
let extractedData;
|
|
330
|
+
try {
|
|
331
|
+
const aiResponse = aiResult.data?.response || '{}';
|
|
332
|
+
const parsedData = JSON.parse(aiResponse);
|
|
333
|
+
extractedData = {
|
|
334
|
+
columns: parsedData.columns || [],
|
|
335
|
+
rows: parsedData.rows || [],
|
|
336
|
+
metadata: parsedData.metadata || {},
|
|
337
|
+
};
|
|
338
|
+
// Post-process to ensure source_document_index values are numeric
|
|
339
|
+
if (extractedData.rows && Array.isArray(extractedData.rows)) {
|
|
340
|
+
console.log('[GenerateDocumentWorkflow] Raw source_document_index values before processing:', extractedData.rows.map((row) => row.source_document_index));
|
|
341
|
+
extractedData.rows = extractedData.rows.map((row) => {
|
|
342
|
+
if (row.source_document_index !== undefined) {
|
|
343
|
+
const originalValue = row.source_document_index;
|
|
344
|
+
// Extract numeric value from strings like "Page 1", "1", etc.
|
|
345
|
+
let numericIndex = row.source_document_index;
|
|
346
|
+
if (typeof numericIndex === 'string') {
|
|
347
|
+
const match = numericIndex.match(/\d+/);
|
|
348
|
+
numericIndex = match ? parseInt(match[0], 10) : numericIndex;
|
|
349
|
+
}
|
|
350
|
+
row.source_document_index = numericIndex;
|
|
351
|
+
if (originalValue !== numericIndex) {
|
|
352
|
+
console.log(`[GenerateDocumentWorkflow] Converted source_document_index from '${originalValue}' to ${numericIndex}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return row;
|
|
356
|
+
});
|
|
357
|
+
console.log('[GenerateDocumentWorkflow] Final source_document_index values:', extractedData.rows.map((row) => row.source_document_index));
|
|
358
|
+
}
|
|
359
|
+
// Validate and normalize the extracted data
|
|
360
|
+
if (!Array.isArray(extractedData.columns) ||
|
|
361
|
+
extractedData.columns.length === 0) {
|
|
362
|
+
throw new Error('No valid columns extracted from documents');
|
|
363
|
+
}
|
|
364
|
+
if (!Array.isArray(extractedData.rows)) {
|
|
365
|
+
extractedData.rows = [];
|
|
366
|
+
}
|
|
367
|
+
// Normalize column types to ensure they match the schema
|
|
368
|
+
extractedData.columns = extractedData.columns.map((col) => ({
|
|
369
|
+
name: col.name || 'unknown',
|
|
370
|
+
type: this.normalizeColumnType(col.type),
|
|
371
|
+
description: col.description || '',
|
|
372
|
+
}));
|
|
373
|
+
// Normalize row data to ensure all values are primitives
|
|
374
|
+
extractedData.rows = extractedData.rows.map((row) => {
|
|
375
|
+
const normalizedRow = {};
|
|
376
|
+
for (const [key, value] of Object.entries(row)) {
|
|
377
|
+
normalizedRow[key] = this.normalizeRowValue(value);
|
|
378
|
+
}
|
|
379
|
+
return normalizedRow;
|
|
380
|
+
});
|
|
381
|
+
console.log(`[GenerateDocumentWorkflow] Extracted ${extractedData.columns.length} columns and ${extractedData.rows.length} rows`);
|
|
382
|
+
}
|
|
383
|
+
catch (parseError) {
|
|
384
|
+
console.error('[GenerateDocumentWorkflow] Failed to parse AI response:', parseError);
|
|
385
|
+
throw new Error('Failed to parse AI analysis results');
|
|
386
|
+
}
|
|
387
|
+
// Step 4: Generate output files
|
|
388
|
+
console.log('[GenerateDocumentWorkflow] Step 4: Generating output files...');
|
|
389
|
+
const generatedFiles = {};
|
|
390
|
+
// Generate JSON (always available)
|
|
391
|
+
generatedFiles.json = JSON.stringify({
|
|
392
|
+
columns: extractedData.columns,
|
|
393
|
+
rows: extractedData.rows,
|
|
394
|
+
}, null, 2);
|
|
395
|
+
// Generate CSV if requested
|
|
396
|
+
if (this.params.outputFormat === 'csv' ||
|
|
397
|
+
this.params.outputFormat === 'html') {
|
|
398
|
+
const csvContent = this.generateCSV(extractedData.columns, extractedData.rows);
|
|
399
|
+
generatedFiles.csv = csvContent;
|
|
400
|
+
}
|
|
401
|
+
// Generate HTML if requested
|
|
402
|
+
console.log('🔍 HTML Generation Check:', {
|
|
403
|
+
outputFormat: this.params.outputFormat,
|
|
404
|
+
isHtml: this.params.outputFormat === 'html',
|
|
405
|
+
typeof: typeof this.params.outputFormat,
|
|
406
|
+
stringified: JSON.stringify(this.params.outputFormat),
|
|
407
|
+
});
|
|
408
|
+
if (this.params.outputFormat === 'html') {
|
|
409
|
+
const htmlContent = this.generateHTML(extractedData.columns, extractedData.rows);
|
|
410
|
+
generatedFiles.html = htmlContent;
|
|
411
|
+
console.log('✅ HTML generated, length:', htmlContent.length);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
console.log('❌ HTML not generated - outputFormat mismatch');
|
|
415
|
+
}
|
|
416
|
+
const processingTime = Date.now() - startTime;
|
|
417
|
+
// Step 5: Compile final results
|
|
418
|
+
const finalMetadata = {
|
|
419
|
+
totalDocuments: this.params.documents.length,
|
|
420
|
+
totalRows: extractedData.rows.length,
|
|
421
|
+
totalColumns: extractedData.columns.length,
|
|
422
|
+
processingTime,
|
|
423
|
+
extractedFrom: this.params.documents.map((doc) => `Document ${doc.index}`),
|
|
424
|
+
...extractedData.metadata,
|
|
425
|
+
};
|
|
426
|
+
console.log(`[GenerateDocumentWorkflow] Workflow completed successfully in ${processingTime}ms`);
|
|
427
|
+
return {
|
|
428
|
+
columns: extractedData.columns,
|
|
429
|
+
rows: extractedData.rows,
|
|
430
|
+
metadata: finalMetadata,
|
|
431
|
+
generatedFiles,
|
|
432
|
+
aiAnalysis: {
|
|
433
|
+
model: this.params.aiOptions?.model || 'google/gemini-2.5-flash',
|
|
434
|
+
iterations: aiResult.data?.iterations || 0,
|
|
435
|
+
processingTime,
|
|
436
|
+
},
|
|
437
|
+
success: true,
|
|
438
|
+
error: '',
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
const processingTime = Date.now() - startTime;
|
|
443
|
+
console.error('[GenerateDocumentWorkflow] Workflow failed:', error);
|
|
444
|
+
return {
|
|
445
|
+
columns: [],
|
|
446
|
+
rows: [],
|
|
447
|
+
metadata: {
|
|
448
|
+
totalDocuments: this.params.documents.length,
|
|
449
|
+
totalRows: 0,
|
|
450
|
+
totalColumns: 0,
|
|
451
|
+
processingTime,
|
|
452
|
+
extractedFrom: [],
|
|
453
|
+
},
|
|
454
|
+
generatedFiles: {},
|
|
455
|
+
aiAnalysis: {
|
|
456
|
+
model: this.params.aiOptions?.model || 'google/gemini-2.5-flash',
|
|
457
|
+
iterations: 0,
|
|
458
|
+
processingTime,
|
|
459
|
+
},
|
|
460
|
+
success: false,
|
|
461
|
+
error: error instanceof Error
|
|
462
|
+
? error.message
|
|
463
|
+
: 'Unknown error during document generation workflow',
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Generate CSV content from columns and rows
|
|
469
|
+
*/
|
|
470
|
+
generateCSV(columns, rows) {
|
|
471
|
+
const headers = columns.map((col) => col.name).join(',');
|
|
472
|
+
const csvRows = rows.map((row) => columns
|
|
473
|
+
.map((col) => {
|
|
474
|
+
const value = row[col.name];
|
|
475
|
+
// Escape commas and quotes in CSV
|
|
476
|
+
if (typeof value === 'string' &&
|
|
477
|
+
(value.includes(',') || value.includes('"'))) {
|
|
478
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
479
|
+
}
|
|
480
|
+
return value?.toString() || '';
|
|
481
|
+
})
|
|
482
|
+
.join(','));
|
|
483
|
+
return [headers, ...csvRows].join('\n');
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Normalize column type to match schema expectations
|
|
487
|
+
*/
|
|
488
|
+
normalizeColumnType(type) {
|
|
489
|
+
if (typeof type === 'string') {
|
|
490
|
+
const normalizedType = type.toLowerCase();
|
|
491
|
+
if (['string', 'text', 'varchar'].includes(normalizedType))
|
|
492
|
+
return 'string';
|
|
493
|
+
if (['number', 'numeric', 'decimal'].includes(normalizedType))
|
|
494
|
+
return 'number';
|
|
495
|
+
if (['integer', 'int'].includes(normalizedType))
|
|
496
|
+
return 'integer';
|
|
497
|
+
if (['float', 'double', 'real'].includes(normalizedType))
|
|
498
|
+
return 'float';
|
|
499
|
+
if (['date', 'datetime', 'timestamp'].includes(normalizedType))
|
|
500
|
+
return 'date';
|
|
501
|
+
if (['boolean', 'bool'].includes(normalizedType))
|
|
502
|
+
return 'boolean';
|
|
503
|
+
}
|
|
504
|
+
// Default to string if type is unknown or invalid
|
|
505
|
+
return 'string';
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Normalize row value to ensure it's a primitive type
|
|
509
|
+
*/
|
|
510
|
+
normalizeRowValue(value) {
|
|
511
|
+
if (value === null || value === undefined) {
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
if (typeof value === 'string' ||
|
|
515
|
+
typeof value === 'number' ||
|
|
516
|
+
typeof value === 'boolean') {
|
|
517
|
+
return value;
|
|
518
|
+
}
|
|
519
|
+
if (typeof value === 'object' && value !== null) {
|
|
520
|
+
// Convert objects to JSON string
|
|
521
|
+
try {
|
|
522
|
+
return JSON.stringify(value);
|
|
523
|
+
}
|
|
524
|
+
catch {
|
|
525
|
+
return String(value);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
// Convert anything else to string
|
|
529
|
+
return String(value);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Generate HTML table from columns and rows
|
|
533
|
+
*/
|
|
534
|
+
generateHTML(columns, rows) {
|
|
535
|
+
const headers = columns
|
|
536
|
+
.map((col) => `<th title="${col.description}">${col.name}</th>`)
|
|
537
|
+
.join('');
|
|
538
|
+
const tableRows = rows
|
|
539
|
+
.map((row) => {
|
|
540
|
+
const cells = columns
|
|
541
|
+
.map((col) => {
|
|
542
|
+
const value = row[col.name];
|
|
543
|
+
const cellClass = col.type === 'number' ? 'text-right' : '';
|
|
544
|
+
return `<td class="${cellClass}">${value?.toString() || ''}</td>`;
|
|
545
|
+
})
|
|
546
|
+
.join('');
|
|
547
|
+
return `<tr>${cells}</tr>`;
|
|
548
|
+
})
|
|
549
|
+
.join('');
|
|
550
|
+
return `
|
|
551
|
+
<!DOCTYPE html>
|
|
552
|
+
<html lang="en">
|
|
553
|
+
<head>
|
|
554
|
+
<meta charset="UTF-8">
|
|
555
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
556
|
+
<title>Generated Document Data</title>
|
|
557
|
+
<style>
|
|
558
|
+
body {
|
|
559
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
560
|
+
margin: 20px;
|
|
561
|
+
background-color: #f5f5f5;
|
|
562
|
+
}
|
|
563
|
+
.container {
|
|
564
|
+
max-width: 1200px;
|
|
565
|
+
margin: 0 auto;
|
|
566
|
+
background: white;
|
|
567
|
+
padding: 20px;
|
|
568
|
+
border-radius: 8px;
|
|
569
|
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
570
|
+
}
|
|
571
|
+
h1 {
|
|
572
|
+
color: #333;
|
|
573
|
+
margin-bottom: 20px;
|
|
574
|
+
}
|
|
575
|
+
table {
|
|
576
|
+
width: 100%;
|
|
577
|
+
border-collapse: collapse;
|
|
578
|
+
margin-top: 20px;
|
|
579
|
+
}
|
|
580
|
+
th, td {
|
|
581
|
+
padding: 12px;
|
|
582
|
+
text-align: left;
|
|
583
|
+
border-bottom: 1px solid #ddd;
|
|
584
|
+
}
|
|
585
|
+
th {
|
|
586
|
+
background-color: #f8f9fa;
|
|
587
|
+
font-weight: 600;
|
|
588
|
+
color: #555;
|
|
589
|
+
cursor: help;
|
|
590
|
+
}
|
|
591
|
+
tr:hover {
|
|
592
|
+
background-color: #f8f9fa;
|
|
593
|
+
}
|
|
594
|
+
.text-right {
|
|
595
|
+
text-align: right;
|
|
596
|
+
}
|
|
597
|
+
.metadata {
|
|
598
|
+
margin-top: 20px;
|
|
599
|
+
padding: 15px;
|
|
600
|
+
background-color: #f8f9fa;
|
|
601
|
+
border-radius: 6px;
|
|
602
|
+
font-size: 14px;
|
|
603
|
+
color: #666;
|
|
604
|
+
}
|
|
605
|
+
</style>
|
|
606
|
+
</head>
|
|
607
|
+
<body>
|
|
608
|
+
<div class="container">
|
|
609
|
+
<h1>Generated Document Data</h1>
|
|
610
|
+
<table>
|
|
611
|
+
<thead>
|
|
612
|
+
<tr>${headers}</tr>
|
|
613
|
+
</thead>
|
|
614
|
+
<tbody>
|
|
615
|
+
${tableRows}
|
|
616
|
+
</tbody>
|
|
617
|
+
</table>
|
|
618
|
+
<div class="metadata">
|
|
619
|
+
<strong>Generated by Generate Document Workflow</strong> •
|
|
620
|
+
${rows.length} rows • ${columns.length} columns •
|
|
621
|
+
${new Date().toLocaleString()}
|
|
622
|
+
</div>
|
|
623
|
+
</div>
|
|
624
|
+
</body>
|
|
625
|
+
</html>`.trim();
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
//# sourceMappingURL=generate-document.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-document.workflow.js","sourceRoot":"","sources":["../../../src/bubbles/workflow-bubble/generate-document.workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAmB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,MAAM,wBAAwB,GAAG;;;kBAGf,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;kBACtC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gIAoDsF,CAAC;AA6BjI;;GAEG;AACH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