@squadbase/vite-server 0.1.18 → 0.1.19-dev.40d2ebd

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.
@@ -0,0 +1,18 @@
1
+ // Server build entry used by `squadbasePlugin` (see vite-plugin.ts).
2
+ //
3
+ // It re-exports the vite-server app as default (so @hono/vite-build's injected
4
+ // `serve({ fetch: app.fetch })` works), and statically imports the project's
5
+ // TypeScript server-logic handlers via the `virtual:squadbase-server-logics`
6
+ // module (generated by the plugin from `server-logic/*.json`). Because the
7
+ // handlers are compiled into THIS bundle, they share the server's module graph
8
+ // — in particular hono's `contextStorage` AsyncLocalStorage — so `getContext()`
9
+ // works. This replaces runtime jiti transpilation.
10
+ //
11
+ // Registration goes through `@squadbase/vite-server/main` (not `/`) because
12
+ // `./main` and `./` are separate bundle entry points with separate module state.
13
+ import app, { registerBundledHandlers } from "@squadbase/vite-server/main";
14
+ import { HANDLERS } from "virtual:squadbase-server-logics";
15
+
16
+ registerBundledHandlers(HANDLERS);
17
+
18
+ export default app;
package/dist/cli/index.js CHANGED
@@ -10612,8 +10612,8 @@ init_parameter_definition();
10612
10612
  var parameters16 = {
10613
10613
  propertyId: new ParameterDefinition({
10614
10614
  slug: "property-id",
10615
- name: "Google Analytics Property ID",
10616
- description: "The Google Analytics 4 property ID (e.g., 123456789). Can be found in GA4 Admin > Property Settings.",
10615
+ name: "Default Property ID",
10616
+ description: "Optional default Google Analytics 4 property ID (e.g., 123456789) used when a request does not specify one. Can be found in GA4 Admin > Property Settings. Leave empty to always pass the property ID per request.",
10617
10617
  envVarBaseKey: "GA_OAUTH_PROPERTY_ID",
10618
10618
  type: "text",
10619
10619
  secret: false,
@@ -10926,7 +10926,7 @@ var inputSchema25 = z25.object({
10926
10926
  connectionId: z25.string().describe("ID of the Google Analytics OAuth connection to use"),
10927
10927
  method: z25.enum(["GET", "POST"]).describe("HTTP method"),
10928
10928
  path: z25.string().describe(
10929
- "API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."
10929
+ "API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/123456789:runReport'). Write the numeric property id directly; the {propertyId} placeholder is only substituted when a default property is configured on the connection."
10930
10930
  ),
10931
10931
  body: z25.record(z25.string(), z25.unknown()).optional().describe("POST request body (JSON)")
10932
10932
  });
@@ -10945,7 +10945,7 @@ var requestTool4 = new ConnectorTool({
10945
10945
  name: "request",
10946
10946
  description: `Send authenticated requests to the Google Analytics Data API v1beta.
10947
10947
  Authentication is handled automatically via OAuth proxy.
10948
- {propertyId} in the path is automatically replaced with the connection's property ID.`,
10948
+ Write the numeric property id directly into the path (e.g. properties/123456789:runReport). The {propertyId} placeholder is only substituted when a default property is configured on the connection.`,
10949
10949
  inputSchema: inputSchema25,
10950
10950
  outputSchema: outputSchema25,
10951
10951
  async execute({ connectionId, method, path: path5, body }, connections, config) {
@@ -11032,7 +11032,7 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
11032
11032
  systemPrompt: {
11033
11033
  en: `### Tools
11034
11034
 
11035
- - \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports. The {propertyId} placeholder in paths is automatically replaced. Authentication is configured automatically via OAuth.
11035
+ - \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports. Write the target property into the path as \`properties/{numericPropertyId}\` (the \`{propertyId}\` placeholder is only substituted when a default property is configured on the connection). Authentication is configured automatically via OAuth.
11036
11036
  - \`connector_google-analytics-oauth_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
11037
11037
  - \`connector_google-analytics-oauth_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
11038
11038
 
@@ -11068,10 +11068,12 @@ averageSessionDuration, conversions, totalRevenue
11068
11068
  The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables and do NOT read \`INTERNAL_SQUADBASE_*\` env vars \u2014 the SDK takes care of OAuth.
11069
11069
 
11070
11070
  SDK surface (client created via \`connection(connectionId)\`):
11071
- - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (\`path\` is appended to \`https://analyticsdata.googleapis.com/v1beta/\`).
11072
- - \`client.runReport(request)\` \u2014 run a GA4 report.
11073
- - \`client.runRealtimeReport(request)\` \u2014 run a realtime report.
11074
- - \`client.getMetadata()\` \u2014 fetch available dimensions and metrics.
11071
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (\`path\` is appended to \`https://analyticsdata.googleapis.com/v1beta/\`; \`{propertyId}\` placeholders are auto-replaced only when a default property is configured on the connection).
11072
+ - \`client.runReport(request)\` \u2014 run a GA4 report. Set \`propertyId\` (bare numeric id) on the request object to target a property; required when no default is configured.
11073
+ - \`client.runRealtimeReport(request)\` \u2014 run a realtime report. \`propertyId\` works the same as \`runReport\`.
11074
+ - \`client.getMetadata(propertyId?)\` \u2014 fetch available dimensions and metrics for a property.
11075
+
11076
+ **Always pass \`propertyId\` explicitly** (the numeric id from the data overview) \u2014 the connection does not necessarily store a default property.
11075
11077
 
11076
11078
  If a handler test fails with \`Connection proxy is not configured\`, retry \u2014 the sandbox is still initializing. Do NOT abandon the SDK and construct OAuth proxy URLs manually.
11077
11079
 
@@ -11081,30 +11083,33 @@ If a handler test fails with \`Connection proxy is not configured\`, retry \u201
11081
11083
  import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
11082
11084
 
11083
11085
  const ga = connection("<connectionId>");
11086
+ const propertyId = "123456789"; // numeric GA4 property id from the data overview
11084
11087
 
11085
- // Authenticated fetch (returns standard Response)
11086
- const res = await ga.request("properties/{propertyId}:runReport", {
11087
- method: "POST",
11088
- body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
11089
- });
11090
- const data = await res.json();
11091
-
11092
- // Convenience methods
11088
+ // Convenience methods (pass propertyId explicitly)
11093
11089
  const { rows, rowCount } = await ga.runReport({
11090
+ propertyId,
11094
11091
  dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
11095
11092
  dimensions: [{ name: "date" }],
11096
11093
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
11097
11094
  limit: 100,
11098
11095
  });
11099
- const metadata = await ga.getMetadata();
11096
+ const metadata = await ga.getMetadata(propertyId);
11100
11097
  const realtime = await ga.runRealtimeReport({
11098
+ propertyId,
11101
11099
  metrics: [{ name: "activeUsers" }],
11102
11100
  dimensions: [{ name: "country" }],
11103
11101
  });
11102
+
11103
+ // Low-level authenticated fetch (write the numeric property id into the path)
11104
+ const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
11105
+ method: "POST",
11106
+ body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
11107
+ });
11108
+ const data = await res.json();
11104
11109
  \`\`\``,
11105
11110
  ja: `### \u30C4\u30FC\u30EB
11106
11111
 
11107
- - \`connector_google-analytics-oauth_request\`: GA4 Data API\u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{propertyId}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
11112
+ - \`connector_google-analytics-oauth_request\`: GA4 Data API\u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u5BFE\u8C61\u30D7\u30ED\u30D1\u30C6\u30A3\u306F\u30D1\u30B9\u306B \`properties/{\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID}\` \u306E\u5F62\u3067\u76F4\u63A5\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\`{propertyId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u306E\u307F\u7F6E\u63DB\u3055\u308C\u307E\u3059\uFF09\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
11108
11113
  - \`connector_google-analytics-oauth_listAccounts\`: \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGoogle Analytics\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u5229\u7528\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u78BA\u8A8D\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
11109
11114
  - \`connector_google-analytics-oauth_listProperties\`: \u6307\u5B9A\u30A2\u30AB\u30A6\u30F3\u30C8\u306EGA4\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u30BF\u30FC\u30B2\u30C3\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
11110
11115
 
@@ -11140,10 +11145,12 @@ averageSessionDuration, conversions, totalRevenue
11140
11145
  \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BF SDK \u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002\`INTERNAL_SQUADBASE_*\` \u306E\u74B0\u5883\u5909\u6570\u3092\u4F7F\u3063\u3066\u624B\u52D5\u3067 OAuth \u30D7\u30ED\u30AD\u30B7\u3092\u53E9\u304F\u3053\u3068\u3082\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 SDK \u304C OAuth \u3092\u51E6\u7406\u3057\u307E\u3059\u3002
11141
11146
 
11142
11147
  SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
11143
- - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\`path\` \u306F \`https://analyticsdata.googleapis.com/v1beta/\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\uFF09\u3002
11144
- - \`client.runReport(request)\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002
11145
- - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002
11146
- - \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97\u3002
11148
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\`path\` \u306F \`https://analyticsdata.googleapis.com/v1beta/\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\u3002\`{propertyId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u306F\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u306E\u307F\u81EA\u52D5\u7F6E\u63DB\u3055\u308C\u307E\u3059\uFF09\u3002
11149
+ - \`client.runReport(request)\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002\u30EA\u30AF\u30A8\u30B9\u30C8\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B \`propertyId\`\uFF08\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\uFF09\u3092\u6307\u5B9A\u3057\u3066\u5BFE\u8C61\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u6C7A\u3081\u307E\u3059\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u672A\u8A2D\u5B9A\u306E\u5834\u5408\u306F\u5FC5\u9808\u3067\u3059\u3002
11150
+ - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002\`propertyId\` \u306E\u6271\u3044\u306F \`runReport\` \u3068\u540C\u3058\u3067\u3059\u3002
11151
+ - \`client.getMetadata(propertyId?)\` \u2014 \u6307\u5B9A\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97\u3002
11152
+
11153
+ **\`propertyId\` \u306F\u5FC5\u305A\u660E\u793A\u7684\u306B\u6E21\u3057\u3066\u304F\u3060\u3055\u3044**\uFF08\u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024ID\uFF09\u3002\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u4FDD\u5B58\u3055\u308C\u3066\u3044\u308B\u3068\u306F\u9650\u308A\u307E\u305B\u3093\u3002
11147
11154
 
11148
11155
  \u30CF\u30F3\u30C9\u30E9\u306E\u30C6\u30B9\u30C8\u304C \`Connection proxy is not configured\` \u3067\u5931\u6557\u3059\u308B\u5834\u5408\u306F\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u901A\u5E38\u306F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u521D\u671F\u5316\u4E2D\u306B\u8D77\u304D\u307E\u3059\u3002SDK \u3092\u8AE6\u3081\u3066 OAuth \u30D7\u30ED\u30AD\u30B7\u306E URL \u3092\u81EA\u5206\u3067\u7D44\u307F\u7ACB\u3066\u308B\u3053\u3068\u306F **\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044**\u3002
11149
11156
 
@@ -11153,26 +11160,29 @@ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9
11153
11160
  import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
11154
11161
 
11155
11162
  const ga = connection("<connectionId>");
11163
+ const propertyId = "123456789"; // \u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024\u306E GA4 \u30D7\u30ED\u30D1\u30C6\u30A3ID
11156
11164
 
11157
- // Authenticated fetch (returns standard Response)
11158
- const res = await ga.request("properties/{propertyId}:runReport", {
11159
- method: "POST",
11160
- body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
11161
- });
11162
- const data = await res.json();
11163
-
11164
- // Convenience methods
11165
+ // \u4FBF\u5229\u30E1\u30BD\u30C3\u30C9\uFF08propertyId \u3092\u660E\u793A\u7684\u306B\u6E21\u3059\uFF09
11165
11166
  const { rows, rowCount } = await ga.runReport({
11167
+ propertyId,
11166
11168
  dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
11167
11169
  dimensions: [{ name: "date" }],
11168
11170
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
11169
11171
  limit: 100,
11170
11172
  });
11171
- const metadata = await ga.getMetadata();
11173
+ const metadata = await ga.getMetadata(propertyId);
11172
11174
  const realtime = await ga.runRealtimeReport({
11175
+ propertyId,
11173
11176
  metrics: [{ name: "activeUsers" }],
11174
11177
  dimensions: [{ name: "country" }],
11175
11178
  });
11179
+
11180
+ // \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u30D1\u30B9\u306B\u76F4\u63A5\u66F8\u304F\uFF09
11181
+ const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
11182
+ method: "POST",
11183
+ body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
11184
+ });
11185
+ const data = await res.json();
11176
11186
  \`\`\``
11177
11187
  },
11178
11188
  tools: tools16,
@@ -65,8 +65,8 @@ init_parameter_definition();
65
65
  var parameters = {
66
66
  propertyId: new ParameterDefinition({
67
67
  slug: "property-id",
68
- name: "Google Analytics Property ID",
69
- description: "The Google Analytics 4 property ID (e.g., 123456789). Can be found in GA4 Admin > Property Settings.",
68
+ name: "Default Property ID",
69
+ description: "Optional default Google Analytics 4 property ID (e.g., 123456789) used when a request does not specify one. Can be found in GA4 Admin > Property Settings. Leave empty to always pass the property ID per request.",
70
70
  envVarBaseKey: "GA_OAUTH_PROPERTY_ID",
71
71
  type: "text",
72
72
  secret: false,
@@ -77,24 +77,24 @@ var parameters = {
77
77
  // ../connectors/src/connectors/google-analytics-oauth/sdk/index.ts
78
78
  var BASE_URL = "https://analyticsdata.googleapis.com/v1beta/";
79
79
  function createClient(params, fetchFn) {
80
- const propertyId = params[parameters.propertyId.slug];
81
- function resolvePropertyId() {
82
- if (!propertyId) {
80
+ const defaultPropertyId = params[parameters.propertyId.slug];
81
+ function resolvePropertyId(override) {
82
+ const pid = override ?? defaultPropertyId;
83
+ if (!pid) {
83
84
  throw new Error(
84
- "google-analytics-oauth: propertyId is required. Configure it via connection parameters."
85
+ "google-analytics-oauth: propertyId is required. Configure it via connection parameters or pass it as an argument."
85
86
  );
86
87
  }
87
- return propertyId;
88
+ return pid;
88
89
  }
89
90
  return {
90
91
  async request(path2, init) {
91
- const pid = propertyId;
92
- const resolvedPath = pid ? path2.replace(/\{propertyId\}/g, pid) : path2;
92
+ const resolvedPath = defaultPropertyId ? path2.replace(/\{propertyId\}/g, defaultPropertyId) : path2;
93
93
  const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
94
94
  return fetchFn(url, init);
95
95
  },
96
- async runReport(request) {
97
- const pid = resolvePropertyId();
96
+ async runReport({ propertyId, ...request }) {
97
+ const pid = resolvePropertyId(propertyId);
98
98
  const response = await this.request(
99
99
  `properties/${pid}:runReport`,
100
100
  {
@@ -115,8 +115,8 @@ function createClient(params, fetchFn) {
115
115
  rowCount: data.rowCount ?? 0
116
116
  };
117
117
  },
118
- async getMetadata() {
119
- const pid = resolvePropertyId();
118
+ async getMetadata(propertyId) {
119
+ const pid = resolvePropertyId(propertyId);
120
120
  const response = await this.request(
121
121
  `properties/${pid}/metadata`,
122
122
  { method: "GET" }
@@ -129,8 +129,8 @@ function createClient(params, fetchFn) {
129
129
  }
130
130
  return await response.json();
131
131
  },
132
- async runRealtimeReport(request) {
133
- const pid = resolvePropertyId();
132
+ async runRealtimeReport({ propertyId, ...request }) {
133
+ const pid = resolvePropertyId(propertyId);
134
134
  const response = await this.request(
135
135
  `properties/${pid}:runRealtimeReport`,
136
136
  {
@@ -1001,7 +1001,7 @@ var inputSchema3 = z3.object({
1001
1001
  connectionId: z3.string().describe("ID of the Google Analytics OAuth connection to use"),
1002
1002
  method: z3.enum(["GET", "POST"]).describe("HTTP method"),
1003
1003
  path: z3.string().describe(
1004
- "API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."
1004
+ "API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/123456789:runReport'). Write the numeric property id directly; the {propertyId} placeholder is only substituted when a default property is configured on the connection."
1005
1005
  ),
1006
1006
  body: z3.record(z3.string(), z3.unknown()).optional().describe("POST request body (JSON)")
1007
1007
  });
@@ -1020,7 +1020,7 @@ var requestTool = new ConnectorTool({
1020
1020
  name: "request",
1021
1021
  description: `Send authenticated requests to the Google Analytics Data API v1beta.
1022
1022
  Authentication is handled automatically via OAuth proxy.
1023
- {propertyId} in the path is automatically replaced with the connection's property ID.`,
1023
+ Write the numeric property id directly into the path (e.g. properties/123456789:runReport). The {propertyId} placeholder is only substituted when a default property is configured on the connection.`,
1024
1024
  inputSchema: inputSchema3,
1025
1025
  outputSchema: outputSchema3,
1026
1026
  async execute({ connectionId, method, path: path2, body }, connections, config) {
@@ -1107,7 +1107,7 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
1107
1107
  systemPrompt: {
1108
1108
  en: `### Tools
1109
1109
 
1110
- - \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports. The {propertyId} placeholder in paths is automatically replaced. Authentication is configured automatically via OAuth.
1110
+ - \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports. Write the target property into the path as \`properties/{numericPropertyId}\` (the \`{propertyId}\` placeholder is only substituted when a default property is configured on the connection). Authentication is configured automatically via OAuth.
1111
1111
  - \`connector_google-analytics-oauth_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
1112
1112
  - \`connector_google-analytics-oauth_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
1113
1113
 
@@ -1143,10 +1143,12 @@ averageSessionDuration, conversions, totalRevenue
1143
1143
  The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables and do NOT read \`INTERNAL_SQUADBASE_*\` env vars \u2014 the SDK takes care of OAuth.
1144
1144
 
1145
1145
  SDK surface (client created via \`connection(connectionId)\`):
1146
- - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (\`path\` is appended to \`https://analyticsdata.googleapis.com/v1beta/\`).
1147
- - \`client.runReport(request)\` \u2014 run a GA4 report.
1148
- - \`client.runRealtimeReport(request)\` \u2014 run a realtime report.
1149
- - \`client.getMetadata()\` \u2014 fetch available dimensions and metrics.
1146
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (\`path\` is appended to \`https://analyticsdata.googleapis.com/v1beta/\`; \`{propertyId}\` placeholders are auto-replaced only when a default property is configured on the connection).
1147
+ - \`client.runReport(request)\` \u2014 run a GA4 report. Set \`propertyId\` (bare numeric id) on the request object to target a property; required when no default is configured.
1148
+ - \`client.runRealtimeReport(request)\` \u2014 run a realtime report. \`propertyId\` works the same as \`runReport\`.
1149
+ - \`client.getMetadata(propertyId?)\` \u2014 fetch available dimensions and metrics for a property.
1150
+
1151
+ **Always pass \`propertyId\` explicitly** (the numeric id from the data overview) \u2014 the connection does not necessarily store a default property.
1150
1152
 
1151
1153
  If a handler test fails with \`Connection proxy is not configured\`, retry \u2014 the sandbox is still initializing. Do NOT abandon the SDK and construct OAuth proxy URLs manually.
1152
1154
 
@@ -1156,30 +1158,33 @@ If a handler test fails with \`Connection proxy is not configured\`, retry \u201
1156
1158
  import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
1157
1159
 
1158
1160
  const ga = connection("<connectionId>");
1161
+ const propertyId = "123456789"; // numeric GA4 property id from the data overview
1159
1162
 
1160
- // Authenticated fetch (returns standard Response)
1161
- const res = await ga.request("properties/{propertyId}:runReport", {
1162
- method: "POST",
1163
- body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
1164
- });
1165
- const data = await res.json();
1166
-
1167
- // Convenience methods
1163
+ // Convenience methods (pass propertyId explicitly)
1168
1164
  const { rows, rowCount } = await ga.runReport({
1165
+ propertyId,
1169
1166
  dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
1170
1167
  dimensions: [{ name: "date" }],
1171
1168
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
1172
1169
  limit: 100,
1173
1170
  });
1174
- const metadata = await ga.getMetadata();
1171
+ const metadata = await ga.getMetadata(propertyId);
1175
1172
  const realtime = await ga.runRealtimeReport({
1173
+ propertyId,
1176
1174
  metrics: [{ name: "activeUsers" }],
1177
1175
  dimensions: [{ name: "country" }],
1178
1176
  });
1177
+
1178
+ // Low-level authenticated fetch (write the numeric property id into the path)
1179
+ const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
1180
+ method: "POST",
1181
+ body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
1182
+ });
1183
+ const data = await res.json();
1179
1184
  \`\`\``,
1180
1185
  ja: `### \u30C4\u30FC\u30EB
1181
1186
 
1182
- - \`connector_google-analytics-oauth_request\`: GA4 Data API\u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{propertyId}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
1187
+ - \`connector_google-analytics-oauth_request\`: GA4 Data API\u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u5BFE\u8C61\u30D7\u30ED\u30D1\u30C6\u30A3\u306F\u30D1\u30B9\u306B \`properties/{\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID}\` \u306E\u5F62\u3067\u76F4\u63A5\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\`{propertyId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u306E\u307F\u7F6E\u63DB\u3055\u308C\u307E\u3059\uFF09\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
1183
1188
  - \`connector_google-analytics-oauth_listAccounts\`: \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGoogle Analytics\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u5229\u7528\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u78BA\u8A8D\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
1184
1189
  - \`connector_google-analytics-oauth_listProperties\`: \u6307\u5B9A\u30A2\u30AB\u30A6\u30F3\u30C8\u306EGA4\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u30BF\u30FC\u30B2\u30C3\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
1185
1190
 
@@ -1215,10 +1220,12 @@ averageSessionDuration, conversions, totalRevenue
1215
1220
  \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BF SDK \u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002\`INTERNAL_SQUADBASE_*\` \u306E\u74B0\u5883\u5909\u6570\u3092\u4F7F\u3063\u3066\u624B\u52D5\u3067 OAuth \u30D7\u30ED\u30AD\u30B7\u3092\u53E9\u304F\u3053\u3068\u3082\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 SDK \u304C OAuth \u3092\u51E6\u7406\u3057\u307E\u3059\u3002
1216
1221
 
1217
1222
  SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
1218
- - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\`path\` \u306F \`https://analyticsdata.googleapis.com/v1beta/\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\uFF09\u3002
1219
- - \`client.runReport(request)\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002
1220
- - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002
1221
- - \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97\u3002
1223
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\`path\` \u306F \`https://analyticsdata.googleapis.com/v1beta/\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\u3002\`{propertyId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u306F\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u306E\u307F\u81EA\u52D5\u7F6E\u63DB\u3055\u308C\u307E\u3059\uFF09\u3002
1224
+ - \`client.runReport(request)\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002\u30EA\u30AF\u30A8\u30B9\u30C8\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B \`propertyId\`\uFF08\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\uFF09\u3092\u6307\u5B9A\u3057\u3066\u5BFE\u8C61\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u6C7A\u3081\u307E\u3059\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u672A\u8A2D\u5B9A\u306E\u5834\u5408\u306F\u5FC5\u9808\u3067\u3059\u3002
1225
+ - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002\`propertyId\` \u306E\u6271\u3044\u306F \`runReport\` \u3068\u540C\u3058\u3067\u3059\u3002
1226
+ - \`client.getMetadata(propertyId?)\` \u2014 \u6307\u5B9A\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97\u3002
1227
+
1228
+ **\`propertyId\` \u306F\u5FC5\u305A\u660E\u793A\u7684\u306B\u6E21\u3057\u3066\u304F\u3060\u3055\u3044**\uFF08\u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024ID\uFF09\u3002\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u4FDD\u5B58\u3055\u308C\u3066\u3044\u308B\u3068\u306F\u9650\u308A\u307E\u305B\u3093\u3002
1222
1229
 
1223
1230
  \u30CF\u30F3\u30C9\u30E9\u306E\u30C6\u30B9\u30C8\u304C \`Connection proxy is not configured\` \u3067\u5931\u6557\u3059\u308B\u5834\u5408\u306F\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u901A\u5E38\u306F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u521D\u671F\u5316\u4E2D\u306B\u8D77\u304D\u307E\u3059\u3002SDK \u3092\u8AE6\u3081\u3066 OAuth \u30D7\u30ED\u30AD\u30B7\u306E URL \u3092\u81EA\u5206\u3067\u7D44\u307F\u7ACB\u3066\u308B\u3053\u3068\u306F **\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044**\u3002
1224
1231
 
@@ -1228,26 +1235,29 @@ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9
1228
1235
  import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
1229
1236
 
1230
1237
  const ga = connection("<connectionId>");
1238
+ const propertyId = "123456789"; // \u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024\u306E GA4 \u30D7\u30ED\u30D1\u30C6\u30A3ID
1231
1239
 
1232
- // Authenticated fetch (returns standard Response)
1233
- const res = await ga.request("properties/{propertyId}:runReport", {
1234
- method: "POST",
1235
- body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
1236
- });
1237
- const data = await res.json();
1238
-
1239
- // Convenience methods
1240
+ // \u4FBF\u5229\u30E1\u30BD\u30C3\u30C9\uFF08propertyId \u3092\u660E\u793A\u7684\u306B\u6E21\u3059\uFF09
1240
1241
  const { rows, rowCount } = await ga.runReport({
1242
+ propertyId,
1241
1243
  dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
1242
1244
  dimensions: [{ name: "date" }],
1243
1245
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
1244
1246
  limit: 100,
1245
1247
  });
1246
- const metadata = await ga.getMetadata();
1248
+ const metadata = await ga.getMetadata(propertyId);
1247
1249
  const realtime = await ga.runRealtimeReport({
1250
+ propertyId,
1248
1251
  metrics: [{ name: "activeUsers" }],
1249
1252
  dimensions: [{ name: "country" }],
1250
1253
  });
1254
+
1255
+ // \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u30D1\u30B9\u306B\u76F4\u63A5\u66F8\u304F\uFF09
1256
+ const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
1257
+ method: "POST",
1258
+ body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
1259
+ });
1260
+ const data = await res.json();
1251
1261
  \`\`\``
1252
1262
  },
1253
1263
  tools,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  import * as hono_types from 'hono/types';
2
+ import * as hono from 'hono';
2
3
  import { Hono } from 'hono';
3
4
 
5
+ /**
6
+ * Called once at startup by the build-generated server entry with the map of
7
+ * bundled TypeScript handlers. See `vite-plugin.ts`.
8
+ */
9
+ declare function registerBundledHandlers(handlers: Record<string, (c: hono.Context) => Promise<unknown>>): void;
10
+
4
11
  interface ConnectionEntry {
5
12
  connector: {
6
13
  slug: string;
@@ -283,4 +290,4 @@ declare const storage: {
283
290
 
284
291
  declare const app: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
285
292
 
286
- export { type AirtableClient, type AirtableRecord, type ConnectionEntry, type ConnectionFetchOptions, type ConnectionsMap, type DbtClient, type GoogleAnalyticsClient, type KintoneClient, type PresignedGetResult, PresignedHttpsTransport, type PresignedPutResult, type QueryFn, type GetResult as StorageGetResult, type StorageListItem, type ListOptions as StorageListOptions, type StorageListResult, type StorageMetadata, type PutOptions as StoragePutOptions, type StorageTransport, StorageUploadsClient, type StorageUsageDelta, type WixStoreClient, connection, createAirtableClient, createDbtClient, createGoogleAnalyticsClient, createKintoneClient, createWixStoreClient, app as default, getQuery, loadConnections, storage };
293
+ export { type AirtableClient, type AirtableRecord, type ConnectionEntry, type ConnectionFetchOptions, type ConnectionsMap, type DbtClient, type GoogleAnalyticsClient, type KintoneClient, type PresignedGetResult, PresignedHttpsTransport, type PresignedPutResult, type QueryFn, type GetResult as StorageGetResult, type StorageListItem, type ListOptions as StorageListOptions, type StorageListResult, type StorageMetadata, type PutOptions as StoragePutOptions, type StorageTransport, StorageUploadsClient, type StorageUsageDelta, type WixStoreClient, connection, createAirtableClient, createDbtClient, createGoogleAnalyticsClient, createKintoneClient, createWixStoreClient, app as default, getQuery, loadConnections, registerBundledHandlers, storage };