@squadbase/vite-server 0.1.3-dev.9 → 0.1.4-dev.0
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 +14539 -29447
- package/dist/connectors/airtable-oauth.js +43 -6
- package/dist/connectors/airtable.js +43 -6
- package/dist/connectors/amplitude.js +43 -6
- package/dist/connectors/anthropic.js +43 -6
- package/dist/connectors/asana.js +43 -6
- package/dist/connectors/attio.js +522 -118
- package/dist/connectors/{google-ads-oauth.d.ts → backlog-api-key.d.ts} +1 -1
- package/dist/connectors/backlog-api-key.js +629 -0
- package/dist/connectors/customerio.js +43 -6
- package/dist/connectors/dbt.js +43 -6
- package/dist/connectors/{google-sheets-oauth.d.ts → gamma.d.ts} +1 -1
- package/dist/connectors/gamma.js +866 -0
- package/dist/connectors/gemini.js +43 -6
- package/dist/connectors/gmail-oauth.js +65 -8
- package/dist/connectors/gmail.js +104 -44
- package/dist/connectors/google-ads.d.ts +1 -1
- package/dist/connectors/google-ads.js +410 -332
- package/dist/connectors/google-analytics-oauth.js +61 -8
- package/dist/connectors/google-analytics.js +107 -292
- package/dist/connectors/google-calendar-oauth.js +61 -8
- package/dist/connectors/google-calendar.js +111 -58
- package/dist/connectors/{linkedin-ads-oauth.d.ts → google-docs.d.ts} +1 -1
- package/dist/connectors/google-docs.js +631 -0
- package/dist/connectors/google-drive.d.ts +5 -0
- package/dist/connectors/google-drive.js +875 -0
- package/dist/connectors/google-sheets.d.ts +1 -1
- package/dist/connectors/google-sheets.js +267 -285
- package/dist/connectors/google-slides.d.ts +5 -0
- package/dist/connectors/google-slides.js +663 -0
- package/dist/connectors/grafana.js +43 -6
- package/dist/connectors/hubspot-oauth.js +43 -6
- package/dist/connectors/hubspot.js +43 -6
- package/dist/connectors/intercom-oauth.js +43 -6
- package/dist/connectors/intercom.js +43 -6
- package/dist/connectors/jira-api-key.js +43 -6
- package/dist/connectors/kintone-api-token.js +256 -82
- package/dist/connectors/kintone.js +43 -6
- package/dist/connectors/linkedin-ads.js +188 -168
- package/dist/connectors/mailchimp-oauth.js +43 -6
- package/dist/connectors/mailchimp.js +43 -6
- package/dist/connectors/mixpanel.d.ts +5 -0
- package/dist/connectors/mixpanel.js +779 -0
- package/dist/connectors/notion-oauth.js +43 -6
- package/dist/connectors/notion.js +43 -6
- package/dist/connectors/openai.js +43 -6
- package/dist/connectors/sentry.d.ts +5 -0
- package/dist/connectors/sentry.js +761 -0
- package/dist/connectors/shopify-oauth.js +43 -6
- package/dist/connectors/shopify.js +43 -6
- package/dist/connectors/stripe-api-key.js +46 -7
- package/dist/connectors/stripe-oauth.js +43 -6
- package/dist/connectors/wix-store.js +43 -6
- package/dist/connectors/zendesk-oauth.js +43 -6
- package/dist/connectors/zendesk.js +43 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4574 -3863
- package/dist/main.js +4572 -3862
- package/dist/vite-plugin.js +4572 -3862
- package/package.json +30 -12
- package/dist/connectors/google-ads-oauth.js +0 -890
- package/dist/connectors/google-sheets-oauth.js +0 -718
- package/dist/connectors/linkedin-ads-oauth.js +0 -848
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
// ../connectors/src/connectors/google-slides/sdk/index.ts
|
|
2
|
+
var SLIDES_BASE_URL = "https://slides.googleapis.com/v1/presentations";
|
|
3
|
+
function createClient(_params, fetchFn = fetch) {
|
|
4
|
+
function request(path2, init) {
|
|
5
|
+
const url = `${SLIDES_BASE_URL}${path2 === "" || path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
6
|
+
return fetchFn(url, init);
|
|
7
|
+
}
|
|
8
|
+
async function getPresentation(presentationId) {
|
|
9
|
+
const url = `${SLIDES_BASE_URL}/${presentationId}`;
|
|
10
|
+
const response = await fetchFn(url);
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
const body = await response.text();
|
|
13
|
+
throw new Error(
|
|
14
|
+
`google-slides: getPresentation failed (${response.status}): ${body}`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return await response.json();
|
|
18
|
+
}
|
|
19
|
+
async function getPage(presentationId, pageObjectId) {
|
|
20
|
+
const url = `${SLIDES_BASE_URL}/${presentationId}/pages/${pageObjectId}`;
|
|
21
|
+
const response = await fetchFn(url);
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
const body = await response.text();
|
|
24
|
+
throw new Error(
|
|
25
|
+
`google-slides: getPage failed (${response.status}): ${body}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return await response.json();
|
|
29
|
+
}
|
|
30
|
+
async function batchUpdate(presentationId, requests) {
|
|
31
|
+
const url = `${SLIDES_BASE_URL}/${presentationId}:batchUpdate`;
|
|
32
|
+
const response = await fetchFn(url, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "Content-Type": "application/json" },
|
|
35
|
+
body: JSON.stringify({ requests })
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
const body = await response.text();
|
|
39
|
+
throw new Error(
|
|
40
|
+
`google-slides: batchUpdate failed (${response.status}): ${body}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return await response.json();
|
|
44
|
+
}
|
|
45
|
+
async function createPresentation(title) {
|
|
46
|
+
const url = SLIDES_BASE_URL;
|
|
47
|
+
const response = await fetchFn(url, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: { "Content-Type": "application/json" },
|
|
50
|
+
body: JSON.stringify({ title })
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const body = await response.text();
|
|
54
|
+
throw new Error(
|
|
55
|
+
`google-slides: createPresentation failed (${response.status}): ${body}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return await response.json();
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
request,
|
|
62
|
+
getPresentation,
|
|
63
|
+
getPage,
|
|
64
|
+
batchUpdate,
|
|
65
|
+
createPresentation
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ../connectors/src/connector-onboarding.ts
|
|
70
|
+
var ConnectorOnboarding = class {
|
|
71
|
+
/** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
|
|
72
|
+
connectionSetupInstructions;
|
|
73
|
+
/** Phase 2: Data overview instructions */
|
|
74
|
+
dataOverviewInstructions;
|
|
75
|
+
constructor(config) {
|
|
76
|
+
this.connectionSetupInstructions = config.connectionSetupInstructions;
|
|
77
|
+
this.dataOverviewInstructions = config.dataOverviewInstructions;
|
|
78
|
+
}
|
|
79
|
+
getConnectionSetupPrompt(language) {
|
|
80
|
+
return this.connectionSetupInstructions?.[language] ?? null;
|
|
81
|
+
}
|
|
82
|
+
getDataOverviewInstructions(language) {
|
|
83
|
+
return this.dataOverviewInstructions[language];
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// ../connectors/src/connector-tool.ts
|
|
88
|
+
var ConnectorTool = class {
|
|
89
|
+
name;
|
|
90
|
+
description;
|
|
91
|
+
inputSchema;
|
|
92
|
+
outputSchema;
|
|
93
|
+
_execute;
|
|
94
|
+
constructor(config) {
|
|
95
|
+
this.name = config.name;
|
|
96
|
+
this.description = config.description;
|
|
97
|
+
this.inputSchema = config.inputSchema;
|
|
98
|
+
this.outputSchema = config.outputSchema;
|
|
99
|
+
this._execute = config.execute;
|
|
100
|
+
}
|
|
101
|
+
createTool(connections, config) {
|
|
102
|
+
return {
|
|
103
|
+
description: this.description,
|
|
104
|
+
inputSchema: this.inputSchema,
|
|
105
|
+
outputSchema: this.outputSchema,
|
|
106
|
+
execute: (input) => this._execute(input, connections, config)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// ../connectors/src/connector-plugin.ts
|
|
112
|
+
var ConnectorPlugin = class _ConnectorPlugin {
|
|
113
|
+
slug;
|
|
114
|
+
authType;
|
|
115
|
+
name;
|
|
116
|
+
description;
|
|
117
|
+
iconUrl;
|
|
118
|
+
parameters;
|
|
119
|
+
releaseFlag;
|
|
120
|
+
proxyPolicy;
|
|
121
|
+
experimentalAttributes;
|
|
122
|
+
onboarding;
|
|
123
|
+
systemPrompt;
|
|
124
|
+
tools;
|
|
125
|
+
query;
|
|
126
|
+
checkConnection;
|
|
127
|
+
constructor(config) {
|
|
128
|
+
this.slug = config.slug;
|
|
129
|
+
this.authType = config.authType;
|
|
130
|
+
this.name = config.name;
|
|
131
|
+
this.description = config.description;
|
|
132
|
+
this.iconUrl = config.iconUrl;
|
|
133
|
+
this.parameters = config.parameters;
|
|
134
|
+
this.releaseFlag = config.releaseFlag;
|
|
135
|
+
this.proxyPolicy = config.proxyPolicy;
|
|
136
|
+
this.experimentalAttributes = config.experimentalAttributes;
|
|
137
|
+
this.onboarding = config.onboarding;
|
|
138
|
+
this.systemPrompt = config.systemPrompt;
|
|
139
|
+
this.tools = config.tools;
|
|
140
|
+
this.query = config.query;
|
|
141
|
+
this.checkConnection = config.checkConnection;
|
|
142
|
+
}
|
|
143
|
+
get connectorKey() {
|
|
144
|
+
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create tools for connections that belong to this connector.
|
|
148
|
+
* Filters connections by connectorKey internally.
|
|
149
|
+
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
150
|
+
*/
|
|
151
|
+
createTools(connections, config, opts) {
|
|
152
|
+
const myConnections = connections.filter(
|
|
153
|
+
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
154
|
+
);
|
|
155
|
+
const result = {};
|
|
156
|
+
for (const t of Object.values(this.tools)) {
|
|
157
|
+
const tool = t.createTool(myConnections, config);
|
|
158
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
159
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
160
|
+
...tool,
|
|
161
|
+
toModelOutput: async (options) => {
|
|
162
|
+
if (!originalToModelOutput) {
|
|
163
|
+
return opts.truncateOutput(options.output);
|
|
164
|
+
}
|
|
165
|
+
const modelOutput = await originalToModelOutput(options);
|
|
166
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
167
|
+
return opts.truncateOutput(modelOutput.value);
|
|
168
|
+
}
|
|
169
|
+
return modelOutput;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
static deriveKey(slug, authType) {
|
|
176
|
+
if (authType) return `${slug}-${authType}`;
|
|
177
|
+
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
178
|
+
// user-password
|
|
179
|
+
"postgresql": "user-password",
|
|
180
|
+
"mysql": "user-password",
|
|
181
|
+
"clickhouse": "user-password",
|
|
182
|
+
"kintone": "user-password",
|
|
183
|
+
"squadbase-db": "user-password",
|
|
184
|
+
// service-account
|
|
185
|
+
"snowflake": "service-account",
|
|
186
|
+
"bigquery": "service-account",
|
|
187
|
+
"google-analytics": "service-account",
|
|
188
|
+
"google-calendar": "service-account",
|
|
189
|
+
"aws-athena": "service-account",
|
|
190
|
+
"redshift": "service-account",
|
|
191
|
+
// api-key
|
|
192
|
+
"databricks": "api-key",
|
|
193
|
+
"dbt": "api-key",
|
|
194
|
+
"airtable": "api-key",
|
|
195
|
+
"openai": "api-key",
|
|
196
|
+
"gemini": "api-key",
|
|
197
|
+
"anthropic": "api-key",
|
|
198
|
+
"wix-store": "api-key"
|
|
199
|
+
};
|
|
200
|
+
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|
|
201
|
+
if (fallbackAuthType) return `${slug}-${fallbackAuthType}`;
|
|
202
|
+
return slug;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// ../connectors/src/auth-types.ts
|
|
207
|
+
var AUTH_TYPES = {
|
|
208
|
+
OAUTH: "oauth",
|
|
209
|
+
API_KEY: "api-key",
|
|
210
|
+
JWT: "jwt",
|
|
211
|
+
SERVICE_ACCOUNT: "service-account",
|
|
212
|
+
PAT: "pat",
|
|
213
|
+
USER_PASSWORD: "user-password"
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// ../connectors/src/connectors/google-slides/setup.ts
|
|
217
|
+
var googleSlidesOnboarding = new ConnectorOnboarding({
|
|
218
|
+
dataOverviewInstructions: {
|
|
219
|
+
en: `1. Create a new presentation with google-slides-oauth_request (POST with body { title: "..." }) or use an existing presentation ID.
|
|
220
|
+
2. Call google-slides-oauth_request with GET /{presentationId} to fetch presentation metadata (title, slide count, layout info).`,
|
|
221
|
+
ja: `1. google-slides-oauth_request \u3092 POST\uFF08Body: { title: "..." }\uFF09\u3067\u547C\u3073\u51FA\u3057\u3066\u65B0\u3057\u3044\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3092\u4F5C\u6210\u3059\u308B\u304B\u3001\u65E2\u5B58\u306E\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3ID\u3092\u5229\u7528\u3057\u307E\u3059\u3002
|
|
222
|
+
2. google-slides-oauth_request \u3067 GET /{presentationId} \u3092\u547C\u3073\u51FA\u3057\u3001\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\uFF08\u30BF\u30A4\u30C8\u30EB\u3001\u30B9\u30E9\u30A4\u30C9\u6570\u3001\u30EC\u30A4\u30A2\u30A6\u30C8\u60C5\u5831\uFF09\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002`
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// ../connectors/src/connectors/google-slides/parameters.ts
|
|
227
|
+
var parameters = {};
|
|
228
|
+
|
|
229
|
+
// ../connectors/src/connectors/google-slides/tools/request.ts
|
|
230
|
+
import { z } from "zod";
|
|
231
|
+
var SLIDES_BASE_URL2 = "https://slides.googleapis.com/v1/presentations";
|
|
232
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
233
|
+
var cachedToken = null;
|
|
234
|
+
async function getProxyToken(config) {
|
|
235
|
+
if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
|
|
236
|
+
return cachedToken.token;
|
|
237
|
+
}
|
|
238
|
+
const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
|
|
239
|
+
const res = await fetch(url, {
|
|
240
|
+
method: "POST",
|
|
241
|
+
headers: {
|
|
242
|
+
"Content-Type": "application/json",
|
|
243
|
+
"x-api-key": config.appApiKey,
|
|
244
|
+
"project-id": config.projectId
|
|
245
|
+
},
|
|
246
|
+
body: JSON.stringify({
|
|
247
|
+
sandboxId: config.sandboxId,
|
|
248
|
+
issuedBy: "coding-agent"
|
|
249
|
+
})
|
|
250
|
+
});
|
|
251
|
+
if (!res.ok) {
|
|
252
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Failed to get proxy token: HTTP ${res.status} ${errorText}`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const data = await res.json();
|
|
258
|
+
cachedToken = {
|
|
259
|
+
token: data.token,
|
|
260
|
+
expiresAt: new Date(data.expiresAt).getTime()
|
|
261
|
+
};
|
|
262
|
+
return data.token;
|
|
263
|
+
}
|
|
264
|
+
var inputSchema = z.object({
|
|
265
|
+
toolUseIntent: z.string().optional().describe(
|
|
266
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
267
|
+
),
|
|
268
|
+
connectionId: z.string().describe("ID of the Google Slides connection to use"),
|
|
269
|
+
method: z.enum(["GET", "POST"]).describe("HTTP method"),
|
|
270
|
+
path: z.string().describe(
|
|
271
|
+
"API path appended to https://slides.googleapis.com/v1/presentations (e.g., '', '/{presentationId}', '/{presentationId}/pages/{pageId}')."
|
|
272
|
+
),
|
|
273
|
+
body: z.record(z.string(), z.unknown()).optional().describe("JSON request body for POST requests"),
|
|
274
|
+
queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL")
|
|
275
|
+
});
|
|
276
|
+
var outputSchema = z.discriminatedUnion("success", [
|
|
277
|
+
z.object({
|
|
278
|
+
success: z.literal(true),
|
|
279
|
+
status: z.number(),
|
|
280
|
+
data: z.record(z.string(), z.unknown())
|
|
281
|
+
}),
|
|
282
|
+
z.object({
|
|
283
|
+
success: z.literal(false),
|
|
284
|
+
error: z.string()
|
|
285
|
+
})
|
|
286
|
+
]);
|
|
287
|
+
var requestTool = new ConnectorTool({
|
|
288
|
+
name: "request",
|
|
289
|
+
description: `Send authenticated requests to the Google Slides API v1.
|
|
290
|
+
Supports GET (read) and POST (create/update) methods.
|
|
291
|
+
Authentication is handled automatically via OAuth proxy.`,
|
|
292
|
+
inputSchema,
|
|
293
|
+
outputSchema,
|
|
294
|
+
async execute({ connectionId, method, path: path2, body, queryParams }, connections, config) {
|
|
295
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
296
|
+
if (!connection2) {
|
|
297
|
+
return {
|
|
298
|
+
success: false,
|
|
299
|
+
error: `Connection ${connectionId} not found`
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
console.log(
|
|
303
|
+
`[connector-request] google-slides/${connection2.name}: ${method} ${path2}`
|
|
304
|
+
);
|
|
305
|
+
try {
|
|
306
|
+
let url = `${SLIDES_BASE_URL2}${path2 === "" || path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
307
|
+
if (queryParams) {
|
|
308
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
309
|
+
url += `?${searchParams.toString()}`;
|
|
310
|
+
}
|
|
311
|
+
const token = await getProxyToken(config.oauthProxy);
|
|
312
|
+
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
313
|
+
const controller = new AbortController();
|
|
314
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
315
|
+
try {
|
|
316
|
+
const response = await fetch(proxyUrl, {
|
|
317
|
+
method: "POST",
|
|
318
|
+
headers: {
|
|
319
|
+
"Content-Type": "application/json",
|
|
320
|
+
Authorization: `Bearer ${token}`
|
|
321
|
+
},
|
|
322
|
+
body: JSON.stringify({
|
|
323
|
+
url,
|
|
324
|
+
method,
|
|
325
|
+
...body != null ? { body: JSON.stringify(body) } : {}
|
|
326
|
+
}),
|
|
327
|
+
signal: controller.signal
|
|
328
|
+
});
|
|
329
|
+
const data = await response.json();
|
|
330
|
+
if (!response.ok) {
|
|
331
|
+
const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`;
|
|
332
|
+
return { success: false, error: errorMessage };
|
|
333
|
+
}
|
|
334
|
+
return { success: true, status: response.status, data };
|
|
335
|
+
} finally {
|
|
336
|
+
clearTimeout(timeout);
|
|
337
|
+
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
340
|
+
return { success: false, error: msg };
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// ../connectors/src/connectors/google-slides/index.ts
|
|
346
|
+
var tools = { request: requestTool };
|
|
347
|
+
var googleSlidesConnector = new ConnectorPlugin({
|
|
348
|
+
slug: "google-slides",
|
|
349
|
+
authType: AUTH_TYPES.OAUTH,
|
|
350
|
+
name: "Google Slides",
|
|
351
|
+
description: "Connect to Google Slides for presentation data access and creation using OAuth.",
|
|
352
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4oyF4yTRpemMA43X49masx/e1582d25e3b4c9a63ba83df2147c1968/google_slide.png",
|
|
353
|
+
parameters,
|
|
354
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
355
|
+
onboarding: googleSlidesOnboarding,
|
|
356
|
+
proxyPolicy: {
|
|
357
|
+
allowlist: [
|
|
358
|
+
{
|
|
359
|
+
host: "slides.googleapis.com",
|
|
360
|
+
methods: ["GET", "POST"]
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
},
|
|
364
|
+
systemPrompt: {
|
|
365
|
+
en: `### Tools (setup-time only)
|
|
366
|
+
|
|
367
|
+
- \`google-slides-oauth_request\`: Call the Google Slides API directly during setup / data overview. Supports read and write operations. Use it to get presentation metadata, slide content, create new presentations, and modify slides. Authentication is configured automatically via OAuth.
|
|
368
|
+
|
|
369
|
+
> **Important**: The \`google-slides-oauth_request\` tool is only available at setup time. Inside server-logic handlers, use the SDK (\`connection(id).createPresentation\`, etc.) \u2014 the SDK's fetch is already wired through the OAuth proxy. **Do NOT** hand-roll HTTP calls to \`_sqcore/connections/*/request\` from a handler.
|
|
370
|
+
|
|
371
|
+
### Google Slides API Reference
|
|
372
|
+
|
|
373
|
+
#### Read Endpoints
|
|
374
|
+
- GET \`/{presentationId}\` \u2014 Get presentation metadata (title, slides, layouts, masters)
|
|
375
|
+
- GET \`/{presentationId}/pages/{pageObjectId}\` \u2014 Get a specific slide page with all its elements (shapes, text, images, tables)
|
|
376
|
+
|
|
377
|
+
#### Write Endpoints
|
|
378
|
+
- POST \`\` (empty path, with body) \u2014 Create a new presentation. Body: \`{ "title": "My Presentation" }\`
|
|
379
|
+
- POST \`/{presentationId}:batchUpdate\` \u2014 Apply multiple updates to a presentation. Body: \`{ "requests": [...] }\`
|
|
380
|
+
|
|
381
|
+
#### Common batchUpdate Request Types
|
|
382
|
+
- \`createSlide\` \u2014 Add a new slide: \`{ "createSlide": { "insertionIndex": 1, "slideLayoutReference": { "predefinedLayout": "BLANK" } } }\`
|
|
383
|
+
- \`insertText\` \u2014 Insert text into a shape: \`{ "insertText": { "objectId": "shapeId", "text": "Hello" } }\`
|
|
384
|
+
- \`createShape\` \u2014 Add a shape to a slide: \`{ "createShape": { "shapeType": "TEXT_BOX", "elementProperties": { "pageObjectId": "slideId", "size": {...}, "transform": {...} } } }\`
|
|
385
|
+
- \`createImage\` \u2014 Add an image: \`{ "createImage": { "url": "https://...", "elementProperties": { "pageObjectId": "slideId" } } }\`
|
|
386
|
+
- \`deleteObject\` \u2014 Delete a page element or slide: \`{ "deleteObject": { "objectId": "objectId" } }\`
|
|
387
|
+
- \`replaceAllText\` \u2014 Find & replace text: \`{ "replaceAllText": { "containsText": { "text": "old" }, "replaceText": "new" } }\`
|
|
388
|
+
- \`updateTextStyle\` \u2014 Style text (bold, color, font): \`{ "updateTextStyle": { "objectId": "shapeId", "style": { "bold": true }, "textRange": { "type": "ALL" }, "fields": "bold" } }\`
|
|
389
|
+
- \`updateShapeProperties\` \u2014 Update shape fill, outline, etc.
|
|
390
|
+
- \`createTable\` \u2014 Create a table on a slide
|
|
391
|
+
- \`insertTableRows\` / \`insertTableColumns\` \u2014 Add rows/columns to a table
|
|
392
|
+
- \`deleteTableRow\` / \`deleteTableColumn\` \u2014 Remove rows/columns
|
|
393
|
+
|
|
394
|
+
#### Predefined Slide Layouts
|
|
395
|
+
\`BLANK\`, \`CAPTION_ONLY\`, \`TITLE\`, \`TITLE_AND_BODY\`, \`TITLE_AND_TWO_COLUMNS\`, \`TITLE_ONLY\`, \`SECTION_HEADER\`, \`SECTION_TITLE_AND_DESCRIPTION\`, \`ONE_COLUMN_TEXT\`, \`MAIN_POINT\`, \`BIG_NUMBER\`
|
|
396
|
+
|
|
397
|
+
### Tips
|
|
398
|
+
- To explore a presentation, first GET the presentation metadata to see available slide object IDs
|
|
399
|
+
- When inserting text or shapes, you need the \`pageObjectId\` of the target slide (from the metadata)
|
|
400
|
+
- batchUpdate requests are applied in order \u2014 use this for complex multi-step modifications
|
|
401
|
+
- Shape sizes and positions use EMU (English Metric Units): 1 inch = 914400 EMU, 1 pt = 12700 EMU
|
|
402
|
+
- Sharing (permissions) cannot be done via this connector; only the OAuth user has access to the created presentations
|
|
403
|
+
|
|
404
|
+
### Business Logic
|
|
405
|
+
|
|
406
|
+
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 and do NOT import from \`INTERNAL_SQUADBASE_*\` env vars \u2014 the SDK takes care of OAuth.
|
|
407
|
+
|
|
408
|
+
SDK surface (client created via \`connection(connectionId)\`):
|
|
409
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch (returns a standard \`Response\`). \`path\` is appended to \`https://slides.googleapis.com/v1/presentations\`.
|
|
410
|
+
- \`client.getPresentation(presentationId)\` \u2014 fetch presentation metadata (title, slides, layouts, masters).
|
|
411
|
+
- \`client.getPage(presentationId, pageObjectId)\` \u2014 fetch one slide page with its elements.
|
|
412
|
+
- \`client.createPresentation(title)\` \u2014 create a new presentation.
|
|
413
|
+
- \`client.batchUpdate(presentationId, requests)\` \u2014 apply one or more requests (createSlide / insertText / createShape / etc.).
|
|
414
|
+
|
|
415
|
+
#### Example
|
|
416
|
+
|
|
417
|
+
\`\`\`ts
|
|
418
|
+
import { connection } from "@squadbase/vite-server/connectors/google-slides";
|
|
419
|
+
|
|
420
|
+
const slides = connection("<connectionId>");
|
|
421
|
+
|
|
422
|
+
// Create a new presentation
|
|
423
|
+
const newPres = await slides.createPresentation("Quarterly Report");
|
|
424
|
+
const presentationId = newPres.presentationId;
|
|
425
|
+
|
|
426
|
+
// Get presentation metadata
|
|
427
|
+
const presentation = await slides.getPresentation(presentationId);
|
|
428
|
+
console.log(presentation.title, presentation.slides.length);
|
|
429
|
+
|
|
430
|
+
// Get a specific slide's content
|
|
431
|
+
const page = await slides.getPage(presentationId, presentation.slides[0].objectId);
|
|
432
|
+
console.log(page.pageElements);
|
|
433
|
+
|
|
434
|
+
// Add a slide and insert text
|
|
435
|
+
await slides.batchUpdate(presentationId, [
|
|
436
|
+
{ createSlide: { insertionIndex: 1, slideLayoutReference: { predefinedLayout: "TITLE_AND_BODY" } } },
|
|
437
|
+
{ insertText: { objectId: "someShapeId", text: "Hello, World!" } },
|
|
438
|
+
]);
|
|
439
|
+
\`\`\`
|
|
440
|
+
|
|
441
|
+
#### Troubleshooting
|
|
442
|
+
|
|
443
|
+
If a handler test fails with \`Connection proxy is not configured\`, retry \u2014 this usually means the sandbox is still initializing. Do NOT abandon the SDK and construct OAuth proxy URLs manually.`,
|
|
444
|
+
ja: `### \u30C4\u30FC\u30EB\uFF08\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\uFF09
|
|
445
|
+
|
|
446
|
+
- \`google-slides-oauth_request\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3084\u30C7\u30FC\u30BF\u6982\u8981\u628A\u63E1\u6642\u306B Google Slides API \u3092\u76F4\u63A5\u53E9\u304F\u30C4\u30FC\u30EB\u3067\u3059\u3002\u8AAD\u307F\u53D6\u308A\u3068\u66F8\u304D\u8FBC\u307F\u306E\u4E21\u65B9\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u30FB\u30B9\u30E9\u30A4\u30C9\u5185\u5BB9\u306E\u53D6\u5F97\u3001\u65B0\u3057\u3044\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u4F5C\u6210\u3001\u30B9\u30E9\u30A4\u30C9\u306E\u5909\u66F4\u306A\u3069\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth \u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
|
|
447
|
+
|
|
448
|
+
> **\u91CD\u8981**: \`google-slides-oauth_request\` \u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\u5229\u7528\u53EF\u80FD\u3067\u3059\u3002\u30B5\u30FC\u30D0\u30FC\u30ED\u30B8\u30C3\u30AF\u306E\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u5FC5\u305A SDK\uFF08\`connection(id).createPresentation\` \u306A\u3069\uFF09\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002SDK \u306E fetch \u306F OAuth \u30D7\u30ED\u30AD\u30B7\u7D4C\u7531\u3067\u65E2\u306B\u914D\u7DDA\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u304B\u3089 \`_sqcore/connections/*/request\` \u3092\u624B\u66F8\u304D\u3067\u547C\u3073\u51FA\u3055\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
449
|
+
|
|
450
|
+
### Google Slides API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
451
|
+
|
|
452
|
+
#### \u8AAD\u307F\u53D6\u308A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
453
|
+
- GET \`/{presentationId}\` \u2014 \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\uFF08\u30BF\u30A4\u30C8\u30EB\u3001\u30B9\u30E9\u30A4\u30C9\u3001\u30EC\u30A4\u30A2\u30A6\u30C8\u3001\u30DE\u30B9\u30BF\u30FC\uFF09
|
|
454
|
+
- GET \`/{presentationId}/pages/{pageObjectId}\` \u2014 \u7279\u5B9A\u306E\u30B9\u30E9\u30A4\u30C9\u30DA\u30FC\u30B8\u3068\u305D\u306E\u5168\u8981\u7D20\uFF08\u56F3\u5F62\u3001\u30C6\u30AD\u30B9\u30C8\u3001\u753B\u50CF\u3001\u30C6\u30FC\u30D6\u30EB\uFF09\u3092\u53D6\u5F97
|
|
455
|
+
|
|
456
|
+
#### \u66F8\u304D\u8FBC\u307F\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
457
|
+
- POST \`\`\uFF08\u7A7A\u30D1\u30B9\u3001\u30DC\u30C7\u30A3\u4ED8\u304D\uFF09\u2014 \u65B0\u3057\u3044\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3092\u4F5C\u6210\u3002Body: \`{ "title": "\u30DE\u30A4\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3" }\`
|
|
458
|
+
- POST \`/{presentationId}:batchUpdate\` \u2014 \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306B\u8907\u6570\u306E\u66F4\u65B0\u3092\u9069\u7528\u3002Body: \`{ "requests": [...] }\`
|
|
459
|
+
|
|
460
|
+
#### \u4E3B\u306A batchUpdate \u30EA\u30AF\u30A8\u30B9\u30C8\u30BF\u30A4\u30D7
|
|
461
|
+
- \`createSlide\` \u2014 \u30B9\u30E9\u30A4\u30C9\u3092\u8FFD\u52A0: \`{ "createSlide": { "insertionIndex": 1, "slideLayoutReference": { "predefinedLayout": "BLANK" } } }\`
|
|
462
|
+
- \`insertText\` \u2014 \u56F3\u5F62\u306B\u30C6\u30AD\u30B9\u30C8\u3092\u633F\u5165: \`{ "insertText": { "objectId": "shapeId", "text": "Hello" } }\`
|
|
463
|
+
- \`createShape\` \u2014 \u30B9\u30E9\u30A4\u30C9\u306B\u56F3\u5F62\u3092\u8FFD\u52A0: \`{ "createShape": { "shapeType": "TEXT_BOX", "elementProperties": { "pageObjectId": "slideId", "size": {...}, "transform": {...} } } }\`
|
|
464
|
+
- \`createImage\` \u2014 \u753B\u50CF\u3092\u8FFD\u52A0: \`{ "createImage": { "url": "https://...", "elementProperties": { "pageObjectId": "slideId" } } }\`
|
|
465
|
+
- \`deleteObject\` \u2014 \u30DA\u30FC\u30B8\u8981\u7D20\u307E\u305F\u306F\u30B9\u30E9\u30A4\u30C9\u3092\u524A\u9664: \`{ "deleteObject": { "objectId": "objectId" } }\`
|
|
466
|
+
- \`replaceAllText\` \u2014 \u30C6\u30AD\u30B9\u30C8\u306E\u691C\u7D22\u3068\u7F6E\u63DB: \`{ "replaceAllText": { "containsText": { "text": "\u53E4\u3044" }, "replaceText": "\u65B0\u3057\u3044" } }\`
|
|
467
|
+
- \`updateTextStyle\` \u2014 \u30C6\u30AD\u30B9\u30C8\u306E\u30B9\u30BF\u30A4\u30EB\u8A2D\u5B9A\uFF08\u592A\u5B57\u3001\u8272\u3001\u30D5\u30A9\u30F3\u30C8\uFF09: \`{ "updateTextStyle": { "objectId": "shapeId", "style": { "bold": true }, "textRange": { "type": "ALL" }, "fields": "bold" } }\`
|
|
468
|
+
- \`updateShapeProperties\` \u2014 \u56F3\u5F62\u306E\u5857\u308A\u3064\u3076\u3057\u3001\u30A2\u30A6\u30C8\u30E9\u30A4\u30F3\u306A\u3069\u3092\u66F4\u65B0
|
|
469
|
+
- \`createTable\` \u2014 \u30B9\u30E9\u30A4\u30C9\u306B\u30C6\u30FC\u30D6\u30EB\u3092\u4F5C\u6210
|
|
470
|
+
- \`insertTableRows\` / \`insertTableColumns\` \u2014 \u30C6\u30FC\u30D6\u30EB\u306B\u884C/\u5217\u3092\u8FFD\u52A0
|
|
471
|
+
- \`deleteTableRow\` / \`deleteTableColumn\` \u2014 \u884C/\u5217\u3092\u524A\u9664
|
|
472
|
+
|
|
473
|
+
#### \u5B9A\u7FA9\u6E08\u307F\u30B9\u30E9\u30A4\u30C9\u30EC\u30A4\u30A2\u30A6\u30C8
|
|
474
|
+
\`BLANK\`, \`CAPTION_ONLY\`, \`TITLE\`, \`TITLE_AND_BODY\`, \`TITLE_AND_TWO_COLUMNS\`, \`TITLE_ONLY\`, \`SECTION_HEADER\`, \`SECTION_TITLE_AND_DESCRIPTION\`, \`ONE_COLUMN_TEXT\`, \`MAIN_POINT\`, \`BIG_NUMBER\`
|
|
475
|
+
|
|
476
|
+
### \u30D2\u30F3\u30C8
|
|
477
|
+
- \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3092\u63A2\u7D22\u3059\u308B\u306B\u306F\u3001\u307E\u305AGET\u3067\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u3066\u5229\u7528\u53EF\u80FD\u306A\u30B9\u30E9\u30A4\u30C9\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8ID\u3092\u78BA\u8A8D\u3057\u307E\u3059
|
|
478
|
+
- \u30C6\u30AD\u30B9\u30C8\u3084\u56F3\u5F62\u3092\u633F\u5165\u3059\u308B\u969B\u306F\u3001\u5BFE\u8C61\u30B9\u30E9\u30A4\u30C9\u306E \`pageObjectId\` \u304C\u5FC5\u8981\u3067\u3059\uFF08\u30E1\u30BF\u30C7\u30FC\u30BF\u304B\u3089\u53D6\u5F97\uFF09
|
|
479
|
+
- batchUpdate\u30EA\u30AF\u30A8\u30B9\u30C8\u306F\u9806\u756A\u306B\u9069\u7528\u3055\u308C\u307E\u3059 \u2014 \u8907\u96D1\u306A\u8907\u6570\u30B9\u30C6\u30C3\u30D7\u306E\u5909\u66F4\u306B\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044
|
|
480
|
+
- \u56F3\u5F62\u306E\u30B5\u30A4\u30BA\u3068\u4F4D\u7F6E\u306FEMU\uFF08English Metric Units\uFF09\u3092\u4F7F\u7528: 1\u30A4\u30F3\u30C1 = 914400 EMU\u30011pt = 12700 EMU
|
|
481
|
+
- \u5171\u6709\uFF08permissions\uFF09\u306F\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u7D4C\u7531\u3067\u306F\u884C\u3048\u307E\u305B\u3093\u3002\u4F5C\u6210\u3057\u305F\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3078\u306F\u63A5\u7D9A\u3057\u305FOAuth\u30E6\u30FC\u30B6\u30FC\u306E\u307F\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u3067\u3059
|
|
482
|
+
|
|
483
|
+
### Business Logic
|
|
484
|
+
|
|
485
|
+
\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\u30BF SDK \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\`INTERNAL_SQUADBASE_*\` \u306E\u74B0\u5883\u5909\u6570\u3092\u4F7F\u3063\u3066\u624B\u52D5\u3067 OAuth \u30D7\u30ED\u30AD\u30B7\u3092\u53E9\u304F\u3053\u3068\u3082\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 SDK \u304C OAuth \u3092\u51E6\u7406\u3057\u307E\u3059\u3002
|
|
486
|
+
|
|
487
|
+
SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
|
|
488
|
+
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\u6A19\u6E96 \`Response\` \u3092\u8FD4\u3059\uFF09\u3002\`path\` \u306F \`https://slides.googleapis.com/v1/presentations\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\u3002
|
|
489
|
+
- \`client.getPresentation(presentationId)\` \u2014 \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3002
|
|
490
|
+
- \`client.getPage(presentationId, pageObjectId)\` \u2014 \u7279\u5B9A\u306E\u30B9\u30E9\u30A4\u30C9\u30DA\u30FC\u30B8\u3068\u305D\u306E\u8981\u7D20\u3092\u53D6\u5F97\u3002
|
|
491
|
+
- \`client.createPresentation(title)\` \u2014 \u65B0\u3057\u3044\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3092\u4F5C\u6210\u3002
|
|
492
|
+
- \`client.batchUpdate(presentationId, requests)\` \u2014 createSlide / insertText / createShape \u306A\u3069\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u307E\u3068\u3081\u3066\u9069\u7528\u3002
|
|
493
|
+
|
|
494
|
+
#### Example
|
|
495
|
+
|
|
496
|
+
\`\`\`ts
|
|
497
|
+
import { connection } from "@squadbase/vite-server/connectors/google-slides";
|
|
498
|
+
|
|
499
|
+
const slides = connection("<connectionId>");
|
|
500
|
+
|
|
501
|
+
// \u65B0\u3057\u3044\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3092\u4F5C\u6210
|
|
502
|
+
const newPres = await slides.createPresentation("\u56DB\u534A\u671F\u30EC\u30DD\u30FC\u30C8");
|
|
503
|
+
const presentationId = newPres.presentationId;
|
|
504
|
+
|
|
505
|
+
// \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
|
|
506
|
+
const presentation = await slides.getPresentation(presentationId);
|
|
507
|
+
console.log(presentation.title, presentation.slides.length);
|
|
508
|
+
|
|
509
|
+
// \u7279\u5B9A\u306E\u30B9\u30E9\u30A4\u30C9\u306E\u5185\u5BB9\u3092\u53D6\u5F97
|
|
510
|
+
const page = await slides.getPage(presentationId, presentation.slides[0].objectId);
|
|
511
|
+
console.log(page.pageElements);
|
|
512
|
+
|
|
513
|
+
// \u30B9\u30E9\u30A4\u30C9\u3092\u8FFD\u52A0\u3057\u3066\u30C6\u30AD\u30B9\u30C8\u3092\u633F\u5165
|
|
514
|
+
await slides.batchUpdate(presentationId, [
|
|
515
|
+
{ createSlide: { insertionIndex: 1, slideLayoutReference: { predefinedLayout: "TITLE_AND_BODY" } } },
|
|
516
|
+
{ insertText: { objectId: "someShapeId", text: "Hello, World!" } },
|
|
517
|
+
]);
|
|
518
|
+
\`\`\`
|
|
519
|
+
|
|
520
|
+
#### \u30C8\u30E9\u30D6\u30EB\u30B7\u30E5\u30FC\u30C6\u30A3\u30F3\u30B0
|
|
521
|
+
|
|
522
|
+
\u30CF\u30F3\u30C9\u30E9\u306E\u30C6\u30B9\u30C8\u304C \`Connection proxy is not configured\` \u3067\u5931\u6557\u3059\u308B\u5834\u5408\u306F\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u901A\u5E38\u306F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u521D\u671F\u5316\u4E2D\u306B\u8D77\u304D\u307E\u3059\u3002SDK \u3092\u8AE6\u3081\u3066 OAuth \u30D7\u30ED\u30AD\u30B7\u306E URL \u3092\u81EA\u5206\u3067\u7D44\u307F\u7ACB\u3066\u308B\u3053\u3068\u306F **\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044**\u3002`
|
|
523
|
+
},
|
|
524
|
+
tools
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
// src/connectors/create-connector-sdk.ts
|
|
528
|
+
import { readFileSync } from "fs";
|
|
529
|
+
import path from "path";
|
|
530
|
+
|
|
531
|
+
// src/connector-client/env.ts
|
|
532
|
+
function resolveEnvVar(entry, key, connectionId) {
|
|
533
|
+
const envVarName = entry.envVars[key];
|
|
534
|
+
if (!envVarName) {
|
|
535
|
+
throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
|
|
536
|
+
}
|
|
537
|
+
const value = process.env[envVarName];
|
|
538
|
+
if (!value) {
|
|
539
|
+
throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
|
|
540
|
+
}
|
|
541
|
+
return value;
|
|
542
|
+
}
|
|
543
|
+
function resolveEnvVarOptional(entry, key) {
|
|
544
|
+
const envVarName = entry.envVars[key];
|
|
545
|
+
if (!envVarName) return void 0;
|
|
546
|
+
return process.env[envVarName] || void 0;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/connector-client/proxy-fetch.ts
|
|
550
|
+
import { getContext } from "hono/context-storage";
|
|
551
|
+
import { getCookie } from "hono/cookie";
|
|
552
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
553
|
+
function createSandboxProxyFetch(connectionId) {
|
|
554
|
+
return async (input, init) => {
|
|
555
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
556
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
557
|
+
if (!token || !sandboxId) {
|
|
558
|
+
throw new Error(
|
|
559
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
563
|
+
const originalMethod = init?.method ?? "GET";
|
|
564
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
565
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
566
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
567
|
+
return fetch(proxyUrl, {
|
|
568
|
+
method: "POST",
|
|
569
|
+
headers: {
|
|
570
|
+
"Content-Type": "application/json",
|
|
571
|
+
Authorization: `Bearer ${token}`
|
|
572
|
+
},
|
|
573
|
+
body: JSON.stringify({
|
|
574
|
+
url: originalUrl,
|
|
575
|
+
method: originalMethod,
|
|
576
|
+
body: originalBody
|
|
577
|
+
})
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
582
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
583
|
+
if (!projectId) {
|
|
584
|
+
throw new Error(
|
|
585
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
589
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
590
|
+
return async (input, init) => {
|
|
591
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
592
|
+
const originalMethod = init?.method ?? "GET";
|
|
593
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
594
|
+
const c = getContext();
|
|
595
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
596
|
+
if (!appSession) {
|
|
597
|
+
throw new Error(
|
|
598
|
+
"No authentication method available for connection proxy."
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
return fetch(proxyUrl, {
|
|
602
|
+
method: "POST",
|
|
603
|
+
headers: {
|
|
604
|
+
"Content-Type": "application/json",
|
|
605
|
+
Authorization: `Bearer ${appSession}`
|
|
606
|
+
},
|
|
607
|
+
body: JSON.stringify({
|
|
608
|
+
url: originalUrl,
|
|
609
|
+
method: originalMethod,
|
|
610
|
+
body: originalBody
|
|
611
|
+
})
|
|
612
|
+
});
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function createProxyFetch(connectionId) {
|
|
616
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
617
|
+
return createSandboxProxyFetch(connectionId);
|
|
618
|
+
}
|
|
619
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// src/connectors/create-connector-sdk.ts
|
|
623
|
+
function loadConnectionsSync() {
|
|
624
|
+
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
625
|
+
try {
|
|
626
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
627
|
+
return JSON.parse(raw);
|
|
628
|
+
} catch {
|
|
629
|
+
return {};
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
function createConnectorSdk(plugin, createClient2) {
|
|
633
|
+
return (connectionId) => {
|
|
634
|
+
const connections = loadConnectionsSync();
|
|
635
|
+
const entry = connections[connectionId];
|
|
636
|
+
if (!entry) {
|
|
637
|
+
throw new Error(
|
|
638
|
+
`Connection "${connectionId}" not found in .squadbase/connections.json`
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
if (entry.connector.slug !== plugin.slug) {
|
|
642
|
+
throw new Error(
|
|
643
|
+
`Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
const params = {};
|
|
647
|
+
for (const param of Object.values(plugin.parameters)) {
|
|
648
|
+
if (param.required) {
|
|
649
|
+
params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
|
|
650
|
+
} else {
|
|
651
|
+
const val = resolveEnvVarOptional(entry, param.slug);
|
|
652
|
+
if (val !== void 0) params[param.slug] = val;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// src/connectors/entries/google-slides.ts
|
|
660
|
+
var connection = createConnectorSdk(googleSlidesConnector, createClient);
|
|
661
|
+
export {
|
|
662
|
+
connection
|
|
663
|
+
};
|