@squadbase/vite-server 0.1.3-dev.0 → 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.
Files changed (34) hide show
  1. package/dist/cli/index.js +13282 -4299
  2. package/dist/connectors/asana.d.ts +5 -0
  3. package/dist/connectors/asana.js +661 -0
  4. package/dist/connectors/customerio.d.ts +5 -0
  5. package/dist/connectors/customerio.js +633 -0
  6. package/dist/connectors/gmail-oauth.d.ts +5 -0
  7. package/dist/connectors/gmail-oauth.js +639 -0
  8. package/dist/connectors/google-ads.d.ts +5 -0
  9. package/dist/connectors/google-ads.js +784 -0
  10. package/dist/connectors/google-sheets.d.ts +5 -0
  11. package/dist/connectors/google-sheets.js +598 -0
  12. package/dist/connectors/hubspot.js +14 -5
  13. package/dist/connectors/intercom-oauth.d.ts +5 -0
  14. package/dist/connectors/intercom-oauth.js +510 -0
  15. package/dist/connectors/intercom.d.ts +5 -0
  16. package/dist/connectors/intercom.js +627 -0
  17. package/dist/connectors/jira-api-key.d.ts +5 -0
  18. package/dist/connectors/jira-api-key.js +523 -0
  19. package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
  20. package/dist/connectors/linkedin-ads-oauth.js +774 -0
  21. package/dist/connectors/linkedin-ads.d.ts +5 -0
  22. package/dist/connectors/linkedin-ads.js +782 -0
  23. package/dist/connectors/mailchimp-oauth.d.ts +5 -0
  24. package/dist/connectors/mailchimp-oauth.js +539 -0
  25. package/dist/connectors/mailchimp.d.ts +5 -0
  26. package/dist/connectors/mailchimp.js +646 -0
  27. package/dist/connectors/zendesk-oauth.d.ts +5 -0
  28. package/dist/connectors/zendesk-oauth.js +505 -0
  29. package/dist/connectors/zendesk.d.ts +5 -0
  30. package/dist/connectors/zendesk.js +631 -0
  31. package/dist/index.js +13238 -4255
  32. package/dist/main.js +13240 -4257
  33. package/dist/vite-plugin.js +13240 -4257
  34. package/package.json +42 -2
@@ -0,0 +1,627 @@
1
+ // ../connectors/src/parameter-definition.ts
2
+ var ParameterDefinition = class {
3
+ slug;
4
+ name;
5
+ description;
6
+ envVarBaseKey;
7
+ type;
8
+ secret;
9
+ required;
10
+ constructor(config) {
11
+ this.slug = config.slug;
12
+ this.name = config.name;
13
+ this.description = config.description;
14
+ this.envVarBaseKey = config.envVarBaseKey;
15
+ this.type = config.type;
16
+ this.secret = config.secret;
17
+ this.required = config.required;
18
+ }
19
+ /**
20
+ * Get the parameter value from a ConnectorConnectionObject.
21
+ */
22
+ getValue(connection2) {
23
+ const param = connection2.parameters.find(
24
+ (p) => p.parameterSlug === this.slug
25
+ );
26
+ if (!param || param.value == null) {
27
+ throw new Error(
28
+ `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
29
+ );
30
+ }
31
+ return param.value;
32
+ }
33
+ /**
34
+ * Try to get the parameter value. Returns undefined if not found (for optional params).
35
+ */
36
+ tryGetValue(connection2) {
37
+ const param = connection2.parameters.find(
38
+ (p) => p.parameterSlug === this.slug
39
+ );
40
+ if (!param || param.value == null) return void 0;
41
+ return param.value;
42
+ }
43
+ };
44
+
45
+ // ../connectors/src/connectors/intercom/parameters.ts
46
+ var parameters = {
47
+ accessToken: new ParameterDefinition({
48
+ slug: "access-token",
49
+ name: "Access Token",
50
+ description: "Your Intercom Access Token (found in Developer Hub > Your App > Authentication).",
51
+ envVarBaseKey: "INTERCOM_ACCESS_TOKEN",
52
+ type: "text",
53
+ secret: true,
54
+ required: true
55
+ })
56
+ };
57
+
58
+ // ../connectors/src/connectors/intercom/sdk/index.ts
59
+ var BASE_URL = "https://api.intercom.io";
60
+ var API_VERSION = "2.11";
61
+ function createClient(params) {
62
+ const accessToken = params[parameters.accessToken.slug];
63
+ if (!accessToken) {
64
+ throw new Error(
65
+ `intercom: missing required parameter: ${parameters.accessToken.slug}`
66
+ );
67
+ }
68
+ function authHeaders(extra) {
69
+ const headers = new Headers(extra);
70
+ headers.set("Authorization", `Bearer ${accessToken}`);
71
+ headers.set("Content-Type", "application/json");
72
+ headers.set("Accept", "application/json");
73
+ headers.set("Intercom-Version", API_VERSION);
74
+ return headers;
75
+ }
76
+ async function assertOk(res, label) {
77
+ if (!res.ok) {
78
+ const body = await res.text().catch(() => "(unreadable body)");
79
+ throw new Error(
80
+ `intercom ${label}: ${res.status} ${res.statusText} \u2014 ${body}`
81
+ );
82
+ }
83
+ }
84
+ return {
85
+ request(path2, init) {
86
+ const url = `${BASE_URL}${path2.startsWith("/") ? "" : "/"}${path2}`;
87
+ const headers = new Headers(init?.headers);
88
+ headers.set("Authorization", `Bearer ${accessToken}`);
89
+ headers.set("Content-Type", "application/json");
90
+ headers.set("Accept", "application/json");
91
+ headers.set("Intercom-Version", API_VERSION);
92
+ return fetch(url, { ...init, headers });
93
+ },
94
+ async listContacts(options) {
95
+ const searchParams = new URLSearchParams();
96
+ if (options?.per_page) searchParams.set("per_page", String(options.per_page));
97
+ if (options?.starting_after) searchParams.set("starting_after", options.starting_after);
98
+ const qs = searchParams.toString();
99
+ const res = await fetch(
100
+ `${BASE_URL}/contacts${qs ? `?${qs}` : ""}`,
101
+ { method: "GET", headers: authHeaders() }
102
+ );
103
+ await assertOk(res, "listContacts");
104
+ return await res.json();
105
+ },
106
+ async getContact(contactId) {
107
+ const res = await fetch(
108
+ `${BASE_URL}/contacts/${encodeURIComponent(contactId)}`,
109
+ { method: "GET", headers: authHeaders() }
110
+ );
111
+ await assertOk(res, "getContact");
112
+ return await res.json();
113
+ },
114
+ async searchContacts(query) {
115
+ const res = await fetch(`${BASE_URL}/contacts/search`, {
116
+ method: "POST",
117
+ headers: authHeaders(),
118
+ body: JSON.stringify({ query })
119
+ });
120
+ await assertOk(res, "searchContacts");
121
+ return await res.json();
122
+ },
123
+ async listConversations(options) {
124
+ const searchParams = new URLSearchParams();
125
+ if (options?.per_page) searchParams.set("per_page", String(options.per_page));
126
+ if (options?.starting_after) searchParams.set("starting_after", options.starting_after);
127
+ const qs = searchParams.toString();
128
+ const res = await fetch(
129
+ `${BASE_URL}/conversations${qs ? `?${qs}` : ""}`,
130
+ { method: "GET", headers: authHeaders() }
131
+ );
132
+ await assertOk(res, "listConversations");
133
+ return await res.json();
134
+ },
135
+ async getConversation(conversationId) {
136
+ const res = await fetch(
137
+ `${BASE_URL}/conversations/${encodeURIComponent(conversationId)}`,
138
+ { method: "GET", headers: authHeaders() }
139
+ );
140
+ await assertOk(res, "getConversation");
141
+ return await res.json();
142
+ },
143
+ async listCompanies(options) {
144
+ const searchParams = new URLSearchParams();
145
+ if (options?.per_page) searchParams.set("per_page", String(options.per_page));
146
+ if (options?.page) searchParams.set("page", String(options.page));
147
+ const qs = searchParams.toString();
148
+ const res = await fetch(
149
+ `${BASE_URL}/companies${qs ? `?${qs}` : ""}`,
150
+ { method: "GET", headers: authHeaders() }
151
+ );
152
+ await assertOk(res, "listCompanies");
153
+ return await res.json();
154
+ }
155
+ };
156
+ }
157
+
158
+ // ../connectors/src/connector-onboarding.ts
159
+ var ConnectorOnboarding = class {
160
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
161
+ connectionSetupInstructions;
162
+ /** Phase 2: Data overview instructions */
163
+ dataOverviewInstructions;
164
+ constructor(config) {
165
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
166
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
167
+ }
168
+ getConnectionSetupPrompt(language) {
169
+ return this.connectionSetupInstructions?.[language] ?? null;
170
+ }
171
+ getDataOverviewInstructions(language) {
172
+ return this.dataOverviewInstructions[language];
173
+ }
174
+ };
175
+
176
+ // ../connectors/src/connector-tool.ts
177
+ var ConnectorTool = class {
178
+ name;
179
+ description;
180
+ inputSchema;
181
+ outputSchema;
182
+ _execute;
183
+ constructor(config) {
184
+ this.name = config.name;
185
+ this.description = config.description;
186
+ this.inputSchema = config.inputSchema;
187
+ this.outputSchema = config.outputSchema;
188
+ this._execute = config.execute;
189
+ }
190
+ createTool(connections, config) {
191
+ return {
192
+ description: this.description,
193
+ inputSchema: this.inputSchema,
194
+ outputSchema: this.outputSchema,
195
+ execute: (input) => this._execute(input, connections, config)
196
+ };
197
+ }
198
+ };
199
+
200
+ // ../connectors/src/connector-plugin.ts
201
+ var ConnectorPlugin = class _ConnectorPlugin {
202
+ slug;
203
+ authType;
204
+ name;
205
+ description;
206
+ iconUrl;
207
+ parameters;
208
+ releaseFlag;
209
+ proxyPolicy;
210
+ experimentalAttributes;
211
+ onboarding;
212
+ systemPrompt;
213
+ tools;
214
+ query;
215
+ checkConnection;
216
+ constructor(config) {
217
+ this.slug = config.slug;
218
+ this.authType = config.authType;
219
+ this.name = config.name;
220
+ this.description = config.description;
221
+ this.iconUrl = config.iconUrl;
222
+ this.parameters = config.parameters;
223
+ this.releaseFlag = config.releaseFlag;
224
+ this.proxyPolicy = config.proxyPolicy;
225
+ this.experimentalAttributes = config.experimentalAttributes;
226
+ this.onboarding = config.onboarding;
227
+ this.systemPrompt = config.systemPrompt;
228
+ this.tools = config.tools;
229
+ this.query = config.query;
230
+ this.checkConnection = config.checkConnection;
231
+ }
232
+ get connectorKey() {
233
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
234
+ }
235
+ /**
236
+ * Create tools for connections that belong to this connector.
237
+ * Filters connections by connectorKey internally.
238
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
239
+ */
240
+ createTools(connections, config) {
241
+ const myConnections = connections.filter(
242
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
243
+ );
244
+ const result = {};
245
+ for (const t of Object.values(this.tools)) {
246
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
247
+ myConnections,
248
+ config
249
+ );
250
+ }
251
+ return result;
252
+ }
253
+ static deriveKey(slug, authType) {
254
+ return authType ? `${slug}-${authType}` : slug;
255
+ }
256
+ };
257
+
258
+ // ../connectors/src/connectors/intercom/setup.ts
259
+ var intercomOnboarding = new ConnectorOnboarding({
260
+ dataOverviewInstructions: {
261
+ en: `1. Call intercom_request with GET /contacts?per_page=5 to explore contacts structure
262
+ 2. Call intercom_request with GET /conversations?per_page=5 to explore conversations structure
263
+ 3. Call intercom_request with GET /data_attributes?model=contact to list contact data attributes
264
+ 4. Call intercom_request with GET /companies?per_page=5 to explore company structure`,
265
+ ja: `1. intercom_request \u3067 GET /contacts?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u30B3\u30F3\u30BF\u30AF\u30C8\u306E\u69CB\u9020\u3092\u78BA\u8A8D
266
+ 2. intercom_request \u3067 GET /conversations?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u4F1A\u8A71\u306E\u69CB\u9020\u3092\u78BA\u8A8D
267
+ 3. intercom_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
268
+ 4. intercom_request \u3067 GET /companies?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u4F01\u696D\u306E\u69CB\u9020\u3092\u78BA\u8A8D`
269
+ }
270
+ });
271
+
272
+ // ../connectors/src/connectors/intercom/tools/request.ts
273
+ import { z } from "zod";
274
+ var BASE_URL2 = "https://api.intercom.io";
275
+ var API_VERSION2 = "2.11";
276
+ var REQUEST_TIMEOUT_MS = 6e4;
277
+ var inputSchema = z.object({
278
+ toolUseIntent: z.string().optional().describe(
279
+ "Brief description of what you intend to accomplish with this tool call"
280
+ ),
281
+ connectionId: z.string().describe("ID of the Intercom connection to use"),
282
+ method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe(
283
+ "HTTP method. GET for reading, POST for creating/searching, PUT for updating, DELETE for removing."
284
+ ),
285
+ path: z.string().describe(
286
+ "API path appended to https://api.intercom.io (e.g., '/contacts', '/conversations', '/contacts/search')"
287
+ ),
288
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PUT requests")
289
+ });
290
+ var outputSchema = z.discriminatedUnion("success", [
291
+ z.object({
292
+ success: z.literal(true),
293
+ status: z.number(),
294
+ data: z.record(z.string(), z.unknown())
295
+ }),
296
+ z.object({
297
+ success: z.literal(false),
298
+ error: z.string()
299
+ })
300
+ ]);
301
+ var requestTool = new ConnectorTool({
302
+ name: "request",
303
+ description: `Send authenticated requests to the Intercom API.
304
+ Authentication is handled automatically using the Access Token (Bearer token).
305
+ Use this tool for all Intercom API interactions: querying contacts, conversations, companies, articles, tags, and segments.
306
+ Intercom uses cursor-based pagination with the starting_after parameter from pages.next.starting_after in the response.
307
+ Search endpoints (contacts/search, conversations/search) use POST with a query object in the body.
308
+ The Intercom-Version header is set to 2.11 automatically.`,
309
+ inputSchema,
310
+ outputSchema,
311
+ async execute({ connectionId, method, path: path2, body }, connections) {
312
+ const connection2 = connections.find((c) => c.id === connectionId);
313
+ if (!connection2) {
314
+ return {
315
+ success: false,
316
+ error: `Connection ${connectionId} not found`
317
+ };
318
+ }
319
+ console.log(
320
+ `[connector-request] intercom/${connection2.name}: ${method} ${path2}`
321
+ );
322
+ try {
323
+ const accessToken = parameters.accessToken.getValue(connection2);
324
+ const url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
325
+ const controller = new AbortController();
326
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
327
+ try {
328
+ const response = await fetch(url, {
329
+ method,
330
+ headers: {
331
+ Authorization: `Bearer ${accessToken}`,
332
+ "Content-Type": "application/json",
333
+ Accept: "application/json",
334
+ "Intercom-Version": API_VERSION2
335
+ },
336
+ body: body ? JSON.stringify(body) : void 0,
337
+ signal: controller.signal
338
+ });
339
+ const data = await response.json();
340
+ if (!response.ok) {
341
+ const errors = data?.errors;
342
+ const errorMessage = errors?.[0]?.message ?? (typeof data?.message === "string" ? data.message : null) ?? `HTTP ${response.status} ${response.statusText}`;
343
+ return { success: false, error: errorMessage };
344
+ }
345
+ return { success: true, status: response.status, data };
346
+ } finally {
347
+ clearTimeout(timeout);
348
+ }
349
+ } catch (err) {
350
+ const msg = err instanceof Error ? err.message : String(err);
351
+ return { success: false, error: msg };
352
+ }
353
+ }
354
+ });
355
+
356
+ // ../connectors/src/connectors/intercom/index.ts
357
+ var tools = { request: requestTool };
358
+ var intercomConnector = new ConnectorPlugin({
359
+ slug: "intercom",
360
+ authType: null,
361
+ name: "Intercom",
362
+ description: "Connect to Intercom for contacts, conversations, companies, and customer engagement data using an Access Token.",
363
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1vKzXhRhJvDWGlAXdqBzMM/c0a58d645fba28a7ff6e2e0f84a098e9/intercom.svg",
364
+ parameters,
365
+ releaseFlag: { dev1: true, dev2: false, prod: false },
366
+ onboarding: intercomOnboarding,
367
+ systemPrompt: {
368
+ en: `### Tools
369
+
370
+ - \`intercom_request\`: The only way to call the Intercom API. Use it to query contacts, conversations, companies, articles, tags, segments, and more. Authentication (Bearer token) and API version header (Intercom-Version: 2.11) are configured automatically. Intercom uses cursor-based pagination with the \`starting_after\` parameter from \`pages.next.starting_after\` in the response. Use search endpoints (POST) for complex queries with filters.
371
+
372
+ ### Business Logic
373
+
374
+ The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
375
+
376
+ SDK methods (client created via \`connection(connectionId)\`):
377
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
378
+ - \`client.listContacts(options?)\` \u2014 list contacts with pagination (per_page, starting_after)
379
+ - \`client.getContact(contactId)\` \u2014 fetch a single contact
380
+ - \`client.searchContacts(query)\` \u2014 search contacts with field/operator/value filter
381
+ - \`client.listConversations(options?)\` \u2014 list conversations with pagination
382
+ - \`client.getConversation(conversationId)\` \u2014 fetch a single conversation
383
+ - \`client.listCompanies(options?)\` \u2014 list companies with pagination
384
+
385
+ \`\`\`ts
386
+ import type { Context } from "hono";
387
+ import { connection } from "@squadbase/vite-server/connectors/intercom";
388
+
389
+ const intercom = connection("<connectionId>");
390
+
391
+ export default async function handler(c: Context) {
392
+ const { data: contacts, total_count } = await intercom.listContacts({
393
+ per_page: 50,
394
+ });
395
+
396
+ return c.json({ contacts, total_count });
397
+ }
398
+ \`\`\`
399
+
400
+ ### Intercom API Reference
401
+
402
+ - Base URL: \`https://api.intercom.io\`
403
+ - Authentication: Bearer token (handled automatically)
404
+ - API Version: 2.11 (set via Intercom-Version header automatically)
405
+ - Pagination: Cursor-based with \`starting_after\` parameter from \`pages.next.starting_after\`
406
+
407
+ #### Contacts
408
+ - GET \`/contacts\` \u2014 List contacts (query params: per_page, starting_after)
409
+ - GET \`/contacts/{id}\` \u2014 Get a contact
410
+ - POST \`/contacts\` \u2014 Create a contact (body: \`{ "role": "user", "email": "..." }\`)
411
+ - PUT \`/contacts/{id}\` \u2014 Update a contact
412
+ - DELETE \`/contacts/{id}\` \u2014 Delete a contact (archive)
413
+ - POST \`/contacts/search\` \u2014 Search contacts (body: \`{ "query": { "field": "email", "operator": "=", "value": "..." } }\`)
414
+ - POST \`/contacts/merge\` \u2014 Merge contacts
415
+
416
+ #### Conversations
417
+ - GET \`/conversations\` \u2014 List conversations (query params: per_page, starting_after)
418
+ - GET \`/conversations/{id}\` \u2014 Get a conversation
419
+ - POST \`/conversations\` \u2014 Create a conversation
420
+ - PUT \`/conversations/{id}\` \u2014 Update a conversation
421
+ - POST \`/conversations/search\` \u2014 Search conversations
422
+ - POST \`/conversations/{id}/reply\` \u2014 Reply to a conversation
423
+ - POST \`/conversations/{id}/parts\` \u2014 Add a conversation part (note, assignment, etc.)
424
+
425
+ #### Companies
426
+ - GET \`/companies\` \u2014 List companies (query params: per_page, page)
427
+ - GET \`/companies/{id}\` \u2014 Get a company
428
+ - POST \`/companies\` \u2014 Create or update a company
429
+ - GET \`/companies/{id}/segments\` \u2014 List segments for a company
430
+
431
+ #### Articles
432
+ - GET \`/articles\` \u2014 List articles
433
+ - GET \`/articles/{id}\` \u2014 Get an article
434
+ - POST \`/articles\` \u2014 Create an article
435
+ - PUT \`/articles/{id}\` \u2014 Update an article
436
+ - DELETE \`/articles/{id}\` \u2014 Delete an article
437
+
438
+ #### Other Resources
439
+ - GET \`/tags\` \u2014 List tags
440
+ - GET \`/segments\` \u2014 List segments
441
+ - GET \`/admins\` \u2014 List admins
442
+ - GET \`/teams\` \u2014 List teams
443
+ - GET \`/data_attributes?model={model}\` \u2014 List data attributes (model: contact, company, conversation)
444
+ - GET \`/counts\` \u2014 App-wide counts
445
+ - GET \`/subscription_types\` \u2014 List subscription types
446
+ - GET \`/contacts/{id}/notes\` \u2014 List notes for a contact
447
+ - POST \`/contacts/{id}/notes\` \u2014 Create a note for a contact
448
+
449
+ #### Search Query Syntax (POST /contacts/search, /conversations/search)
450
+ \`\`\`json
451
+ {
452
+ "query": {
453
+ "operator": "AND",
454
+ "value": [
455
+ { "field": "email", "operator": "=", "value": "user@example.com" },
456
+ { "field": "created_at", "operator": ">", "value": 1672531200 }
457
+ ]
458
+ }
459
+ }
460
+ \`\`\`
461
+ - Operators: \`=\`, \`!=\`, \`>\`, \`<\`, \`~\` (contains), \`!~\` (not contains), \`IN\`, \`NIN\`
462
+ - Logical: \`AND\`, \`OR\` (combine multiple filters)
463
+ - Date fields use Unix timestamps`,
464
+ ja: `### \u30C4\u30FC\u30EB
465
+
466
+ - \`intercom_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\u3002\u8A8D\u8A3C\uFF08Bearer\u30C8\u30FC\u30AF\u30F3\uFF09\u3068API\u30D0\u30FC\u30B8\u30E7\u30F3\u30D8\u30C3\u30C0\u30FC\uFF08Intercom-Version: 2.11\uFF09\u306F\u81EA\u52D5\u7684\u306B\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\u8907\u96D1\u306A\u30AF\u30A8\u30EA\u306B\u306Fsearch\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\uFF08POST\uFF09\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
467
+
468
+ ### Business Logic
469
+
470
+ \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
471
+
472
+ SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
473
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
474
+ - \`client.listContacts(options?)\` \u2014 \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u4ED8\u304D\u3067\u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u4E00\u89A7\u53D6\u5F97\uFF08per_page, starting_after\uFF09
475
+ - \`client.getContact(contactId)\` \u2014 \u5358\u4E00\u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u53D6\u5F97
476
+ - \`client.searchContacts(query)\` \u2014 field/operator/value\u30D5\u30A3\u30EB\u30BF\u3067\u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u691C\u7D22
477
+ - \`client.listConversations(options?)\` \u2014 \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u4ED8\u304D\u3067\u4F1A\u8A71\u3092\u4E00\u89A7\u53D6\u5F97
478
+ - \`client.getConversation(conversationId)\` \u2014 \u5358\u4E00\u4F1A\u8A71\u3092\u53D6\u5F97
479
+ - \`client.listCompanies(options?)\` \u2014 \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u4ED8\u304D\u3067\u4F01\u696D\u3092\u4E00\u89A7\u53D6\u5F97
480
+
481
+ \`\`\`ts
482
+ import type { Context } from "hono";
483
+ import { connection } from "@squadbase/vite-server/connectors/intercom";
484
+
485
+ const intercom = connection("<connectionId>");
486
+
487
+ export default async function handler(c: Context) {
488
+ const { data: contacts, total_count } = await intercom.listContacts({
489
+ per_page: 50,
490
+ });
491
+
492
+ return c.json({ contacts, total_count });
493
+ }
494
+ \`\`\`
495
+
496
+ ### Intercom API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
497
+
498
+ - \u30D9\u30FC\u30B9URL: \`https://api.intercom.io\`
499
+ - \u8A8D\u8A3C: Bearer\u30C8\u30FC\u30AF\u30F3\uFF08\u81EA\u52D5\u8A2D\u5B9A\uFF09
500
+ - API\u30D0\u30FC\u30B8\u30E7\u30F3: 2.11\uFF08Intercom-Version\u30D8\u30C3\u30C0\u30FC\u3067\u81EA\u52D5\u8A2D\u5B9A\uFF09
501
+ - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3: \`pages.next.starting_after\` \u304B\u3089\u306E \`starting_after\` \u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9
502
+
503
+ #### \u30B3\u30F3\u30BF\u30AF\u30C8
504
+ - 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
505
+ - GET \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u53D6\u5F97
506
+ - POST \`/contacts\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u4F5C\u6210\uFF08body: \`{ "role": "user", "email": "..." }\`\uFF09
507
+ - PUT \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u66F4\u65B0
508
+ - DELETE \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u524A\u9664\uFF08\u30A2\u30FC\u30AB\u30A4\u30D6\uFF09
509
+ - POST \`/contacts/search\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u691C\u7D22\uFF08body: \`{ "query": { "field": "email", "operator": "=", "value": "..." } }\`\uFF09
510
+ - POST \`/contacts/merge\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u30DE\u30FC\u30B8
511
+
512
+ #### \u4F1A\u8A71
513
+ - GET \`/conversations\` \u2014 \u4F1A\u8A71\u4E00\u89A7\u3092\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: per_page, starting_after\uFF09
514
+ - GET \`/conversations/{id}\` \u2014 \u4F1A\u8A71\u3092\u53D6\u5F97
515
+ - POST \`/conversations\` \u2014 \u4F1A\u8A71\u3092\u4F5C\u6210
516
+ - PUT \`/conversations/{id}\` \u2014 \u4F1A\u8A71\u3092\u66F4\u65B0
517
+ - POST \`/conversations/search\` \u2014 \u4F1A\u8A71\u3092\u691C\u7D22
518
+ - POST \`/conversations/{id}/reply\` \u2014 \u4F1A\u8A71\u306B\u8FD4\u4FE1
519
+ - POST \`/conversations/{id}/parts\` \u2014 \u4F1A\u8A71\u30D1\u30FC\u30C4\u3092\u8FFD\u52A0\uFF08\u30E1\u30E2\u3001\u30A2\u30B5\u30A4\u30F3\u306A\u3069\uFF09
520
+
521
+ #### \u4F01\u696D
522
+ - GET \`/companies\` \u2014 \u4F01\u696D\u4E00\u89A7\u3092\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: per_page, page\uFF09
523
+ - GET \`/companies/{id}\` \u2014 \u4F01\u696D\u3092\u53D6\u5F97
524
+ - POST \`/companies\` \u2014 \u4F01\u696D\u3092\u4F5C\u6210\u30FB\u66F4\u65B0
525
+ - GET \`/companies/{id}/segments\` \u2014 \u4F01\u696D\u306E\u30BB\u30B0\u30E1\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
526
+
527
+ #### \u8A18\u4E8B
528
+ - GET \`/articles\` \u2014 \u8A18\u4E8B\u4E00\u89A7\u3092\u53D6\u5F97
529
+ - GET \`/articles/{id}\` \u2014 \u8A18\u4E8B\u3092\u53D6\u5F97
530
+ - POST \`/articles\` \u2014 \u8A18\u4E8B\u3092\u4F5C\u6210
531
+ - PUT \`/articles/{id}\` \u2014 \u8A18\u4E8B\u3092\u66F4\u65B0
532
+ - DELETE \`/articles/{id}\` \u2014 \u8A18\u4E8B\u3092\u524A\u9664
533
+
534
+ #### \u305D\u306E\u4ED6\u306E\u30EA\u30BD\u30FC\u30B9
535
+ - GET \`/tags\` \u2014 \u30BF\u30B0\u4E00\u89A7\u3092\u53D6\u5F97
536
+ - GET \`/segments\` \u2014 \u30BB\u30B0\u30E1\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
537
+ - GET \`/admins\` \u2014 \u7BA1\u7406\u8005\u4E00\u89A7\u3092\u53D6\u5F97
538
+ - GET \`/teams\` \u2014 \u30C1\u30FC\u30E0\u4E00\u89A7\u3092\u53D6\u5F97
539
+ - GET \`/data_attributes?model={model}\` \u2014 \u30C7\u30FC\u30BF\u5C5E\u6027\u4E00\u89A7\u3092\u53D6\u5F97\uFF08model: contact, company, conversation\uFF09
540
+ - GET \`/counts\` \u2014 \u30A2\u30D7\u30EA\u5168\u4F53\u306E\u30AB\u30A6\u30F3\u30C8
541
+ - GET \`/subscription_types\` \u2014 \u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u30BF\u30A4\u30D7\u4E00\u89A7\u3092\u53D6\u5F97
542
+ - GET \`/contacts/{id}/notes\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u306E\u30E1\u30E2\u4E00\u89A7\u3092\u53D6\u5F97
543
+ - POST \`/contacts/{id}/notes\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u306B\u30E1\u30E2\u3092\u4F5C\u6210
544
+
545
+ #### \u691C\u7D22\u30AF\u30A8\u30EA\u69CB\u6587 (POST /contacts/search, /conversations/search)
546
+ \`\`\`json
547
+ {
548
+ "query": {
549
+ "operator": "AND",
550
+ "value": [
551
+ { "field": "email", "operator": "=", "value": "user@example.com" },
552
+ { "field": "created_at", "operator": ">", "value": 1672531200 }
553
+ ]
554
+ }
555
+ }
556
+ \`\`\`
557
+ - \u6F14\u7B97\u5B50: \`=\`, \`!=\`, \`>\`, \`<\`, \`~\`\uFF08\u542B\u3080\uFF09, \`!~\`\uFF08\u542B\u307E\u306A\u3044\uFF09, \`IN\`, \`NIN\`
558
+ - \u8AD6\u7406\u6F14\u7B97\u5B50: \`AND\`, \`OR\`\uFF08\u8907\u6570\u30D5\u30A3\u30EB\u30BF\u306E\u7D50\u5408\uFF09
559
+ - \u65E5\u4ED8\u30D5\u30A3\u30FC\u30EB\u30C9\u306FUnix\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3092\u4F7F\u7528`
560
+ },
561
+ tools
562
+ });
563
+
564
+ // src/connectors/create-connector-sdk.ts
565
+ import { readFileSync } from "fs";
566
+ import path from "path";
567
+
568
+ // src/connector-client/env.ts
569
+ function resolveEnvVar(entry, key, connectionId) {
570
+ const envVarName = entry.envVars[key];
571
+ if (!envVarName) {
572
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
573
+ }
574
+ const value = process.env[envVarName];
575
+ if (!value) {
576
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
577
+ }
578
+ return value;
579
+ }
580
+ function resolveEnvVarOptional(entry, key) {
581
+ const envVarName = entry.envVars[key];
582
+ if (!envVarName) return void 0;
583
+ return process.env[envVarName] || void 0;
584
+ }
585
+
586
+ // src/connectors/create-connector-sdk.ts
587
+ function loadConnectionsSync() {
588
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
589
+ try {
590
+ const raw = readFileSync(filePath, "utf-8");
591
+ return JSON.parse(raw);
592
+ } catch {
593
+ return {};
594
+ }
595
+ }
596
+ function createConnectorSdk(plugin, createClient2) {
597
+ return (connectionId) => {
598
+ const connections = loadConnectionsSync();
599
+ const entry = connections[connectionId];
600
+ if (!entry) {
601
+ throw new Error(
602
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
603
+ );
604
+ }
605
+ if (entry.connector.slug !== plugin.slug) {
606
+ throw new Error(
607
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
608
+ );
609
+ }
610
+ const params = {};
611
+ for (const param of Object.values(plugin.parameters)) {
612
+ if (param.required) {
613
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
614
+ } else {
615
+ const val = resolveEnvVarOptional(entry, param.slug);
616
+ if (val !== void 0) params[param.slug] = val;
617
+ }
618
+ }
619
+ return createClient2(params);
620
+ };
621
+ }
622
+
623
+ // src/connectors/entries/intercom.ts
624
+ var connection = createConnectorSdk(intercomConnector, createClient);
625
+ export {
626
+ connection
627
+ };
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.JiraConnectorSdk;
4
+
5
+ export { connection };