@tool-bridge/server 0.1.1 → 0.3.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.
Files changed (107) hide show
  1. package/dist/airtable-V6446SVY.js +792 -0
  2. package/dist/alt_text_generator_ai-HV7JZPDT.js +72 -0
  3. package/dist/amap-TTTVB6WS.js +755 -0
  4. package/dist/anthropic-JH3RA363.js +224 -0
  5. package/dist/apify-ETNN7ITU.js +262 -0
  6. package/dist/brave_search-3DDR2MMB.js +322 -0
  7. package/dist/chunk-CSJEZHQO.js +252 -0
  8. package/dist/chunk-JLTYA2B3.js +20121 -0
  9. package/dist/chunk-K7FVSFUX.js +333 -0
  10. package/dist/{chunk-MQEYFCJB.js → chunk-KGYJEEBI.js} +2770 -21574
  11. package/dist/circleci-MX3TX3HC.js +409 -0
  12. package/dist/clerk-MRPORVF4.js +1036 -0
  13. package/dist/cloudflare_dns-OWP7DD7L.js +605 -0
  14. package/dist/cohere-GPECP66S.js +197 -0
  15. package/dist/confluence-BN7LZ6BC.js +436 -0
  16. package/dist/convertapi-SBEOFOFQ.js +161 -0
  17. package/dist/currencyapi-P2YY7Y7P.js +306 -0
  18. package/dist/deepseek-MWB3NYIN.js +205 -0
  19. package/dist/docker_hub-3JSCIGQ3.js +946 -0
  20. package/dist/dropbox-RFIBDAXO.js +1308 -0
  21. package/dist/dub-YVP57ELQ.js +706 -0
  22. package/dist/e2b-NFSUHTZR.js +305 -0
  23. package/dist/exa-KTDY6IV3.js +360 -0
  24. package/dist/fal_ai-OCUENLNQ.js +405 -0
  25. package/dist/feishu-5CWBQ7E5.js +225 -0
  26. package/dist/feishu_custom_bot-ZJR22OK6.js +240 -0
  27. package/dist/figma-YULGANSA.js +798 -0
  28. package/dist/firehydrant-2V6YSYAP.js +573 -0
  29. package/dist/fixer-LTCDB3CJ.js +171 -0
  30. package/dist/fly-IXPKMAML.js +478 -0
  31. package/dist/front-KRFB4M5X.js +379 -0
  32. package/dist/geocodio-VVURKYHQ.js +236 -0
  33. package/dist/ghost-6J2RIOUB.js +341 -0
  34. package/dist/github-5Z6KQRYH.js +5410 -0
  35. package/dist/gmail-KU4NZ7VA.js +1894 -0
  36. package/dist/googlecalendar-X44DFFXG.js +2539 -0
  37. package/dist/googledocs-WSGLPKSF.js +1322 -0
  38. package/dist/grafana-4PKSSDXY.js +817 -0
  39. package/dist/graphhopper-DF65ZNGK.js +336 -0
  40. package/dist/index.d.ts +181 -2
  41. package/dist/index.js +2 -1
  42. package/dist/ip2proxy-UCAQ5P2J.js +118 -0
  43. package/dist/ipgeolocation_io-UX6FCA2S.js +333 -0
  44. package/dist/ipqualityscore-MKTRXIZJ.js +287 -0
  45. package/dist/jina_ai-MRHPCSV5.js +119 -0
  46. package/dist/jira-EG7ZPOIW.js +627 -0
  47. package/dist/langsmith-FNO3RCOZ.js +597 -0
  48. package/dist/lemlist-SN6BJHSG.js +298 -0
  49. package/dist/linear-H3VU4PSD.js +2163 -0
  50. package/dist/logsnag-OY2JJT2H.js +167 -0
  51. package/dist/main.js +246 -2
  52. package/dist/mattermost-C5SQ7PGD.js +320 -0
  53. package/dist/mem0-LMLE5BFC.js +567 -0
  54. package/dist/memos-UWFAMBZC.js +781 -0
  55. package/dist/metabase-SRYDSDJ6.js +365 -0
  56. package/dist/mistral_ai-YNIJ7VDM.js +1195 -0
  57. package/dist/mother_duck-CPGOFEXE.js +322 -0
  58. package/dist/ngrok-CDJFBSOM.js +375 -0
  59. package/dist/notes-DIVFH3P3.js +109 -0
  60. package/dist/notion-HGDKS4HK.js +945 -0
  61. package/dist/open_exchange_rates-COHHYJDD.js +216 -0
  62. package/dist/openai-4TRT66GW.js +795 -0
  63. package/dist/opengraph_io-YKVW4PXI.js +377 -0
  64. package/dist/openrouter-6CV7B7V5.js +444 -0
  65. package/dist/outline-YWDUK5F7.js +604 -0
  66. package/dist/paddle-MEU7HWDZ.js +464 -0
  67. package/dist/perplexity-MRQUDBIC.js +238 -0
  68. package/dist/pinecone-JI7X2TAF.js +599 -0
  69. package/dist/pipedrive-6JQPAW23.js +453 -0
  70. package/dist/polar-7BF56CMC.js +400 -0
  71. package/dist/posthog-YPU5ADEN.js +3462 -0
  72. package/dist/postmark-BEU5OFKU.js +441 -0
  73. package/dist/prerender-UT5GOOZH.js +180 -0
  74. package/dist/pubmed-3SGOE24Q.js +1052 -0
  75. package/dist/railway-CEK4GLRQ.js +452 -0
  76. package/dist/readwise-DXQUQU67.js +482 -0
  77. package/dist/render-7TGAU5AW.js +473 -0
  78. package/dist/replicate-VICFSQ5A.js +347 -0
  79. package/dist/resend-3E76WK3O.js +100 -0
  80. package/dist/rootly-36GY46BY.js +345 -0
  81. package/dist/scrapfly-VDVUYAHX.js +289 -0
  82. package/dist/scrapingbee-3KTPMAVY.js +247 -0
  83. package/dist/screenshot_fyi-LKG62C3J.js +116 -0
  84. package/dist/semantic_scholar-4WREECYO.js +626 -0
  85. package/dist/sentry-HUQTGXOV.js +1139 -0
  86. package/dist/shodan-SGRKU4KS.js +303 -0
  87. package/dist/shopify-YCZ4L5HT.js +620 -0
  88. package/dist/stripe-OEBKMELB.js +583 -0
  89. package/dist/supabase-I3DBY7L4.js +937 -0
  90. package/dist/tavily-B2YHCNRD.js +349 -0
  91. package/dist/telegram-2VYJELZX.js +1773 -0
  92. package/dist/telnyx-HHXD3CXL.js +237 -0
  93. package/dist/todoist-PHFDEEIS.js +672 -0
  94. package/dist/trello-WUSAK6YN.js +1091 -0
  95. package/dist/turso-FW56U2B3.js +432 -0
  96. package/dist/twilio-M5JI7XHA.js +321 -0
  97. package/dist/umami-HAYODRC4.js +411 -0
  98. package/dist/unsplash-EDPTNEHJ.js +364 -0
  99. package/dist/upstash_redis-GC2CLIWD.js +299 -0
  100. package/dist/uptimerobot-XMSNYLIT.js +481 -0
  101. package/dist/v2ex-KU4ECD65.js +672 -0
  102. package/dist/vercel-THPCEFHW.js +1096 -0
  103. package/dist/wolfram_alpha_api-WHHTH4GU.js +212 -0
  104. package/dist/wordpress-O6TQEQNF.js +822 -0
  105. package/dist/workos-A3VHHWI3.js +681 -0
  106. package/dist/zhihu-BJAI64YJ.js +273 -0
  107. package/package.json +5 -4
@@ -0,0 +1,453 @@
1
+ import {
2
+ createProviderPlugin,
3
+ guardedFetch,
4
+ requireApiKey,
5
+ upstreamError
6
+ } from "./chunk-CSJEZHQO.js";
7
+ import "./chunk-K7FVSFUX.js";
8
+ import {
9
+ TBError,
10
+ external_exports
11
+ } from "./chunk-JLTYA2B3.js";
12
+ import "./chunk-MLKGABMK.js";
13
+
14
+ // ../plugins/src/pipedrive/schema.ts
15
+ var listPersonsInput = external_exports.looseObject({}).describe("Input for listing Pipedrive persons.");
16
+ var listPersonsOutput = external_exports.looseObject({}).describe("Pipedrive persons list response.");
17
+ var getPersonInput = external_exports.strictObject({
18
+ personId: external_exports.int().min(1).describe("The Pipedrive person ID to retrieve.").optional()
19
+ }).describe("Input for The Pipedrive person ID to retrieve..");
20
+ var getPersonOutput = external_exports.looseObject({}).describe("Pipedrive person response.");
21
+ var createPersonInput = external_exports.looseObject({}).describe("Input for creating a Pipedrive person.");
22
+ var createPersonOutput = external_exports.looseObject({}).describe("Pipedrive create person response.");
23
+ var updatePersonInput = external_exports.looseObject({}).describe("Input for updating a Pipedrive person.");
24
+ var updatePersonOutput = external_exports.looseObject({}).describe("Pipedrive update person response.");
25
+ var deletePersonInput = external_exports.strictObject({
26
+ personId: external_exports.int().min(1).describe("The Pipedrive person ID to delete.").optional()
27
+ }).describe("Input for The Pipedrive person ID to delete..");
28
+ var deletePersonOutput = external_exports.looseObject({}).describe("Pipedrive delete person response.");
29
+ var searchPersonsInput = external_exports.looseObject({}).describe("Input for searching Pipedrive persons.");
30
+ var searchPersonsOutput = external_exports.looseObject({}).describe("Pipedrive person search response.");
31
+ var listOrganizationsInput = external_exports.looseObject({}).describe("Input for listing Pipedrive organizations.");
32
+ var listOrganizationsOutput = external_exports.looseObject({}).describe("Pipedrive organizations list response.");
33
+ var getOrganizationInput = external_exports.strictObject({
34
+ organizationId: external_exports.int().min(1).describe("The Pipedrive organization ID to retrieve.").optional()
35
+ }).describe("Input for The Pipedrive organization ID to retrieve..");
36
+ var getOrganizationOutput = external_exports.looseObject({}).describe("Pipedrive organization response.");
37
+ var createOrganizationInput = external_exports.looseObject({}).describe("Input for creating a Pipedrive organization.");
38
+ var createOrganizationOutput = external_exports.looseObject({}).describe("Pipedrive create organization response.");
39
+ var updateOrganizationInput = external_exports.looseObject({}).describe("Input for updating a Pipedrive organization.");
40
+ var updateOrganizationOutput = external_exports.looseObject({}).describe("Pipedrive update organization response.");
41
+ var deleteOrganizationInput = external_exports.strictObject({
42
+ organizationId: external_exports.int().min(1).describe("The Pipedrive organization ID to delete.").optional()
43
+ }).describe("Input for The Pipedrive organization ID to delete..");
44
+ var deleteOrganizationOutput = external_exports.looseObject({}).describe("Pipedrive delete organization response.");
45
+ var searchOrganizationsInput = external_exports.looseObject({}).describe("Input for searching Pipedrive organizations.");
46
+ var searchOrganizationsOutput = external_exports.looseObject({}).describe("Pipedrive organization search response.");
47
+ var listDealsInput = external_exports.looseObject({}).describe("Input for listing Pipedrive deals.");
48
+ var listDealsOutput = external_exports.looseObject({}).describe("Pipedrive deals list response.");
49
+ var getDealInput = external_exports.strictObject({
50
+ dealId: external_exports.int().min(1).describe("The Pipedrive deal ID to retrieve.").optional()
51
+ }).describe("Input for The Pipedrive deal ID to retrieve..");
52
+ var getDealOutput = external_exports.looseObject({}).describe("Pipedrive deal response.");
53
+ var createDealInput = external_exports.looseObject({}).describe("Input for creating a Pipedrive deal.");
54
+ var createDealOutput = external_exports.looseObject({}).describe("Pipedrive create deal response.");
55
+ var updateDealInput = external_exports.looseObject({}).describe("Input for updating a Pipedrive deal.");
56
+ var updateDealOutput = external_exports.looseObject({}).describe("Pipedrive update deal response.");
57
+ var deleteDealInput = external_exports.strictObject({
58
+ dealId: external_exports.int().min(1).describe("The Pipedrive deal ID to delete.").optional()
59
+ }).describe("Input for The Pipedrive deal ID to delete..");
60
+ var deleteDealOutput = external_exports.looseObject({}).describe("Pipedrive delete deal response.");
61
+ var searchDealsInput = external_exports.looseObject({}).describe("Input for searching Pipedrive deals.");
62
+ var searchDealsOutput = external_exports.looseObject({}).describe("Pipedrive deal search response.");
63
+ var listActivitiesInput = external_exports.looseObject({}).describe("Input for listing Pipedrive activities.");
64
+ var listActivitiesOutput = external_exports.looseObject({}).describe("Pipedrive activities list response.");
65
+ var getActivityInput = external_exports.strictObject({
66
+ activityId: external_exports.int().min(1).describe("The Pipedrive activity ID to retrieve.").optional()
67
+ }).describe("Input for The Pipedrive activity ID to retrieve..");
68
+ var getActivityOutput = external_exports.looseObject({}).describe("Pipedrive activity response.");
69
+ var createActivityInput = external_exports.looseObject({}).describe("Input for creating a Pipedrive activity.");
70
+ var createActivityOutput = external_exports.looseObject({}).describe("Pipedrive create activity response.");
71
+ var updateActivityInput = external_exports.looseObject({}).describe("Input for updating a Pipedrive activity.");
72
+ var updateActivityOutput = external_exports.looseObject({}).describe("Pipedrive update activity response.");
73
+ var deleteActivityInput = external_exports.strictObject({
74
+ activityId: external_exports.int().min(1).describe("The Pipedrive activity ID to delete.").optional()
75
+ }).describe("Input for The Pipedrive activity ID to delete..");
76
+ var deleteActivityOutput = external_exports.looseObject({}).describe("Pipedrive delete activity response.");
77
+ var listPipelinesInput = external_exports.looseObject({}).describe("Input for listing Pipedrive pipelines.");
78
+ var listPipelinesOutput = external_exports.looseObject({}).describe("Pipedrive pipelines list response.");
79
+ var getPipelineInput = external_exports.strictObject({
80
+ pipelineId: external_exports.int().min(1).describe("The Pipedrive pipeline ID to retrieve.").optional()
81
+ }).describe("Input for The Pipedrive pipeline ID to retrieve..");
82
+ var getPipelineOutput = external_exports.looseObject({}).describe("Pipedrive pipeline response.");
83
+ var listStagesInput = external_exports.looseObject({}).describe("Input for listing Pipedrive stages.");
84
+ var listStagesOutput = external_exports.looseObject({}).describe("Pipedrive stages list response.");
85
+ var getStageInput = external_exports.strictObject({
86
+ stageId: external_exports.int().min(1).describe("The Pipedrive stage ID to retrieve.").optional()
87
+ }).describe("Input for The Pipedrive stage ID to retrieve..");
88
+ var getStageOutput = external_exports.looseObject({}).describe("Pipedrive stage response.");
89
+ var pipedriveActions = {
90
+ list_persons: {
91
+ description: "List Pipedrive persons with optional owner, updated time, pagination, and custom field filters.",
92
+ effect: "read",
93
+ inputSchema: listPersonsInput,
94
+ outputSchema: external_exports.toJSONSchema(listPersonsOutput, { io: "output", unrepresentable: "any" })
95
+ },
96
+ get_person: {
97
+ description: "Get one Pipedrive person by person ID.",
98
+ effect: "read",
99
+ inputSchema: getPersonInput,
100
+ outputSchema: external_exports.toJSONSchema(getPersonOutput, { io: "output", unrepresentable: "any" })
101
+ },
102
+ create_person: {
103
+ description: "Create a Pipedrive person with contact values, labels, ownership, visibility, and custom fields.",
104
+ effect: "write",
105
+ inputSchema: createPersonInput,
106
+ outputSchema: external_exports.toJSONSchema(createPersonOutput, { io: "output", unrepresentable: "any" })
107
+ },
108
+ update_person: {
109
+ description: "Update one Pipedrive person by person ID.",
110
+ effect: "write",
111
+ inputSchema: updatePersonInput,
112
+ outputSchema: external_exports.toJSONSchema(updatePersonOutput, { io: "output", unrepresentable: "any" })
113
+ },
114
+ delete_person: {
115
+ description: "Delete one Pipedrive person by person ID.",
116
+ effect: "destructive",
117
+ inputSchema: deletePersonInput,
118
+ outputSchema: external_exports.toJSONSchema(deletePersonOutput, { io: "output", unrepresentable: "any" })
119
+ },
120
+ search_persons: {
121
+ description: "Search Pipedrive persons by name, email, phone, notes, or custom fields.",
122
+ effect: "read",
123
+ inputSchema: searchPersonsInput,
124
+ outputSchema: external_exports.toJSONSchema(searchPersonsOutput, { io: "output", unrepresentable: "any" })
125
+ },
126
+ list_organizations: {
127
+ description: "List Pipedrive organizations with optional owner, updated time, pagination, and custom field filters.",
128
+ effect: "read",
129
+ inputSchema: listOrganizationsInput,
130
+ outputSchema: external_exports.toJSONSchema(listOrganizationsOutput, { io: "output", unrepresentable: "any" })
131
+ },
132
+ get_organization: {
133
+ description: "Get one Pipedrive organization by organization ID.",
134
+ effect: "read",
135
+ inputSchema: getOrganizationInput,
136
+ outputSchema: external_exports.toJSONSchema(getOrganizationOutput, { io: "output", unrepresentable: "any" })
137
+ },
138
+ create_organization: {
139
+ description: "Create a Pipedrive organization with address, labels, ownership, visibility, and custom fields.",
140
+ effect: "write",
141
+ inputSchema: createOrganizationInput,
142
+ outputSchema: external_exports.toJSONSchema(createOrganizationOutput, { io: "output", unrepresentable: "any" })
143
+ },
144
+ update_organization: {
145
+ description: "Update one Pipedrive organization by organization ID.",
146
+ effect: "write",
147
+ inputSchema: updateOrganizationInput,
148
+ outputSchema: external_exports.toJSONSchema(updateOrganizationOutput, { io: "output", unrepresentable: "any" })
149
+ },
150
+ delete_organization: {
151
+ description: "Delete one Pipedrive organization by organization ID.",
152
+ effect: "destructive",
153
+ inputSchema: deleteOrganizationInput,
154
+ outputSchema: external_exports.toJSONSchema(deleteOrganizationOutput, { io: "output", unrepresentable: "any" })
155
+ },
156
+ search_organizations: {
157
+ description: "Search Pipedrive organizations by name, address, notes, or custom fields.",
158
+ effect: "read",
159
+ inputSchema: searchOrganizationsInput,
160
+ outputSchema: external_exports.toJSONSchema(searchOrganizationsOutput, { io: "output", unrepresentable: "any" })
161
+ },
162
+ list_deals: {
163
+ description: "List Pipedrive deals with optional owner, status, updated time, pagination, and custom field filters.",
164
+ effect: "read",
165
+ inputSchema: listDealsInput,
166
+ outputSchema: external_exports.toJSONSchema(listDealsOutput, { io: "output", unrepresentable: "any" })
167
+ },
168
+ get_deal: {
169
+ description: "Get one Pipedrive deal by deal ID.",
170
+ effect: "read",
171
+ inputSchema: getDealInput,
172
+ outputSchema: external_exports.toJSONSchema(getDealOutput, { io: "output", unrepresentable: "any" })
173
+ },
174
+ create_deal: {
175
+ description: "Create a Pipedrive deal with title, linked person or organization, value, stage, labels, and custom fields.",
176
+ effect: "write",
177
+ inputSchema: createDealInput,
178
+ outputSchema: external_exports.toJSONSchema(createDealOutput, { io: "output", unrepresentable: "any" })
179
+ },
180
+ update_deal: {
181
+ description: "Update one Pipedrive deal by deal ID.",
182
+ effect: "write",
183
+ inputSchema: updateDealInput,
184
+ outputSchema: external_exports.toJSONSchema(updateDealOutput, { io: "output", unrepresentable: "any" })
185
+ },
186
+ delete_deal: {
187
+ description: "Delete one Pipedrive deal by deal ID.",
188
+ effect: "destructive",
189
+ inputSchema: deleteDealInput,
190
+ outputSchema: external_exports.toJSONSchema(deleteDealOutput, { io: "output", unrepresentable: "any" })
191
+ },
192
+ search_deals: {
193
+ description: "Search Pipedrive deals by title, notes, or custom fields.",
194
+ effect: "read",
195
+ inputSchema: searchDealsInput,
196
+ outputSchema: external_exports.toJSONSchema(searchDealsOutput, { io: "output", unrepresentable: "any" })
197
+ },
198
+ list_activities: {
199
+ description: "List Pipedrive activities with optional user, type, date, done state, and pagination filters.",
200
+ effect: "read",
201
+ inputSchema: listActivitiesInput,
202
+ outputSchema: external_exports.toJSONSchema(listActivitiesOutput, { io: "output", unrepresentable: "any" })
203
+ },
204
+ get_activity: {
205
+ description: "Get one Pipedrive activity by activity ID.",
206
+ effect: "read",
207
+ inputSchema: getActivityInput,
208
+ outputSchema: external_exports.toJSONSchema(getActivityOutput, { io: "output", unrepresentable: "any" })
209
+ },
210
+ create_activity: {
211
+ description: "Create a Pipedrive activity with schedule, attendees, participants, linked entities, and notes.",
212
+ effect: "write",
213
+ inputSchema: createActivityInput,
214
+ outputSchema: external_exports.toJSONSchema(createActivityOutput, { io: "output", unrepresentable: "any" })
215
+ },
216
+ update_activity: {
217
+ description: "Update one Pipedrive activity by activity ID.",
218
+ effect: "write",
219
+ inputSchema: updateActivityInput,
220
+ outputSchema: external_exports.toJSONSchema(updateActivityOutput, { io: "output", unrepresentable: "any" })
221
+ },
222
+ delete_activity: {
223
+ description: "Delete one Pipedrive activity by activity ID.",
224
+ effect: "destructive",
225
+ inputSchema: deleteActivityInput,
226
+ outputSchema: external_exports.toJSONSchema(deleteActivityOutput, { io: "output", unrepresentable: "any" })
227
+ },
228
+ list_pipelines: {
229
+ description: "List Pipedrive pipelines with optional sorting and pagination.",
230
+ effect: "read",
231
+ inputSchema: listPipelinesInput,
232
+ outputSchema: external_exports.toJSONSchema(listPipelinesOutput, { io: "output", unrepresentable: "any" })
233
+ },
234
+ get_pipeline: {
235
+ description: "Get one Pipedrive pipeline by pipeline ID.",
236
+ effect: "read",
237
+ inputSchema: getPipelineInput,
238
+ outputSchema: external_exports.toJSONSchema(getPipelineOutput, { io: "output", unrepresentable: "any" })
239
+ },
240
+ list_stages: {
241
+ description: "List Pipedrive stages with optional pipeline, sorting, and pagination filters.",
242
+ effect: "read",
243
+ inputSchema: listStagesInput,
244
+ outputSchema: external_exports.toJSONSchema(listStagesOutput, { io: "output", unrepresentable: "any" })
245
+ },
246
+ get_stage: {
247
+ description: "Get one Pipedrive stage by stage ID.",
248
+ effect: "read",
249
+ inputSchema: getStageInput,
250
+ outputSchema: external_exports.toJSONSchema(getStageOutput, { io: "output", unrepresentable: "any" })
251
+ }
252
+ };
253
+
254
+ // ../plugins/src/pipedrive/api.ts
255
+ var SERVICE = "pipedrive";
256
+ var API_BASE = "https://api.pipedrive.com";
257
+ var OPERATIONS = {
258
+ list_persons: { method: "GET", path: "/api/v2/persons", listKey: "persons" },
259
+ get_person: { method: "GET", path: "/api/v2/persons/{id}", idField: "personId", itemKey: "person" },
260
+ create_person: { method: "POST", path: "/api/v2/persons", itemKey: "person" },
261
+ update_person: { method: "PATCH", path: "/api/v2/persons/{id}", idField: "personId", itemKey: "person" },
262
+ delete_person: { method: "DELETE", path: "/api/v2/persons/{id}", idField: "personId" },
263
+ search_persons: { method: "GET", path: "/api/v2/persons/search", search: true },
264
+ list_organizations: { method: "GET", path: "/api/v2/organizations", listKey: "organizations" },
265
+ get_organization: {
266
+ method: "GET",
267
+ path: "/api/v2/organizations/{id}",
268
+ idField: "organizationId",
269
+ itemKey: "organization"
270
+ },
271
+ create_organization: { method: "POST", path: "/api/v2/organizations", itemKey: "organization" },
272
+ update_organization: {
273
+ method: "PATCH",
274
+ path: "/api/v2/organizations/{id}",
275
+ idField: "organizationId",
276
+ itemKey: "organization"
277
+ },
278
+ delete_organization: { method: "DELETE", path: "/api/v2/organizations/{id}", idField: "organizationId" },
279
+ search_organizations: { method: "GET", path: "/api/v2/organizations/search", search: true },
280
+ list_deals: { method: "GET", path: "/api/v2/deals", listKey: "deals" },
281
+ get_deal: { method: "GET", path: "/api/v2/deals/{id}", idField: "dealId", itemKey: "deal" },
282
+ create_deal: { method: "POST", path: "/api/v2/deals", itemKey: "deal" },
283
+ update_deal: { method: "PATCH", path: "/api/v2/deals/{id}", idField: "dealId", itemKey: "deal" },
284
+ delete_deal: { method: "DELETE", path: "/api/v2/deals/{id}", idField: "dealId" },
285
+ search_deals: { method: "GET", path: "/api/v2/deals/search", search: true },
286
+ list_activities: { method: "GET", path: "/api/v2/activities", listKey: "activities" },
287
+ get_activity: { method: "GET", path: "/api/v2/activities/{id}", idField: "activityId", itemKey: "activity" },
288
+ create_activity: { method: "POST", path: "/api/v2/activities", itemKey: "activity" },
289
+ update_activity: {
290
+ method: "PATCH",
291
+ path: "/api/v2/activities/{id}",
292
+ idField: "activityId",
293
+ itemKey: "activity"
294
+ },
295
+ delete_activity: { method: "DELETE", path: "/api/v2/activities/{id}", idField: "activityId" },
296
+ list_pipelines: { method: "GET", path: "/api/v2/pipelines", listKey: "pipelines" },
297
+ get_pipeline: { method: "GET", path: "/api/v2/pipelines/{id}", idField: "pipelineId", itemKey: "pipeline" },
298
+ list_stages: { method: "GET", path: "/api/v2/stages", listKey: "stages" },
299
+ get_stage: { method: "GET", path: "/api/v2/stages/{id}", idField: "stageId", itemKey: "stage" }
300
+ };
301
+ function asRecord(value) {
302
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
303
+ }
304
+ function optionalText(value) {
305
+ if (typeof value !== "string") return void 0;
306
+ const trimmed = value.trim();
307
+ return trimmed === "" ? void 0 : trimmed;
308
+ }
309
+ function requiredText(value, field) {
310
+ const text = optionalText(value);
311
+ if (text === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
312
+ return text;
313
+ }
314
+ function toSnakeCase(value) {
315
+ return value.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
316
+ }
317
+ function requiredPositiveInteger(value, field) {
318
+ if (typeof value === "number" && Number.isSafeInteger(value) && value > 0) return String(value);
319
+ throw new TBError("invalid_argument", `${field} \u5FC5\u987B\u662F\u6B63\u6574\u6570`);
320
+ }
321
+ function buildPath(operation, input) {
322
+ if (operation.idField === void 0) return operation.path;
323
+ return operation.path.replace("{id}", requiredPositiveInteger(input[operation.idField], operation.idField));
324
+ }
325
+ function buildQuery(operation, input) {
326
+ const query = {};
327
+ for (const [key, value] of Object.entries(input)) {
328
+ if (key === operation.idField) continue;
329
+ if (value === void 0 || value === null || typeof value === "object") continue;
330
+ query[toSnakeCase(key)] = String(value);
331
+ }
332
+ if (operation.search === true) {
333
+ query.term = requiredText(input.term ?? input.query, "term");
334
+ }
335
+ return query;
336
+ }
337
+ function buildBody(operation, input) {
338
+ const body = {};
339
+ for (const [key, value] of Object.entries(input)) {
340
+ if (key === operation.idField || value === void 0) continue;
341
+ body[toSnakeCase(key)] = value;
342
+ }
343
+ return body;
344
+ }
345
+ async function readPayload(response) {
346
+ const text = await response.text().catch(() => "");
347
+ if (text.trim() === "") return null;
348
+ try {
349
+ return JSON.parse(text);
350
+ } catch {
351
+ return text;
352
+ }
353
+ }
354
+ function errorMessage(payload) {
355
+ if (typeof payload === "string") return optionalText(payload);
356
+ const record = asRecord(payload);
357
+ if (record === void 0) return void 0;
358
+ return optionalText(record.error) ?? optionalText(record.error_info) ?? optionalText(record.message) ?? optionalText(record.statusText);
359
+ }
360
+ async function request(ctx, operation, input) {
361
+ const apiKey = requireApiKey(ctx, SERVICE);
362
+ const url = new URL(buildPath(operation, input), API_BASE);
363
+ if (operation.method === "GET") {
364
+ for (const [key, value] of Object.entries(buildQuery(operation, input))) {
365
+ if (value !== void 0) url.searchParams.set(key, value);
366
+ }
367
+ }
368
+ const hasBody = operation.method === "POST" || operation.method === "PATCH";
369
+ const headers = {
370
+ "accept": "application/json",
371
+ "x-api-token": apiKey
372
+ };
373
+ if (hasBody) headers["content-type"] = "application/json";
374
+ let response;
375
+ let payload;
376
+ try {
377
+ response = await guardedFetch(url.toString(), {
378
+ method: operation.method,
379
+ headers,
380
+ ...hasBody ? { body: JSON.stringify(buildBody(operation, input)) } : {}
381
+ });
382
+ payload = await readPayload(response);
383
+ } catch (error) {
384
+ if (error instanceof TBError) throw error;
385
+ throw upstreamError(502, error instanceof Error ? `pipedrive \u8BF7\u6C42\u5931\u8D25: ${error.message}` : "pipedrive \u8BF7\u6C42\u5931\u8D25");
386
+ }
387
+ if (!response.ok) {
388
+ throw upstreamError(
389
+ response.status,
390
+ errorMessage(payload) ?? (response.statusText || `pipedrive \u8FD4\u56DE HTTP ${response.status}`)
391
+ );
392
+ }
393
+ const record = payload === null ? {} : asRecord(payload);
394
+ if (record === void 0) throw upstreamError(502, "pipedrive \u8FD4\u56DE\u7684\u54CD\u5E94\u4E0D\u662F JSON \u5BF9\u8C61");
395
+ if (record.success === false) {
396
+ throw upstreamError(502, errorMessage(record) ?? "pipedrive \u62A5\u544A\u4E86\u4E00\u6B21\u5931\u8D25\u7684\u54CD\u5E94");
397
+ }
398
+ return record;
399
+ }
400
+ function responseRecord(value, field) {
401
+ const record = asRecord(value);
402
+ if (record === void 0) throw upstreamError(502, `pipedrive \u54CD\u5E94\u7684 ${field} \u4E0D\u662F\u5BF9\u8C61`);
403
+ return record;
404
+ }
405
+ function nextCursor(envelope) {
406
+ const pagination = asRecord(asRecord(envelope.additional_data)?.pagination);
407
+ return optionalText(pagination?.next_cursor) ?? null;
408
+ }
409
+ function shapeOutput(envelope, operation) {
410
+ const data = envelope.data;
411
+ if (operation.listKey !== void 0) {
412
+ return { [operation.listKey]: Array.isArray(data) ? data : [], nextCursor: nextCursor(envelope) };
413
+ }
414
+ if (operation.itemKey !== void 0) {
415
+ return { [operation.itemKey]: responseRecord(data, "data") };
416
+ }
417
+ if (operation.search === true) {
418
+ const searchData = responseRecord(data, "data");
419
+ return { items: Array.isArray(searchData.items) ? searchData.items : [], nextCursor: nextCursor(envelope) };
420
+ }
421
+ const deleted = asRecord(data);
422
+ const id = deleted?.id;
423
+ return {
424
+ // id 通常是整数;不是整数时如实透出原值,而不是伪造成 null —— 调用方要能看见上游给了什么。
425
+ id: id === void 0 ? null : id,
426
+ deleted: true,
427
+ raw: data ?? null
428
+ };
429
+ }
430
+ async function execute(operation, input, ctx) {
431
+ return shapeOutput(await request(ctx, operation, input), operation);
432
+ }
433
+ var pipedriveHandlers = Object.fromEntries(
434
+ Object.entries(OPERATIONS).map(([name, operation]) => [
435
+ name,
436
+ (input, ctx) => execute(operation, input, ctx)
437
+ ])
438
+ );
439
+
440
+ // ../plugins/src/pipedrive/index.ts
441
+ function createPipedrivePlugin() {
442
+ return createProviderPlugin({
443
+ description: "Pipedrive",
444
+ actions: pipedriveActions,
445
+ credentialProbe: "list_pipelines",
446
+ handlers: pipedriveHandlers
447
+ });
448
+ }
449
+ var pipedrive_default = createPipedrivePlugin();
450
+ export {
451
+ createPipedrivePlugin,
452
+ pipedrive_default as default
453
+ };