@squadbase/vite-server 0.1.2 → 0.1.3-dev.1
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/dist/cli/index.js +13609 -3797
- package/dist/connectors/airtable-oauth.js +12 -4
- package/dist/connectors/amplitude.js +335 -32
- package/dist/connectors/asana.d.ts +5 -0
- package/dist/connectors/asana.js +661 -0
- package/dist/connectors/attio.js +304 -36
- package/dist/connectors/customerio.d.ts +5 -0
- package/dist/connectors/customerio.js +633 -0
- package/dist/connectors/gmail-oauth.d.ts +5 -0
- package/dist/connectors/gmail-oauth.js +639 -0
- package/dist/connectors/google-ads-oauth.js +14 -8
- package/dist/connectors/google-ads.d.ts +5 -0
- package/dist/connectors/google-ads.js +784 -0
- package/dist/connectors/google-analytics-oauth.js +16 -8
- package/dist/connectors/google-sheets-oauth.js +12 -4
- package/dist/connectors/google-sheets.d.ts +5 -0
- package/dist/connectors/google-sheets.js +598 -0
- package/dist/connectors/hubspot-oauth.js +12 -4
- package/dist/connectors/hubspot.d.ts +5 -0
- package/dist/connectors/hubspot.js +550 -0
- package/dist/connectors/intercom-oauth.d.ts +5 -0
- package/dist/connectors/intercom-oauth.js +510 -0
- package/dist/connectors/intercom.d.ts +5 -0
- package/dist/connectors/intercom.js +627 -0
- package/dist/connectors/jira-api-key.d.ts +5 -0
- package/dist/connectors/jira-api-key.js +523 -0
- package/dist/connectors/kintone-api-token.js +16 -20
- package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
- package/dist/connectors/linkedin-ads-oauth.js +774 -0
- package/dist/connectors/linkedin-ads.d.ts +5 -0
- package/dist/connectors/linkedin-ads.js +782 -0
- package/dist/connectors/mailchimp-oauth.d.ts +5 -0
- package/dist/connectors/mailchimp-oauth.js +539 -0
- package/dist/connectors/mailchimp.d.ts +5 -0
- package/dist/connectors/mailchimp.js +646 -0
- package/dist/connectors/shopify-oauth.js +12 -4
- package/dist/connectors/shopify.js +500 -80
- package/dist/connectors/stripe-oauth.js +12 -4
- package/dist/connectors/zendesk-oauth.d.ts +5 -0
- package/dist/connectors/zendesk-oauth.js +505 -0
- package/dist/connectors/zendesk.d.ts +5 -0
- package/dist/connectors/zendesk.js +631 -0
- package/dist/index.js +13594 -3782
- package/dist/main.js +13596 -3784
- package/dist/vite-plugin.js +13596 -3784
- package/package.json +46 -2
|
@@ -296,9 +296,13 @@ var stripeOauthConnector = new ConnectorPlugin({
|
|
|
296
296
|
]
|
|
297
297
|
},
|
|
298
298
|
systemPrompt: {
|
|
299
|
-
en: `###
|
|
299
|
+
en: `### Tools
|
|
300
300
|
|
|
301
|
-
|
|
301
|
+
- \`stripe-oauth_request\`: The only way to call the Stripe API. Use it to query charges, customers, invoices, subscriptions, products, prices, payment intents, balances, and more. Authentication is configured automatically via OAuth. Stripe uses cursor-based pagination with \`starting_after\` and \`has_more\`.
|
|
302
|
+
|
|
303
|
+
### Stripe API Reference
|
|
304
|
+
|
|
305
|
+
#### Available Endpoints
|
|
302
306
|
- GET \`/v1/charges\` \u2014 List charges
|
|
303
307
|
- GET \`/v1/charges/{chargeId}\` \u2014 Get a charge
|
|
304
308
|
- GET \`/v1/customers\` \u2014 List customers
|
|
@@ -341,9 +345,13 @@ const stripe = connection("<connectionId>");
|
|
|
341
345
|
const res = await stripe.request("/v1/customers?limit=10");
|
|
342
346
|
const data = await res.json();
|
|
343
347
|
\`\`\``,
|
|
344
|
-
ja: `###
|
|
348
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
349
|
+
|
|
350
|
+
- \`stripe-oauth_request\`: Stripe API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u8ACB\u6C42\u3001\u9867\u5BA2\u3001\u8ACB\u6C42\u66F8\u3001\u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u3001\u5546\u54C1\u3001\u4FA1\u683C\u3001\u652F\u6255\u3044\u30A4\u30F3\u30C6\u30F3\u30C8\u3001\u6B8B\u9AD8\u306A\u3069\u306E\u30AF\u30A8\u30EA\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Stripe\u306F \`starting_after\` \u3068 \`has_more\` \u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
|
|
351
|
+
|
|
352
|
+
### Stripe API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
345
353
|
|
|
346
|
-
|
|
354
|
+
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
347
355
|
- GET \`/v1/charges\` \u2014 \u8ACB\u6C42\u4E00\u89A7\u3092\u53D6\u5F97
|
|
348
356
|
- GET \`/v1/charges/{chargeId}\` \u2014 \u8ACB\u6C42\u3092\u53D6\u5F97
|
|
349
357
|
- GET \`/v1/customers\` \u2014 \u9867\u5BA2\u4E00\u89A7\u3092\u53D6\u5F97
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
// ../connectors/src/connectors/zendesk-oauth/sdk/index.ts
|
|
2
|
+
function createClient(_params, fetchFn = fetch) {
|
|
3
|
+
function request(path2, init) {
|
|
4
|
+
return fetchFn(path2, init);
|
|
5
|
+
}
|
|
6
|
+
return { request };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// ../connectors/src/connector-onboarding.ts
|
|
10
|
+
var ConnectorOnboarding = class {
|
|
11
|
+
/** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
|
|
12
|
+
connectionSetupInstructions;
|
|
13
|
+
/** Phase 2: Data overview instructions */
|
|
14
|
+
dataOverviewInstructions;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.connectionSetupInstructions = config.connectionSetupInstructions;
|
|
17
|
+
this.dataOverviewInstructions = config.dataOverviewInstructions;
|
|
18
|
+
}
|
|
19
|
+
getConnectionSetupPrompt(language) {
|
|
20
|
+
return this.connectionSetupInstructions?.[language] ?? null;
|
|
21
|
+
}
|
|
22
|
+
getDataOverviewInstructions(language) {
|
|
23
|
+
return this.dataOverviewInstructions[language];
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// ../connectors/src/connector-tool.ts
|
|
28
|
+
var ConnectorTool = class {
|
|
29
|
+
name;
|
|
30
|
+
description;
|
|
31
|
+
inputSchema;
|
|
32
|
+
outputSchema;
|
|
33
|
+
_execute;
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.name = config.name;
|
|
36
|
+
this.description = config.description;
|
|
37
|
+
this.inputSchema = config.inputSchema;
|
|
38
|
+
this.outputSchema = config.outputSchema;
|
|
39
|
+
this._execute = config.execute;
|
|
40
|
+
}
|
|
41
|
+
createTool(connections, config) {
|
|
42
|
+
return {
|
|
43
|
+
description: this.description,
|
|
44
|
+
inputSchema: this.inputSchema,
|
|
45
|
+
outputSchema: this.outputSchema,
|
|
46
|
+
execute: (input) => this._execute(input, connections, config)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// ../connectors/src/connector-plugin.ts
|
|
52
|
+
var ConnectorPlugin = class _ConnectorPlugin {
|
|
53
|
+
slug;
|
|
54
|
+
authType;
|
|
55
|
+
name;
|
|
56
|
+
description;
|
|
57
|
+
iconUrl;
|
|
58
|
+
parameters;
|
|
59
|
+
releaseFlag;
|
|
60
|
+
proxyPolicy;
|
|
61
|
+
experimentalAttributes;
|
|
62
|
+
onboarding;
|
|
63
|
+
systemPrompt;
|
|
64
|
+
tools;
|
|
65
|
+
query;
|
|
66
|
+
checkConnection;
|
|
67
|
+
constructor(config) {
|
|
68
|
+
this.slug = config.slug;
|
|
69
|
+
this.authType = config.authType;
|
|
70
|
+
this.name = config.name;
|
|
71
|
+
this.description = config.description;
|
|
72
|
+
this.iconUrl = config.iconUrl;
|
|
73
|
+
this.parameters = config.parameters;
|
|
74
|
+
this.releaseFlag = config.releaseFlag;
|
|
75
|
+
this.proxyPolicy = config.proxyPolicy;
|
|
76
|
+
this.experimentalAttributes = config.experimentalAttributes;
|
|
77
|
+
this.onboarding = config.onboarding;
|
|
78
|
+
this.systemPrompt = config.systemPrompt;
|
|
79
|
+
this.tools = config.tools;
|
|
80
|
+
this.query = config.query;
|
|
81
|
+
this.checkConnection = config.checkConnection;
|
|
82
|
+
}
|
|
83
|
+
get connectorKey() {
|
|
84
|
+
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create tools for connections that belong to this connector.
|
|
88
|
+
* Filters connections by connectorKey internally.
|
|
89
|
+
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
90
|
+
*/
|
|
91
|
+
createTools(connections, config) {
|
|
92
|
+
const myConnections = connections.filter(
|
|
93
|
+
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
94
|
+
);
|
|
95
|
+
const result = {};
|
|
96
|
+
for (const t of Object.values(this.tools)) {
|
|
97
|
+
result[`${this.connectorKey}_${t.name}`] = t.createTool(
|
|
98
|
+
myConnections,
|
|
99
|
+
config
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
static deriveKey(slug, authType) {
|
|
105
|
+
return authType ? `${slug}-${authType}` : slug;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// ../connectors/src/auth-types.ts
|
|
110
|
+
var AUTH_TYPES = {
|
|
111
|
+
OAUTH: "oauth",
|
|
112
|
+
API_KEY: "api-key",
|
|
113
|
+
JWT: "jwt",
|
|
114
|
+
SERVICE_ACCOUNT: "service-account",
|
|
115
|
+
PAT: "pat"
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// ../connectors/src/connectors/zendesk-oauth/tools/request.ts
|
|
119
|
+
import { z } from "zod";
|
|
120
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
121
|
+
var cachedToken = null;
|
|
122
|
+
async function getProxyToken(config) {
|
|
123
|
+
if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
|
|
124
|
+
return cachedToken.token;
|
|
125
|
+
}
|
|
126
|
+
const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
|
|
127
|
+
const res = await fetch(url, {
|
|
128
|
+
method: "POST",
|
|
129
|
+
headers: {
|
|
130
|
+
"Content-Type": "application/json",
|
|
131
|
+
"x-api-key": config.appApiKey,
|
|
132
|
+
"project-id": config.projectId
|
|
133
|
+
},
|
|
134
|
+
body: JSON.stringify({
|
|
135
|
+
sandboxId: config.sandboxId,
|
|
136
|
+
issuedBy: "coding-agent"
|
|
137
|
+
})
|
|
138
|
+
});
|
|
139
|
+
if (!res.ok) {
|
|
140
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
141
|
+
throw new Error(
|
|
142
|
+
`Failed to get proxy token: HTTP ${res.status} ${errorText}`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const data = await res.json();
|
|
146
|
+
cachedToken = {
|
|
147
|
+
token: data.token,
|
|
148
|
+
expiresAt: new Date(data.expiresAt).getTime()
|
|
149
|
+
};
|
|
150
|
+
return data.token;
|
|
151
|
+
}
|
|
152
|
+
var inputSchema = z.object({
|
|
153
|
+
toolUseIntent: z.string().optional().describe(
|
|
154
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
155
|
+
),
|
|
156
|
+
connectionId: z.string().describe("ID of the Zendesk OAuth connection to use"),
|
|
157
|
+
method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
|
|
158
|
+
path: z.string().describe(
|
|
159
|
+
"API path appended to the Zendesk base URL (e.g., '/api/v2/tickets.json', '/api/v2/search.json?query=status:open')"
|
|
160
|
+
),
|
|
161
|
+
queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
|
|
162
|
+
body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PUT requests")
|
|
163
|
+
});
|
|
164
|
+
var outputSchema = z.discriminatedUnion("success", [
|
|
165
|
+
z.object({
|
|
166
|
+
success: z.literal(true),
|
|
167
|
+
status: z.number(),
|
|
168
|
+
data: z.record(z.string(), z.unknown())
|
|
169
|
+
}),
|
|
170
|
+
z.object({
|
|
171
|
+
success: z.literal(false),
|
|
172
|
+
error: z.string()
|
|
173
|
+
})
|
|
174
|
+
]);
|
|
175
|
+
var requestTool = new ConnectorTool({
|
|
176
|
+
name: "request",
|
|
177
|
+
description: `Send authenticated requests to the Zendesk Support API.
|
|
178
|
+
Authentication is handled automatically via OAuth proxy.
|
|
179
|
+
Use this tool for all Zendesk API interactions: querying tickets, users, organizations, groups, and searching.
|
|
180
|
+
Zendesk uses cursor-based pagination with page[size] and page[after] parameters. All endpoint paths end with .json.`,
|
|
181
|
+
inputSchema,
|
|
182
|
+
outputSchema,
|
|
183
|
+
async execute({ connectionId, method, path: path2, queryParams, body }, connections, config) {
|
|
184
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
185
|
+
if (!connection2) {
|
|
186
|
+
return {
|
|
187
|
+
success: false,
|
|
188
|
+
error: `Connection ${connectionId} not found`
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
console.log(
|
|
192
|
+
`[connector-request] zendesk-oauth/${connection2.name}: ${method} ${path2}`
|
|
193
|
+
);
|
|
194
|
+
try {
|
|
195
|
+
let url = path2;
|
|
196
|
+
if (queryParams) {
|
|
197
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
198
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
199
|
+
url += `${separator}${searchParams.toString()}`;
|
|
200
|
+
}
|
|
201
|
+
const token = await getProxyToken(config.oauthProxy);
|
|
202
|
+
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
203
|
+
const controller = new AbortController();
|
|
204
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
205
|
+
try {
|
|
206
|
+
const response = await fetch(proxyUrl, {
|
|
207
|
+
method: "POST",
|
|
208
|
+
headers: {
|
|
209
|
+
"Content-Type": "application/json",
|
|
210
|
+
Authorization: `Bearer ${token}`
|
|
211
|
+
},
|
|
212
|
+
body: JSON.stringify({
|
|
213
|
+
url,
|
|
214
|
+
method,
|
|
215
|
+
body: body ? JSON.stringify(body) : void 0
|
|
216
|
+
}),
|
|
217
|
+
signal: controller.signal
|
|
218
|
+
});
|
|
219
|
+
const data = await response.json();
|
|
220
|
+
if (!response.ok) {
|
|
221
|
+
const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.description === "string" ? data.description : `HTTP ${response.status} ${response.statusText}`;
|
|
222
|
+
return { success: false, error: errorMessage };
|
|
223
|
+
}
|
|
224
|
+
return { success: true, status: response.status, data };
|
|
225
|
+
} finally {
|
|
226
|
+
clearTimeout(timeout);
|
|
227
|
+
}
|
|
228
|
+
} catch (err) {
|
|
229
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
230
|
+
return { success: false, error: msg };
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// ../connectors/src/connectors/zendesk-oauth/setup.ts
|
|
236
|
+
var requestToolName = `zendesk-oauth_${requestTool.name}`;
|
|
237
|
+
var zendeskOauthOnboarding = new ConnectorOnboarding({
|
|
238
|
+
connectionSetupInstructions: {
|
|
239
|
+
en: `Follow these steps to set up the Zendesk connection.
|
|
240
|
+
|
|
241
|
+
1. Call \`${requestToolName}\` to fetch account info:
|
|
242
|
+
- \`method\`: \`"GET"\`
|
|
243
|
+
- \`path\`: \`"/api/v2/account/settings.json"\`
|
|
244
|
+
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
245
|
+
3. Call \`updateConnectionContext\`:
|
|
246
|
+
- \`account\`: Zendesk subdomain or account name
|
|
247
|
+
- \`note\`: Brief description of the setup
|
|
248
|
+
|
|
249
|
+
#### Constraints
|
|
250
|
+
- **Do NOT read business data during setup**. Only the metadata request specified in the steps above is allowed
|
|
251
|
+
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`,
|
|
252
|
+
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Zendesk\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
253
|
+
|
|
254
|
+
1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
255
|
+
- \`method\`: \`"GET"\`
|
|
256
|
+
- \`path\`: \`"/api/v2/account/settings.json"\`
|
|
257
|
+
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BOAuth\u63A5\u7D9A\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
258
|
+
3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
259
|
+
- \`account\`: Zendesk\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u307E\u305F\u306F\u30A2\u30AB\u30A6\u30F3\u30C8\u540D
|
|
260
|
+
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
261
|
+
|
|
262
|
+
#### \u5236\u7D04
|
|
263
|
+
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30D3\u30B8\u30CD\u30B9\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u307F
|
|
264
|
+
- \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u3002\u4E0D\u8981\u306A\u8AAC\u660E\u306F\u7701\u7565\u3057\u3001\u52B9\u7387\u7684\u306B\u9032\u3081\u308B`
|
|
265
|
+
},
|
|
266
|
+
dataOverviewInstructions: {
|
|
267
|
+
en: `1. Call zendesk-oauth_request with GET /api/v2/ticket_fields.json to list available ticket fields
|
|
268
|
+
2. Call zendesk-oauth_request with GET /api/v2/tickets.json?page[size]=5 to explore ticket structure
|
|
269
|
+
3. Call zendesk-oauth_request with GET /api/v2/users.json?page[size]=5 to explore user structure
|
|
270
|
+
4. Call zendesk-oauth_request with GET /api/v2/organizations.json?page[size]=5 to explore organization structure`,
|
|
271
|
+
ja: `1. zendesk-oauth_request \u3067 GET /api/v2/ticket_fields.json \u3092\u547C\u3073\u51FA\u3057\u3001\u5229\u7528\u53EF\u80FD\u306A\u30C1\u30B1\u30C3\u30C8\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u78BA\u8A8D
|
|
272
|
+
2. zendesk-oauth_request \u3067 GET /api/v2/tickets.json?page[size]=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u30C1\u30B1\u30C3\u30C8\u306E\u69CB\u9020\u3092\u78BA\u8A8D
|
|
273
|
+
3. zendesk-oauth_request \u3067 GET /api/v2/users.json?page[size]=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306E\u69CB\u9020\u3092\u78BA\u8A8D
|
|
274
|
+
4. zendesk-oauth_request \u3067 GET /api/v2/organizations.json?page[size]=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u7D44\u7E54\u306E\u69CB\u9020\u3092\u78BA\u8A8D`
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// ../connectors/src/connectors/zendesk-oauth/parameters.ts
|
|
279
|
+
var parameters = {};
|
|
280
|
+
|
|
281
|
+
// ../connectors/src/connectors/zendesk-oauth/index.ts
|
|
282
|
+
var tools = { request: requestTool };
|
|
283
|
+
var zendeskOauthConnector = new ConnectorPlugin({
|
|
284
|
+
slug: "zendesk",
|
|
285
|
+
authType: AUTH_TYPES.OAUTH,
|
|
286
|
+
name: "Zendesk (OAuth)",
|
|
287
|
+
description: "Connect to Zendesk Support for tickets, users, organizations, and customer service data using OAuth.",
|
|
288
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4vJHzNjXZ5gPabCCjTMz7v/2afba49a2b7e901f1e6c3cfa16d76e82/zendesk.svg",
|
|
289
|
+
parameters,
|
|
290
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
291
|
+
onboarding: zendeskOauthOnboarding,
|
|
292
|
+
proxyPolicy: {
|
|
293
|
+
allowlist: [
|
|
294
|
+
{
|
|
295
|
+
host: "*.zendesk.com",
|
|
296
|
+
methods: ["GET", "POST", "PUT", "DELETE"]
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
},
|
|
300
|
+
systemPrompt: {
|
|
301
|
+
en: `### Tools
|
|
302
|
+
|
|
303
|
+
- \`zendesk-oauth_request\`: The only way to call the Zendesk Support API. Use it to query tickets, users, organizations, groups, and perform searches. Authentication is configured automatically via OAuth. Zendesk uses cursor-based pagination with \`page[size]\` and \`page[after]\` parameters. All endpoint paths end with \`.json\`.
|
|
304
|
+
|
|
305
|
+
### Zendesk API Reference
|
|
306
|
+
|
|
307
|
+
#### Tickets
|
|
308
|
+
- GET \`/api/v2/tickets.json\` \u2014 List tickets
|
|
309
|
+
- GET \`/api/v2/tickets/{id}.json\` \u2014 Get a ticket
|
|
310
|
+
- POST \`/api/v2/tickets.json\` \u2014 Create a ticket
|
|
311
|
+
- PUT \`/api/v2/tickets/{id}.json\` \u2014 Update a ticket
|
|
312
|
+
- DELETE \`/api/v2/tickets/{id}.json\` \u2014 Delete a ticket
|
|
313
|
+
- GET \`/api/v2/tickets/{id}/comments.json\` \u2014 List ticket comments
|
|
314
|
+
|
|
315
|
+
#### Users
|
|
316
|
+
- GET \`/api/v2/users.json\` \u2014 List users
|
|
317
|
+
- GET \`/api/v2/users/{id}.json\` \u2014 Get a user
|
|
318
|
+
|
|
319
|
+
#### Organizations
|
|
320
|
+
- GET \`/api/v2/organizations.json\` \u2014 List organizations
|
|
321
|
+
- GET \`/api/v2/organizations/{id}.json\` \u2014 Get an organization
|
|
322
|
+
|
|
323
|
+
#### Groups
|
|
324
|
+
- GET \`/api/v2/groups.json\` \u2014 List groups
|
|
325
|
+
|
|
326
|
+
#### Search
|
|
327
|
+
- GET \`/api/v2/search.json?query={query}\` \u2014 Search tickets, users, organizations
|
|
328
|
+
- Query params: \`sort_by\` (updated_at, created_at, priority, status), \`sort_order\` (asc, desc)
|
|
329
|
+
|
|
330
|
+
#### Ticket Fields & Forms
|
|
331
|
+
- GET \`/api/v2/ticket_fields.json\` \u2014 List ticket fields
|
|
332
|
+
- GET \`/api/v2/ticket_forms.json\` \u2014 List ticket forms
|
|
333
|
+
|
|
334
|
+
#### Views
|
|
335
|
+
- GET \`/api/v2/views.json\` \u2014 List views
|
|
336
|
+
- GET \`/api/v2/views/{id}/tickets.json\` \u2014 List tickets in a view
|
|
337
|
+
|
|
338
|
+
### Tips
|
|
339
|
+
- All endpoint paths end with \`.json\`
|
|
340
|
+
- Pagination uses cursor-based \`page[size]\` and \`page[after]\` parameters
|
|
341
|
+
- Search uses Zendesk query syntax (e.g., \`type:ticket status:open\`)
|
|
342
|
+
- Max 100 results per page
|
|
343
|
+
|
|
344
|
+
### Business Logic
|
|
345
|
+
|
|
346
|
+
The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables.
|
|
347
|
+
|
|
348
|
+
#### Example
|
|
349
|
+
|
|
350
|
+
\`\`\`ts
|
|
351
|
+
import { connection } from "@squadbase/vite-server/connectors/zendesk-oauth";
|
|
352
|
+
|
|
353
|
+
const zendesk = connection("<connectionId>");
|
|
354
|
+
|
|
355
|
+
// Authenticated fetch (returns standard Response)
|
|
356
|
+
const res = await zendesk.request("/api/v2/tickets.json?page[size]=10");
|
|
357
|
+
const data = await res.json();
|
|
358
|
+
\`\`\``,
|
|
359
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
360
|
+
|
|
361
|
+
- \`zendesk-oauth_request\`: Zendesk Support API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30C1\u30B1\u30C3\u30C8\u3001\u30E6\u30FC\u30B6\u30FC\u3001\u7D44\u7E54\u3001\u30B0\u30EB\u30FC\u30D7\u306E\u30AF\u30A8\u30EA\u3084\u691C\u7D22\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Zendesk\u306F \`page[size]\` \u3068 \`page[after]\` \u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002\u5168\u3066\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u30D1\u30B9\u306F \`.json\` \u3067\u7D42\u308F\u308A\u307E\u3059\u3002
|
|
362
|
+
|
|
363
|
+
### Zendesk API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
364
|
+
|
|
365
|
+
#### \u30C1\u30B1\u30C3\u30C8
|
|
366
|
+
- GET \`/api/v2/tickets.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
|
|
367
|
+
- GET \`/api/v2/tickets/{id}.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u53D6\u5F97
|
|
368
|
+
- POST \`/api/v2/tickets.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u4F5C\u6210
|
|
369
|
+
- PUT \`/api/v2/tickets/{id}.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u66F4\u65B0
|
|
370
|
+
- DELETE \`/api/v2/tickets/{id}.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u524A\u9664
|
|
371
|
+
- GET \`/api/v2/tickets/{id}/comments.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u30B3\u30E1\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
|
|
372
|
+
|
|
373
|
+
#### \u30E6\u30FC\u30B6\u30FC
|
|
374
|
+
- GET \`/api/v2/users.json\` \u2014 \u30E6\u30FC\u30B6\u30FC\u4E00\u89A7\u3092\u53D6\u5F97
|
|
375
|
+
- GET \`/api/v2/users/{id}.json\` \u2014 \u30E6\u30FC\u30B6\u30FC\u3092\u53D6\u5F97
|
|
376
|
+
|
|
377
|
+
#### \u7D44\u7E54
|
|
378
|
+
- GET \`/api/v2/organizations.json\` \u2014 \u7D44\u7E54\u4E00\u89A7\u3092\u53D6\u5F97
|
|
379
|
+
- GET \`/api/v2/organizations/{id}.json\` \u2014 \u7D44\u7E54\u3092\u53D6\u5F97
|
|
380
|
+
|
|
381
|
+
#### \u30B0\u30EB\u30FC\u30D7
|
|
382
|
+
- GET \`/api/v2/groups.json\` \u2014 \u30B0\u30EB\u30FC\u30D7\u4E00\u89A7\u3092\u53D6\u5F97
|
|
383
|
+
|
|
384
|
+
#### \u691C\u7D22
|
|
385
|
+
- GET \`/api/v2/search.json?query={query}\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3001\u30E6\u30FC\u30B6\u30FC\u3001\u7D44\u7E54\u3092\u691C\u7D22
|
|
386
|
+
- \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: \`sort_by\`\uFF08updated_at, created_at, priority, status\uFF09\u3001\`sort_order\`\uFF08asc, desc\uFF09
|
|
387
|
+
|
|
388
|
+
#### \u30C1\u30B1\u30C3\u30C8\u30D5\u30A3\u30FC\u30EB\u30C9\u30FB\u30D5\u30A9\u30FC\u30E0
|
|
389
|
+
- GET \`/api/v2/ticket_fields.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u30D5\u30A3\u30FC\u30EB\u30C9\u4E00\u89A7\u3092\u53D6\u5F97
|
|
390
|
+
- GET \`/api/v2/ticket_forms.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u4E00\u89A7\u3092\u53D6\u5F97
|
|
391
|
+
|
|
392
|
+
#### \u30D3\u30E5\u30FC
|
|
393
|
+
- GET \`/api/v2/views.json\` \u2014 \u30D3\u30E5\u30FC\u4E00\u89A7\u3092\u53D6\u5F97
|
|
394
|
+
- GET \`/api/v2/views/{id}/tickets.json\` \u2014 \u30D3\u30E5\u30FC\u5185\u306E\u30C1\u30B1\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
|
|
395
|
+
|
|
396
|
+
### \u30D2\u30F3\u30C8
|
|
397
|
+
- \u5168\u3066\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u30D1\u30B9\u306F \`.json\` \u3067\u7D42\u308F\u308A\u307E\u3059
|
|
398
|
+
- \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u306F\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E \`page[size]\` \u3068 \`page[after]\` \u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4F7F\u7528\u3057\u307E\u3059
|
|
399
|
+
- \u691C\u7D22\u306FZendesk\u30AF\u30A8\u30EA\u69CB\u6587\u3092\u4F7F\u7528\u3057\u307E\u3059\uFF08\u4F8B: \`type:ticket status:open\`\uFF09
|
|
400
|
+
- 1\u30DA\u30FC\u30B8\u3042\u305F\u308A\u6700\u5927100\u4EF6
|
|
401
|
+
|
|
402
|
+
### Business Logic
|
|
403
|
+
|
|
404
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
405
|
+
|
|
406
|
+
#### Example
|
|
407
|
+
|
|
408
|
+
\`\`\`ts
|
|
409
|
+
import { connection } from "@squadbase/vite-server/connectors/zendesk-oauth";
|
|
410
|
+
|
|
411
|
+
const zendesk = connection("<connectionId>");
|
|
412
|
+
|
|
413
|
+
// Authenticated fetch (returns standard Response)
|
|
414
|
+
const res = await zendesk.request("/api/v2/tickets.json?page[size]=10");
|
|
415
|
+
const data = await res.json();
|
|
416
|
+
\`\`\``
|
|
417
|
+
},
|
|
418
|
+
tools,
|
|
419
|
+
async checkConnection(_params, config) {
|
|
420
|
+
const { proxyFetch } = config;
|
|
421
|
+
try {
|
|
422
|
+
const res = await proxyFetch("/api/v2/account/settings.json", {
|
|
423
|
+
method: "GET"
|
|
424
|
+
});
|
|
425
|
+
if (!res.ok) {
|
|
426
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
427
|
+
return {
|
|
428
|
+
success: false,
|
|
429
|
+
error: `Zendesk API failed: HTTP ${res.status} ${errorText}`
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
return { success: true };
|
|
433
|
+
} catch (error) {
|
|
434
|
+
return {
|
|
435
|
+
success: false,
|
|
436
|
+
error: error instanceof Error ? error.message : String(error)
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
// src/connectors/create-connector-sdk.ts
|
|
443
|
+
import { readFileSync } from "fs";
|
|
444
|
+
import path from "path";
|
|
445
|
+
|
|
446
|
+
// src/connector-client/env.ts
|
|
447
|
+
function resolveEnvVar(entry, key, connectionId) {
|
|
448
|
+
const envVarName = entry.envVars[key];
|
|
449
|
+
if (!envVarName) {
|
|
450
|
+
throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
|
|
451
|
+
}
|
|
452
|
+
const value = process.env[envVarName];
|
|
453
|
+
if (!value) {
|
|
454
|
+
throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
|
|
455
|
+
}
|
|
456
|
+
return value;
|
|
457
|
+
}
|
|
458
|
+
function resolveEnvVarOptional(entry, key) {
|
|
459
|
+
const envVarName = entry.envVars[key];
|
|
460
|
+
if (!envVarName) return void 0;
|
|
461
|
+
return process.env[envVarName] || void 0;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/connectors/create-connector-sdk.ts
|
|
465
|
+
function loadConnectionsSync() {
|
|
466
|
+
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
467
|
+
try {
|
|
468
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
469
|
+
return JSON.parse(raw);
|
|
470
|
+
} catch {
|
|
471
|
+
return {};
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function createConnectorSdk(plugin, createClient2) {
|
|
475
|
+
return (connectionId) => {
|
|
476
|
+
const connections = loadConnectionsSync();
|
|
477
|
+
const entry = connections[connectionId];
|
|
478
|
+
if (!entry) {
|
|
479
|
+
throw new Error(
|
|
480
|
+
`Connection "${connectionId}" not found in .squadbase/connections.json`
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
if (entry.connector.slug !== plugin.slug) {
|
|
484
|
+
throw new Error(
|
|
485
|
+
`Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
const params = {};
|
|
489
|
+
for (const param of Object.values(plugin.parameters)) {
|
|
490
|
+
if (param.required) {
|
|
491
|
+
params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
|
|
492
|
+
} else {
|
|
493
|
+
const val = resolveEnvVarOptional(entry, param.slug);
|
|
494
|
+
if (val !== void 0) params[param.slug] = val;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return createClient2(params);
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// src/connectors/entries/zendesk-oauth.ts
|
|
502
|
+
var connection = createConnectorSdk(zendeskOauthConnector, createClient);
|
|
503
|
+
export {
|
|
504
|
+
connection
|
|
505
|
+
};
|