@squadbase/vite-server 0.1.3-dev.0 → 0.1.3-dev.10

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 (70) hide show
  1. package/dist/cli/index.js +82859 -9645
  2. package/dist/connectors/airtable-oauth.js +77 -3
  3. package/dist/connectors/airtable.js +85 -2
  4. package/dist/connectors/amplitude.js +85 -2
  5. package/dist/connectors/anthropic.js +85 -2
  6. package/dist/connectors/{slack.d.ts → asana.d.ts} +1 -1
  7. package/dist/connectors/asana.js +744 -0
  8. package/dist/connectors/attio.js +85 -2
  9. package/dist/connectors/{microsoft-teams-oauth.d.ts → customerio.d.ts} +1 -1
  10. package/dist/connectors/customerio.js +716 -0
  11. package/dist/connectors/dbt.js +85 -2
  12. package/dist/connectors/gemini.js +86 -3
  13. package/dist/connectors/{microsoft-teams.d.ts → gmail-oauth.d.ts} +1 -1
  14. package/dist/connectors/gmail-oauth.js +713 -0
  15. package/dist/connectors/gmail.d.ts +5 -0
  16. package/dist/connectors/gmail.js +875 -0
  17. package/dist/connectors/google-ads-oauth.js +78 -4
  18. package/dist/connectors/google-ads.d.ts +5 -0
  19. package/dist/connectors/google-ads.js +867 -0
  20. package/dist/connectors/google-analytics-oauth.js +90 -8
  21. package/dist/connectors/google-analytics.js +85 -2
  22. package/dist/connectors/google-calendar-oauth.d.ts +5 -0
  23. package/dist/connectors/google-calendar-oauth.js +817 -0
  24. package/dist/connectors/google-calendar.d.ts +5 -0
  25. package/dist/connectors/google-calendar.js +991 -0
  26. package/dist/connectors/google-sheets-oauth.js +144 -33
  27. package/dist/connectors/google-sheets.d.ts +5 -0
  28. package/dist/connectors/google-sheets.js +707 -0
  29. package/dist/connectors/grafana.d.ts +5 -0
  30. package/dist/connectors/grafana.js +638 -0
  31. package/dist/connectors/hubspot-oauth.js +77 -3
  32. package/dist/connectors/hubspot.js +89 -6
  33. package/dist/connectors/intercom-oauth.d.ts +5 -0
  34. package/dist/connectors/intercom-oauth.js +584 -0
  35. package/dist/connectors/intercom.d.ts +5 -0
  36. package/dist/connectors/intercom.js +710 -0
  37. package/dist/connectors/jira-api-key.d.ts +5 -0
  38. package/dist/connectors/jira-api-key.js +598 -0
  39. package/dist/connectors/kintone-api-token.js +77 -3
  40. package/dist/connectors/kintone.js +86 -3
  41. package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
  42. package/dist/connectors/linkedin-ads-oauth.js +848 -0
  43. package/dist/connectors/linkedin-ads.d.ts +5 -0
  44. package/dist/connectors/linkedin-ads.js +865 -0
  45. package/dist/connectors/mailchimp-oauth.d.ts +5 -0
  46. package/dist/connectors/mailchimp-oauth.js +613 -0
  47. package/dist/connectors/mailchimp.d.ts +5 -0
  48. package/dist/connectors/mailchimp.js +729 -0
  49. package/dist/connectors/notion-oauth.d.ts +5 -0
  50. package/dist/connectors/notion-oauth.js +567 -0
  51. package/dist/connectors/notion.d.ts +5 -0
  52. package/dist/connectors/notion.js +663 -0
  53. package/dist/connectors/openai.js +85 -2
  54. package/dist/connectors/shopify-oauth.js +77 -3
  55. package/dist/connectors/shopify.js +85 -2
  56. package/dist/connectors/stripe-api-key.d.ts +5 -0
  57. package/dist/connectors/stripe-api-key.js +600 -0
  58. package/dist/connectors/stripe-oauth.js +77 -3
  59. package/dist/connectors/wix-store.js +85 -2
  60. package/dist/connectors/zendesk-oauth.d.ts +5 -0
  61. package/dist/connectors/zendesk-oauth.js +579 -0
  62. package/dist/connectors/zendesk.d.ts +5 -0
  63. package/dist/connectors/zendesk.js +714 -0
  64. package/dist/index.js +83024 -7099
  65. package/dist/main.js +82988 -7063
  66. package/dist/vite-plugin.js +82862 -6974
  67. package/package.json +86 -2
  68. package/dist/connectors/microsoft-teams-oauth.js +0 -479
  69. package/dist/connectors/microsoft-teams.js +0 -381
  70. package/dist/connectors/slack.js +0 -362
@@ -0,0 +1,579 @@
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
+ USER_PASSWORD: "user-password"
117
+ };
118
+
119
+ // ../connectors/src/connectors/zendesk-oauth/tools/request.ts
120
+ import { z } from "zod";
121
+ var REQUEST_TIMEOUT_MS = 6e4;
122
+ var cachedToken = null;
123
+ async function getProxyToken(config) {
124
+ if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
125
+ return cachedToken.token;
126
+ }
127
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
128
+ const res = await fetch(url, {
129
+ method: "POST",
130
+ headers: {
131
+ "Content-Type": "application/json",
132
+ "x-api-key": config.appApiKey,
133
+ "project-id": config.projectId
134
+ },
135
+ body: JSON.stringify({
136
+ sandboxId: config.sandboxId,
137
+ issuedBy: "coding-agent"
138
+ })
139
+ });
140
+ if (!res.ok) {
141
+ const errorText = await res.text().catch(() => res.statusText);
142
+ throw new Error(
143
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
144
+ );
145
+ }
146
+ const data = await res.json();
147
+ cachedToken = {
148
+ token: data.token,
149
+ expiresAt: new Date(data.expiresAt).getTime()
150
+ };
151
+ return data.token;
152
+ }
153
+ var inputSchema = z.object({
154
+ toolUseIntent: z.string().optional().describe(
155
+ "Brief description of what you intend to accomplish with this tool call"
156
+ ),
157
+ connectionId: z.string().describe("ID of the Zendesk OAuth connection to use"),
158
+ method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
159
+ path: z.string().describe(
160
+ "API path appended to the Zendesk base URL (e.g., '/api/v2/tickets.json', '/api/v2/search.json?query=status:open')"
161
+ ),
162
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
163
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PUT requests")
164
+ });
165
+ var outputSchema = z.discriminatedUnion("success", [
166
+ z.object({
167
+ success: z.literal(true),
168
+ status: z.number(),
169
+ data: z.record(z.string(), z.unknown())
170
+ }),
171
+ z.object({
172
+ success: z.literal(false),
173
+ error: z.string()
174
+ })
175
+ ]);
176
+ var requestTool = new ConnectorTool({
177
+ name: "request",
178
+ description: `Send authenticated requests to the Zendesk Support API.
179
+ Authentication is handled automatically via OAuth proxy.
180
+ Use this tool for all Zendesk API interactions: querying tickets, users, organizations, groups, and searching.
181
+ Zendesk uses cursor-based pagination with page[size] and page[after] parameters. All endpoint paths end with .json.`,
182
+ inputSchema,
183
+ outputSchema,
184
+ async execute({ connectionId, method, path: path2, queryParams, body }, connections, config) {
185
+ const connection2 = connections.find((c) => c.id === connectionId);
186
+ if (!connection2) {
187
+ return {
188
+ success: false,
189
+ error: `Connection ${connectionId} not found`
190
+ };
191
+ }
192
+ console.log(
193
+ `[connector-request] zendesk-oauth/${connection2.name}: ${method} ${path2}`
194
+ );
195
+ try {
196
+ let url = path2;
197
+ if (queryParams) {
198
+ const searchParams = new URLSearchParams(queryParams);
199
+ const separator = url.includes("?") ? "&" : "?";
200
+ url += `${separator}${searchParams.toString()}`;
201
+ }
202
+ const token = await getProxyToken(config.oauthProxy);
203
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
204
+ const controller = new AbortController();
205
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
206
+ try {
207
+ const response = await fetch(proxyUrl, {
208
+ method: "POST",
209
+ headers: {
210
+ "Content-Type": "application/json",
211
+ Authorization: `Bearer ${token}`
212
+ },
213
+ body: JSON.stringify({
214
+ url,
215
+ method,
216
+ body: body ? JSON.stringify(body) : void 0
217
+ }),
218
+ signal: controller.signal
219
+ });
220
+ const data = await response.json();
221
+ if (!response.ok) {
222
+ const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.description === "string" ? data.description : `HTTP ${response.status} ${response.statusText}`;
223
+ return { success: false, error: errorMessage };
224
+ }
225
+ return { success: true, status: response.status, data };
226
+ } finally {
227
+ clearTimeout(timeout);
228
+ }
229
+ } catch (err) {
230
+ const msg = err instanceof Error ? err.message : String(err);
231
+ return { success: false, error: msg };
232
+ }
233
+ }
234
+ });
235
+
236
+ // ../connectors/src/connectors/zendesk-oauth/setup.ts
237
+ var requestToolName = `zendesk-oauth_${requestTool.name}`;
238
+ var zendeskOauthOnboarding = new ConnectorOnboarding({
239
+ connectionSetupInstructions: {
240
+ en: `Follow these steps to set up the Zendesk connection.
241
+
242
+ 1. Call \`${requestToolName}\` to fetch account info:
243
+ - \`method\`: \`"GET"\`
244
+ - \`path\`: \`"/api/v2/account/settings.json"\`
245
+ 2. If an error is returned, ask the user to check the OAuth connection settings
246
+ 3. Call \`updateConnectionContext\`:
247
+ - \`account\`: Zendesk subdomain or account name
248
+ - \`note\`: Brief description of the setup
249
+
250
+ #### Constraints
251
+ - **Do NOT read business data during setup**. Only the metadata request specified in the steps above is allowed
252
+ - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`,
253
+ 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
254
+
255
+ 1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
256
+ - \`method\`: \`"GET"\`
257
+ - \`path\`: \`"/api/v2/account/settings.json"\`
258
+ 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
259
+ 3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
260
+ - \`account\`: Zendesk\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u307E\u305F\u306F\u30A2\u30AB\u30A6\u30F3\u30C8\u540D
261
+ - \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
262
+
263
+ #### \u5236\u7D04
264
+ - **\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
265
+ - \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`
266
+ },
267
+ dataOverviewInstructions: {
268
+ en: `1. Call zendesk-oauth_request with GET /api/v2/ticket_fields.json to list available ticket fields
269
+ 2. Call zendesk-oauth_request with GET /api/v2/tickets.json?page[size]=5 to explore ticket structure
270
+ 3. Call zendesk-oauth_request with GET /api/v2/users.json?page[size]=5 to explore user structure
271
+ 4. Call zendesk-oauth_request with GET /api/v2/organizations.json?page[size]=5 to explore organization structure`,
272
+ 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
273
+ 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
274
+ 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
275
+ 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`
276
+ }
277
+ });
278
+
279
+ // ../connectors/src/connectors/zendesk-oauth/parameters.ts
280
+ var parameters = {};
281
+
282
+ // ../connectors/src/connectors/zendesk-oauth/index.ts
283
+ var tools = { request: requestTool };
284
+ var zendeskOauthConnector = new ConnectorPlugin({
285
+ slug: "zendesk",
286
+ authType: AUTH_TYPES.OAUTH,
287
+ name: "Zendesk",
288
+ description: "Connect to Zendesk Support for tickets, users, organizations, and customer service data using OAuth.",
289
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7e9Q7PwV6MJRJMj543m2gl/55385fae903ccfa1599e35be9d3516aa/zendesk-icon.svg",
290
+ parameters,
291
+ releaseFlag: { dev1: true, dev2: false, prod: false },
292
+ onboarding: zendeskOauthOnboarding,
293
+ proxyPolicy: {
294
+ allowlist: [
295
+ {
296
+ host: "*.zendesk.com",
297
+ methods: ["GET", "POST", "PUT", "DELETE"]
298
+ }
299
+ ]
300
+ },
301
+ systemPrompt: {
302
+ en: `### Tools
303
+
304
+ - \`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\`.
305
+
306
+ ### Zendesk API Reference
307
+
308
+ #### Tickets
309
+ - GET \`/api/v2/tickets.json\` \u2014 List tickets
310
+ - GET \`/api/v2/tickets/{id}.json\` \u2014 Get a ticket
311
+ - POST \`/api/v2/tickets.json\` \u2014 Create a ticket
312
+ - PUT \`/api/v2/tickets/{id}.json\` \u2014 Update a ticket
313
+ - DELETE \`/api/v2/tickets/{id}.json\` \u2014 Delete a ticket
314
+ - GET \`/api/v2/tickets/{id}/comments.json\` \u2014 List ticket comments
315
+
316
+ #### Users
317
+ - GET \`/api/v2/users.json\` \u2014 List users
318
+ - GET \`/api/v2/users/{id}.json\` \u2014 Get a user
319
+
320
+ #### Organizations
321
+ - GET \`/api/v2/organizations.json\` \u2014 List organizations
322
+ - GET \`/api/v2/organizations/{id}.json\` \u2014 Get an organization
323
+
324
+ #### Groups
325
+ - GET \`/api/v2/groups.json\` \u2014 List groups
326
+
327
+ #### Search
328
+ - GET \`/api/v2/search.json?query={query}\` \u2014 Search tickets, users, organizations
329
+ - Query params: \`sort_by\` (updated_at, created_at, priority, status), \`sort_order\` (asc, desc)
330
+
331
+ #### Ticket Fields & Forms
332
+ - GET \`/api/v2/ticket_fields.json\` \u2014 List ticket fields
333
+ - GET \`/api/v2/ticket_forms.json\` \u2014 List ticket forms
334
+
335
+ #### Views
336
+ - GET \`/api/v2/views.json\` \u2014 List views
337
+ - GET \`/api/v2/views/{id}/tickets.json\` \u2014 List tickets in a view
338
+
339
+ ### Tips
340
+ - All endpoint paths end with \`.json\`
341
+ - Pagination uses cursor-based \`page[size]\` and \`page[after]\` parameters
342
+ - Search uses Zendesk query syntax (e.g., \`type:ticket status:open\`)
343
+ - Max 100 results per page
344
+
345
+ ### Business Logic
346
+
347
+ 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.
348
+
349
+ #### Example
350
+
351
+ \`\`\`ts
352
+ import { connection } from "@squadbase/vite-server/connectors/zendesk-oauth";
353
+
354
+ const zendesk = connection("<connectionId>");
355
+
356
+ // Authenticated fetch (returns standard Response)
357
+ const res = await zendesk.request("/api/v2/tickets.json?page[size]=10");
358
+ const data = await res.json();
359
+ \`\`\``,
360
+ ja: `### \u30C4\u30FC\u30EB
361
+
362
+ - \`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
363
+
364
+ ### Zendesk API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
365
+
366
+ #### \u30C1\u30B1\u30C3\u30C8
367
+ - GET \`/api/v2/tickets.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
368
+ - GET \`/api/v2/tickets/{id}.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u53D6\u5F97
369
+ - POST \`/api/v2/tickets.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u4F5C\u6210
370
+ - PUT \`/api/v2/tickets/{id}.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u66F4\u65B0
371
+ - DELETE \`/api/v2/tickets/{id}.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3092\u524A\u9664
372
+ - GET \`/api/v2/tickets/{id}/comments.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u30B3\u30E1\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
373
+
374
+ #### \u30E6\u30FC\u30B6\u30FC
375
+ - GET \`/api/v2/users.json\` \u2014 \u30E6\u30FC\u30B6\u30FC\u4E00\u89A7\u3092\u53D6\u5F97
376
+ - GET \`/api/v2/users/{id}.json\` \u2014 \u30E6\u30FC\u30B6\u30FC\u3092\u53D6\u5F97
377
+
378
+ #### \u7D44\u7E54
379
+ - GET \`/api/v2/organizations.json\` \u2014 \u7D44\u7E54\u4E00\u89A7\u3092\u53D6\u5F97
380
+ - GET \`/api/v2/organizations/{id}.json\` \u2014 \u7D44\u7E54\u3092\u53D6\u5F97
381
+
382
+ #### \u30B0\u30EB\u30FC\u30D7
383
+ - GET \`/api/v2/groups.json\` \u2014 \u30B0\u30EB\u30FC\u30D7\u4E00\u89A7\u3092\u53D6\u5F97
384
+
385
+ #### \u691C\u7D22
386
+ - GET \`/api/v2/search.json?query={query}\` \u2014 \u30C1\u30B1\u30C3\u30C8\u3001\u30E6\u30FC\u30B6\u30FC\u3001\u7D44\u7E54\u3092\u691C\u7D22
387
+ - \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: \`sort_by\`\uFF08updated_at, created_at, priority, status\uFF09\u3001\`sort_order\`\uFF08asc, desc\uFF09
388
+
389
+ #### \u30C1\u30B1\u30C3\u30C8\u30D5\u30A3\u30FC\u30EB\u30C9\u30FB\u30D5\u30A9\u30FC\u30E0
390
+ - GET \`/api/v2/ticket_fields.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u30D5\u30A3\u30FC\u30EB\u30C9\u4E00\u89A7\u3092\u53D6\u5F97
391
+ - GET \`/api/v2/ticket_forms.json\` \u2014 \u30C1\u30B1\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u4E00\u89A7\u3092\u53D6\u5F97
392
+
393
+ #### \u30D3\u30E5\u30FC
394
+ - GET \`/api/v2/views.json\` \u2014 \u30D3\u30E5\u30FC\u4E00\u89A7\u3092\u53D6\u5F97
395
+ - GET \`/api/v2/views/{id}/tickets.json\` \u2014 \u30D3\u30E5\u30FC\u5185\u306E\u30C1\u30B1\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
396
+
397
+ ### \u30D2\u30F3\u30C8
398
+ - \u5168\u3066\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u30D1\u30B9\u306F \`.json\` \u3067\u7D42\u308F\u308A\u307E\u3059
399
+ - \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
400
+ - \u691C\u7D22\u306FZendesk\u30AF\u30A8\u30EA\u69CB\u6587\u3092\u4F7F\u7528\u3057\u307E\u3059\uFF08\u4F8B: \`type:ticket status:open\`\uFF09
401
+ - 1\u30DA\u30FC\u30B8\u3042\u305F\u308A\u6700\u5927100\u4EF6
402
+
403
+ ### Business Logic
404
+
405
+ \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
406
+
407
+ #### Example
408
+
409
+ \`\`\`ts
410
+ import { connection } from "@squadbase/vite-server/connectors/zendesk-oauth";
411
+
412
+ const zendesk = connection("<connectionId>");
413
+
414
+ // Authenticated fetch (returns standard Response)
415
+ const res = await zendesk.request("/api/v2/tickets.json?page[size]=10");
416
+ const data = await res.json();
417
+ \`\`\``
418
+ },
419
+ tools,
420
+ async checkConnection(_params, config) {
421
+ const { proxyFetch } = config;
422
+ try {
423
+ const res = await proxyFetch("/api/v2/account/settings.json", {
424
+ method: "GET"
425
+ });
426
+ if (!res.ok) {
427
+ const errorText = await res.text().catch(() => res.statusText);
428
+ return {
429
+ success: false,
430
+ error: `Zendesk API failed: HTTP ${res.status} ${errorText}`
431
+ };
432
+ }
433
+ return { success: true };
434
+ } catch (error) {
435
+ return {
436
+ success: false,
437
+ error: error instanceof Error ? error.message : String(error)
438
+ };
439
+ }
440
+ }
441
+ });
442
+
443
+ // src/connectors/create-connector-sdk.ts
444
+ import { readFileSync } from "fs";
445
+ import path from "path";
446
+
447
+ // src/connector-client/env.ts
448
+ function resolveEnvVar(entry, key, connectionId) {
449
+ const envVarName = entry.envVars[key];
450
+ if (!envVarName) {
451
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
452
+ }
453
+ const value = process.env[envVarName];
454
+ if (!value) {
455
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
456
+ }
457
+ return value;
458
+ }
459
+ function resolveEnvVarOptional(entry, key) {
460
+ const envVarName = entry.envVars[key];
461
+ if (!envVarName) return void 0;
462
+ return process.env[envVarName] || void 0;
463
+ }
464
+
465
+ // src/connector-client/proxy-fetch.ts
466
+ import { getContext } from "hono/context-storage";
467
+ import { getCookie } from "hono/cookie";
468
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
469
+ function createSandboxProxyFetch(connectionId) {
470
+ return async (input, init) => {
471
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
472
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
473
+ if (!token || !sandboxId) {
474
+ throw new Error(
475
+ "Connection proxy is not configured. Please check your deployment settings."
476
+ );
477
+ }
478
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
479
+ const originalMethod = init?.method ?? "GET";
480
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
481
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
482
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
483
+ return fetch(proxyUrl, {
484
+ method: "POST",
485
+ headers: {
486
+ "Content-Type": "application/json",
487
+ Authorization: `Bearer ${token}`
488
+ },
489
+ body: JSON.stringify({
490
+ url: originalUrl,
491
+ method: originalMethod,
492
+ body: originalBody
493
+ })
494
+ });
495
+ };
496
+ }
497
+ function createDeployedAppProxyFetch(connectionId) {
498
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
499
+ if (!projectId) {
500
+ throw new Error(
501
+ "Connection proxy is not configured. Please check your deployment settings."
502
+ );
503
+ }
504
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
505
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
506
+ return async (input, init) => {
507
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
508
+ const originalMethod = init?.method ?? "GET";
509
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
510
+ const c = getContext();
511
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
512
+ if (!appSession) {
513
+ throw new Error(
514
+ "No authentication method available for connection proxy."
515
+ );
516
+ }
517
+ return fetch(proxyUrl, {
518
+ method: "POST",
519
+ headers: {
520
+ "Content-Type": "application/json",
521
+ Authorization: `Bearer ${appSession}`
522
+ },
523
+ body: JSON.stringify({
524
+ url: originalUrl,
525
+ method: originalMethod,
526
+ body: originalBody
527
+ })
528
+ });
529
+ };
530
+ }
531
+ function createProxyFetch(connectionId) {
532
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
533
+ return createSandboxProxyFetch(connectionId);
534
+ }
535
+ return createDeployedAppProxyFetch(connectionId);
536
+ }
537
+
538
+ // src/connectors/create-connector-sdk.ts
539
+ function loadConnectionsSync() {
540
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
541
+ try {
542
+ const raw = readFileSync(filePath, "utf-8");
543
+ return JSON.parse(raw);
544
+ } catch {
545
+ return {};
546
+ }
547
+ }
548
+ function createConnectorSdk(plugin, createClient2) {
549
+ return (connectionId) => {
550
+ const connections = loadConnectionsSync();
551
+ const entry = connections[connectionId];
552
+ if (!entry) {
553
+ throw new Error(
554
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
555
+ );
556
+ }
557
+ if (entry.connector.slug !== plugin.slug) {
558
+ throw new Error(
559
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
560
+ );
561
+ }
562
+ const params = {};
563
+ for (const param of Object.values(plugin.parameters)) {
564
+ if (param.required) {
565
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
566
+ } else {
567
+ const val = resolveEnvVarOptional(entry, param.slug);
568
+ if (val !== void 0) params[param.slug] = val;
569
+ }
570
+ }
571
+ return createClient2(params, createProxyFetch(connectionId));
572
+ };
573
+ }
574
+
575
+ // src/connectors/entries/zendesk-oauth.ts
576
+ var connection = createConnectorSdk(zendeskOauthConnector, createClient);
577
+ export {
578
+ connection
579
+ };
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.ZendeskConnectorSdk;
4
+
5
+ export { connection };