@squadbase/vite-server 0.1.17-dev.7408ec4 → 0.1.17-dev.a107052

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.
Files changed (77) hide show
  1. package/dist/cli/index.js +43 -36
  2. package/dist/connectors/airtable-oauth.js +8 -0
  3. package/dist/connectors/airtable.js +8 -0
  4. package/dist/connectors/amplitude.js +8 -0
  5. package/dist/connectors/anthropic.js +2 -0
  6. package/dist/connectors/asana.js +8 -0
  7. package/dist/connectors/attio.js +8 -0
  8. package/dist/connectors/aws-billing.js +8 -0
  9. package/dist/connectors/azure-sql.js +8 -0
  10. package/dist/connectors/backlog-api-key.js +8 -0
  11. package/dist/connectors/clickup.js +8 -0
  12. package/dist/connectors/cosmosdb.js +8 -0
  13. package/dist/connectors/customerio.js +8 -0
  14. package/dist/connectors/dbt.js +8 -0
  15. package/dist/connectors/freshdesk.js +8 -0
  16. package/dist/connectors/freshsales.js +8 -0
  17. package/dist/connectors/freshservice.js +8 -0
  18. package/dist/connectors/gamma.js +8 -0
  19. package/dist/connectors/gemini.js +2 -0
  20. package/dist/connectors/github.js +8 -0
  21. package/dist/connectors/gmail-oauth.js +6 -0
  22. package/dist/connectors/gmail.js +8 -0
  23. package/dist/connectors/google-ads.js +8 -0
  24. package/dist/connectors/google-analytics-oauth.js +8 -0
  25. package/dist/connectors/google-analytics.js +64 -49
  26. package/dist/connectors/google-audit-log.js +8 -0
  27. package/dist/connectors/google-calendar-oauth.js +8 -0
  28. package/dist/connectors/google-calendar.js +8 -0
  29. package/dist/connectors/google-docs.js +6 -0
  30. package/dist/connectors/google-drive.js +6 -0
  31. package/dist/connectors/google-search-console-oauth.js +8 -0
  32. package/dist/connectors/google-sheets.js +8 -0
  33. package/dist/connectors/google-slides.js +6 -0
  34. package/dist/connectors/grafana.js +8 -0
  35. package/dist/connectors/hubspot-oauth.js +6 -0
  36. package/dist/connectors/hubspot.js +8 -0
  37. package/dist/connectors/influxdb.js +8 -0
  38. package/dist/connectors/intercom-oauth.js +6 -0
  39. package/dist/connectors/intercom.js +8 -0
  40. package/dist/connectors/jdbc.js +8 -0
  41. package/dist/connectors/jira-api-key.js +8 -0
  42. package/dist/connectors/kintone-api-token.js +8 -0
  43. package/dist/connectors/kintone.js +8 -0
  44. package/dist/connectors/linear.js +8 -0
  45. package/dist/connectors/linkedin-ads.js +8 -0
  46. package/dist/connectors/mailchimp-oauth.js +8 -0
  47. package/dist/connectors/mailchimp.js +8 -0
  48. package/dist/connectors/meta-ads-oauth.js +8 -0
  49. package/dist/connectors/meta-ads.js +8 -0
  50. package/dist/connectors/mixpanel.js +8 -0
  51. package/dist/connectors/monday.js +8 -0
  52. package/dist/connectors/mongodb.js +8 -0
  53. package/dist/connectors/notion-oauth.js +6 -0
  54. package/dist/connectors/notion.js +8 -0
  55. package/dist/connectors/openai.js +2 -0
  56. package/dist/connectors/oracle.js +8 -0
  57. package/dist/connectors/outlook-oauth.js +6 -0
  58. package/dist/connectors/powerbi-oauth.js +6 -0
  59. package/dist/connectors/salesforce.js +8 -0
  60. package/dist/connectors/semrush.js +8 -0
  61. package/dist/connectors/sentry.js +8 -0
  62. package/dist/connectors/shopify-oauth.js +6 -0
  63. package/dist/connectors/shopify.js +8 -0
  64. package/dist/connectors/sqlserver.js +8 -0
  65. package/dist/connectors/stripe-api-key.js +8 -0
  66. package/dist/connectors/stripe-oauth.js +6 -0
  67. package/dist/connectors/supabase.js +8 -0
  68. package/dist/connectors/tableau.js +8 -0
  69. package/dist/connectors/tiktok-ads.js +8 -0
  70. package/dist/connectors/wix-store.js +8 -0
  71. package/dist/connectors/zendesk-oauth.js +6 -0
  72. package/dist/connectors/zendesk.js +8 -0
  73. package/dist/index.d.ts +1 -0
  74. package/dist/index.js +54 -42
  75. package/dist/main.js +43 -36
  76. package/dist/vite-plugin.js +43 -36
  77. package/package.json +1 -1
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -348,6 +350,12 @@ async function runSetupFlow(flow, params, ctx, config) {
348
350
  }
349
351
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
350
352
  if (step.type === "text") {
353
+ if (step.fetchOptions) {
354
+ const options2 = await step.fetchOptions(state, runtime);
355
+ if (options2.length === 0) {
356
+ continue;
357
+ }
358
+ }
351
359
  return {
352
360
  type: "nextQuestion",
353
361
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -481,6 +483,12 @@ async function runSetupFlow(flow, params, ctx, config) {
481
483
  }
482
484
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
483
485
  if (step.type === "text") {
486
+ if (step.fetchOptions) {
487
+ const options2 = await step.fetchOptions(state, runtime);
488
+ if (options2.length === 0) {
489
+ continue;
490
+ }
491
+ }
484
492
  return {
485
493
  type: "nextQuestion",
486
494
  questionSlug: step.slug,
@@ -291,6 +291,12 @@ async function runSetupFlow(flow, params, ctx, config) {
291
291
  }
292
292
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
293
293
  if (step.type === "text") {
294
+ if (step.fetchOptions) {
295
+ const options2 = await step.fetchOptions(state, runtime);
296
+ if (options2.length === 0) {
297
+ continue;
298
+ }
299
+ }
294
300
  return {
295
301
  type: "nextQuestion",
296
302
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -303,6 +305,12 @@ async function runSetupFlow(flow, params, ctx, config) {
303
305
  }
304
306
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
305
307
  if (step.type === "text") {
308
+ if (step.fetchOptions) {
309
+ const options2 = await step.fetchOptions(state, runtime);
310
+ if (options2.length === 0) {
311
+ continue;
312
+ }
313
+ }
306
314
  return {
307
315
  type: "nextQuestion",
308
316
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -351,6 +353,12 @@ async function runSetupFlow(flow, params, ctx, config) {
351
353
  }
352
354
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
353
355
  if (step.type === "text") {
356
+ if (step.fetchOptions) {
357
+ const options2 = await step.fetchOptions(state, runtime);
358
+ if (options2.length === 0) {
359
+ continue;
360
+ }
361
+ }
354
362
  return {
355
363
  type: "nextQuestion",
356
364
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -332,6 +334,12 @@ async function runSetupFlow(flow, params, ctx, config) {
332
334
  }
333
335
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
334
336
  if (step.type === "text") {
337
+ if (step.fetchOptions) {
338
+ const options2 = await step.fetchOptions(state, runtime);
339
+ if (options2.length === 0) {
340
+ continue;
341
+ }
342
+ }
335
343
  return {
336
344
  type: "nextQuestion",
337
345
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -75,7 +77,8 @@ var parameters = {
75
77
  envVarBaseKey: "GA_PROPERTY_ID",
76
78
  type: "text",
77
79
  secret: false,
78
- required: false
80
+ required: false,
81
+ isDeprecated: true
79
82
  })
80
83
  };
81
84
 
@@ -107,15 +110,10 @@ function buildJwt(clientEmail, privateKey, nowSec) {
107
110
  }
108
111
  function createClient(params) {
109
112
  const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
110
- const propertyId = params[parameters.propertyId.slug];
111
- if (!serviceAccountKeyJsonBase64 || !propertyId) {
112
- const required = [
113
- parameters.serviceAccountKeyJsonBase64.slug,
114
- parameters.propertyId.slug
115
- ];
116
- const missing = required.filter((s) => !params[s]);
113
+ const defaultPropertyId = params["property-id"] ?? "";
114
+ if (!serviceAccountKeyJsonBase64) {
117
115
  throw new Error(
118
- `google-analytics: missing required parameters: ${missing.join(", ")}`
116
+ `google-analytics: missing required parameters: ${parameters.serviceAccountKeyJsonBase64.slug}`
119
117
  );
120
118
  }
121
119
  let serviceAccountKey;
@@ -169,19 +167,23 @@ function createClient(params) {
169
167
  return {
170
168
  async request(path2, init) {
171
169
  const accessToken = await getAccessToken2();
172
- const resolvedPath = path2.replace(/\{propertyId\}/g, propertyId);
173
- const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
170
+ const url = `${BASE_URL.replace(/\/+$/, "")}/${path2.replace(/^\/+/, "")}`;
174
171
  const headers = new Headers(init?.headers);
175
172
  headers.set("Authorization", `Bearer ${accessToken}`);
176
173
  return fetch(url, { ...init, headers });
177
174
  },
178
175
  async runReport(request) {
176
+ const { propertyId: pid, ...body } = request;
177
+ const propertyId = pid || defaultPropertyId;
178
+ if (!propertyId) {
179
+ throw new Error("google-analytics: propertyId is required in runReport request");
180
+ }
179
181
  const response = await this.request(
180
182
  `properties/${propertyId}:runReport`,
181
183
  {
182
184
  method: "POST",
183
185
  headers: { "Content-Type": "application/json" },
184
- body: JSON.stringify(request)
186
+ body: JSON.stringify(body)
185
187
  }
186
188
  );
187
189
  if (!response.ok) {
@@ -196,7 +198,11 @@ function createClient(params) {
196
198
  rowCount: data.rowCount ?? 0
197
199
  };
198
200
  },
199
- async getMetadata() {
201
+ async getMetadata(request) {
202
+ const propertyId = request.propertyId || defaultPropertyId;
203
+ if (!propertyId) {
204
+ throw new Error("google-analytics: propertyId is required in getMetadata request");
205
+ }
200
206
  const response = await this.request(
201
207
  `properties/${propertyId}/metadata`,
202
208
  { method: "GET" }
@@ -210,12 +216,17 @@ function createClient(params) {
210
216
  return await response.json();
211
217
  },
212
218
  async runRealtimeReport(request) {
219
+ const { propertyId: pid, ...body } = request;
220
+ const propertyId = pid || defaultPropertyId;
221
+ if (!propertyId) {
222
+ throw new Error("google-analytics: propertyId is required in runRealtimeReport request");
223
+ }
213
224
  const response = await this.request(
214
225
  `properties/${propertyId}:runRealtimeReport`,
215
226
  {
216
227
  method: "POST",
217
228
  headers: { "Content-Type": "application/json" },
218
- body: JSON.stringify(request)
229
+ body: JSON.stringify(body)
219
230
  }
220
231
  );
221
232
  if (!response.ok) {
@@ -418,6 +429,12 @@ async function runSetupFlow(flow, params, ctx, config) {
418
429
  }
419
430
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
420
431
  if (step.type === "text") {
432
+ if (step.fetchOptions) {
433
+ const options2 = await step.fetchOptions(state, runtime);
434
+ if (options2.length === 0) {
435
+ continue;
436
+ }
437
+ }
421
438
  return {
422
439
  type: "nextQuestion",
423
440
  questionSlug: step.slug,
@@ -714,40 +731,23 @@ var googleAnalyticsSetupFlow = {
714
731
  return [];
715
732
  }
716
733
  },
717
- applyAnswer: (state, answer) => ({ ...state, properties: answer }),
718
- toParameterUpdates: (state) => {
719
- const first = state.properties?.find((v) => v !== ALL_PROPERTIES);
720
- return first ? [{ slug: parameters.propertyId.slug, value: first }] : [];
721
- }
734
+ applyAnswer: (state, answer) => ({ ...state, properties: answer })
722
735
  },
723
736
  {
724
737
  slug: "manualPropertyId",
725
- type: "select",
726
- allowFreeText: true,
738
+ type: "text",
727
739
  question: {
728
740
  ja: "GA4 \u30D7\u30ED\u30D1\u30C6\u30A3 ID \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: 123456789\uFF09\u3002GA4 \u7BA1\u7406\u753B\u9762 > \u30D7\u30ED\u30D1\u30C6\u30A3\u8A2D\u5B9A\u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002",
729
741
  en: "Enter your GA4 Property ID (e.g., 123456789). Found in GA4 Admin > Property Settings."
730
742
  },
731
- async fetchOptions(state, rt) {
743
+ async fetchOptions(state) {
732
744
  if (state.properties?.length) return [];
733
- const existing = rt.params[parameters.propertyId.slug];
734
- return existing ? [{ value: existing, label: existing }] : [
735
- {
736
- value: "example",
737
- label: rt.language === "ja" ? "\u4F8B: 123456789" : "Example: 123456789"
738
- }
739
- ];
745
+ return [{ value: "_show", label: "" }];
740
746
  },
741
747
  applyAnswer: (state, answer) => ({
742
748
  ...state,
743
749
  manualPropertyId: answer[0]
744
- }),
745
- toParameterUpdates: (state) => state.manualPropertyId ? [
746
- {
747
- slug: parameters.propertyId.slug,
748
- value: state.manualPropertyId
749
- }
750
- ] : []
750
+ })
751
751
  }
752
752
  ],
753
753
  async finalize(state, rt) {
@@ -803,7 +803,7 @@ var googleAnalyticsSetupFlow = {
803
803
  }
804
804
  return sections.join("\n");
805
805
  }
806
- const propertyId = state.manualPropertyId ?? rt.params[parameters.propertyId.slug];
806
+ const propertyId = state.manualPropertyId;
807
807
  if (propertyId) {
808
808
  sections.push(`### Property: ${propertyId}`, "");
809
809
  const { dimensions, metrics } = await getMetadata(
@@ -814,7 +814,7 @@ var googleAnalyticsSetupFlow = {
814
814
  return sections.join("\n");
815
815
  }
816
816
  sections.push(
817
- "_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project, or set the Property ID parameter manually._",
817
+ "_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project. Property ID can be specified per request at runtime._",
818
818
  ""
819
819
  );
820
820
  return sections.join("\n");
@@ -828,8 +828,9 @@ var REQUEST_TIMEOUT_MS = 6e4;
828
828
  var inputSchema = z.object({
829
829
  toolUseIntent: z.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
830
830
  connectionId: z.string().describe("ID of the Google Analytics connection to use"),
831
+ propertyId: z.string().describe("GA4 property ID (e.g., '123456789')"),
831
832
  method: z.enum(["GET", "POST"]).describe("HTTP method"),
832
- path: z.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
833
+ path: z.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is replaced with the propertyId parameter."),
833
834
  body: z.record(z.string(), z.unknown()).optional().describe("POST request body (JSON)")
834
835
  });
835
836
  var outputSchema = z.discriminatedUnion("success", [
@@ -847,10 +848,10 @@ var requestTool = new ConnectorTool({
847
848
  name: "request",
848
849
  description: `Send authenticated requests to the Google Analytics Data API.
849
850
  Authentication is handled automatically using a service account.
850
- {propertyId} in the path is automatically replaced with the connection's property-id.`,
851
+ {propertyId} in the path is automatically replaced with the propertyId parameter.`,
851
852
  inputSchema,
852
853
  outputSchema,
853
- async execute({ connectionId, method, path: path2, body }, connections) {
854
+ async execute({ connectionId, propertyId, method, path: path2, body }, connections) {
854
855
  const connection2 = connections.find((c) => c.id === connectionId);
855
856
  if (!connection2) {
856
857
  return { success: false, error: `Connection ${connectionId} not found` };
@@ -859,7 +860,6 @@ Authentication is handled automatically using a service account.
859
860
  try {
860
861
  const { GoogleAuth } = await import("google-auth-library");
861
862
  const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
862
- const propertyId = parameters.propertyId.getValue(connection2);
863
863
  const credentials = JSON.parse(
864
864
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
865
865
  );
@@ -919,7 +919,7 @@ var googleAnalyticsConnector = new ConnectorPlugin({
919
919
  systemPrompt: {
920
920
  en: `### Tools
921
921
 
922
- - \`google-analytics-service-account_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.
922
+ - \`google-analytics-service-account_request\`: The only way to call the GA4 Data API. Use it to fetch metadata, run reports, or run realtime reports. Requires a \`propertyId\` parameter. See the GA4 Data API Reference below for available endpoints and request bodies.
923
923
 
924
924
  ### Business Logic
925
925
 
@@ -928,9 +928,11 @@ The business logic type for this connector is "typescript". Use the connector SD
928
928
  SDK methods (client created via \`connection(connectionId)\`):
929
929
  - \`client.runReport(request)\` \u2014 run a GA4 report
930
930
  - \`client.runRealtimeReport(request)\` \u2014 run a realtime report
931
- - \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
931
+ - \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
932
932
  - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
933
933
 
934
+ **IMPORTANT**: You MUST always include \`propertyId\` in every SDK method call. The property ID is obtained during the setup flow. Without it, the request will fail.
935
+
934
936
  \`\`\`ts
935
937
  import type { Context } from "hono";
936
938
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
@@ -938,12 +940,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
938
940
  const ga = connection("<connectionId>");
939
941
 
940
942
  export default async function handler(c: Context) {
941
- const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
943
+ const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
944
+ propertyId: string;
942
945
  startDate?: string;
943
946
  endDate?: string;
944
947
  }>();
945
948
 
946
949
  const { rows } = await ga.runReport({
950
+ propertyId,
947
951
  dateRanges: [{ startDate, endDate }],
948
952
  dimensions: [{ name: "date" }],
949
953
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -987,7 +991,7 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
987
991
  - Relative: \`"today"\`, \`"yesterday"\`, \`"7daysAgo"\`, \`"30daysAgo"\``,
988
992
  ja: `### \u30C4\u30FC\u30EB
989
993
 
990
- - \`google-analytics-service-account_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
994
+ - \`google-analytics-service-account_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\`propertyId\` \u30D1\u30E9\u30E1\u30FC\u30BF\u30FC\u304C\u5FC5\u8981\u3067\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
991
995
 
992
996
  ### Business Logic
993
997
 
@@ -996,9 +1000,11 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
996
1000
  SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
997
1001
  - \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
998
1002
  - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
999
- - \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
1003
+ - \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
1000
1004
  - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
1001
1005
 
1006
+ **\u91CD\u8981**: \u3059\u3079\u3066\u306ESDK\u30E1\u30BD\u30C3\u30C9\u547C\u3073\u51FA\u3057\u306B\u306F\u5FC5\u305A \`propertyId\` \u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u30D5\u30ED\u30FC\u3067\u53D6\u5F97\u3055\u308C\u307E\u3059\u3002\u6307\u5B9A\u3057\u306A\u3044\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u5931\u6557\u3057\u307E\u3059\u3002
1007
+
1002
1008
  \`\`\`ts
1003
1009
  import type { Context } from "hono";
1004
1010
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
@@ -1006,12 +1012,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
1006
1012
  const ga = connection("<connectionId>");
1007
1013
 
1008
1014
  export default async function handler(c: Context) {
1009
- const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
1015
+ const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
1016
+ propertyId: string;
1010
1017
  startDate?: string;
1011
1018
  endDate?: string;
1012
1019
  }>();
1013
1020
 
1014
1021
  const { rows } = await ga.runReport({
1022
+ propertyId,
1015
1023
  dateRanges: [{ startDate, endDate }],
1016
1024
  dimensions: [{ name: "date" }],
1017
1025
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -1066,7 +1074,14 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
1066
1074
  }
1067
1075
  const propertyId = params[parameters.propertyId.slug];
1068
1076
  if (!propertyId) {
1069
- return { success: true };
1077
+ try {
1078
+ const sa = decodeServiceAccount(keyJsonBase64);
1079
+ await getAccessToken(sa);
1080
+ return { success: true };
1081
+ } catch (err) {
1082
+ const msg = err instanceof Error ? err.message : String(err);
1083
+ return { success: false, error: msg };
1084
+ }
1070
1085
  }
1071
1086
  try {
1072
1087
  const res = await dataFetch(
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -303,6 +305,12 @@ async function runSetupFlow(flow, params, ctx, config) {
303
305
  }
304
306
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
305
307
  if (step.type === "text") {
308
+ if (step.fetchOptions) {
309
+ const options2 = await step.fetchOptions(state, runtime);
310
+ if (options2.length === 0) {
311
+ continue;
312
+ }
313
+ }
306
314
  return {
307
315
  type: "nextQuestion",
308
316
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -319,6 +321,12 @@ async function runSetupFlow(flow, params, ctx, config) {
319
321
  }
320
322
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
321
323
  if (step.type === "text") {
324
+ if (step.fetchOptions) {
325
+ const options2 = await step.fetchOptions(state, runtime);
326
+ if (options2.length === 0) {
327
+ continue;
328
+ }
329
+ }
322
330
  return {
323
331
  type: "nextQuestion",
324
332
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -324,6 +326,12 @@ async function runSetupFlow(flow, params, ctx, config) {
324
326
  }
325
327
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
326
328
  if (step.type === "text") {
329
+ if (step.fetchOptions) {
330
+ const options2 = await step.fetchOptions(state, runtime);
331
+ if (options2.length === 0) {
332
+ continue;
333
+ }
334
+ }
327
335
  return {
328
336
  type: "nextQuestion",
329
337
  questionSlug: step.slug,
@@ -239,6 +239,12 @@ async function runSetupFlow(flow, params, ctx, config) {
239
239
  }
240
240
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
241
241
  if (step.type === "text") {
242
+ if (step.fetchOptions) {
243
+ const options2 = await step.fetchOptions(state, runtime);
244
+ if (options2.length === 0) {
245
+ continue;
246
+ }
247
+ }
242
248
  return {
243
249
  type: "nextQuestion",
244
250
  questionSlug: step.slug,
@@ -328,6 +328,12 @@ async function runSetupFlow(flow, params, ctx, config) {
328
328
  }
329
329
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
330
330
  if (step.type === "text") {
331
+ if (step.fetchOptions) {
332
+ const options2 = await step.fetchOptions(state, runtime);
333
+ if (options2.length === 0) {
334
+ continue;
335
+ }
336
+ }
331
337
  return {
332
338
  type: "nextQuestion",
333
339
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -333,6 +335,12 @@ async function runSetupFlow(flow, params, ctx, config) {
333
335
  }
334
336
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
335
337
  if (step.type === "text") {
338
+ if (step.fetchOptions) {
339
+ const options2 = await step.fetchOptions(state, runtime);
340
+ if (options2.length === 0) {
341
+ continue;
342
+ }
343
+ }
336
344
  return {
337
345
  type: "nextQuestion",
338
346
  questionSlug: step.slug,
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -320,6 +322,12 @@ async function runSetupFlow(flow, params, ctx, config) {
320
322
  }
321
323
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
322
324
  if (step.type === "text") {
325
+ if (step.fetchOptions) {
326
+ const options2 = await step.fetchOptions(state, runtime);
327
+ if (options2.length === 0) {
328
+ continue;
329
+ }
330
+ }
323
331
  return {
324
332
  type: "nextQuestion",
325
333
  questionSlug: step.slug,
@@ -251,6 +251,12 @@ async function runSetupFlow(flow, params, ctx, config) {
251
251
  }
252
252
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
253
253
  if (step.type === "text") {
254
+ if (step.fetchOptions) {
255
+ const options2 = await step.fetchOptions(state, runtime);
256
+ if (options2.length === 0) {
257
+ continue;
258
+ }
259
+ }
254
260
  return {
255
261
  type: "nextQuestion",
256
262
  questionSlug: step.slug,