@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,180 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ServiceBubble } from '../../types/service-bubble-class.js';
|
|
3
|
+
import type { BubbleContext } from '../../types/bubble.js';
|
|
4
|
+
import { CredentialType, type DatabaseMetadata } from '@bubblelab/shared-schemas';
|
|
5
|
+
export declare const SqlOperations: z.ZodEnum<["SELECT", "INSERT", "UPDATE", "DELETE", "WITH", "EXPLAIN", "ANALYZE", "SHOW", "DESCRIBE", "DESC", "CREATE"]>;
|
|
6
|
+
declare const PostgreSQLParamsSchema: z.ZodObject<{
|
|
7
|
+
ignoreSSL: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
query: z.ZodEffects<z.ZodString, string, string>;
|
|
9
|
+
allowedOperations: z.ZodDefault<z.ZodArray<z.ZodEnum<["SELECT", "INSERT", "UPDATE", "DELETE", "WITH", "EXPLAIN", "ANALYZE", "SHOW", "DESCRIBE", "DESC", "CREATE"]>, "many">>;
|
|
10
|
+
parameters: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>>;
|
|
11
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
maxRows: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
parameters: unknown[];
|
|
16
|
+
timeout: number;
|
|
17
|
+
ignoreSSL: boolean;
|
|
18
|
+
query: string;
|
|
19
|
+
allowedOperations: ("SELECT" | "INSERT" | "UPDATE" | "DELETE" | "WITH" | "EXPLAIN" | "ANALYZE" | "SHOW" | "DESCRIBE" | "DESC" | "CREATE")[];
|
|
20
|
+
maxRows: number;
|
|
21
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
query: string;
|
|
24
|
+
parameters?: unknown[] | undefined;
|
|
25
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
26
|
+
timeout?: number | undefined;
|
|
27
|
+
ignoreSSL?: boolean | undefined;
|
|
28
|
+
allowedOperations?: ("SELECT" | "INSERT" | "UPDATE" | "DELETE" | "WITH" | "EXPLAIN" | "ANALYZE" | "SHOW" | "DESCRIBE" | "DESC" | "CREATE")[] | undefined;
|
|
29
|
+
maxRows?: number | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
type PostgreSQLParamsInput = z.input<typeof PostgreSQLParamsSchema>;
|
|
32
|
+
type PostgreSQLParams = z.output<typeof PostgreSQLParamsSchema>;
|
|
33
|
+
declare const PostgreSQLResultSchema: z.ZodObject<{
|
|
34
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
|
|
35
|
+
rowCount: z.ZodNullable<z.ZodNumber>;
|
|
36
|
+
command: z.ZodString;
|
|
37
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
dataTypeID: z.ZodNumber;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
name: string;
|
|
42
|
+
dataTypeID: number;
|
|
43
|
+
}, {
|
|
44
|
+
name: string;
|
|
45
|
+
dataTypeID: number;
|
|
46
|
+
}>, "many">>;
|
|
47
|
+
executionTime: z.ZodNumber;
|
|
48
|
+
success: z.ZodBoolean;
|
|
49
|
+
error: z.ZodString;
|
|
50
|
+
cleanedJSONString: z.ZodString;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
success: boolean;
|
|
53
|
+
error: string;
|
|
54
|
+
rows: Record<string, unknown>[];
|
|
55
|
+
rowCount: number | null;
|
|
56
|
+
command: string;
|
|
57
|
+
executionTime: number;
|
|
58
|
+
cleanedJSONString: string;
|
|
59
|
+
fields?: {
|
|
60
|
+
name: string;
|
|
61
|
+
dataTypeID: number;
|
|
62
|
+
}[] | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
success: boolean;
|
|
65
|
+
error: string;
|
|
66
|
+
rows: Record<string, unknown>[];
|
|
67
|
+
rowCount: number | null;
|
|
68
|
+
command: string;
|
|
69
|
+
executionTime: number;
|
|
70
|
+
cleanedJSONString: string;
|
|
71
|
+
fields?: {
|
|
72
|
+
name: string;
|
|
73
|
+
dataTypeID: number;
|
|
74
|
+
}[] | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
type PostgreSQLResult = z.output<typeof PostgreSQLResultSchema>;
|
|
77
|
+
export declare class PostgreSQLBubble extends ServiceBubble<PostgreSQLParams, PostgreSQLResult> {
|
|
78
|
+
testCredential(): Promise<boolean>;
|
|
79
|
+
static readonly type: "service";
|
|
80
|
+
static readonly service = "postgresql";
|
|
81
|
+
static readonly authType: "connection-string";
|
|
82
|
+
static readonly bubbleName = "postgresql";
|
|
83
|
+
static readonly schema: z.ZodObject<{
|
|
84
|
+
ignoreSSL: z.ZodDefault<z.ZodBoolean>;
|
|
85
|
+
query: z.ZodEffects<z.ZodString, string, string>;
|
|
86
|
+
allowedOperations: z.ZodDefault<z.ZodArray<z.ZodEnum<["SELECT", "INSERT", "UPDATE", "DELETE", "WITH", "EXPLAIN", "ANALYZE", "SHOW", "DESCRIBE", "DESC", "CREATE"]>, "many">>;
|
|
87
|
+
parameters: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>>;
|
|
88
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
89
|
+
maxRows: z.ZodDefault<z.ZodNumber>;
|
|
90
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
parameters: unknown[];
|
|
93
|
+
timeout: number;
|
|
94
|
+
ignoreSSL: boolean;
|
|
95
|
+
query: string;
|
|
96
|
+
allowedOperations: ("SELECT" | "INSERT" | "UPDATE" | "DELETE" | "WITH" | "EXPLAIN" | "ANALYZE" | "SHOW" | "DESCRIBE" | "DESC" | "CREATE")[];
|
|
97
|
+
maxRows: number;
|
|
98
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
query: string;
|
|
101
|
+
parameters?: unknown[] | undefined;
|
|
102
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
103
|
+
timeout?: number | undefined;
|
|
104
|
+
ignoreSSL?: boolean | undefined;
|
|
105
|
+
allowedOperations?: ("SELECT" | "INSERT" | "UPDATE" | "DELETE" | "WITH" | "EXPLAIN" | "ANALYZE" | "SHOW" | "DESCRIBE" | "DESC" | "CREATE")[] | undefined;
|
|
106
|
+
maxRows?: number | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
static readonly resultSchema: z.ZodObject<{
|
|
109
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
|
|
110
|
+
rowCount: z.ZodNullable<z.ZodNumber>;
|
|
111
|
+
command: z.ZodString;
|
|
112
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
dataTypeID: z.ZodNumber;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
name: string;
|
|
117
|
+
dataTypeID: number;
|
|
118
|
+
}, {
|
|
119
|
+
name: string;
|
|
120
|
+
dataTypeID: number;
|
|
121
|
+
}>, "many">>;
|
|
122
|
+
executionTime: z.ZodNumber;
|
|
123
|
+
success: z.ZodBoolean;
|
|
124
|
+
error: z.ZodString;
|
|
125
|
+
cleanedJSONString: z.ZodString;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
success: boolean;
|
|
128
|
+
error: string;
|
|
129
|
+
rows: Record<string, unknown>[];
|
|
130
|
+
rowCount: number | null;
|
|
131
|
+
command: string;
|
|
132
|
+
executionTime: number;
|
|
133
|
+
cleanedJSONString: string;
|
|
134
|
+
fields?: {
|
|
135
|
+
name: string;
|
|
136
|
+
dataTypeID: number;
|
|
137
|
+
}[] | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
success: boolean;
|
|
140
|
+
error: string;
|
|
141
|
+
rows: Record<string, unknown>[];
|
|
142
|
+
rowCount: number | null;
|
|
143
|
+
command: string;
|
|
144
|
+
executionTime: number;
|
|
145
|
+
cleanedJSONString: string;
|
|
146
|
+
fields?: {
|
|
147
|
+
name: string;
|
|
148
|
+
dataTypeID: number;
|
|
149
|
+
}[] | undefined;
|
|
150
|
+
}>;
|
|
151
|
+
static readonly shortDescription = "Execute PostgreSQL queries with operation validation";
|
|
152
|
+
static readonly longDescription = "\n Execute SQL queries against PostgreSQL databases with proper validation and security controls.\n Use cases:\n - Data retrieval with SELECT queries\n - Data manipulation with INSERT, UPDATE, DELETE (when explicitly allowed)\n - Database reporting and analytics\n - Data migration and synchronization tasks\n - JSON string output for integration with other systems\n \n Security Features:\n - Operation whitelist (defaults to SELECT only)\n - Parameterized queries to prevent SQL injection\n - Connection timeout controls\n - Result sanitization for JSON output\n ";
|
|
153
|
+
static readonly alias = "pg";
|
|
154
|
+
constructor(params?: PostgreSQLParamsInput, context?: BubbleContext);
|
|
155
|
+
protected performAction(context?: BubbleContext): Promise<PostgreSQLResult>;
|
|
156
|
+
getCredentialMetadata(): Promise<DatabaseMetadata | undefined>;
|
|
157
|
+
/**
|
|
158
|
+
* Validate that the SQL query operation is allowed
|
|
159
|
+
*/
|
|
160
|
+
private validateSqlOperation;
|
|
161
|
+
/**
|
|
162
|
+
* Validate parameter usage to encourage parameterized queries
|
|
163
|
+
*/
|
|
164
|
+
private validateParameterUsage;
|
|
165
|
+
/**
|
|
166
|
+
* Validate parentheses and quotes are balanced
|
|
167
|
+
*/
|
|
168
|
+
private validateParenthesesBalance;
|
|
169
|
+
/**
|
|
170
|
+
* Clean and format query results as a JSON string
|
|
171
|
+
*/
|
|
172
|
+
private cleanJSONString;
|
|
173
|
+
/**
|
|
174
|
+
* Clean an object by handling special values and preventing circular references
|
|
175
|
+
*/
|
|
176
|
+
private cleanObject;
|
|
177
|
+
protected chooseCredential(): string | undefined;
|
|
178
|
+
}
|
|
179
|
+
export {};
|
|
180
|
+
//# sourceMappingURL=postgresql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgresql.d.ts","sourceRoot":"","sources":["../../../src/bubbles/service-bubble/postgresql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,cAAc,EACd,K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qBAAqB,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAiEpE;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAuD5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAmB9B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAmClC;;OAEG;IACH,OAAO,CAAC,eAAe;IAcvB;;OAEG;IACH,OAAO,CAAC,WAAW;IA2CnB,SAAS,CAAC,gBAAgB,IAAI,MAAM,GAAG,SAAS;CAWjD"}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ServiceBubble } from '../../types/service-bubble-class.js';
|
|
3
|
+
import { CredentialType, } from '@bubblelab/shared-schemas';
|
|
4
|
+
import { Pool } from 'pg';
|
|
5
|
+
// Define available SQL operations
|
|
6
|
+
export const SqlOperations = z.enum([
|
|
7
|
+
'SELECT',
|
|
8
|
+
'INSERT',
|
|
9
|
+
'UPDATE',
|
|
10
|
+
'DELETE',
|
|
11
|
+
'WITH', // Common Table Expressions for complex analysis
|
|
12
|
+
'EXPLAIN', // Query execution plans for optimization
|
|
13
|
+
'ANALYZE', // Table statistics for analysis
|
|
14
|
+
'SHOW', // Show database/table information
|
|
15
|
+
'DESCRIBE', // Describe table structure
|
|
16
|
+
'DESC', // Alias for DESCRIBE
|
|
17
|
+
'CREATE', // Allow CREATE TEMPORARY for analysis
|
|
18
|
+
]);
|
|
19
|
+
// Define the parameters schema for the PostgreSQL bubble
|
|
20
|
+
const PostgreSQLParamsSchema = z.object({
|
|
21
|
+
ignoreSSL: z
|
|
22
|
+
.boolean()
|
|
23
|
+
.default(true)
|
|
24
|
+
.describe('Ignore SSL certificate errors when connecting to the database'),
|
|
25
|
+
query: z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1, 'Query is required')
|
|
28
|
+
.refine((query) => {
|
|
29
|
+
// Basic SQL injection patterns to reject
|
|
30
|
+
const suspiciousPatterns = [
|
|
31
|
+
/;\s*--/, // Comment injection
|
|
32
|
+
/;\s*\/\*/, // Block comment injection
|
|
33
|
+
/'\s*;\s*drop/i, // Drop table injection
|
|
34
|
+
/;\s*delete\s+from/i, // Delete injection via semicolon
|
|
35
|
+
/;\s*insert\s+into/i, // Insert injection via semicolon
|
|
36
|
+
/;\s*update\s+\w+\s+set/i, // Update injection via semicolon
|
|
37
|
+
/'\s*;\s*alter/i, // Alter injection
|
|
38
|
+
/'\s*;\s*create/i, // Create injection
|
|
39
|
+
/union\s+select/i, // Union select injection
|
|
40
|
+
/'\s*or\s+1\s*=\s*1/i, // Classic OR injection
|
|
41
|
+
/'\s*or\s+true/i, // OR true injection
|
|
42
|
+
/'\s*and\s+1\s*=\s*1/i, // AND injection
|
|
43
|
+
/exec\s*\(/i, // Stored procedure execution
|
|
44
|
+
/sp_/i, // System stored procedures
|
|
45
|
+
/xp_/i, // Extended stored procedures
|
|
46
|
+
/declare\s+@/i, // Variable declaration
|
|
47
|
+
/cast\s*\(/i, // Type casting (can be used maliciously)
|
|
48
|
+
/convert\s*\(/i, // Type conversion
|
|
49
|
+
/waitfor\s+delay/i, // Time-based attacks
|
|
50
|
+
/benchmark\s*\(/i, // MySQL benchmark attacks
|
|
51
|
+
/sleep\s*\(/i, // Sleep attacks
|
|
52
|
+
/load_file\s*\(/i, // File reading attacks
|
|
53
|
+
/into\s+outfile/i, // File writing attacks
|
|
54
|
+
/information_schema.*password/i, // Block password-related schema probing
|
|
55
|
+
/pg_stat_/i, // PostgreSQL statistics
|
|
56
|
+
/pg_user/i, // PostgreSQL user info
|
|
57
|
+
/current_user\s*\(\)/i, // Function call for user enumeration (but allow current_user as column)
|
|
58
|
+
/session_user/i, // Session enumeration
|
|
59
|
+
/version\s*\(/i, // Version enumeration
|
|
60
|
+
/\bxp_cmdshell\b/i, // Command execution
|
|
61
|
+
/\bdbms_/i, // Oracle DBMS packages
|
|
62
|
+
/\butl_/i, // Oracle UTL packages
|
|
63
|
+
];
|
|
64
|
+
return !suspiciousPatterns.some((pattern) => pattern.test(query));
|
|
65
|
+
}, 'Query contains potentially dangerous SQL patterns')
|
|
66
|
+
.describe('SQL query to execute against the PostgreSQL database (use parameterized queries with $1, $2, etc.)'),
|
|
67
|
+
allowedOperations: z
|
|
68
|
+
.array(SqlOperations)
|
|
69
|
+
.default([
|
|
70
|
+
'SELECT',
|
|
71
|
+
'WITH',
|
|
72
|
+
'EXPLAIN',
|
|
73
|
+
'ANALYZE',
|
|
74
|
+
'SHOW',
|
|
75
|
+
'DESCRIBE',
|
|
76
|
+
'DESC',
|
|
77
|
+
])
|
|
78
|
+
.describe('List of allowed SQL operations for security (defaults to read-only operations)'),
|
|
79
|
+
parameters: z
|
|
80
|
+
.array(z.unknown())
|
|
81
|
+
.optional()
|
|
82
|
+
.default([])
|
|
83
|
+
.describe('Parameters for parameterized queries (e.g., [value1, value2] for $1, $2)'),
|
|
84
|
+
timeout: z
|
|
85
|
+
.number()
|
|
86
|
+
.positive()
|
|
87
|
+
.default(30000)
|
|
88
|
+
.describe('Query timeout in milliseconds (default: 30 seconds, max recommended: 300000)'),
|
|
89
|
+
maxRows: z
|
|
90
|
+
.number()
|
|
91
|
+
.positive()
|
|
92
|
+
.default(1000)
|
|
93
|
+
.describe('Maximum number of rows to return to prevent large result sets (default: 1000)'),
|
|
94
|
+
credentials: z
|
|
95
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
96
|
+
.optional()
|
|
97
|
+
.describe('Object mapping credential types to values (injected at runtime)'),
|
|
98
|
+
});
|
|
99
|
+
// Define the result schema for validation
|
|
100
|
+
const PostgreSQLResultSchema = z.object({
|
|
101
|
+
rows: z
|
|
102
|
+
.array(z.record(z.unknown()))
|
|
103
|
+
.describe('Array of result rows, each row is an object with column names as keys'),
|
|
104
|
+
rowCount: z
|
|
105
|
+
.number()
|
|
106
|
+
.nullable()
|
|
107
|
+
.describe('Number of rows affected by the query (null for SELECT queries)'),
|
|
108
|
+
command: z
|
|
109
|
+
.string()
|
|
110
|
+
.describe('SQL command that was executed (SELECT, INSERT, UPDATE, DELETE)'),
|
|
111
|
+
fields: z
|
|
112
|
+
.array(z.object({
|
|
113
|
+
name: z.string().describe('Column name'),
|
|
114
|
+
dataTypeID: z.number().describe('PostgreSQL data type identifier'),
|
|
115
|
+
}))
|
|
116
|
+
.optional()
|
|
117
|
+
.describe('Metadata about the columns returned by the query'),
|
|
118
|
+
executionTime: z.number().describe('Query execution time in milliseconds'),
|
|
119
|
+
success: z.boolean().describe('Whether the query executed successfully'),
|
|
120
|
+
// Make error optional or undefined
|
|
121
|
+
error: z
|
|
122
|
+
.string()
|
|
123
|
+
.describe('Error message if query execution failed (empty string if successful)'),
|
|
124
|
+
cleanedJSONString: z
|
|
125
|
+
.string()
|
|
126
|
+
.describe('Clean JSON string representation of the row data, suitable for AI prompts and integrations'),
|
|
127
|
+
});
|
|
128
|
+
// Example usage:
|
|
129
|
+
// const pgBubble = new PostgreSQLBubble({
|
|
130
|
+
// connectionString: 'postgresql://user:pass@localhost:5432/db',
|
|
131
|
+
// ignoreSSL: false, // Set to true to ignore SSL certificate errors
|
|
132
|
+
// query: 'SELECT * FROM users WHERE active = $1 AND role = $2',
|
|
133
|
+
// parameters: [true, 'admin'],
|
|
134
|
+
// allowedOperations: ['SELECT'],
|
|
135
|
+
// maxRows: 100,
|
|
136
|
+
// timeout: 30000,
|
|
137
|
+
// returnCleanedJSONString: true, // Optional: return results as cleaned JSON string
|
|
138
|
+
// });
|
|
139
|
+
export class PostgreSQLBubble extends ServiceBubble {
|
|
140
|
+
async testCredential() {
|
|
141
|
+
// Make a query to the database to test the credential
|
|
142
|
+
const connectionString = this.chooseCredential();
|
|
143
|
+
const pool = new Pool({
|
|
144
|
+
connectionString,
|
|
145
|
+
ssl: this.params.ignoreSSL ? { rejectUnauthorized: false } : undefined,
|
|
146
|
+
});
|
|
147
|
+
try {
|
|
148
|
+
await pool.query('SELECT 1');
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
await pool.end();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
static type = 'service';
|
|
156
|
+
static service = 'postgresql';
|
|
157
|
+
static authType = 'connection-string';
|
|
158
|
+
// Required static metadata - TypeScript will enforce these exist
|
|
159
|
+
static bubbleName = 'postgresql';
|
|
160
|
+
static schema = PostgreSQLParamsSchema;
|
|
161
|
+
static resultSchema = PostgreSQLResultSchema;
|
|
162
|
+
static shortDescription = 'Execute PostgreSQL queries with operation validation';
|
|
163
|
+
static longDescription = `
|
|
164
|
+
Execute SQL queries against PostgreSQL databases with proper validation and security controls.
|
|
165
|
+
Use cases:
|
|
166
|
+
- Data retrieval with SELECT queries
|
|
167
|
+
- Data manipulation with INSERT, UPDATE, DELETE (when explicitly allowed)
|
|
168
|
+
- Database reporting and analytics
|
|
169
|
+
- Data migration and synchronization tasks
|
|
170
|
+
- JSON string output for integration with other systems
|
|
171
|
+
|
|
172
|
+
Security Features:
|
|
173
|
+
- Operation whitelist (defaults to SELECT only)
|
|
174
|
+
- Parameterized queries to prevent SQL injection
|
|
175
|
+
- Connection timeout controls
|
|
176
|
+
- Result sanitization for JSON output
|
|
177
|
+
`;
|
|
178
|
+
static alias = 'pg';
|
|
179
|
+
constructor(params = {
|
|
180
|
+
query: 'SELECT 1',
|
|
181
|
+
allowedOperations: ['SELECT'],
|
|
182
|
+
parameters: [],
|
|
183
|
+
timeout: 30000,
|
|
184
|
+
maxRows: 1000,
|
|
185
|
+
}, context) {
|
|
186
|
+
super(params, context);
|
|
187
|
+
// Perform additional validation after Zod schema validation
|
|
188
|
+
this.validateSqlOperation(this.params.query, this.params.allowedOperations);
|
|
189
|
+
this.validateParameterUsage(this.params.query, this.params.parameters);
|
|
190
|
+
}
|
|
191
|
+
async performAction(context) {
|
|
192
|
+
// Context is available but not currently used in this implementation
|
|
193
|
+
void context;
|
|
194
|
+
const { ignoreSSL, query, allowedOperations, parameters, timeout, maxRows, } = this.params;
|
|
195
|
+
const startTime = Date.now();
|
|
196
|
+
// Validate the SQL operation against allowed operations
|
|
197
|
+
this.validateSqlOperation(query, allowedOperations);
|
|
198
|
+
// Additional validation: ensure parameters are used for any dynamic values
|
|
199
|
+
this.validateParameterUsage(query, parameters);
|
|
200
|
+
// Create connection pool with strict settings
|
|
201
|
+
// Use chooseCredential to get the appropriate credential
|
|
202
|
+
const connectionString = this.chooseCredential();
|
|
203
|
+
const pool = new Pool({
|
|
204
|
+
connectionString,
|
|
205
|
+
connectionTimeoutMillis: timeout,
|
|
206
|
+
idleTimeoutMillis: timeout,
|
|
207
|
+
max: 1, // Single connection for bubble execution
|
|
208
|
+
allowExitOnIdle: true, // Exit when idle
|
|
209
|
+
statement_timeout: timeout, // Query timeout
|
|
210
|
+
ssl: ignoreSSL ? { rejectUnauthorized: false } : undefined, // SSL configuration
|
|
211
|
+
});
|
|
212
|
+
try {
|
|
213
|
+
// Execute the query with parameters (prevents SQL injection)
|
|
214
|
+
const result = await pool.query(query, parameters);
|
|
215
|
+
const executionTime = Date.now() - startTime;
|
|
216
|
+
// Additional safety: truncate rows if they exceed maxRows
|
|
217
|
+
const truncatedRows = result.rows.slice(0, maxRows);
|
|
218
|
+
const wasTruncated = result.rows.length > maxRows;
|
|
219
|
+
if (wasTruncated) {
|
|
220
|
+
console.warn(`Result set truncated to ${maxRows} rows`);
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
rows: truncatedRows,
|
|
224
|
+
rowCount: result.rowCount,
|
|
225
|
+
command: result.command,
|
|
226
|
+
fields: result.fields?.map((field) => ({
|
|
227
|
+
name: field.name,
|
|
228
|
+
dataTypeID: field.dataTypeID,
|
|
229
|
+
})),
|
|
230
|
+
executionTime,
|
|
231
|
+
success: true,
|
|
232
|
+
error: '',
|
|
233
|
+
cleanedJSONString: this.cleanJSONString(truncatedRows),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
// Always close the pool
|
|
238
|
+
await pool.end();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async getCredentialMetadata() {
|
|
242
|
+
const connectionString = this.chooseCredential();
|
|
243
|
+
if (!connectionString) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
const pool = new Pool({
|
|
247
|
+
connectionString,
|
|
248
|
+
ssl: this.params.ignoreSSL ? { rejectUnauthorized: false } : undefined,
|
|
249
|
+
});
|
|
250
|
+
try {
|
|
251
|
+
// Query all schemas, not just 'public'
|
|
252
|
+
const schemaQuery = `
|
|
253
|
+
SELECT
|
|
254
|
+
t.table_schema,
|
|
255
|
+
t.table_name,
|
|
256
|
+
c.column_name,
|
|
257
|
+
c.data_type,
|
|
258
|
+
c.is_nullable,
|
|
259
|
+
c.column_default,
|
|
260
|
+
c.ordinal_position
|
|
261
|
+
FROM information_schema.tables t
|
|
262
|
+
JOIN information_schema.columns c ON t.table_name = c.table_name
|
|
263
|
+
AND t.table_schema = c.table_schema
|
|
264
|
+
WHERE t.table_type = 'BASE TABLE'
|
|
265
|
+
AND t.table_schema NOT IN ('information_schema', 'pg_catalog', 'pg_toast')
|
|
266
|
+
ORDER BY t.table_schema, t.table_name, c.ordinal_position
|
|
267
|
+
`;
|
|
268
|
+
const result = await pool.query(schemaQuery);
|
|
269
|
+
const rawData = result.rows;
|
|
270
|
+
// Process the schema data into the same compact format as database-analyzer
|
|
271
|
+
// Tables from 'public' schema will not have schema prefix, others will
|
|
272
|
+
const compactSchema = {};
|
|
273
|
+
rawData.forEach((row) => {
|
|
274
|
+
const tableSchema = row.table_schema;
|
|
275
|
+
const tableName = row.table_name;
|
|
276
|
+
const columnName = row.column_name;
|
|
277
|
+
const dataType = row.data_type;
|
|
278
|
+
// Format table name: public schema tables have no prefix, others have schema prefix
|
|
279
|
+
const formattedTableName = `${tableSchema}.${tableName}`;
|
|
280
|
+
if (!compactSchema[formattedTableName]) {
|
|
281
|
+
compactSchema[formattedTableName] = {};
|
|
282
|
+
}
|
|
283
|
+
compactSchema[formattedTableName][columnName] = dataType;
|
|
284
|
+
});
|
|
285
|
+
return {
|
|
286
|
+
tables: compactSchema,
|
|
287
|
+
databaseName: 'postgresql_database',
|
|
288
|
+
databaseType: 'postgresql',
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
console.error('Error getting credential metadata:', error);
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
await pool.end();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Validate that the SQL query operation is allowed
|
|
301
|
+
*/
|
|
302
|
+
validateSqlOperation(query, allowedOperations) {
|
|
303
|
+
// Extract the first SQL keyword (operation) from the query
|
|
304
|
+
const trimmedQuery = query.trim().toUpperCase();
|
|
305
|
+
const firstKeyword = trimmedQuery.split(/\s+/)[0];
|
|
306
|
+
// Check if the operation is in the allowed list
|
|
307
|
+
const isAllowed = allowedOperations.some((op) => firstKeyword.startsWith(op));
|
|
308
|
+
if (!isAllowed) {
|
|
309
|
+
throw new Error(`SQL operation '${firstKeyword}' is not allowed. Allowed operations: ${allowedOperations.join(', ')}`);
|
|
310
|
+
}
|
|
311
|
+
// Additional validation for dangerous operations
|
|
312
|
+
if (firstKeyword === 'DELETE' && !trimmedQuery.includes('WHERE')) {
|
|
313
|
+
throw new Error('DELETE queries must include a WHERE clause for safety');
|
|
314
|
+
}
|
|
315
|
+
if (firstKeyword === 'UPDATE' && !trimmedQuery.includes('WHERE')) {
|
|
316
|
+
throw new Error('UPDATE queries must include a WHERE clause for safety');
|
|
317
|
+
}
|
|
318
|
+
// Block potentially dangerous keywords using word boundaries
|
|
319
|
+
// Allow CREATE TEMPORARY for analysis but block permanent CREATE operations
|
|
320
|
+
const dangerousKeywords = [
|
|
321
|
+
'\\bDROP\\b',
|
|
322
|
+
'\\bALTER\\b',
|
|
323
|
+
'\\bTRUNCATE\\b',
|
|
324
|
+
'\\bGRANT\\b',
|
|
325
|
+
'\\bREVOKE\\b',
|
|
326
|
+
'\\bCOPY\\b',
|
|
327
|
+
'\\bBULK\\b',
|
|
328
|
+
'\\bLOAD\\b',
|
|
329
|
+
];
|
|
330
|
+
const containsDangerous = dangerousKeywords.some((keyword) => new RegExp(keyword, 'i').test(trimmedQuery));
|
|
331
|
+
if (containsDangerous) {
|
|
332
|
+
throw new Error(`Query contains potentially dangerous operations. This bubble only supports: ${allowedOperations.join(', ')}`);
|
|
333
|
+
}
|
|
334
|
+
// Validate parentheses balance to prevent injection through unclosed strings
|
|
335
|
+
this.validateParenthesesBalance(query);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Validate parameter usage to encourage parameterized queries
|
|
339
|
+
*/
|
|
340
|
+
validateParameterUsage(query, parameters) {
|
|
341
|
+
// Count parameter placeholders ($1, $2, etc.)
|
|
342
|
+
const paramPlaceholders = (query.match(/\$\d+/g) || []).length;
|
|
343
|
+
if (paramPlaceholders !== parameters.length) {
|
|
344
|
+
throw new Error(`Parameter count mismatch: query has ${paramPlaceholders} placeholders but ${parameters.length} parameters provided`);
|
|
345
|
+
}
|
|
346
|
+
// Warn if query contains string literals with potential variables
|
|
347
|
+
const hasStringLiterals = /['"][^'"]*\$[^'"]*['"]/.test(query);
|
|
348
|
+
if (hasStringLiterals) {
|
|
349
|
+
console.warn('Query contains string literals with $ symbols. Consider using parameterized queries.');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Validate parentheses and quotes are balanced
|
|
354
|
+
*/
|
|
355
|
+
validateParenthesesBalance(query) {
|
|
356
|
+
let parenCount = 0;
|
|
357
|
+
let singleQuoteCount = 0;
|
|
358
|
+
let doubleQuoteCount = 0;
|
|
359
|
+
for (const char of query) {
|
|
360
|
+
switch (char) {
|
|
361
|
+
case '(':
|
|
362
|
+
parenCount++;
|
|
363
|
+
break;
|
|
364
|
+
case ')':
|
|
365
|
+
parenCount--;
|
|
366
|
+
break;
|
|
367
|
+
case "'":
|
|
368
|
+
singleQuoteCount++;
|
|
369
|
+
break;
|
|
370
|
+
case '"':
|
|
371
|
+
doubleQuoteCount++;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (parenCount !== 0) {
|
|
376
|
+
throw new Error('Unbalanced parentheses in query');
|
|
377
|
+
}
|
|
378
|
+
if (singleQuoteCount % 2 !== 0) {
|
|
379
|
+
throw new Error('Unbalanced single quotes in query');
|
|
380
|
+
}
|
|
381
|
+
if (doubleQuoteCount % 2 !== 0) {
|
|
382
|
+
throw new Error('Unbalanced double quotes in query');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Clean and format query results as a JSON string
|
|
387
|
+
*/
|
|
388
|
+
cleanJSONString(rows) {
|
|
389
|
+
try {
|
|
390
|
+
// Clean the data by removing any potential circular references and handling special values
|
|
391
|
+
const cleanedRows = rows.map((row) => this.cleanObject(row));
|
|
392
|
+
// Return just the essential data as a clean JSON string
|
|
393
|
+
return JSON.stringify(cleanedRows, null, 2);
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
// Fallback to basic JSON stringify if cleaning fails
|
|
397
|
+
console.warn('Failed to clean JSON data, using basic stringify:', error);
|
|
398
|
+
return JSON.stringify(rows, null, 2);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Clean an object by handling special values and preventing circular references
|
|
403
|
+
*/
|
|
404
|
+
cleanObject(obj) {
|
|
405
|
+
if (obj === null || obj === undefined) {
|
|
406
|
+
return obj;
|
|
407
|
+
}
|
|
408
|
+
if (typeof obj === 'bigint') {
|
|
409
|
+
return obj.toString();
|
|
410
|
+
}
|
|
411
|
+
if (obj instanceof Date) {
|
|
412
|
+
return obj.toISOString();
|
|
413
|
+
}
|
|
414
|
+
if (obj instanceof Buffer) {
|
|
415
|
+
return `<Buffer ${obj.length} bytes>`;
|
|
416
|
+
}
|
|
417
|
+
if (typeof obj === 'function') {
|
|
418
|
+
return '<function>';
|
|
419
|
+
}
|
|
420
|
+
if (typeof obj === 'symbol') {
|
|
421
|
+
return obj.toString();
|
|
422
|
+
}
|
|
423
|
+
if (Array.isArray(obj)) {
|
|
424
|
+
return obj.map((item) => this.cleanObject(item));
|
|
425
|
+
}
|
|
426
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
427
|
+
const cleaned = {};
|
|
428
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
429
|
+
// Skip functions and symbols as keys
|
|
430
|
+
if (typeof key === 'string') {
|
|
431
|
+
cleaned[key] = this.cleanObject(value);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return cleaned;
|
|
435
|
+
}
|
|
436
|
+
return obj;
|
|
437
|
+
}
|
|
438
|
+
chooseCredential() {
|
|
439
|
+
const { credentials } = this.params;
|
|
440
|
+
// If no credentials were injected, return undefined
|
|
441
|
+
if (!credentials || typeof credentials !== 'object') {
|
|
442
|
+
throw new Error('No postgres credentials provided');
|
|
443
|
+
}
|
|
444
|
+
// PostgreSQL bubble always uses database credentials
|
|
445
|
+
return credentials[CredentialType.DATABASE_CRED];
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
//# sourceMappingURL=postgresql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgresql.js","sourceRoot":"","sources":["../../../src/bubbles/service-bubble/postgresql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAoB,MAAM,IAAI,CAAC;AAE5C,kCAAkC;AAClC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC;IAClC,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM,EAAE,gDAAgD;IACxD,SAAS,EAAE,yCAAyC;IAC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