@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
package/dist/main.js CHANGED
@@ -21,6 +21,7 @@ var init_parameter_definition = __esm({
21
21
  type;
22
22
  secret;
23
23
  required;
24
+ isDeprecated;
24
25
  constructor(config) {
25
26
  this.slug = config.slug;
26
27
  this.name = config.name;
@@ -29,6 +30,7 @@ var init_parameter_definition = __esm({
29
30
  this.type = config.type;
30
31
  this.secret = config.secret;
31
32
  this.required = config.required;
33
+ this.isDeprecated = config.isDeprecated ?? false;
32
34
  }
33
35
  /**
34
36
  * Get the parameter value from a ConnectorConnectionObject.
@@ -804,6 +806,12 @@ async function runSetupFlow(flow, params, ctx, config) {
804
806
  }
805
807
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
806
808
  if (step.type === "text") {
809
+ if (step.fetchOptions) {
810
+ const options2 = await step.fetchOptions(state, runtime);
811
+ if (options2.length === 0) {
812
+ continue;
813
+ }
814
+ }
807
815
  return {
808
816
  type: "nextQuestion",
809
817
  questionSlug: step.slug,
@@ -7609,7 +7617,8 @@ var parameters13 = {
7609
7617
  envVarBaseKey: "GA_PROPERTY_ID",
7610
7618
  type: "text",
7611
7619
  secret: false,
7612
- required: false
7620
+ required: false,
7621
+ isDeprecated: true
7613
7622
  })
7614
7623
  };
7615
7624
 
@@ -7847,40 +7856,23 @@ var googleAnalyticsSetupFlow = {
7847
7856
  return [];
7848
7857
  }
7849
7858
  },
7850
- applyAnswer: (state, answer) => ({ ...state, properties: answer }),
7851
- toParameterUpdates: (state) => {
7852
- const first = state.properties?.find((v) => v !== ALL_PROPERTIES);
7853
- return first ? [{ slug: parameters13.propertyId.slug, value: first }] : [];
7854
- }
7859
+ applyAnswer: (state, answer) => ({ ...state, properties: answer })
7855
7860
  },
7856
7861
  {
7857
7862
  slug: "manualPropertyId",
7858
- type: "select",
7859
- allowFreeText: true,
7863
+ type: "text",
7860
7864
  question: {
7861
7865
  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",
7862
7866
  en: "Enter your GA4 Property ID (e.g., 123456789). Found in GA4 Admin > Property Settings."
7863
7867
  },
7864
- async fetchOptions(state, rt) {
7868
+ async fetchOptions(state) {
7865
7869
  if (state.properties?.length) return [];
7866
- const existing = rt.params[parameters13.propertyId.slug];
7867
- return existing ? [{ value: existing, label: existing }] : [
7868
- {
7869
- value: "example",
7870
- label: rt.language === "ja" ? "\u4F8B: 123456789" : "Example: 123456789"
7871
- }
7872
- ];
7870
+ return [{ value: "_show", label: "" }];
7873
7871
  },
7874
7872
  applyAnswer: (state, answer) => ({
7875
7873
  ...state,
7876
7874
  manualPropertyId: answer[0]
7877
- }),
7878
- toParameterUpdates: (state) => state.manualPropertyId ? [
7879
- {
7880
- slug: parameters13.propertyId.slug,
7881
- value: state.manualPropertyId
7882
- }
7883
- ] : []
7875
+ })
7884
7876
  }
7885
7877
  ],
7886
7878
  async finalize(state, rt) {
@@ -7936,7 +7928,7 @@ var googleAnalyticsSetupFlow = {
7936
7928
  }
7937
7929
  return sections.join("\n");
7938
7930
  }
7939
- const propertyId = state.manualPropertyId ?? rt.params[parameters13.propertyId.slug];
7931
+ const propertyId = state.manualPropertyId;
7940
7932
  if (propertyId) {
7941
7933
  sections.push(`### Property: ${propertyId}`, "");
7942
7934
  const { dimensions, metrics } = await getMetadata(
@@ -7947,7 +7939,7 @@ var googleAnalyticsSetupFlow = {
7947
7939
  return sections.join("\n");
7948
7940
  }
7949
7941
  sections.push(
7950
- "_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project, or set the Property ID parameter manually._",
7942
+ "_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._",
7951
7943
  ""
7952
7944
  );
7953
7945
  return sections.join("\n");
@@ -7961,8 +7953,9 @@ var REQUEST_TIMEOUT_MS10 = 6e4;
7961
7953
  var inputSchema20 = z20.object({
7962
7954
  toolUseIntent: z20.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
7963
7955
  connectionId: z20.string().describe("ID of the Google Analytics connection to use"),
7956
+ propertyId: z20.string().describe("GA4 property ID (e.g., '123456789')"),
7964
7957
  method: z20.enum(["GET", "POST"]).describe("HTTP method"),
7965
- path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
7958
+ path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is replaced with the propertyId parameter."),
7966
7959
  body: z20.record(z20.string(), z20.unknown()).optional().describe("POST request body (JSON)")
7967
7960
  });
7968
7961
  var outputSchema20 = z20.discriminatedUnion("success", [
@@ -7980,10 +7973,10 @@ var requestTool3 = new ConnectorTool({
7980
7973
  name: "request",
7981
7974
  description: `Send authenticated requests to the Google Analytics Data API.
7982
7975
  Authentication is handled automatically using a service account.
7983
- {propertyId} in the path is automatically replaced with the connection's property-id.`,
7976
+ {propertyId} in the path is automatically replaced with the propertyId parameter.`,
7984
7977
  inputSchema: inputSchema20,
7985
7978
  outputSchema: outputSchema20,
7986
- async execute({ connectionId, method, path: path6, body }, connections) {
7979
+ async execute({ connectionId, propertyId, method, path: path6, body }, connections) {
7987
7980
  const connection2 = connections.find((c) => c.id === connectionId);
7988
7981
  if (!connection2) {
7989
7982
  return { success: false, error: `Connection ${connectionId} not found` };
@@ -7992,7 +7985,6 @@ Authentication is handled automatically using a service account.
7992
7985
  try {
7993
7986
  const { GoogleAuth } = await import("google-auth-library");
7994
7987
  const keyJsonBase64 = parameters13.serviceAccountKeyJsonBase64.getValue(connection2);
7995
- const propertyId = parameters13.propertyId.getValue(connection2);
7996
7988
  const credentials = JSON.parse(
7997
7989
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
7998
7990
  );
@@ -8052,7 +8044,7 @@ var googleAnalyticsConnector = new ConnectorPlugin({
8052
8044
  systemPrompt: {
8053
8045
  en: `### Tools
8054
8046
 
8055
- - \`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.
8047
+ - \`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.
8056
8048
 
8057
8049
  ### Business Logic
8058
8050
 
@@ -8061,9 +8053,11 @@ The business logic type for this connector is "typescript". Use the connector SD
8061
8053
  SDK methods (client created via \`connection(connectionId)\`):
8062
8054
  - \`client.runReport(request)\` \u2014 run a GA4 report
8063
8055
  - \`client.runRealtimeReport(request)\` \u2014 run a realtime report
8064
- - \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
8056
+ - \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
8065
8057
  - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
8066
8058
 
8059
+ **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.
8060
+
8067
8061
  \`\`\`ts
8068
8062
  import type { Context } from "hono";
8069
8063
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
@@ -8071,12 +8065,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8071
8065
  const ga = connection("<connectionId>");
8072
8066
 
8073
8067
  export default async function handler(c: Context) {
8074
- const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8068
+ const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8069
+ propertyId: string;
8075
8070
  startDate?: string;
8076
8071
  endDate?: string;
8077
8072
  }>();
8078
8073
 
8079
8074
  const { rows } = await ga.runReport({
8075
+ propertyId,
8080
8076
  dateRanges: [{ startDate, endDate }],
8081
8077
  dimensions: [{ name: "date" }],
8082
8078
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8120,7 +8116,7 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8120
8116
  - Relative: \`"today"\`, \`"yesterday"\`, \`"7daysAgo"\`, \`"30daysAgo"\``,
8121
8117
  ja: `### \u30C4\u30FC\u30EB
8122
8118
 
8123
- - \`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
8119
+ - \`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
8124
8120
 
8125
8121
  ### Business Logic
8126
8122
 
@@ -8129,9 +8125,11 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8129
8125
  SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
8130
8126
  - \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8131
8127
  - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8132
- - \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
8128
+ - \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
8133
8129
  - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
8134
8130
 
8131
+ **\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
8132
+
8135
8133
  \`\`\`ts
8136
8134
  import type { Context } from "hono";
8137
8135
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
@@ -8139,12 +8137,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8139
8137
  const ga = connection("<connectionId>");
8140
8138
 
8141
8139
  export default async function handler(c: Context) {
8142
- const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8140
+ const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8141
+ propertyId: string;
8143
8142
  startDate?: string;
8144
8143
  endDate?: string;
8145
8144
  }>();
8146
8145
 
8147
8146
  const { rows } = await ga.runReport({
8147
+ propertyId,
8148
8148
  dateRanges: [{ startDate, endDate }],
8149
8149
  dimensions: [{ name: "date" }],
8150
8150
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8199,7 +8199,14 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8199
8199
  }
8200
8200
  const propertyId = params[parameters13.propertyId.slug];
8201
8201
  if (!propertyId) {
8202
- return { success: true };
8202
+ try {
8203
+ const sa = decodeServiceAccount(keyJsonBase64);
8204
+ await getAccessToken(sa);
8205
+ return { success: true };
8206
+ } catch (err) {
8207
+ const msg = err instanceof Error ? err.message : String(err);
8208
+ return { success: false, error: msg };
8209
+ }
8203
8210
  }
8204
8211
  try {
8205
8212
  const res = await dataFetch(
@@ -21,6 +21,7 @@ var init_parameter_definition = __esm({
21
21
  type;
22
22
  secret;
23
23
  required;
24
+ isDeprecated;
24
25
  constructor(config) {
25
26
  this.slug = config.slug;
26
27
  this.name = config.name;
@@ -29,6 +30,7 @@ var init_parameter_definition = __esm({
29
30
  this.type = config.type;
30
31
  this.secret = config.secret;
31
32
  this.required = config.required;
33
+ this.isDeprecated = config.isDeprecated ?? false;
32
34
  }
33
35
  /**
34
36
  * Get the parameter value from a ConnectorConnectionObject.
@@ -805,6 +807,12 @@ async function runSetupFlow(flow, params, ctx, config) {
805
807
  }
806
808
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
807
809
  if (step.type === "text") {
810
+ if (step.fetchOptions) {
811
+ const options2 = await step.fetchOptions(state, runtime);
812
+ if (options2.length === 0) {
813
+ continue;
814
+ }
815
+ }
808
816
  return {
809
817
  type: "nextQuestion",
810
818
  questionSlug: step.slug,
@@ -7610,7 +7618,8 @@ var parameters13 = {
7610
7618
  envVarBaseKey: "GA_PROPERTY_ID",
7611
7619
  type: "text",
7612
7620
  secret: false,
7613
- required: false
7621
+ required: false,
7622
+ isDeprecated: true
7614
7623
  })
7615
7624
  };
7616
7625
 
@@ -7848,40 +7857,23 @@ var googleAnalyticsSetupFlow = {
7848
7857
  return [];
7849
7858
  }
7850
7859
  },
7851
- applyAnswer: (state, answer) => ({ ...state, properties: answer }),
7852
- toParameterUpdates: (state) => {
7853
- const first = state.properties?.find((v) => v !== ALL_PROPERTIES);
7854
- return first ? [{ slug: parameters13.propertyId.slug, value: first }] : [];
7855
- }
7860
+ applyAnswer: (state, answer) => ({ ...state, properties: answer })
7856
7861
  },
7857
7862
  {
7858
7863
  slug: "manualPropertyId",
7859
- type: "select",
7860
- allowFreeText: true,
7864
+ type: "text",
7861
7865
  question: {
7862
7866
  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",
7863
7867
  en: "Enter your GA4 Property ID (e.g., 123456789). Found in GA4 Admin > Property Settings."
7864
7868
  },
7865
- async fetchOptions(state, rt) {
7869
+ async fetchOptions(state) {
7866
7870
  if (state.properties?.length) return [];
7867
- const existing = rt.params[parameters13.propertyId.slug];
7868
- return existing ? [{ value: existing, label: existing }] : [
7869
- {
7870
- value: "example",
7871
- label: rt.language === "ja" ? "\u4F8B: 123456789" : "Example: 123456789"
7872
- }
7873
- ];
7871
+ return [{ value: "_show", label: "" }];
7874
7872
  },
7875
7873
  applyAnswer: (state, answer) => ({
7876
7874
  ...state,
7877
7875
  manualPropertyId: answer[0]
7878
- }),
7879
- toParameterUpdates: (state) => state.manualPropertyId ? [
7880
- {
7881
- slug: parameters13.propertyId.slug,
7882
- value: state.manualPropertyId
7883
- }
7884
- ] : []
7876
+ })
7885
7877
  }
7886
7878
  ],
7887
7879
  async finalize(state, rt) {
@@ -7937,7 +7929,7 @@ var googleAnalyticsSetupFlow = {
7937
7929
  }
7938
7930
  return sections.join("\n");
7939
7931
  }
7940
- const propertyId = state.manualPropertyId ?? rt.params[parameters13.propertyId.slug];
7932
+ const propertyId = state.manualPropertyId;
7941
7933
  if (propertyId) {
7942
7934
  sections.push(`### Property: ${propertyId}`, "");
7943
7935
  const { dimensions, metrics } = await getMetadata(
@@ -7948,7 +7940,7 @@ var googleAnalyticsSetupFlow = {
7948
7940
  return sections.join("\n");
7949
7941
  }
7950
7942
  sections.push(
7951
- "_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project, or set the Property ID parameter manually._",
7943
+ "_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._",
7952
7944
  ""
7953
7945
  );
7954
7946
  return sections.join("\n");
@@ -7962,8 +7954,9 @@ var REQUEST_TIMEOUT_MS10 = 6e4;
7962
7954
  var inputSchema20 = z20.object({
7963
7955
  toolUseIntent: z20.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
7964
7956
  connectionId: z20.string().describe("ID of the Google Analytics connection to use"),
7957
+ propertyId: z20.string().describe("GA4 property ID (e.g., '123456789')"),
7965
7958
  method: z20.enum(["GET", "POST"]).describe("HTTP method"),
7966
- path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
7959
+ path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is replaced with the propertyId parameter."),
7967
7960
  body: z20.record(z20.string(), z20.unknown()).optional().describe("POST request body (JSON)")
7968
7961
  });
7969
7962
  var outputSchema20 = z20.discriminatedUnion("success", [
@@ -7981,10 +7974,10 @@ var requestTool3 = new ConnectorTool({
7981
7974
  name: "request",
7982
7975
  description: `Send authenticated requests to the Google Analytics Data API.
7983
7976
  Authentication is handled automatically using a service account.
7984
- {propertyId} in the path is automatically replaced with the connection's property-id.`,
7977
+ {propertyId} in the path is automatically replaced with the propertyId parameter.`,
7985
7978
  inputSchema: inputSchema20,
7986
7979
  outputSchema: outputSchema20,
7987
- async execute({ connectionId, method, path: path4, body }, connections) {
7980
+ async execute({ connectionId, propertyId, method, path: path4, body }, connections) {
7988
7981
  const connection = connections.find((c) => c.id === connectionId);
7989
7982
  if (!connection) {
7990
7983
  return { success: false, error: `Connection ${connectionId} not found` };
@@ -7993,7 +7986,6 @@ Authentication is handled automatically using a service account.
7993
7986
  try {
7994
7987
  const { GoogleAuth } = await import("google-auth-library");
7995
7988
  const keyJsonBase64 = parameters13.serviceAccountKeyJsonBase64.getValue(connection);
7996
- const propertyId = parameters13.propertyId.getValue(connection);
7997
7989
  const credentials = JSON.parse(
7998
7990
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
7999
7991
  );
@@ -8053,7 +8045,7 @@ var googleAnalyticsConnector = new ConnectorPlugin({
8053
8045
  systemPrompt: {
8054
8046
  en: `### Tools
8055
8047
 
8056
- - \`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.
8048
+ - \`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.
8057
8049
 
8058
8050
  ### Business Logic
8059
8051
 
@@ -8062,9 +8054,11 @@ The business logic type for this connector is "typescript". Use the connector SD
8062
8054
  SDK methods (client created via \`connection(connectionId)\`):
8063
8055
  - \`client.runReport(request)\` \u2014 run a GA4 report
8064
8056
  - \`client.runRealtimeReport(request)\` \u2014 run a realtime report
8065
- - \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
8057
+ - \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
8066
8058
  - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
8067
8059
 
8060
+ **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.
8061
+
8068
8062
  \`\`\`ts
8069
8063
  import type { Context } from "hono";
8070
8064
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
@@ -8072,12 +8066,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8072
8066
  const ga = connection("<connectionId>");
8073
8067
 
8074
8068
  export default async function handler(c: Context) {
8075
- const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8069
+ const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8070
+ propertyId: string;
8076
8071
  startDate?: string;
8077
8072
  endDate?: string;
8078
8073
  }>();
8079
8074
 
8080
8075
  const { rows } = await ga.runReport({
8076
+ propertyId,
8081
8077
  dateRanges: [{ startDate, endDate }],
8082
8078
  dimensions: [{ name: "date" }],
8083
8079
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8121,7 +8117,7 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8121
8117
  - Relative: \`"today"\`, \`"yesterday"\`, \`"7daysAgo"\`, \`"30daysAgo"\``,
8122
8118
  ja: `### \u30C4\u30FC\u30EB
8123
8119
 
8124
- - \`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
8120
+ - \`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
8125
8121
 
8126
8122
  ### Business Logic
8127
8123
 
@@ -8130,9 +8126,11 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8130
8126
  SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
8131
8127
  - \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8132
8128
  - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8133
- - \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
8129
+ - \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
8134
8130
  - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
8135
8131
 
8132
+ **\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
8133
+
8136
8134
  \`\`\`ts
8137
8135
  import type { Context } from "hono";
8138
8136
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
@@ -8140,12 +8138,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8140
8138
  const ga = connection("<connectionId>");
8141
8139
 
8142
8140
  export default async function handler(c: Context) {
8143
- const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8141
+ const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8142
+ propertyId: string;
8144
8143
  startDate?: string;
8145
8144
  endDate?: string;
8146
8145
  }>();
8147
8146
 
8148
8147
  const { rows } = await ga.runReport({
8148
+ propertyId,
8149
8149
  dateRanges: [{ startDate, endDate }],
8150
8150
  dimensions: [{ name: "date" }],
8151
8151
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8200,7 +8200,14 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8200
8200
  }
8201
8201
  const propertyId = params[parameters13.propertyId.slug];
8202
8202
  if (!propertyId) {
8203
- return { success: true };
8203
+ try {
8204
+ const sa = decodeServiceAccount(keyJsonBase64);
8205
+ await getAccessToken(sa);
8206
+ return { success: true };
8207
+ } catch (err) {
8208
+ const msg = err instanceof Error ? err.message : String(err);
8209
+ return { success: false, error: msg };
8210
+ }
8204
8211
  }
8205
8212
  try {
8206
8213
  const res = await dataFetch(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/vite-server",
3
- "version": "0.1.17-dev.7408ec4",
3
+ "version": "0.1.17-dev.a107052",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {