@oomol-lab/open-connector 1.6.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/open-connector/catalog/apps/aisa.json +6394 -0
- package/assets/open-connector/catalog/apps/baizhi_mcp.json +135 -0
- package/assets/open-connector/catalog/apps/bilibili.json +2586 -0
- package/assets/open-connector/catalog/apps/bitwarden.json +1423 -0
- package/assets/open-connector/catalog/apps/cronfree.json +303 -0
- package/assets/open-connector/catalog/apps/cufinder.json +368 -0
- package/assets/open-connector/catalog/apps/discordbot.json +2888 -248
- package/assets/open-connector/catalog/apps/drawio_mcp.json +192 -0
- package/assets/open-connector/catalog/apps/firecrawl.json +176 -32
- package/assets/open-connector/catalog/apps/framejet.json +273 -0
- package/assets/open-connector/catalog/apps/futunn.json +2967 -0
- package/assets/open-connector/catalog/apps/gmail.json +298 -0
- package/assets/open-connector/catalog/apps/google_analytics.json +4 -1
- package/assets/open-connector/catalog/apps/google_bigquery.json +4 -1
- package/assets/open-connector/catalog/apps/google_search_console.json +4 -1
- package/assets/open-connector/catalog/apps/googlecalendar.json +4 -1
- package/assets/open-connector/catalog/apps/googlechat.json +694 -7
- package/assets/open-connector/catalog/apps/googledocs.json +4 -1
- package/assets/open-connector/catalog/apps/googlesheets.json +4 -1
- package/assets/open-connector/catalog/apps/granola.json +23 -0
- package/assets/open-connector/catalog/apps/investoday_mcp.json +22228 -197
- package/assets/open-connector/catalog/apps/ixspy.json +2274 -0
- package/assets/open-connector/catalog/apps/keepa.json +3534 -987
- package/assets/open-connector/catalog/apps/linear.json +17 -0
- package/assets/open-connector/catalog/apps/linear_mcp.json +510 -0
- package/assets/open-connector/catalog/apps/moneyforward_mcp.json +1432 -0
- package/assets/open-connector/catalog/apps/notion.json +446 -1
- package/assets/open-connector/catalog/apps/notion_mcp.json +490 -0
- package/assets/open-connector/catalog/apps/odoo.json +619 -0
- package/assets/open-connector/catalog/apps/osv.json +663 -0
- package/assets/open-connector/catalog/apps/outlook.json +30 -8
- package/assets/open-connector/catalog/apps/outlook_calendar.json +23 -2
- package/assets/open-connector/catalog/apps/pdf_vector.json +329 -0
- package/assets/open-connector/catalog/apps/postiz.json +334 -0
- package/assets/open-connector/catalog/apps/proworkflow.json +529 -0
- package/assets/open-connector/catalog/apps/pulsetic.json +406 -0
- package/assets/open-connector/catalog/apps/sellersprite_mcp.json +2 -1
- package/assets/open-connector/catalog/apps/shopee.json +1785 -0
- package/assets/open-connector/catalog/apps/slack.json +304 -0
- package/assets/open-connector/catalog/apps/slackbot.json +295 -0
- package/assets/open-connector/catalog/apps/speak_ai.json +360 -0
- package/assets/open-connector/catalog/apps/tencent_docs.json +3 -0
- package/assets/open-connector/catalog/apps/wisburg.json +1528 -0
- package/assets/open-connector/catalog/apps/youtube.json +4 -1
- package/assets/open-connector/catalog/apps/zerotier.json +3319 -0
- package/assets/open-connector/catalog/apps/zyhub.json +1585 -0
- package/assets/open-connector/catalog/apps-index.json +1 -1
- package/package.json +1 -1
- package/src/core/cast.d.ts +10 -0
- package/src/core/cast.js +14 -0
- package/src/core/guarded-fetch.d.ts +6 -3
- package/src/core/guarded-fetch.js +6 -3
- package/src/core/json-schema.d.ts +5 -1
- package/src/core/json-schema.js +14 -2
- package/src/core/provider-scenarios.js +67 -13
- package/src/core/request.js +4 -1
- package/src/core/types.d.ts +10 -1
- package/src/mcp.js +10 -7
- package/src/oauth/oauth-client-config-service.d.ts +16 -1
- package/src/oauth/oauth-client-config-service.js +59 -3
- package/src/oauth/oauth-credential-refresh-service.js +3 -1
- package/src/oauth/oauth-flow-service.d.ts +6 -0
- package/src/oauth/oauth-flow-service.js +21 -4
- package/src/oauth/oauth-token.d.ts +13 -0
- package/src/providers/17track/runtime.js +1 -1
- package/src/providers/action-contracts.generated.d.ts +32 -8
- package/src/providers/aifinmarket/runtime.js +1 -1
- package/src/providers/aisa/executors.d.ts +4 -0
- package/src/providers/aisa/executors.js +864 -0
- package/src/providers/aliyun_ack/runtime.js +1 -1
- package/src/providers/aliyun_sls/runtime.js +1 -1
- package/src/providers/app_store_server/runtime-helpers.js +1 -1
- package/src/providers/baizhi_mcp/actions.d.ts +2 -0
- package/src/providers/baizhi_mcp/actions.js +40 -0
- package/src/providers/baizhi_mcp/executors.d.ts +3 -0
- package/src/providers/baizhi_mcp/executors.js +102 -0
- package/src/providers/bazhuayu/runtime.js +2 -2
- package/src/providers/bilibili/articles.d.ts +3 -0
- package/src/providers/bilibili/articles.js +369 -0
- package/src/providers/bilibili/executors.d.ts +8 -0
- package/src/providers/bilibili/executors.js +262 -0
- package/src/providers/bilibili/runtime.d.ts +95 -0
- package/src/providers/bilibili/runtime.js +236 -0
- package/src/providers/bilibili/upload.d.ts +14 -0
- package/src/providers/bilibili/upload.js +107 -0
- package/src/providers/bitwarden/executors.d.ts +3 -0
- package/src/providers/bitwarden/executors.js +146 -0
- package/src/providers/cloudflare_browser_rendering/executors.js +1 -1
- package/src/providers/cloudflare_dns/executors.js +1 -1
- package/src/providers/{cloudflare-current-user.js → cloudflare_dns/runtime-user.js} +2 -2
- package/src/providers/cloudflare_dns/runtime.d.ts +1 -1
- package/src/providers/cloudflare_dns/runtime.js +1 -1
- package/src/providers/cloudflare_r2/executors.js +1 -1
- package/src/providers/cloudflare_r2/runtime.d.ts +1 -1
- package/src/providers/cloudflare_r2/runtime.js +1 -1
- package/src/providers/cloudflare_worker/executors.js +1 -1
- package/src/providers/cloudflare_worker/runtime.d.ts +1 -1
- package/src/providers/cloudflare_worker/runtime.js +1 -1
- package/src/providers/cronfree/executors.d.ts +4 -0
- package/src/providers/cronfree/executors.js +89 -0
- package/src/providers/cufinder/executors.d.ts +4 -0
- package/src/providers/cufinder/executors.js +105 -0
- package/src/providers/dingtalk_mcp/runtime.js +1 -1
- package/src/providers/discordbot/executors.d.ts +0 -9
- package/src/providers/discordbot/executors.js +9 -101
- package/src/providers/discordbot/runtime-guilds.d.ts +3 -0
- package/src/providers/discordbot/runtime-guilds.js +464 -0
- package/src/providers/discordbot/runtime.d.ts +42 -0
- package/src/providers/discordbot/runtime.js +124 -0
- package/src/providers/drawio_mcp/executors.d.ts +3 -0
- package/src/providers/drawio_mcp/executors.js +19 -0
- package/src/providers/drawio_mcp/runtime.d.ts +8 -0
- package/src/providers/drawio_mcp/runtime.js +175 -0
- package/src/providers/elevenreader/runtime.js +6 -5
- package/src/providers/fastmoss_mcp/executors.js +2 -2
- package/src/providers/finchina/executors.js +1 -1
- package/src/providers/framejet/executors.d.ts +4 -0
- package/src/providers/framejet/executors.js +19 -0
- package/src/providers/framejet/runtime.d.ts +16 -0
- package/src/providers/framejet/runtime.js +148 -0
- package/src/providers/futunn/actions.d.ts +2 -0
- package/src/providers/futunn/actions.js +152 -0
- package/src/providers/futunn/actions.research.d.ts +2 -0
- package/src/providers/futunn/actions.research.js +423 -0
- package/src/providers/futunn/actions.trading.d.ts +2 -0
- package/src/providers/futunn/actions.trading.js +204 -0
- package/src/providers/futunn/executors.d.ts +3 -0
- package/src/providers/futunn/executors.js +24 -0
- package/src/providers/futunn/runtime-research.d.ts +3 -0
- package/src/providers/futunn/runtime-research.js +133 -0
- package/src/providers/futunn/runtime-trading.d.ts +3 -0
- package/src/providers/futunn/runtime-trading.js +39 -0
- package/src/providers/futunn/runtime.d.ts +2 -0
- package/src/providers/futunn/runtime.js +50 -0
- package/src/providers/futunn/transport.d.ts +11 -0
- package/src/providers/futunn/transport.js +76 -0
- package/src/providers/gildata/executors.js +1 -1
- package/src/providers/gmail/attachment-stream.d.ts +2 -0
- package/src/providers/gmail/attachment-stream.js +162 -0
- package/src/providers/gmail/executors.d.ts +3 -1
- package/src/providers/gmail/executors.js +54 -26
- package/src/providers/gmail/message.d.ts +6 -8
- package/src/providers/gmail/message.js +4 -0
- package/src/providers/gmail/scopes.d.ts +32 -0
- package/src/providers/gmail/scopes.js +37 -0
- package/src/providers/google_analytics/executors.js +2 -2
- package/src/providers/google_analytics/scopes.js +6 -1
- package/src/providers/google_bigquery/executors.js +2 -2
- package/src/providers/google_bigquery/scopes.js +2 -0
- package/src/providers/google_search_console/executors.js +2 -2
- package/src/providers/google_search_console/scopes.js +2 -0
- package/src/providers/googleads/executors.js +1 -1
- package/src/providers/googleads/scopes.d.ts +1 -3
- package/src/providers/googleads/scopes.js +2 -4
- package/src/providers/googlecalendar/executors.js +1 -1
- package/src/providers/googlecalendar/runtime-shared.js +2 -2
- package/src/providers/googlecalendar/scopes.js +2 -0
- package/src/providers/googlechat/executors.d.ts +1 -3
- package/src/providers/googlechat/executors.js +219 -28
- package/src/providers/googlechat/members.d.ts +55 -0
- package/src/providers/googlechat/members.js +293 -0
- package/src/providers/googlechat/runtime.d.ts +16 -0
- package/src/providers/googlechat/runtime.js +25 -0
- package/src/providers/googlechat/scopes.d.ts +22 -3
- package/src/providers/googlechat/scopes.js +30 -7
- package/src/providers/googledocs/executors.js +1 -1
- package/src/providers/googledrive/executors.js +2 -2
- package/src/providers/{google-auth.d.ts → googledrive/runtime-auth.d.ts} +2 -2
- package/src/providers/{google-auth.js → googledrive/runtime-auth.js} +3 -3
- package/src/providers/googledrive/runtime-collaboration.js +1 -1
- package/src/providers/{google-runtime.d.ts → googledrive/runtime-request.d.ts} +1 -1
- package/src/providers/{google-runtime.js → googledrive/runtime-request.js} +2 -2
- package/src/providers/googleforms/executors.js +2 -2
- package/src/providers/googleforms/scopes.d.ts +0 -3
- package/src/providers/googleforms/scopes.js +2 -6
- package/src/providers/googlemeet/executors.js +2 -2
- package/src/providers/googlemeet/scopes.d.ts +0 -3
- package/src/providers/googlemeet/scopes.js +2 -6
- package/src/providers/googlesheets/executors.js +1 -1
- package/src/providers/googlesheets/scopes.js +2 -0
- package/src/providers/googleslides/executors.js +2 -2
- package/src/providers/googleslides/scopes.d.ts +0 -3
- package/src/providers/googleslides/scopes.js +2 -6
- package/src/providers/googletasks/executors.js +2 -2
- package/src/providers/googletasks/scopes.d.ts +0 -3
- package/src/providers/googletasks/scopes.js +2 -6
- package/src/providers/granola/actions.js +2 -0
- package/src/providers/granola/runtime-mcp.js +2 -0
- package/src/providers/granola/runtime.js +2 -2
- package/src/providers/indiegogo/executors.js +1 -1
- package/src/providers/investoday_mcp/executors.js +2 -2
- package/src/providers/investoday_mcp/official-actions.js +19 -372
- package/src/providers/investoday_mcp/official-tool-types.d.ts +10 -0
- package/src/providers/investoday_mcp/official-tool-types.js +4 -0
- package/src/providers/investoday_mcp/official-tools/charts.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/charts.js +32 -0
- package/src/providers/investoday_mcp/official-tools/fixed-income.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/fixed-income.js +326 -0
- package/src/providers/investoday_mcp/official-tools/funds.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/funds.js +1085 -0
- package/src/providers/investoday_mcp/official-tools/hong-kong.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/hong-kong.js +275 -0
- package/src/providers/investoday_mcp/official-tools/indices-industries.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/indices-industries.js +642 -0
- package/src/providers/investoday_mcp/official-tools/macro-calendar.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/macro-calendar.js +398 -0
- package/src/providers/investoday_mcp/official-tools/other.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/other.js +131 -0
- package/src/providers/investoday_mcp/official-tools/research-news.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/research-news.js +302 -0
- package/src/providers/investoday_mcp/official-tools/stocks.d.ts +2 -0
- package/src/providers/investoday_mcp/official-tools/stocks.js +2829 -0
- package/src/providers/ixspy/executors.d.ts +3 -0
- package/src/providers/ixspy/executors.js +220 -0
- package/src/providers/iyunbiao/runtime.js +2 -2
- package/src/providers/keepa/actions.d.ts +1 -1
- package/src/providers/keepa/actions.js +371 -149
- package/src/providers/keepa/deal-attributes.d.ts +1 -0
- package/src/providers/keepa/deal-attributes.js +26 -0
- package/src/providers/keepa/runtime.js +212 -18
- package/src/providers/kingdee/executors.js +1 -1
- package/src/providers/kingdee/runtime.js +2 -2
- package/src/providers/kuaidi100/runtime.js +1 -1
- package/src/providers/linear/executors.js +12 -9
- package/src/providers/linear_mcp/actions.d.ts +47 -0
- package/src/providers/linear_mcp/actions.js +102 -0
- package/src/providers/linear_mcp/endpoints.d.ts +3 -0
- package/src/providers/linear_mcp/endpoints.js +3 -0
- package/src/providers/linear_mcp/executors.d.ts +3 -0
- package/src/providers/linear_mcp/executors.js +9 -0
- package/src/providers/linear_mcp/runtime-mcp.d.ts +15 -0
- package/src/providers/linear_mcp/runtime-mcp.js +238 -0
- package/src/providers/lingxing_mcp/runtime.js +1 -1
- package/src/providers/mcdonalds_cn_mcp/runtime.js +1 -1
- package/src/providers/metabase/mcp-runtime.js +1 -1
- package/src/providers/moneyforward_mcp/executors.d.ts +3 -0
- package/src/providers/moneyforward_mcp/executors.js +11 -0
- package/src/providers/moneyforward_mcp/manifest.d.ts +31 -0
- package/src/providers/moneyforward_mcp/manifest.js +204 -0
- package/src/providers/moneyforward_mcp/runtime.d.ts +18 -0
- package/src/providers/moneyforward_mcp/runtime.js +296 -0
- package/src/providers/notion/executors.js +39 -3
- package/src/providers/notion_mcp/endpoints.d.ts +3 -0
- package/src/providers/notion_mcp/endpoints.js +3 -0
- package/src/providers/notion_mcp/executors.d.ts +3 -0
- package/src/providers/notion_mcp/executors.js +176 -0
- package/src/providers/notion_mcp/mcp-response.d.ts +86 -0
- package/src/providers/notion_mcp/mcp-response.js +314 -0
- package/src/providers/odoo/executors.d.ts +3 -0
- package/src/providers/odoo/executors.js +32 -0
- package/src/providers/odoo/runtime.d.ts +16 -0
- package/src/providers/odoo/runtime.js +140 -0
- package/src/providers/osv/executors.d.ts +2 -0
- package/src/providers/osv/executors.js +11 -0
- package/src/providers/osv/runtime.d.ts +9 -0
- package/src/providers/osv/runtime.js +66 -0
- package/src/providers/outlook/executors.js +27 -6
- package/src/providers/outlook/microsoft-graph.js +17 -6
- package/src/providers/outlook_calendar/executors.js +24 -7
- package/src/providers/patsnap_mcp/executors.js +2 -2
- package/src/providers/pdf_vector/executors.d.ts +4 -0
- package/src/providers/pdf_vector/executors.js +108 -0
- package/src/providers/postiz/executors.d.ts +4 -0
- package/src/providers/postiz/executors.js +83 -0
- package/src/providers/provider-runtime.d.ts +18 -0
- package/src/providers/provider-runtime.js +60 -4
- package/src/providers/proworkflow/executors.d.ts +4 -0
- package/src/providers/proworkflow/executors.js +135 -0
- package/src/providers/pulsetic/executors.d.ts +4 -0
- package/src/providers/pulsetic/executors.js +126 -0
- package/src/providers/registry.generated.js +24 -0
- package/src/providers/scrape_creators/catalog.js +1 -1
- package/src/providers/scrape_creators/runtime.js +1 -1
- package/src/providers/sellersprite_mcp/executors.js +2 -2
- package/src/providers/sellersprite_mcp/official-actions.js +3 -2
- package/src/providers/sentry/runtime.js +6 -7
- package/src/providers/shopee/actions.d.ts +2 -0
- package/src/providers/shopee/actions.js +474 -0
- package/src/providers/shopee/executors.d.ts +3 -0
- package/src/providers/shopee/executors.js +85 -0
- package/src/providers/shopee/runtime.d.ts +79 -0
- package/src/providers/shopee/runtime.js +693 -0
- package/src/providers/slack/actions.js +69 -3
- package/src/providers/slack/runtime.js +116 -21
- package/src/providers/slickdeals/runtime.js +1 -1
- package/src/providers/sorftime_mcp/executors.js +2 -2
- package/src/providers/speak_ai/executors.d.ts +3 -0
- package/src/providers/speak_ai/executors.js +187 -0
- package/src/providers/tikhub/bounded-response.d.ts +1 -1
- package/src/providers/tikhub/bounded-response.js +8 -34
- package/src/providers/tikhub/endpoint-catalog.js +1 -1
- package/src/providers/tikhub/runtime.js +2 -2
- package/src/providers/tongdaxin/executors.js +79 -15
- package/src/providers/tushare/runtime.js +22 -9
- package/src/providers/uspto/executors.js +1 -1
- package/src/providers/waffo/executors.js +1 -1
- package/src/providers/waffo/runtime.js +1 -1
- package/src/providers/wecom_mcp/runtime.js +1 -1
- package/src/providers/wisburg/executors.d.ts +4 -0
- package/src/providers/wisburg/executors.js +13 -0
- package/src/providers/wisburg/runtime.d.ts +12 -0
- package/src/providers/wisburg/runtime.js +133 -0
- package/src/providers/xydc_mcp/executors.js +2 -2
- package/src/providers/youtube/executors.js +1 -1
- package/src/providers/youtube/runtime.js +1 -1
- package/src/providers/zerotier/executors.d.ts +9 -0
- package/src/providers/zerotier/executors.js +629 -0
- package/src/providers/zerotier/runtime.d.ts +54 -0
- package/src/providers/zerotier/runtime.js +207 -0
- package/src/providers/zyhub/executors.d.ts +3 -0
- package/src/providers/zyhub/executors.js +240 -0
- package/src/server/api/openapi.js +12 -2
- package/src/server/api/runtime-api.d.ts +8 -1
- package/src/server/api/runtime-api.js +19 -1
- package/src/server/connect-server.js +10 -2
- package/src/server/files/transit-files.d.ts +3 -2
- package/src/server/files/transit-files.js +31 -35
- package/src/providers/sentry/scopes.d.ts +0 -1
- package/src/providers/sentry/scopes.js +0 -7
- /package/src/providers/{cloudflare-current-user.d.ts → cloudflare_dns/runtime-user.d.ts} +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { optionalNumber, requiredString } from "../../core/cast.js";
|
|
2
|
+
import { providerInputError, providerResponseError, requiredResponseRecord, runProviderRequest, setSearchParams, } from "../provider-runtime.js";
|
|
3
|
+
import { bilibiliApiRequest, bilibiliFormRequest, bilibiliUposBaseUrl, readBilibiliApiResponse } from "./runtime.js";
|
|
4
|
+
const smallVideoUploadMaxBytes = 100 * 1024 * 1024;
|
|
5
|
+
const videoUploadPartBytes = 10 * 1024 * 1024;
|
|
6
|
+
const videoUploadMaxBytes = 4 * 1024 * 1024 * 1024;
|
|
7
|
+
const imageUploadMaxBytes = 5 * 1024 * 1024;
|
|
8
|
+
/**
|
|
9
|
+
* Upload one video through Bilibili's upload-token flow: initialize, then a
|
|
10
|
+
* single openupos upload (files up to 100MB) or equal-sized 10MB parts plus
|
|
11
|
+
* the merge call. Returns the upload token used by archive submission.
|
|
12
|
+
*/
|
|
13
|
+
export async function uploadBilibiliVideo(context, file) {
|
|
14
|
+
if (file.size === 0) {
|
|
15
|
+
throw providerInputError("The video file is empty.");
|
|
16
|
+
}
|
|
17
|
+
if (file.size > videoUploadMaxBytes) {
|
|
18
|
+
throw providerInputError("The video file exceeds the Bilibili 4GB upload limit.");
|
|
19
|
+
}
|
|
20
|
+
const initData = requiredResponseRecord(await bilibiliApiRequest(context, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
path: "/archive/video/init",
|
|
23
|
+
body: {
|
|
24
|
+
name: normalizeUploadFileName(file.name),
|
|
25
|
+
utype: file.size <= smallVideoUploadMaxBytes ? "1" : "0",
|
|
26
|
+
},
|
|
27
|
+
label: "Bilibili video upload init",
|
|
28
|
+
}), "Bilibili video upload init");
|
|
29
|
+
const uploadToken = requiredString(initData.upload_token, "upload_token", providerResponseError);
|
|
30
|
+
if (file.size <= smallVideoUploadMaxBytes) {
|
|
31
|
+
await postBilibiliUposBytes(context, "/video/v2/upload", { upload_token: uploadToken }, file, "Bilibili video upload");
|
|
32
|
+
return uploadToken;
|
|
33
|
+
}
|
|
34
|
+
let offset = 0;
|
|
35
|
+
let partNumber = 1;
|
|
36
|
+
while (offset < file.size) {
|
|
37
|
+
const part = file.slice(offset, offset + videoUploadPartBytes);
|
|
38
|
+
await postBilibiliUposBytes(context, "/video/v2/part/upload", { upload_token: uploadToken, part_number: String(partNumber) }, part, `Bilibili video part ${partNumber} upload`);
|
|
39
|
+
offset += videoUploadPartBytes;
|
|
40
|
+
partNumber += 1;
|
|
41
|
+
}
|
|
42
|
+
await bilibiliApiRequest(context, {
|
|
43
|
+
method: "POST",
|
|
44
|
+
path: "/archive/video/complete",
|
|
45
|
+
query: { upload_token: uploadToken },
|
|
46
|
+
label: "Bilibili video upload complete",
|
|
47
|
+
});
|
|
48
|
+
return uploadToken;
|
|
49
|
+
}
|
|
50
|
+
/** Upload one cover image (jpeg/png, up to 5MB) and return its Bilibili-hosted URL. */
|
|
51
|
+
export async function uploadBilibiliCover(context, file) {
|
|
52
|
+
if (file.size === 0) {
|
|
53
|
+
throw providerInputError("The cover image is empty.");
|
|
54
|
+
}
|
|
55
|
+
if (file.size > imageUploadMaxBytes) {
|
|
56
|
+
throw providerInputError("The cover image exceeds the Bilibili 5MB limit.");
|
|
57
|
+
}
|
|
58
|
+
const data = requiredResponseRecord(await bilibiliFormRequest(context, {
|
|
59
|
+
path: "/archive/cover/upload",
|
|
60
|
+
file,
|
|
61
|
+
label: "Bilibili cover upload",
|
|
62
|
+
}), "Bilibili cover upload");
|
|
63
|
+
return requiredString(data.url, "url", providerResponseError);
|
|
64
|
+
}
|
|
65
|
+
/** Upload one article image (jpg/png, up to 5MB) and return its Bilibili-hosted URL. */
|
|
66
|
+
export async function uploadBilibiliArticleImage(context, file, watermark) {
|
|
67
|
+
if (file.size === 0) {
|
|
68
|
+
throw providerInputError("The article image is empty.");
|
|
69
|
+
}
|
|
70
|
+
if (file.size > imageUploadMaxBytes) {
|
|
71
|
+
throw providerInputError("The article image exceeds the Bilibili 5MB limit.");
|
|
72
|
+
}
|
|
73
|
+
const data = requiredResponseRecord(await bilibiliFormRequest(context, {
|
|
74
|
+
path: "/article/upload/image",
|
|
75
|
+
fields: { watermark: watermark === undefined ? undefined : String(watermark) },
|
|
76
|
+
file,
|
|
77
|
+
label: "Bilibili article image upload",
|
|
78
|
+
}), "Bilibili article image upload");
|
|
79
|
+
const url = requiredString(data.url, "url", providerResponseError);
|
|
80
|
+
const size = optionalNumber(data.size);
|
|
81
|
+
return size === undefined ? { url } : { url, size };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Post raw file bytes to the openupos upload host. These endpoints
|
|
85
|
+
* authenticate through the upload_token query parameter and must not carry
|
|
86
|
+
* multipart packaging around the bare binary body.
|
|
87
|
+
*/
|
|
88
|
+
async function postBilibiliUposBytes(context, path, query, body, label) {
|
|
89
|
+
const url = new URL(`${bilibiliUposBaseUrl}${path}`);
|
|
90
|
+
setSearchParams(url, query);
|
|
91
|
+
await runProviderRequest({ signal: context.signal, label }, async (signal) => {
|
|
92
|
+
const response = await context.fetcher(url.toString(), {
|
|
93
|
+
method: "POST",
|
|
94
|
+
headers: { "content-type": "application/octet-stream" },
|
|
95
|
+
body,
|
|
96
|
+
signal,
|
|
97
|
+
});
|
|
98
|
+
await readBilibiliApiResponse(response, label);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function normalizeUploadFileName(name) {
|
|
102
|
+
const trimmed = name.trim();
|
|
103
|
+
if (!trimmed) {
|
|
104
|
+
return "video.mp4";
|
|
105
|
+
}
|
|
106
|
+
return trimmed.includes(".") ? trimmed : `${trimmed}.mp4`;
|
|
107
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { compactObject, looseArray, optionalRecord, optionalString } from "../../core/cast.js";
|
|
2
|
+
import { defineProviderExecutors, providerInputError, ProviderRequestError, providerResponseError, providerUserAgent, readProviderJsonBody, requireCustomCredential, requiredInputString, requiredResponseRecord, runProviderRequest, } from "../provider-runtime.js";
|
|
3
|
+
const service = "bitwarden";
|
|
4
|
+
const regions = {
|
|
5
|
+
us: { api: "https://api.bitwarden.com", identity: "https://identity.bitwarden.com" },
|
|
6
|
+
eu: { api: "https://api.bitwarden.eu", identity: "https://identity.bitwarden.eu" },
|
|
7
|
+
};
|
|
8
|
+
const handlers = {
|
|
9
|
+
list_collections: list("/public/collections", "collections"),
|
|
10
|
+
get_collection: get("/public/collections", "collection"),
|
|
11
|
+
async list_events(input, context) {
|
|
12
|
+
const payload = requiredResponseRecord(await request("/public/events", "list events", context, compactObject({
|
|
13
|
+
start: optionalString(input.start),
|
|
14
|
+
end: optionalString(input.end),
|
|
15
|
+
actingUserId: optionalString(input.actingUserId),
|
|
16
|
+
itemId: optionalString(input.itemId),
|
|
17
|
+
secretId: optionalString(input.secretId),
|
|
18
|
+
projectId: optionalString(input.projectId),
|
|
19
|
+
continuationToken: optionalString(input.continuationToken),
|
|
20
|
+
})), "Bitwarden event list");
|
|
21
|
+
return { events: looseArray(payload.data), continuationToken: optionalString(payload.continuationToken) ?? null };
|
|
22
|
+
},
|
|
23
|
+
list_groups: list("/public/groups", "groups"),
|
|
24
|
+
get_group: get("/public/groups", "group"),
|
|
25
|
+
get_group_member_ids: ids("/public/groups", "member-ids", "memberIds"),
|
|
26
|
+
list_members: list("/public/members", "members"),
|
|
27
|
+
get_member: get("/public/members", "member"),
|
|
28
|
+
get_member_group_ids: ids("/public/members", "group-ids", "groupIds"),
|
|
29
|
+
list_policies: list("/public/policies", "policies"),
|
|
30
|
+
async get_policy(input, context) {
|
|
31
|
+
if (!Number.isInteger(input.type))
|
|
32
|
+
throw providerInputError("type is required");
|
|
33
|
+
return {
|
|
34
|
+
policy: requiredResponseRecord(await request(`/public/policies/${input.type}`, "get policy", context), "Bitwarden policy"),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
async get_subscription(_input, context) {
|
|
38
|
+
return requiredResponseRecord(await request("/public/organization/subscription", "get subscription", context), "Bitwarden subscription");
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
export const executors = defineProviderExecutors({
|
|
42
|
+
service,
|
|
43
|
+
handlers,
|
|
44
|
+
async createContext(context, fetcher) {
|
|
45
|
+
const stored = await requireCustomCredential(context, service);
|
|
46
|
+
return { ...credential(stored.values), fetcher, signal: context.signal };
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
export const credentialValidators = {
|
|
50
|
+
async customCredential(input, { fetcher, signal }) {
|
|
51
|
+
const value = credential(input.values);
|
|
52
|
+
await token(value, fetcher, signal, true);
|
|
53
|
+
return {
|
|
54
|
+
profile: { accountId: value.clientId, displayName: `Bitwarden Organization (${value.region.toUpperCase()})` },
|
|
55
|
+
grantedScopes: ["api.organization"],
|
|
56
|
+
metadata: { region: value.region, apiBaseUrl: regions[value.region].api },
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
function credential(values) {
|
|
61
|
+
const region = requiredInputString(values.region, "region").toLowerCase();
|
|
62
|
+
if (region !== "us" && region !== "eu")
|
|
63
|
+
throw providerInputError("region must be us or eu");
|
|
64
|
+
return {
|
|
65
|
+
clientId: requiredInputString(values.clientId, "clientId"),
|
|
66
|
+
clientSecret: requiredInputString(values.clientSecret, "clientSecret"),
|
|
67
|
+
region,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function list(path, field) {
|
|
71
|
+
return async (input, context) => {
|
|
72
|
+
const payload = requiredResponseRecord(await request(path, `list ${field}`, context, compactObject({ continuationToken: optionalString(input.continuationToken) })), `Bitwarden ${field}`);
|
|
73
|
+
return { [field]: looseArray(payload.data), continuationToken: optionalString(payload.continuationToken) ?? null };
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function get(path, field) {
|
|
77
|
+
return async (input, context) => ({
|
|
78
|
+
[field]: requiredResponseRecord(await request(`${path}/${encodeURIComponent(requiredInputString(input.id, "id"))}`, `get ${field}`, context), `Bitwarden ${field}`),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function ids(path, suffix, field) {
|
|
82
|
+
return async (input, context) => ({
|
|
83
|
+
[field]: looseArray(await request(`${path}/${encodeURIComponent(requiredInputString(input.id, "id"))}/${suffix}`, `get ${field}`, context)),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async function token(value, fetcher, parentSignal, validating) {
|
|
87
|
+
const response = await runProviderRequest({ signal: parentSignal, label: "Bitwarden token exchange" }, (signal) => fetcher(`${regions[value.region].identity}/connect/token`, {
|
|
88
|
+
method: "POST",
|
|
89
|
+
headers: {
|
|
90
|
+
accept: "application/json",
|
|
91
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
92
|
+
"user-agent": providerUserAgent,
|
|
93
|
+
},
|
|
94
|
+
body: new URLSearchParams({
|
|
95
|
+
grant_type: "client_credentials",
|
|
96
|
+
scope: "api.organization",
|
|
97
|
+
client_id: value.clientId,
|
|
98
|
+
client_secret: value.clientSecret,
|
|
99
|
+
}).toString(),
|
|
100
|
+
signal,
|
|
101
|
+
}));
|
|
102
|
+
const payload = await readProviderJsonBody(response, {
|
|
103
|
+
emptyBody: null,
|
|
104
|
+
invalidJsonMessage: "Bitwarden token exchange returned invalid JSON",
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok)
|
|
107
|
+
throw error(response.status, payload, validating);
|
|
108
|
+
const accessToken = optionalString(optionalRecord(payload)?.access_token)?.trim();
|
|
109
|
+
if (!accessToken)
|
|
110
|
+
throw providerResponseError("Bitwarden access token is missing");
|
|
111
|
+
return accessToken;
|
|
112
|
+
}
|
|
113
|
+
async function request(path, operation, context, query = {}) {
|
|
114
|
+
const accessToken = await token(context, context.fetcher, context.signal, false);
|
|
115
|
+
const url = new URL(path, `${regions[context.region].api}/`);
|
|
116
|
+
for (const [key, value] of Object.entries(query))
|
|
117
|
+
if (value != null)
|
|
118
|
+
url.searchParams.set(key, String(value));
|
|
119
|
+
const response = await runProviderRequest({ signal: context.signal, label: `Bitwarden ${operation}` }, (signal) => context.fetcher(url, {
|
|
120
|
+
headers: { accept: "application/json", authorization: `Bearer ${accessToken}`, "user-agent": providerUserAgent },
|
|
121
|
+
signal,
|
|
122
|
+
}));
|
|
123
|
+
const payload = await readProviderJsonBody(response, {
|
|
124
|
+
emptyBody: null,
|
|
125
|
+
invalidJsonMessage: `Bitwarden ${operation} returned invalid JSON`,
|
|
126
|
+
});
|
|
127
|
+
if (!response.ok)
|
|
128
|
+
throw error(response.status, payload, false);
|
|
129
|
+
if (payload == null)
|
|
130
|
+
throw providerResponseError(`Bitwarden ${operation} returned an empty response`);
|
|
131
|
+
return payload;
|
|
132
|
+
}
|
|
133
|
+
function error(status, payload, validating) {
|
|
134
|
+
const body = optionalRecord(payload);
|
|
135
|
+
const code = optionalString(body?.error);
|
|
136
|
+
const message = optionalString(body?.error_description) ??
|
|
137
|
+
optionalString(body?.message) ??
|
|
138
|
+
`Bitwarden request failed with ${status}`;
|
|
139
|
+
if (status === 429)
|
|
140
|
+
return new ProviderRequestError(429, message, payload);
|
|
141
|
+
if (code === "invalid_client")
|
|
142
|
+
return validating ? providerInputError(message) : new ProviderRequestError(409, message, payload);
|
|
143
|
+
if (status === 400)
|
|
144
|
+
return providerInputError(message);
|
|
145
|
+
return new ProviderRequestError(status, message, payload);
|
|
146
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compactObject, optionalBoolean, optionalInteger, optionalNumber, optionalRawString, optionalRecord, optionalString, requiredString, } from "../../core/cast.js";
|
|
2
|
-
import { cloudflareCurrentUserDisplayName, readCloudflareCurrentUser } from "../
|
|
2
|
+
import { cloudflareCurrentUserDisplayName, readCloudflareCurrentUser } from "../cloudflare_dns/runtime-user.js";
|
|
3
3
|
import { defineProviderExecutors, defineProviderProxy, ProviderRequestError, providerUserAgent, } from "../provider-runtime.js";
|
|
4
4
|
const service = "cloudflare_browser_rendering";
|
|
5
5
|
const cloudflareBrowserRenderingApiBaseUrl = "https://api.cloudflare.com/client/v4";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compactObject } from "../../core/cast.js";
|
|
2
|
-
import { cloudflareCurrentUserDisplayName } from "../cloudflare-current-user.js";
|
|
3
2
|
import { defineBearerProviderExecutors } from "../provider-runtime.js";
|
|
3
|
+
import { cloudflareCurrentUserDisplayName } from "./runtime-user.js";
|
|
4
4
|
import { cloudflareDnsActionHandlers, requestCloudflareCurrentUser, validateCloudflareDnsToken } from "./runtime.js";
|
|
5
5
|
const service = "cloudflare_dns";
|
|
6
6
|
export const executors = defineBearerProviderExecutors(service, cloudflareDnsActionHandlers);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { optionalRecord, optionalString } from "
|
|
2
|
-
import { ProviderRequestError } from "
|
|
1
|
+
import { optionalRecord, optionalString } from "../../core/cast.js";
|
|
2
|
+
import { ProviderRequestError } from "../provider-runtime.js";
|
|
3
3
|
export function readCloudflareCurrentUser(value) {
|
|
4
4
|
const user = optionalRecord(value);
|
|
5
5
|
if (!user) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CredentialValidationResult } from "../../core/types.ts";
|
|
2
|
-
import type { CloudflareCurrentUser } from "../cloudflare-current-user.ts";
|
|
3
2
|
import type { ProviderActionHandlers } from "../provider-runtime.ts";
|
|
4
3
|
import type { BearerProviderContext, ProviderRuntimeHandler } from "../provider-runtime.ts";
|
|
4
|
+
import type { CloudflareCurrentUser } from "./runtime-user.ts";
|
|
5
5
|
interface CloudflareAccount {
|
|
6
6
|
id: string;
|
|
7
7
|
name?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { compactObject, optionalBoolean, optionalInteger, optionalRecord, optionalString } from "../../core/cast.js";
|
|
2
2
|
import { queryParams } from "../../core/request.js";
|
|
3
|
-
import { readCloudflareCurrentUser } from "../cloudflare-current-user.js";
|
|
4
3
|
import { ProviderRequestError, providerUserAgent } from "../provider-runtime.js";
|
|
4
|
+
import { readCloudflareCurrentUser } from "./runtime-user.js";
|
|
5
5
|
const cloudflareApiBaseUrl = "https://api.cloudflare.com/client/v4";
|
|
6
6
|
export const cloudflareDnsActionHandlers = {
|
|
7
7
|
list_accounts(input, context) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compactObject, optionalString, requiredString } from "../../core/cast.js";
|
|
2
|
-
import { cloudflareCurrentUserDisplayName } from "../
|
|
2
|
+
import { cloudflareCurrentUserDisplayName } from "../cloudflare_dns/runtime-user.js";
|
|
3
3
|
import { createProviderFetch, createProviderProxyUrl, defineProviderExecutors, normalizeProviderProxyHeaders, ProviderRequestError, providerUserAgent, readProviderProxyErrorMessage, readProviderProxyResponse, toProviderProxyError, } from "../provider-runtime.js";
|
|
4
4
|
import { cloudflareR2ActionHandlers, cloudflareR2ApiBaseUrl, requestCloudflareR2CurrentUser, validateCloudflareR2Credential, } from "./runtime.js";
|
|
5
5
|
const service = "cloudflare_r2";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CredentialValidationResult, TransitFileWriter } from "../../core/types.ts";
|
|
2
|
-
import type { CloudflareCurrentUser } from "../
|
|
2
|
+
import type { CloudflareCurrentUser } from "../cloudflare_dns/runtime-user.ts";
|
|
3
3
|
import type { ProviderActionHandlers, ProviderRuntimeHandler } from "../provider-runtime.ts";
|
|
4
4
|
export interface CloudflareR2Context {
|
|
5
5
|
authType: "custom_credential" | "oauth2";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { base64Bytes, compactObject, integer, optionalInteger, optionalRecord, optionalString, requiredRawString, requiredString, } from "../../core/cast.js";
|
|
2
2
|
import { assertPublicHttpUrl, queryParams, readBoundedResponseBytes } from "../../core/request.js";
|
|
3
|
-
import { readCloudflareCurrentUser } from "../
|
|
3
|
+
import { readCloudflareCurrentUser } from "../cloudflare_dns/runtime-user.js";
|
|
4
4
|
import { combineProviderActionHandlers, providerFetch, providerInputError, ProviderRequestError, providerUserAgent, runProviderRequest, } from "../provider-runtime.js";
|
|
5
5
|
import { cloudflareR2AccountActionHandlers } from "./runtime-account.js";
|
|
6
6
|
import { cloudflareR2BucketSettingsActionHandlers } from "./runtime-bucket-settings.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compactObject, optionalString, requiredString } from "../../core/cast.js";
|
|
2
|
-
import { cloudflareCurrentUserDisplayName } from "../
|
|
2
|
+
import { cloudflareCurrentUserDisplayName } from "../cloudflare_dns/runtime-user.js";
|
|
3
3
|
import { defineProviderExecutors, ProviderRequestError } from "../provider-runtime.js";
|
|
4
4
|
import { cloudflareWorkerActionHandlers, requestCloudflareWorkerCurrentUser, validateCloudflareWorkerCredential, } from "./runtime.js";
|
|
5
5
|
const service = "cloudflare_worker";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CredentialValidationResult } from "../../core/types.ts";
|
|
2
|
-
import type { CloudflareCurrentUser } from "../
|
|
2
|
+
import type { CloudflareCurrentUser } from "../cloudflare_dns/runtime-user.ts";
|
|
3
3
|
import type { ProviderActionHandlers } from "../provider-runtime.ts";
|
|
4
4
|
import type { ProviderRuntimeHandler } from "../provider-runtime.ts";
|
|
5
5
|
export interface CloudflareWorkerContext {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compactObject, optionalBoolean, optionalInteger, optionalRecord, optionalString, requiredString, } from "../../core/cast.js";
|
|
2
2
|
import { queryParams } from "../../core/request.js";
|
|
3
|
-
import { readCloudflareCurrentUser } from "../
|
|
3
|
+
import { readCloudflareCurrentUser } from "../cloudflare_dns/runtime-user.js";
|
|
4
4
|
import { ProviderRequestError, providerUserAgent } from "../provider-runtime.js";
|
|
5
5
|
const cloudflareApiBaseUrl = "https://api.cloudflare.com/client/v4";
|
|
6
6
|
const defaultModuleName = "main.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CredentialValidators, ProviderExecutors, ProviderProxyExecutor } from "../../core/types.ts";
|
|
2
|
+
export declare const executors: ProviderExecutors;
|
|
3
|
+
export declare const proxy: ProviderProxyExecutor;
|
|
4
|
+
export declare const credentialValidators: CredentialValidators;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { looseArray, optionalString } from "../../core/cast.js";
|
|
2
|
+
import { defineApiKeyProviderExecutors, defineProviderProxy, providerInputError, ProviderRequestError, providerUserAgent, readProviderJsonBody, requiredInputString, runProviderRequest, } from "../provider-runtime.js";
|
|
3
|
+
const service = "cronfree";
|
|
4
|
+
const cronfreeApiBaseUrl = "https://login.cronfree.com/zapier";
|
|
5
|
+
const handlers = {
|
|
6
|
+
async create_schedule(input, context) {
|
|
7
|
+
const result = await requestCronfree({
|
|
8
|
+
path: "/schedule",
|
|
9
|
+
body: {
|
|
10
|
+
hookUrl: requiredInputString(input.hookUrl, "hookUrl"),
|
|
11
|
+
wdays: readStringArray(input.weekdays),
|
|
12
|
+
months: readStringArray(input.months),
|
|
13
|
+
mdays: readStringArray(input.monthDays),
|
|
14
|
+
hours: readStringArray(input.hours),
|
|
15
|
+
minutes: readStringArray(input.minutes),
|
|
16
|
+
timezone: [requiredInputString(input.timezone, "timezone")],
|
|
17
|
+
},
|
|
18
|
+
context,
|
|
19
|
+
phase: "execute",
|
|
20
|
+
});
|
|
21
|
+
return { result };
|
|
22
|
+
},
|
|
23
|
+
async delete_schedule(input, context) {
|
|
24
|
+
const result = await requestCronfree({
|
|
25
|
+
path: "/unschedule",
|
|
26
|
+
body: { hookUrl: requiredInputString(input.hookUrl, "hookUrl") },
|
|
27
|
+
context,
|
|
28
|
+
phase: "execute",
|
|
29
|
+
});
|
|
30
|
+
return { result };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const executors = defineApiKeyProviderExecutors(service, handlers, {
|
|
34
|
+
skipDnsValidation: true,
|
|
35
|
+
});
|
|
36
|
+
export const proxy = defineProviderProxy({
|
|
37
|
+
service,
|
|
38
|
+
baseUrl: cronfreeApiBaseUrl,
|
|
39
|
+
auth: { type: "api_key_json_body", name: "license_key" },
|
|
40
|
+
skipDnsValidation: true,
|
|
41
|
+
customizeRequest({ headers }) {
|
|
42
|
+
headers.set("accept", "application/json");
|
|
43
|
+
headers.set("content-type", "application/json");
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
export const credentialValidators = {
|
|
47
|
+
async apiKey(input, { fetcher, signal }) {
|
|
48
|
+
await requestCronfree({
|
|
49
|
+
path: "/unschedule",
|
|
50
|
+
body: { hookUrl: `https://connector.oomol.com/cronfree-validation/${crypto.randomUUID()}` },
|
|
51
|
+
context: { apiKey: input.apiKey, fetcher, signal },
|
|
52
|
+
phase: "validate",
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
profile: { accountId: "cronfree-license-key", displayName: "Cronfree License Key" },
|
|
56
|
+
grantedScopes: [],
|
|
57
|
+
metadata: { apiBaseUrl: cronfreeApiBaseUrl, validationEndpoint: "/unschedule" },
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
function readStringArray(value) {
|
|
62
|
+
return looseArray(value)
|
|
63
|
+
.map((item) => optionalString(item))
|
|
64
|
+
.filter((item) => item != null);
|
|
65
|
+
}
|
|
66
|
+
async function requestCronfree(input) {
|
|
67
|
+
return runProviderRequest({ signal: input.context.signal, label: "Cronfree" }, async (signal) => {
|
|
68
|
+
const response = await input.context.fetcher(`${cronfreeApiBaseUrl}${input.path}`, {
|
|
69
|
+
method: "POST",
|
|
70
|
+
headers: {
|
|
71
|
+
accept: "application/json",
|
|
72
|
+
"content-type": "application/json",
|
|
73
|
+
"user-agent": providerUserAgent,
|
|
74
|
+
},
|
|
75
|
+
body: JSON.stringify({ ...input.body, license_key: input.context.apiKey }),
|
|
76
|
+
signal,
|
|
77
|
+
});
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
if (response.status === 401 && input.phase === "validate") {
|
|
80
|
+
throw providerInputError("Cronfree rejected the license key");
|
|
81
|
+
}
|
|
82
|
+
throw new ProviderRequestError(response.status, `Cronfree request failed with HTTP ${response.status}`);
|
|
83
|
+
}
|
|
84
|
+
return readProviderJsonBody(response, {
|
|
85
|
+
emptyBody: null,
|
|
86
|
+
invalidJsonMessage: "Cronfree returned invalid JSON",
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CredentialValidators, ProviderExecutors, ProviderProxyExecutor } from "../../core/types.ts";
|
|
2
|
+
export declare const executors: ProviderExecutors;
|
|
3
|
+
export declare const proxy: ProviderProxyExecutor;
|
|
4
|
+
export declare const credentialValidators: CredentialValidators;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { compactObject, optionalRecord, optionalString } from "../../core/cast.js";
|
|
2
|
+
import { defineApiKeyProviderExecutors, defineProviderProxy, providerInputError, ProviderRequestError, providerResponseError, providerUserAgent, readProviderJsonBody, requiredResponseRecord, runProviderRequest, } from "../provider-runtime.js";
|
|
3
|
+
const service = "cufinder";
|
|
4
|
+
const baseUrl = "https://api.cufinder.io/v3";
|
|
5
|
+
const handlers = {
|
|
6
|
+
find_company_domain(input, context) {
|
|
7
|
+
return execute("/companies/name-to-domain", { name: trim(input.name), country_code: upper(input.countryCode), address: trim(input.address) }, context, (data, meta) => ({ domain: requireString(data.domain, "domain"), meta }));
|
|
8
|
+
},
|
|
9
|
+
find_company_name(input, context) {
|
|
10
|
+
return execute("/companies/domain-to-name", { domain: trim(input.domain) }, context, (data, meta) => ({
|
|
11
|
+
name: requireString(data.name, "name"),
|
|
12
|
+
meta,
|
|
13
|
+
}));
|
|
14
|
+
},
|
|
15
|
+
enrich_company(input, context) {
|
|
16
|
+
return execute("/companies/enrich", { query: trim(input.query) }, context, (data, meta) => ({
|
|
17
|
+
company: requiredResponseRecord(data.company, "cufinder company"),
|
|
18
|
+
meta,
|
|
19
|
+
}));
|
|
20
|
+
},
|
|
21
|
+
enrich_person(input, context) {
|
|
22
|
+
return execute("/people/enrich-by-name", { full_name: trim(input.fullName), company: trim(input.company) }, context, (data, meta) => ({ person: requiredResponseRecord(data.person, "cufinder person"), meta }));
|
|
23
|
+
},
|
|
24
|
+
enrich_person_by_email(input, context) {
|
|
25
|
+
return execute("/people/enrich-by-email", { email: trim(input.email) }, context, (data, meta) => ({
|
|
26
|
+
person: requiredResponseRecord(data.person, "cufinder person"),
|
|
27
|
+
meta,
|
|
28
|
+
}));
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export const executors = defineApiKeyProviderExecutors(service, handlers, {
|
|
32
|
+
skipDnsValidation: true,
|
|
33
|
+
});
|
|
34
|
+
export const proxy = defineProviderProxy({
|
|
35
|
+
service,
|
|
36
|
+
baseUrl,
|
|
37
|
+
auth: { type: "api_key_header", name: "x-api-key" },
|
|
38
|
+
skipDnsValidation: true,
|
|
39
|
+
});
|
|
40
|
+
export const credentialValidators = {
|
|
41
|
+
async apiKey(input, { fetcher, signal }) {
|
|
42
|
+
await request("/normalize/url", { value: "https://cufinder.io" }, { apiKey: input.apiKey, fetcher, signal }, "validate");
|
|
43
|
+
return {
|
|
44
|
+
profile: { accountId: "cufinder-api-key", displayName: "CUFinder API Key" },
|
|
45
|
+
grantedScopes: [],
|
|
46
|
+
metadata: { apiBaseUrl: baseUrl, validationEndpoint: "/normalize/url" },
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
async function execute(path, body, context, normalize) {
|
|
51
|
+
const payload = await request(path, body, context, "execute");
|
|
52
|
+
return normalize(requiredResponseRecord(payload.data, "cufinder data"), requiredResponseRecord(payload.meta, "cufinder metadata"));
|
|
53
|
+
}
|
|
54
|
+
async function request(path, body, context, phase) {
|
|
55
|
+
return runProviderRequest({ signal: context.signal, label: "cufinder" }, async (signal) => {
|
|
56
|
+
const response = await context.fetcher(`${baseUrl}${path}`, {
|
|
57
|
+
method: "POST",
|
|
58
|
+
headers: {
|
|
59
|
+
accept: "application/json",
|
|
60
|
+
"content-type": "application/json",
|
|
61
|
+
"user-agent": providerUserAgent,
|
|
62
|
+
"x-api-key": context.apiKey,
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify(compactObject(body)),
|
|
65
|
+
signal,
|
|
66
|
+
});
|
|
67
|
+
const decoded = await readProviderJsonBody(response, {
|
|
68
|
+
emptyBody: {},
|
|
69
|
+
invalidJsonMessage: "cufinder returned malformed JSON",
|
|
70
|
+
invalidJsonFallback: response.ok ? undefined : () => ({}),
|
|
71
|
+
});
|
|
72
|
+
const payload = optionalRecord(decoded) ?? {};
|
|
73
|
+
if (!response.ok)
|
|
74
|
+
throw makeError(response.status, payload, phase);
|
|
75
|
+
if (payload.success !== true)
|
|
76
|
+
throw makeError(response.status, payload, phase);
|
|
77
|
+
return payload;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function makeError(status, payload, phase) {
|
|
81
|
+
const error = optionalRecord(payload.error);
|
|
82
|
+
const code = optionalString(error?.code);
|
|
83
|
+
const message = optionalString(error?.message) ?? `cufinder request failed with status ${status}`;
|
|
84
|
+
if (code === "unauthorized")
|
|
85
|
+
return phase === "validate" ? providerInputError(message) : new ProviderRequestError(409, message, payload);
|
|
86
|
+
if (code === "rate_limited")
|
|
87
|
+
return new ProviderRequestError(429, message, payload);
|
|
88
|
+
if (["invalid_request", "validation_failed", "not_found"].includes(code ?? ""))
|
|
89
|
+
return providerInputError(message);
|
|
90
|
+
if (code === "request_timeout")
|
|
91
|
+
return new ProviderRequestError(504, message, payload);
|
|
92
|
+
return new ProviderRequestError(status >= 400 ? status : 502, message, payload);
|
|
93
|
+
}
|
|
94
|
+
function trim(value) {
|
|
95
|
+
return typeof value === "string" ? value.trim() : value;
|
|
96
|
+
}
|
|
97
|
+
function upper(value) {
|
|
98
|
+
return typeof value === "string" ? value.trim().toUpperCase() : value;
|
|
99
|
+
}
|
|
100
|
+
function requireString(value, field) {
|
|
101
|
+
const result = optionalString(value);
|
|
102
|
+
if (!result)
|
|
103
|
+
throw providerResponseError(`cufinder data.${field} must be a string`);
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
@@ -107,7 +107,7 @@ async function withDingTalkMcpClient(context, run) {
|
|
|
107
107
|
transport: "streamable_http",
|
|
108
108
|
fetcher: context.fetcher,
|
|
109
109
|
headers,
|
|
110
|
-
redirect: "
|
|
110
|
+
redirect: "manual",
|
|
111
111
|
signal: context.signal,
|
|
112
112
|
mapError: mapDingTalkMcpError,
|
|
113
113
|
}, run);
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import type { CredentialValidators, ProviderExecutors, ProviderProxyExecutor } from "../../core/types.ts";
|
|
2
|
-
import type { ProviderActionHandlers } from "../provider-runtime.ts";
|
|
3
|
-
interface DiscordbotContext {
|
|
4
|
-
apiKey: string;
|
|
5
|
-
fetcher: typeof fetch;
|
|
6
|
-
signal?: AbortSignal;
|
|
7
|
-
}
|
|
8
|
-
type DiscordbotActionHandler = (input: Record<string, unknown>, context: DiscordbotContext) => Promise<unknown>;
|
|
9
|
-
export declare const discordbotActionHandlers: ProviderActionHandlers<"discordbot", DiscordbotActionHandler>;
|
|
10
2
|
export declare const executors: ProviderExecutors;
|
|
11
3
|
export declare const proxy: ProviderProxyExecutor;
|
|
12
4
|
export declare const credentialValidators: CredentialValidators;
|
|
13
|
-
export {};
|