@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,584 @@
1
+ // ../connectors/src/connectors/intercom-oauth/sdk/index.ts
2
+ var BASE_URL = "https://api.intercom.io";
3
+ function createClient(_params, fetchFn = fetch) {
4
+ function request(path2, init) {
5
+ const url = `${BASE_URL}${path2.startsWith("/") ? "" : "/"}${path2}`;
6
+ return fetchFn(url, init);
7
+ }
8
+ return { request };
9
+ }
10
+
11
+ // ../connectors/src/connector-onboarding.ts
12
+ var ConnectorOnboarding = class {
13
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
14
+ connectionSetupInstructions;
15
+ /** Phase 2: Data overview instructions */
16
+ dataOverviewInstructions;
17
+ constructor(config) {
18
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
19
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
20
+ }
21
+ getConnectionSetupPrompt(language) {
22
+ return this.connectionSetupInstructions?.[language] ?? null;
23
+ }
24
+ getDataOverviewInstructions(language) {
25
+ return this.dataOverviewInstructions[language];
26
+ }
27
+ };
28
+
29
+ // ../connectors/src/connector-tool.ts
30
+ var ConnectorTool = class {
31
+ name;
32
+ description;
33
+ inputSchema;
34
+ outputSchema;
35
+ _execute;
36
+ constructor(config) {
37
+ this.name = config.name;
38
+ this.description = config.description;
39
+ this.inputSchema = config.inputSchema;
40
+ this.outputSchema = config.outputSchema;
41
+ this._execute = config.execute;
42
+ }
43
+ createTool(connections, config) {
44
+ return {
45
+ description: this.description,
46
+ inputSchema: this.inputSchema,
47
+ outputSchema: this.outputSchema,
48
+ execute: (input) => this._execute(input, connections, config)
49
+ };
50
+ }
51
+ };
52
+
53
+ // ../connectors/src/connector-plugin.ts
54
+ var ConnectorPlugin = class _ConnectorPlugin {
55
+ slug;
56
+ authType;
57
+ name;
58
+ description;
59
+ iconUrl;
60
+ parameters;
61
+ releaseFlag;
62
+ proxyPolicy;
63
+ experimentalAttributes;
64
+ onboarding;
65
+ systemPrompt;
66
+ tools;
67
+ query;
68
+ checkConnection;
69
+ constructor(config) {
70
+ this.slug = config.slug;
71
+ this.authType = config.authType;
72
+ this.name = config.name;
73
+ this.description = config.description;
74
+ this.iconUrl = config.iconUrl;
75
+ this.parameters = config.parameters;
76
+ this.releaseFlag = config.releaseFlag;
77
+ this.proxyPolicy = config.proxyPolicy;
78
+ this.experimentalAttributes = config.experimentalAttributes;
79
+ this.onboarding = config.onboarding;
80
+ this.systemPrompt = config.systemPrompt;
81
+ this.tools = config.tools;
82
+ this.query = config.query;
83
+ this.checkConnection = config.checkConnection;
84
+ }
85
+ get connectorKey() {
86
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
87
+ }
88
+ /**
89
+ * Create tools for connections that belong to this connector.
90
+ * Filters connections by connectorKey internally.
91
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
92
+ */
93
+ createTools(connections, config) {
94
+ const myConnections = connections.filter(
95
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
96
+ );
97
+ const result = {};
98
+ for (const t of Object.values(this.tools)) {
99
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
100
+ myConnections,
101
+ config
102
+ );
103
+ }
104
+ return result;
105
+ }
106
+ static deriveKey(slug, authType) {
107
+ return authType ? `${slug}-${authType}` : slug;
108
+ }
109
+ };
110
+
111
+ // ../connectors/src/auth-types.ts
112
+ var AUTH_TYPES = {
113
+ OAUTH: "oauth",
114
+ API_KEY: "api-key",
115
+ JWT: "jwt",
116
+ SERVICE_ACCOUNT: "service-account",
117
+ PAT: "pat",
118
+ USER_PASSWORD: "user-password"
119
+ };
120
+
121
+ // ../connectors/src/connectors/intercom-oauth/tools/request.ts
122
+ import { z } from "zod";
123
+ var BASE_URL2 = "https://api.intercom.io";
124
+ var REQUEST_TIMEOUT_MS = 6e4;
125
+ var cachedToken = null;
126
+ async function getProxyToken(config) {
127
+ if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
128
+ return cachedToken.token;
129
+ }
130
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
131
+ const res = await fetch(url, {
132
+ method: "POST",
133
+ headers: {
134
+ "Content-Type": "application/json",
135
+ "x-api-key": config.appApiKey,
136
+ "project-id": config.projectId
137
+ },
138
+ body: JSON.stringify({
139
+ sandboxId: config.sandboxId,
140
+ issuedBy: "coding-agent"
141
+ })
142
+ });
143
+ if (!res.ok) {
144
+ const errorText = await res.text().catch(() => res.statusText);
145
+ throw new Error(
146
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
147
+ );
148
+ }
149
+ const data = await res.json();
150
+ cachedToken = {
151
+ token: data.token,
152
+ expiresAt: new Date(data.expiresAt).getTime()
153
+ };
154
+ return data.token;
155
+ }
156
+ var inputSchema = z.object({
157
+ toolUseIntent: z.string().optional().describe(
158
+ "Brief description of what you intend to accomplish with this tool call"
159
+ ),
160
+ connectionId: z.string().describe("ID of the Intercom OAuth connection to use"),
161
+ method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
162
+ path: z.string().describe(
163
+ "API path appended to https://api.intercom.io (e.g., '/contacts', '/conversations', '/contacts/search')"
164
+ ),
165
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
166
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PUT requests")
167
+ });
168
+ var outputSchema = z.discriminatedUnion("success", [
169
+ z.object({
170
+ success: z.literal(true),
171
+ status: z.number(),
172
+ data: z.record(z.string(), z.unknown())
173
+ }),
174
+ z.object({
175
+ success: z.literal(false),
176
+ error: z.string()
177
+ })
178
+ ]);
179
+ var requestTool = new ConnectorTool({
180
+ name: "request",
181
+ description: `Send authenticated requests to the Intercom API.
182
+ Authentication is handled automatically via OAuth proxy.
183
+ The Intercom-Version header (2.11) is set automatically.
184
+ Use this tool for all Intercom API interactions: querying contacts, conversations, companies, articles, tags, and segments.
185
+ Search endpoints (contacts/search, conversations/search) use POST with a query object in the body.`,
186
+ inputSchema,
187
+ outputSchema,
188
+ async execute({ connectionId, method, path: path2, queryParams, body }, connections, config) {
189
+ const connection2 = connections.find((c) => c.id === connectionId);
190
+ if (!connection2) {
191
+ return {
192
+ success: false,
193
+ error: `Connection ${connectionId} not found`
194
+ };
195
+ }
196
+ console.log(
197
+ `[connector-request] intercom-oauth/${connection2.name}: ${method} ${path2}`
198
+ );
199
+ try {
200
+ let url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
201
+ if (queryParams) {
202
+ const searchParams = new URLSearchParams(queryParams);
203
+ const separator = url.includes("?") ? "&" : "?";
204
+ url += `${separator}${searchParams.toString()}`;
205
+ }
206
+ const token = await getProxyToken(config.oauthProxy);
207
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
208
+ const controller = new AbortController();
209
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
210
+ try {
211
+ const response = await fetch(proxyUrl, {
212
+ method: "POST",
213
+ headers: {
214
+ "Content-Type": "application/json",
215
+ Authorization: `Bearer ${token}`
216
+ },
217
+ body: JSON.stringify({
218
+ url,
219
+ method,
220
+ body: body ? JSON.stringify(body) : void 0
221
+ }),
222
+ signal: controller.signal
223
+ });
224
+ const data = await response.json();
225
+ if (!response.ok) {
226
+ const errors = data?.errors;
227
+ const errorMessage = errors?.[0]?.message ?? (typeof data?.error === "string" ? data.error : null) ?? `HTTP ${response.status} ${response.statusText}`;
228
+ return { success: false, error: errorMessage };
229
+ }
230
+ return { success: true, status: response.status, data };
231
+ } finally {
232
+ clearTimeout(timeout);
233
+ }
234
+ } catch (err) {
235
+ const msg = err instanceof Error ? err.message : String(err);
236
+ return { success: false, error: msg };
237
+ }
238
+ }
239
+ });
240
+
241
+ // ../connectors/src/connectors/intercom-oauth/setup.ts
242
+ var requestToolName = `intercom-oauth_${requestTool.name}`;
243
+ var intercomOauthOnboarding = new ConnectorOnboarding({
244
+ connectionSetupInstructions: {
245
+ en: `Follow these steps to set up the Intercom connection.
246
+
247
+ 1. Call \`${requestToolName}\` to verify the connection:
248
+ - \`method\`: \`"GET"\`
249
+ - \`path\`: \`"/me"\`
250
+ 2. If an error is returned, ask the user to check the OAuth connection settings
251
+ 3. Call \`updateConnectionContext\`:
252
+ - \`account\`: Intercom workspace name or admin email
253
+ - \`note\`: Brief description of the setup
254
+
255
+ #### Constraints
256
+ - **Do NOT read business data during setup**. Only the metadata request specified in the steps above is allowed
257
+ - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`,
258
+ ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Intercom\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
259
+
260
+ 1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u63A5\u7D9A\u3092\u78BA\u8A8D\u3059\u308B:
261
+ - \`method\`: \`"GET"\`
262
+ - \`path\`: \`"/me"\`
263
+ 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
264
+ 3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
265
+ - \`account\`: Intercom\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u540D\u307E\u305F\u306F\u7BA1\u7406\u8005\u30E1\u30FC\u30EB
266
+ - \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
267
+
268
+ #### \u5236\u7D04
269
+ - **\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
270
+ - \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`
271
+ },
272
+ dataOverviewInstructions: {
273
+ en: `1. Call intercom-oauth_request with GET /contacts?per_page=5 to explore contacts structure
274
+ 2. Call intercom-oauth_request with GET /conversations?per_page=5 to explore conversations structure
275
+ 3. Call intercom-oauth_request with GET /data_attributes?model=contact to list contact data attributes
276
+ 4. Call intercom-oauth_request with GET /companies?per_page=5 to explore company structure`,
277
+ ja: `1. intercom-oauth_request \u3067 GET /contacts?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u30B3\u30F3\u30BF\u30AF\u30C8\u306E\u69CB\u9020\u3092\u78BA\u8A8D
278
+ 2. intercom-oauth_request \u3067 GET /conversations?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u4F1A\u8A71\u306E\u69CB\u9020\u3092\u78BA\u8A8D
279
+ 3. intercom-oauth_request \u3067 GET /data_attributes?model=contact \u3092\u547C\u3073\u51FA\u3057\u3001\u30B3\u30F3\u30BF\u30AF\u30C8\u306E\u30C7\u30FC\u30BF\u5C5E\u6027\u3092\u78BA\u8A8D
280
+ 4. intercom-oauth_request \u3067 GET /companies?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u4F01\u696D\u306E\u69CB\u9020\u3092\u78BA\u8A8D`
281
+ }
282
+ });
283
+
284
+ // ../connectors/src/connectors/intercom-oauth/parameters.ts
285
+ var parameters = {};
286
+
287
+ // ../connectors/src/connectors/intercom-oauth/index.ts
288
+ var tools = { request: requestTool };
289
+ var intercomOauthConnector = new ConnectorPlugin({
290
+ slug: "intercom",
291
+ authType: AUTH_TYPES.OAUTH,
292
+ name: "Intercom",
293
+ description: "Connect to Intercom for contacts, conversations, companies, and customer engagement data using OAuth.",
294
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/sb2cRMGClpId0LKiSqsok/ae90a0849f21ffe3faf73e04a5676b45/intercom.svg",
295
+ parameters,
296
+ releaseFlag: { dev1: true, dev2: false, prod: false },
297
+ onboarding: intercomOauthOnboarding,
298
+ proxyPolicy: {
299
+ allowlist: [
300
+ {
301
+ host: "api.intercom.io",
302
+ methods: ["GET", "POST", "PUT", "DELETE"]
303
+ }
304
+ ]
305
+ },
306
+ systemPrompt: {
307
+ en: `### Tools
308
+
309
+ - \`intercom-oauth_request\`: The only way to call the Intercom API. Use it to query contacts, conversations, companies, articles, tags, segments, and more. Authentication is configured automatically via OAuth. The Intercom-Version header is set automatically. Intercom uses cursor-based pagination with the \`starting_after\` parameter from \`pages.next.starting_after\` in the response.
310
+
311
+ ### Intercom API Reference
312
+
313
+ #### Contacts
314
+ - GET \`/contacts\` \u2014 List contacts (query params: per_page, starting_after)
315
+ - GET \`/contacts/{id}\` \u2014 Get a contact
316
+ - POST \`/contacts\` \u2014 Create a contact
317
+ - PUT \`/contacts/{id}\` \u2014 Update a contact
318
+ - DELETE \`/contacts/{id}\` \u2014 Delete a contact (archive)
319
+ - POST \`/contacts/search\` \u2014 Search contacts
320
+
321
+ #### Conversations
322
+ - GET \`/conversations\` \u2014 List conversations (query params: per_page, starting_after)
323
+ - GET \`/conversations/{id}\` \u2014 Get a conversation
324
+ - POST \`/conversations\` \u2014 Create a conversation
325
+ - PUT \`/conversations/{id}\` \u2014 Update a conversation
326
+ - POST \`/conversations/search\` \u2014 Search conversations
327
+ - POST \`/conversations/{id}/reply\` \u2014 Reply to a conversation
328
+
329
+ #### Companies
330
+ - GET \`/companies\` \u2014 List companies (query params: per_page, page)
331
+ - GET \`/companies/{id}\` \u2014 Get a company
332
+ - POST \`/companies\` \u2014 Create or update a company
333
+
334
+ #### Articles
335
+ - GET \`/articles\` \u2014 List articles
336
+ - GET \`/articles/{id}\` \u2014 Get an article
337
+
338
+ #### Other Resources
339
+ - GET \`/tags\` \u2014 List tags
340
+ - GET \`/segments\` \u2014 List segments
341
+ - GET \`/admins\` \u2014 List admins
342
+ - GET \`/teams\` \u2014 List teams
343
+ - GET \`/data_attributes?model={model}\` \u2014 List data attributes (model: contact, company, conversation)
344
+
345
+ ### Tips
346
+ - Search endpoints use POST with a JSON query body
347
+ - Pagination uses cursor-based \`starting_after\` from \`pages.next.starting_after\`
348
+ - Date fields in search use Unix timestamps
349
+
350
+ ### Business Logic
351
+
352
+ 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.
353
+
354
+ #### Example
355
+
356
+ \`\`\`ts
357
+ import { connection } from "@squadbase/vite-server/connectors/intercom-oauth";
358
+
359
+ const intercom = connection("<connectionId>");
360
+
361
+ // Authenticated fetch (returns standard Response)
362
+ const res = await intercom.request("/contacts?per_page=10");
363
+ const data = await res.json();
364
+ \`\`\``,
365
+ ja: `### \u30C4\u30FC\u30EB
366
+
367
+ - \`intercom-oauth_request\`: Intercom API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30B3\u30F3\u30BF\u30AF\u30C8\u3001\u4F1A\u8A71\u3001\u4F01\u696D\u3001\u8A18\u4E8B\u3001\u30BF\u30B0\u3001\u30BB\u30B0\u30E1\u30F3\u30C8\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\u3002Intercom-Version\u30D8\u30C3\u30C0\u30FC\u3082\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Intercom\u306F\u30EC\u30B9\u30DD\u30F3\u30B9\u306E \`pages.next.starting_after\` \u304B\u3089\u306E \`starting_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
368
+
369
+ ### Intercom API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
370
+
371
+ #### \u30B3\u30F3\u30BF\u30AF\u30C8
372
+ - GET \`/contacts\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: per_page, starting_after\uFF09
373
+ - GET \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u53D6\u5F97
374
+ - POST \`/contacts\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u4F5C\u6210
375
+ - PUT \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u66F4\u65B0
376
+ - DELETE \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u524A\u9664\uFF08\u30A2\u30FC\u30AB\u30A4\u30D6\uFF09
377
+ - POST \`/contacts/search\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u691C\u7D22
378
+
379
+ #### \u4F1A\u8A71
380
+ - GET \`/conversations\` \u2014 \u4F1A\u8A71\u4E00\u89A7\u3092\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: per_page, starting_after\uFF09
381
+ - GET \`/conversations/{id}\` \u2014 \u4F1A\u8A71\u3092\u53D6\u5F97
382
+ - POST \`/conversations\` \u2014 \u4F1A\u8A71\u3092\u4F5C\u6210
383
+ - PUT \`/conversations/{id}\` \u2014 \u4F1A\u8A71\u3092\u66F4\u65B0
384
+ - POST \`/conversations/search\` \u2014 \u4F1A\u8A71\u3092\u691C\u7D22
385
+ - POST \`/conversations/{id}/reply\` \u2014 \u4F1A\u8A71\u306B\u8FD4\u4FE1
386
+
387
+ #### \u4F01\u696D
388
+ - GET \`/companies\` \u2014 \u4F01\u696D\u4E00\u89A7\u3092\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: per_page, page\uFF09
389
+ - GET \`/companies/{id}\` \u2014 \u4F01\u696D\u3092\u53D6\u5F97
390
+ - POST \`/companies\` \u2014 \u4F01\u696D\u3092\u4F5C\u6210\u30FB\u66F4\u65B0
391
+
392
+ #### \u8A18\u4E8B
393
+ - GET \`/articles\` \u2014 \u8A18\u4E8B\u4E00\u89A7\u3092\u53D6\u5F97
394
+ - GET \`/articles/{id}\` \u2014 \u8A18\u4E8B\u3092\u53D6\u5F97
395
+
396
+ #### \u305D\u306E\u4ED6\u306E\u30EA\u30BD\u30FC\u30B9
397
+ - GET \`/tags\` \u2014 \u30BF\u30B0\u4E00\u89A7\u3092\u53D6\u5F97
398
+ - GET \`/segments\` \u2014 \u30BB\u30B0\u30E1\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
399
+ - GET \`/admins\` \u2014 \u7BA1\u7406\u8005\u4E00\u89A7\u3092\u53D6\u5F97
400
+ - GET \`/teams\` \u2014 \u30C1\u30FC\u30E0\u4E00\u89A7\u3092\u53D6\u5F97
401
+ - GET \`/data_attributes?model={model}\` \u2014 \u30C7\u30FC\u30BF\u5C5E\u6027\u4E00\u89A7\u3092\u53D6\u5F97\uFF08model: contact, company, conversation\uFF09
402
+
403
+ ### \u30D2\u30F3\u30C8
404
+ - \u691C\u7D22\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306FJSON\u30AF\u30A8\u30EA\u30DC\u30C7\u30A3\u3092\u4F7F\u3063\u305FPOST\u3092\u4F7F\u7528\u3057\u307E\u3059
405
+ - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u306F \`pages.next.starting_after\` \u304B\u3089\u306E\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E \`starting_after\` \u3092\u4F7F\u7528\u3057\u307E\u3059
406
+ - \u691C\u7D22\u306E\u65E5\u4ED8\u30D5\u30A3\u30FC\u30EB\u30C9\u306FUnix\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3092\u4F7F\u7528\u3057\u307E\u3059
407
+
408
+ ### Business Logic
409
+
410
+ \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
411
+
412
+ #### Example
413
+
414
+ \`\`\`ts
415
+ import { connection } from "@squadbase/vite-server/connectors/intercom-oauth";
416
+
417
+ const intercom = connection("<connectionId>");
418
+
419
+ // Authenticated fetch (returns standard Response)
420
+ const res = await intercom.request("/contacts?per_page=10");
421
+ const data = await res.json();
422
+ \`\`\``
423
+ },
424
+ tools,
425
+ async checkConnection(_params, config) {
426
+ const { proxyFetch } = config;
427
+ try {
428
+ const res = await proxyFetch("https://api.intercom.io/me", {
429
+ method: "GET"
430
+ });
431
+ if (!res.ok) {
432
+ const errorText = await res.text().catch(() => res.statusText);
433
+ return {
434
+ success: false,
435
+ error: `Intercom API failed: HTTP ${res.status} ${errorText}`
436
+ };
437
+ }
438
+ return { success: true };
439
+ } catch (error) {
440
+ return {
441
+ success: false,
442
+ error: error instanceof Error ? error.message : String(error)
443
+ };
444
+ }
445
+ }
446
+ });
447
+
448
+ // src/connectors/create-connector-sdk.ts
449
+ import { readFileSync } from "fs";
450
+ import path from "path";
451
+
452
+ // src/connector-client/env.ts
453
+ function resolveEnvVar(entry, key, connectionId) {
454
+ const envVarName = entry.envVars[key];
455
+ if (!envVarName) {
456
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
457
+ }
458
+ const value = process.env[envVarName];
459
+ if (!value) {
460
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
461
+ }
462
+ return value;
463
+ }
464
+ function resolveEnvVarOptional(entry, key) {
465
+ const envVarName = entry.envVars[key];
466
+ if (!envVarName) return void 0;
467
+ return process.env[envVarName] || void 0;
468
+ }
469
+
470
+ // src/connector-client/proxy-fetch.ts
471
+ import { getContext } from "hono/context-storage";
472
+ import { getCookie } from "hono/cookie";
473
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
474
+ function createSandboxProxyFetch(connectionId) {
475
+ return async (input, init) => {
476
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
477
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
478
+ if (!token || !sandboxId) {
479
+ throw new Error(
480
+ "Connection proxy is not configured. Please check your deployment settings."
481
+ );
482
+ }
483
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
484
+ const originalMethod = init?.method ?? "GET";
485
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
486
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
487
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
488
+ return fetch(proxyUrl, {
489
+ method: "POST",
490
+ headers: {
491
+ "Content-Type": "application/json",
492
+ Authorization: `Bearer ${token}`
493
+ },
494
+ body: JSON.stringify({
495
+ url: originalUrl,
496
+ method: originalMethod,
497
+ body: originalBody
498
+ })
499
+ });
500
+ };
501
+ }
502
+ function createDeployedAppProxyFetch(connectionId) {
503
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
504
+ if (!projectId) {
505
+ throw new Error(
506
+ "Connection proxy is not configured. Please check your deployment settings."
507
+ );
508
+ }
509
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
510
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
511
+ return async (input, init) => {
512
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
513
+ const originalMethod = init?.method ?? "GET";
514
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
515
+ const c = getContext();
516
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
517
+ if (!appSession) {
518
+ throw new Error(
519
+ "No authentication method available for connection proxy."
520
+ );
521
+ }
522
+ return fetch(proxyUrl, {
523
+ method: "POST",
524
+ headers: {
525
+ "Content-Type": "application/json",
526
+ Authorization: `Bearer ${appSession}`
527
+ },
528
+ body: JSON.stringify({
529
+ url: originalUrl,
530
+ method: originalMethod,
531
+ body: originalBody
532
+ })
533
+ });
534
+ };
535
+ }
536
+ function createProxyFetch(connectionId) {
537
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
538
+ return createSandboxProxyFetch(connectionId);
539
+ }
540
+ return createDeployedAppProxyFetch(connectionId);
541
+ }
542
+
543
+ // src/connectors/create-connector-sdk.ts
544
+ function loadConnectionsSync() {
545
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
546
+ try {
547
+ const raw = readFileSync(filePath, "utf-8");
548
+ return JSON.parse(raw);
549
+ } catch {
550
+ return {};
551
+ }
552
+ }
553
+ function createConnectorSdk(plugin, createClient2) {
554
+ return (connectionId) => {
555
+ const connections = loadConnectionsSync();
556
+ const entry = connections[connectionId];
557
+ if (!entry) {
558
+ throw new Error(
559
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
560
+ );
561
+ }
562
+ if (entry.connector.slug !== plugin.slug) {
563
+ throw new Error(
564
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
565
+ );
566
+ }
567
+ const params = {};
568
+ for (const param of Object.values(plugin.parameters)) {
569
+ if (param.required) {
570
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
571
+ } else {
572
+ const val = resolveEnvVarOptional(entry, param.slug);
573
+ if (val !== void 0) params[param.slug] = val;
574
+ }
575
+ }
576
+ return createClient2(params, createProxyFetch(connectionId));
577
+ };
578
+ }
579
+
580
+ // src/connectors/entries/intercom-oauth.ts
581
+ var connection = createConnectorSdk(intercomOauthConnector, createClient);
582
+ export {
583
+ connection
584
+ };
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.IntercomConnectorSdk;
4
+
5
+ export { connection };