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

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 (73) hide show
  1. package/dist/cli/index.js +57 -32
  2. package/dist/connectors/airtable-oauth.js +0 -6
  3. package/dist/connectors/airtable.js +0 -6
  4. package/dist/connectors/amplitude.js +0 -6
  5. package/dist/connectors/asana.js +0 -6
  6. package/dist/connectors/attio.js +0 -6
  7. package/dist/connectors/aws-billing.js +0 -6
  8. package/dist/connectors/azure-sql.js +0 -6
  9. package/dist/connectors/backlog-api-key.js +0 -6
  10. package/dist/connectors/clickup.js +0 -6
  11. package/dist/connectors/cosmosdb.js +0 -6
  12. package/dist/connectors/customerio.js +0 -6
  13. package/dist/connectors/dbt.js +0 -6
  14. package/dist/connectors/freshdesk.js +0 -6
  15. package/dist/connectors/freshsales.js +0 -6
  16. package/dist/connectors/freshservice.js +0 -6
  17. package/dist/connectors/gamma.js +0 -6
  18. package/dist/connectors/github.js +0 -6
  19. package/dist/connectors/gmail-oauth.js +0 -6
  20. package/dist/connectors/gmail.js +0 -6
  21. package/dist/connectors/google-ads.js +0 -6
  22. package/dist/connectors/google-analytics-oauth.js +0 -6
  23. package/dist/connectors/google-analytics.js +70 -38
  24. package/dist/connectors/google-audit-log.js +0 -6
  25. package/dist/connectors/google-calendar-oauth.js +0 -6
  26. package/dist/connectors/google-calendar.js +0 -6
  27. package/dist/connectors/google-docs.js +0 -6
  28. package/dist/connectors/google-drive.js +0 -6
  29. package/dist/connectors/google-search-console-oauth.js +0 -6
  30. package/dist/connectors/google-sheets.js +0 -6
  31. package/dist/connectors/google-slides.js +0 -6
  32. package/dist/connectors/grafana.js +0 -6
  33. package/dist/connectors/hubspot-oauth.js +0 -6
  34. package/dist/connectors/hubspot.js +0 -6
  35. package/dist/connectors/influxdb.js +0 -6
  36. package/dist/connectors/intercom-oauth.js +0 -6
  37. package/dist/connectors/intercom.js +0 -6
  38. package/dist/connectors/jdbc.js +0 -6
  39. package/dist/connectors/jira-api-key.js +0 -6
  40. package/dist/connectors/kintone-api-token.js +0 -6
  41. package/dist/connectors/kintone.js +0 -6
  42. package/dist/connectors/linear.js +0 -6
  43. package/dist/connectors/linkedin-ads.js +0 -6
  44. package/dist/connectors/mailchimp-oauth.js +0 -6
  45. package/dist/connectors/mailchimp.js +0 -6
  46. package/dist/connectors/meta-ads-oauth.js +0 -6
  47. package/dist/connectors/meta-ads.js +0 -6
  48. package/dist/connectors/mixpanel.js +0 -6
  49. package/dist/connectors/monday.js +0 -6
  50. package/dist/connectors/mongodb.js +0 -6
  51. package/dist/connectors/notion-oauth.js +0 -6
  52. package/dist/connectors/notion.js +0 -6
  53. package/dist/connectors/oracle.js +0 -6
  54. package/dist/connectors/outlook-oauth.js +0 -6
  55. package/dist/connectors/powerbi-oauth.js +0 -6
  56. package/dist/connectors/salesforce.js +0 -6
  57. package/dist/connectors/semrush.js +0 -6
  58. package/dist/connectors/sentry.js +0 -6
  59. package/dist/connectors/shopify-oauth.js +0 -6
  60. package/dist/connectors/shopify.js +0 -6
  61. package/dist/connectors/sqlserver.js +0 -6
  62. package/dist/connectors/stripe-api-key.js +0 -6
  63. package/dist/connectors/stripe-oauth.js +0 -6
  64. package/dist/connectors/supabase.js +0 -6
  65. package/dist/connectors/tableau.js +0 -6
  66. package/dist/connectors/tiktok-ads.js +0 -6
  67. package/dist/connectors/wix-store.js +0 -6
  68. package/dist/connectors/zendesk-oauth.js +0 -6
  69. package/dist/connectors/zendesk.js +0 -6
  70. package/dist/index.js +57 -32
  71. package/dist/main.js +57 -32
  72. package/dist/vite-plugin.js +57 -32
  73. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -804,12 +804,6 @@ async function runSetupFlow(flow, params, ctx, config) {
804
804
  }
805
805
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
806
806
  if (step.type === "text") {
807
- if (step.fetchOptions) {
808
- const options2 = await step.fetchOptions(state, runtime);
809
- if (options2.length === 0) {
810
- continue;
811
- }
812
- }
813
807
  return {
814
808
  type: "nextQuestion",
815
809
  questionSlug: step.slug,
@@ -7607,6 +7601,15 @@ var parameters13 = {
7607
7601
  type: "base64EncodedJson",
7608
7602
  secret: true,
7609
7603
  required: true
7604
+ }),
7605
+ propertyId: new ParameterDefinition({
7606
+ slug: "property-id",
7607
+ name: "Google Analytics Property ID",
7608
+ description: "The Google Analytics 4 property ID (e.g., 123456789). Automatically set during the setup flow.",
7609
+ envVarBaseKey: "GA_PROPERTY_ID",
7610
+ type: "text",
7611
+ secret: false,
7612
+ required: false
7610
7613
  })
7611
7614
  };
7612
7615
 
@@ -7844,23 +7847,40 @@ var googleAnalyticsSetupFlow = {
7844
7847
  return [];
7845
7848
  }
7846
7849
  },
7847
- applyAnswer: (state, answer) => ({ ...state, properties: answer })
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
+ }
7848
7855
  },
7849
7856
  {
7850
7857
  slug: "manualPropertyId",
7851
- type: "text",
7858
+ type: "select",
7859
+ allowFreeText: true,
7852
7860
  question: {
7853
7861
  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",
7854
7862
  en: "Enter your GA4 Property ID (e.g., 123456789). Found in GA4 Admin > Property Settings."
7855
7863
  },
7856
- async fetchOptions(state) {
7864
+ async fetchOptions(state, rt) {
7857
7865
  if (state.properties?.length) return [];
7858
- return [{ value: "_show", label: "" }];
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
+ ];
7859
7873
  },
7860
7874
  applyAnswer: (state, answer) => ({
7861
7875
  ...state,
7862
7876
  manualPropertyId: answer[0]
7863
- })
7877
+ }),
7878
+ toParameterUpdates: (state) => state.manualPropertyId ? [
7879
+ {
7880
+ slug: parameters13.propertyId.slug,
7881
+ value: state.manualPropertyId
7882
+ }
7883
+ ] : []
7864
7884
  }
7865
7885
  ],
7866
7886
  async finalize(state, rt) {
@@ -7916,7 +7936,7 @@ var googleAnalyticsSetupFlow = {
7916
7936
  }
7917
7937
  return sections.join("\n");
7918
7938
  }
7919
- const propertyId = state.manualPropertyId;
7939
+ const propertyId = state.manualPropertyId ?? rt.params[parameters13.propertyId.slug];
7920
7940
  if (propertyId) {
7921
7941
  sections.push(`### Property: ${propertyId}`, "");
7922
7942
  const { dimensions, metrics } = await getMetadata(
@@ -7927,7 +7947,7 @@ var googleAnalyticsSetupFlow = {
7927
7947
  return sections.join("\n");
7928
7948
  }
7929
7949
  sections.push(
7930
- "_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._",
7950
+ "_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project, or set the Property ID parameter manually._",
7931
7951
  ""
7932
7952
  );
7933
7953
  return sections.join("\n");
@@ -7941,9 +7961,8 @@ var REQUEST_TIMEOUT_MS10 = 6e4;
7941
7961
  var inputSchema20 = z20.object({
7942
7962
  toolUseIntent: z20.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
7943
7963
  connectionId: z20.string().describe("ID of the Google Analytics connection to use"),
7944
- propertyId: z20.string().describe("GA4 property ID (e.g., '123456789')"),
7945
7964
  method: z20.enum(["GET", "POST"]).describe("HTTP method"),
7946
- path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is replaced with the propertyId parameter."),
7965
+ path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
7947
7966
  body: z20.record(z20.string(), z20.unknown()).optional().describe("POST request body (JSON)")
7948
7967
  });
7949
7968
  var outputSchema20 = z20.discriminatedUnion("success", [
@@ -7961,10 +7980,10 @@ var requestTool3 = new ConnectorTool({
7961
7980
  name: "request",
7962
7981
  description: `Send authenticated requests to the Google Analytics Data API.
7963
7982
  Authentication is handled automatically using a service account.
7964
- {propertyId} in the path is automatically replaced with the propertyId parameter.`,
7983
+ {propertyId} in the path is automatically replaced with the connection's property-id.`,
7965
7984
  inputSchema: inputSchema20,
7966
7985
  outputSchema: outputSchema20,
7967
- async execute({ connectionId, propertyId, method, path: path6, body }, connections) {
7986
+ async execute({ connectionId, method, path: path6, body }, connections) {
7968
7987
  const connection2 = connections.find((c) => c.id === connectionId);
7969
7988
  if (!connection2) {
7970
7989
  return { success: false, error: `Connection ${connectionId} not found` };
@@ -7973,6 +7992,7 @@ Authentication is handled automatically using a service account.
7973
7992
  try {
7974
7993
  const { GoogleAuth } = await import("google-auth-library");
7975
7994
  const keyJsonBase64 = parameters13.serviceAccountKeyJsonBase64.getValue(connection2);
7995
+ const propertyId = parameters13.propertyId.getValue(connection2);
7976
7996
  const credentials = JSON.parse(
7977
7997
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
7978
7998
  );
@@ -8032,16 +8052,16 @@ var googleAnalyticsConnector = new ConnectorPlugin({
8032
8052
  systemPrompt: {
8033
8053
  en: `### Tools
8034
8054
 
8035
- - \`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.
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.
8036
8056
 
8037
8057
  ### Business Logic
8038
8058
 
8039
8059
  The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
8040
8060
 
8041
8061
  SDK methods (client created via \`connection(connectionId)\`):
8042
- - \`client.runReport(propertyId, request)\` \u2014 run a GA4 report
8043
- - \`client.runRealtimeReport(propertyId, request)\` \u2014 run a realtime report
8044
- - \`client.getMetadata(propertyId)\` \u2014 fetch available dimensions/metrics
8062
+ - \`client.runReport(request)\` \u2014 run a GA4 report
8063
+ - \`client.runRealtimeReport(request)\` \u2014 run a realtime report
8064
+ - \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
8045
8065
  - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
8046
8066
 
8047
8067
  \`\`\`ts
@@ -8051,13 +8071,12 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8051
8071
  const ga = connection("<connectionId>");
8052
8072
 
8053
8073
  export default async function handler(c: Context) {
8054
- const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8055
- propertyId: string;
8074
+ const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8056
8075
  startDate?: string;
8057
8076
  endDate?: string;
8058
8077
  }>();
8059
8078
 
8060
- const { rows } = await ga.runReport(propertyId, {
8079
+ const { rows } = await ga.runReport({
8061
8080
  dateRanges: [{ startDate, endDate }],
8062
8081
  dimensions: [{ name: "date" }],
8063
8082
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8101,16 +8120,16 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8101
8120
  - Relative: \`"today"\`, \`"yesterday"\`, \`"7daysAgo"\`, \`"30daysAgo"\``,
8102
8121
  ja: `### \u30C4\u30FC\u30EB
8103
8122
 
8104
- - \`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
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
8105
8124
 
8106
8125
  ### Business Logic
8107
8126
 
8108
8127
  \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
8109
8128
 
8110
8129
  SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
8111
- - \`client.runReport(propertyId, request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8112
- - \`client.runRealtimeReport(propertyId, request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8113
- - \`client.getMetadata(propertyId)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
8130
+ - \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8131
+ - \`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
8114
8133
  - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
8115
8134
 
8116
8135
  \`\`\`ts
@@ -8120,13 +8139,12 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8120
8139
  const ga = connection("<connectionId>");
8121
8140
 
8122
8141
  export default async function handler(c: Context) {
8123
- const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8124
- propertyId: string;
8142
+ const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8125
8143
  startDate?: string;
8126
8144
  endDate?: string;
8127
8145
  }>();
8128
8146
 
8129
- const { rows } = await ga.runReport(propertyId, {
8147
+ const { rows } = await ga.runReport({
8130
8148
  dateRanges: [{ startDate, endDate }],
8131
8149
  dimensions: [{ name: "date" }],
8132
8150
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8179,8 +8197,15 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8179
8197
  error: "google-analytics: missing service account key"
8180
8198
  };
8181
8199
  }
8200
+ const propertyId = params[parameters13.propertyId.slug];
8201
+ if (!propertyId) {
8202
+ return { success: true };
8203
+ }
8182
8204
  try {
8183
- const res = await dataFetch(params, `/metadata`);
8205
+ const res = await dataFetch(
8206
+ params,
8207
+ `/properties/${propertyId}/metadata`
8208
+ );
8184
8209
  if (!res.ok) {
8185
8210
  const body = await res.text().catch(() => res.statusText);
8186
8211
  return {
@@ -805,12 +805,6 @@ async function runSetupFlow(flow, params, ctx, config) {
805
805
  }
806
806
  const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
807
807
  if (step.type === "text") {
808
- if (step.fetchOptions) {
809
- const options2 = await step.fetchOptions(state, runtime);
810
- if (options2.length === 0) {
811
- continue;
812
- }
813
- }
814
808
  return {
815
809
  type: "nextQuestion",
816
810
  questionSlug: step.slug,
@@ -7608,6 +7602,15 @@ var parameters13 = {
7608
7602
  type: "base64EncodedJson",
7609
7603
  secret: true,
7610
7604
  required: true
7605
+ }),
7606
+ propertyId: new ParameterDefinition({
7607
+ slug: "property-id",
7608
+ name: "Google Analytics Property ID",
7609
+ description: "The Google Analytics 4 property ID (e.g., 123456789). Automatically set during the setup flow.",
7610
+ envVarBaseKey: "GA_PROPERTY_ID",
7611
+ type: "text",
7612
+ secret: false,
7613
+ required: false
7611
7614
  })
7612
7615
  };
7613
7616
 
@@ -7845,23 +7848,40 @@ var googleAnalyticsSetupFlow = {
7845
7848
  return [];
7846
7849
  }
7847
7850
  },
7848
- applyAnswer: (state, answer) => ({ ...state, properties: answer })
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
+ }
7849
7856
  },
7850
7857
  {
7851
7858
  slug: "manualPropertyId",
7852
- type: "text",
7859
+ type: "select",
7860
+ allowFreeText: true,
7853
7861
  question: {
7854
7862
  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",
7855
7863
  en: "Enter your GA4 Property ID (e.g., 123456789). Found in GA4 Admin > Property Settings."
7856
7864
  },
7857
- async fetchOptions(state) {
7865
+ async fetchOptions(state, rt) {
7858
7866
  if (state.properties?.length) return [];
7859
- return [{ value: "_show", label: "" }];
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
+ ];
7860
7874
  },
7861
7875
  applyAnswer: (state, answer) => ({
7862
7876
  ...state,
7863
7877
  manualPropertyId: answer[0]
7864
- })
7878
+ }),
7879
+ toParameterUpdates: (state) => state.manualPropertyId ? [
7880
+ {
7881
+ slug: parameters13.propertyId.slug,
7882
+ value: state.manualPropertyId
7883
+ }
7884
+ ] : []
7865
7885
  }
7866
7886
  ],
7867
7887
  async finalize(state, rt) {
@@ -7917,7 +7937,7 @@ var googleAnalyticsSetupFlow = {
7917
7937
  }
7918
7938
  return sections.join("\n");
7919
7939
  }
7920
- const propertyId = state.manualPropertyId;
7940
+ const propertyId = state.manualPropertyId ?? rt.params[parameters13.propertyId.slug];
7921
7941
  if (propertyId) {
7922
7942
  sections.push(`### Property: ${propertyId}`, "");
7923
7943
  const { dimensions, metrics } = await getMetadata(
@@ -7928,7 +7948,7 @@ var googleAnalyticsSetupFlow = {
7928
7948
  return sections.join("\n");
7929
7949
  }
7930
7950
  sections.push(
7931
- "_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
+ "_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project, or set the Property ID parameter manually._",
7932
7952
  ""
7933
7953
  );
7934
7954
  return sections.join("\n");
@@ -7942,9 +7962,8 @@ var REQUEST_TIMEOUT_MS10 = 6e4;
7942
7962
  var inputSchema20 = z20.object({
7943
7963
  toolUseIntent: z20.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
7944
7964
  connectionId: z20.string().describe("ID of the Google Analytics connection to use"),
7945
- propertyId: z20.string().describe("GA4 property ID (e.g., '123456789')"),
7946
7965
  method: z20.enum(["GET", "POST"]).describe("HTTP method"),
7947
- path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is replaced with the propertyId parameter."),
7966
+ path: z20.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
7948
7967
  body: z20.record(z20.string(), z20.unknown()).optional().describe("POST request body (JSON)")
7949
7968
  });
7950
7969
  var outputSchema20 = z20.discriminatedUnion("success", [
@@ -7962,10 +7981,10 @@ var requestTool3 = new ConnectorTool({
7962
7981
  name: "request",
7963
7982
  description: `Send authenticated requests to the Google Analytics Data API.
7964
7983
  Authentication is handled automatically using a service account.
7965
- {propertyId} in the path is automatically replaced with the propertyId parameter.`,
7984
+ {propertyId} in the path is automatically replaced with the connection's property-id.`,
7966
7985
  inputSchema: inputSchema20,
7967
7986
  outputSchema: outputSchema20,
7968
- async execute({ connectionId, propertyId, method, path: path4, body }, connections) {
7987
+ async execute({ connectionId, method, path: path4, body }, connections) {
7969
7988
  const connection = connections.find((c) => c.id === connectionId);
7970
7989
  if (!connection) {
7971
7990
  return { success: false, error: `Connection ${connectionId} not found` };
@@ -7974,6 +7993,7 @@ Authentication is handled automatically using a service account.
7974
7993
  try {
7975
7994
  const { GoogleAuth } = await import("google-auth-library");
7976
7995
  const keyJsonBase64 = parameters13.serviceAccountKeyJsonBase64.getValue(connection);
7996
+ const propertyId = parameters13.propertyId.getValue(connection);
7977
7997
  const credentials = JSON.parse(
7978
7998
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
7979
7999
  );
@@ -8033,16 +8053,16 @@ var googleAnalyticsConnector = new ConnectorPlugin({
8033
8053
  systemPrompt: {
8034
8054
  en: `### Tools
8035
8055
 
8036
- - \`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
+ - \`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.
8037
8057
 
8038
8058
  ### Business Logic
8039
8059
 
8040
8060
  The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
8041
8061
 
8042
8062
  SDK methods (client created via \`connection(connectionId)\`):
8043
- - \`client.runReport(propertyId, request)\` \u2014 run a GA4 report
8044
- - \`client.runRealtimeReport(propertyId, request)\` \u2014 run a realtime report
8045
- - \`client.getMetadata(propertyId)\` \u2014 fetch available dimensions/metrics
8063
+ - \`client.runReport(request)\` \u2014 run a GA4 report
8064
+ - \`client.runRealtimeReport(request)\` \u2014 run a realtime report
8065
+ - \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
8046
8066
  - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
8047
8067
 
8048
8068
  \`\`\`ts
@@ -8052,13 +8072,12 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8052
8072
  const ga = connection("<connectionId>");
8053
8073
 
8054
8074
  export default async function handler(c: Context) {
8055
- const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8056
- propertyId: string;
8075
+ const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8057
8076
  startDate?: string;
8058
8077
  endDate?: string;
8059
8078
  }>();
8060
8079
 
8061
- const { rows } = await ga.runReport(propertyId, {
8080
+ const { rows } = await ga.runReport({
8062
8081
  dateRanges: [{ startDate, endDate }],
8063
8082
  dimensions: [{ name: "date" }],
8064
8083
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8102,16 +8121,16 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8102
8121
  - Relative: \`"today"\`, \`"yesterday"\`, \`"7daysAgo"\`, \`"30daysAgo"\``,
8103
8122
  ja: `### \u30C4\u30FC\u30EB
8104
8123
 
8105
- - \`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
+ - \`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
8106
8125
 
8107
8126
  ### Business Logic
8108
8127
 
8109
8128
  \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
8110
8129
 
8111
8130
  SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
8112
- - \`client.runReport(propertyId, request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8113
- - \`client.runRealtimeReport(propertyId, request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8114
- - \`client.getMetadata(propertyId)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
8131
+ - \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
8132
+ - \`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
8115
8134
  - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
8116
8135
 
8117
8136
  \`\`\`ts
@@ -8121,13 +8140,12 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
8121
8140
  const ga = connection("<connectionId>");
8122
8141
 
8123
8142
  export default async function handler(c: Context) {
8124
- const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8125
- propertyId: string;
8143
+ const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
8126
8144
  startDate?: string;
8127
8145
  endDate?: string;
8128
8146
  }>();
8129
8147
 
8130
- const { rows } = await ga.runReport(propertyId, {
8148
+ const { rows } = await ga.runReport({
8131
8149
  dateRanges: [{ startDate, endDate }],
8132
8150
  dimensions: [{ name: "date" }],
8133
8151
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -8180,8 +8198,15 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
8180
8198
  error: "google-analytics: missing service account key"
8181
8199
  };
8182
8200
  }
8201
+ const propertyId = params[parameters13.propertyId.slug];
8202
+ if (!propertyId) {
8203
+ return { success: true };
8204
+ }
8183
8205
  try {
8184
- const res = await dataFetch(params, `/metadata`);
8206
+ const res = await dataFetch(
8207
+ params,
8208
+ `/properties/${propertyId}/metadata`
8209
+ );
8185
8210
  if (!res.ok) {
8186
8211
  const body = await res.text().catch(() => res.statusText);
8187
8212
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/vite-server",
3
- "version": "0.1.17-dev.3b633bb",
3
+ "version": "0.1.17-dev.7408ec4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {