@squadbase/vite-server 0.1.19-dev.6ec878e → 0.1.19-dev.907a033
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-entry/server-entry.mjs +18 -0
- package/dist/cli/index.js +60 -65
- package/dist/connectors/google-analytics-oauth.js +72 -142
- package/dist/index.d.ts +8 -1
- package/dist/index.js +82 -88
- package/dist/main.d.ts +1 -0
- package/dist/main.js +83 -89
- package/dist/vite-plugin.d.ts +0 -1
- package/dist/vite-plugin.js +144 -82
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -10505,11 +10505,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
10505
10505
|
- \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **1\u4EF6\u306E\u307F**: \`askUserQuestion\` \u306F\u30B9\u30AD\u30C3\u30D7\u3057\u3001\u305D\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u6E08\u307F\u3068\u3057\u3066\u6B21\u3078\u9032\u3080
|
|
10506
10506
|
- \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **0\u4EF6**: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
|
|
10507
10507
|
3. \`${listPropertiesToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u9078\u629E\u3055\u308C\u305F\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
10508
|
-
4.
|
|
10509
|
-
- \`
|
|
10510
|
-
-
|
|
10511
|
-
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6
|
|
10512
|
-
5. \
|
|
10508
|
+
4. \u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u9078\u629E:
|
|
10509
|
+
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **2\u4EF6\u4EE5\u4E0A**: \u300C\u4F7F\u7528\u3059\u308B\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059\uFF08\`options\`: \u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (id: \u30D7\u30ED\u30D1\u30C6\u30A3ID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30D7\u30ED\u30D1\u30C6\u30A3ID\uFF09
|
|
10510
|
+
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **1\u4EF6\u306E\u307F**: \`askUserQuestion\` \u306F\u30B9\u30AD\u30C3\u30D7\u3057\u3001\u305D\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u6E08\u307F\u3068\u3057\u3066\u6B21\u3078\u9032\u3080
|
|
10511
|
+
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6**: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
|
|
10512
|
+
5. \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3ID\uFF08\u6570\u5024\uFF09\u306F\u4EE5\u964D\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u3067\u30D1\u30B9\u306B\u76F4\u63A5\u6307\u5B9A\u3059\u308B\uFF08\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u306F\u4FDD\u5B58\u3055\u308C\u306A\u3044\uFF09\u3002\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080
|
|
10513
10513
|
|
|
10514
10514
|
#### \u5236\u7D04
|
|
10515
10515
|
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30EC\u30DD\u30FC\u30C8\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u306E\u307F
|
|
@@ -10523,11 +10523,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
10523
10523
|
- **Only 1 account**: Skip \`askUserQuestion\` and proceed using that account as the selection
|
|
10524
10524
|
- **0 accounts**: Abort setup and inform the user that no accessible accounts are available
|
|
10525
10525
|
3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
|
|
10526
|
-
4.
|
|
10527
|
-
- \`
|
|
10528
|
-
-
|
|
10529
|
-
-
|
|
10530
|
-
5.
|
|
10526
|
+
4. Select a property:
|
|
10527
|
+
- **2 or more properties**: Tell the user "Please select a property.", then call \`askUserQuestion\` (\`options\`: each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID)
|
|
10528
|
+
- **Only 1 property**: Skip \`askUserQuestion\` and proceed using that property as the selection
|
|
10529
|
+
- **0 properties**: Abort setup and inform the user that no accessible properties are available
|
|
10530
|
+
5. Write the selected numeric property id directly into the request path (it is not stored on the connection). Proceed to the next step
|
|
10531
10531
|
|
|
10532
10532
|
#### Constraints
|
|
10533
10533
|
- **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
|
|
@@ -10535,26 +10535,17 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
10535
10535
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
10536
10536
|
},
|
|
10537
10537
|
dataOverviewInstructions: {
|
|
10538
|
-
en: `
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10538
|
+
en: `Use the selected numeric property id in the path (write it directly, e.g. properties/123456789).
|
|
10539
|
+
1. Call connector_google-analytics-oauth_request with GET properties/<propertyId>/metadata to list available dimensions and metrics
|
|
10540
|
+
2. Call connector_google-analytics-oauth_request with POST properties/<propertyId>:runReport using a small date range and basic metrics to verify data availability`,
|
|
10541
|
+
ja: `\u9078\u629E\u3057\u305F\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u30D1\u30B9\u306B\u76F4\u63A5\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: properties/123456789\uFF09\u3002
|
|
10542
|
+
1. connector_google-analytics-oauth_request \u3067 GET properties/<propertyId>/metadata \u3092\u547C\u3073\u51FA\u3057\u3001\u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u306E\u4E00\u89A7\u3092\u53D6\u5F97
|
|
10543
|
+
2. connector_google-analytics-oauth_request \u3067 POST properties/<propertyId>:runReport \u3092\u77ED\u3044\u671F\u9593\u3068\u57FA\u672C\u30E1\u30C8\u30EA\u30AF\u30B9\u3067\u547C\u3073\u51FA\u3057\u3001\u30C7\u30FC\u30BF\u306E\u53EF\u7528\u6027\u3092\u78BA\u8A8D`
|
|
10542
10544
|
}
|
|
10543
10545
|
});
|
|
10544
10546
|
|
|
10545
10547
|
// ../connectors/src/connectors/google-analytics-oauth/parameters.ts
|
|
10546
|
-
|
|
10547
|
-
var parameters16 = {
|
|
10548
|
-
propertyId: new ParameterDefinition({
|
|
10549
|
-
slug: "property-id",
|
|
10550
|
-
name: "Google Analytics Property ID",
|
|
10551
|
-
description: "The Google Analytics 4 property ID (e.g., 123456789). Can be found in GA4 Admin > Property Settings.",
|
|
10552
|
-
envVarBaseKey: "GA_OAUTH_PROPERTY_ID",
|
|
10553
|
-
type: "text",
|
|
10554
|
-
secret: false,
|
|
10555
|
-
required: false
|
|
10556
|
-
})
|
|
10557
|
-
};
|
|
10548
|
+
var parameters16 = {};
|
|
10558
10549
|
|
|
10559
10550
|
// ../connectors/src/connectors/google-analytics-oauth/setup-flow.ts
|
|
10560
10551
|
var ADMIN_BASE_URL4 = "https://analyticsadmin.googleapis.com/v1beta";
|
|
@@ -10861,7 +10852,7 @@ var inputSchema25 = z25.object({
|
|
|
10861
10852
|
connectionId: z25.string().describe("ID of the Google Analytics OAuth connection to use"),
|
|
10862
10853
|
method: z25.enum(["GET", "POST"]).describe("HTTP method"),
|
|
10863
10854
|
path: z25.string().describe(
|
|
10864
|
-
"API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/
|
|
10855
|
+
"API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/123456789:runReport'). Write the numeric property id directly into the path."
|
|
10865
10856
|
),
|
|
10866
10857
|
body: z25.record(z25.string(), z25.unknown()).optional().describe("POST request body (JSON)")
|
|
10867
10858
|
});
|
|
@@ -10880,7 +10871,7 @@ var requestTool4 = new ConnectorTool({
|
|
|
10880
10871
|
name: "request",
|
|
10881
10872
|
description: `Send authenticated requests to the Google Analytics Data API v1beta.
|
|
10882
10873
|
Authentication is handled automatically via OAuth proxy.
|
|
10883
|
-
|
|
10874
|
+
Write the numeric property id directly into the path (e.g. properties/123456789:runReport).`,
|
|
10884
10875
|
inputSchema: inputSchema25,
|
|
10885
10876
|
outputSchema: outputSchema25,
|
|
10886
10877
|
async execute({ connectionId, method, path: path6, body }, connections, config) {
|
|
@@ -10895,9 +10886,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
10895
10886
|
`[connector-request] google-analytics-oauth/${connection2.name}: ${method} ${path6}`
|
|
10896
10887
|
);
|
|
10897
10888
|
try {
|
|
10898
|
-
const
|
|
10899
|
-
const resolvedPath = propertyId ? path6.replace(/\{propertyId\}/g, propertyId) : path6;
|
|
10900
|
-
const url = `${BASE_URL4}${resolvedPath}`;
|
|
10889
|
+
const url = `${BASE_URL4}${path6}`;
|
|
10901
10890
|
const token = await getProxyToken8(config.oauthProxy);
|
|
10902
10891
|
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
10903
10892
|
const controller = new AbortController();
|
|
@@ -10967,7 +10956,7 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
|
|
|
10967
10956
|
systemPrompt: {
|
|
10968
10957
|
en: `### Tools
|
|
10969
10958
|
|
|
10970
|
-
- \`connector_google-analytics-oauth_request\`: Send authenticated requests to the GA4 Data API. Use it for running reports, getting metadata, and realtime reports.
|
|
10959
|
+
- \`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}\`. Authentication is configured automatically via OAuth.
|
|
10971
10960
|
- \`connector_google-analytics-oauth_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
|
|
10972
10961
|
- \`connector_google-analytics-oauth_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
|
|
10973
10962
|
|
|
@@ -11003,10 +10992,12 @@ averageSessionDuration, conversions, totalRevenue
|
|
|
11003
10992
|
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.
|
|
11004
10993
|
|
|
11005
10994
|
SDK surface (client created via \`connection(connectionId)\`):
|
|
11006
|
-
- \`client.request(
|
|
11007
|
-
- \`client.
|
|
11008
|
-
- \`client.
|
|
11009
|
-
- \`client.
|
|
10995
|
+
- \`client.runReport(request)\` \u2014 run a GA4 report and get back \`{ rows, rowCount }\` (JSON, already parsed). **This is the primary method \u2014 prefer it over \`request\`.** Pass \`propertyId\` (bare numeric id) on the request object to target a property.
|
|
10996
|
+
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report. \`propertyId\` works the same as \`runReport\`.
|
|
10997
|
+
- \`client.getMetadata(propertyId)\` \u2014 fetch available dimensions and metrics for a property.
|
|
10998
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch that returns a raw \`Response\` (\`path\` is appended to \`https://analyticsdata.googleapis.com/v1beta/\`; write the numeric property id directly into the path). Only use this for endpoints the convenience methods above do not cover, and remember to \`await res.json()\` yourself.
|
|
10999
|
+
|
|
11000
|
+
**\`propertyId\` is required on every call** \u2014 pass the numeric id from the data overview. A GA connection can span multiple properties, so there is no stored default.
|
|
11010
11001
|
|
|
11011
11002
|
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.
|
|
11012
11003
|
|
|
@@ -11016,30 +11007,33 @@ If a handler test fails with \`Connection proxy is not configured\`, retry \u201
|
|
|
11016
11007
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
|
|
11017
11008
|
|
|
11018
11009
|
const ga = connection("<connectionId>");
|
|
11010
|
+
const propertyId = "123456789"; // numeric GA4 property id from the data overview
|
|
11019
11011
|
|
|
11020
|
-
//
|
|
11021
|
-
const res = await ga.request("properties/{propertyId}:runReport", {
|
|
11022
|
-
method: "POST",
|
|
11023
|
-
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11024
|
-
});
|
|
11025
|
-
const data = await res.json();
|
|
11026
|
-
|
|
11027
|
-
// Convenience methods
|
|
11012
|
+
// Convenience methods (pass propertyId explicitly)
|
|
11028
11013
|
const { rows, rowCount } = await ga.runReport({
|
|
11014
|
+
propertyId,
|
|
11029
11015
|
dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
|
|
11030
11016
|
dimensions: [{ name: "date" }],
|
|
11031
11017
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
11032
11018
|
limit: 100,
|
|
11033
11019
|
});
|
|
11034
|
-
const metadata = await ga.getMetadata();
|
|
11020
|
+
const metadata = await ga.getMetadata(propertyId);
|
|
11035
11021
|
const realtime = await ga.runRealtimeReport({
|
|
11022
|
+
propertyId,
|
|
11036
11023
|
metrics: [{ name: "activeUsers" }],
|
|
11037
11024
|
dimensions: [{ name: "country" }],
|
|
11038
11025
|
});
|
|
11026
|
+
|
|
11027
|
+
// Low-level authenticated fetch (write the numeric property id into the path)
|
|
11028
|
+
const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
|
|
11029
|
+
method: "POST",
|
|
11030
|
+
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11031
|
+
});
|
|
11032
|
+
const data = await res.json();
|
|
11039
11033
|
\`\`\``,
|
|
11040
11034
|
ja: `### \u30C4\u30FC\u30EB
|
|
11041
11035
|
|
|
11042
|
-
- \`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\
|
|
11036
|
+
- \`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\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
|
|
11043
11037
|
- \`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
|
|
11044
11038
|
- \`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
|
|
11045
11039
|
|
|
@@ -11075,10 +11069,12 @@ averageSessionDuration, conversions, totalRevenue
|
|
|
11075
11069
|
\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
|
|
11076
11070
|
|
|
11077
11071
|
SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
|
|
11078
|
-
- \`client.request
|
|
11079
|
-
- \`client.
|
|
11080
|
-
- \`client.
|
|
11081
|
-
- \`client.
|
|
11072
|
+
- \`client.runReport(request)\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3057\u3001\`{ rows, rowCount }\`\uFF08\u30D1\u30FC\u30B9\u6E08\u307F JSON\uFF09\u3092\u8FD4\u3057\u307E\u3059\u3002**\u3053\u308C\u304C\u4E3B\u8981\u30E1\u30BD\u30C3\u30C9\u3067\u3059 \u2014 \`request\` \u3088\u308A\u512A\u5148\u3057\u3066\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\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
|
|
11073
|
+
- \`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
|
|
11074
|
+
- \`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
|
|
11075
|
+
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\u3002\u751F\u306E \`Response\` \u3092\u8FD4\u3057\u307E\u3059\uFF08\`path\` \u306F \`https://analyticsdata.googleapis.com/v1beta/\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\u3002\u6570\u5024\u306E\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u30D1\u30B9\u306B\u76F4\u63A5\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002\u4E0A\u8A18\u306E\u4FBF\u5229\u30E1\u30BD\u30C3\u30C9\u3067\u8CC4\u3048\u306A\u3044\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306E\u5834\u5408\u306E\u307F\u4F7F\u7528\u3057\u3001\`await res.json()\` \u306F\u81EA\u5206\u3067\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
11076
|
+
|
|
11077
|
+
**\`propertyId\` \u306F\u3059\u3079\u3066\u306E\u547C\u3073\u51FA\u3057\u3067\u5FC5\u9808\u3067\u3059**\uFF08\u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024ID\uFF09\u3002GA \u306E\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306F\u8907\u6570\u30D7\u30ED\u30D1\u30C6\u30A3\u306B\u307E\u305F\u304C\u308B\u3053\u3068\u304C\u3042\u308B\u305F\u3081\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u4FDD\u5B58\u3055\u308C\u307E\u305B\u3093\u3002
|
|
11082
11078
|
|
|
11083
11079
|
\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
|
|
11084
11080
|
|
|
@@ -11088,37 +11084,36 @@ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9
|
|
|
11088
11084
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
|
|
11089
11085
|
|
|
11090
11086
|
const ga = connection("<connectionId>");
|
|
11087
|
+
const propertyId = "123456789"; // \u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024\u306E GA4 \u30D7\u30ED\u30D1\u30C6\u30A3ID
|
|
11091
11088
|
|
|
11092
|
-
//
|
|
11093
|
-
const res = await ga.request("properties/{propertyId}:runReport", {
|
|
11094
|
-
method: "POST",
|
|
11095
|
-
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11096
|
-
});
|
|
11097
|
-
const data = await res.json();
|
|
11098
|
-
|
|
11099
|
-
// Convenience methods
|
|
11089
|
+
// \u4FBF\u5229\u30E1\u30BD\u30C3\u30C9\uFF08propertyId \u3092\u660E\u793A\u7684\u306B\u6E21\u3059\uFF09
|
|
11100
11090
|
const { rows, rowCount } = await ga.runReport({
|
|
11091
|
+
propertyId,
|
|
11101
11092
|
dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
|
|
11102
11093
|
dimensions: [{ name: "date" }],
|
|
11103
11094
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
11104
11095
|
limit: 100,
|
|
11105
11096
|
});
|
|
11106
|
-
const metadata = await ga.getMetadata();
|
|
11097
|
+
const metadata = await ga.getMetadata(propertyId);
|
|
11107
11098
|
const realtime = await ga.runRealtimeReport({
|
|
11099
|
+
propertyId,
|
|
11108
11100
|
metrics: [{ name: "activeUsers" }],
|
|
11109
11101
|
dimensions: [{ name: "country" }],
|
|
11110
11102
|
});
|
|
11103
|
+
|
|
11104
|
+
// \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
|
|
11105
|
+
const res = await ga.request(\`properties/\${propertyId}:runReport\`, {
|
|
11106
|
+
method: "POST",
|
|
11107
|
+
body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
|
|
11108
|
+
});
|
|
11109
|
+
const data = await res.json();
|
|
11111
11110
|
\`\`\``
|
|
11112
11111
|
},
|
|
11113
11112
|
tools: tools16,
|
|
11114
11113
|
setup: (params, ctx, config) => runSetupFlow(googleAnalyticsOauthSetupFlow, params, ctx, config),
|
|
11115
|
-
async checkConnection(
|
|
11114
|
+
async checkConnection(_params, config) {
|
|
11116
11115
|
const { proxyFetch } = config;
|
|
11117
|
-
const
|
|
11118
|
-
if (!propertyId) {
|
|
11119
|
-
return { success: true };
|
|
11120
|
-
}
|
|
11121
|
-
const url = `https://analyticsdata.googleapis.com/v1beta/properties/${propertyId}/metadata`;
|
|
11116
|
+
const url = "https://analyticsadmin.googleapis.com/v1beta/accountSummaries";
|
|
11122
11117
|
try {
|
|
11123
11118
|
const res = await proxyFetch(url, { method: "GET" });
|
|
11124
11119
|
if (!res.ok) {
|
|
@@ -47440,31 +47435,29 @@ function validateHandlerPath(dirPath, handlerPath) {
|
|
|
47440
47435
|
}
|
|
47441
47436
|
return absolute;
|
|
47442
47437
|
}
|
|
47443
|
-
var
|
|
47444
|
-
|
|
47445
|
-
|
|
47446
|
-
const cached = jitiModuleCache.get(absolutePath);
|
|
47447
|
-
if (cached) return cached;
|
|
47448
|
-
if (!jitiInstance) {
|
|
47449
|
-
const { createJiti } = await import("jiti");
|
|
47450
|
-
jitiInstance = createJiti(import.meta.url, { fsCache: false });
|
|
47451
|
-
}
|
|
47452
|
-
const mod = await jitiInstance.import(absolutePath);
|
|
47453
|
-
jitiModuleCache.set(absolutePath, mod);
|
|
47454
|
-
return mod;
|
|
47438
|
+
var bundledHandlers = {};
|
|
47439
|
+
function registerBundledHandlers(handlers) {
|
|
47440
|
+
bundledHandlers = handlers;
|
|
47455
47441
|
}
|
|
47456
|
-
async function loadTypeScriptHandler(absolutePath) {
|
|
47457
|
-
let mod;
|
|
47442
|
+
async function loadTypeScriptHandler(slug, absolutePath) {
|
|
47458
47443
|
if (viteServer) {
|
|
47459
47444
|
const module = viteServer.moduleGraph.getModuleById(absolutePath);
|
|
47460
47445
|
if (module) viteServer.moduleGraph.invalidateModule(module);
|
|
47461
|
-
mod = await viteServer.ssrLoadModule(absolutePath);
|
|
47462
|
-
|
|
47463
|
-
|
|
47446
|
+
const mod = await viteServer.ssrLoadModule(absolutePath);
|
|
47447
|
+
const handler2 = mod.default;
|
|
47448
|
+
if (typeof handler2 !== "function") {
|
|
47449
|
+
throw new Error(`Handler must export a default function: ${absolutePath}`);
|
|
47450
|
+
}
|
|
47451
|
+
return handler2;
|
|
47452
|
+
}
|
|
47453
|
+
if (!(slug in bundledHandlers)) {
|
|
47454
|
+
throw new Error(
|
|
47455
|
+
`Bundled handler not found for server logic: ${slug} (not compiled into the build)`
|
|
47456
|
+
);
|
|
47464
47457
|
}
|
|
47465
|
-
const handler =
|
|
47458
|
+
const handler = bundledHandlers[slug];
|
|
47466
47459
|
if (typeof handler !== "function") {
|
|
47467
|
-
throw new Error(`
|
|
47460
|
+
throw new Error(`Server logic '${slug}' must export a default function`);
|
|
47468
47461
|
}
|
|
47469
47462
|
return handler;
|
|
47470
47463
|
}
|
|
@@ -47761,7 +47754,7 @@ app.get("/:slug", async (c) => {
|
|
|
47761
47754
|
}
|
|
47762
47755
|
try {
|
|
47763
47756
|
if (ds._isTypescript && ds._tsHandlerPath) {
|
|
47764
|
-
const handler = await loadTypeScriptHandler(ds._tsHandlerPath);
|
|
47757
|
+
const handler = await loadTypeScriptHandler(slug, ds._tsHandlerPath);
|
|
47765
47758
|
const result = await handler(c);
|
|
47766
47759
|
return result;
|
|
47767
47760
|
} else {
|
|
@@ -47789,7 +47782,7 @@ app.post("/:slug", async (c) => {
|
|
|
47789
47782
|
const ttl = cacheConfig?.ttl ?? 0;
|
|
47790
47783
|
if (ttl <= 0) {
|
|
47791
47784
|
if (ds._isTypescript && ds._tsHandlerPath) {
|
|
47792
|
-
const handler = await loadTypeScriptHandler(ds._tsHandlerPath);
|
|
47785
|
+
const handler = await loadTypeScriptHandler(slug, ds._tsHandlerPath);
|
|
47793
47786
|
const result = await handler(c);
|
|
47794
47787
|
return result;
|
|
47795
47788
|
} else {
|
|
@@ -47813,7 +47806,7 @@ app.post("/:slug", async (c) => {
|
|
|
47813
47806
|
void (async () => {
|
|
47814
47807
|
try {
|
|
47815
47808
|
if (ds._isTypescript && ds._tsHandlerPath) {
|
|
47816
|
-
const tsHandler = await loadTypeScriptHandler(ds._tsHandlerPath);
|
|
47809
|
+
const tsHandler = await loadTypeScriptHandler(slug, ds._tsHandlerPath);
|
|
47817
47810
|
const freshResponse = await tsHandler(c);
|
|
47818
47811
|
const outcome = await cacheTypescriptResponse(freshResponse);
|
|
47819
47812
|
if (outcome.cacheable) {
|
|
@@ -47837,7 +47830,7 @@ app.post("/:slug", async (c) => {
|
|
|
47837
47830
|
}
|
|
47838
47831
|
}
|
|
47839
47832
|
if (ds._isTypescript && ds._tsHandlerPath) {
|
|
47840
|
-
const handler = await loadTypeScriptHandler(ds._tsHandlerPath);
|
|
47833
|
+
const handler = await loadTypeScriptHandler(slug, ds._tsHandlerPath);
|
|
47841
47834
|
const response = await handler(c);
|
|
47842
47835
|
const outcome = await cacheTypescriptResponse(response);
|
|
47843
47836
|
if (outcome.cacheable) {
|
|
@@ -48242,5 +48235,6 @@ src_default.get("*", (c) => {
|
|
|
48242
48235
|
});
|
|
48243
48236
|
var main_default = src_default;
|
|
48244
48237
|
export {
|
|
48245
|
-
main_default as default
|
|
48238
|
+
main_default as default,
|
|
48239
|
+
registerBundledHandlers
|
|
48246
48240
|
};
|