Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,33 @@
{
"extends": [
"../../../../.eslintrc.base.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {}
},
{
"files": [
"*.ts",
"*.tsx"
],
"rules": {}
},
{
"files": [
"*.js",
"*.jsx"
],
"rules": {}
}
]
}

View File

@@ -0,0 +1,7 @@
# pieces-couchbase
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build pieces-couchbase` to build the library.

View File

@@ -0,0 +1,197 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"name": "@activepieces/piece-couchbase",
"dependencies": {
"couchbase": "^4.6.0",
"tslib": "^2.3.0",
},
},
},
"packages": {
"@couchbase/couchbase-darwin-arm64-napi": ["@couchbase/couchbase-darwin-arm64-napi@4.6.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-zSL/I4tipdgszW8Yz3P5KxVKoZruHsUdeE01CrkEPOZh23xpbFRj0RQSM3eIuxy5AsBkg1aFq5icY0Yqmt1g9g=="],
"@couchbase/couchbase-darwin-x64-napi": ["@couchbase/couchbase-darwin-x64-napi@4.6.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-rn5NaWee//FFWtslivULMHVr1yzoAxkvxmvaAhf8VTHLRQuCxzgF2c6vzHisq9ztIdNfVwCHUrr7+A5ocfKpSg=="],
"@couchbase/couchbase-linux-arm64-napi": ["@couchbase/couchbase-linux-arm64-napi@4.6.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-AcAxOzuMJ8cFEiCshY/GUWBiviAtx/YGzaHWGyMds0jKgfm8HD1UquLnyic1KnrjB6wXflIDDKSVQ12uBTb2eQ=="],
"@couchbase/couchbase-linux-x64-napi": ["@couchbase/couchbase-linux-x64-napi@4.6.0", "", { "os": "linux", "cpu": "x64" }, "sha512-Q9fXaD/McHUDKcINYyRrsbSk5lUrWL+XkLoV69aKo3DTqwRWAw7JuDjM87hOM1mIBbT9cPYtOaHzDiwkX3SJ5w=="],
"@couchbase/couchbase-linuxmusl-arm64-napi": ["@couchbase/couchbase-linuxmusl-arm64-napi@4.6.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-GzrLNC34DP3Ac4hzd5R81Xz6VWVGJHmqzHcZGchaAJblUlG1l+ni2eGU4X2KG3t9pSAmBCfu7FsELZDaoYZibQ=="],
"@couchbase/couchbase-linuxmusl-x64-napi": ["@couchbase/couchbase-linuxmusl-x64-napi@4.6.0", "", { "os": "linux", "cpu": "x64" }, "sha512-v6t93c3LJg+ZgpLc+yG7bSKYNb7QPizh5CApU5GpeurPnyK2Osp9CV5JCY3OMSbZuK9zWkRgMIzQN/AJNKNbZQ=="],
"@couchbase/couchbase-win32-x64-napi": ["@couchbase/couchbase-win32-x64-napi@4.6.0", "", { "os": "win32", "cpu": "x64" }, "sha512-T1zLkY3EugmBhWOOhn22hfs0gD/yBpFza0ReePTwxYU93cxKofx3Sh5+QQWebsrOablYJy7lt4o3oLtGqYwu8g=="],
"ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
"ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
"aproba": ["aproba@2.1.0", "", {}, "sha512-tLIEcj5GuR2RSTnxNKdkK0dJ/GrC7P38sUkiDmDuHfsHmbagTFAxDVIBltoklXEVIQ/f14IL8IMJ5pn9Hez1Ew=="],
"are-we-there-yet": ["are-we-there-yet@3.0.1", "", { "dependencies": { "delegates": "^1.0.0", "readable-stream": "^3.6.0" } }, "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg=="],
"asynckit": ["asynckit@0.4.0", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
"axios": ["axios@1.13.2", "", { "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA=="],
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
"chownr": ["chownr@2.0.0", "", {}, "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="],
"cliui": ["cliui@8.0.1", "", { "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" } }, "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ=="],
"cmake-js": ["cmake-js@7.4.0", "", { "dependencies": { "axios": "^1.6.5", "debug": "^4", "fs-extra": "^11.2.0", "memory-stream": "^1.0.0", "node-api-headers": "^1.1.0", "npmlog": "^6.0.2", "rc": "^1.2.7", "semver": "^7.5.4", "tar": "^6.2.0", "url-join": "^4.0.1", "which": "^2.0.2", "yargs": "^17.7.2" }, "bin": { "cmake-js": "bin/cmake-js" } }, "sha512-Lw0JxEHrmk+qNj1n9W9d4IvkDdYTBn7l2BW6XmtLj7WPpIo2shvxUy+YokfjMxAAOELNonQwX3stkPhM5xSC2Q=="],
"color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
"color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
"color-support": ["color-support@1.1.3", "", { "bin": { "color-support": "bin.js" } }, "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg=="],
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
"console-control-strings": ["console-control-strings@1.1.0", "", {}, "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ=="],
"couchbase": ["couchbase@4.6.0", "", { "dependencies": { "cmake-js": "^7.3.1", "node-addon-api": "^8.3.1" }, "optionalDependencies": { "@couchbase/couchbase-darwin-arm64-napi": "4.6.0", "@couchbase/couchbase-darwin-x64-napi": "4.6.0", "@couchbase/couchbase-linux-arm64-napi": "4.6.0", "@couchbase/couchbase-linux-x64-napi": "4.6.0", "@couchbase/couchbase-linuxmusl-arm64-napi": "4.6.0", "@couchbase/couchbase-linuxmusl-x64-napi": "4.6.0", "@couchbase/couchbase-win32-x64-napi": "4.6.0" } }, "sha512-2rW9a61ktoJTczjmb+TWXzqcTe0nGQWH6wjyzWrfZXZdvuNRDrnM/Sf+Ao3OAtol0jc7YJD7OPw5WoT3mv1G/Q=="],
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
"deep-extend": ["deep-extend@0.6.0", "", {}, "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="],
"delayed-stream": ["delayed-stream@1.0.0", "", {}, "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
"delegates": ["delegates@1.0.0", "", {}, "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ=="],
"dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
"emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
"es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
"es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
"es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
"es-set-tostringtag": ["es-set-tostringtag@2.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="],
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
"follow-redirects": ["follow-redirects@1.15.11", "", {}, "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ=="],
"form-data": ["form-data@4.0.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="],
"fs-extra": ["fs-extra@11.3.2", "", { "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" } }, "sha512-Xr9F6z6up6Ws+NjzMCZc6WXg2YFRlrLP9NQDO3VQrWrfiojdhS56TzueT88ze0uBdCTwEIhQ3ptnmKeWGFAe0A=="],
"fs-minipass": ["fs-minipass@2.1.0", "", { "dependencies": { "minipass": "^3.0.0" } }, "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg=="],
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
"gauge": ["gauge@4.0.4", "", { "dependencies": { "aproba": "^1.0.3 || ^2.0.0", "color-support": "^1.1.3", "console-control-strings": "^1.1.0", "has-unicode": "^2.0.1", "signal-exit": "^3.0.7", "string-width": "^4.2.3", "strip-ansi": "^6.0.1", "wide-align": "^1.1.5" } }, "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg=="],
"get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="],
"get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
"get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
"gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
"graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
"has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
"has-tostringtag": ["has-tostringtag@1.0.2", "", { "dependencies": { "has-symbols": "^1.0.3" } }, "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="],
"has-unicode": ["has-unicode@2.0.1", "", {}, "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ=="],
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
"inherits": ["inherits@2.0.4", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],
"ini": ["ini@1.3.8", "", {}, "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="],
"is-fullwidth-code-point": ["is-fullwidth-code-point@3.0.0", "", {}, "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="],
"isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
"jsonfile": ["jsonfile@6.2.0", "", { "dependencies": { "universalify": "^2.0.0" }, "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg=="],
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
"memory-stream": ["memory-stream@1.0.0", "", { "dependencies": { "readable-stream": "^3.4.0" } }, "sha512-Wm13VcsPIMdG96dzILfij09PvuS3APtcKNh7M28FsCA/w6+1mjR7hhPmfFNoilX9xU7wTdhsH5lJAm6XNzdtww=="],
"mime-db": ["mime-db@1.52.0", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
"mime-types": ["mime-types@2.1.35", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
"minimist": ["minimist@1.2.8", "", {}, "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="],
"minipass": ["minipass@5.0.0", "", {}, "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ=="],
"minizlib": ["minizlib@2.1.2", "", { "dependencies": { "minipass": "^3.0.0", "yallist": "^4.0.0" } }, "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg=="],
"mkdirp": ["mkdirp@1.0.4", "", { "bin": { "mkdirp": "bin/cmd.js" } }, "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="],
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
"node-addon-api": ["node-addon-api@8.5.0", "", {}, "sha512-/bRZty2mXUIFY/xU5HLvveNHlswNJej+RnxBjOMkidWfwZzgTbPG1E3K5TOxRLOR+5hX7bSofy8yf1hZevMS8A=="],
"node-api-headers": ["node-api-headers@1.7.0", "", {}, "sha512-uJMGdkhVwu9+I3UsVvI3KW6ICAy/yDfsu5Br9rSnTtY3WpoaComXvKloiV5wtx0Md2rn0B9n29Ys2WMNwWxj9A=="],
"npmlog": ["npmlog@6.0.2", "", { "dependencies": { "are-we-there-yet": "^3.0.0", "console-control-strings": "^1.1.0", "gauge": "^4.0.3", "set-blocking": "^2.0.0" } }, "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg=="],
"proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
"rc": ["rc@1.2.8", "", { "dependencies": { "deep-extend": "^0.6.0", "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" }, "bin": { "rc": "./cli.js" } }, "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw=="],
"readable-stream": ["readable-stream@3.6.2", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="],
"require-directory": ["require-directory@2.1.1", "", {}, "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q=="],
"safe-buffer": ["safe-buffer@5.2.1", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="],
"semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="],
"set-blocking": ["set-blocking@2.0.0", "", {}, "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw=="],
"signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="],
"string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
"string_decoder": ["string_decoder@1.3.0", "", { "dependencies": { "safe-buffer": "~5.2.0" } }, "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="],
"strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
"strip-json-comments": ["strip-json-comments@2.0.1", "", {}, "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ=="],
"tar": ["tar@6.2.1", "", { "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" } }, "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A=="],
"tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
"universalify": ["universalify@2.0.1", "", {}, "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw=="],
"url-join": ["url-join@4.0.1", "", {}, "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="],
"util-deprecate": ["util-deprecate@1.0.2", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
"which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],
"wide-align": ["wide-align@1.1.5", "", { "dependencies": { "string-width": "^1.0.2 || 2 || 3 || 4" } }, "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg=="],
"wrap-ansi": ["wrap-ansi@7.0.0", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q=="],
"y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="],
"yallist": ["yallist@4.0.0", "", {}, "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="],
"yargs": ["yargs@17.7.2", "", { "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" } }, "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w=="],
"yargs-parser": ["yargs-parser@21.1.1", "", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="],
"fs-minipass/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="],
"minizlib/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="],
}
}

View File

@@ -0,0 +1,35 @@
{
"name": "@activepieces/piece-couchbase",
"version": "0.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@activepieces/piece-couchbase",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0",
"uuid": "^13.0.0"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
"node_modules/uuid": {
"version": "13.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz",
"integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist-node/bin/uuid"
}
}
}
}

View File

@@ -0,0 +1,11 @@
{
"name": "@activepieces/piece-couchbase",
"version": "0.0.1",
"type": "commonjs",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"dependencies": {
"couchbase": "^4.6.0",
"tslib": "^2.3.0"
}
}

View File

@@ -0,0 +1,65 @@
{
"name": "pieces-couchbase",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/couchbase/src",
"projectType": "library",
"release": {
"version": {
"manifestRootsToUpdate": [
"dist/{projectRoot}"
],
"currentVersionResolver": "git-tag",
"fallbackCurrentVersionResolver": "disk"
}
},
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/couchbase",
"tsConfig": "packages/pieces/community/couchbase/tsconfig.lib.json",
"packageJson": "packages/pieces/community/couchbase/package.json",
"main": "packages/pieces/community/couchbase/src/index.ts",
"assets": [
"packages/pieces/community/couchbase/*.md",
{
"input": "packages/pieces/community/couchbase/src/i18n",
"output": "./src/i18n",
"glob": "**/!(i18n.json)"
}
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": [
"prebuild",
"^build"
]
},
"nx-release-publish": {
"options": {
"packageRoot": "dist/{projectRoot}"
}
},
"prebuild": {
"executor": "nx:run-commands",
"options": {
"cwd": "packages/pieces/community/couchbase",
"command": "bun install --no-save --silent"
},
"dependsOn": [
"^build"
]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
}
}
}

View File

@@ -0,0 +1,61 @@
import { createPiece, PieceAuth, Property } from '@activepieces/pieces-framework';
import { createCouchbaseClient, closeCluster, CouchbaseAuthValue } from './lib/common';
import actions from './lib/actions';
export const couchbaseAuth = PieceAuth.CustomAuth({
description: 'Connect to your Couchbase cluster',
required: true,
props: {
connectionString: Property.ShortText({
displayName: 'Connection String',
description: 'Couchbase connection string (e.g., couchbase://localhost or couchbases://cloud.couchbase.com)',
required: true,
}),
username: Property.ShortText({
displayName: 'Username',
description: 'Username for authentication',
required: true,
}),
password: PieceAuth.SecretText({
displayName: 'Password',
description: 'Password for authentication',
required: true,
}),
},
validate: async ({ auth }) => {
const authValue = auth as CouchbaseAuthValue;
if (!authValue.connectionString) {
return { valid: false, error: 'Connection string is required' };
}
if (!authValue.username) {
return { valid: false, error: 'Username is required' };
}
if (!authValue.password) {
return { valid: false, error: 'Password is required' };
}
try {
const cluster = await createCouchbaseClient(authValue);
await cluster.ping();
await closeCluster(cluster);
return { valid: true };
} catch (error) {
return {
valid: false,
error: `Connection failed: ${(error as Error).message}`,
};
}
},
});
export const couchbasePiece = createPiece({
displayName: 'Couchbase',
description: 'NoSQL document database for modern applications',
auth: couchbaseAuth,
minimumSupportedRelease: '0.36.1',
logoUrl: 'https://cdn.activepieces.com/pieces/couchbase.png',
authors: ['chedim', 'onyedikachi-david'],
actions,
triggers: [],
});

View File

@@ -0,0 +1,13 @@
import insertDocument from './actions/insert-document';
import upsertDocument from './actions/upsert-document';
import getDocument from './actions/get-document';
import deleteDocument from './actions/delete-document';
import query from './actions/query';
export default [
insertDocument,
upsertDocument,
getDocument,
deleteDocument,
query,
];

View File

@@ -0,0 +1,64 @@
import { createAction } from '@activepieces/pieces-framework';
import { couchbaseAuth } from '../..';
import {
couchbaseCommonProps,
createCouchbaseClient,
getCollection,
closeCluster,
formatMutationResult,
CouchbaseAuthValue,
} from '../common';
import { RemoveOptions, DurabilityLevel } from 'couchbase';
export default createAction({
auth: couchbaseAuth,
name: 'delete_document',
displayName: 'Delete Document',
description: 'Remove a document by its ID',
props: {
bucket: couchbaseCommonProps.bucket,
scope: couchbaseCommonProps.scope,
collection: couchbaseCommonProps.collection,
documentId: couchbaseCommonProps.documentIdDropdown,
durabilityLevel: couchbaseCommonProps.durabilityLevel,
timeout: couchbaseCommonProps.timeout,
},
async run(context) {
const auth = (context.auth as { props: CouchbaseAuthValue }).props;
const { bucket, scope, collection, documentId, durabilityLevel, timeout } = context.propsValue;
if (!bucket) {
throw new Error('Bucket is required');
}
if (!documentId) {
throw new Error('Document ID is required');
}
const cluster = await createCouchbaseClient(auth);
try {
const coll = getCollection(
cluster,
bucket,
scope || undefined,
collection || undefined
);
const options: RemoveOptions = {};
if (durabilityLevel !== undefined && durabilityLevel !== null) {
options.durabilityLevel = durabilityLevel as DurabilityLevel;
}
if (timeout && timeout > 0) {
options.timeout = timeout;
}
const result = await coll.remove(documentId, options);
return formatMutationResult(result, documentId);
} finally {
await closeCluster(cluster);
}
},
});

View File

@@ -0,0 +1,59 @@
import { createAction } from '@activepieces/pieces-framework';
import { couchbaseAuth } from '../..';
import {
couchbaseCommonProps,
createCouchbaseClient,
getCollection,
closeCluster,
formatGetResult,
CouchbaseAuthValue,
} from '../common';
import { GetOptions } from 'couchbase';
export default createAction({
auth: couchbaseAuth,
name: 'get_document',
displayName: 'Get Document',
description: 'Retrieve a document by its ID',
props: {
bucket: couchbaseCommonProps.bucket,
scope: couchbaseCommonProps.scope,
collection: couchbaseCommonProps.collection,
documentId: couchbaseCommonProps.documentIdDropdown,
timeout: couchbaseCommonProps.timeout,
},
async run(context) {
const auth = (context.auth as { props: CouchbaseAuthValue }).props;
const { bucket, scope, collection, documentId, timeout } = context.propsValue;
if (!bucket) {
throw new Error('Bucket is required');
}
if (!documentId) {
throw new Error('Document ID is required');
}
const cluster = await createCouchbaseClient(auth);
try {
const coll = getCollection(
cluster,
bucket,
scope || undefined,
collection || undefined
);
const options: GetOptions = {};
if (timeout && timeout > 0) {
options.timeout = timeout;
}
const result = await coll.get(documentId, options);
return formatGetResult(result, documentId);
} finally {
await closeCluster(cluster);
}
},
});

View File

@@ -0,0 +1,72 @@
import { createAction } from '@activepieces/pieces-framework';
import { couchbaseAuth } from '../..';
import {
couchbaseCommonProps,
createCouchbaseClient,
getCollection,
closeCluster,
formatMutationResult,
CouchbaseAuthValue,
} from '../common';
import { randomUUID } from 'crypto';
import { InsertOptions, DurabilityLevel } from 'couchbase';
export default createAction({
auth: couchbaseAuth,
name: 'insert_document',
displayName: 'Insert Document',
description: 'Create a new document. Fails if document already exists.',
props: {
bucket: couchbaseCommonProps.bucket,
scope: couchbaseCommonProps.scope,
collection: couchbaseCommonProps.collection,
documentId: couchbaseCommonProps.documentIdOptional,
document: couchbaseCommonProps.document,
expiry: couchbaseCommonProps.expiry,
durabilityLevel: couchbaseCommonProps.durabilityLevel,
timeout: couchbaseCommonProps.timeout,
},
async run(context) {
const auth = (context.auth as { props: CouchbaseAuthValue }).props;
const { bucket, scope, collection, documentId, document, expiry, durabilityLevel, timeout } = context.propsValue;
if (!bucket) {
throw new Error('Bucket is required');
}
if (!document) {
throw new Error('Document is required');
}
const docId = documentId || randomUUID();
const cluster = await createCouchbaseClient(auth);
try {
const coll = getCollection(
cluster,
bucket,
scope || undefined,
collection || undefined
);
const options: InsertOptions = {};
if (expiry && expiry > 0) {
options.expiry = expiry;
}
if (durabilityLevel !== undefined && durabilityLevel !== null) {
options.durabilityLevel = durabilityLevel as DurabilityLevel;
}
if (timeout && timeout > 0) {
options.timeout = timeout;
}
const result = await coll.insert(docId, document, options);
return formatMutationResult(result, docId);
} finally {
await closeCluster(cluster);
}
},
});

View File

@@ -0,0 +1,164 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { couchbaseAuth } from '../..';
import {
couchbaseCommonProps,
createCouchbaseClient,
closeCluster,
CouchbaseAuthValue,
LooseObject,
} from '../common';
import { QueryOptions, QueryScanConsistency } from 'couchbase';
export default createAction({
auth: couchbaseAuth,
name: 'query',
displayName: 'Execute SQL++ Query',
description: 'Run a SQL++ (N1QL) query with optional vector search filters',
props: {
bucket: couchbaseCommonProps.bucket,
scope: couchbaseCommonProps.scope,
query: couchbaseCommonProps.query,
arguments: couchbaseCommonProps.arguments,
vectorFilters: couchbaseCommonProps.vectorFilters,
vectorOrder: couchbaseCommonProps.vectorOrder,
limit: couchbaseCommonProps.limit,
offset: couchbaseCommonProps.offset,
scanConsistency: Property.StaticDropdown({
displayName: 'Scan Consistency',
description: 'Query consistency level',
required: false,
options: {
options: [
{ label: 'Not Bounded (Fastest)', value: QueryScanConsistency.NotBounded },
{ label: 'Request Plus (Consistent)', value: QueryScanConsistency.RequestPlus },
],
},
}),
timeout: couchbaseCommonProps.timeout,
},
async run(context) {
const auth = (context.auth as { props: CouchbaseAuthValue }).props;
const {
bucket,
scope,
query,
arguments: queryArgs,
vectorFilters,
vectorOrder,
limit,
offset,
scanConsistency,
timeout,
} = context.propsValue;
if (!query) {
throw new Error('Query is required');
}
const limitValue = Math.round(limit || 0);
const offsetValue = Math.round(offset || 0);
let userQuery = query;
const userQueryUpperCase = userQuery.toUpperCase();
const args: string[] = [...((queryArgs as string[]) || [])];
if (userQueryUpperCase.includes('LIMIT') || userQueryUpperCase.includes('OFFSET')) {
throw new Error('Do not include LIMIT or OFFSET in the query. Use the Limit and Offset fields instead.');
}
const whereClauseParts: string[] = [];
const orderClauseParts: string[] = [];
if (vectorFilters && Array.isArray(vectorFilters)) {
for (const elem of vectorFilters) {
const filter = elem as LooseObject;
const funcName = filter['preciseDistance'] ? 'VECTOR_DISTANCE' : 'APPROX_VECTOR_DISTANCE';
whereClauseParts.push(
`${funcName}(${filter['vectorExpr']}, ${filter['targetVector']}, "${filter['vectorSimilarity']}") < ?`
);
args.push(String(filter['maxDistance']));
}
}
if (vectorOrder && Array.isArray(vectorOrder)) {
for (const elem of vectorOrder) {
const order = elem as LooseObject;
const funcName = order['preciseDistance'] ? 'VECTOR_DISTANCE' : 'APPROX_VECTOR_DISTANCE';
orderClauseParts.push(
`${funcName}(${order['vectorExpr']}, ${order['targetVector']}, "${order['vectorSimilarity']}")`
);
}
}
if (whereClauseParts.length > 0) {
const whereClause = whereClauseParts.join(' AND ');
const orderByIndex = userQueryUpperCase.indexOf('ORDER BY');
if (userQueryUpperCase.includes('WHERE')) {
userQuery = userQuery.replace(/WHERE/i, `WHERE ${whereClause} AND `);
} else if (orderByIndex > -1) {
userQuery = userQuery.slice(0, orderByIndex) + `WHERE ${whereClause} ` + userQuery.slice(orderByIndex);
} else {
userQuery += ` WHERE ${whereClause}`;
}
}
if (orderClauseParts.length > 0) {
const orderClause = orderClauseParts.join(', ');
if (userQueryUpperCase.indexOf('ORDER BY') > -1) {
userQuery += `, ${orderClause}`;
} else {
userQuery += ` ORDER BY ${orderClause}`;
}
}
let finalQuery = `SELECT RAW data FROM (${userQuery}) data`;
if (limitValue > 0) {
finalQuery += ` LIMIT ${limitValue}`;
}
if (offsetValue > 0) {
finalQuery += ` OFFSET ${offsetValue}`;
}
const cluster = await createCouchbaseClient(auth);
try {
const options: QueryOptions = {};
if (args.length > 0) {
options.parameters = args;
}
if (scanConsistency !== undefined && scanConsistency !== null) {
options.scanConsistency = scanConsistency as QueryScanConsistency;
}
if (timeout && timeout > 0) {
options.timeout = timeout;
}
let result;
if (bucket && scope) {
const bucketObj = cluster.bucket(bucket);
const scopeObj = bucketObj.scope(scope);
result = await scopeObj.query(finalQuery, options);
} else {
result = await cluster.query(finalQuery, options);
}
return {
rows: result.rows,
meta: {
requestId: result.meta.requestId,
status: result.meta.status,
metrics: result.meta.metrics,
},
};
} finally {
await closeCluster(cluster);
}
},
});

View File

@@ -0,0 +1,72 @@
import { createAction } from '@activepieces/pieces-framework';
import { couchbaseAuth } from '../..';
import {
couchbaseCommonProps,
createCouchbaseClient,
getCollection,
closeCluster,
formatMutationResult,
CouchbaseAuthValue,
} from '../common';
import { randomUUID } from 'crypto';
import { UpsertOptions, DurabilityLevel } from 'couchbase';
export default createAction({
auth: couchbaseAuth,
name: 'upsert_document',
displayName: 'Upsert Document',
description: 'Create or update a document. Creates if it doesn\'t exist, updates if it does.',
props: {
bucket: couchbaseCommonProps.bucket,
scope: couchbaseCommonProps.scope,
collection: couchbaseCommonProps.collection,
documentId: couchbaseCommonProps.documentIdOptional,
document: couchbaseCommonProps.document,
expiry: couchbaseCommonProps.expiry,
durabilityLevel: couchbaseCommonProps.durabilityLevel,
timeout: couchbaseCommonProps.timeout,
},
async run(context) {
const auth = (context.auth as { props: CouchbaseAuthValue }).props;
const { bucket, scope, collection, documentId, document, expiry, durabilityLevel, timeout } = context.propsValue;
if (!bucket) {
throw new Error('Bucket is required');
}
if (!document) {
throw new Error('Document is required');
}
const docId = documentId || randomUUID();
const cluster = await createCouchbaseClient(auth);
try {
const coll = getCollection(
cluster,
bucket,
scope || undefined,
collection || undefined
);
const options: UpsertOptions = {};
if (expiry && expiry > 0) {
options.expiry = expiry;
}
if (durabilityLevel !== undefined && durabilityLevel !== null) {
options.durabilityLevel = durabilityLevel as DurabilityLevel;
}
if (timeout && timeout > 0) {
options.timeout = timeout;
}
const result = await coll.upsert(docId, document, options);
return formatMutationResult(result, docId);
} finally {
await closeCluster(cluster);
}
},
});

View File

@@ -0,0 +1,471 @@
import { Property } from '@activepieces/pieces-framework';
import { couchbaseAuth } from '../..';
import {
Cluster,
Collection,
connect,
Bucket,
Scope,
DurabilityLevel,
GetResult,
MutationResult,
} from 'couchbase';
export interface CouchbaseAuthValue {
connectionString: string;
username: string;
password: string;
}
export interface LooseObject {
[key: string]: unknown;
}
export async function createCouchbaseClient(
auth: CouchbaseAuthValue
): Promise<Cluster> {
const isCloudConnection = auth.connectionString.includes('cloud.couchbase.com');
return await connect(auth.connectionString, {
username: auth.username,
password: auth.password,
configProfile: isCloudConnection ? 'wanDevelopment' : undefined,
timeouts: {
connectTimeout: 30000,
kvTimeout: 15000,
managementTimeout: 60000,
bootstrapTimeout: 30000,
},
});
}
export function getCollection(
cluster: Cluster,
bucketName: string,
scopeName?: string,
collectionName?: string
): Collection {
const bucket: Bucket = cluster.bucket(bucketName);
const scope: Scope = scopeName ? bucket.scope(scopeName) : bucket.defaultScope();
return collectionName ? scope.collection(collectionName) : scope.collection('_default');
}
export async function closeCluster(cluster: Cluster): Promise<void> {
try {
await cluster.close();
} catch {
// Ignore close errors
}
}
export function formatMutationResult(
result: MutationResult,
documentId: string
): { id: string; cas: string; success: boolean } {
return {
id: documentId,
cas: result.cas.toString(),
success: true,
};
}
export function formatGetResult(
result: GetResult,
documentId: string
): { id: string; content: unknown; cas: string } {
return {
id: documentId,
content: result.content,
cas: result.cas.toString(),
};
}
export const bucketDropdown = Property.Dropdown({
displayName: 'Bucket',
description: 'Select the bucket',
required: true,
refreshers: ['auth'],
auth: couchbaseAuth,
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Connect to Couchbase first',
options: [],
};
}
const authValue = (auth as { props: CouchbaseAuthValue }).props;
let cluster: Cluster | null = null;
try {
cluster = await createCouchbaseClient(authValue);
const bucketManager = cluster.buckets();
const buckets = await bucketManager.getAllBuckets();
if (!buckets || buckets.length === 0) {
return {
disabled: true,
placeholder: 'No buckets found in cluster',
options: [],
};
}
return {
disabled: false,
options: buckets.map((bucket) => ({
label: bucket.name,
value: bucket.name,
})),
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
return {
disabled: true,
placeholder: `Failed to load buckets: ${errorMessage}`,
options: [],
};
} finally {
if (cluster) {
await closeCluster(cluster);
}
}
},
});
export const scopeDropdown = Property.Dropdown({
displayName: 'Scope',
description: 'Select the scope (leave empty for default)',
required: false,
refreshers: ['auth', 'bucket'],
auth: couchbaseAuth,
options: async ({ auth, bucket }) => {
if (!auth || !bucket) {
return {
disabled: true,
placeholder: 'Select a bucket first',
options: [],
};
}
const authValue = (auth as { props: CouchbaseAuthValue }).props;
let cluster: Cluster | null = null;
try {
cluster = await createCouchbaseClient(authValue);
const bucketObj = cluster.bucket(bucket as string);
const collectionManager = bucketObj.collections();
const scopes = await collectionManager.getAllScopes();
if (!scopes || scopes.length === 0) {
return {
disabled: false,
options: [{ label: '_default (Default)', value: '_default' }],
};
}
return {
disabled: false,
options: scopes.map((scope) => ({
label: scope.name === '_default' ? '_default (Default)' : scope.name,
value: scope.name,
})),
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
return {
disabled: true,
placeholder: `Failed to load scopes: ${errorMessage}`,
options: [],
};
} finally {
if (cluster) {
await closeCluster(cluster);
}
}
},
});
export const collectionDropdown = Property.Dropdown({
displayName: 'Collection',
description: 'Select the collection (leave empty for default)',
required: false,
refreshers: ['auth', 'bucket', 'scope'],
auth: couchbaseAuth,
options: async ({ auth, bucket, scope }) => {
if (!auth || !bucket) {
return {
disabled: true,
placeholder: 'Select a bucket first',
options: [],
};
}
const authValue = (auth as { props: CouchbaseAuthValue }).props;
let cluster: Cluster | null = null;
try {
cluster = await createCouchbaseClient(authValue);
const bucketObj = cluster.bucket(bucket as string);
const collectionManager = bucketObj.collections();
const scopes = await collectionManager.getAllScopes();
const selectedScope = scopes?.find(
(s) => s.name === (scope || '_default')
);
if (!selectedScope || !selectedScope.collections) {
return {
disabled: false,
options: [{ label: '_default (Default)', value: '_default' }],
};
}
return {
disabled: false,
options: selectedScope.collections.map((coll) => ({
label: coll.name === '_default' ? '_default (Default)' : coll.name,
value: coll.name,
})),
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
return {
disabled: true,
placeholder: `Failed to load collections: ${errorMessage}`,
options: [],
};
} finally {
if (cluster) {
await closeCluster(cluster);
}
}
},
});
export const documentIdDropdown = Property.Dropdown({
displayName: 'Document ID',
description: 'Select an existing document or type a custom ID',
required: true,
refreshers: ['auth', 'bucket', 'scope', 'collection'],
auth: couchbaseAuth,
options: async ({ auth, bucket, scope, collection }) => {
if (!auth || !bucket) {
return {
disabled: true,
placeholder: 'Select a bucket first',
options: [],
};
}
const authValue = (auth as { props: CouchbaseAuthValue }).props;
let cluster: Cluster | null = null;
try {
cluster = await createCouchbaseClient(authValue);
const scopeName = (scope as string) || '_default';
const collectionName = (collection as string) || '_default';
const keyspace = `\`${bucket}\`.\`${scopeName}\`.\`${collectionName}\``;
const query = `SELECT META().id AS docId FROM ${keyspace} LIMIT 100`;
const result = await cluster.query(query);
if (!result.rows || result.rows.length === 0) {
return {
disabled: false,
placeholder: 'No documents found - type a document ID',
options: [],
};
}
return {
disabled: false,
options: result.rows.map((row: { docId: string }) => ({
label: row.docId,
value: row.docId,
})),
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
return {
disabled: false,
placeholder: `Could not load documents: ${errorMessage}`,
options: [],
};
} finally {
if (cluster) {
await closeCluster(cluster);
}
}
},
});
export const durabilityLevelDropdown = Property.StaticDropdown({
displayName: 'Durability Level',
description: 'How durable the write should be before returning success',
required: false,
options: {
options: [
{ label: 'None (Fastest)', value: DurabilityLevel.None },
{ label: 'Majority', value: DurabilityLevel.Majority },
{ label: 'Majority and Persist on Master', value: DurabilityLevel.MajorityAndPersistOnMaster },
{ label: 'Persist to Majority (Safest)', value: DurabilityLevel.PersistToMajority },
],
},
});
export const couchbaseCommonProps = {
bucket: bucketDropdown,
scope: scopeDropdown,
collection: collectionDropdown,
documentIdDropdown: documentIdDropdown,
documentId: Property.ShortText({
displayName: 'Document ID',
description: 'Unique identifier for the document',
required: true,
}),
documentIdOptional: Property.ShortText({
displayName: 'Document ID',
description: 'Unique identifier for the document. Leave empty to auto-generate.',
required: false,
}),
document: Property.Json({
displayName: 'Document',
description: 'The JSON document to store',
required: true,
}),
expiry: Property.Number({
displayName: 'Expiry (seconds)',
description: 'Document expiration time in seconds. Leave empty for no expiry.',
required: false,
}),
durabilityLevel: durabilityLevelDropdown,
timeout: Property.Number({
displayName: 'Timeout (ms)',
description: 'Operation timeout in milliseconds',
required: false,
defaultValue: 10000,
}),
query: Property.LongText({
displayName: 'SQL++ Query',
description: 'SELECT statement with optional positional parameters ($1, $2, etc.). Do not include LIMIT or OFFSET.',
required: true,
}),
arguments: Property.Array({
displayName: 'Query Arguments',
description: 'Values for positional parameters ($1, $2, etc.) in the query',
required: false,
}),
limit: Property.Number({
displayName: 'Limit',
description: 'Maximum number of results to return',
required: false,
}),
offset: Property.Number({
displayName: 'Offset',
description: 'Number of results to skip',
required: false,
}),
vectorFilters: Property.Array({
displayName: 'Vector Filters',
description: 'Filter results by vector similarity (requires vector index)',
required: false,
properties: {
vectorExpr: Property.ShortText({
displayName: 'Vector Expression',
description: 'Field path returning a vector (e.g., data.embedding)',
required: true,
}),
targetVector: Property.LongText({
displayName: 'Target Vector',
description: 'Array of numbers to compare against (e.g., [0.1, 0.2, ...])',
required: true,
}),
vectorSimilarity: Property.StaticDropdown({
displayName: 'Similarity Metric',
required: true,
defaultValue: 'L2_SQUARED',
options: {
options: [
{ label: 'Cosine', value: 'COSINE' },
{ label: 'Dot Product', value: 'DOT' },
{ label: 'Euclidean (L2)', value: 'L2' },
{ label: 'Squared Euclidean', value: 'L2_SQUARED' },
],
},
}),
maxDistance: Property.Number({
displayName: 'Max Distance',
description: 'Maximum distance threshold',
required: true,
}),
preciseDistance: Property.Checkbox({
displayName: 'Use Precise Distance',
description: 'Use VECTOR_DISTANCE instead of APPROX_VECTOR_DISTANCE (slower but more accurate)',
required: false,
}),
},
}),
vectorOrder: Property.Array({
displayName: 'Vector Ordering',
description: 'Order results by vector similarity (requires vector index)',
required: false,
properties: {
vectorExpr: Property.ShortText({
displayName: 'Vector Expression',
description: 'Field path returning a vector (e.g., data.embedding)',
required: true,
}),
targetVector: Property.LongText({
displayName: 'Target Vector',
description: 'Array of numbers to compare against (e.g., [0.1, 0.2, ...])',
required: true,
}),
vectorSimilarity: Property.StaticDropdown({
displayName: 'Similarity Metric',
required: true,
defaultValue: 'L2_SQUARED',
options: {
options: [
{ label: 'Cosine', value: 'COSINE' },
{ label: 'Dot Product', value: 'DOT' },
{ label: 'Euclidean (L2)', value: 'L2' },
{ label: 'Squared Euclidean', value: 'L2_SQUARED' },
],
},
}),
preciseDistance: Property.Checkbox({
displayName: 'Use Precise Distance',
description: 'Use VECTOR_DISTANCE instead of APPROX_VECTOR_DISTANCE (slower but more accurate)',
required: false,
}),
},
}),
};

View File

@@ -0,0 +1,20 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"importHelpers": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}

View File

@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"]
}