@squadbase/vite-server 0.1.3-dev.0 → 0.1.3-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +82143 -9661
- package/dist/connectors/asana.d.ts +5 -0
- package/dist/connectors/asana.js +661 -0
- package/dist/connectors/customerio.d.ts +5 -0
- package/dist/connectors/customerio.js +633 -0
- package/dist/connectors/gemini.js +1 -1
- package/dist/connectors/gmail-oauth.d.ts +5 -0
- package/dist/connectors/gmail-oauth.js +639 -0
- package/dist/connectors/google-ads.d.ts +5 -0
- package/dist/connectors/google-ads.js +784 -0
- package/dist/connectors/google-sheets.d.ts +5 -0
- package/dist/connectors/google-sheets.js +598 -0
- package/dist/connectors/hubspot.js +14 -5
- package/dist/connectors/intercom-oauth.d.ts +5 -0
- package/dist/connectors/intercom-oauth.js +510 -0
- package/dist/connectors/intercom.d.ts +5 -0
- package/dist/connectors/intercom.js +627 -0
- package/dist/connectors/jira-api-key.d.ts +5 -0
- package/dist/connectors/jira-api-key.js +524 -0
- package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
- package/dist/connectors/linkedin-ads-oauth.js +774 -0
- package/dist/connectors/linkedin-ads.d.ts +5 -0
- package/dist/connectors/linkedin-ads.js +782 -0
- package/dist/connectors/mailchimp-oauth.d.ts +5 -0
- package/dist/connectors/mailchimp-oauth.js +539 -0
- package/dist/connectors/mailchimp.d.ts +5 -0
- package/dist/connectors/mailchimp.js +646 -0
- package/dist/connectors/notion-oauth.d.ts +5 -0
- package/dist/connectors/notion-oauth.js +493 -0
- package/dist/connectors/notion.d.ts +5 -0
- package/dist/connectors/notion.js +580 -0
- package/dist/connectors/zendesk-oauth.d.ts +5 -0
- package/dist/connectors/zendesk-oauth.js +505 -0
- package/dist/connectors/zendesk.d.ts +5 -0
- package/dist/connectors/zendesk.js +631 -0
- package/dist/index.js +82350 -7194
- package/dist/main.js +82336 -7180
- package/dist/vite-plugin.js +82235 -7079
- package/package.json +66 -2
|
@@ -0,0 +1,510 @@
|
|
|
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
|
+
};
|
|
119
|
+
|
|
120
|
+
// ../connectors/src/connectors/intercom-oauth/tools/request.ts
|
|
121
|
+
import { z } from "zod";
|
|
122
|
+
var BASE_URL2 = "https://api.intercom.io";
|
|
123
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
124
|
+
var cachedToken = null;
|
|
125
|
+
async function getProxyToken(config) {
|
|
126
|
+
if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
|
|
127
|
+
return cachedToken.token;
|
|
128
|
+
}
|
|
129
|
+
const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
|
|
130
|
+
const res = await fetch(url, {
|
|
131
|
+
method: "POST",
|
|
132
|
+
headers: {
|
|
133
|
+
"Content-Type": "application/json",
|
|
134
|
+
"x-api-key": config.appApiKey,
|
|
135
|
+
"project-id": config.projectId
|
|
136
|
+
},
|
|
137
|
+
body: JSON.stringify({
|
|
138
|
+
sandboxId: config.sandboxId,
|
|
139
|
+
issuedBy: "coding-agent"
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
if (!res.ok) {
|
|
143
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
144
|
+
throw new Error(
|
|
145
|
+
`Failed to get proxy token: HTTP ${res.status} ${errorText}`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const data = await res.json();
|
|
149
|
+
cachedToken = {
|
|
150
|
+
token: data.token,
|
|
151
|
+
expiresAt: new Date(data.expiresAt).getTime()
|
|
152
|
+
};
|
|
153
|
+
return data.token;
|
|
154
|
+
}
|
|
155
|
+
var inputSchema = z.object({
|
|
156
|
+
toolUseIntent: z.string().optional().describe(
|
|
157
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
158
|
+
),
|
|
159
|
+
connectionId: z.string().describe("ID of the Intercom OAuth connection to use"),
|
|
160
|
+
method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
|
|
161
|
+
path: z.string().describe(
|
|
162
|
+
"API path appended to https://api.intercom.io (e.g., '/contacts', '/conversations', '/contacts/search')"
|
|
163
|
+
),
|
|
164
|
+
queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
|
|
165
|
+
body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PUT requests")
|
|
166
|
+
});
|
|
167
|
+
var outputSchema = z.discriminatedUnion("success", [
|
|
168
|
+
z.object({
|
|
169
|
+
success: z.literal(true),
|
|
170
|
+
status: z.number(),
|
|
171
|
+
data: z.record(z.string(), z.unknown())
|
|
172
|
+
}),
|
|
173
|
+
z.object({
|
|
174
|
+
success: z.literal(false),
|
|
175
|
+
error: z.string()
|
|
176
|
+
})
|
|
177
|
+
]);
|
|
178
|
+
var requestTool = new ConnectorTool({
|
|
179
|
+
name: "request",
|
|
180
|
+
description: `Send authenticated requests to the Intercom API.
|
|
181
|
+
Authentication is handled automatically via OAuth proxy.
|
|
182
|
+
The Intercom-Version header (2.11) is set automatically.
|
|
183
|
+
Use this tool for all Intercom API interactions: querying contacts, conversations, companies, articles, tags, and segments.
|
|
184
|
+
Search endpoints (contacts/search, conversations/search) use POST with a query object in the body.`,
|
|
185
|
+
inputSchema,
|
|
186
|
+
outputSchema,
|
|
187
|
+
async execute({ connectionId, method, path: path2, queryParams, body }, connections, config) {
|
|
188
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
189
|
+
if (!connection2) {
|
|
190
|
+
return {
|
|
191
|
+
success: false,
|
|
192
|
+
error: `Connection ${connectionId} not found`
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
console.log(
|
|
196
|
+
`[connector-request] intercom-oauth/${connection2.name}: ${method} ${path2}`
|
|
197
|
+
);
|
|
198
|
+
try {
|
|
199
|
+
let url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
200
|
+
if (queryParams) {
|
|
201
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
202
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
203
|
+
url += `${separator}${searchParams.toString()}`;
|
|
204
|
+
}
|
|
205
|
+
const token = await getProxyToken(config.oauthProxy);
|
|
206
|
+
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
207
|
+
const controller = new AbortController();
|
|
208
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
209
|
+
try {
|
|
210
|
+
const response = await fetch(proxyUrl, {
|
|
211
|
+
method: "POST",
|
|
212
|
+
headers: {
|
|
213
|
+
"Content-Type": "application/json",
|
|
214
|
+
Authorization: `Bearer ${token}`
|
|
215
|
+
},
|
|
216
|
+
body: JSON.stringify({
|
|
217
|
+
url,
|
|
218
|
+
method,
|
|
219
|
+
body: body ? JSON.stringify(body) : void 0
|
|
220
|
+
}),
|
|
221
|
+
signal: controller.signal
|
|
222
|
+
});
|
|
223
|
+
const data = await response.json();
|
|
224
|
+
if (!response.ok) {
|
|
225
|
+
const errors = data?.errors;
|
|
226
|
+
const errorMessage = errors?.[0]?.message ?? (typeof data?.error === "string" ? data.error : null) ?? `HTTP ${response.status} ${response.statusText}`;
|
|
227
|
+
return { success: false, error: errorMessage };
|
|
228
|
+
}
|
|
229
|
+
return { success: true, status: response.status, data };
|
|
230
|
+
} finally {
|
|
231
|
+
clearTimeout(timeout);
|
|
232
|
+
}
|
|
233
|
+
} catch (err) {
|
|
234
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
235
|
+
return { success: false, error: msg };
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// ../connectors/src/connectors/intercom-oauth/setup.ts
|
|
241
|
+
var requestToolName = `intercom-oauth_${requestTool.name}`;
|
|
242
|
+
var intercomOauthOnboarding = new ConnectorOnboarding({
|
|
243
|
+
connectionSetupInstructions: {
|
|
244
|
+
en: `Follow these steps to set up the Intercom connection.
|
|
245
|
+
|
|
246
|
+
1. Call \`${requestToolName}\` to verify the connection:
|
|
247
|
+
- \`method\`: \`"GET"\`
|
|
248
|
+
- \`path\`: \`"/me"\`
|
|
249
|
+
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
250
|
+
3. Call \`updateConnectionContext\`:
|
|
251
|
+
- \`account\`: Intercom workspace name or admin email
|
|
252
|
+
- \`note\`: Brief description of the setup
|
|
253
|
+
|
|
254
|
+
#### Constraints
|
|
255
|
+
- **Do NOT read business data during setup**. Only the metadata request specified in the steps above is allowed
|
|
256
|
+
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`,
|
|
257
|
+
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
|
|
258
|
+
|
|
259
|
+
1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u63A5\u7D9A\u3092\u78BA\u8A8D\u3059\u308B:
|
|
260
|
+
- \`method\`: \`"GET"\`
|
|
261
|
+
- \`path\`: \`"/me"\`
|
|
262
|
+
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
|
|
263
|
+
3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
264
|
+
- \`account\`: Intercom\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u540D\u307E\u305F\u306F\u7BA1\u7406\u8005\u30E1\u30FC\u30EB
|
|
265
|
+
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
266
|
+
|
|
267
|
+
#### \u5236\u7D04
|
|
268
|
+
- **\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
|
|
269
|
+
- \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`
|
|
270
|
+
},
|
|
271
|
+
dataOverviewInstructions: {
|
|
272
|
+
en: `1. Call intercom-oauth_request with GET /contacts?per_page=5 to explore contacts structure
|
|
273
|
+
2. Call intercom-oauth_request with GET /conversations?per_page=5 to explore conversations structure
|
|
274
|
+
3. Call intercom-oauth_request with GET /data_attributes?model=contact to list contact data attributes
|
|
275
|
+
4. Call intercom-oauth_request with GET /companies?per_page=5 to explore company structure`,
|
|
276
|
+
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
|
|
277
|
+
2. intercom-oauth_request \u3067 GET /conversations?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u4F1A\u8A71\u306E\u69CB\u9020\u3092\u78BA\u8A8D
|
|
278
|
+
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
|
|
279
|
+
4. intercom-oauth_request \u3067 GET /companies?per_page=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u4F01\u696D\u306E\u69CB\u9020\u3092\u78BA\u8A8D`
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// ../connectors/src/connectors/intercom-oauth/parameters.ts
|
|
284
|
+
var parameters = {};
|
|
285
|
+
|
|
286
|
+
// ../connectors/src/connectors/intercom-oauth/index.ts
|
|
287
|
+
var tools = { request: requestTool };
|
|
288
|
+
var intercomOauthConnector = new ConnectorPlugin({
|
|
289
|
+
slug: "intercom",
|
|
290
|
+
authType: AUTH_TYPES.OAUTH,
|
|
291
|
+
name: "Intercom (OAuth)",
|
|
292
|
+
description: "Connect to Intercom for contacts, conversations, companies, and customer engagement data using OAuth.",
|
|
293
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/sb2cRMGClpId0LKiSqsok/ae90a0849f21ffe3faf73e04a5676b45/intercom.svg",
|
|
294
|
+
parameters,
|
|
295
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
296
|
+
onboarding: intercomOauthOnboarding,
|
|
297
|
+
proxyPolicy: {
|
|
298
|
+
allowlist: [
|
|
299
|
+
{
|
|
300
|
+
host: "api.intercom.io",
|
|
301
|
+
methods: ["GET", "POST", "PUT", "DELETE"]
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
systemPrompt: {
|
|
306
|
+
en: `### Tools
|
|
307
|
+
|
|
308
|
+
- \`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.
|
|
309
|
+
|
|
310
|
+
### Intercom API Reference
|
|
311
|
+
|
|
312
|
+
#### Contacts
|
|
313
|
+
- GET \`/contacts\` \u2014 List contacts (query params: per_page, starting_after)
|
|
314
|
+
- GET \`/contacts/{id}\` \u2014 Get a contact
|
|
315
|
+
- POST \`/contacts\` \u2014 Create a contact
|
|
316
|
+
- PUT \`/contacts/{id}\` \u2014 Update a contact
|
|
317
|
+
- DELETE \`/contacts/{id}\` \u2014 Delete a contact (archive)
|
|
318
|
+
- POST \`/contacts/search\` \u2014 Search contacts
|
|
319
|
+
|
|
320
|
+
#### Conversations
|
|
321
|
+
- GET \`/conversations\` \u2014 List conversations (query params: per_page, starting_after)
|
|
322
|
+
- GET \`/conversations/{id}\` \u2014 Get a conversation
|
|
323
|
+
- POST \`/conversations\` \u2014 Create a conversation
|
|
324
|
+
- PUT \`/conversations/{id}\` \u2014 Update a conversation
|
|
325
|
+
- POST \`/conversations/search\` \u2014 Search conversations
|
|
326
|
+
- POST \`/conversations/{id}/reply\` \u2014 Reply to a conversation
|
|
327
|
+
|
|
328
|
+
#### Companies
|
|
329
|
+
- GET \`/companies\` \u2014 List companies (query params: per_page, page)
|
|
330
|
+
- GET \`/companies/{id}\` \u2014 Get a company
|
|
331
|
+
- POST \`/companies\` \u2014 Create or update a company
|
|
332
|
+
|
|
333
|
+
#### Articles
|
|
334
|
+
- GET \`/articles\` \u2014 List articles
|
|
335
|
+
- GET \`/articles/{id}\` \u2014 Get an article
|
|
336
|
+
|
|
337
|
+
#### Other Resources
|
|
338
|
+
- GET \`/tags\` \u2014 List tags
|
|
339
|
+
- GET \`/segments\` \u2014 List segments
|
|
340
|
+
- GET \`/admins\` \u2014 List admins
|
|
341
|
+
- GET \`/teams\` \u2014 List teams
|
|
342
|
+
- GET \`/data_attributes?model={model}\` \u2014 List data attributes (model: contact, company, conversation)
|
|
343
|
+
|
|
344
|
+
### Tips
|
|
345
|
+
- Search endpoints use POST with a JSON query body
|
|
346
|
+
- Pagination uses cursor-based \`starting_after\` from \`pages.next.starting_after\`
|
|
347
|
+
- Date fields in search use Unix timestamps
|
|
348
|
+
|
|
349
|
+
### Business Logic
|
|
350
|
+
|
|
351
|
+
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.
|
|
352
|
+
|
|
353
|
+
#### Example
|
|
354
|
+
|
|
355
|
+
\`\`\`ts
|
|
356
|
+
import { connection } from "@squadbase/vite-server/connectors/intercom-oauth";
|
|
357
|
+
|
|
358
|
+
const intercom = connection("<connectionId>");
|
|
359
|
+
|
|
360
|
+
// Authenticated fetch (returns standard Response)
|
|
361
|
+
const res = await intercom.request("/contacts?per_page=10");
|
|
362
|
+
const data = await res.json();
|
|
363
|
+
\`\`\``,
|
|
364
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
365
|
+
|
|
366
|
+
- \`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
|
|
367
|
+
|
|
368
|
+
### Intercom API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
369
|
+
|
|
370
|
+
#### \u30B3\u30F3\u30BF\u30AF\u30C8
|
|
371
|
+
- 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
|
|
372
|
+
- GET \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u53D6\u5F97
|
|
373
|
+
- POST \`/contacts\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u4F5C\u6210
|
|
374
|
+
- PUT \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u66F4\u65B0
|
|
375
|
+
- DELETE \`/contacts/{id}\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u524A\u9664\uFF08\u30A2\u30FC\u30AB\u30A4\u30D6\uFF09
|
|
376
|
+
- POST \`/contacts/search\` \u2014 \u30B3\u30F3\u30BF\u30AF\u30C8\u3092\u691C\u7D22
|
|
377
|
+
|
|
378
|
+
#### \u4F1A\u8A71
|
|
379
|
+
- GET \`/conversations\` \u2014 \u4F1A\u8A71\u4E00\u89A7\u3092\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: per_page, starting_after\uFF09
|
|
380
|
+
- GET \`/conversations/{id}\` \u2014 \u4F1A\u8A71\u3092\u53D6\u5F97
|
|
381
|
+
- POST \`/conversations\` \u2014 \u4F1A\u8A71\u3092\u4F5C\u6210
|
|
382
|
+
- PUT \`/conversations/{id}\` \u2014 \u4F1A\u8A71\u3092\u66F4\u65B0
|
|
383
|
+
- POST \`/conversations/search\` \u2014 \u4F1A\u8A71\u3092\u691C\u7D22
|
|
384
|
+
- POST \`/conversations/{id}/reply\` \u2014 \u4F1A\u8A71\u306B\u8FD4\u4FE1
|
|
385
|
+
|
|
386
|
+
#### \u4F01\u696D
|
|
387
|
+
- GET \`/companies\` \u2014 \u4F01\u696D\u4E00\u89A7\u3092\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: per_page, page\uFF09
|
|
388
|
+
- GET \`/companies/{id}\` \u2014 \u4F01\u696D\u3092\u53D6\u5F97
|
|
389
|
+
- POST \`/companies\` \u2014 \u4F01\u696D\u3092\u4F5C\u6210\u30FB\u66F4\u65B0
|
|
390
|
+
|
|
391
|
+
#### \u8A18\u4E8B
|
|
392
|
+
- GET \`/articles\` \u2014 \u8A18\u4E8B\u4E00\u89A7\u3092\u53D6\u5F97
|
|
393
|
+
- GET \`/articles/{id}\` \u2014 \u8A18\u4E8B\u3092\u53D6\u5F97
|
|
394
|
+
|
|
395
|
+
#### \u305D\u306E\u4ED6\u306E\u30EA\u30BD\u30FC\u30B9
|
|
396
|
+
- GET \`/tags\` \u2014 \u30BF\u30B0\u4E00\u89A7\u3092\u53D6\u5F97
|
|
397
|
+
- GET \`/segments\` \u2014 \u30BB\u30B0\u30E1\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
|
|
398
|
+
- GET \`/admins\` \u2014 \u7BA1\u7406\u8005\u4E00\u89A7\u3092\u53D6\u5F97
|
|
399
|
+
- GET \`/teams\` \u2014 \u30C1\u30FC\u30E0\u4E00\u89A7\u3092\u53D6\u5F97
|
|
400
|
+
- GET \`/data_attributes?model={model}\` \u2014 \u30C7\u30FC\u30BF\u5C5E\u6027\u4E00\u89A7\u3092\u53D6\u5F97\uFF08model: contact, company, conversation\uFF09
|
|
401
|
+
|
|
402
|
+
### \u30D2\u30F3\u30C8
|
|
403
|
+
- \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
|
|
404
|
+
- \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
|
|
405
|
+
- \u691C\u7D22\u306E\u65E5\u4ED8\u30D5\u30A3\u30FC\u30EB\u30C9\u306FUnix\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3092\u4F7F\u7528\u3057\u307E\u3059
|
|
406
|
+
|
|
407
|
+
### Business Logic
|
|
408
|
+
|
|
409
|
+
\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
|
|
410
|
+
|
|
411
|
+
#### Example
|
|
412
|
+
|
|
413
|
+
\`\`\`ts
|
|
414
|
+
import { connection } from "@squadbase/vite-server/connectors/intercom-oauth";
|
|
415
|
+
|
|
416
|
+
const intercom = connection("<connectionId>");
|
|
417
|
+
|
|
418
|
+
// Authenticated fetch (returns standard Response)
|
|
419
|
+
const res = await intercom.request("/contacts?per_page=10");
|
|
420
|
+
const data = await res.json();
|
|
421
|
+
\`\`\``
|
|
422
|
+
},
|
|
423
|
+
tools,
|
|
424
|
+
async checkConnection(_params, config) {
|
|
425
|
+
const { proxyFetch } = config;
|
|
426
|
+
try {
|
|
427
|
+
const res = await proxyFetch("https://api.intercom.io/me", {
|
|
428
|
+
method: "GET"
|
|
429
|
+
});
|
|
430
|
+
if (!res.ok) {
|
|
431
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
432
|
+
return {
|
|
433
|
+
success: false,
|
|
434
|
+
error: `Intercom API failed: HTTP ${res.status} ${errorText}`
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
return { success: true };
|
|
438
|
+
} catch (error) {
|
|
439
|
+
return {
|
|
440
|
+
success: false,
|
|
441
|
+
error: error instanceof Error ? error.message : String(error)
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
// src/connectors/create-connector-sdk.ts
|
|
448
|
+
import { readFileSync } from "fs";
|
|
449
|
+
import path from "path";
|
|
450
|
+
|
|
451
|
+
// src/connector-client/env.ts
|
|
452
|
+
function resolveEnvVar(entry, key, connectionId) {
|
|
453
|
+
const envVarName = entry.envVars[key];
|
|
454
|
+
if (!envVarName) {
|
|
455
|
+
throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
|
|
456
|
+
}
|
|
457
|
+
const value = process.env[envVarName];
|
|
458
|
+
if (!value) {
|
|
459
|
+
throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
|
|
460
|
+
}
|
|
461
|
+
return value;
|
|
462
|
+
}
|
|
463
|
+
function resolveEnvVarOptional(entry, key) {
|
|
464
|
+
const envVarName = entry.envVars[key];
|
|
465
|
+
if (!envVarName) return void 0;
|
|
466
|
+
return process.env[envVarName] || void 0;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// src/connectors/create-connector-sdk.ts
|
|
470
|
+
function loadConnectionsSync() {
|
|
471
|
+
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
472
|
+
try {
|
|
473
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
474
|
+
return JSON.parse(raw);
|
|
475
|
+
} catch {
|
|
476
|
+
return {};
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function createConnectorSdk(plugin, createClient2) {
|
|
480
|
+
return (connectionId) => {
|
|
481
|
+
const connections = loadConnectionsSync();
|
|
482
|
+
const entry = connections[connectionId];
|
|
483
|
+
if (!entry) {
|
|
484
|
+
throw new Error(
|
|
485
|
+
`Connection "${connectionId}" not found in .squadbase/connections.json`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
if (entry.connector.slug !== plugin.slug) {
|
|
489
|
+
throw new Error(
|
|
490
|
+
`Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
const params = {};
|
|
494
|
+
for (const param of Object.values(plugin.parameters)) {
|
|
495
|
+
if (param.required) {
|
|
496
|
+
params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
|
|
497
|
+
} else {
|
|
498
|
+
const val = resolveEnvVarOptional(entry, param.slug);
|
|
499
|
+
if (val !== void 0) params[param.slug] = val;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return createClient2(params);
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// src/connectors/entries/intercom-oauth.ts
|
|
507
|
+
var connection = createConnectorSdk(intercomOauthConnector, createClient);
|
|
508
|
+
export {
|
|
509
|
+
connection
|
|
510
|
+
};
|