@squadbase/vite-server 0.1.3-dev.4 → 0.1.3-dev.6
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 +3104 -2679
- package/dist/connectors/airtable-oauth.js +3 -2
- package/dist/connectors/airtable.js +11 -1
- package/dist/connectors/amplitude.js +11 -1
- package/dist/connectors/anthropic.js +11 -1
- package/dist/connectors/asana.js +11 -1
- package/dist/connectors/attio.js +11 -1
- package/dist/connectors/customerio.js +11 -1
- package/dist/connectors/dbt.js +11 -1
- package/dist/connectors/gemini.js +11 -1
- package/dist/connectors/gmail-oauth.js +3 -2
- package/dist/connectors/{microsoft-teams-oauth.d.ts → gmail.d.ts} +1 -1
- package/dist/connectors/gmail.js +802 -0
- package/dist/connectors/google-ads-oauth.js +4 -3
- package/dist/connectors/google-ads.js +11 -1
- package/dist/connectors/google-analytics-oauth.js +3 -2
- package/dist/connectors/google-analytics.js +267 -27
- package/dist/connectors/{slack.d.ts → google-calendar-oauth.d.ts} +1 -1
- package/dist/connectors/google-calendar-oauth.js +744 -0
- package/dist/connectors/google-calendar.d.ts +12 -0
- package/dist/connectors/google-calendar.js +688 -0
- package/dist/connectors/google-sheets-oauth.js +3 -2
- package/dist/connectors/google-sheets.js +11 -1
- package/dist/connectors/hubspot-oauth.js +2 -1
- package/dist/connectors/hubspot.js +11 -1
- package/dist/connectors/intercom-oauth.js +3 -2
- package/dist/connectors/intercom.js +11 -1
- package/dist/connectors/jira-api-key.js +3 -2
- package/dist/connectors/kintone-api-token.js +3 -2
- package/dist/connectors/kintone.js +12 -2
- package/dist/connectors/linkedin-ads-oauth.js +3 -2
- package/dist/connectors/linkedin-ads.js +11 -1
- package/dist/connectors/mailchimp-oauth.js +2 -1
- package/dist/connectors/mailchimp.js +11 -1
- package/dist/connectors/notion-oauth.js +3 -2
- package/dist/connectors/notion.js +11 -1
- package/dist/connectors/openai.js +11 -1
- package/dist/connectors/shopify-oauth.js +3 -2
- package/dist/connectors/shopify.js +11 -1
- package/dist/connectors/stripe-api-key.js +3 -2
- package/dist/connectors/stripe-oauth.js +3 -2
- package/dist/connectors/wix-store.js +11 -1
- package/dist/connectors/zendesk-oauth.js +3 -2
- package/dist/connectors/zendesk.js +11 -1
- package/dist/index.js +3099 -2674
- package/dist/main.js +3099 -2674
- package/dist/vite-plugin.js +3099 -2674
- package/package.json +13 -1
- package/dist/connectors/microsoft-teams-oauth.js +0 -479
- package/dist/connectors/microsoft-teams.d.ts +0 -5
- package/dist/connectors/microsoft-teams.js +0 -381
- package/dist/connectors/slack.js +0 -362
|
@@ -60,7 +60,7 @@ var parameters = {
|
|
|
60
60
|
envVarBaseKey: "GOOGLE_ADS_DEVELOPER_TOKEN",
|
|
61
61
|
type: "text",
|
|
62
62
|
secret: true,
|
|
63
|
-
required:
|
|
63
|
+
required: true
|
|
64
64
|
})
|
|
65
65
|
};
|
|
66
66
|
|
|
@@ -244,7 +244,8 @@ var AUTH_TYPES = {
|
|
|
244
244
|
API_KEY: "api-key",
|
|
245
245
|
JWT: "jwt",
|
|
246
246
|
SERVICE_ACCOUNT: "service-account",
|
|
247
|
-
PAT: "pat"
|
|
247
|
+
PAT: "pat",
|
|
248
|
+
USER_PASSWORD: "user-password"
|
|
248
249
|
};
|
|
249
250
|
|
|
250
251
|
// ../connectors/src/connectors/google-ads-oauth/tools/list-customers.ts
|
|
@@ -583,7 +584,7 @@ var tools = {
|
|
|
583
584
|
var googleAdsOauthConnector = new ConnectorPlugin({
|
|
584
585
|
slug: "google-ads",
|
|
585
586
|
authType: AUTH_TYPES.OAUTH,
|
|
586
|
-
name: "Google Ads
|
|
587
|
+
name: "Google Ads",
|
|
587
588
|
description: "Connect to Google Ads for advertising campaign data and reporting using OAuth.",
|
|
588
589
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1NGvmgvCxX7Tn11EST2N3N/a745fe7c63d360ed40a27ddaad3af168/google-ads.svg",
|
|
589
590
|
parameters,
|
|
@@ -347,6 +347,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
347
347
|
}
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
+
// ../connectors/src/auth-types.ts
|
|
351
|
+
var AUTH_TYPES = {
|
|
352
|
+
OAUTH: "oauth",
|
|
353
|
+
API_KEY: "api-key",
|
|
354
|
+
JWT: "jwt",
|
|
355
|
+
SERVICE_ACCOUNT: "service-account",
|
|
356
|
+
PAT: "pat",
|
|
357
|
+
USER_PASSWORD: "user-password"
|
|
358
|
+
};
|
|
359
|
+
|
|
350
360
|
// ../connectors/src/connectors/google-ads/setup.ts
|
|
351
361
|
var googleAdsOnboarding = new ConnectorOnboarding({
|
|
352
362
|
dataOverviewInstructions: {
|
|
@@ -600,7 +610,7 @@ var tools = {
|
|
|
600
610
|
};
|
|
601
611
|
var googleAdsConnector = new ConnectorPlugin({
|
|
602
612
|
slug: "google-ads",
|
|
603
|
-
authType:
|
|
613
|
+
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
604
614
|
name: "Google Ads",
|
|
605
615
|
description: "Connect to Google Ads for advertising campaign data and reporting using a service account.",
|
|
606
616
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1NGvmgvCxX7Tn11EST2N3N/a745fe7c63d360ed40a27ddaad3af168/google-ads.svg",
|
|
@@ -241,7 +241,8 @@ var AUTH_TYPES = {
|
|
|
241
241
|
API_KEY: "api-key",
|
|
242
242
|
JWT: "jwt",
|
|
243
243
|
SERVICE_ACCOUNT: "service-account",
|
|
244
|
-
PAT: "pat"
|
|
244
|
+
PAT: "pat",
|
|
245
|
+
USER_PASSWORD: "user-password"
|
|
245
246
|
};
|
|
246
247
|
|
|
247
248
|
// ../connectors/src/connectors/google-analytics-oauth/tools/list-accounts.ts
|
|
@@ -649,7 +650,7 @@ var tools = {
|
|
|
649
650
|
var googleAnalyticsOauthConnector = new ConnectorPlugin({
|
|
650
651
|
slug: "google-analytics",
|
|
651
652
|
authType: AUTH_TYPES.OAUTH,
|
|
652
|
-
name: "Google Analytics
|
|
653
|
+
name: "Google Analytics",
|
|
653
654
|
description: "Connect to Google Analytics for web analytics and reporting using OAuth.",
|
|
654
655
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
|
|
655
656
|
parameters,
|
|
@@ -59,11 +59,11 @@ var parameters = {
|
|
|
59
59
|
propertyId: new ParameterDefinition({
|
|
60
60
|
slug: "property-id",
|
|
61
61
|
name: "Google Analytics Property ID",
|
|
62
|
-
description: "The Google Analytics 4 property ID (e.g., 123456789).",
|
|
62
|
+
description: "The Google Analytics 4 property ID (e.g., 123456789). Set during connection setup.",
|
|
63
63
|
envVarBaseKey: "GA_PROPERTY_ID",
|
|
64
64
|
type: "text",
|
|
65
65
|
secret: false,
|
|
66
|
-
required:
|
|
66
|
+
required: false
|
|
67
67
|
})
|
|
68
68
|
};
|
|
69
69
|
|
|
@@ -125,7 +125,7 @@ function createClient(params) {
|
|
|
125
125
|
}
|
|
126
126
|
let cachedToken = null;
|
|
127
127
|
let tokenExpiresAt = 0;
|
|
128
|
-
async function
|
|
128
|
+
async function getAccessToken2() {
|
|
129
129
|
const nowSec = Math.floor(Date.now() / 1e3);
|
|
130
130
|
if (cachedToken && nowSec < tokenExpiresAt - 60) {
|
|
131
131
|
return cachedToken;
|
|
@@ -156,7 +156,7 @@ function createClient(params) {
|
|
|
156
156
|
}
|
|
157
157
|
return {
|
|
158
158
|
async request(path2, init) {
|
|
159
|
-
const accessToken = await
|
|
159
|
+
const accessToken = await getAccessToken2();
|
|
160
160
|
const resolvedPath = path2.replace(/\{propertyId\}/g, propertyId);
|
|
161
161
|
const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
|
|
162
162
|
const headers = new Headers(init?.headers);
|
|
@@ -321,8 +321,240 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
321
321
|
}
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
+
// ../connectors/src/auth-types.ts
|
|
325
|
+
var AUTH_TYPES = {
|
|
326
|
+
OAUTH: "oauth",
|
|
327
|
+
API_KEY: "api-key",
|
|
328
|
+
JWT: "jwt",
|
|
329
|
+
SERVICE_ACCOUNT: "service-account",
|
|
330
|
+
PAT: "pat",
|
|
331
|
+
USER_PASSWORD: "user-password"
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// ../connectors/src/connectors/google-analytics/tools/list-accounts.ts
|
|
335
|
+
import { z } from "zod";
|
|
336
|
+
|
|
337
|
+
// ../connectors/src/connectors/google-analytics/tools/auth.ts
|
|
338
|
+
var SCOPES = [
|
|
339
|
+
"https://www.googleapis.com/auth/analytics.readonly"
|
|
340
|
+
];
|
|
341
|
+
async function getAccessToken(connection2) {
|
|
342
|
+
const { GoogleAuth } = await import("google-auth-library");
|
|
343
|
+
const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
344
|
+
const credentials = JSON.parse(
|
|
345
|
+
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
346
|
+
);
|
|
347
|
+
const auth = new GoogleAuth({
|
|
348
|
+
credentials,
|
|
349
|
+
scopes: SCOPES
|
|
350
|
+
});
|
|
351
|
+
const token = await auth.getAccessToken();
|
|
352
|
+
if (!token) {
|
|
353
|
+
throw new Error("Failed to obtain access token");
|
|
354
|
+
}
|
|
355
|
+
return token;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// ../connectors/src/connectors/google-analytics/tools/list-accounts.ts
|
|
359
|
+
var ADMIN_BASE_URL = "https://analyticsadmin.googleapis.com/v1beta/";
|
|
360
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
361
|
+
var inputSchema = z.object({
|
|
362
|
+
toolUseIntent: z.string().optional().describe(
|
|
363
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
364
|
+
),
|
|
365
|
+
connectionId: z.string().describe("ID of the Google Analytics connection to use")
|
|
366
|
+
});
|
|
367
|
+
var outputSchema = z.discriminatedUnion("success", [
|
|
368
|
+
z.object({
|
|
369
|
+
success: z.literal(true),
|
|
370
|
+
accounts: z.array(
|
|
371
|
+
z.object({
|
|
372
|
+
name: z.string(),
|
|
373
|
+
displayName: z.string()
|
|
374
|
+
})
|
|
375
|
+
)
|
|
376
|
+
}),
|
|
377
|
+
z.object({
|
|
378
|
+
success: z.literal(false),
|
|
379
|
+
error: z.string()
|
|
380
|
+
})
|
|
381
|
+
]);
|
|
382
|
+
var listAccountsTool = new ConnectorTool({
|
|
383
|
+
name: "listAccounts",
|
|
384
|
+
description: "List Google Analytics accounts accessible with the service account credentials. Returns account names and display names.",
|
|
385
|
+
inputSchema,
|
|
386
|
+
outputSchema,
|
|
387
|
+
async execute({ connectionId }, connections) {
|
|
388
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
389
|
+
if (!connection2) {
|
|
390
|
+
return {
|
|
391
|
+
success: false,
|
|
392
|
+
error: `Connection ${connectionId} not found`
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
console.log(
|
|
396
|
+
`[connector-request] google-analytics/${connection2.name}: listAccounts`
|
|
397
|
+
);
|
|
398
|
+
try {
|
|
399
|
+
const token = await getAccessToken(connection2);
|
|
400
|
+
const controller = new AbortController();
|
|
401
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
402
|
+
try {
|
|
403
|
+
const response = await fetch(`${ADMIN_BASE_URL}accounts`, {
|
|
404
|
+
method: "GET",
|
|
405
|
+
headers: {
|
|
406
|
+
Authorization: `Bearer ${token}`
|
|
407
|
+
},
|
|
408
|
+
signal: controller.signal
|
|
409
|
+
});
|
|
410
|
+
const data = await response.json();
|
|
411
|
+
if (!response.ok) {
|
|
412
|
+
const errorMessage = data?.error?.message ?? `HTTP ${response.status} ${response.statusText}`;
|
|
413
|
+
return { success: false, error: errorMessage };
|
|
414
|
+
}
|
|
415
|
+
const accounts = (data.accounts ?? []).map((a) => ({
|
|
416
|
+
name: a.name ?? "",
|
|
417
|
+
displayName: a.displayName ?? ""
|
|
418
|
+
}));
|
|
419
|
+
return { success: true, accounts };
|
|
420
|
+
} finally {
|
|
421
|
+
clearTimeout(timeout);
|
|
422
|
+
}
|
|
423
|
+
} catch (err) {
|
|
424
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
425
|
+
return { success: false, error: msg };
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// ../connectors/src/connectors/google-analytics/tools/list-properties.ts
|
|
431
|
+
import { z as z2 } from "zod";
|
|
432
|
+
var ADMIN_BASE_URL2 = "https://analyticsadmin.googleapis.com/v1beta/";
|
|
433
|
+
var REQUEST_TIMEOUT_MS2 = 6e4;
|
|
434
|
+
var inputSchema2 = z2.object({
|
|
435
|
+
toolUseIntent: z2.string().optional().describe(
|
|
436
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
437
|
+
),
|
|
438
|
+
connectionId: z2.string().describe("ID of the Google Analytics connection to use"),
|
|
439
|
+
accountName: z2.string().describe(
|
|
440
|
+
"The account resource name (e.g., 'accounts/123456'). Obtained from the listAccounts tool."
|
|
441
|
+
)
|
|
442
|
+
});
|
|
443
|
+
var outputSchema2 = z2.discriminatedUnion("success", [
|
|
444
|
+
z2.object({
|
|
445
|
+
success: z2.literal(true),
|
|
446
|
+
properties: z2.array(
|
|
447
|
+
z2.object({
|
|
448
|
+
name: z2.string(),
|
|
449
|
+
displayName: z2.string(),
|
|
450
|
+
propertyId: z2.string()
|
|
451
|
+
})
|
|
452
|
+
)
|
|
453
|
+
}),
|
|
454
|
+
z2.object({
|
|
455
|
+
success: z2.literal(false),
|
|
456
|
+
error: z2.string()
|
|
457
|
+
})
|
|
458
|
+
]);
|
|
459
|
+
var listPropertiesTool = new ConnectorTool({
|
|
460
|
+
name: "listProperties",
|
|
461
|
+
description: "List GA4 properties for a given Google Analytics account. Returns property names, display names, and property IDs.",
|
|
462
|
+
inputSchema: inputSchema2,
|
|
463
|
+
outputSchema: outputSchema2,
|
|
464
|
+
async execute({ connectionId, accountName }, connections) {
|
|
465
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
466
|
+
if (!connection2) {
|
|
467
|
+
return {
|
|
468
|
+
success: false,
|
|
469
|
+
error: `Connection ${connectionId} not found`
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
console.log(
|
|
473
|
+
`[connector-request] google-analytics/${connection2.name}: listProperties for ${accountName}`
|
|
474
|
+
);
|
|
475
|
+
try {
|
|
476
|
+
const token = await getAccessToken(connection2);
|
|
477
|
+
const controller = new AbortController();
|
|
478
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS2);
|
|
479
|
+
try {
|
|
480
|
+
const filter = encodeURIComponent(`parent:${accountName}`);
|
|
481
|
+
const response = await fetch(
|
|
482
|
+
`${ADMIN_BASE_URL2}properties?filter=${filter}`,
|
|
483
|
+
{
|
|
484
|
+
method: "GET",
|
|
485
|
+
headers: {
|
|
486
|
+
Authorization: `Bearer ${token}`
|
|
487
|
+
},
|
|
488
|
+
signal: controller.signal
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
const data = await response.json();
|
|
492
|
+
if (!response.ok) {
|
|
493
|
+
const errorMessage = data?.error?.message ?? `HTTP ${response.status} ${response.statusText}`;
|
|
494
|
+
return { success: false, error: errorMessage };
|
|
495
|
+
}
|
|
496
|
+
const properties = (data.properties ?? []).map((p) => {
|
|
497
|
+
const name = p.name ?? "";
|
|
498
|
+
const propertyId = name.replace(/^properties\//, "");
|
|
499
|
+
return {
|
|
500
|
+
name,
|
|
501
|
+
displayName: p.displayName ?? "",
|
|
502
|
+
propertyId
|
|
503
|
+
};
|
|
504
|
+
});
|
|
505
|
+
return { success: true, properties };
|
|
506
|
+
} finally {
|
|
507
|
+
clearTimeout(timeout);
|
|
508
|
+
}
|
|
509
|
+
} catch (err) {
|
|
510
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
511
|
+
return { success: false, error: msg };
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
|
|
324
516
|
// ../connectors/src/connectors/google-analytics/setup.ts
|
|
517
|
+
var listAccountsToolName = `google-analytics_${listAccountsTool.name}`;
|
|
518
|
+
var listPropertiesToolName = `google-analytics_${listPropertiesTool.name}`;
|
|
325
519
|
var googleAnalyticsOnboarding = new ConnectorOnboarding({
|
|
520
|
+
connectionSetupInstructions: {
|
|
521
|
+
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Analytics (Service Account) \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
522
|
+
|
|
523
|
+
1. \`${listAccountsToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001Service Account\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGoogle Analytics\u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
524
|
+
2. \u300C\u4F7F\u7528\u3059\u308B\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059:
|
|
525
|
+
- \`options\`: \u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (name)\` \u306E\u5F62\u5F0F
|
|
526
|
+
3. \`${listPropertiesToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u9078\u629E\u3055\u308C\u305F\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
527
|
+
4. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
528
|
+
- \`parameterSlug\`: \`"property-id"\`
|
|
529
|
+
- \`options\`: \u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (id: \u30D7\u30ED\u30D1\u30C6\u30A3ID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30D7\u30ED\u30D1\u30C6\u30A3ID
|
|
530
|
+
5. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E \`label\` \u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u5C4A\u304F\u306E\u3067\u3001\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080
|
|
531
|
+
6. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
532
|
+
- \`property\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u8868\u793A\u540D
|
|
533
|
+
- \`propertyId\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3ID
|
|
534
|
+
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
535
|
+
|
|
536
|
+
#### \u5236\u7D04
|
|
537
|
+
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30EC\u30DD\u30FC\u30C8\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\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\u306E\u307F
|
|
538
|
+
- \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`,
|
|
539
|
+
en: `Follow these steps to set up the Google Analytics (Service Account) connection.
|
|
540
|
+
|
|
541
|
+
1. Call \`${listAccountsToolName}\` to get the list of Google Analytics accounts accessible with the service account credentials
|
|
542
|
+
2. Tell the user "Please select an account.", then call \`askUserQuestion\`:
|
|
543
|
+
- \`options\`: The account list. Each option's \`label\` should be \`Display Name (name)\`
|
|
544
|
+
3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
|
|
545
|
+
4. Call \`updateConnectionParameters\`:
|
|
546
|
+
- \`parameterSlug\`: \`"property-id"\`
|
|
547
|
+
- \`options\`: The property list. Each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID
|
|
548
|
+
5. The \`label\` of the user's selected property will arrive as a message. Proceed to the next step
|
|
549
|
+
6. Call \`updateConnectionContext\`:
|
|
550
|
+
- \`property\`: The selected property's display name
|
|
551
|
+
- \`propertyId\`: The selected property ID
|
|
552
|
+
- \`note\`: Brief description of the setup
|
|
553
|
+
|
|
554
|
+
#### Constraints
|
|
555
|
+
- **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
|
|
556
|
+
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
557
|
+
},
|
|
326
558
|
dataOverviewInstructions: {
|
|
327
559
|
en: `1. Call google-analytics_request with GET properties/{propertyId}/metadata to list available dimensions and metrics
|
|
328
560
|
2. Call google-analytics_request with POST properties/{propertyId}:runReport using a small date range and basic metrics to verify data availability`,
|
|
@@ -332,25 +564,25 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
|
|
|
332
564
|
});
|
|
333
565
|
|
|
334
566
|
// ../connectors/src/connectors/google-analytics/tools/request.ts
|
|
335
|
-
import { z } from "zod";
|
|
567
|
+
import { z as z3 } from "zod";
|
|
336
568
|
var BASE_URL2 = "https://analyticsdata.googleapis.com/v1beta/";
|
|
337
|
-
var
|
|
338
|
-
var
|
|
339
|
-
toolUseIntent:
|
|
340
|
-
connectionId:
|
|
341
|
-
method:
|
|
342
|
-
path:
|
|
343
|
-
body:
|
|
569
|
+
var REQUEST_TIMEOUT_MS3 = 6e4;
|
|
570
|
+
var inputSchema3 = z3.object({
|
|
571
|
+
toolUseIntent: z3.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
|
|
572
|
+
connectionId: z3.string().describe("ID of the Google Analytics connection to use"),
|
|
573
|
+
method: z3.enum(["GET", "POST"]).describe("HTTP method"),
|
|
574
|
+
path: z3.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
|
|
575
|
+
body: z3.record(z3.string(), z3.unknown()).optional().describe("POST request body (JSON)")
|
|
344
576
|
});
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
success:
|
|
348
|
-
status:
|
|
349
|
-
data:
|
|
577
|
+
var outputSchema3 = z3.discriminatedUnion("success", [
|
|
578
|
+
z3.object({
|
|
579
|
+
success: z3.literal(true),
|
|
580
|
+
status: z3.number(),
|
|
581
|
+
data: z3.record(z3.string(), z3.unknown())
|
|
350
582
|
}),
|
|
351
|
-
|
|
352
|
-
success:
|
|
353
|
-
error:
|
|
583
|
+
z3.object({
|
|
584
|
+
success: z3.literal(false),
|
|
585
|
+
error: z3.string()
|
|
354
586
|
})
|
|
355
587
|
]);
|
|
356
588
|
var requestTool = new ConnectorTool({
|
|
@@ -358,8 +590,8 @@ var requestTool = new ConnectorTool({
|
|
|
358
590
|
description: `Send authenticated requests to the Google Analytics Data API.
|
|
359
591
|
Authentication is handled automatically using a service account.
|
|
360
592
|
{propertyId} in the path is automatically replaced with the connection's property-id.`,
|
|
361
|
-
inputSchema,
|
|
362
|
-
outputSchema,
|
|
593
|
+
inputSchema: inputSchema3,
|
|
594
|
+
outputSchema: outputSchema3,
|
|
363
595
|
async execute({ connectionId, method, path: path2, body }, connections) {
|
|
364
596
|
const connection2 = connections.find((c) => c.id === connectionId);
|
|
365
597
|
if (!connection2) {
|
|
@@ -369,7 +601,7 @@ Authentication is handled automatically using a service account.
|
|
|
369
601
|
try {
|
|
370
602
|
const { GoogleAuth } = await import("google-auth-library");
|
|
371
603
|
const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
372
|
-
const propertyId = parameters.propertyId.
|
|
604
|
+
const propertyId = parameters.propertyId.tryGetValue(connection2);
|
|
373
605
|
const credentials = JSON.parse(
|
|
374
606
|
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
375
607
|
);
|
|
@@ -381,10 +613,10 @@ Authentication is handled automatically using a service account.
|
|
|
381
613
|
if (!token) {
|
|
382
614
|
return { success: false, error: "Failed to obtain access token" };
|
|
383
615
|
}
|
|
384
|
-
const resolvedPath = path2.replace(/\{propertyId\}/g, propertyId);
|
|
616
|
+
const resolvedPath = propertyId ? path2.replace(/\{propertyId\}/g, propertyId) : path2;
|
|
385
617
|
const url = `${BASE_URL2}${resolvedPath}`;
|
|
386
618
|
const controller = new AbortController();
|
|
387
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
619
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS3);
|
|
388
620
|
try {
|
|
389
621
|
const response = await fetch(url, {
|
|
390
622
|
method,
|
|
@@ -415,10 +647,14 @@ Authentication is handled automatically using a service account.
|
|
|
415
647
|
});
|
|
416
648
|
|
|
417
649
|
// ../connectors/src/connectors/google-analytics/index.ts
|
|
418
|
-
var tools = {
|
|
650
|
+
var tools = {
|
|
651
|
+
request: requestTool,
|
|
652
|
+
listAccounts: listAccountsTool,
|
|
653
|
+
listProperties: listPropertiesTool
|
|
654
|
+
};
|
|
419
655
|
var googleAnalyticsConnector = new ConnectorPlugin({
|
|
420
656
|
slug: "google-analytics",
|
|
421
|
-
authType:
|
|
657
|
+
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
422
658
|
name: "Google Analytics",
|
|
423
659
|
description: "Connect to Google Analytics for web analytics and reporting.",
|
|
424
660
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
|
|
@@ -429,6 +665,8 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
429
665
|
en: `### Tools
|
|
430
666
|
|
|
431
667
|
- \`google-analytics_request\`: The only way to call the GA4 Data API. Use it to fetch metadata, run reports, or run realtime reports. See the GA4 Data API Reference below for available endpoints and request bodies.
|
|
668
|
+
- \`google-analytics_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
|
|
669
|
+
- \`google-analytics_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
|
|
432
670
|
|
|
433
671
|
### Business Logic
|
|
434
672
|
|
|
@@ -497,6 +735,8 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
497
735
|
ja: `### \u30C4\u30FC\u30EB
|
|
498
736
|
|
|
499
737
|
- \`google-analytics_request\`: GA4 Data API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306F\u4E0B\u90E8\u306E\u300CGA4 Data API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u300D\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
738
|
+
- \`google-analytics_listAccounts\`: \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGoogle Analytics\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u5229\u7528\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u78BA\u8A8D\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
|
|
739
|
+
- \`google-analytics_listProperties\`: \u6307\u5B9A\u30A2\u30AB\u30A6\u30F3\u30C8\u306EGA4\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u30BF\u30FC\u30B2\u30C3\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
|
|
500
740
|
|
|
501
741
|
### Business Logic
|
|
502
742
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
|
|
2
2
|
|
|
3
|
-
declare const connection: (connectionId: string) => _squadbase_connectors_sdk.
|
|
3
|
+
declare const connection: (connectionId: string) => _squadbase_connectors_sdk.GoogleCalendarOauthConnectorSdk;
|
|
4
4
|
|
|
5
5
|
export { connection };
|