@squadbase/vite-server 0.1.17-dev.7408ec4 → 0.1.17-dev.9d1f952
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/dist/cli/index.js +32 -51
- package/dist/connectors/airtable-oauth.js +6 -0
- package/dist/connectors/airtable.js +6 -0
- package/dist/connectors/amplitude.js +6 -0
- package/dist/connectors/asana.js +6 -0
- package/dist/connectors/attio.js +6 -0
- package/dist/connectors/aws-billing.js +6 -0
- package/dist/connectors/azure-sql.js +6 -0
- package/dist/connectors/backlog-api-key.js +6 -0
- package/dist/connectors/clickup.js +6 -0
- package/dist/connectors/cosmosdb.js +6 -0
- package/dist/connectors/customerio.js +6 -0
- package/dist/connectors/dbt.js +6 -0
- package/dist/connectors/freshdesk.js +6 -0
- package/dist/connectors/freshsales.js +6 -0
- package/dist/connectors/freshservice.js +6 -0
- package/dist/connectors/gamma.js +6 -0
- package/dist/connectors/github.js +6 -0
- package/dist/connectors/gmail-oauth.js +6 -0
- package/dist/connectors/gmail.js +6 -0
- package/dist/connectors/google-ads.js +6 -0
- package/dist/connectors/google-analytics-oauth.js +6 -0
- package/dist/connectors/google-analytics.js +53 -64
- package/dist/connectors/google-audit-log.js +6 -0
- package/dist/connectors/google-calendar-oauth.js +6 -0
- package/dist/connectors/google-calendar.js +6 -0
- package/dist/connectors/google-docs.js +6 -0
- package/dist/connectors/google-drive.js +6 -0
- package/dist/connectors/google-search-console-oauth.js +6 -0
- package/dist/connectors/google-sheets.js +6 -0
- package/dist/connectors/google-slides.js +6 -0
- package/dist/connectors/grafana.js +6 -0
- package/dist/connectors/hubspot-oauth.js +6 -0
- package/dist/connectors/hubspot.js +6 -0
- package/dist/connectors/influxdb.js +6 -0
- package/dist/connectors/intercom-oauth.js +6 -0
- package/dist/connectors/intercom.js +6 -0
- package/dist/connectors/jdbc.js +6 -0
- package/dist/connectors/jira-api-key.js +6 -0
- package/dist/connectors/kintone-api-token.js +6 -0
- package/dist/connectors/kintone.js +6 -0
- package/dist/connectors/linear.js +6 -0
- package/dist/connectors/linkedin-ads.js +6 -0
- package/dist/connectors/mailchimp-oauth.js +6 -0
- package/dist/connectors/mailchimp.js +6 -0
- package/dist/connectors/meta-ads-oauth.js +6 -0
- package/dist/connectors/meta-ads.js +6 -0
- package/dist/connectors/mixpanel.js +6 -0
- package/dist/connectors/monday.js +6 -0
- package/dist/connectors/mongodb.js +6 -0
- package/dist/connectors/notion-oauth.js +6 -0
- package/dist/connectors/notion.js +6 -0
- package/dist/connectors/oracle.js +6 -0
- package/dist/connectors/outlook-oauth.js +6 -0
- package/dist/connectors/powerbi-oauth.js +6 -0
- package/dist/connectors/salesforce.js +6 -0
- package/dist/connectors/semrush.js +6 -0
- package/dist/connectors/sentry.js +6 -0
- package/dist/connectors/shopify-oauth.js +6 -0
- package/dist/connectors/shopify.js +6 -0
- package/dist/connectors/sqlserver.js +6 -0
- package/dist/connectors/stripe-api-key.js +6 -0
- package/dist/connectors/stripe-oauth.js +6 -0
- package/dist/connectors/supabase.js +6 -0
- package/dist/connectors/tableau.js +6 -0
- package/dist/connectors/tiktok-ads.js +6 -0
- package/dist/connectors/wix-store.js +6 -0
- package/dist/connectors/zendesk-oauth.js +6 -0
- package/dist/connectors/zendesk.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -57
- package/dist/main.js +32 -51
- package/dist/vite-plugin.js +32 -51
- package/package.json +1 -1
|
@@ -67,15 +67,6 @@ var parameters = {
|
|
|
67
67
|
type: "base64EncodedJson",
|
|
68
68
|
secret: true,
|
|
69
69
|
required: true
|
|
70
|
-
}),
|
|
71
|
-
propertyId: new ParameterDefinition({
|
|
72
|
-
slug: "property-id",
|
|
73
|
-
name: "Google Analytics Property ID",
|
|
74
|
-
description: "The Google Analytics 4 property ID (e.g., 123456789). Automatically set during the setup flow.",
|
|
75
|
-
envVarBaseKey: "GA_PROPERTY_ID",
|
|
76
|
-
type: "text",
|
|
77
|
-
secret: false,
|
|
78
|
-
required: false
|
|
79
70
|
})
|
|
80
71
|
};
|
|
81
72
|
|
|
@@ -107,15 +98,10 @@ function buildJwt(clientEmail, privateKey, nowSec) {
|
|
|
107
98
|
}
|
|
108
99
|
function createClient(params) {
|
|
109
100
|
const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
|
|
110
|
-
const
|
|
111
|
-
if (!serviceAccountKeyJsonBase64
|
|
112
|
-
const required = [
|
|
113
|
-
parameters.serviceAccountKeyJsonBase64.slug,
|
|
114
|
-
parameters.propertyId.slug
|
|
115
|
-
];
|
|
116
|
-
const missing = required.filter((s) => !params[s]);
|
|
101
|
+
const defaultPropertyId = params["property-id"] ?? "";
|
|
102
|
+
if (!serviceAccountKeyJsonBase64) {
|
|
117
103
|
throw new Error(
|
|
118
|
-
`google-analytics: missing required parameters: ${
|
|
104
|
+
`google-analytics: missing required parameters: ${parameters.serviceAccountKeyJsonBase64.slug}`
|
|
119
105
|
);
|
|
120
106
|
}
|
|
121
107
|
let serviceAccountKey;
|
|
@@ -169,19 +155,23 @@ function createClient(params) {
|
|
|
169
155
|
return {
|
|
170
156
|
async request(path2, init) {
|
|
171
157
|
const accessToken = await getAccessToken2();
|
|
172
|
-
const
|
|
173
|
-
const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
|
|
158
|
+
const url = `${BASE_URL.replace(/\/+$/, "")}/${path2.replace(/^\/+/, "")}`;
|
|
174
159
|
const headers = new Headers(init?.headers);
|
|
175
160
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
176
161
|
return fetch(url, { ...init, headers });
|
|
177
162
|
},
|
|
178
163
|
async runReport(request) {
|
|
164
|
+
const { propertyId: pid, ...body } = request;
|
|
165
|
+
const propertyId = pid || defaultPropertyId;
|
|
166
|
+
if (!propertyId) {
|
|
167
|
+
throw new Error("google-analytics: propertyId is required in runReport request");
|
|
168
|
+
}
|
|
179
169
|
const response = await this.request(
|
|
180
170
|
`properties/${propertyId}:runReport`,
|
|
181
171
|
{
|
|
182
172
|
method: "POST",
|
|
183
173
|
headers: { "Content-Type": "application/json" },
|
|
184
|
-
body: JSON.stringify(
|
|
174
|
+
body: JSON.stringify(body)
|
|
185
175
|
}
|
|
186
176
|
);
|
|
187
177
|
if (!response.ok) {
|
|
@@ -196,7 +186,11 @@ function createClient(params) {
|
|
|
196
186
|
rowCount: data.rowCount ?? 0
|
|
197
187
|
};
|
|
198
188
|
},
|
|
199
|
-
async getMetadata() {
|
|
189
|
+
async getMetadata(request) {
|
|
190
|
+
const propertyId = request.propertyId || defaultPropertyId;
|
|
191
|
+
if (!propertyId) {
|
|
192
|
+
throw new Error("google-analytics: propertyId is required in getMetadata request");
|
|
193
|
+
}
|
|
200
194
|
const response = await this.request(
|
|
201
195
|
`properties/${propertyId}/metadata`,
|
|
202
196
|
{ method: "GET" }
|
|
@@ -210,12 +204,17 @@ function createClient(params) {
|
|
|
210
204
|
return await response.json();
|
|
211
205
|
},
|
|
212
206
|
async runRealtimeReport(request) {
|
|
207
|
+
const { propertyId: pid, ...body } = request;
|
|
208
|
+
const propertyId = pid || defaultPropertyId;
|
|
209
|
+
if (!propertyId) {
|
|
210
|
+
throw new Error("google-analytics: propertyId is required in runRealtimeReport request");
|
|
211
|
+
}
|
|
213
212
|
const response = await this.request(
|
|
214
213
|
`properties/${propertyId}:runRealtimeReport`,
|
|
215
214
|
{
|
|
216
215
|
method: "POST",
|
|
217
216
|
headers: { "Content-Type": "application/json" },
|
|
218
|
-
body: JSON.stringify(
|
|
217
|
+
body: JSON.stringify(body)
|
|
219
218
|
}
|
|
220
219
|
);
|
|
221
220
|
if (!response.ok) {
|
|
@@ -418,6 +417,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
418
417
|
}
|
|
419
418
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
420
419
|
if (step.type === "text") {
|
|
420
|
+
if (step.fetchOptions) {
|
|
421
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
422
|
+
if (options2.length === 0) {
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
421
426
|
return {
|
|
422
427
|
type: "nextQuestion",
|
|
423
428
|
questionSlug: step.slug,
|
|
@@ -714,40 +719,23 @@ var googleAnalyticsSetupFlow = {
|
|
|
714
719
|
return [];
|
|
715
720
|
}
|
|
716
721
|
},
|
|
717
|
-
applyAnswer: (state, answer) => ({ ...state, properties: answer })
|
|
718
|
-
toParameterUpdates: (state) => {
|
|
719
|
-
const first = state.properties?.find((v) => v !== ALL_PROPERTIES);
|
|
720
|
-
return first ? [{ slug: parameters.propertyId.slug, value: first }] : [];
|
|
721
|
-
}
|
|
722
|
+
applyAnswer: (state, answer) => ({ ...state, properties: answer })
|
|
722
723
|
},
|
|
723
724
|
{
|
|
724
725
|
slug: "manualPropertyId",
|
|
725
|
-
type: "
|
|
726
|
-
allowFreeText: true,
|
|
726
|
+
type: "text",
|
|
727
727
|
question: {
|
|
728
728
|
ja: "GA4 \u30D7\u30ED\u30D1\u30C6\u30A3 ID \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: 123456789\uFF09\u3002GA4 \u7BA1\u7406\u753B\u9762 > \u30D7\u30ED\u30D1\u30C6\u30A3\u8A2D\u5B9A\u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002",
|
|
729
729
|
en: "Enter your GA4 Property ID (e.g., 123456789). Found in GA4 Admin > Property Settings."
|
|
730
730
|
},
|
|
731
|
-
async fetchOptions(state
|
|
731
|
+
async fetchOptions(state) {
|
|
732
732
|
if (state.properties?.length) return [];
|
|
733
|
-
|
|
734
|
-
return existing ? [{ value: existing, label: existing }] : [
|
|
735
|
-
{
|
|
736
|
-
value: "example",
|
|
737
|
-
label: rt.language === "ja" ? "\u4F8B: 123456789" : "Example: 123456789"
|
|
738
|
-
}
|
|
739
|
-
];
|
|
733
|
+
return [{ value: "_show", label: "" }];
|
|
740
734
|
},
|
|
741
735
|
applyAnswer: (state, answer) => ({
|
|
742
736
|
...state,
|
|
743
737
|
manualPropertyId: answer[0]
|
|
744
|
-
})
|
|
745
|
-
toParameterUpdates: (state) => state.manualPropertyId ? [
|
|
746
|
-
{
|
|
747
|
-
slug: parameters.propertyId.slug,
|
|
748
|
-
value: state.manualPropertyId
|
|
749
|
-
}
|
|
750
|
-
] : []
|
|
738
|
+
})
|
|
751
739
|
}
|
|
752
740
|
],
|
|
753
741
|
async finalize(state, rt) {
|
|
@@ -803,7 +791,7 @@ var googleAnalyticsSetupFlow = {
|
|
|
803
791
|
}
|
|
804
792
|
return sections.join("\n");
|
|
805
793
|
}
|
|
806
|
-
const propertyId = state.manualPropertyId
|
|
794
|
+
const propertyId = state.manualPropertyId;
|
|
807
795
|
if (propertyId) {
|
|
808
796
|
sections.push(`### Property: ${propertyId}`, "");
|
|
809
797
|
const { dimensions, metrics } = await getMetadata(
|
|
@@ -814,7 +802,7 @@ var googleAnalyticsSetupFlow = {
|
|
|
814
802
|
return sections.join("\n");
|
|
815
803
|
}
|
|
816
804
|
sections.push(
|
|
817
|
-
"_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project
|
|
805
|
+
"_Could not list GA4 accounts. Please enable the Google Analytics Admin API in your GCP project. Property ID can be specified per request at runtime._",
|
|
818
806
|
""
|
|
819
807
|
);
|
|
820
808
|
return sections.join("\n");
|
|
@@ -828,8 +816,9 @@ var REQUEST_TIMEOUT_MS = 6e4;
|
|
|
828
816
|
var inputSchema = z.object({
|
|
829
817
|
toolUseIntent: z.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
|
|
830
818
|
connectionId: z.string().describe("ID of the Google Analytics connection to use"),
|
|
819
|
+
propertyId: z.string().describe("GA4 property ID (e.g., '123456789')"),
|
|
831
820
|
method: z.enum(["GET", "POST"]).describe("HTTP method"),
|
|
832
|
-
path: z.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is
|
|
821
|
+
path: z.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is replaced with the propertyId parameter."),
|
|
833
822
|
body: z.record(z.string(), z.unknown()).optional().describe("POST request body (JSON)")
|
|
834
823
|
});
|
|
835
824
|
var outputSchema = z.discriminatedUnion("success", [
|
|
@@ -847,10 +836,10 @@ var requestTool = new ConnectorTool({
|
|
|
847
836
|
name: "request",
|
|
848
837
|
description: `Send authenticated requests to the Google Analytics Data API.
|
|
849
838
|
Authentication is handled automatically using a service account.
|
|
850
|
-
{propertyId} in the path is automatically replaced with the
|
|
839
|
+
{propertyId} in the path is automatically replaced with the propertyId parameter.`,
|
|
851
840
|
inputSchema,
|
|
852
841
|
outputSchema,
|
|
853
|
-
async execute({ connectionId, method, path: path2, body }, connections) {
|
|
842
|
+
async execute({ connectionId, propertyId, method, path: path2, body }, connections) {
|
|
854
843
|
const connection2 = connections.find((c) => c.id === connectionId);
|
|
855
844
|
if (!connection2) {
|
|
856
845
|
return { success: false, error: `Connection ${connectionId} not found` };
|
|
@@ -859,7 +848,6 @@ Authentication is handled automatically using a service account.
|
|
|
859
848
|
try {
|
|
860
849
|
const { GoogleAuth } = await import("google-auth-library");
|
|
861
850
|
const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
862
|
-
const propertyId = parameters.propertyId.getValue(connection2);
|
|
863
851
|
const credentials = JSON.parse(
|
|
864
852
|
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
865
853
|
);
|
|
@@ -919,7 +907,7 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
919
907
|
systemPrompt: {
|
|
920
908
|
en: `### Tools
|
|
921
909
|
|
|
922
|
-
- \`google-analytics-service-account_request\`: The only way to call the GA4 Data API. Use it to fetch metadata, run reports, or run realtime reports. See the GA4 Data API Reference below for available endpoints and request bodies.
|
|
910
|
+
- \`google-analytics-service-account_request\`: The only way to call the GA4 Data API. Use it to fetch metadata, run reports, or run realtime reports. Requires a \`propertyId\` parameter. See the GA4 Data API Reference below for available endpoints and request bodies.
|
|
923
911
|
|
|
924
912
|
### Business Logic
|
|
925
913
|
|
|
@@ -928,9 +916,11 @@ The business logic type for this connector is "typescript". Use the connector SD
|
|
|
928
916
|
SDK methods (client created via \`connection(connectionId)\`):
|
|
929
917
|
- \`client.runReport(request)\` \u2014 run a GA4 report
|
|
930
918
|
- \`client.runRealtimeReport(request)\` \u2014 run a realtime report
|
|
931
|
-
- \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
|
|
919
|
+
- \`client.getMetadata(request)\` \u2014 fetch available dimensions/metrics
|
|
932
920
|
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
933
921
|
|
|
922
|
+
**IMPORTANT**: You MUST always include \`propertyId\` in every SDK method call. The property ID is obtained during the setup flow. Without it, the request will fail.
|
|
923
|
+
|
|
934
924
|
\`\`\`ts
|
|
935
925
|
import type { Context } from "hono";
|
|
936
926
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -938,12 +928,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
|
938
928
|
const ga = connection("<connectionId>");
|
|
939
929
|
|
|
940
930
|
export default async function handler(c: Context) {
|
|
941
|
-
const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
|
|
931
|
+
const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
|
|
932
|
+
propertyId: string;
|
|
942
933
|
startDate?: string;
|
|
943
934
|
endDate?: string;
|
|
944
935
|
}>();
|
|
945
936
|
|
|
946
937
|
const { rows } = await ga.runReport({
|
|
938
|
+
propertyId,
|
|
947
939
|
dateRanges: [{ startDate, endDate }],
|
|
948
940
|
dimensions: [{ name: "date" }],
|
|
949
941
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -987,7 +979,7 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
987
979
|
- Relative: \`"today"\`, \`"yesterday"\`, \`"7daysAgo"\`, \`"30daysAgo"\``,
|
|
988
980
|
ja: `### \u30C4\u30FC\u30EB
|
|
989
981
|
|
|
990
|
-
- \`google-analytics-service-account_request\`: GA4 Data API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306F\u4E0B\u90E8\u306E\u300CGA4 Data API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u300D\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
982
|
+
- \`google-analytics-service-account_request\`: GA4 Data API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u3001\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u3001\u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u306E\u5B9F\u884C\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\`propertyId\` \u30D1\u30E9\u30E1\u30FC\u30BF\u30FC\u304C\u5FC5\u8981\u3067\u3059\u3002\u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306F\u4E0B\u90E8\u306E\u300CGA4 Data API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u300D\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
991
983
|
|
|
992
984
|
### Business Logic
|
|
993
985
|
|
|
@@ -996,9 +988,11 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
996
988
|
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
997
989
|
- \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
998
990
|
- \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
|
|
999
|
-
- \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
|
|
991
|
+
- \`client.getMetadata(request)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
|
|
1000
992
|
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
1001
993
|
|
|
994
|
+
**\u91CD\u8981**: \u3059\u3079\u3066\u306ESDK\u30E1\u30BD\u30C3\u30C9\u547C\u3073\u51FA\u3057\u306B\u306F\u5FC5\u305A \`propertyId\` \u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u30D5\u30ED\u30FC\u3067\u53D6\u5F97\u3055\u308C\u307E\u3059\u3002\u6307\u5B9A\u3057\u306A\u3044\u3068\u30EA\u30AF\u30A8\u30B9\u30C8\u304C\u5931\u6557\u3057\u307E\u3059\u3002
|
|
995
|
+
|
|
1002
996
|
\`\`\`ts
|
|
1003
997
|
import type { Context } from "hono";
|
|
1004
998
|
import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
@@ -1006,12 +1000,14 @@ import { connection } from "@squadbase/vite-server/connectors/google-analytics";
|
|
|
1006
1000
|
const ga = connection("<connectionId>");
|
|
1007
1001
|
|
|
1008
1002
|
export default async function handler(c: Context) {
|
|
1009
|
-
const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
|
|
1003
|
+
const { propertyId, startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
|
|
1004
|
+
propertyId: string;
|
|
1010
1005
|
startDate?: string;
|
|
1011
1006
|
endDate?: string;
|
|
1012
1007
|
}>();
|
|
1013
1008
|
|
|
1014
1009
|
const { rows } = await ga.runReport({
|
|
1010
|
+
propertyId,
|
|
1015
1011
|
dateRanges: [{ startDate, endDate }],
|
|
1016
1012
|
dimensions: [{ name: "date" }],
|
|
1017
1013
|
metrics: [{ name: "activeUsers" }, { name: "sessions" }],
|
|
@@ -1064,15 +1060,8 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
|
|
|
1064
1060
|
error: "google-analytics: missing service account key"
|
|
1065
1061
|
};
|
|
1066
1062
|
}
|
|
1067
|
-
const propertyId = params[parameters.propertyId.slug];
|
|
1068
|
-
if (!propertyId) {
|
|
1069
|
-
return { success: true };
|
|
1070
|
-
}
|
|
1071
1063
|
try {
|
|
1072
|
-
const res = await dataFetch(
|
|
1073
|
-
params,
|
|
1074
|
-
`/properties/${propertyId}/metadata`
|
|
1075
|
-
);
|
|
1064
|
+
const res = await dataFetch(params, `/metadata`);
|
|
1076
1065
|
if (!res.ok) {
|
|
1077
1066
|
const body = await res.text().catch(() => res.statusText);
|
|
1078
1067
|
return {
|
|
@@ -303,6 +303,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
303
303
|
}
|
|
304
304
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
305
305
|
if (step.type === "text") {
|
|
306
|
+
if (step.fetchOptions) {
|
|
307
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
308
|
+
if (options2.length === 0) {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
306
312
|
return {
|
|
307
313
|
type: "nextQuestion",
|
|
308
314
|
questionSlug: step.slug,
|
|
@@ -319,6 +319,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
319
319
|
}
|
|
320
320
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
321
321
|
if (step.type === "text") {
|
|
322
|
+
if (step.fetchOptions) {
|
|
323
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
324
|
+
if (options2.length === 0) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
322
328
|
return {
|
|
323
329
|
type: "nextQuestion",
|
|
324
330
|
questionSlug: step.slug,
|
|
@@ -324,6 +324,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
324
324
|
}
|
|
325
325
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
326
326
|
if (step.type === "text") {
|
|
327
|
+
if (step.fetchOptions) {
|
|
328
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
329
|
+
if (options2.length === 0) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
327
333
|
return {
|
|
328
334
|
type: "nextQuestion",
|
|
329
335
|
questionSlug: step.slug,
|
|
@@ -239,6 +239,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
239
239
|
}
|
|
240
240
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
241
241
|
if (step.type === "text") {
|
|
242
|
+
if (step.fetchOptions) {
|
|
243
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
244
|
+
if (options2.length === 0) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
242
248
|
return {
|
|
243
249
|
type: "nextQuestion",
|
|
244
250
|
questionSlug: step.slug,
|
|
@@ -328,6 +328,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
328
328
|
}
|
|
329
329
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
330
330
|
if (step.type === "text") {
|
|
331
|
+
if (step.fetchOptions) {
|
|
332
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
333
|
+
if (options2.length === 0) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
331
337
|
return {
|
|
332
338
|
type: "nextQuestion",
|
|
333
339
|
questionSlug: step.slug,
|
|
@@ -333,6 +333,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
333
333
|
}
|
|
334
334
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
335
335
|
if (step.type === "text") {
|
|
336
|
+
if (step.fetchOptions) {
|
|
337
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
338
|
+
if (options2.length === 0) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
336
342
|
return {
|
|
337
343
|
type: "nextQuestion",
|
|
338
344
|
questionSlug: step.slug,
|
|
@@ -320,6 +320,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
320
320
|
}
|
|
321
321
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
322
322
|
if (step.type === "text") {
|
|
323
|
+
if (step.fetchOptions) {
|
|
324
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
325
|
+
if (options2.length === 0) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
323
329
|
return {
|
|
324
330
|
type: "nextQuestion",
|
|
325
331
|
questionSlug: step.slug,
|
|
@@ -251,6 +251,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
251
251
|
}
|
|
252
252
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
253
253
|
if (step.type === "text") {
|
|
254
|
+
if (step.fetchOptions) {
|
|
255
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
256
|
+
if (options2.length === 0) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
254
260
|
return {
|
|
255
261
|
type: "nextQuestion",
|
|
256
262
|
questionSlug: step.slug,
|
|
@@ -360,6 +360,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
360
360
|
}
|
|
361
361
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
362
362
|
if (step.type === "text") {
|
|
363
|
+
if (step.fetchOptions) {
|
|
364
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
365
|
+
if (options2.length === 0) {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
363
369
|
return {
|
|
364
370
|
type: "nextQuestion",
|
|
365
371
|
questionSlug: step.slug,
|
|
@@ -193,6 +193,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
193
193
|
}
|
|
194
194
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
195
195
|
if (step.type === "text") {
|
|
196
|
+
if (step.fetchOptions) {
|
|
197
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
198
|
+
if (options2.length === 0) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
196
202
|
return {
|
|
197
203
|
type: "nextQuestion",
|
|
198
204
|
questionSlug: step.slug,
|
|
@@ -334,6 +334,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
334
334
|
}
|
|
335
335
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
336
336
|
if (step.type === "text") {
|
|
337
|
+
if (step.fetchOptions) {
|
|
338
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
339
|
+
if (options2.length === 0) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
337
343
|
return {
|
|
338
344
|
type: "nextQuestion",
|
|
339
345
|
questionSlug: step.slug,
|
|
@@ -393,6 +393,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
393
393
|
}
|
|
394
394
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
395
395
|
if (step.type === "text") {
|
|
396
|
+
if (step.fetchOptions) {
|
|
397
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
398
|
+
if (options2.length === 0) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
396
402
|
return {
|
|
397
403
|
type: "nextQuestion",
|
|
398
404
|
questionSlug: step.slug,
|
|
@@ -193,6 +193,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
193
193
|
}
|
|
194
194
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
195
195
|
if (step.type === "text") {
|
|
196
|
+
if (step.fetchOptions) {
|
|
197
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
198
|
+
if (options2.length === 0) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
196
202
|
return {
|
|
197
203
|
type: "nextQuestion",
|
|
198
204
|
questionSlug: step.slug,
|
|
@@ -352,6 +352,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
352
352
|
}
|
|
353
353
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
354
354
|
if (step.type === "text") {
|
|
355
|
+
if (step.fetchOptions) {
|
|
356
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
357
|
+
if (options2.length === 0) {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
355
361
|
return {
|
|
356
362
|
type: "nextQuestion",
|
|
357
363
|
questionSlug: step.slug,
|
package/dist/connectors/jdbc.js
CHANGED
|
@@ -1100,6 +1100,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
1100
1100
|
}
|
|
1101
1101
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
1102
1102
|
if (step.type === "text") {
|
|
1103
|
+
if (step.fetchOptions) {
|
|
1104
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
1105
|
+
if (options2.length === 0) {
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1103
1109
|
return {
|
|
1104
1110
|
type: "nextQuestion",
|
|
1105
1111
|
questionSlug: step.slug,
|
|
@@ -301,6 +301,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
301
301
|
}
|
|
302
302
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
303
303
|
if (step.type === "text") {
|
|
304
|
+
if (step.fetchOptions) {
|
|
305
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
306
|
+
if (options2.length === 0) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
304
310
|
return {
|
|
305
311
|
type: "nextQuestion",
|
|
306
312
|
questionSlug: step.slug,
|
|
@@ -330,6 +330,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
330
330
|
}
|
|
331
331
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
332
332
|
if (step.type === "text") {
|
|
333
|
+
if (step.fetchOptions) {
|
|
334
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
335
|
+
if (options2.length === 0) {
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
333
339
|
return {
|
|
334
340
|
type: "nextQuestion",
|
|
335
341
|
questionSlug: step.slug,
|
|
@@ -339,6 +339,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
339
339
|
}
|
|
340
340
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
341
341
|
if (step.type === "text") {
|
|
342
|
+
if (step.fetchOptions) {
|
|
343
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
344
|
+
if (options2.length === 0) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
342
348
|
return {
|
|
343
349
|
type: "nextQuestion",
|
|
344
350
|
questionSlug: step.slug,
|
|
@@ -345,6 +345,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
345
345
|
}
|
|
346
346
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
347
347
|
if (step.type === "text") {
|
|
348
|
+
if (step.fetchOptions) {
|
|
349
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
350
|
+
if (options2.length === 0) {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
348
354
|
return {
|
|
349
355
|
type: "nextQuestion",
|
|
350
356
|
questionSlug: step.slug,
|
|
@@ -248,6 +248,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
248
248
|
}
|
|
249
249
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
250
250
|
if (step.type === "text") {
|
|
251
|
+
if (step.fetchOptions) {
|
|
252
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
253
|
+
if (options2.length === 0) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
251
257
|
return {
|
|
252
258
|
type: "nextQuestion",
|
|
253
259
|
questionSlug: step.slug,
|
|
@@ -254,6 +254,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
254
254
|
}
|
|
255
255
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
256
256
|
if (step.type === "text") {
|
|
257
|
+
if (step.fetchOptions) {
|
|
258
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
259
|
+
if (options2.length === 0) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
257
263
|
return {
|
|
258
264
|
type: "nextQuestion",
|
|
259
265
|
questionSlug: step.slug,
|
|
@@ -359,6 +359,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
359
359
|
}
|
|
360
360
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
361
361
|
if (step.type === "text") {
|
|
362
|
+
if (step.fetchOptions) {
|
|
363
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
364
|
+
if (options2.length === 0) {
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
362
368
|
return {
|
|
363
369
|
type: "nextQuestion",
|
|
364
370
|
questionSlug: step.slug,
|
|
@@ -248,6 +248,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
248
248
|
}
|
|
249
249
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
250
250
|
if (step.type === "text") {
|
|
251
|
+
if (step.fetchOptions) {
|
|
252
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
253
|
+
if (options2.length === 0) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
251
257
|
return {
|
|
252
258
|
type: "nextQuestion",
|
|
253
259
|
questionSlug: step.slug,
|
|
@@ -319,6 +319,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
319
319
|
}
|
|
320
320
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
321
321
|
if (step.type === "text") {
|
|
322
|
+
if (step.fetchOptions) {
|
|
323
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
324
|
+
if (options2.length === 0) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
322
328
|
return {
|
|
323
329
|
type: "nextQuestion",
|
|
324
330
|
questionSlug: step.slug,
|
|
@@ -411,6 +411,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
411
411
|
}
|
|
412
412
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
413
413
|
if (step.type === "text") {
|
|
414
|
+
if (step.fetchOptions) {
|
|
415
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
416
|
+
if (options2.length === 0) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
414
420
|
return {
|
|
415
421
|
type: "nextQuestion",
|
|
416
422
|
questionSlug: step.slug,
|
|
@@ -441,6 +441,12 @@ async function runSetupFlow(flow, params, ctx, config) {
|
|
|
441
441
|
}
|
|
442
442
|
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
443
443
|
if (step.type === "text") {
|
|
444
|
+
if (step.fetchOptions) {
|
|
445
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
446
|
+
if (options2.length === 0) {
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
444
450
|
return {
|
|
445
451
|
type: "nextQuestion",
|
|
446
452
|
questionSlug: step.slug,
|