@squadbase/vite-server 0.1.3-dev.15 → 0.1.3-dev.16
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 +2105 -2700
- package/dist/connectors/airtable-oauth.js +16 -5
- package/dist/connectors/airtable.js +16 -5
- package/dist/connectors/amplitude.js +16 -5
- package/dist/connectors/anthropic.js +16 -5
- package/dist/connectors/asana.js +16 -5
- package/dist/connectors/attio.js +16 -5
- package/dist/connectors/backlog-api-key.js +16 -5
- package/dist/connectors/customerio.js +16 -5
- package/dist/connectors/dbt.js +16 -5
- package/dist/connectors/gamma.js +16 -5
- package/dist/connectors/gemini.js +16 -5
- package/dist/connectors/gmail-oauth.js +16 -5
- package/dist/connectors/gmail.js +68 -34
- package/dist/connectors/google-ads.js +16 -5
- package/dist/connectors/google-analytics-oauth.js +16 -5
- package/dist/connectors/google-analytics.js +16 -5
- package/dist/connectors/google-calendar-oauth.js +16 -5
- package/dist/connectors/google-calendar.js +71 -48
- package/dist/connectors/{google-drive-oauth.d.ts → google-docs.d.ts} +1 -1
- package/dist/connectors/google-docs.js +585 -0
- package/dist/connectors/google-drive.d.ts +1 -1
- package/dist/connectors/google-drive.js +391 -327
- package/dist/connectors/google-sheets.d.ts +1 -1
- package/dist/connectors/google-sheets.js +210 -280
- package/dist/connectors/google-slides.d.ts +1 -1
- package/dist/connectors/google-slides.js +198 -335
- package/dist/connectors/grafana.js +16 -5
- package/dist/connectors/hubspot-oauth.js +16 -5
- package/dist/connectors/hubspot.js +16 -5
- package/dist/connectors/intercom-oauth.js +16 -5
- package/dist/connectors/intercom.js +16 -5
- package/dist/connectors/jira-api-key.js +16 -5
- package/dist/connectors/kintone-api-token.js +133 -59
- package/dist/connectors/kintone.js +16 -5
- package/dist/connectors/linkedin-ads.js +16 -5
- package/dist/connectors/mailchimp-oauth.js +16 -5
- package/dist/connectors/mailchimp.js +16 -5
- package/dist/connectors/mixpanel.js +16 -5
- package/dist/connectors/notion-oauth.js +16 -5
- package/dist/connectors/notion.js +16 -5
- package/dist/connectors/openai.js +16 -5
- package/dist/connectors/sentry.js +16 -5
- package/dist/connectors/shopify-oauth.js +16 -5
- package/dist/connectors/shopify.js +16 -5
- package/dist/connectors/stripe-api-key.js +16 -5
- package/dist/connectors/stripe-oauth.js +16 -5
- package/dist/connectors/wix-store.js +16 -5
- package/dist/connectors/zendesk-oauth.js +16 -5
- package/dist/connectors/zendesk.js +16 -5
- package/dist/index.js +2100 -2695
- package/dist/main.js +2100 -2695
- package/dist/vite-plugin.js +2100 -2695
- package/package.json +7 -15
- package/dist/connectors/google-drive-oauth.js +0 -879
- package/dist/connectors/google-sheets-oauth.d.ts +0 -5
- package/dist/connectors/google-sheets-oauth.js +0 -821
- package/dist/connectors/google-slides-oauth.d.ts +0 -5
- package/dist/connectors/google-slides-oauth.js +0 -742
|
@@ -1,742 +0,0 @@
|
|
|
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/google-slides-oauth/utils.ts
|
|
46
|
-
var PRESENTATION_URL_PATTERN = /docs\.google\.com\/presentation\/d\/([a-zA-Z0-9_-]+)/;
|
|
47
|
-
function extractPresentationId(urlOrId) {
|
|
48
|
-
const trimmed = urlOrId.trim();
|
|
49
|
-
const match = trimmed.match(PRESENTATION_URL_PATTERN);
|
|
50
|
-
if (match) {
|
|
51
|
-
return match[1];
|
|
52
|
-
}
|
|
53
|
-
return trimmed;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ../connectors/src/connectors/google-slides-oauth/parameters.ts
|
|
57
|
-
var parameters = {
|
|
58
|
-
presentationUrl: new ParameterDefinition({
|
|
59
|
-
slug: "presentation-url",
|
|
60
|
-
name: "Google Slides Presentation URL",
|
|
61
|
-
description: "The URL of the Google Slides presentation (e.g., https://docs.google.com/presentation/d/xxxxx/edit). The presentation ID is automatically extracted from the URL.",
|
|
62
|
-
envVarBaseKey: "GOOGLE_SLIDES_OAUTH_PRESENTATION_URL",
|
|
63
|
-
type: "text",
|
|
64
|
-
secret: false,
|
|
65
|
-
required: false
|
|
66
|
-
})
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// ../connectors/src/connectors/google-slides-oauth/sdk/index.ts
|
|
70
|
-
var SLIDES_BASE_URL = "https://slides.googleapis.com/v1/presentations";
|
|
71
|
-
function createClient(params, fetchFn = fetch) {
|
|
72
|
-
const presentationUrl = params[parameters.presentationUrl.slug];
|
|
73
|
-
const defaultPresentationId = presentationUrl ? extractPresentationId(presentationUrl) : void 0;
|
|
74
|
-
function resolvePresentationId(override) {
|
|
75
|
-
const id = override ?? defaultPresentationId;
|
|
76
|
-
if (!id) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
"google-slides: presentationId is required. Either configure a default or pass it explicitly."
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
return id;
|
|
82
|
-
}
|
|
83
|
-
function request(path2, init) {
|
|
84
|
-
const resolvedPath = defaultPresentationId ? path2.replace(/\{presentationId\}/g, defaultPresentationId) : path2;
|
|
85
|
-
const url = `${SLIDES_BASE_URL}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
|
|
86
|
-
return fetchFn(url, init);
|
|
87
|
-
}
|
|
88
|
-
async function getPresentation(presentationId) {
|
|
89
|
-
const id = resolvePresentationId(presentationId);
|
|
90
|
-
const url = `${SLIDES_BASE_URL}/${id}`;
|
|
91
|
-
const response = await fetchFn(url);
|
|
92
|
-
if (!response.ok) {
|
|
93
|
-
const body = await response.text();
|
|
94
|
-
throw new Error(
|
|
95
|
-
`google-slides: getPresentation failed (${response.status}): ${body}`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return await response.json();
|
|
99
|
-
}
|
|
100
|
-
async function getPage(pageObjectId, presentationId) {
|
|
101
|
-
const id = resolvePresentationId(presentationId);
|
|
102
|
-
const url = `${SLIDES_BASE_URL}/${id}/pages/${pageObjectId}`;
|
|
103
|
-
const response = await fetchFn(url);
|
|
104
|
-
if (!response.ok) {
|
|
105
|
-
const body = await response.text();
|
|
106
|
-
throw new Error(
|
|
107
|
-
`google-slides: getPage failed (${response.status}): ${body}`
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
return await response.json();
|
|
111
|
-
}
|
|
112
|
-
async function batchUpdate(requests, presentationId) {
|
|
113
|
-
const id = resolvePresentationId(presentationId);
|
|
114
|
-
const url = `${SLIDES_BASE_URL}/${id}:batchUpdate`;
|
|
115
|
-
const response = await fetchFn(url, {
|
|
116
|
-
method: "POST",
|
|
117
|
-
headers: { "Content-Type": "application/json" },
|
|
118
|
-
body: JSON.stringify({ requests })
|
|
119
|
-
});
|
|
120
|
-
if (!response.ok) {
|
|
121
|
-
const body = await response.text();
|
|
122
|
-
throw new Error(
|
|
123
|
-
`google-slides: batchUpdate failed (${response.status}): ${body}`
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
return await response.json();
|
|
127
|
-
}
|
|
128
|
-
async function createPresentation(title) {
|
|
129
|
-
const url = SLIDES_BASE_URL;
|
|
130
|
-
const response = await fetchFn(url, {
|
|
131
|
-
method: "POST",
|
|
132
|
-
headers: { "Content-Type": "application/json" },
|
|
133
|
-
body: JSON.stringify({ title })
|
|
134
|
-
});
|
|
135
|
-
if (!response.ok) {
|
|
136
|
-
const body = await response.text();
|
|
137
|
-
throw new Error(
|
|
138
|
-
`google-slides: createPresentation failed (${response.status}): ${body}`
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
return await response.json();
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
request,
|
|
145
|
-
getPresentation,
|
|
146
|
-
getPage,
|
|
147
|
-
batchUpdate,
|
|
148
|
-
createPresentation
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// ../connectors/src/connector-onboarding.ts
|
|
153
|
-
var ConnectorOnboarding = class {
|
|
154
|
-
/** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
|
|
155
|
-
connectionSetupInstructions;
|
|
156
|
-
/** Phase 2: Data overview instructions */
|
|
157
|
-
dataOverviewInstructions;
|
|
158
|
-
constructor(config) {
|
|
159
|
-
this.connectionSetupInstructions = config.connectionSetupInstructions;
|
|
160
|
-
this.dataOverviewInstructions = config.dataOverviewInstructions;
|
|
161
|
-
}
|
|
162
|
-
getConnectionSetupPrompt(language) {
|
|
163
|
-
return this.connectionSetupInstructions?.[language] ?? null;
|
|
164
|
-
}
|
|
165
|
-
getDataOverviewInstructions(language) {
|
|
166
|
-
return this.dataOverviewInstructions[language];
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// ../connectors/src/connector-tool.ts
|
|
171
|
-
var ConnectorTool = class {
|
|
172
|
-
name;
|
|
173
|
-
description;
|
|
174
|
-
inputSchema;
|
|
175
|
-
outputSchema;
|
|
176
|
-
_execute;
|
|
177
|
-
constructor(config) {
|
|
178
|
-
this.name = config.name;
|
|
179
|
-
this.description = config.description;
|
|
180
|
-
this.inputSchema = config.inputSchema;
|
|
181
|
-
this.outputSchema = config.outputSchema;
|
|
182
|
-
this._execute = config.execute;
|
|
183
|
-
}
|
|
184
|
-
createTool(connections, config) {
|
|
185
|
-
return {
|
|
186
|
-
description: this.description,
|
|
187
|
-
inputSchema: this.inputSchema,
|
|
188
|
-
outputSchema: this.outputSchema,
|
|
189
|
-
execute: (input) => this._execute(input, connections, config)
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// ../connectors/src/connector-plugin.ts
|
|
195
|
-
var ConnectorPlugin = class _ConnectorPlugin {
|
|
196
|
-
slug;
|
|
197
|
-
authType;
|
|
198
|
-
name;
|
|
199
|
-
description;
|
|
200
|
-
iconUrl;
|
|
201
|
-
parameters;
|
|
202
|
-
releaseFlag;
|
|
203
|
-
proxyPolicy;
|
|
204
|
-
experimentalAttributes;
|
|
205
|
-
onboarding;
|
|
206
|
-
systemPrompt;
|
|
207
|
-
tools;
|
|
208
|
-
query;
|
|
209
|
-
checkConnection;
|
|
210
|
-
constructor(config) {
|
|
211
|
-
this.slug = config.slug;
|
|
212
|
-
this.authType = config.authType;
|
|
213
|
-
this.name = config.name;
|
|
214
|
-
this.description = config.description;
|
|
215
|
-
this.iconUrl = config.iconUrl;
|
|
216
|
-
this.parameters = config.parameters;
|
|
217
|
-
this.releaseFlag = config.releaseFlag;
|
|
218
|
-
this.proxyPolicy = config.proxyPolicy;
|
|
219
|
-
this.experimentalAttributes = config.experimentalAttributes;
|
|
220
|
-
this.onboarding = config.onboarding;
|
|
221
|
-
this.systemPrompt = config.systemPrompt;
|
|
222
|
-
this.tools = config.tools;
|
|
223
|
-
this.query = config.query;
|
|
224
|
-
this.checkConnection = config.checkConnection;
|
|
225
|
-
}
|
|
226
|
-
get connectorKey() {
|
|
227
|
-
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Create tools for connections that belong to this connector.
|
|
231
|
-
* Filters connections by connectorKey internally.
|
|
232
|
-
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
233
|
-
*/
|
|
234
|
-
createTools(connections, config) {
|
|
235
|
-
const myConnections = connections.filter(
|
|
236
|
-
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
237
|
-
);
|
|
238
|
-
const result = {};
|
|
239
|
-
for (const t of Object.values(this.tools)) {
|
|
240
|
-
result[`${this.connectorKey}_${t.name}`] = t.createTool(
|
|
241
|
-
myConnections,
|
|
242
|
-
config
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
return result;
|
|
246
|
-
}
|
|
247
|
-
static deriveKey(slug, authType) {
|
|
248
|
-
return authType ? `${slug}-${authType}` : slug;
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
// ../connectors/src/auth-types.ts
|
|
253
|
-
var AUTH_TYPES = {
|
|
254
|
-
OAUTH: "oauth",
|
|
255
|
-
API_KEY: "api-key",
|
|
256
|
-
JWT: "jwt",
|
|
257
|
-
SERVICE_ACCOUNT: "service-account",
|
|
258
|
-
PAT: "pat",
|
|
259
|
-
USER_PASSWORD: "user-password"
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
// ../connectors/src/connectors/google-slides-oauth/tools/request.ts
|
|
263
|
-
import { z } from "zod";
|
|
264
|
-
var SLIDES_BASE_URL2 = "https://slides.googleapis.com/v1/presentations";
|
|
265
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
266
|
-
var cachedToken = null;
|
|
267
|
-
async function getProxyToken(config) {
|
|
268
|
-
if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
|
|
269
|
-
return cachedToken.token;
|
|
270
|
-
}
|
|
271
|
-
const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
|
|
272
|
-
const res = await fetch(url, {
|
|
273
|
-
method: "POST",
|
|
274
|
-
headers: {
|
|
275
|
-
"Content-Type": "application/json",
|
|
276
|
-
"x-api-key": config.appApiKey,
|
|
277
|
-
"project-id": config.projectId
|
|
278
|
-
},
|
|
279
|
-
body: JSON.stringify({
|
|
280
|
-
sandboxId: config.sandboxId,
|
|
281
|
-
issuedBy: "coding-agent"
|
|
282
|
-
})
|
|
283
|
-
});
|
|
284
|
-
if (!res.ok) {
|
|
285
|
-
const errorText = await res.text().catch(() => res.statusText);
|
|
286
|
-
throw new Error(
|
|
287
|
-
`Failed to get proxy token: HTTP ${res.status} ${errorText}`
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
const data = await res.json();
|
|
291
|
-
cachedToken = {
|
|
292
|
-
token: data.token,
|
|
293
|
-
expiresAt: new Date(data.expiresAt).getTime()
|
|
294
|
-
};
|
|
295
|
-
return data.token;
|
|
296
|
-
}
|
|
297
|
-
var inputSchema = z.object({
|
|
298
|
-
toolUseIntent: z.string().optional().describe(
|
|
299
|
-
"Brief description of what you intend to accomplish with this tool call"
|
|
300
|
-
),
|
|
301
|
-
connectionId: z.string().describe("ID of the Google Slides OAuth connection to use"),
|
|
302
|
-
method: z.enum(["GET", "POST"]).describe("HTTP method"),
|
|
303
|
-
path: z.string().describe(
|
|
304
|
-
"API path appended to https://slides.googleapis.com/v1/presentations (e.g., '/{presentationId}', '/{presentationId}/pages/{pageId}'). {presentationId} is automatically replaced if a default is configured."
|
|
305
|
-
),
|
|
306
|
-
body: z.record(z.string(), z.unknown()).optional().describe("JSON request body for POST requests"),
|
|
307
|
-
queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL")
|
|
308
|
-
});
|
|
309
|
-
var outputSchema = z.discriminatedUnion("success", [
|
|
310
|
-
z.object({
|
|
311
|
-
success: z.literal(true),
|
|
312
|
-
status: z.number(),
|
|
313
|
-
data: z.record(z.string(), z.unknown())
|
|
314
|
-
}),
|
|
315
|
-
z.object({
|
|
316
|
-
success: z.literal(false),
|
|
317
|
-
error: z.string()
|
|
318
|
-
})
|
|
319
|
-
]);
|
|
320
|
-
var requestTool = new ConnectorTool({
|
|
321
|
-
name: "request",
|
|
322
|
-
description: `Send authenticated requests to the Google Slides API v1.
|
|
323
|
-
Supports GET (read) and POST (create/update) methods.
|
|
324
|
-
Authentication is handled automatically via OAuth proxy.
|
|
325
|
-
{presentationId} in the path is automatically replaced with the connection's default presentation ID if configured.`,
|
|
326
|
-
inputSchema,
|
|
327
|
-
outputSchema,
|
|
328
|
-
async execute({ connectionId, method, path: path2, body, queryParams }, connections, config) {
|
|
329
|
-
const connection2 = connections.find((c) => c.id === connectionId);
|
|
330
|
-
if (!connection2) {
|
|
331
|
-
return {
|
|
332
|
-
success: false,
|
|
333
|
-
error: `Connection ${connectionId} not found`
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
console.log(
|
|
337
|
-
`[connector-request] google-slides-oauth/${connection2.name}: ${method} ${path2}`
|
|
338
|
-
);
|
|
339
|
-
try {
|
|
340
|
-
const presentationUrl = parameters.presentationUrl.tryGetValue(connection2);
|
|
341
|
-
const presentationId = presentationUrl ? extractPresentationId(presentationUrl) : void 0;
|
|
342
|
-
const resolvedPath = presentationId ? path2.replace(/\{presentationId\}/g, presentationId) : path2;
|
|
343
|
-
let url = `${SLIDES_BASE_URL2}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
|
|
344
|
-
if (queryParams) {
|
|
345
|
-
const searchParams = new URLSearchParams(queryParams);
|
|
346
|
-
url += `?${searchParams.toString()}`;
|
|
347
|
-
}
|
|
348
|
-
const token = await getProxyToken(config.oauthProxy);
|
|
349
|
-
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
350
|
-
const controller = new AbortController();
|
|
351
|
-
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
352
|
-
try {
|
|
353
|
-
const response = await fetch(proxyUrl, {
|
|
354
|
-
method: "POST",
|
|
355
|
-
headers: {
|
|
356
|
-
"Content-Type": "application/json",
|
|
357
|
-
Authorization: `Bearer ${token}`
|
|
358
|
-
},
|
|
359
|
-
body: JSON.stringify({
|
|
360
|
-
url,
|
|
361
|
-
method,
|
|
362
|
-
...body != null ? { body: JSON.stringify(body) } : {}
|
|
363
|
-
}),
|
|
364
|
-
signal: controller.signal
|
|
365
|
-
});
|
|
366
|
-
const data = await response.json();
|
|
367
|
-
if (!response.ok) {
|
|
368
|
-
const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`;
|
|
369
|
-
return { success: false, error: errorMessage };
|
|
370
|
-
}
|
|
371
|
-
return { success: true, status: response.status, data };
|
|
372
|
-
} finally {
|
|
373
|
-
clearTimeout(timeout);
|
|
374
|
-
}
|
|
375
|
-
} catch (err) {
|
|
376
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
377
|
-
return { success: false, error: msg };
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
// ../connectors/src/connectors/google-slides-oauth/setup.ts
|
|
383
|
-
var requestToolName = `google-slides-oauth_${requestTool.name}`;
|
|
384
|
-
var googleSlidesOnboarding = new ConnectorOnboarding({
|
|
385
|
-
connectionSetupInstructions: {
|
|
386
|
-
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Slides\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3URL\u306F\u63A5\u7D9A\u30D1\u30E9\u30E1\u30FC\u30BF\u3068\u3057\u3066\u65E2\u306B\u767B\u9332\u6E08\u307F\u3067\u3059\u3002\u30E6\u30FC\u30B6\u30FC\u306B\u805E\u304D\u8FD4\u3055\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
387
|
-
|
|
388
|
-
1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3059\u308B:
|
|
389
|
-
- \`method\`: \`"GET"\`
|
|
390
|
-
- \`path\`: \`"/{presentationId}?fields=presentationId,title,slides.objectId"\`
|
|
391
|
-
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u5171\u6709\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
392
|
-
3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
393
|
-
- \`presentation\`: \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30BF\u30A4\u30C8\u30EB
|
|
394
|
-
- \`slides\`: \u30B9\u30E9\u30A4\u30C9\u6570
|
|
395
|
-
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
396
|
-
|
|
397
|
-
#### \u5236\u7D04
|
|
398
|
-
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30B9\u30E9\u30A4\u30C9\u306E\u8A73\u7D30\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
|
|
399
|
-
- \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3URL\u3092\u30E6\u30FC\u30B6\u30FC\u306B\u805E\u304D\u8FD4\u3055\u306A\u3044\u3053\u3068\uFF08\u767B\u9332\u6E08\u307F\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u305D\u306E\u307E\u307E\u4F7F\u7528\u3059\u308B\uFF09
|
|
400
|
-
- \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`,
|
|
401
|
-
en: `Follow these steps to set up the Google Slides connection. The presentation URL is already registered as a connection parameter \u2014 do NOT ask the user for it again.
|
|
402
|
-
|
|
403
|
-
1. Call \`${requestToolName}\` to fetch presentation metadata:
|
|
404
|
-
- \`method\`: \`"GET"\`
|
|
405
|
-
- \`path\`: \`"/{presentationId}?fields=presentationId,title,slides.objectId"\`
|
|
406
|
-
2. If an error is returned, ask the user to check the presentation sharing settings
|
|
407
|
-
3. Call \`updateConnectionContext\`:
|
|
408
|
-
- \`presentation\`: The presentation title
|
|
409
|
-
- \`slides\`: Number of slides
|
|
410
|
-
- \`note\`: Brief description of the setup
|
|
411
|
-
|
|
412
|
-
#### Constraints
|
|
413
|
-
- **Do NOT read slide detail data during setup**. Only the metadata request specified in the steps above is allowed
|
|
414
|
-
- Do NOT ask the user for the presentation URL \u2014 it is already stored as a connection parameter
|
|
415
|
-
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
416
|
-
},
|
|
417
|
-
dataOverviewInstructions: {
|
|
418
|
-
en: `1. Call google-slides-oauth_request with GET /{presentationId} to get presentation metadata (title, slide count, layout info)
|
|
419
|
-
2. Call google-slides-oauth_request with GET /{presentationId}/pages/{pageObjectId} to inspect individual slide content`,
|
|
420
|
-
ja: `1. 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
|
|
421
|
-
2. google-slides-oauth_request \u3067 GET /{presentationId}/pages/{pageObjectId} \u3092\u547C\u3073\u51FA\u3057\u3001\u500B\u5225\u30B9\u30E9\u30A4\u30C9\u306E\u5185\u5BB9\u3092\u78BA\u8A8D`
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// ../connectors/src/connectors/google-slides-oauth/index.ts
|
|
426
|
-
var tools = { request: requestTool };
|
|
427
|
-
var googleSlidesOauthConnector = new ConnectorPlugin({
|
|
428
|
-
slug: "google-slides",
|
|
429
|
-
authType: AUTH_TYPES.OAUTH,
|
|
430
|
-
name: "Google Slides",
|
|
431
|
-
description: "Connect to Google Slides for presentation data access and creation using OAuth.",
|
|
432
|
-
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4oyF4yTRpemMA43X49masx/e1582d25e3b4c9a63ba83df2147c1968/google_slide.png",
|
|
433
|
-
parameters,
|
|
434
|
-
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
435
|
-
onboarding: googleSlidesOnboarding,
|
|
436
|
-
proxyPolicy: {
|
|
437
|
-
allowlist: [
|
|
438
|
-
{
|
|
439
|
-
host: "slides.googleapis.com",
|
|
440
|
-
methods: ["GET", "POST"]
|
|
441
|
-
}
|
|
442
|
-
]
|
|
443
|
-
},
|
|
444
|
-
systemPrompt: {
|
|
445
|
-
en: `### Tools
|
|
446
|
-
|
|
447
|
-
- \`google-slides-oauth_request\`: The way to call the Google Slides API. 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. The {presentationId} placeholder in paths is automatically replaced with the configured default presentation ID.
|
|
448
|
-
|
|
449
|
-
### Google Slides API Reference
|
|
450
|
-
|
|
451
|
-
#### Read Endpoints
|
|
452
|
-
- GET \`/{presentationId}\` \u2014 Get presentation metadata (title, slides, layouts, masters)
|
|
453
|
-
- GET \`/{presentationId}/pages/{pageObjectId}\` \u2014 Get a specific slide page with all its elements (shapes, text, images, tables)
|
|
454
|
-
|
|
455
|
-
#### Write Endpoints
|
|
456
|
-
- POST \`\` (empty path, with body) \u2014 Create a new presentation. Body: \`{ "title": "My Presentation" }\`
|
|
457
|
-
- POST \`/{presentationId}:batchUpdate\` \u2014 Apply multiple updates to a presentation. Body: \`{ "requests": [...] }\`
|
|
458
|
-
|
|
459
|
-
#### Common batchUpdate Request Types
|
|
460
|
-
- \`createSlide\` \u2014 Add a new slide: \`{ "createSlide": { "insertionIndex": 1, "slideLayoutReference": { "predefinedLayout": "BLANK" } } }\`
|
|
461
|
-
- \`insertText\` \u2014 Insert text into a shape: \`{ "insertText": { "objectId": "shapeId", "text": "Hello" } }\`
|
|
462
|
-
- \`createShape\` \u2014 Add a shape to a slide: \`{ "createShape": { "shapeType": "TEXT_BOX", "elementProperties": { "pageObjectId": "slideId", "size": {...}, "transform": {...} } } }\`
|
|
463
|
-
- \`createImage\` \u2014 Add an image: \`{ "createImage": { "url": "https://...", "elementProperties": { "pageObjectId": "slideId" } } }\`
|
|
464
|
-
- \`deleteObject\` \u2014 Delete a page element or slide: \`{ "deleteObject": { "objectId": "objectId" } }\`
|
|
465
|
-
- \`replaceAllText\` \u2014 Find & replace text: \`{ "replaceAllText": { "containsText": { "text": "old" }, "replaceText": "new" } }\`
|
|
466
|
-
- \`updateTextStyle\` \u2014 Style text (bold, color, font): \`{ "updateTextStyle": { "objectId": "shapeId", "style": { "bold": true }, "textRange": { "type": "ALL" }, "fields": "bold" } }\`
|
|
467
|
-
- \`updateShapeProperties\` \u2014 Update shape fill, outline, etc.
|
|
468
|
-
- \`createTable\` \u2014 Create a table on a slide
|
|
469
|
-
- \`insertTableRows\` / \`insertTableColumns\` \u2014 Add rows/columns to a table
|
|
470
|
-
- \`deleteTableRow\` / \`deleteTableColumn\` \u2014 Remove rows/columns
|
|
471
|
-
|
|
472
|
-
#### Predefined Slide Layouts
|
|
473
|
-
\`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\`
|
|
474
|
-
|
|
475
|
-
### Tips
|
|
476
|
-
- Use \`{presentationId}\` placeholder in paths \u2014 it is automatically replaced with the configured default presentation ID
|
|
477
|
-
- To explore a presentation, first GET the presentation metadata to see available slide object IDs
|
|
478
|
-
- When inserting text or shapes, you need the \`pageObjectId\` of the target slide (from the metadata)
|
|
479
|
-
- batchUpdate requests are applied in order \u2014 use this for complex multi-step modifications
|
|
480
|
-
- Shape sizes and positions use EMU (English Metric Units): 1 inch = 914400 EMU, 1 pt = 12700 EMU
|
|
481
|
-
|
|
482
|
-
### Business Logic
|
|
483
|
-
|
|
484
|
-
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.
|
|
485
|
-
|
|
486
|
-
#### Example
|
|
487
|
-
|
|
488
|
-
\`\`\`ts
|
|
489
|
-
import { connection } from "@squadbase/vite-server/connectors/google-slides-oauth";
|
|
490
|
-
|
|
491
|
-
const slides = connection("<connectionId>");
|
|
492
|
-
|
|
493
|
-
// Get presentation metadata
|
|
494
|
-
const presentation = await slides.getPresentation();
|
|
495
|
-
console.log(presentation.title, presentation.slides.length);
|
|
496
|
-
|
|
497
|
-
// Get a specific slide's content
|
|
498
|
-
const page = await slides.getPage(presentation.slides[0].objectId);
|
|
499
|
-
console.log(page.pageElements);
|
|
500
|
-
|
|
501
|
-
// Create a new presentation
|
|
502
|
-
const newPres = await slides.createPresentation("Quarterly Report");
|
|
503
|
-
console.log(newPres.presentationId);
|
|
504
|
-
|
|
505
|
-
// Add a slide and insert text
|
|
506
|
-
await slides.batchUpdate([
|
|
507
|
-
{ createSlide: { insertionIndex: 1, slideLayoutReference: { predefinedLayout: "TITLE_AND_BODY" } } },
|
|
508
|
-
{ insertText: { objectId: "someShapeId", text: "Hello, World!" } },
|
|
509
|
-
]);
|
|
510
|
-
\`\`\``,
|
|
511
|
-
ja: `### \u30C4\u30FC\u30EB
|
|
512
|
-
|
|
513
|
-
- \`google-slides-oauth_request\`: Google Slides API\u3092\u547C\u3073\u51FA\u3059\u624B\u6BB5\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\u30D1\u30B9\u5185\u306E{presentationId}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u8A2D\u5B9A\u6E08\u307F\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3ID\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002
|
|
514
|
-
|
|
515
|
-
### Google Slides API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
516
|
-
|
|
517
|
-
#### \u8AAD\u307F\u53D6\u308A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
518
|
-
- 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
|
|
519
|
-
- 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
|
|
520
|
-
|
|
521
|
-
#### \u66F8\u304D\u8FBC\u307F\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
522
|
-
- 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" }\`
|
|
523
|
-
- POST \`/{presentationId}:batchUpdate\` \u2014 \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306B\u8907\u6570\u306E\u66F4\u65B0\u3092\u9069\u7528\u3002Body: \`{ "requests": [...] }\`
|
|
524
|
-
|
|
525
|
-
#### \u4E3B\u306A batchUpdate \u30EA\u30AF\u30A8\u30B9\u30C8\u30BF\u30A4\u30D7
|
|
526
|
-
- \`createSlide\` \u2014 \u30B9\u30E9\u30A4\u30C9\u3092\u8FFD\u52A0: \`{ "createSlide": { "insertionIndex": 1, "slideLayoutReference": { "predefinedLayout": "BLANK" } } }\`
|
|
527
|
-
- \`insertText\` \u2014 \u56F3\u5F62\u306B\u30C6\u30AD\u30B9\u30C8\u3092\u633F\u5165: \`{ "insertText": { "objectId": "shapeId", "text": "Hello" } }\`
|
|
528
|
-
- \`createShape\` \u2014 \u30B9\u30E9\u30A4\u30C9\u306B\u56F3\u5F62\u3092\u8FFD\u52A0: \`{ "createShape": { "shapeType": "TEXT_BOX", "elementProperties": { "pageObjectId": "slideId", "size": {...}, "transform": {...} } } }\`
|
|
529
|
-
- \`createImage\` \u2014 \u753B\u50CF\u3092\u8FFD\u52A0: \`{ "createImage": { "url": "https://...", "elementProperties": { "pageObjectId": "slideId" } } }\`
|
|
530
|
-
- \`deleteObject\` \u2014 \u30DA\u30FC\u30B8\u8981\u7D20\u307E\u305F\u306F\u30B9\u30E9\u30A4\u30C9\u3092\u524A\u9664: \`{ "deleteObject": { "objectId": "objectId" } }\`
|
|
531
|
-
- \`replaceAllText\` \u2014 \u30C6\u30AD\u30B9\u30C8\u306E\u691C\u7D22\u3068\u7F6E\u63DB: \`{ "replaceAllText": { "containsText": { "text": "\u53E4\u3044" }, "replaceText": "\u65B0\u3057\u3044" } }\`
|
|
532
|
-
- \`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" } }\`
|
|
533
|
-
- \`updateShapeProperties\` \u2014 \u56F3\u5F62\u306E\u5857\u308A\u3064\u3076\u3057\u3001\u30A2\u30A6\u30C8\u30E9\u30A4\u30F3\u306A\u3069\u3092\u66F4\u65B0
|
|
534
|
-
- \`createTable\` \u2014 \u30B9\u30E9\u30A4\u30C9\u306B\u30C6\u30FC\u30D6\u30EB\u3092\u4F5C\u6210
|
|
535
|
-
- \`insertTableRows\` / \`insertTableColumns\` \u2014 \u30C6\u30FC\u30D6\u30EB\u306B\u884C/\u5217\u3092\u8FFD\u52A0
|
|
536
|
-
- \`deleteTableRow\` / \`deleteTableColumn\` \u2014 \u884C/\u5217\u3092\u524A\u9664
|
|
537
|
-
|
|
538
|
-
#### \u5B9A\u7FA9\u6E08\u307F\u30B9\u30E9\u30A4\u30C9\u30EC\u30A4\u30A2\u30A6\u30C8
|
|
539
|
-
\`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\`
|
|
540
|
-
|
|
541
|
-
### \u30D2\u30F3\u30C8
|
|
542
|
-
- \u30D1\u30B9\u306B \`{presentationId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u3092\u4F7F\u7528 \u2014 \u8A2D\u5B9A\u6E08\u307F\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3ID\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059
|
|
543
|
-
- \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
|
|
544
|
-
- \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
|
|
545
|
-
- 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
|
|
546
|
-
- \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
|
|
547
|
-
|
|
548
|
-
### Business Logic
|
|
549
|
-
|
|
550
|
-
\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
|
|
551
|
-
|
|
552
|
-
#### Example
|
|
553
|
-
|
|
554
|
-
\`\`\`ts
|
|
555
|
-
import { connection } from "@squadbase/vite-server/connectors/google-slides-oauth";
|
|
556
|
-
|
|
557
|
-
const slides = connection("<connectionId>");
|
|
558
|
-
|
|
559
|
-
// \u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
|
|
560
|
-
const presentation = await slides.getPresentation();
|
|
561
|
-
console.log(presentation.title, presentation.slides.length);
|
|
562
|
-
|
|
563
|
-
// \u7279\u5B9A\u306E\u30B9\u30E9\u30A4\u30C9\u306E\u5185\u5BB9\u3092\u53D6\u5F97
|
|
564
|
-
const page = await slides.getPage(presentation.slides[0].objectId);
|
|
565
|
-
console.log(page.pageElements);
|
|
566
|
-
|
|
567
|
-
// \u65B0\u3057\u3044\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3092\u4F5C\u6210
|
|
568
|
-
const newPres = await slides.createPresentation("\u56DB\u534A\u671F\u30EC\u30DD\u30FC\u30C8");
|
|
569
|
-
console.log(newPres.presentationId);
|
|
570
|
-
|
|
571
|
-
// \u30B9\u30E9\u30A4\u30C9\u3092\u8FFD\u52A0\u3057\u3066\u30C6\u30AD\u30B9\u30C8\u3092\u633F\u5165
|
|
572
|
-
await slides.batchUpdate([
|
|
573
|
-
{ createSlide: { insertionIndex: 1, slideLayoutReference: { predefinedLayout: "TITLE_AND_BODY" } } },
|
|
574
|
-
{ insertText: { objectId: "someShapeId", text: "Hello, World!" } },
|
|
575
|
-
]);
|
|
576
|
-
\`\`\``
|
|
577
|
-
},
|
|
578
|
-
tools,
|
|
579
|
-
async checkConnection(params, config) {
|
|
580
|
-
const { proxyFetch } = config;
|
|
581
|
-
const presentationUrl = params[parameters.presentationUrl.slug];
|
|
582
|
-
if (!presentationUrl) {
|
|
583
|
-
return { success: true };
|
|
584
|
-
}
|
|
585
|
-
const presentationId = extractPresentationId(presentationUrl);
|
|
586
|
-
const url = `https://slides.googleapis.com/v1/presentations/${presentationId}?fields=presentationId,title`;
|
|
587
|
-
try {
|
|
588
|
-
const res = await proxyFetch(url, { method: "GET" });
|
|
589
|
-
if (!res.ok) {
|
|
590
|
-
const errorText = await res.text().catch(() => res.statusText);
|
|
591
|
-
return {
|
|
592
|
-
success: false,
|
|
593
|
-
error: `Google Slides API failed: HTTP ${res.status} ${errorText}`
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
return { success: true };
|
|
597
|
-
} catch (error) {
|
|
598
|
-
return {
|
|
599
|
-
success: false,
|
|
600
|
-
error: error instanceof Error ? error.message : String(error)
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
// src/connectors/create-connector-sdk.ts
|
|
607
|
-
import { readFileSync } from "fs";
|
|
608
|
-
import path from "path";
|
|
609
|
-
|
|
610
|
-
// src/connector-client/env.ts
|
|
611
|
-
function resolveEnvVar(entry, key, connectionId) {
|
|
612
|
-
const envVarName = entry.envVars[key];
|
|
613
|
-
if (!envVarName) {
|
|
614
|
-
throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
|
|
615
|
-
}
|
|
616
|
-
const value = process.env[envVarName];
|
|
617
|
-
if (!value) {
|
|
618
|
-
throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
|
|
619
|
-
}
|
|
620
|
-
return value;
|
|
621
|
-
}
|
|
622
|
-
function resolveEnvVarOptional(entry, key) {
|
|
623
|
-
const envVarName = entry.envVars[key];
|
|
624
|
-
if (!envVarName) return void 0;
|
|
625
|
-
return process.env[envVarName] || void 0;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// src/connector-client/proxy-fetch.ts
|
|
629
|
-
import { getContext } from "hono/context-storage";
|
|
630
|
-
import { getCookie } from "hono/cookie";
|
|
631
|
-
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
632
|
-
function createSandboxProxyFetch(connectionId) {
|
|
633
|
-
return async (input, init) => {
|
|
634
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
635
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
636
|
-
if (!token || !sandboxId) {
|
|
637
|
-
throw new Error(
|
|
638
|
-
"Connection proxy is not configured. Please check your deployment settings."
|
|
639
|
-
);
|
|
640
|
-
}
|
|
641
|
-
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
642
|
-
const originalMethod = init?.method ?? "GET";
|
|
643
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
644
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
645
|
-
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
646
|
-
return fetch(proxyUrl, {
|
|
647
|
-
method: "POST",
|
|
648
|
-
headers: {
|
|
649
|
-
"Content-Type": "application/json",
|
|
650
|
-
Authorization: `Bearer ${token}`
|
|
651
|
-
},
|
|
652
|
-
body: JSON.stringify({
|
|
653
|
-
url: originalUrl,
|
|
654
|
-
method: originalMethod,
|
|
655
|
-
body: originalBody
|
|
656
|
-
})
|
|
657
|
-
});
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
function createDeployedAppProxyFetch(connectionId) {
|
|
661
|
-
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
662
|
-
if (!projectId) {
|
|
663
|
-
throw new Error(
|
|
664
|
-
"Connection proxy is not configured. Please check your deployment settings."
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
668
|
-
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
669
|
-
return async (input, init) => {
|
|
670
|
-
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
671
|
-
const originalMethod = init?.method ?? "GET";
|
|
672
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
673
|
-
const c = getContext();
|
|
674
|
-
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
675
|
-
if (!appSession) {
|
|
676
|
-
throw new Error(
|
|
677
|
-
"No authentication method available for connection proxy."
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
return fetch(proxyUrl, {
|
|
681
|
-
method: "POST",
|
|
682
|
-
headers: {
|
|
683
|
-
"Content-Type": "application/json",
|
|
684
|
-
Authorization: `Bearer ${appSession}`
|
|
685
|
-
},
|
|
686
|
-
body: JSON.stringify({
|
|
687
|
-
url: originalUrl,
|
|
688
|
-
method: originalMethod,
|
|
689
|
-
body: originalBody
|
|
690
|
-
})
|
|
691
|
-
});
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
function createProxyFetch(connectionId) {
|
|
695
|
-
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
696
|
-
return createSandboxProxyFetch(connectionId);
|
|
697
|
-
}
|
|
698
|
-
return createDeployedAppProxyFetch(connectionId);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// src/connectors/create-connector-sdk.ts
|
|
702
|
-
function loadConnectionsSync() {
|
|
703
|
-
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
704
|
-
try {
|
|
705
|
-
const raw = readFileSync(filePath, "utf-8");
|
|
706
|
-
return JSON.parse(raw);
|
|
707
|
-
} catch {
|
|
708
|
-
return {};
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
function createConnectorSdk(plugin, createClient2) {
|
|
712
|
-
return (connectionId) => {
|
|
713
|
-
const connections = loadConnectionsSync();
|
|
714
|
-
const entry = connections[connectionId];
|
|
715
|
-
if (!entry) {
|
|
716
|
-
throw new Error(
|
|
717
|
-
`Connection "${connectionId}" not found in .squadbase/connections.json`
|
|
718
|
-
);
|
|
719
|
-
}
|
|
720
|
-
if (entry.connector.slug !== plugin.slug) {
|
|
721
|
-
throw new Error(
|
|
722
|
-
`Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
|
|
723
|
-
);
|
|
724
|
-
}
|
|
725
|
-
const params = {};
|
|
726
|
-
for (const param of Object.values(plugin.parameters)) {
|
|
727
|
-
if (param.required) {
|
|
728
|
-
params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
|
|
729
|
-
} else {
|
|
730
|
-
const val = resolveEnvVarOptional(entry, param.slug);
|
|
731
|
-
if (val !== void 0) params[param.slug] = val;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
return createClient2(params, createProxyFetch(connectionId));
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// src/connectors/entries/google-slides-oauth.ts
|
|
739
|
-
var connection = createConnectorSdk(googleSlidesOauthConnector, createClient);
|
|
740
|
-
export {
|
|
741
|
-
connection
|
|
742
|
-
};
|