@squadbase/vite-server 0.1.3-dev.5 → 0.1.3-dev.7
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 +2097 -1441
- package/dist/connectors/gmail.d.ts +5 -0
- package/dist/connectors/gmail.js +802 -0
- package/dist/connectors/google-ads-oauth.js +1 -1
- package/dist/connectors/google-analytics.js +259 -35
- package/dist/connectors/google-calendar-oauth.js +1 -1
- package/dist/connectors/google-calendar.d.ts +8 -1
- package/dist/connectors/google-calendar.js +115 -31
- package/dist/connectors/google-sheets-oauth.js +66 -23
- package/dist/connectors/google-sheets.js +33 -7
- package/dist/connectors/grafana.d.ts +5 -0
- package/dist/connectors/grafana.js +565 -0
- package/dist/index.js +2095 -1439
- package/dist/main.js +2095 -1439
- package/dist/vite-plugin.js +2095 -1439
- package/package.json +9 -1
|
@@ -55,17 +55,9 @@ var parameters = {
|
|
|
55
55
|
type: "base64EncodedJson",
|
|
56
56
|
secret: true,
|
|
57
57
|
required: true
|
|
58
|
-
}),
|
|
59
|
-
propertyId: new ParameterDefinition({
|
|
60
|
-
slug: "property-id",
|
|
61
|
-
name: "Google Analytics Property ID",
|
|
62
|
-
description: "The Google Analytics 4 property ID (e.g., 123456789).",
|
|
63
|
-
envVarBaseKey: "GA_PROPERTY_ID",
|
|
64
|
-
type: "text",
|
|
65
|
-
secret: false,
|
|
66
|
-
required: true
|
|
67
58
|
})
|
|
68
59
|
};
|
|
60
|
+
var PROPERTY_ID_SLUG = "property-id";
|
|
69
61
|
|
|
70
62
|
// ../connectors/src/connectors/google-analytics/sdk/index.ts
|
|
71
63
|
var TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
@@ -95,11 +87,11 @@ function buildJwt(clientEmail, privateKey, nowSec) {
|
|
|
95
87
|
}
|
|
96
88
|
function createClient(params) {
|
|
97
89
|
const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
|
|
98
|
-
const propertyId = params[
|
|
90
|
+
const propertyId = params[PROPERTY_ID_SLUG];
|
|
99
91
|
if (!serviceAccountKeyJsonBase64 || !propertyId) {
|
|
100
92
|
const required = [
|
|
101
93
|
parameters.serviceAccountKeyJsonBase64.slug,
|
|
102
|
-
|
|
94
|
+
PROPERTY_ID_SLUG
|
|
103
95
|
];
|
|
104
96
|
const missing = required.filter((s) => !params[s]);
|
|
105
97
|
throw new Error(
|
|
@@ -125,7 +117,7 @@ function createClient(params) {
|
|
|
125
117
|
}
|
|
126
118
|
let cachedToken = null;
|
|
127
119
|
let tokenExpiresAt = 0;
|
|
128
|
-
async function
|
|
120
|
+
async function getAccessToken2() {
|
|
129
121
|
const nowSec = Math.floor(Date.now() / 1e3);
|
|
130
122
|
if (cachedToken && nowSec < tokenExpiresAt - 60) {
|
|
131
123
|
return cachedToken;
|
|
@@ -156,7 +148,7 @@ function createClient(params) {
|
|
|
156
148
|
}
|
|
157
149
|
return {
|
|
158
150
|
async request(path2, init) {
|
|
159
|
-
const accessToken = await
|
|
151
|
+
const accessToken = await getAccessToken2();
|
|
160
152
|
const resolvedPath = path2.replace(/\{propertyId\}/g, propertyId);
|
|
161
153
|
const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
|
|
162
154
|
const headers = new Headers(init?.headers);
|
|
@@ -331,8 +323,230 @@ var AUTH_TYPES = {
|
|
|
331
323
|
USER_PASSWORD: "user-password"
|
|
332
324
|
};
|
|
333
325
|
|
|
326
|
+
// ../connectors/src/connectors/google-analytics/tools/list-accounts.ts
|
|
327
|
+
import { z } from "zod";
|
|
328
|
+
|
|
329
|
+
// ../connectors/src/connectors/google-analytics/tools/auth.ts
|
|
330
|
+
var SCOPES = [
|
|
331
|
+
"https://www.googleapis.com/auth/analytics.readonly"
|
|
332
|
+
];
|
|
333
|
+
async function getAccessToken(connection2) {
|
|
334
|
+
const { GoogleAuth } = await import("google-auth-library");
|
|
335
|
+
const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
336
|
+
const credentials = JSON.parse(
|
|
337
|
+
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
338
|
+
);
|
|
339
|
+
const auth = new GoogleAuth({
|
|
340
|
+
credentials,
|
|
341
|
+
scopes: SCOPES
|
|
342
|
+
});
|
|
343
|
+
const token = await auth.getAccessToken();
|
|
344
|
+
if (!token) {
|
|
345
|
+
throw new Error("Failed to obtain access token");
|
|
346
|
+
}
|
|
347
|
+
return token;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ../connectors/src/connectors/google-analytics/tools/list-accounts.ts
|
|
351
|
+
var ADMIN_BASE_URL = "https://analyticsadmin.googleapis.com/v1beta/";
|
|
352
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
353
|
+
var inputSchema = z.object({
|
|
354
|
+
toolUseIntent: z.string().optional().describe(
|
|
355
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
356
|
+
),
|
|
357
|
+
connectionId: z.string().describe("ID of the Google Analytics connection to use")
|
|
358
|
+
});
|
|
359
|
+
var outputSchema = z.discriminatedUnion("success", [
|
|
360
|
+
z.object({
|
|
361
|
+
success: z.literal(true),
|
|
362
|
+
accounts: z.array(
|
|
363
|
+
z.object({
|
|
364
|
+
name: z.string(),
|
|
365
|
+
displayName: z.string()
|
|
366
|
+
})
|
|
367
|
+
)
|
|
368
|
+
}),
|
|
369
|
+
z.object({
|
|
370
|
+
success: z.literal(false),
|
|
371
|
+
error: z.string()
|
|
372
|
+
})
|
|
373
|
+
]);
|
|
374
|
+
var listAccountsTool = new ConnectorTool({
|
|
375
|
+
name: "listAccounts",
|
|
376
|
+
description: "List Google Analytics accounts accessible with the service account credentials. Returns account names and display names.",
|
|
377
|
+
inputSchema,
|
|
378
|
+
outputSchema,
|
|
379
|
+
async execute({ connectionId }, connections) {
|
|
380
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
381
|
+
if (!connection2) {
|
|
382
|
+
return {
|
|
383
|
+
success: false,
|
|
384
|
+
error: `Connection ${connectionId} not found`
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
console.log(
|
|
388
|
+
`[connector-request] google-analytics/${connection2.name}: listAccounts`
|
|
389
|
+
);
|
|
390
|
+
try {
|
|
391
|
+
const token = await getAccessToken(connection2);
|
|
392
|
+
const controller = new AbortController();
|
|
393
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
394
|
+
try {
|
|
395
|
+
const response = await fetch(`${ADMIN_BASE_URL}accounts`, {
|
|
396
|
+
method: "GET",
|
|
397
|
+
headers: {
|
|
398
|
+
Authorization: `Bearer ${token}`
|
|
399
|
+
},
|
|
400
|
+
signal: controller.signal
|
|
401
|
+
});
|
|
402
|
+
const data = await response.json();
|
|
403
|
+
if (!response.ok) {
|
|
404
|
+
const errorMessage = data?.error?.message ?? `HTTP ${response.status} ${response.statusText}`;
|
|
405
|
+
return { success: false, error: errorMessage };
|
|
406
|
+
}
|
|
407
|
+
const accounts = (data.accounts ?? []).map((a) => ({
|
|
408
|
+
name: a.name ?? "",
|
|
409
|
+
displayName: a.displayName ?? ""
|
|
410
|
+
}));
|
|
411
|
+
return { success: true, accounts };
|
|
412
|
+
} finally {
|
|
413
|
+
clearTimeout(timeout);
|
|
414
|
+
}
|
|
415
|
+
} catch (err) {
|
|
416
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
417
|
+
return { success: false, error: msg };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// ../connectors/src/connectors/google-analytics/tools/list-properties.ts
|
|
423
|
+
import { z as z2 } from "zod";
|
|
424
|
+
var ADMIN_BASE_URL2 = "https://analyticsadmin.googleapis.com/v1beta/";
|
|
425
|
+
var REQUEST_TIMEOUT_MS2 = 6e4;
|
|
426
|
+
var inputSchema2 = z2.object({
|
|
427
|
+
toolUseIntent: z2.string().optional().describe(
|
|
428
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
429
|
+
),
|
|
430
|
+
connectionId: z2.string().describe("ID of the Google Analytics connection to use"),
|
|
431
|
+
accountName: z2.string().describe(
|
|
432
|
+
"The account resource name (e.g., 'accounts/123456'). Obtained from the listAccounts tool."
|
|
433
|
+
)
|
|
434
|
+
});
|
|
435
|
+
var outputSchema2 = z2.discriminatedUnion("success", [
|
|
436
|
+
z2.object({
|
|
437
|
+
success: z2.literal(true),
|
|
438
|
+
properties: z2.array(
|
|
439
|
+
z2.object({
|
|
440
|
+
name: z2.string(),
|
|
441
|
+
displayName: z2.string(),
|
|
442
|
+
propertyId: z2.string()
|
|
443
|
+
})
|
|
444
|
+
)
|
|
445
|
+
}),
|
|
446
|
+
z2.object({
|
|
447
|
+
success: z2.literal(false),
|
|
448
|
+
error: z2.string()
|
|
449
|
+
})
|
|
450
|
+
]);
|
|
451
|
+
var listPropertiesTool = new ConnectorTool({
|
|
452
|
+
name: "listProperties",
|
|
453
|
+
description: "List GA4 properties for a given Google Analytics account. Returns property names, display names, and property IDs.",
|
|
454
|
+
inputSchema: inputSchema2,
|
|
455
|
+
outputSchema: outputSchema2,
|
|
456
|
+
async execute({ connectionId, accountName }, connections) {
|
|
457
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
458
|
+
if (!connection2) {
|
|
459
|
+
return {
|
|
460
|
+
success: false,
|
|
461
|
+
error: `Connection ${connectionId} not found`
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
console.log(
|
|
465
|
+
`[connector-request] google-analytics/${connection2.name}: listProperties for ${accountName}`
|
|
466
|
+
);
|
|
467
|
+
try {
|
|
468
|
+
const token = await getAccessToken(connection2);
|
|
469
|
+
const controller = new AbortController();
|
|
470
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS2);
|
|
471
|
+
try {
|
|
472
|
+
const filter = encodeURIComponent(`parent:${accountName}`);
|
|
473
|
+
const response = await fetch(
|
|
474
|
+
`${ADMIN_BASE_URL2}properties?filter=${filter}`,
|
|
475
|
+
{
|
|
476
|
+
method: "GET",
|
|
477
|
+
headers: {
|
|
478
|
+
Authorization: `Bearer ${token}`
|
|
479
|
+
},
|
|
480
|
+
signal: controller.signal
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
const data = await response.json();
|
|
484
|
+
if (!response.ok) {
|
|
485
|
+
const errorMessage = data?.error?.message ?? `HTTP ${response.status} ${response.statusText}`;
|
|
486
|
+
return { success: false, error: errorMessage };
|
|
487
|
+
}
|
|
488
|
+
const properties = (data.properties ?? []).map((p) => {
|
|
489
|
+
const name = p.name ?? "";
|
|
490
|
+
const propertyId = name.replace(/^properties\//, "");
|
|
491
|
+
return {
|
|
492
|
+
name,
|
|
493
|
+
displayName: p.displayName ?? "",
|
|
494
|
+
propertyId
|
|
495
|
+
};
|
|
496
|
+
});
|
|
497
|
+
return { success: true, properties };
|
|
498
|
+
} finally {
|
|
499
|
+
clearTimeout(timeout);
|
|
500
|
+
}
|
|
501
|
+
} catch (err) {
|
|
502
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
503
|
+
return { success: false, error: msg };
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
|
|
334
508
|
// ../connectors/src/connectors/google-analytics/setup.ts
|
|
509
|
+
var listAccountsToolName = `google-analytics_${listAccountsTool.name}`;
|
|
510
|
+
var listPropertiesToolName = `google-analytics_${listPropertiesTool.name}`;
|
|
335
511
|
var googleAnalyticsOnboarding = new ConnectorOnboarding({
|
|
512
|
+
connectionSetupInstructions: {
|
|
513
|
+
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
|
|
514
|
+
|
|
515
|
+
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
|
|
516
|
+
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:
|
|
517
|
+
- \`options\`: \u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (name)\` \u306E\u5F62\u5F0F
|
|
518
|
+
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
|
|
519
|
+
4. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
520
|
+
- \`parameterSlug\`: \`"property-id"\`
|
|
521
|
+
- \`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
|
|
522
|
+
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
|
|
523
|
+
6. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
524
|
+
- \`property\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u8868\u793A\u540D
|
|
525
|
+
- \`propertyId\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3ID
|
|
526
|
+
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
527
|
+
|
|
528
|
+
#### \u5236\u7D04
|
|
529
|
+
- **\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
|
|
530
|
+
- \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`,
|
|
531
|
+
en: `Follow these steps to set up the Google Analytics (Service Account) connection.
|
|
532
|
+
|
|
533
|
+
1. Call \`${listAccountsToolName}\` to get the list of Google Analytics accounts accessible with the service account credentials
|
|
534
|
+
2. Tell the user "Please select an account.", then call \`askUserQuestion\`:
|
|
535
|
+
- \`options\`: The account list. Each option's \`label\` should be \`Display Name (name)\`
|
|
536
|
+
3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
|
|
537
|
+
4. Call \`updateConnectionParameters\`:
|
|
538
|
+
- \`parameterSlug\`: \`"property-id"\`
|
|
539
|
+
- \`options\`: The property list. Each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID
|
|
540
|
+
5. The \`label\` of the user's selected property will arrive as a message. Proceed to the next step
|
|
541
|
+
6. Call \`updateConnectionContext\`:
|
|
542
|
+
- \`property\`: The selected property's display name
|
|
543
|
+
- \`propertyId\`: The selected property ID
|
|
544
|
+
- \`note\`: Brief description of the setup
|
|
545
|
+
|
|
546
|
+
#### Constraints
|
|
547
|
+
- **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
|
|
548
|
+
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
549
|
+
},
|
|
336
550
|
dataOverviewInstructions: {
|
|
337
551
|
en: `1. Call google-analytics_request with GET properties/{propertyId}/metadata to list available dimensions and metrics
|
|
338
552
|
2. Call google-analytics_request with POST properties/{propertyId}:runReport using a small date range and basic metrics to verify data availability`,
|
|
@@ -342,25 +556,25 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
|
|
|
342
556
|
});
|
|
343
557
|
|
|
344
558
|
// ../connectors/src/connectors/google-analytics/tools/request.ts
|
|
345
|
-
import { z } from "zod";
|
|
559
|
+
import { z as z3 } from "zod";
|
|
346
560
|
var BASE_URL2 = "https://analyticsdata.googleapis.com/v1beta/";
|
|
347
|
-
var
|
|
348
|
-
var
|
|
349
|
-
toolUseIntent:
|
|
350
|
-
connectionId:
|
|
351
|
-
method:
|
|
352
|
-
path:
|
|
353
|
-
body:
|
|
561
|
+
var REQUEST_TIMEOUT_MS3 = 6e4;
|
|
562
|
+
var inputSchema3 = z3.object({
|
|
563
|
+
toolUseIntent: z3.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
|
|
564
|
+
connectionId: z3.string().describe("ID of the Google Analytics connection to use"),
|
|
565
|
+
method: z3.enum(["GET", "POST"]).describe("HTTP method"),
|
|
566
|
+
path: z3.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
|
|
567
|
+
body: z3.record(z3.string(), z3.unknown()).optional().describe("POST request body (JSON)")
|
|
354
568
|
});
|
|
355
|
-
var
|
|
356
|
-
|
|
357
|
-
success:
|
|
358
|
-
status:
|
|
359
|
-
data:
|
|
569
|
+
var outputSchema3 = z3.discriminatedUnion("success", [
|
|
570
|
+
z3.object({
|
|
571
|
+
success: z3.literal(true),
|
|
572
|
+
status: z3.number(),
|
|
573
|
+
data: z3.record(z3.string(), z3.unknown())
|
|
360
574
|
}),
|
|
361
|
-
|
|
362
|
-
success:
|
|
363
|
-
error:
|
|
575
|
+
z3.object({
|
|
576
|
+
success: z3.literal(false),
|
|
577
|
+
error: z3.string()
|
|
364
578
|
})
|
|
365
579
|
]);
|
|
366
580
|
var requestTool = new ConnectorTool({
|
|
@@ -368,8 +582,8 @@ var requestTool = new ConnectorTool({
|
|
|
368
582
|
description: `Send authenticated requests to the Google Analytics Data API.
|
|
369
583
|
Authentication is handled automatically using a service account.
|
|
370
584
|
{propertyId} in the path is automatically replaced with the connection's property-id.`,
|
|
371
|
-
inputSchema,
|
|
372
|
-
outputSchema,
|
|
585
|
+
inputSchema: inputSchema3,
|
|
586
|
+
outputSchema: outputSchema3,
|
|
373
587
|
async execute({ connectionId, method, path: path2, body }, connections) {
|
|
374
588
|
const connection2 = connections.find((c) => c.id === connectionId);
|
|
375
589
|
if (!connection2) {
|
|
@@ -379,7 +593,9 @@ Authentication is handled automatically using a service account.
|
|
|
379
593
|
try {
|
|
380
594
|
const { GoogleAuth } = await import("google-auth-library");
|
|
381
595
|
const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
382
|
-
const propertyId = parameters.
|
|
596
|
+
const propertyId = connection2.parameters.find(
|
|
597
|
+
(p) => p.parameterSlug === PROPERTY_ID_SLUG
|
|
598
|
+
)?.value ?? void 0;
|
|
383
599
|
const credentials = JSON.parse(
|
|
384
600
|
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
385
601
|
);
|
|
@@ -391,10 +607,10 @@ Authentication is handled automatically using a service account.
|
|
|
391
607
|
if (!token) {
|
|
392
608
|
return { success: false, error: "Failed to obtain access token" };
|
|
393
609
|
}
|
|
394
|
-
const resolvedPath = path2.replace(/\{propertyId\}/g, propertyId);
|
|
610
|
+
const resolvedPath = propertyId ? path2.replace(/\{propertyId\}/g, propertyId) : path2;
|
|
395
611
|
const url = `${BASE_URL2}${resolvedPath}`;
|
|
396
612
|
const controller = new AbortController();
|
|
397
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
613
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS3);
|
|
398
614
|
try {
|
|
399
615
|
const response = await fetch(url, {
|
|
400
616
|
method,
|
|
@@ -425,7 +641,11 @@ Authentication is handled automatically using a service account.
|
|
|
425
641
|
});
|
|
426
642
|
|
|
427
643
|
// ../connectors/src/connectors/google-analytics/index.ts
|
|
428
|
-
var tools = {
|
|
644
|
+
var tools = {
|
|
645
|
+
request: requestTool,
|
|
646
|
+
listAccounts: listAccountsTool,
|
|
647
|
+
listProperties: listPropertiesTool
|
|
648
|
+
};
|
|
429
649
|
var googleAnalyticsConnector = new ConnectorPlugin({
|
|
430
650
|
slug: "google-analytics",
|
|
431
651
|
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
@@ -439,6 +659,8 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
439
659
|
en: `### Tools
|
|
440
660
|
|
|
441
661
|
- \`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.
|
|
662
|
+
- \`google-analytics_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
|
|
663
|
+
- \`google-analytics_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
|
|
442
664
|
|
|
443
665
|
### Business Logic
|
|
444
666
|
|
|
@@ -507,6 +729,8 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
507
729
|
ja: `### \u30C4\u30FC\u30EB
|
|
508
730
|
|
|
509
731
|
- \`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
|
|
732
|
+
- \`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
|
|
733
|
+
- \`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
|
|
510
734
|
|
|
511
735
|
### Business Logic
|
|
512
736
|
|
|
@@ -526,7 +526,7 @@ var googleCalendarOauthConnector = new ConnectorPlugin({
|
|
|
526
526
|
authType: AUTH_TYPES.OAUTH,
|
|
527
527
|
name: "Google Calendar",
|
|
528
528
|
description: "Connect to Google Calendar for calendar and event data access using OAuth.",
|
|
529
|
-
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/
|
|
529
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2YsqoBEpdELmfDeFcyGHyE/4494c633b5ae15e562cb739cd85442c1/google-calendar.png",
|
|
530
530
|
parameters,
|
|
531
531
|
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
532
532
|
onboarding: googleCalendarOauthOnboarding,
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
|
|
2
|
+
import { GoogleCalendarClientOptions } from '@squadbase/connectors/sdk';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Create a Google Calendar SDK client for the given connection.
|
|
6
|
+
*
|
|
7
|
+
* @param connectionId - The connection ID from .squadbase/connections.json
|
|
8
|
+
* @param options - Optional configuration (e.g., subject for Domain-wide Delegation)
|
|
9
|
+
*/
|
|
10
|
+
declare const connection: (connectionId: string, options?: GoogleCalendarClientOptions) => _squadbase_connectors_sdk.GoogleCalendarConnectorSdk;
|
|
4
11
|
|
|
5
12
|
export { connection };
|