Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(amazon-redshift): add Amazon Redshift piece (#17140)

Kishan Parmar1fcb8d44529d
diff --git a/bun.lock b/bun.lock
index 135365f7c22..1ca87b0fcc6 100644
--- a/bun.lock
+++ b/bun.lock
@@ -571,6 +571,21 @@
"vitest": "3.2.6",
},
},
+ "packages/pieces/community/amazon-redshift": {
+ "name": "@activepieces/piece-amazon-redshift",
+ "version": "0.0.1",
+ "dependencies": {
+ "@activepieces/pieces-common": "workspace:*",
+ "@activepieces/pieces-framework": "workspace:*",
+ "@aws-sdk/client-redshift-data": "3.974.0",
+ "@aws-sdk/client-sts": "3.974.0",
+ "pg": "8.20.0",
+ },
+ "devDependencies": {
+ "@types/pg": "8.16.0",
+ "tslib": "2.6.2",
+ },
+ },
"packages/pieces/community/amazon-s3": {
"name": "@activepieces/piece-amazon-s3",
"version": "0.8.1",
@@ -11527,6 +11542,8 @@
"@activepieces/piece-amazon-lambda": ["@activepieces/piece-amazon-lambda@workspace:packages/pieces/community/amazon-lambda"],
+ "@activepieces/piece-amazon-redshift": ["@activepieces/piece-amazon-redshift@workspace:packages/pieces/community/amazon-redshift"],
+
"@activepieces/piece-amazon-s3": ["@activepieces/piece-amazon-s3@workspace:packages/pieces/community/amazon-s3"],
"@activepieces/piece-amazon-secrets-manager": ["@activepieces/piece-amazon-secrets-manager@workspace:packages/pieces/community/amazon-secrets-manager"],
@@ -13171,6 +13188,8 @@
"@aws-sdk/client-lambda": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.973.0", "@aws-sdk/credential-provider-node": "^3.972.1", "@aws-sdk/middleware-host-header": "^3.972.1", "@aws-sdk/middleware-logger": "^3.972.1", "@aws-sdk/middleware-recursion-detection": "^3.972.1", "@aws-sdk/middleware-user-agent": "^3.972.1", "@aws-sdk/region-config-resolver": "^3.972.1", "@aws-sdk/types": "^3.973.0", "@aws-sdk/util-endpoints": "3.972.0", "@aws-sdk/util-user-agent-browser": "^3.972.1", "@aws-sdk/util-user-agent-node": "^3.972.1", "@smithy/config-resolver": "^4.4.6", "@smithy/core": "^3.21.0", "@smithy/eventstream-serde-browser": "^4.2.8", "@smithy/eventstream-serde-config-resolver": "^4.3.8", "@smithy/eventstream-serde-node": "^4.2.8", "@smithy/fetch-http-handler": "^5.3.9", "@smithy/hash-node": "^4.2.8", "@smithy/invalid-dependency": "^4.2.8", "@smithy/middleware-content-length": "^4.2.8", "@smithy/middleware-endpoint": "^4.4.10", "@smithy/middleware-retry": "^4.4.26", "@smithy/middleware-serde": "^4.2.9", "@smithy/middleware-stack": "^4.2.8", "@smithy/node-config-provider": "^4.3.8", "@smithy/node-http-handler": "^4.4.8", "@smithy/protocol-http": "^5.3.8", "@smithy/smithy-client": "^4.10.11", "@smithy/types": "^4.12.0", "@smithy/url-parser": "^4.2.8", "@smithy/util-base64": "^4.3.0", "@smithy/util-body-length-browser": "^4.2.0", "@smithy/util-body-length-node": "^4.2.1", "@smithy/util-defaults-mode-browser": "^4.3.25", "@smithy/util-defaults-mode-node": "^4.2.28", "@smithy/util-endpoints": "^3.2.8", "@smithy/util-middleware": "^4.2.8", "@smithy/util-retry": "^4.2.8", "@smithy/util-stream": "^4.5.10", "@smithy/util-utf8": "^4.2.0", "@smithy/util-waiter": "^4.2.8", "tslib": "^2.6.2" } }, "sha512-/8CtFqvX4GrmwdSKKQkEH1IEiqNQCpZQKzaHGYXthA8Cfjg/nyJ/M1/2c/4El5R8eiZbzzHPGhUPPFdfGMB9jQ=="],
+ "@aws-sdk/client-redshift-data": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.973.0", "@aws-sdk/credential-provider-node": "^3.972.1", "@aws-sdk/middleware-host-header": "^3.972.1", "@aws-sdk/middleware-logger": "^3.972.1", "@aws-sdk/middleware-recursion-detection": "^3.972.1", "@aws-sdk/middleware-user-agent": "^3.972.1", "@aws-sdk/region-config-resolver": "^3.972.1", "@aws-sdk/types": "^3.973.0", "@aws-sdk/util-endpoints": "3.972.0", "@aws-sdk/util-user-agent-browser": "^3.972.1", "@aws-sdk/util-user-agent-node": "^3.972.1", "@smithy/config-resolver": "^4.4.6", "@smithy/core": "^3.21.0", "@smithy/fetch-http-handler": "^5.3.9", "@smithy/hash-node": "^4.2.8", "@smithy/invalid-dependency": "^4.2.8", "@smithy/middleware-content-length": "^4.2.8", "@smithy/middleware-endpoint": "^4.4.10", "@smithy/middleware-retry": "^4.4.26", "@smithy/middleware-serde": "^4.2.9", "@smithy/middleware-stack": "^4.2.8", "@smithy/node-config-provider": "^4.3.8", "@smithy/node-http-handler": "^4.4.8", "@smithy/protocol-http": "^5.3.8", "@smithy/smithy-client": "^4.10.11", "@smithy/types": "^4.12.0", "@smithy/url-parser": "^4.2.8", "@smithy/util-base64": "^4.3.0", "@smithy/util-body-length-browser": "^4.2.0", "@smithy/util-body-length-node": "^4.2.1", "@smithy/util-defaults-mode-browser": "^4.3.25", "@smithy/util-defaults-mode-node": "^4.2.28", "@smithy/util-endpoints": "^3.2.8", "@smithy/util-middleware": "^4.2.8", "@smithy/util-retry": "^4.2.8", "@smithy/util-utf8": "^4.2.0", "tslib": "^2.6.2" } }, "sha512-sa/RXoX3PaVpUTbR8mlB9RBdlh1P/YrX6BgLghhPHtBtvbTdlLMAaL3CmYJh972CdpVLCHEb9kXmj53VqJwtxA=="],
+
"@aws-sdk/client-s3": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-crypto/sha1-browser": "5.2.0", "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.973.0", "@aws-sdk/credential-provider-node": "^3.972.1", "@aws-sdk/middleware-bucket-endpoint": "^3.972.1", "@aws-sdk/middleware-expect-continue": "^3.972.1", "@aws-sdk/middleware-flexible-checksums": "^3.972.1", "@aws-sdk/middleware-host-header": "^3.972.1", "@aws-sdk/middleware-location-constraint": "^3.972.1", "@aws-sdk/middleware-logger": "^3.972.1", "@aws-sdk/middleware-recursion-detection": "^3.972.1", "@aws-sdk/middleware-sdk-s3": "^3.972.1", "@aws-sdk/middleware-ssec": "^3.972.1", "@aws-sdk/middleware-user-agent": "^3.972.1", "@aws-sdk/region-config-resolver": "^3.972.1", "@aws-sdk/signature-v4-multi-region": "3.972.0", "@aws-sdk/types": "^3.973.0", "@aws-sdk/util-endpoints": "3.972.0", "@aws-sdk/util-user-agent-browser": "^3.972.1", "@aws-sdk/util-user-agent-node": "^3.972.1", "@smithy/config-resolver": "^4.4.6", "@smithy/core": "^3.21.0", "@smithy/eventstream-serde-browser": "^4.2.8", "@smithy/eventstream-serde-config-resolver": "^4.3.8", "@smithy/eventstream-serde-node": "^4.2.8", "@smithy/fetch-http-handler": "^5.3.9", "@smithy/hash-blob-browser": "^4.2.9", "@smithy/hash-node": "^4.2.8", "@smithy/hash-stream-node": "^4.2.8", "@smithy/invalid-dependency": "^4.2.8", "@smithy/md5-js": "^4.2.8", "@smithy/middleware-content-length": "^4.2.8", "@smithy/middleware-endpoint": "^4.4.10", "@smithy/middleware-retry": "^4.4.26", "@smithy/middleware-serde": "^4.2.9", "@smithy/middleware-stack": "^4.2.8", "@smithy/node-config-provider": "^4.3.8", "@smithy/node-http-handler": "^4.4.8", "@smithy/protocol-http": "^5.3.8", "@smithy/smithy-client": "^4.10.11", "@smithy/types": "^4.12.0", "@smithy/url-parser": "^4.2.8", "@smithy/util-base64": "^4.3.0", "@smithy/util-body-length-browser": "^4.2.0", "@smithy/util-body-length-node": "^4.2.1", "@smithy/util-defaults-mode-browser": "^4.3.25", "@smithy/util-defaults-mode-node": "^4.2.28", "@smithy/util-endpoints": "^3.2.8", "@smithy/util-middleware": "^4.2.8", "@smithy/util-retry": "^4.2.8", "@smithy/util-stream": "^4.5.10", "@smithy/util-utf8": "^4.2.0", "@smithy/util-waiter": "^4.2.8", "tslib": "^2.6.2" } }, "sha512-X+vpXNJ8cU8Iw1FtDgDHxo9z6RxlXfcTtpdGnKws4rk+tCYKSAor/DG6BRMzbh4E5xAA7DiU1Ny3BTrRRSt/Yg=="],
"@aws-sdk/client-secrets-manager": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.973.13", "@aws-sdk/credential-provider-node": "^3.972.12", "@aws-sdk/middleware-host-header": "^3.972.4", "@aws-sdk/middleware-logger": "^3.972.4", "@aws-sdk/middleware-recursion-detection": "^3.972.4", "@aws-sdk/middleware-user-agent": "^3.972.13", "@aws-sdk/region-config-resolver": "^3.972.4", "@aws-sdk/types": "^3.973.2", "@aws-sdk/util-endpoints": "^3.996.1", "@aws-sdk/util-user-agent-browser": "^3.972.4", "@aws-sdk/util-user-agent-node": "^3.972.12", "@smithy/config-resolver": "^4.4.7", "@smithy/core": "^3.23.4", "@smithy/fetch-http-handler": "^5.3.10", "@smithy/hash-node": "^4.2.9", "@smithy/invalid-dependency": "^4.2.9", "@smithy/middleware-content-length": "^4.2.9", "@smithy/middleware-endpoint": "^4.4.18", "@smithy/middleware-retry": "^4.4.35", "@smithy/middleware-serde": "^4.2.10", "@smithy/middleware-stack": "^4.2.9", "@smithy/node-config-provider": "^4.3.9", "@smithy/node-http-handler": "^4.4.11", "@smithy/protocol-http": "^5.3.9", "@smithy/smithy-client": "^4.11.7", "@smithy/types": "^4.12.1", "@smithy/url-parser": "^4.2.9", "@smithy/util-base64": "^4.3.1", "@smithy/util-body-length-browser": "^4.2.1", "@smithy/util-body-length-node": "^4.2.2", "@smithy/util-defaults-mode-browser": "^4.3.34", "@smithy/util-defaults-mode-node": "^4.2.37", "@smithy/util-endpoints": "^3.2.9", "@smithy/util-middleware": "^4.2.9", "@smithy/util-retry": "^4.2.9", "@smithy/util-utf8": "^4.2.1", "tslib": "^2.6.2" } }, "sha512-5r+1P1iuILRhtKk7j5gEvfiJpweHk5TWXFJl5BKKKuE47esgd2R5cAwyPJId/5cPJln2yC9qevz9zneoLpWNVw=="],
@@ -17355,7 +17374,7 @@
"pend": ["[email protected]", "", {}, "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg=="],
- "pg": ["[email protected]", "", { "dependencies": { "buffer-writer": "2.0.0", "packet-reader": "1.0.0", "pg-connection-string": "^2.6.2", "pg-pool": "^3.6.1", "pg-protocol": "^1.6.0", "pg-types": "^2.1.0", "pgpass": "1.x" }, "optionalDependencies": { "pg-cloudflare": "^1.1.1" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g=="],
+ "pg": ["[email protected]", "", { "dependencies": { "pg-connection-string": "^2.12.0", "pg-pool": "^3.13.0", "pg-protocol": "^1.13.0", "pg-types": "2.2.0", "pgpass": "1.0.5" }, "optionalDependencies": { "pg-cloudflare": "^1.3.0" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-ldhMxz2r8fl/6QkXnBD3CR9/xg694oT6DZQ2s6c/RI28OjtSOpxnPrUCGOBJ46RCUxcWdx3p6kw/xnDHjKvaRA=="],
"pg-cloudflare": ["[email protected]", "", {}, "sha512-6lswVVSztmHiRtD6I8hw4qP/nDm1EJbKMRhf3HCYaqud7frGysPv7FYJ5noZQdhQtN2xJnimfMtvQq21pdbzyQ=="],
@@ -18579,6 +18598,8 @@
"@activepieces/piece-pinecone/tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
+ "@activepieces/piece-postgres/pg": ["[email protected]", "", { "dependencies": { "buffer-writer": "2.0.0", "packet-reader": "1.0.0", "pg-connection-string": "^2.6.2", "pg-pool": "^3.6.1", "pg-protocol": "^1.6.0", "pg-types": "^2.1.0", "pgpass": "1.x" }, "optionalDependencies": { "pg-cloudflare": "^1.1.1" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g=="],
+
"@activepieces/piece-service-now/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
"@activepieces/pieces-framework/ai": ["[email protected]", "", { "dependencies": { "@ai-sdk/gateway": "3.0.105", "@ai-sdk/provider": "3.0.9", "@ai-sdk/provider-utils": "4.0.24", "@opentelemetry/api": "1.9.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-FWTKeGGDRcYJtPWIrdZDSuvOW5LCjI2NZUJmaml8OTOaPEsXnFdFvmawCXbT+wTGxyWKJTgZ9sZtCjbJsmjM2Q=="],
@@ -18711,6 +18732,18 @@
"@aws-sdk/client-lambda/@smithy/types": ["@smithy/[email protected]", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-0JFs3V2y2M9tKW5na/qxe69Zv+uxLMO7QBbhxF/FHu/Gp2NFZAAL9tWl9PU02xxo07pb3G9FTyjNc6D5uZrJIg=="],
+ "@aws-sdk/client-redshift-data/@aws-sdk/util-endpoints": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/types": "3.972.0", "@smithy/types": "^4.12.0", "@smithy/url-parser": "^4.2.8", "@smithy/util-endpoints": "^3.2.8", "tslib": "^2.6.2" } }, "sha512-6JHsl1V/a1ZW8D8AFfd4R52fwZPnZ5H4U6DS8m/bWT8qad72NvbOFAC7U2cDtFs2TShqUO3TEiX/EJibtY3ijg=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/core": ["@smithy/[email protected]", "", { "dependencies": { "@smithy/types": "^4.16.1", "tslib": "^2.6.2" } }, "sha512-CyogUINxvi7C7LDsh8Syo6hVJOT9ckz4rG8dRZfTJ8r91HkMY59PnNooaj7WcHyxEkxPfBAmbgztZU+xTo76lg=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/node-http-handler": ["@smithy/[email protected]", "", { "dependencies": { "@smithy/protocol-http": "^5.3.14", "@smithy/querystring-builder": "^4.2.14", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-iB+orM4x3xrr57X3YaXazfKnntl0LHlZB1kcXSGzMV1Tt0+YwEjGlbjk/44qEGtBzXAz6yFDzkYTKSV6Pj2HUg=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/protocol-http": ["@smithy/[email protected]", "", { "dependencies": { "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-dN5F8kHx8RNU0r+pCwNmFZyz6ChjMkzShy/zup6MtkRmmix4vZzJdW+di7x//b1LiynIev88FM18ie+wwPcQtQ=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/types": ["@smithy/[email protected]", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-0JFs3V2y2M9tKW5na/qxe69Zv+uxLMO7QBbhxF/FHu/Gp2NFZAAL9tWl9PU02xxo07pb3G9FTyjNc6D5uZrJIg=="],
+
+ "@aws-sdk/client-redshift-data/tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
+
"@aws-sdk/client-s3/@aws-sdk/util-endpoints": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/types": "3.972.0", "@smithy/types": "^4.12.0", "@smithy/url-parser": "^4.2.8", "@smithy/util-endpoints": "^3.2.8", "tslib": "^2.6.2" } }, "sha512-6JHsl1V/a1ZW8D8AFfd4R52fwZPnZ5H4U6DS8m/bWT8qad72NvbOFAC7U2cDtFs2TShqUO3TEiX/EJibtY3ijg=="],
"@aws-sdk/client-s3/@smithy/node-http-handler": ["@smithy/[email protected]", "", { "dependencies": { "@smithy/protocol-http": "^5.3.14", "@smithy/querystring-builder": "^4.2.14", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-iB+orM4x3xrr57X3YaXazfKnntl0LHlZB1kcXSGzMV1Tt0+YwEjGlbjk/44qEGtBzXAz6yFDzkYTKSV6Pj2HUg=="],
@@ -19421,6 +19454,8 @@
"api/google-auth-library": ["[email protected]", "", { "dependencies": { "base64-js": "^1.3.0", "ecdsa-sig-formatter": "^1.0.11", "gaxios": "7.1.3", "gcp-metadata": "8.1.2", "google-logging-utils": "1.1.3", "jws": "^4.0.0" } }, "sha512-5awwuLrzNol+pFDmKJd0dKtZ0fPLAtoA5p7YO4ODsDu6ONJUVqbYwvv8y2ZBO5MBNp9TJXigB19710kYpBPdtA=="],
+ "api/pg": ["[email protected]", "", { "dependencies": { "buffer-writer": "2.0.0", "packet-reader": "1.0.0", "pg-connection-string": "^2.6.2", "pg-pool": "^3.6.1", "pg-protocol": "^1.6.0", "pg-types": "^2.1.0", "pgpass": "1.x" }, "optionalDependencies": { "pg-cloudflare": "^1.1.1" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g=="],
+
"api/socket.io": ["[email protected]", "", { "dependencies": { "accepts": "~1.3.4", "base64id": "~2.0.0", "cors": "~2.8.5", "debug": "~4.3.2", "engine.io": "~6.6.0", "socket.io-adapter": "~2.5.2", "socket.io-parser": "~4.2.4" } }, "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg=="],
"archiver/readable-stream": ["[email protected]", "", { "dependencies": { "abort-controller": "^3.0.0", "buffer": "^6.0.3", "events": "^3.3.0", "process": "^0.11.10", "string_decoder": "^1.3.0" } }, "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg=="],
@@ -20341,8 +20376,6 @@
"web/marked": ["[email protected]", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-NsmlUYBS/Zg57rgDWMYdnre6OTj4e+qq/JS2ot3KrYLSoHLw+sDu0Nm1ZGpRgYAq6c+b1ekaY5NzVchMCQnzcg=="],
- "web/pg": ["[email protected]", "", { "dependencies": { "pg-connection-string": "^2.12.0", "pg-pool": "^3.13.0", "pg-protocol": "^1.13.0", "pg-types": "2.2.0", "pgpass": "1.0.5" }, "optionalDependencies": { "pg-cloudflare": "^1.3.0" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-ldhMxz2r8fl/6QkXnBD3CR9/xg694oT6DZQ2s6c/RI28OjtSOpxnPrUCGOBJ46RCUxcWdx3p6kw/xnDHjKvaRA=="],
-
"webpack/eslint-scope": ["[email protected]", "", { "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" } }, "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw=="],
"webpack-cli/commander": ["[email protected]", "", {}, "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug=="],
@@ -20629,6 +20662,24 @@
"@aws-sdk/client-lambda/@smithy/protocol-http/@smithy/types": ["@smithy/[email protected]", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-59b5HtSVrVR/eYNei3BUj3DCPKD/G7EtDDe7OEJE7i7FtQFugYo6MxbotS8mVJkLNVf8gYaAlEBwwtJ9HzhWSg=="],
+ "@aws-sdk/client-redshift-data/@aws-sdk/util-endpoints/@aws-sdk/types": ["@aws-sdk/[email protected]", "", { "dependencies": { "@smithy/types": "^4.12.0", "tslib": "^2.6.2" } }, "sha512-U7xBIbLSetONxb2bNzHyDgND3oKGoIfmknrEVnoEU4GUSs+0augUOIn9DIWGUO2ETcRFdsRUnmx9KhPT9Ojbug=="],
+
+ "@aws-sdk/client-redshift-data/@aws-sdk/util-endpoints/@smithy/types": ["@smithy/[email protected]", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-59b5HtSVrVR/eYNei3BUj3DCPKD/G7EtDDe7OEJE7i7FtQFugYo6MxbotS8mVJkLNVf8gYaAlEBwwtJ9HzhWSg=="],
+
+ "@aws-sdk/client-redshift-data/@aws-sdk/util-endpoints/tslib": ["[email protected]", "", {}, "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/core/tslib": ["[email protected]", "", {}, "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/node-http-handler/@smithy/types": ["@smithy/[email protected]", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-59b5HtSVrVR/eYNei3BUj3DCPKD/G7EtDDe7OEJE7i7FtQFugYo6MxbotS8mVJkLNVf8gYaAlEBwwtJ9HzhWSg=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/node-http-handler/tslib": ["[email protected]", "", {}, "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/protocol-http/@smithy/types": ["@smithy/[email protected]", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-59b5HtSVrVR/eYNei3BUj3DCPKD/G7EtDDe7OEJE7i7FtQFugYo6MxbotS8mVJkLNVf8gYaAlEBwwtJ9HzhWSg=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/protocol-http/tslib": ["[email protected]", "", {}, "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="],
+
+ "@aws-sdk/client-redshift-data/@smithy/types/tslib": ["[email protected]", "", {}, "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="],
+
"@aws-sdk/client-s3/@aws-sdk/util-endpoints/@aws-sdk/types": ["@aws-sdk/[email protected]", "", { "dependencies": { "@smithy/types": "^4.12.0", "tslib": "^2.6.2" } }, "sha512-U7xBIbLSetONxb2bNzHyDgND3oKGoIfmknrEVnoEU4GUSs+0augUOIn9DIWGUO2ETcRFdsRUnmx9KhPT9Ojbug=="],
"@aws-sdk/client-ses/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/[email protected]", "", { "dependencies": { "@smithy/types": "^4.3.2", "tslib": "^2.6.2" } }, "sha512-6Ed0kmC1NMbuFTEgNmamAUU1h5gShgxL1hBVLbEzUa3trX5aJBz1vU4bXaBTvOYUAnOHtiy1Ml4AMStd6hJnFA=="],
diff --git a/packages/pieces/community/amazon-redshift/.eslintrc.json b/packages/pieces/community/amazon-redshift/.eslintrc.json
new file mode 100644
index 00000000000..6f1536634f9
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/.eslintrc.json
@@ -0,0 +1,47 @@
+{
+ "extends": [
+ "../../../../.eslintrc.json"
+ ],
+ "ignorePatterns": [
+ "!**/*"
+ ],
+ "overrides": [
+ {
+ "files": [
+ "*.ts",
+ "*.tsx",
+ "*.js",
+ "*.jsx"
+ ],
+ "rules": {}
+ },
+ {
+ "files": [
+ "*.ts",
+ "*.tsx"
+ ],
+ "rules": {
+ "no-restricted-imports": [
+ "error",
+ {
+ "patterns": [
+ "lodash",
+ "lodash/*",
+ "@activepieces/core-*",
+ "@activepieces/server*",
+ "@activepieces/engine",
+ "@activepieces/shared"
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "files": [
+ "*.js",
+ "*.jsx"
+ ],
+ "rules": {}
+ }
+ ]
+}
diff --git a/packages/pieces/community/amazon-redshift/package.json b/packages/pieces/community/amazon-redshift/package.json
new file mode 100644
index 00000000000..351cb4cb205
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@activepieces/piece-amazon-redshift",
+ "version": "0.0.1",
+ "main": "./dist/src/index.js",
+ "types": "./dist/src/index.d.ts",
+ "dependencies": {
+ "@activepieces/pieces-common": "workspace:*",
+ "@activepieces/pieces-framework": "workspace:*",
+ "@aws-sdk/client-redshift-data": "3.974.0",
+ "@aws-sdk/client-sts": "3.974.0",
+ "pg": "8.20.0"
+ },
+ "scripts": {
+ "build": "tsc -p tsconfig.lib.json && cp package.json dist/",
+ "bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",
+ "lint": "eslint 'src/**/*.ts'"
+ },
+ "devDependencies": {
+ "@types/pg": "8.16.0",
+ "tslib": "2.6.2"
+ }
+}
diff --git a/packages/pieces/community/amazon-redshift/src/index.ts b/packages/pieces/community/amazon-redshift/src/index.ts
new file mode 100644
index 00000000000..c97cf2f7b07
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/index.ts
@@ -0,0 +1,21 @@
+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';
+import { deleteRows } from './lib/actions/delete-rows';
+import { findRows } from './lib/actions/find-rows';
+import { insertRows } from './lib/actions/insert-rows';
+import { runQuery } from './lib/actions/run-query';
+import { updateRows } from './lib/actions/update-rows';
+import { redshiftAuth } from './lib/auth';
+import { newOrUpdatedRow } from './lib/triggers/new-or-updated-row';
+import { newRow } from './lib/triggers/new-row';
+
+export const amazonRedshift = createPiece({
+ displayName: 'Amazon Redshift',
+ description: 'Fully managed cloud data warehouse from AWS.',
+ minimumSupportedRelease: '0.90.1',
+ logoUrl: 'https://cdn.activepieces.com/pieces/amazon-redshift.png',
+ categories: [PieceCategory.DEVELOPER_TOOLS, PieceCategory.BUSINESS_INTELLIGENCE],
+ authors: ['kishanprmr'],
+ auth: redshiftAuth,
+ actions: [insertRows, updateRows, deleteRows, findRows, runQuery],
+ triggers: [newRow, newOrUpdatedRow],
+});
diff --git a/packages/pieces/community/amazon-redshift/src/lib/actions/delete-rows.ts b/packages/pieces/community/amazon-redshift/src/lib/actions/delete-rows.ts
new file mode 100644
index 00000000000..225977fff6f
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/actions/delete-rows.ts
@@ -0,0 +1,35 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from '../common/client';
+import { redshiftProps } from '../common/props';
+import { redshiftUtils } from '../common/utils';
+import { deleteRowsOutputSchema } from '../output-schemas';
+
+export const deleteRows = createAction({
+ auth: redshiftAuth,
+ name: 'delete_rows',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Rows',
+ description: 'Deletes every row where a column equals a value.',
+ audience: 'both',
+ outputSchema: deleteRowsOutputSchema,
+ aiMetadata: {
+ description: 'Permanently deletes every row of an Amazon Redshift table whose search column equals the search value. Returns the number of rows deleted. Use Run Query for more complex conditions. Not idempotent in result: a repeat deletes nothing and returns 0.',
+ idempotent: false,
+ },
+ props: {
+ table: redshiftProps.table({ required: true }),
+ search_column: redshiftProps.column({ required: true, displayName: 'Search Column', description: 'The column to match rows on.' }),
+ search_value: Property.ShortText({
+ displayName: 'Search Value',
+ description: 'Rows whose search column equals this value are deleted.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { table, search_column, search_value } = context.propsValue;
+ const sql = `DELETE FROM ${redshiftUtils.qualifiedName({ table })} WHERE ${redshiftUtils.quoteIdentifier({ name: search_column })} = $1`;
+ const { rowCount } = await redshiftClient.runSql({ auth: context.auth, server: context.server, sql, params: [search_value] });
+ return { rowCount };
+ },
+});
diff --git a/packages/pieces/community/amazon-redshift/src/lib/actions/find-rows.ts b/packages/pieces/community/amazon-redshift/src/lib/actions/find-rows.ts
new file mode 100644
index 00000000000..be7df7f2414
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/actions/find-rows.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from '../common/client';
+import { redshiftProps } from '../common/props';
+import { redshiftUtils } from '../common/utils';
+import { findRowsOutputSchema } from '../output-schemas';
+
+export const findRows = createAction({
+ auth: redshiftAuth,
+ name: 'find_rows',
+ classification: 'SEARCH',
+ displayName: 'Find Rows',
+ description: 'Finds rows where a column equals a value.',
+ audience: 'both',
+ outputSchema: findRowsOutputSchema,
+ aiMetadata: {
+ description: 'Reads rows from an Amazon Redshift table, optionally only those whose search column equals the search value, up to a row limit (100 by default). Use Run Query for joins, ranges or aggregates. Read-only and idempotent.',
+ idempotent: true,
+ },
+ props: {
+ table: redshiftProps.table({ required: true }),
+ search_column: redshiftProps.column({ required: false, displayName: 'Search Column', description: 'Leave empty to read rows without a filter.' }),
+ search_value: Property.ShortText({
+ displayName: 'Search Value',
+ description: 'Rows whose search column equals this value are returned.',
+ required: false,
+ }),
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'The most rows to return.',
+ defaultValue: 100,
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { table, search_column, search_value, limit } = context.propsValue;
+ if (!Number.isInteger(limit) || limit <= 0) {
+ throw new Error('Limit must be a positive whole number.');
+ }
+ const filtered = Boolean(search_column);
+ if (filtered && (search_value === undefined || search_value === '')) {
+ throw new Error('Enter a Search Value, or clear the Search Column.');
+ }
+ const where = search_column ? ` WHERE ${redshiftUtils.quoteIdentifier({ name: search_column })} = $1` : '';
+ const sql = `SELECT * FROM ${redshiftUtils.qualifiedName({ table })}${where} LIMIT ${limit}`;
+ return await redshiftClient.runSql({ auth: context.auth, server: context.server, sql, params: filtered ? [search_value] : [] });
+ },
+});
diff --git a/packages/pieces/community/amazon-redshift/src/lib/actions/insert-rows.ts b/packages/pieces/community/amazon-redshift/src/lib/actions/insert-rows.ts
new file mode 100644
index 00000000000..f31fe483bfa
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/actions/insert-rows.ts
@@ -0,0 +1,60 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from '../common/client';
+import { redshiftProps } from '../common/props';
+import { redshiftUtils } from '../common/utils';
+import { insertRowsOutputSchema } from '../output-schemas';
+
+const MAX_ROWS = 500;
+
+function buildValues({ records, columns }: { records: Record<string, unknown>[]; columns: string[] }): { tuples: string[]; params: unknown[] } {
+ const params: unknown[] = [];
+ const tuples = records.map((record) => {
+ const cells = columns.map((name) => {
+ if (!(name in record)) {
+ return 'DEFAULT';
+ }
+ params.push(record[name]);
+ return `$${params.length}`;
+ });
+ return `(${cells.join(', ')})`;
+ });
+ return { tuples, params };
+}
+
+export const insertRows = createAction({
+ auth: redshiftAuth,
+ name: 'insert_rows',
+ classification: 'WRITE',
+ displayName: 'Insert Rows',
+ description: 'Inserts one or more rows into a table.',
+ audience: 'both',
+ outputSchema: insertRowsOutputSchema,
+ aiMetadata: {
+ description: `Inserts up to ${MAX_ROWS} rows into an Amazon Redshift table in one INSERT statement, each row a map of column names to values; if any row fails, none are inserted. Columns a row leaves empty get the column default. Returns only the inserted row count, because Redshift cannot return the stored rows. Not idempotent: each call appends new rows.`,
+ idempotent: false,
+ },
+ props: {
+ table: redshiftProps.table({ required: true }),
+ batch: redshiftProps.rows({ required: true }),
+ },
+ async run(context) {
+ const { table, batch } = context.propsValue;
+ const submitted: unknown[] = Array.isArray(batch['rows']) ? batch['rows'] : [];
+ const records = submitted.map((row) => redshiftUtils.filledFields({ values: row }));
+ if (records.length === 0) {
+ throw new Error('Add at least one row.');
+ }
+ if (records.length > MAX_ROWS) {
+ throw new Error(`At most ${MAX_ROWS} rows can be inserted per step. Split the rows over several steps.`);
+ }
+ const columns = [...new Set(records.flatMap((record) => Object.keys(record)))];
+ if (columns.length === 0) {
+ throw new Error('Fill at least one column.');
+ }
+ const { tuples, params } = buildValues({ records, columns });
+ const sql = `INSERT INTO ${redshiftUtils.qualifiedName({ table })} (${columns.map((name) => redshiftUtils.quoteIdentifier({ name })).join(', ')}) VALUES ${tuples.join(', ')}`;
+ const { rowCount } = await redshiftClient.runSql({ auth: context.auth, server: context.server, sql, params });
+ return { rowCount };
+ },
+});
diff --git a/packages/pieces/community/amazon-redshift/src/lib/actions/run-query.ts b/packages/pieces/community/amazon-redshift/src/lib/actions/run-query.ts
new file mode 100644
index 00000000000..cbec190766d
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/actions/run-query.ts
@@ -0,0 +1,39 @@
+import { createAction, MarkdownVariant, Property } from '@activepieces/pieces-framework';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from '../common/client';
+import { runQueryOutputSchema } from '../output-schemas';
+
+export const runQuery = createAction({
+ auth: redshiftAuth,
+ name: 'run_query',
+ classification: 'WRITE',
+ displayName: 'Run Query',
+ description: 'Runs one SQL statement.',
+ audience: 'both',
+ outputSchema: runQueryOutputSchema,
+ aiMetadata: {
+ description: 'Runs a single SQL statement against Amazon Redshift and returns its rows and row count. Use it when no specific action fits: joins, aggregates, ranges, DDL. Always pass dynamic values in Arguments and reference them as $1, $2; never put them in the SQL text. Not idempotent: the statement may change data.',
+ idempotent: false,
+ },
+ props: {
+ markdown: Property.MarkDown({
+ value: 'Never type dynamic values into the query. Write $1, $2 and put the values in Arguments to prevent SQL injection.',
+ variant: MarkdownVariant.WARNING,
+ }),
+ query: Property.LongText({
+ displayName: 'Query',
+ description: 'One SQL statement. Write $1, $2 where each value goes.',
+ placeholder: 'SELECT * FROM public.orders WHERE status = $1',
+ required: true,
+ }),
+ args: Property.Array({
+ displayName: 'Arguments',
+ description: 'Values for $1, $2 and so on in the query, in order.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { query, args } = context.propsValue;
+ return await redshiftClient.runSql({ auth: context.auth, server: context.server, sql: query, params: args ?? [] });
+ },
+});
diff --git a/packages/pieces/community/amazon-redshift/src/lib/actions/update-rows.ts b/packages/pieces/community/amazon-redshift/src/lib/actions/update-rows.ts
new file mode 100644
index 00000000000..3ba483ba05f
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/actions/update-rows.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from '../common/client';
+import { redshiftProps } from '../common/props';
+import { redshiftUtils } from '../common/utils';
+import { updateRowsOutputSchema } from '../output-schemas';
+
+export const updateRows = createAction({
+ auth: redshiftAuth,
+ name: 'update_rows',
+ classification: 'WRITE',
+ displayName: 'Update Rows',
+ description: 'Updates every row where a column equals a value.',
+ audience: 'both',
+ outputSchema: updateRowsOutputSchema,
+ aiMetadata: {
+ description: 'Sets new values on every row of an Amazon Redshift table whose search column equals the search value; only the filled fields change. Returns the number of rows updated. Use Run Query for more complex conditions. Idempotent: repeating the call sets the same values again.',
+ idempotent: true,
+ },
+ props: {
+ table: redshiftProps.table({ required: true }),
+ search_column: redshiftProps.column({ required: true, displayName: 'Search Column', description: 'The column to match rows on.' }),
+ search_value: Property.ShortText({
+ displayName: 'Search Value',
+ description: 'Rows whose search column equals this value are updated.',
+ required: true,
+ }),
+ values: redshiftProps.values({ required: true }),
+ },
+ async run(context) {
+ const { table, search_column, search_value, values } = context.propsValue;
+ const changes = Object.entries(redshiftUtils.filledFields({ values }));
+ if (changes.length === 0) {
+ throw new Error('Fill at least one field in New Values.');
+ }
+ const assignments = changes.map(([name], index) => `${redshiftUtils.quoteIdentifier({ name })} = $${index + 1}`).join(', ');
+ const sql = `UPDATE ${redshiftUtils.qualifiedName({ table })} SET ${assignments} WHERE ${redshiftUtils.quoteIdentifier({ name: search_column })} = $${changes.length + 1}`;
+ const { rowCount } = await redshiftClient.runSql({
+ auth: context.auth,
+ server: context.server,
+ sql,
+ params: [...changes.map(([, value]) => value), search_value],
+ });
+ return { rowCount };
+ },
+});
diff --git a/packages/pieces/community/amazon-redshift/src/lib/auth.ts b/packages/pieces/community/amazon-redshift/src/lib/auth.ts
new file mode 100644
index 00000000000..7daf5a28e90
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/auth.ts
@@ -0,0 +1,196 @@
+import { AppConnectionType, isPieceServerContextError, PieceAuth, Property } from '@activepieces/pieces-framework';
+import { redshiftClient } from './common/client';
+
+const AWS_REGIONS = [
+ { label: 'US East (N. Virginia) [us-east-1]', value: 'us-east-1' },
+ { label: 'US East (Ohio) [us-east-2]', value: 'us-east-2' },
+ { label: 'US West (N. California) [us-west-1]', value: 'us-west-1' },
+ { label: 'US West (Oregon) [us-west-2]', value: 'us-west-2' },
+ { label: 'Africa (Cape Town) [af-south-1]', value: 'af-south-1' },
+ { label: 'Asia Pacific (Hong Kong) [ap-east-1]', value: 'ap-east-1' },
+ { label: 'Asia Pacific (Hyderabad) [ap-south-2]', value: 'ap-south-2' },
+ { label: 'Asia Pacific (Jakarta) [ap-southeast-3]', value: 'ap-southeast-3' },
+ { label: 'Asia Pacific (Melbourne) [ap-southeast-4]', value: 'ap-southeast-4' },
+ { label: 'Asia Pacific (Mumbai) [ap-south-1]', value: 'ap-south-1' },
+ { label: 'Asia Pacific (Osaka) [ap-northeast-3]', value: 'ap-northeast-3' },
+ { label: 'Asia Pacific (Seoul) [ap-northeast-2]', value: 'ap-northeast-2' },
+ { label: 'Asia Pacific (Singapore) [ap-southeast-1]', value: 'ap-southeast-1' },
+ { label: 'Asia Pacific (Sydney) [ap-southeast-2]', value: 'ap-southeast-2' },
+ { label: 'Asia Pacific (Tokyo) [ap-northeast-1]', value: 'ap-northeast-1' },
+ { label: 'Canada (Central) [ca-central-1]', value: 'ca-central-1' },
+ { label: 'Europe (Frankfurt) [eu-central-1]', value: 'eu-central-1' },
+ { label: 'Europe (Ireland) [eu-west-1]', value: 'eu-west-1' },
+ { label: 'Europe (London) [eu-west-2]', value: 'eu-west-2' },
+ { label: 'Europe (Milan) [eu-south-1]', value: 'eu-south-1' },
+ { label: 'Europe (Paris) [eu-west-3]', value: 'eu-west-3' },
+ { label: 'Europe (Spain) [eu-south-2]', value: 'eu-south-2' },
+ { label: 'Europe (Stockholm) [eu-north-1]', value: 'eu-north-1' },
+ { label: 'Europe (Zurich) [eu-central-2]', value: 'eu-central-2' },
+ { label: 'Middle East (Bahrain) [me-south-1]', value: 'me-south-1' },
+ { label: 'Middle East (UAE) [me-central-1]', value: 'me-central-1' },
+ { label: 'South America (São Paulo) [sa-east-1]', value: 'sa-east-1' },
+];
+
+const ROLE_ARN = /^arn:(?:aws|aws-us-gov|aws-cn):iam::\d{12}:role\/[\w+=,.@\-/]{1,512}$/;
+
+const passwordDescription = `
+Connect straight to your cluster or Serverless workgroup with a database user.
+
+**Where to find the values:**
+1. Open the [Amazon Redshift console](https://console.aws.amazon.com/redshiftv2/).
+2. Open your cluster (or **Serverless** → your workgroup) and copy the **Endpoint**. It looks like \`my-workgroup.123456789012.us-east-1.redshift-serverless.amazonaws.com:5439/dev\`: the part before \`:\` is the **Host**, the number is the **Port** and the part after \`/\` is the **Database**.
+3. Use the admin user, or a database user created with \`CREATE USER\`.
+
+The cluster must accept connections from Activepieces: turn on **Publicly accessible** and allow port 5439 in its security group. For a private cluster, use the IAM Role connection instead.
+`;
+
+const iamDescription = `
+Connect through the Redshift Data API with an IAM role. No password or open port is needed, so this works for private clusters.
+
+Activepieces acts as an OIDC identity provider. AWS trusts it and issues temporary credentials with \`AssumeRoleWithWebIdentity\`.
+
+**Setup steps:**
+1. In AWS IAM → Identity providers → Create provider:
+ - Provider type: **OpenID Connect**
+ - Provider URL: \`{{frontendUrl}}\`
+ - Audience: \`sts.amazonaws.com\`
+
+ AWS fetches \`{{frontendUrl}}/.well-known/openid-configuration\`, so that URL must be reachable from the internet.
+2. Create an IAM role with this trust policy:
+\`\`\`json
+{
+ "Version": "2012-10-17",
+ "Statement": [{
+ "Effect": "Allow",
+ "Principal": { "Federated": "arn:aws:iam::YOUR_ACCOUNT_ID:oidc-provider/{{frontendHost}}" },
+ "Action": "sts:AssumeRoleWithWebIdentity",
+ "Condition": {
+ "StringEquals": { "{{frontendHost}}:aud": "sts.amazonaws.com" },
+ "StringLike": { "{{frontendHost}}:sub": "platform:{{platformId}}:project:{{projectId}}" }
+ }
+ }]
+}
+\`\`\`
+3. Attach the **AmazonRedshiftDataFullAccess** policy to the role and paste the **Role ARN** below.
+4. Fill in **Workgroup Name** for Serverless, or **Cluster Identifier** for a provisioned cluster.
+5. For Serverless, add a tag with the key \`RedshiftDataFullAccess\` (any value) to your workgroup. **AmazonRedshiftDataFullAccess** only lets the role sign in to workgroups that carry this tag.
+
+For Serverless, the role signs in to the database as \`IAMR:<role name>\`. Grant that user access to your tables, for example \`GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO "IAMR:MyRole";\`.
+`;
+
+export const redshiftPasswordAuth = PieceAuth.CustomAuth({
+ displayName: 'Username & Password',
+ description: passwordDescription,
+ required: true,
+ props: {
+ host: Property.ShortText({
+ displayName: 'Host',
+ description: 'The endpoint without the port and database.',
+ placeholder: 'my-workgroup.123456789012.us-east-1.redshift-serverless.amazonaws.com',
+ required: true,
+ }),
+ port: Property.Number({
+ displayName: 'Port',
+ description: 'Usually 5439.',
+ defaultValue: 5439,
+ required: true,
+ }),
+ database: Property.ShortText({
+ displayName: 'Database',
+ description: 'The database to connect to. New Redshift databases are named "dev".',
+ defaultValue: 'dev',
+ required: true,
+ }),
+ user: Property.ShortText({
+ displayName: 'Username',
+ description: 'The database user to sign in as.',
+ required: true,
+ }),
+ password: PieceAuth.SecretText({
+ displayName: 'Password',
+ description: 'The password for that user.',
+ required: true,
+ }),
+ enable_ssl: Property.Checkbox({
+ displayName: 'Enable SSL',
+ description: 'Encrypt the connection and verify the server certificate. Keep it on unless your cluster has SSL turned off.',
+ defaultValue: true,
+ required: true,
+ }),
+ },
+ validate: async ({ auth, server }) => {
+ try {
+ await redshiftClient.runSql({ auth: { type: AppConnectionType.CUSTOM_AUTH, props: auth }, server, sql: 'SELECT 1' });
+ return { valid: true };
+ } catch (error) {
+ return { valid: false, error: error instanceof Error ? error.message : String(error) };
+ }
+ },
+});
+
+export const redshiftIamAuth = PieceAuth.OIDC({
+ displayName: 'IAM Role (OIDC)',
+ description: iamDescription,
+ required: true,
+ props: {
+ roleArn: Property.ShortText({
+ displayName: 'Role ARN',
+ description: 'ARN of the IAM role to assume, for example arn:aws:iam::123456789012:role/MyRole.',
+ required: true,
+ }),
+ region: Property.StaticDropdown({
+ displayName: 'Region',
+ description: 'The AWS region your cluster or workgroup is in.',
+ required: true,
+ defaultValue: 'us-east-1',
+ options: { options: AWS_REGIONS },
+ }),
+ database: Property.ShortText({
+ displayName: 'Database',
+ description: 'The database to connect to. New Redshift databases are named "dev".',
+ defaultValue: 'dev',
+ required: true,
+ }),
+ workgroupName: Property.ShortText({
+ displayName: 'Workgroup Name (Serverless)',
+ description: 'Fill this for Redshift Serverless. Leave empty for a provisioned cluster.',
+ required: false,
+ }),
+ clusterIdentifier: Property.ShortText({
+ displayName: 'Cluster Identifier (provisioned)',
+ description: 'Fill this for a provisioned cluster. Leave empty for Serverless.',
+ required: false,
+ }),
+ dbUser: Property.ShortText({
+ displayName: 'Database User (provisioned, optional)',
+ description: 'Sign in to a provisioned cluster as this database user. Leave empty to sign in as the IAM role.',
+ required: false,
+ }),
+ secretArn: Property.ShortText({
+ displayName: 'Secrets Manager ARN (optional)',
+ description: 'Sign in with the username and password stored in this secret instead of the IAM identity.',
+ required: false,
+ }),
+ },
+ validate: async ({ auth, server }) => {
+ if (!ROLE_ARN.test(auth.roleArn.trim())) {
+ return { valid: false, error: 'Invalid IAM Role ARN. Expected: arn:aws:iam::123456789012:role/RoleName' };
+ }
+ const hasWorkgroup = Boolean(auth.workgroupName?.trim());
+ const hasCluster = Boolean(auth.clusterIdentifier?.trim());
+ if (hasWorkgroup === hasCluster) {
+ return { valid: false, error: 'Fill exactly one of Workgroup Name (Serverless) or Cluster Identifier (provisioned).' };
+ }
+ try {
+ await redshiftClient.runSql({ auth: { type: AppConnectionType.OIDC, props: auth }, server, sql: 'SELECT 1' });
+ return { valid: true };
+ } catch (error) {
+ if (isPieceServerContextError(error)) {
+ throw error;
+ }
+ return { valid: false, error: error instanceof Error ? error.message : String(error) };
+ }
+ },
+});
+
+export const redshiftAuth = [redshiftPasswordAuth, redshiftIamAuth];
diff --git a/packages/pieces/community/amazon-redshift/src/lib/common/client.ts b/packages/pieces/community/amazon-redshift/src/lib/common/client.ts
new file mode 100644
index 00000000000..a0727b384af
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/common/client.ts
@@ -0,0 +1,299 @@
+import { AppConnectionType, AuthValidationServerContext, ServerContext, tryCatch } from '@activepieces/pieces-framework';
+import {
+ CancelStatementCommand,
+ DescribeStatementCommand,
+ DescribeStatementResponse,
+ ExecuteStatementCommand,
+ Field,
+ GetStatementResultCommand,
+ RedshiftDataClient,
+ SqlParameter,
+} from '@aws-sdk/client-redshift-data';
+import { AssumeRoleWithWebIdentityCommand, STSClient } from '@aws-sdk/client-sts';
+import { Client, CustomTypesConfig, QueryConfig, types } from 'pg';
+import type { RedshiftAuthValue, RedshiftIamProps, RedshiftPasswordProps, RedshiftQueryResult, RedshiftRow } from './types';
+
+async function runSql({ auth, server, sql, params = [] }: RunSqlParams & { auth: RedshiftAuthValue; server: AnyServerContext }): Promise<RedshiftQueryResult> {
+ if (hasMultipleStatements({ sql })) {
+ throw new Error('Run one SQL statement per step. Split the statements over several steps.');
+ }
+ if (auth.type === AppConnectionType.OIDC) {
+ return await runWithDataApi({ props: auth.props, server, sql, params });
+ }
+ return await runWithPg({ props: auth.props, sql, params });
+}
+
+async function runWithPg({ props, sql, params }: SqlStatement & { props: RedshiftPasswordProps }): Promise<RedshiftQueryResult> {
+ const client = new Client({
+ host: props.host,
+ port: Number(props.port),
+ user: props.user,
+ password: props.password,
+ database: props.database,
+ ssl: props.enable_ssl ? { rejectUnauthorized: true } : undefined,
+ connectionTimeoutMillis: CONNECT_TIMEOUT_MS,
+ query_timeout: QUERY_TIMEOUT_MS,
+ types: redshiftTypeParsers(),
+ });
+ client.on('error', () => undefined);
+ await client.connect();
+ try {
+ const query: QueryConfig & { queryMode: 'extended' } = { text: sql, values: params, queryMode: 'extended' };
+ const result = await client.query<RedshiftRow>(query);
+ return { rows: result.rows, rowCount: result.rowCount ?? result.rows.length };
+ } finally {
+ await client.end();
+ }
+}
+
+function redshiftTypeParsers(): CustomTypesConfig {
+ return {
+ getTypeParser: (oid: number, format?: 'text' | 'binary') => {
+ if (RAW_TEXT_TYPE_OIDS.includes(oid)) {
+ return (value: string) => value;
+ }
+ if (oid === BIGINT_TYPE_OID) {
+ return parseBigint;
+ }
+ return types.getTypeParser(oid, format);
+ },
+ };
+}
+
+function parseBigint(value: string): number | string {
+ const parsed = Number(value);
+ return Number.isSafeInteger(parsed) ? parsed : value;
+}
+
+async function runWithDataApi({ props, server, sql, params }: SqlStatement & { props: RedshiftIamProps; server: AnyServerContext }): Promise<RedshiftQueryResult> {
+ const credentials = await getTemporaryCredentials({ props, server });
+ const client = new RedshiftDataClient({ region: props.region, credentials });
+ client.middlewareStack.add(
+ (next) => async (args) => {
+ const result = await next(args);
+ await keepLargeIntegersAsText({ response: result.response });
+ return result;
+ },
+ { step: 'deserialize', priority: 'low', name: 'keepLargeIntegersAsText' },
+ );
+ const { text, parameters } = toNamedParameters({ sql, params });
+ const started = await client.send(
+ new ExecuteStatementCommand({
+ Sql: text,
+ Database: props.database,
+ WorkgroupName: nonEmpty(props.workgroupName),
+ ClusterIdentifier: nonEmpty(props.clusterIdentifier),
+ DbUser: nonEmpty(props.dbUser),
+ SecretArn: nonEmpty(props.secretArn),
+ Parameters: parameters.length > 0 ? parameters : undefined,
+ }),
+ );
+ if (!started.Id) {
+ throw new Error('Redshift did not return a statement id.');
+ }
+ const statement = await waitForStatement({ client, id: started.Id, deadline: Date.now() + QUERY_TIMEOUT_MS });
+ if (!statement.HasResultSet) {
+ return { rows: [], rowCount: Math.max(statement.ResultRows ?? 0, 0) };
+ }
+ const rows = await readRows({ client, id: started.Id });
+ return { rows, rowCount: rows.length };
+}
+
+async function keepLargeIntegersAsText({ response }: { response: unknown }): Promise<void> {
+ if (typeof response !== 'object' || response === null || !('body' in response) || !isByteStream(response.body)) {
+ return;
+ }
+ const chunks: Uint8Array[] = [];
+ for await (const chunk of response.body) {
+ chunks.push(chunk);
+ }
+ response.body = Buffer.from(
+ Buffer.concat(chunks)
+ .toString('utf8')
+ .replace(LONG_VALUE_FIELD, (match: string, digits: string) => (Number.isSafeInteger(Number(digits)) ? match : `"stringValue":"${digits}"`)),
+ );
+}
+
+function isByteStream(body: unknown): body is AsyncIterable<Uint8Array> {
+ return typeof body === 'object' && body !== null && Symbol.asyncIterator in body;
+}
+
+async function waitForStatement({ client, id, deadline }: { client: RedshiftDataClient; id: string; deadline: number }): Promise<DescribeStatementResponse> {
+ const statement = await client.send(new DescribeStatementCommand({ Id: id }));
+ if (statement.Status === 'FINISHED') {
+ return statement;
+ }
+ if (statement.Status === 'FAILED' || statement.Status === 'ABORTED') {
+ throw new Error(statement.Error ?? `The query was ${statement.Status.toLowerCase()}.`);
+ }
+ if (Date.now() > deadline) {
+ const { error } = await tryCatch(() => client.send(new CancelStatementCommand({ Id: id })));
+ throw new Error(
+ error
+ ? `The query did not finish within ${QUERY_TIMEOUT_MS / 1000} seconds and could not be cancelled, so it may still complete in Redshift (statement id ${id}).`
+ : `The query did not finish within ${QUERY_TIMEOUT_MS / 1000} seconds and was cancelled.`,
+ );
+ }
+ await new Promise((resolve) => setTimeout(resolve, STATEMENT_POLL_INTERVAL_MS));
+ return await waitForStatement({ client, id, deadline });
+}
+
+async function readRows({ client, id }: { client: RedshiftDataClient; id: string }): Promise<RedshiftRow[]> {
+ const rows: RedshiftRow[] = [];
+ let nextToken: string | undefined;
+ do {
+ const page = await client.send(new GetStatementResultCommand({ Id: id, NextToken: nextToken }));
+ const names = (page.ColumnMetadata ?? []).map((column, index) => column.label ?? column.name ?? `column_${index + 1}`);
+ rows.push(...(page.Records ?? []).map((record) => Object.fromEntries(record.map((field, index) => [names[index], fieldValue({ field })]))));
+ nextToken = page.NextToken;
+ } while (nextToken);
+ return rows;
+}
+
+function fieldValue({ field }: { field: Field }): unknown {
+ if (field.isNull) {
+ return null;
+ }
+ return field.stringValue ?? field.longValue ?? field.doubleValue ?? field.booleanValue ?? field.blobValue ?? null;
+}
+
+function toNamedParameters({ sql, params }: { sql: string; params: unknown[] }): { text: string; parameters: SqlParameter[] } {
+ const used = new Set<number>();
+ const text = sql.replace(SQL_TOKENS, (match: string) => {
+ const placeholder = ARG_PLACEHOLDER.exec(match);
+ if (!placeholder) {
+ return match;
+ }
+ const index = Number(placeholder[1]) - 1;
+ if (index < 0 || index >= params.length) {
+ throw new Error(`The query uses ${match} but only ${params.length} argument(s) were given.`);
+ }
+ const value = params[index];
+ if (value === null || value === undefined) {
+ return 'NULL';
+ }
+ used.add(index);
+ return `:p${index + 1}`;
+ });
+ const parameters = [...used].map((index) => ({ name: `p${index + 1}`, value: toText({ value: params[index] }) }));
+ return { text, parameters };
+}
+
+function hasMultipleStatements({ sql }: { sql: string }): boolean {
+ return sql.replace(SKIPPED_SQL, ' ').replace(/[\s;]+$/, '').includes(';');
+}
+
+function toText({ value }: { value: unknown }): string {
+ if (typeof value === 'string') {
+ return value;
+ }
+ if (typeof value === 'object') {
+ return JSON.stringify(value);
+ }
+ return String(value);
+}
+
+function nonEmpty(value: string | undefined): string | undefined {
+ const trimmed = value?.trim();
+ return trimmed ? trimmed : undefined;
+}
+
+async function getTemporaryCredentials({ props, server }: { props: RedshiftIamProps; server: AnyServerContext }): Promise<TemporaryCredentials> {
+ const cacheKey = 'token' in server ? `${server.token}:${props.roleArn}:${props.region}` : undefined;
+ const cached = cacheKey ? credentialsCache.get(cacheKey) : undefined;
+ if (cached && cached.expiresAtMS - Date.now() > CREDENTIALS_EXPIRY_MARGIN_MS) {
+ return cached.credentials;
+ }
+ const token = await resolveOidcToken({ server });
+ const sts = new STSClient({
+ region: props.region,
+ maxAttempts: 2,
+ requestHandler: { requestTimeout: STS_REQUEST_TIMEOUT_MS, connectionTimeout: STS_CONNECT_TIMEOUT_MS },
+ });
+ const { Credentials } = await sts.send(
+ new AssumeRoleWithWebIdentityCommand({
+ RoleArn: props.roleArn.trim(),
+ RoleSessionName: 'activepieces-execution',
+ WebIdentityToken: token,
+ DurationSeconds: STS_DURATION_SECONDS,
+ }),
+ );
+ if (!Credentials?.AccessKeyId || !Credentials.SecretAccessKey) {
+ throw new Error('Failed to assume role: no credentials returned.');
+ }
+ const credentials = {
+ accessKeyId: Credentials.AccessKeyId,
+ secretAccessKey: Credentials.SecretAccessKey,
+ sessionToken: Credentials.SessionToken,
+ };
+ if (cacheKey) {
+ sweepExpiredCredentials();
+ credentialsCache.set(cacheKey, { credentials, expiresAtMS: Credentials.Expiration?.getTime() ?? Date.now() + STS_DURATION_SECONDS * 1000 });
+ }
+ return credentials;
+}
+
+async function resolveOidcToken({ server }: { server: AnyServerContext }): Promise<string> {
+ if ('mintOidcToken' in server) {
+ return await server.mintOidcToken({ audience: AWS_STS_AUDIENCE });
+ }
+ const baseUrl = server.apiUrl.endsWith('/') ? server.apiUrl : `${server.apiUrl}/`;
+ const response = await fetch(`${baseUrl}v1/worker/oidc-token`, {
+ method: 'POST',
+ headers: { Authorization: `Bearer ${server.token}`, 'Content-Type': 'application/json' },
+ body: JSON.stringify({ audience: AWS_STS_AUDIENCE }),
+ });
+ if (!response.ok) {
+ throw new Error(`Failed to get an OIDC token: ${response.statusText}`);
+ }
+ const body: { token?: string } = await response.json();
+ if (!body.token) {
+ throw new Error('Failed to get an OIDC token: empty response.');
+ }
+ return body.token;
+}
+
+function sweepExpiredCredentials(): void {
+ const now = Date.now();
+ credentialsCache.forEach((value, key) => {
+ if (value.expiresAtMS <= now) {
+ credentialsCache.delete(key);
+ }
+ });
+}
+
+export const redshiftClient = { runSql };
+
+const RAW_TEXT_TYPE_OIDS = [1082, 1083, 1114, 1184, 1266];
+const BIGINT_TYPE_OID = 20;
+const LONG_VALUE_FIELD = /"longValue":(-?\d+)/g;
+const SKIPPED_SQL_TEXT = String.raw`'(?:[^'\\]|''|\\[\s\S])*'|"(?:[^"]|"")*"|\$(?<tag>[A-Za-z_][A-Za-z_0-9]*|)\$[\s\S]*?\$\k<tag>\$|--[^\n]*|\/\*[\s\S]*?\*\/`;
+const SKIPPED_SQL = new RegExp(SKIPPED_SQL_TEXT, 'g');
+const SQL_TOKENS = new RegExp(`${SKIPPED_SQL_TEXT}|\\$\\d+`, 'g');
+const ARG_PLACEHOLDER = /^\$(\d+)$/;
+const CONNECT_TIMEOUT_MS = 30_000;
+const QUERY_TIMEOUT_MS = 300_000;
+const STATEMENT_POLL_INTERVAL_MS = 1_000;
+const AWS_STS_AUDIENCE = 'sts.amazonaws.com';
+const STS_DURATION_SECONDS = 3600;
+const STS_REQUEST_TIMEOUT_MS = 10_000;
+const STS_CONNECT_TIMEOUT_MS = 5_000;
+const CREDENTIALS_EXPIRY_MARGIN_MS = 5 * 60 * 1000;
+const credentialsCache = new Map<string, CachedCredentials>();
+
+type AnyServerContext = ServerContext | AuthValidationServerContext;
+
+type RunSqlParams = { sql: string; params?: unknown[] };
+
+type SqlStatement = { sql: string; params: unknown[] };
+
+type TemporaryCredentials = {
+ accessKeyId: string;
+ secretAccessKey: string;
+ sessionToken: string | undefined;
+};
+
+type CachedCredentials = {
+ credentials: TemporaryCredentials;
+ expiresAtMS: number;
+};
diff --git a/packages/pieces/community/amazon-redshift/src/lib/common/props.ts b/packages/pieces/community/amazon-redshift/src/lib/common/props.ts
new file mode 100644
index 00000000000..0b323b7d863
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/common/props.ts
@@ -0,0 +1,133 @@
+import { DropdownState, InputPropertyMap, PropertyContext, Property } from '@activepieces/pieces-framework';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from './client';
+import type { RedshiftAuthValue, RedshiftColumn, RedshiftTable } from './types';
+
+function table<R extends boolean>({ required, displayName = 'Table', description = 'The table to use.' }: PropParams<R>) {
+ return Property.Dropdown<RedshiftTable, R, typeof redshiftAuth>({
+ auth: redshiftAuth,
+ displayName,
+ description,
+ required,
+ refreshers: [],
+ options: async ({ auth }, { server }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: 'Please connect your account first.' });
+ }
+ const { rows } = await redshiftClient.runSql({
+ auth,
+ server,
+ sql: `SELECT table_schema, table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'information_schema', 'pg_internal') ORDER BY table_schema, table_name`,
+ });
+ const tables = rows.map((row) => ({ table_schema: String(row['table_schema']), table_name: String(row['table_name']) }));
+ return {
+ disabled: false,
+ options: tables.map((item) => ({ label: `${item.table_schema}.${item.table_name}`, value: item })),
+ placeholder: tables.length === 0 ? 'No tables found.' : undefined,
+ };
+ },
+ });
+}
+
+function column<R extends boolean>({ required, displayName = 'Column', description }: PropParams<R>) {
+ return Property.Dropdown<string, R, typeof redshiftAuth>({
+ auth: redshiftAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['table'],
+ options: async ({ auth, table }, { server }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: 'Please connect your account first.' });
+ }
+ if (!isTable(table)) {
+ return disabledOptions({ placeholder: 'Please select a table first.' });
+ }
+ const columns = await listColumns({ auth, server, table });
+ return { disabled: false, options: columns.map((item) => ({ label: `${item.column_name} (${item.data_type})`, value: item.column_name })) };
+ },
+ });
+}
+
+function rows<R extends boolean>({ required, displayName = 'Rows', description }: PropParams<R>) {
+ return Property.DynamicProperties({
+ auth: redshiftAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['table'],
+ props: async ({ auth, table }, { server }): Promise<InputPropertyMap> => {
+ if (!auth || !isTable(table)) {
+ return {};
+ }
+ const columns = await listColumns({ auth, server, table });
+ return {
+ rows: Property.Array({
+ displayName: 'Rows',
+ description: 'One item per row. Leave a field empty to use the column default.',
+ required: true,
+ properties: Object.fromEntries(
+ columns.map((item) => [
+ item.column_name,
+ Property.ShortText({ displayName: item.column_name, description: describeColumn({ column: item }), required: isRequiredColumn({ column: item }) }),
+ ]),
+ ),
+ }),
+ };
+ },
+ });
+}
+
+function values<R extends boolean>({ required, displayName = 'New Values', description = 'Only the fields you fill are changed.' }: PropParams<R>) {
+ return Property.DynamicProperties({
+ auth: redshiftAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['table'],
+ props: async ({ auth, table }, { server }): Promise<InputPropertyMap> => {
+ if (!auth || !isTable(table)) {
+ return {};
+ }
+ const columns = await listColumns({ auth, server, table });
+ return Object.fromEntries(
+ columns.map((item) => [item.column_name, Property.ShortText({ displayName: item.column_name, description: item.data_type, required: false })]),
+ );
+ },
+ });
+}
+
+async function listColumns({ auth, server, table }: { auth: RedshiftAuthValue; server: PropertyContext['server']; table: RedshiftTable }): Promise<RedshiftColumn[]> {
+ const { rows: columns } = await redshiftClient.runSql({
+ auth,
+ server,
+ sql: 'SELECT column_name, data_type, is_nullable, column_default FROM information_schema.columns WHERE table_schema = $1 AND table_name = $2 ORDER BY ordinal_position',
+ params: [table.table_schema, table.table_name],
+ });
+ return columns.map((row) => ({
+ column_name: String(row['column_name']),
+ data_type: String(row['data_type']),
+ is_nullable: String(row['is_nullable']),
+ column_default: row['column_default'] === null || row['column_default'] === undefined ? null : String(row['column_default']),
+ }));
+}
+
+function isTable(value: unknown): value is RedshiftTable {
+ return typeof value === 'object' && value !== null && 'table_schema' in value && 'table_name' in value && typeof value.table_schema === 'string' && typeof value.table_name === 'string';
+}
+
+function isRequiredColumn({ column }: { column: RedshiftColumn }): boolean {
+ return column.is_nullable === 'NO' && column.column_default === null;
+}
+
+function describeColumn({ column }: { column: RedshiftColumn }): string {
+ return isRequiredColumn({ column }) ? `${column.data_type} · required` : column.data_type;
+}
+
+function disabledOptions({ placeholder }: { placeholder: string }): DropdownState<never> {
+ return { disabled: true, options: [], placeholder };
+}
+
+export const redshiftProps = { table, column, rows, values };
+
+export type PropParams<R extends boolean> = { required: R; displayName?: string; description?: string };
diff --git a/packages/pieces/community/amazon-redshift/src/lib/common/types.ts b/packages/pieces/community/amazon-redshift/src/lib/common/types.ts
new file mode 100644
index 00000000000..6cc611da04f
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/common/types.ts
@@ -0,0 +1,43 @@
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+
+export type RedshiftPasswordProps = {
+ host: string;
+ port: number;
+ database: string;
+ user: string;
+ password: string;
+ enable_ssl: boolean;
+};
+
+export type RedshiftIamProps = {
+ roleArn: string;
+ region: string;
+ database: string;
+ workgroupName: string | undefined;
+ clusterIdentifier: string | undefined;
+ dbUser: string | undefined;
+ secretArn: string | undefined;
+};
+
+export type RedshiftAuthValue =
+ | { type: AppConnectionType.CUSTOM_AUTH; props: RedshiftPasswordProps }
+ | { type: AppConnectionType.OIDC; props: RedshiftIamProps };
+
+export type RedshiftTable = {
+ table_schema: string;
+ table_name: string;
+};
+
+export type RedshiftColumn = {
+ column_name: string;
+ data_type: string;
+ is_nullable: string;
+ column_default: string | null;
+};
+
+export type RedshiftRow = Record<string, unknown>;
+
+export type RedshiftQueryResult = {
+ rows: RedshiftRow[];
+ rowCount: number;
+};
diff --git a/packages/pieces/community/amazon-redshift/src/lib/common/utils.ts b/packages/pieces/community/amazon-redshift/src/lib/common/utils.ts
new file mode 100644
index 00000000000..adf543ad107
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/common/utils.ts
@@ -0,0 +1,18 @@
+import type { RedshiftTable } from './types';
+
+function quoteIdentifier({ name }: { name: string }): string {
+ return `"${name.replace(/"/g, '""')}"`;
+}
+
+function qualifiedName({ table }: { table: RedshiftTable }): string {
+ return `${quoteIdentifier({ name: table.table_schema })}.${quoteIdentifier({ name: table.table_name })}`;
+}
+
+function filledFields({ values }: { values: unknown }): Record<string, unknown> {
+ if (typeof values !== 'object' || values === null || Array.isArray(values)) {
+ return {};
+ }
+ return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined && value !== null && value !== ''));
+}
+
+export const redshiftUtils = { quoteIdentifier, qualifiedName, filledFields };
diff --git a/packages/pieces/community/amazon-redshift/src/lib/output-schemas.ts b/packages/pieces/community/amazon-redshift/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..1472f79b78e
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/output-schemas.ts
@@ -0,0 +1,51 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+export const insertRowsOutputSchema: OutputSchema = {
+ fields: [{ key: 'rowCount', label: 'Inserted Row Count', format: 'number' }],
+};
+
+export const updateRowsOutputSchema: OutputSchema = {
+ fields: [{ key: 'rowCount', label: 'Updated Row Count', format: 'number' }],
+};
+
+export const deleteRowsOutputSchema: OutputSchema = {
+ fields: [{ key: 'rowCount', label: 'Deleted Row Count', format: 'number' }],
+};
+
+export const findRowsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'rows', label: 'Rows', description: "The matching rows; each row's fields are the columns of the table." },
+ { key: 'rowCount', label: 'Row Count', format: 'number' },
+ ],
+};
+
+export const newRowOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'row',
+ label: 'Row',
+ value: '',
+ dynamicKey: true,
+ description: 'One new row of the table you selected, with every column it has. Date and time columns arrive as text, exactly as Redshift stores them.',
+ },
+ ],
+};
+
+export const newOrUpdatedRowOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'row',
+ label: 'Row',
+ value: '',
+ dynamicKey: true,
+ description: 'One new or updated row of the table you selected, with every column it has. Date and time columns arrive as text, exactly as Redshift stores them.',
+ },
+ ],
+};
+
+export const runQueryOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'rows', label: 'Rows', description: 'The rows the query returned. Empty for INSERT, UPDATE, DELETE and DDL.' },
+ { key: 'rowCount', label: 'Row Count', description: 'Rows returned, or rows changed by INSERT, UPDATE or DELETE.', format: 'number' },
+ ],
+};
diff --git a/packages/pieces/community/amazon-redshift/src/lib/triggers/new-or-updated-row.ts b/packages/pieces/community/amazon-redshift/src/lib/triggers/new-or-updated-row.ts
new file mode 100644
index 00000000000..782a5d894d0
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/triggers/new-or-updated-row.ts
@@ -0,0 +1,105 @@
+import { createTrigger, StaticPropsValue, TriggerStrategy } from '@activepieces/pieces-framework';
+import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from '../common/client';
+import { redshiftProps } from '../common/props';
+import { redshiftUtils } from '../common/utils';
+import { newOrUpdatedRowOutputSchema } from '../output-schemas';
+import type { RedshiftAuthValue, RedshiftRow } from '../common/types';
+
+const props = {
+ table: redshiftProps.table({ required: true }),
+ timestamp_column: redshiftProps.column({
+ required: true,
+ displayName: 'Updated At Column',
+ description: 'A timestamp column your loads set on every insert and update, like updated_at. Read as UTC.',
+ }),
+};
+
+const MAX_ROWS = 1000;
+
+const polling: Polling<RedshiftAuthValue, StaticPropsValue<typeof props>> = {
+ strategy: DedupeStrategy.TIMEBASED,
+ items: async ({ auth, propsValue, lastFetchEpochMS, server }) => {
+ if (!server) {
+ throw new Error('Missing server context.');
+ }
+ const from = redshiftUtils.qualifiedName({ table: propsValue.table });
+ const column = redshiftUtils.quoteIdentifier({ name: propsValue.timestamp_column });
+ const toEvents = (rows: RedshiftRow[]) =>
+ rows.flatMap((row) => {
+ const epochMilliSeconds = toEpochMs({ value: row[propsValue.timestamp_column] });
+ return epochMilliSeconds === undefined ? [] : [{ epochMilliSeconds, data: row }];
+ });
+ if (lastFetchEpochMS === 0) {
+ const { rows } = await redshiftClient.runSql({ auth, server, sql: `SELECT * FROM ${from} WHERE ${column} IS NOT NULL ORDER BY ${column} DESC LIMIT 5` });
+ return toEvents(rows);
+ }
+ const { rows } = await redshiftClient.runSql({
+ auth,
+ server,
+ sql: `SELECT * FROM ${from} WHERE ${column} >= $1 ORDER BY ${column} ASC LIMIT ${MAX_ROWS}`,
+ params: [toSqlTimestamp({ epochMs: lastFetchEpochMS + 1 })],
+ });
+ const events = toEvents(rows);
+ if (rows.length < MAX_ROWS || events.length === 0) {
+ return events;
+ }
+ const lastEpochMs = events[events.length - 1].epochMilliSeconds;
+ if (events[0].epochMilliSeconds !== lastEpochMs) {
+ return events.filter((event) => event.epochMilliSeconds !== lastEpochMs);
+ }
+ const { rows: sameMillisecond } = await redshiftClient.runSql({
+ auth,
+ server,
+ sql: `SELECT * FROM ${from} WHERE ${column} >= $1 AND ${column} < $2 ORDER BY ${column} ASC`,
+ params: [toSqlTimestamp({ epochMs: lastEpochMs }), toSqlTimestamp({ epochMs: lastEpochMs + 1 })],
+ });
+ return toEvents(sameMillisecond);
+ },
+};
+
+function toSqlTimestamp({ epochMs }: { epochMs: number }): string {
+ return new Date(epochMs).toISOString();
+}
+
+function toEpochMs({ value }: { value: unknown }): number | undefined {
+ if (value instanceof Date) {
+ return value.getTime();
+ }
+ if (typeof value !== 'string' || value.trim() === '') {
+ return undefined;
+ }
+ const text = value.trim().replace(' ', 'T');
+ const withTime = /^\d{4}-\d{2}-\d{2}$/.test(text) ? `${text}T00:00:00` : text;
+ const withZone = /([zZ]|[+-]\d{2}(:?\d{2})?)$/.test(withTime) ? withTime.replace(/([+-]\d{2})$/, '$1:00') : `${withTime}Z`;
+ const epoch = Date.parse(withZone);
+ return Number.isNaN(epoch) ? undefined : epoch;
+}
+
+export const newOrUpdatedRow = createTrigger({
+ auth: redshiftAuth,
+ name: 'new_or_updated_row',
+ classification: 'READ',
+ displayName: 'New or Updated Row',
+ description: 'Triggers when a row is added or its timestamp column changes.',
+ aiMetadata: {
+ description: 'Fires once for each row in an Amazon Redshift table whose chosen timestamp column (such as updated_at) moved past the last check, so it covers both new and updated rows. Each event carries one row.',
+ },
+ props,
+ sampleData: { id: 1, name: 'Example', updated_at: '2026-01-01 00:00:00' },
+ outputSchema: newOrUpdatedRowOutputSchema,
+ type: TriggerStrategy.POLLING,
+ async test(context) {
+ return await pollingHelper.test(polling, context);
+ },
+ async onEnable(context) {
+ await pollingHelper.onEnable(polling, context);
+ },
+ async onDisable(context) {
+ await pollingHelper.onDisable(polling, context);
+ },
+ async run(context) {
+ return await pollingHelper.poll(polling, context);
+ },
+});
diff --git a/packages/pieces/community/amazon-redshift/src/lib/triggers/new-row.ts b/packages/pieces/community/amazon-redshift/src/lib/triggers/new-row.ts
new file mode 100644
index 00000000000..b0fbfa65ed5
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/src/lib/triggers/new-row.ts
@@ -0,0 +1,94 @@
+import { createTrigger, isNil, ServerContext, StaticPropsValue, TriggerStrategy } from '@activepieces/pieces-framework';
+import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';
+import { redshiftAuth } from '../auth';
+import { redshiftClient } from '../common/client';
+import { redshiftProps } from '../common/props';
+import { redshiftUtils } from '../common/utils';
+import { newRowOutputSchema } from '../output-schemas';
+import type { RedshiftAuthValue, RedshiftRow } from '../common/types';
+
+const props = {
+ table: redshiftProps.table({ required: true }),
+ order_by: redshiftProps.column({
+ required: true,
+ displayName: 'Order By Column',
+ description: 'A unique column that grows with every new row, ideally an auto-increment id. Rows that share a value with an earlier row, or that commit after a row with a higher value, can be missed, so avoid timestamps.',
+ }),
+};
+
+const MAX_ROWS = 1000;
+const EMPTY_TABLE_CURSOR = 0;
+
+const polling: Polling<RedshiftAuthValue, StaticPropsValue<typeof props>> = {
+ strategy: DedupeStrategy.LAST_ITEM,
+ items: async ({ auth, propsValue, lastItemId, server }) => {
+ if (!server) {
+ throw new Error('Missing server context.');
+ }
+ const from = redshiftUtils.qualifiedName({ table: propsValue.table });
+ const column = redshiftUtils.quoteIdentifier({ name: propsValue.order_by });
+ const keyOf = (row: RedshiftRow) => String(row[propsValue.order_by]);
+ if (lastItemId === EMPTY_TABLE_CURSOR) {
+ return await fetchNewItems({ auth, server, from, column, keyOf, filter: `${column} IS NOT NULL`, params: [] });
+ }
+ if (typeof lastItemId !== 'string') {
+ const { rows } = await redshiftClient.runSql({ auth, server, sql: `SELECT * FROM ${from} WHERE ${column} IS NOT NULL ORDER BY ${column} DESC LIMIT 5` });
+ return rows.map((row) => ({ id: keyOf(row), data: row }));
+ }
+ return await fetchNewItems({ auth, server, from, column, keyOf, filter: `${column} > $1`, params: [lastItemId] });
+ },
+};
+
+async function fetchNewItems({ auth, server, from, column, keyOf, filter, params }: FetchNewItemsParams): Promise<{ id: string; data: RedshiftRow }[]> {
+ const toItems = (rows: RedshiftRow[]) => rows.map((row) => ({ id: keyOf(row), data: row }));
+ const { rows } = await redshiftClient.runSql({ auth, server, sql: `SELECT * FROM ${from} WHERE ${filter} ORDER BY ${column} ASC LIMIT ${MAX_ROWS}`, params });
+ if (rows.length < MAX_ROWS) {
+ return toItems(rows).reverse();
+ }
+ const lastKey = keyOf(rows[rows.length - 1]);
+ if (keyOf(rows[0]) !== lastKey) {
+ return toItems(rows.filter((row) => keyOf(row) !== lastKey)).reverse();
+ }
+ const { rows: sameKey } = await redshiftClient.runSql({ auth, server, sql: `SELECT * FROM ${from} WHERE ${column} = $1`, params: [lastKey] });
+ return toItems(sameKey);
+}
+
+export const newRow = createTrigger({
+ auth: redshiftAuth,
+ name: 'new_row',
+ classification: 'READ',
+ displayName: 'New Row',
+ description: 'Triggers when a new row is added to a table.',
+ aiMetadata: {
+ description: 'Fires once for each new row in an Amazon Redshift table, found by polling and ordering on a column that grows with every insert (an id or created timestamp). Each event carries one row.',
+ },
+ props,
+ sampleData: { id: 1, name: 'Example', created_at: '2026-01-01 00:00:00' },
+ outputSchema: newRowOutputSchema,
+ type: TriggerStrategy.POLLING,
+ async test(context) {
+ return await pollingHelper.test(polling, context);
+ },
+ async onEnable(context) {
+ await pollingHelper.onEnable(polling, context);
+ if (isNil(await context.store.get('lastItem'))) {
+ await context.store.put('lastItem', EMPTY_TABLE_CURSOR);
+ }
+ },
+ async onDisable(context) {
+ await pollingHelper.onDisable(polling, context);
+ },
+ async run(context) {
+ return await pollingHelper.poll(polling, context);
+ },
+});
+
+type FetchNewItemsParams = {
+ auth: RedshiftAuthValue;
+ server: ServerContext;
+ from: string;
+ column: string;
+ keyOf: (row: RedshiftRow) => string;
+ filter: string;
+ params: unknown[];
+};
diff --git a/packages/pieces/community/amazon-redshift/tsconfig.json b/packages/pieces/community/amazon-redshift/tsconfig.json
new file mode 100644
index 00000000000..7bef1d12501
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../../../../tsconfig.base.json",
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ }
+ ],
+ "compilerOptions": {
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true
+ }
+}
diff --git a/packages/pieces/community/amazon-redshift/tsconfig.lib.json b/packages/pieces/community/amazon-redshift/tsconfig.lib.json
new file mode 100644
index 00000000000..0ba4caeb858
--- /dev/null
+++ b/packages/pieces/community/amazon-redshift/tsconfig.lib.json
@@ -0,0 +1,15 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "module": "commonjs",
+ "rootDir": ".",
+ "baseUrl": ".",
+ "paths": {},
+ "outDir": "./dist",
+ "declaration": true,
+ "declarationMap": true,
+ "types": ["node"]
+ },
+ "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
+ "include": ["src/**/*.ts"]
+}
diff --git a/tsconfig.base.json b/tsconfig.base.json
index bcf68bf14bb..17a52afe3bf 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -78,6 +78,9 @@
"@activepieces/piece-amazon-lambda": [
"packages/pieces/community/amazon-lambda/src/index.ts"
],
+ "@activepieces/piece-amazon-redshift": [
+ "packages/pieces/community/amazon-redshift/src/index.ts"
+ ],
"@activepieces/piece-amazon-s3": [
"packages/pieces/community/amazon-s3/src/index.ts"
],