@squadbase/vite-server 0.1.17 → 0.1.19-dev.2880e8d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/build-entry/server-entry.mjs +23 -0
  2. package/dist/cli/index.js +6362 -3420
  3. package/dist/connectors/airtable-oauth.js +39 -15
  4. package/dist/connectors/airtable.js +86 -15
  5. package/dist/connectors/amplitude.js +39 -15
  6. package/dist/connectors/anthropic.js +39 -15
  7. package/dist/connectors/asana.js +39 -15
  8. package/dist/connectors/attio.js +39 -15
  9. package/dist/connectors/aws-billing.js +39 -15
  10. package/dist/connectors/azure-sql.js +291 -18
  11. package/dist/connectors/backlog-api-key.js +39 -15
  12. package/dist/connectors/clickup.js +39 -15
  13. package/dist/connectors/cosmosdb.js +39 -15
  14. package/dist/connectors/customerio.js +39 -15
  15. package/dist/connectors/dbt.js +39 -15
  16. package/dist/connectors/freshdesk.js +39 -15
  17. package/dist/connectors/freshsales.js +39 -15
  18. package/dist/connectors/freshservice.js +39 -15
  19. package/dist/connectors/gamma.js +39 -15
  20. package/dist/connectors/gemini.js +39 -15
  21. package/dist/connectors/github.js +39 -15
  22. package/dist/connectors/gmail-oauth.js +32 -13
  23. package/dist/connectors/gmail.js +39 -15
  24. package/dist/connectors/google-ads.js +39 -15
  25. package/dist/connectors/google-analytics-oauth.js +135 -197
  26. package/dist/connectors/google-analytics.js +39 -15
  27. package/dist/connectors/google-audit-log.js +39 -15
  28. package/dist/connectors/google-calendar-oauth.js +40 -16
  29. package/dist/connectors/google-calendar.js +39 -15
  30. package/dist/connectors/google-docs.js +32 -13
  31. package/dist/connectors/google-drive.js +32 -13
  32. package/dist/connectors/google-search-console-oauth.js +39 -15
  33. package/dist/connectors/google-sheets.js +138 -195
  34. package/dist/connectors/google-slides.js +32 -13
  35. package/dist/connectors/grafana.js +39 -15
  36. package/dist/connectors/hackernews.d.ts +5 -0
  37. package/dist/connectors/hackernews.js +909 -0
  38. package/dist/connectors/hubspot-oauth.js +32 -13
  39. package/dist/connectors/hubspot.js +39 -15
  40. package/dist/connectors/influxdb.js +39 -15
  41. package/dist/connectors/intercom-oauth.js +32 -13
  42. package/dist/connectors/intercom.js +39 -15
  43. package/dist/connectors/jdbc.js +70 -19
  44. package/dist/connectors/jira-api-key.js +39 -15
  45. package/dist/connectors/kintone-api-token.js +39 -15
  46. package/dist/connectors/kintone.js +128 -15
  47. package/dist/connectors/linear.js +39 -15
  48. package/dist/connectors/linkedin-ads.js +39 -15
  49. package/dist/connectors/mailchimp-oauth.js +39 -15
  50. package/dist/connectors/mailchimp.js +39 -15
  51. package/dist/connectors/meta-ads-oauth.js +39 -15
  52. package/dist/connectors/meta-ads.js +39 -15
  53. package/dist/connectors/mixpanel.js +39 -15
  54. package/dist/connectors/monday.js +39 -15
  55. package/dist/connectors/mongodb.js +39 -15
  56. package/dist/connectors/notion-oauth.js +32 -13
  57. package/dist/connectors/notion.js +84 -15
  58. package/dist/connectors/openai.js +39 -15
  59. package/dist/connectors/oracle.js +293 -19
  60. package/dist/connectors/outlook-oauth.js +33 -14
  61. package/dist/connectors/powerbi-oauth.js +33 -14
  62. package/dist/connectors/salesforce.js +108 -15
  63. package/dist/connectors/semrush.js +39 -15
  64. package/dist/connectors/sentry.js +39 -15
  65. package/dist/connectors/shopify-oauth.js +32 -13
  66. package/dist/connectors/shopify.js +39 -15
  67. package/dist/connectors/slack.d.ts +5 -0
  68. package/dist/connectors/slack.js +656 -0
  69. package/dist/connectors/sqlserver.js +291 -18
  70. package/dist/connectors/stripe-api-key.js +39 -15
  71. package/dist/connectors/stripe-oauth.js +32 -13
  72. package/dist/connectors/supabase.js +293 -16
  73. package/dist/connectors/tableau.js +40 -16
  74. package/dist/connectors/tiktok-ads.js +39 -15
  75. package/dist/connectors/wix-store.js +39 -15
  76. package/dist/connectors/x.d.ts +5 -0
  77. package/dist/connectors/x.js +951 -0
  78. package/dist/connectors/zendesk-oauth.js +32 -13
  79. package/dist/connectors/zendesk.js +39 -15
  80. package/dist/index.d.ts +25 -1
  81. package/dist/index.js +6490 -3571
  82. package/dist/main.d.ts +1 -0
  83. package/dist/main.js +6494 -3575
  84. package/dist/types/server-logic.d.ts +3 -0
  85. package/dist/vite-plugin.d.ts +7 -2
  86. package/dist/vite-plugin.js +53 -44480
  87. package/package.json +14 -6
@@ -1,95 +1,21 @@
1
- var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __esm = (fn, res) => function __init() {
3
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
- };
5
-
6
- // ../connectors/src/parameter-definition.ts
7
- var ParameterDefinition;
8
- var init_parameter_definition = __esm({
9
- "../connectors/src/parameter-definition.ts"() {
10
- "use strict";
11
- ParameterDefinition = class {
12
- slug;
13
- name;
14
- description;
15
- envVarBaseKey;
16
- type;
17
- secret;
18
- required;
19
- isDeprecated;
20
- constructor(config) {
21
- this.slug = config.slug;
22
- this.name = config.name;
23
- this.description = config.description;
24
- this.envVarBaseKey = config.envVarBaseKey;
25
- this.type = config.type;
26
- this.secret = config.secret;
27
- this.required = config.required;
28
- this.isDeprecated = config.isDeprecated ?? false;
29
- }
30
- /**
31
- * Get the parameter value from a ConnectorConnectionObject.
32
- */
33
- getValue(connection2) {
34
- const param = connection2.parameters.find(
35
- (p) => p.parameterSlug === this.slug
36
- );
37
- if (!param || param.value == null) {
38
- throw new Error(
39
- `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
40
- );
41
- }
42
- return param.value;
43
- }
44
- /**
45
- * Try to get the parameter value. Returns undefined if not found (for optional params).
46
- */
47
- tryGetValue(connection2) {
48
- const param = connection2.parameters.find(
49
- (p) => p.parameterSlug === this.slug
50
- );
51
- if (!param || param.value == null) return void 0;
52
- return param.value;
53
- }
54
- };
55
- }
56
- });
57
-
58
- // ../connectors/src/connectors/google-analytics-oauth/parameters.ts
59
- init_parameter_definition();
60
- var parameters = {
61
- propertyId: new ParameterDefinition({
62
- slug: "property-id",
63
- name: "Google Analytics Property ID",
64
- description: "The Google Analytics 4 property ID (e.g., 123456789). Can be found in GA4 Admin > Property Settings.",
65
- envVarBaseKey: "GA_OAUTH_PROPERTY_ID",
66
- type: "text",
67
- secret: false,
68
- required: false
69
- })
70
- };
71
-
72
1
  // ../connectors/src/connectors/google-analytics-oauth/sdk/index.ts
73
2
  var BASE_URL = "https://analyticsdata.googleapis.com/v1beta/";
74
- function createClient(params, fetchFn) {
75
- const propertyId = params[parameters.propertyId.slug];
76
- function resolvePropertyId() {
3
+ function createClient(_params, fetchFn) {
4
+ function resolvePropertyId(propertyId) {
77
5
  if (!propertyId) {
78
6
  throw new Error(
79
- "google-analytics-oauth: propertyId is required. Configure it via connection parameters."
7
+ "google-analytics-oauth: propertyId is required. Pass the numeric GA4 property id explicitly."
80
8
  );
81
9
  }
82
10
  return propertyId;
83
11
  }
84
12
  return {
85
13
  async request(path2, init) {
86
- const pid = propertyId;
87
- const resolvedPath = pid ? path2.replace(/\{propertyId\}/g, pid) : path2;
88
- const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
14
+ const url = `${BASE_URL.replace(/\/+$/, "")}/${path2.replace(/^\/+/, "")}`;
89
15
  return fetchFn(url, init);
90
16
  },
91
- async runReport(request) {
92
- const pid = resolvePropertyId();
17
+ async runReport({ propertyId, ...request }) {
18
+ const pid = resolvePropertyId(propertyId);
93
19
  const response = await this.request(
94
20
  `properties/${pid}:runReport`,
95
21
  {
@@ -110,8 +36,8 @@ function createClient(params, fetchFn) {
110
36
  rowCount: data.rowCount ?? 0
111
37
  };
112
38
  },
113
- async getMetadata() {
114
- const pid = resolvePropertyId();
39
+ async getMetadata(propertyId) {
40
+ const pid = resolvePropertyId(propertyId);
115
41
  const response = await this.request(
116
42
  `properties/${pid}/metadata`,
117
43
  { method: "GET" }
@@ -124,8 +50,8 @@ function createClient(params, fetchFn) {
124
50
  }
125
51
  return await response.json();
126
52
  },
127
- async runRealtimeReport(request) {
128
- const pid = resolvePropertyId();
53
+ async runRealtimeReport({ propertyId, ...request }) {
54
+ const pid = resolvePropertyId(propertyId);
129
55
  const response = await this.request(
130
56
  `properties/${pid}:runRealtimeReport`,
131
57
  {
@@ -216,6 +142,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
216
142
  * `runSetupFlow` from `setup-flow.ts`.
217
143
  */
218
144
  setup;
145
+ /**
146
+ * 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
147
+ * メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
148
+ * {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
149
+ * 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
150
+ * `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
151
+ * coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
152
+ */
153
+ introspect;
219
154
  /**
220
155
  * Opt-out of the default "verify before save" behavior on connection
221
156
  * creation. The backend invokes `checkConnection` synchronously while
@@ -230,6 +165,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
230
165
  * the default verify-on-create behavior without opt-in.
231
166
  */
232
167
  skipConnectionCheckOnCreate;
168
+ /**
169
+ * 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
170
+ * read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
171
+ * recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
172
+ * driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
173
+ * 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
174
+ */
175
+ surveyProbes;
233
176
  constructor(config) {
234
177
  this.slug = config.slug;
235
178
  this.authType = config.authType;
@@ -247,7 +190,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
247
190
  this.query = config.query;
248
191
  this.checkConnection = config.checkConnection;
249
192
  this.setup = config.setup;
193
+ this.introspect = config.introspect;
250
194
  this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
195
+ this.surveyProbes = config.surveyProbes;
251
196
  }
252
197
  get connectorKey() {
253
198
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -285,25 +230,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
285
230
  if (authType) return `${slug}-${authType}`;
286
231
  const LEGACY_NULL_AUTH_TYPE_MAP = {
287
232
  // user-password
288
- "postgresql": "user-password",
289
- "mysql": "user-password",
290
- "clickhouse": "user-password",
291
- "kintone": "user-password",
233
+ postgresql: "user-password",
234
+ mysql: "user-password",
235
+ clickhouse: "user-password",
236
+ kintone: "user-password",
292
237
  "squadbase-db": "user-password",
293
238
  // service-account
294
- "snowflake": "service-account",
295
- "bigquery": "service-account",
239
+ snowflake: "service-account",
240
+ bigquery: "service-account",
296
241
  "google-analytics": "service-account",
297
242
  "google-calendar": "service-account",
298
243
  "aws-athena": "service-account",
299
- "redshift": "service-account",
244
+ redshift: "service-account",
300
245
  // api-key
301
- "databricks": "api-key",
302
- "dbt": "api-key",
303
- "airtable": "api-key",
304
- "openai": "api-key",
305
- "gemini": "api-key",
306
- "anthropic": "api-key",
246
+ databricks: "api-key",
247
+ dbt: "api-key",
248
+ airtable: "api-key",
249
+ openai: "api-key",
250
+ gemini: "api-key",
251
+ anthropic: "api-key",
307
252
  "wix-store": "api-key"
308
253
  };
309
254
  const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
@@ -635,11 +580,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
635
580
  - \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
636
581
  - \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
637
582
  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
638
- 4. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
639
- - \`parameterSlug\`: \`"property-id"\`
640
- - \`options\`: \u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3002\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
641
- - \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6** \u306E\u5834\u5408\u306F\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
642
- 5. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E \`label\` \u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u5C4A\u304F\u306E\u3067\u3001\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080
583
+ 4. \u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u9078\u629E:
584
+ - \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
585
+ - \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
586
+ - \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
587
+ 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
643
588
 
644
589
  #### \u5236\u7D04
645
590
  - **\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
@@ -653,11 +598,11 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
653
598
  - **Only 1 account**: Skip \`askUserQuestion\` and proceed using that account as the selection
654
599
  - **0 accounts**: Abort setup and inform the user that no accessible accounts are available
655
600
  3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
656
- 4. Call \`updateConnectionParameters\`:
657
- - \`parameterSlug\`: \`"property-id"\`
658
- - \`options\`: The property list. Each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID
659
- - If **0 properties** are returned, abort setup and inform the user that no accessible properties are available
660
- 5. The \`label\` of the user's selected property will arrive as a message. Proceed to the next step
601
+ 4. Select a property:
602
+ - **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)
603
+ - **Only 1 property**: Skip \`askUserQuestion\` and proceed using that property as the selection
604
+ - **0 properties**: Abort setup and inform the user that no accessible properties are available
605
+ 5. Write the selected numeric property id directly into the request path (it is not stored on the connection). Proceed to the next step
661
606
 
662
607
  #### Constraints
663
608
  - **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
@@ -665,13 +610,18 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
665
610
  - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
666
611
  },
667
612
  dataOverviewInstructions: {
668
- en: `1. Call connector_google-analytics-oauth_request with GET properties/{propertyId}/metadata to list available dimensions and metrics
669
- 2. Call connector_google-analytics-oauth_request with POST properties/{propertyId}:runReport using a small date range and basic metrics to verify data availability`,
670
- ja: `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
671
- 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`
613
+ en: `Use the selected numeric property id in the path (write it directly, e.g. properties/123456789).
614
+ 1. Call connector_google-analytics-oauth_request with GET properties/<propertyId>/metadata to list available dimensions and metrics
615
+ 2. Call connector_google-analytics-oauth_request with POST properties/<propertyId>:runReport using a small date range and basic metrics to verify data availability`,
616
+ 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
617
+ 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
618
+ 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`
672
619
  }
673
620
  });
674
621
 
622
+ // ../connectors/src/connectors/google-analytics-oauth/parameters.ts
623
+ var parameters = {};
624
+
675
625
  // ../connectors/src/connectors/google-analytics-oauth/setup-flow.ts
676
626
  var ADMIN_BASE_URL3 = "https://analyticsadmin.googleapis.com/v1beta";
677
627
  var DATA_BASE_URL = "https://analyticsdata.googleapis.com/v1beta";
@@ -977,7 +927,7 @@ var inputSchema3 = z3.object({
977
927
  connectionId: z3.string().describe("ID of the Google Analytics OAuth connection to use"),
978
928
  method: z3.enum(["GET", "POST"]).describe("HTTP method"),
979
929
  path: z3.string().describe(
980
- "API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."
930
+ "API path appended to https://analyticsdata.googleapis.com/v1beta/ (e.g., 'properties/123456789:runReport'). Write the numeric property id directly into the path."
981
931
  ),
982
932
  body: z3.record(z3.string(), z3.unknown()).optional().describe("POST request body (JSON)")
983
933
  });
@@ -996,7 +946,7 @@ var requestTool = new ConnectorTool({
996
946
  name: "request",
997
947
  description: `Send authenticated requests to the Google Analytics Data API v1beta.
998
948
  Authentication is handled automatically via OAuth proxy.
999
- {propertyId} in the path is automatically replaced with the connection's property ID.`,
949
+ Write the numeric property id directly into the path (e.g. properties/123456789:runReport).`,
1000
950
  inputSchema: inputSchema3,
1001
951
  outputSchema: outputSchema3,
1002
952
  async execute({ connectionId, method, path: path2, body }, connections, config) {
@@ -1011,9 +961,7 @@ Authentication is handled automatically via OAuth proxy.
1011
961
  `[connector-request] google-analytics-oauth/${connection2.name}: ${method} ${path2}`
1012
962
  );
1013
963
  try {
1014
- const propertyId = parameters.propertyId.tryGetValue(connection2);
1015
- const resolvedPath = propertyId ? path2.replace(/\{propertyId\}/g, propertyId) : path2;
1016
- const url = `${BASE_URL2}${resolvedPath}`;
964
+ const url = `${BASE_URL2}${path2}`;
1017
965
  const token = await getProxyToken3(config.oauthProxy);
1018
966
  const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
1019
967
  const controller = new AbortController();
@@ -1065,7 +1013,7 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
1065
1013
  description: "Connect to Google Analytics for web analytics and reporting using OAuth.",
1066
1014
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
1067
1015
  parameters,
1068
- releaseFlag: { dev1: true, dev2: false, prod: false },
1016
+ releaseFlag: { dev1: true, dev2: true, prod: true },
1069
1017
  categories: ["marketing"],
1070
1018
  onboarding: googleAnalyticsOauthOnboarding,
1071
1019
  proxyPolicy: {
@@ -1083,24 +1031,20 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
1083
1031
  systemPrompt: {
1084
1032
  en: `### Tools
1085
1033
 
1086
- - \`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.
1034
+ - \`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.
1087
1035
  - \`connector_google-analytics-oauth_listAccounts\`: List accessible Google Analytics accounts. Use during setup to discover available accounts.
1088
1036
  - \`connector_google-analytics-oauth_listProperties\`: List GA4 properties for a given account. Use during setup to select the target property.
1089
1037
 
1090
- ### GA4 Data API Reference
1038
+ ### GA4 Data API Reference \u2014 for the \`connector_google-analytics-oauth_request\` **tool** only (setup/discovery)
1091
1039
 
1092
- #### Get Metadata (Check available dimensions and metrics)
1093
- - GET properties/{propertyId}/metadata
1040
+ These raw HTTP shapes describe the discovery **tool** above. **In server-logic (Business Logic below) do NOT hand-build these HTTP requests \u2014 call the SDK method on the same line, which takes the same body fields and returns already-parsed JSON:**
1094
1041
 
1095
- ### Get Report
1096
- - POST properties/{propertyId}:runReport
1097
- - Body example:
1098
- {
1099
- "dateRanges": [{"startDate": "7daysAgo", "endDate": "today"}],
1100
- "dimensions": [{"name": "date"}],
1101
- "metrics": [{"name": "activeUsers"}],
1102
- "limit": 100
1103
- }
1042
+ | Raw HTTP (tool, discovery) | Server-logic (SDK method) |
1043
+ |---|---|
1044
+ | \`GET properties/{propertyId}/metadata\` | \`await client.getMetadata(propertyId)\` |
1045
+ | \`POST properties/{propertyId}:runReport\` with body \`{ dateRanges, dimensions, metrics, limit }\` | \`await client.runReport({ propertyId, dateRanges, dimensions, metrics, limit })\` \u2192 \`{ rows, rowCount }\` |
1046
+
1047
+ Report body fields: \`dateRanges: [{ startDate, endDate }]\`, \`dimensions: [{ name }]\`, \`metrics: [{ name }]\`, optional \`limit\`.
1104
1048
 
1105
1049
  ### Common Dimensions
1106
1050
  date, country, city, deviceCategory, browser, pagePath, pageTitle,
@@ -1118,11 +1062,14 @@ averageSessionDuration, conversions, totalRevenue
1118
1062
 
1119
1063
  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.
1120
1064
 
1121
- SDK surface (client created via \`connection(connectionId)\`):
1122
- - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (\`path\` is appended to \`https://analyticsdata.googleapis.com/v1beta/\`).
1123
- - \`client.runReport(request)\` \u2014 run a GA4 report.
1124
- - \`client.runRealtimeReport(request)\` \u2014 run a realtime report.
1125
- - \`client.getMetadata()\` \u2014 fetch available dimensions and metrics.
1065
+ SDK surface (client created via \`connection(connectionId)\`). **Every method returns already-parsed JSON \u2014 you never build an HTTP request or parse a response yourself:**
1066
+ - \`client.runReport({ propertyId, dateRanges, dimensions, metrics, limit? })\` \u2014 run a GA4 report. Returns \`{ rows, rowCount }\`. **Use this for all reporting.**
1067
+ - \`client.runRealtimeReport({ propertyId, dimensions, metrics })\` \u2014 realtime report. Returns \`{ rows, rowCount }\`.
1068
+ - \`client.getMetadata(propertyId)\` \u2014 available dimensions and metrics for a property.
1069
+
1070
+ **Anti-pattern \u2014 do NOT do this.** \`client.request(...)\` is a low-level escape hatch that returns a raw \`Response\`; it is NOT how you run a report. In particular, **never call \`client.request({ method, path, body })\`** \u2014 that object shape belongs to the discovery *tool*, not the SDK. It will not run the report, and \`(await client.request({...})).rows\` is always \`undefined\`. Use \`client.runReport({ propertyId, ... })\` instead.
1071
+
1072
+ **\`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.
1126
1073
 
1127
1074
  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.
1128
1075
 
@@ -1131,48 +1078,42 @@ If a handler test fails with \`Connection proxy is not configured\`, retry \u201
1131
1078
  \`\`\`ts
1132
1079
  import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
1133
1080
 
1134
- const ga = connection("<connectionId>");
1081
+ export default async function handler(c) {
1082
+ const client = connection("<connectionId>");
1083
+ const propertyId = "123456789"; // numeric GA4 property id from the data overview
1135
1084
 
1136
- // Authenticated fetch (returns standard Response)
1137
- const res = await ga.request("properties/{propertyId}:runReport", {
1138
- method: "POST",
1139
- body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
1140
- });
1141
- const data = await res.json();
1085
+ const { rows } = await client.runReport({
1086
+ propertyId,
1087
+ dateRanges: [{ startDate: "28daysAgo", endDate: "today" }],
1088
+ dimensions: [{ name: "date" }, { name: "sessionDefaultChannelGroup" }],
1089
+ metrics: [{ name: "sessions" }],
1090
+ });
1142
1091
 
1143
- // Convenience methods
1144
- const { rows, rowCount } = await ga.runReport({
1145
- dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
1146
- dimensions: [{ name: "date" }],
1147
- metrics: [{ name: "activeUsers" }, { name: "sessions" }],
1148
- limit: 100,
1149
- });
1150
- const metadata = await ga.getMetadata();
1151
- const realtime = await ga.runRealtimeReport({
1152
- metrics: [{ name: "activeUsers" }],
1153
- dimensions: [{ name: "country" }],
1154
- });
1092
+ const data = rows.map((row) => ({
1093
+ date: row.dimensionValues[0].value,
1094
+ channel: row.dimensionValues[1].value,
1095
+ sessions: Number(row.metricValues[0].value) || 0,
1096
+ }));
1097
+
1098
+ return c.json(data);
1099
+ }
1155
1100
  \`\`\``,
1156
1101
  ja: `### \u30C4\u30FC\u30EB
1157
1102
 
1158
- - \`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
1103
+ - \`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
1159
1104
  - \`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
1160
1105
  - \`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
1161
1106
 
1162
- ### GA4 Data API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
1107
+ ### GA4 Data API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9 \u2014 \`connector_google-analytics-oauth_request\` **\u30C4\u30FC\u30EB**\u5C02\u7528\uFF08\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7/\u63A2\u7D22\u6642\uFF09
1163
1108
 
1164
- #### \u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\uFF08\u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3\u3068\u30E1\u30C8\u30EA\u30AF\u30B9\u306E\u78BA\u8A8D\uFF09
1165
- - GET properties/{propertyId}/metadata
1109
+ \u4EE5\u4E0B\u306E\u751F\u306E HTTP \u5F62\u5F0F\u306F\u63A2\u7D22\u7528**\u30C4\u30FC\u30EB**\u306E\u3082\u306E\u3067\u3059\u3002**server-logic\uFF08\u4E0B\u8A18 Business Logic\uFF09\u3067\u306F\u3001\u3053\u308C\u3089\u306E HTTP \u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u624B\u7D44\u307F\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 \u540C\u3058 body \u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u53D6\u308A\u3001\u30D1\u30FC\u30B9\u6E08\u307F JSON \u3092\u8FD4\u3059 SDK \u30E1\u30BD\u30C3\u30C9\u3092\u547C\u3093\u3067\u304F\u3060\u3055\u3044:**
1166
1110
 
1167
- ### \u30EC\u30DD\u30FC\u30C8\u306E\u53D6\u5F97
1168
- - POST properties/{propertyId}:runReport
1169
- - Body\u4F8B:
1170
- {
1171
- "dateRanges": [{"startDate": "7daysAgo", "endDate": "today"}],
1172
- "dimensions": [{"name": "date"}],
1173
- "metrics": [{"name": "activeUsers"}],
1174
- "limit": 100
1175
- }
1111
+ | \u751F\u306E HTTP\uFF08\u30C4\u30FC\u30EB\u30FB\u63A2\u7D22\u7528\uFF09 | server-logic\uFF08SDK \u30E1\u30BD\u30C3\u30C9\uFF09 |
1112
+ |---|---|
1113
+ | \`GET properties/{propertyId}/metadata\` | \`await client.getMetadata(propertyId)\` |
1114
+ | \`POST properties/{propertyId}:runReport\`\uFF08body: \`{ dateRanges, dimensions, metrics, limit }\`\uFF09 | \`await client.runReport({ propertyId, dateRanges, dimensions, metrics, limit })\` \u2192 \`{ rows, rowCount }\` |
1115
+
1116
+ \u30EC\u30DD\u30FC\u30C8\u306E body \u30D5\u30A3\u30FC\u30EB\u30C9: \`dateRanges: [{ startDate, endDate }]\`, \`dimensions: [{ name }]\`, \`metrics: [{ name }]\`, \u4EFB\u610F\u3067 \`limit\`\u3002
1176
1117
 
1177
1118
  ### \u4E3B\u8981\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3
1178
1119
  date, country, city, deviceCategory, browser, pagePath, pageTitle,
@@ -1190,11 +1131,14 @@ averageSessionDuration, conversions, totalRevenue
1190
1131
 
1191
1132
  \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
1192
1133
 
1193
- SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
1194
- - \`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
1195
- - \`client.runReport(request)\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002
1196
- - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002
1197
- - \`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
1134
+ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09\u3002**\u5404\u30E1\u30BD\u30C3\u30C9\u306F\u30D1\u30FC\u30B9\u6E08\u307F JSON \u3092\u8FD4\u3057\u307E\u3059 \u2014 HTTP \u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u7D44\u307F\u7ACB\u3066\u3084\u30EC\u30B9\u30DD\u30F3\u30B9\u306E\u30D1\u30FC\u30B9\u3092\u81EA\u5206\u3067\u884C\u3046\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093:**
1135
+ - \`client.runReport({ propertyId, dateRanges, dimensions, metrics, limit? })\` \u2014 GA4 \u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3002\`{ rows, rowCount }\` \u3092\u8FD4\u3057\u307E\u3059\u3002**\u30EC\u30DD\u30FC\u30C8\u53D6\u5F97\u306F\u5FC5\u305A\u3053\u308C\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002**
1136
+ - \`client.runRealtimeReport({ propertyId, dimensions, metrics })\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3002\`{ rows, rowCount }\` \u3092\u8FD4\u3057\u307E\u3059\u3002
1137
+ - \`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
1138
+
1139
+ **\u30A2\u30F3\u30C1\u30D1\u30BF\u30FC\u30F3 \u2014 \u3053\u308C\u306F\u7D76\u5BFE\u306B\u3084\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002** \`client.request(...)\` \u306F\u751F\u306E \`Response\` \u3092\u8FD4\u3059\u4F4E\u30EC\u30D9\u30EB\u306E\u9003\u3052\u9053\u3067\u3042\u308A\u3001\u30EC\u30DD\u30FC\u30C8\u5B9F\u884C\u306E\u624B\u6BB5\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7279\u306B **\`client.request({ method, path, body })\` \u306F\u7D76\u5BFE\u306B\u547C\u3070\u306A\u3044\u3067\u304F\u3060\u3055\u3044** \u2014 \u305D\u306E\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u5F62\u306F\u63A2\u7D22\u7528*\u30C4\u30FC\u30EB*\u306E\u5F62\u3067\u3042\u3063\u3066 SDK \u306E\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u30EC\u30DD\u30FC\u30C8\u306F\u5B9F\u884C\u3055\u308C\u305A\u3001\`(await client.request({...})).rows\` \u306F\u5E38\u306B \`undefined\` \u306B\u306A\u308A\u307E\u3059\u3002\u4EE3\u308F\u308A\u306B \`client.runReport({ propertyId, ... })\` \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002
1140
+
1141
+ **\`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
1198
1142
 
1199
1143
  \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
1200
1144
 
@@ -1203,38 +1147,32 @@ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9
1203
1147
  \`\`\`ts
1204
1148
  import { connection } from "@squadbase/vite-server/connectors/google-analytics-oauth";
1205
1149
 
1206
- const ga = connection("<connectionId>");
1150
+ export default async function handler(c) {
1151
+ const client = connection("<connectionId>");
1152
+ const propertyId = "123456789"; // \u30C7\u30FC\u30BF\u6982\u8981\u306B\u8F09\u3063\u3066\u3044\u308B\u6570\u5024\u306E GA4 \u30D7\u30ED\u30D1\u30C6\u30A3ID
1207
1153
 
1208
- // Authenticated fetch (returns standard Response)
1209
- const res = await ga.request("properties/{propertyId}:runReport", {
1210
- method: "POST",
1211
- body: JSON.stringify({ dateRanges: [{ startDate: "7daysAgo", endDate: "today" }], metrics: [{ name: "activeUsers" }] }),
1212
- });
1213
- const data = await res.json();
1154
+ const { rows } = await client.runReport({
1155
+ propertyId,
1156
+ dateRanges: [{ startDate: "28daysAgo", endDate: "today" }],
1157
+ dimensions: [{ name: "date" }, { name: "sessionDefaultChannelGroup" }],
1158
+ metrics: [{ name: "sessions" }],
1159
+ });
1214
1160
 
1215
- // Convenience methods
1216
- const { rows, rowCount } = await ga.runReport({
1217
- dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
1218
- dimensions: [{ name: "date" }],
1219
- metrics: [{ name: "activeUsers" }, { name: "sessions" }],
1220
- limit: 100,
1221
- });
1222
- const metadata = await ga.getMetadata();
1223
- const realtime = await ga.runRealtimeReport({
1224
- metrics: [{ name: "activeUsers" }],
1225
- dimensions: [{ name: "country" }],
1226
- });
1161
+ const data = rows.map((row) => ({
1162
+ date: row.dimensionValues[0].value,
1163
+ channel: row.dimensionValues[1].value,
1164
+ sessions: Number(row.metricValues[0].value) || 0,
1165
+ }));
1166
+
1167
+ return c.json(data);
1168
+ }
1227
1169
  \`\`\``
1228
1170
  },
1229
1171
  tools,
1230
1172
  setup: (params, ctx, config) => runSetupFlow(googleAnalyticsOauthSetupFlow, params, ctx, config),
1231
- async checkConnection(params, config) {
1173
+ async checkConnection(_params, config) {
1232
1174
  const { proxyFetch } = config;
1233
- const propertyId = params[parameters.propertyId.slug];
1234
- if (!propertyId) {
1235
- return { success: true };
1236
- }
1237
- const url = `https://analyticsdata.googleapis.com/v1beta/properties/${propertyId}/metadata`;
1175
+ const url = "https://analyticsadmin.googleapis.com/v1beta/accountSummaries";
1238
1176
  try {
1239
1177
  const res = await proxyFetch(url, { method: "GET" });
1240
1178
  if (!res.ok) {
@@ -1,6 +1,11 @@
1
1
  var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __esm = (fn, res) => function __init() {
3
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
2
+ var __esm = (fn, res, err) => function __init() {
3
+ if (err) throw err[0];
4
+ try {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ } catch (e) {
7
+ throw err = [e], e;
8
+ }
4
9
  };
5
10
 
6
11
  // ../connectors/src/parameter-definition.ts
@@ -311,6 +316,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
311
316
  * `runSetupFlow` from `setup-flow.ts`.
312
317
  */
313
318
  setup;
319
+ /**
320
+ * 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
321
+ * メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
322
+ * {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
323
+ * 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
324
+ * `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
325
+ * coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
326
+ */
327
+ introspect;
314
328
  /**
315
329
  * Opt-out of the default "verify before save" behavior on connection
316
330
  * creation. The backend invokes `checkConnection` synchronously while
@@ -325,6 +339,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
325
339
  * the default verify-on-create behavior without opt-in.
326
340
  */
327
341
  skipConnectionCheckOnCreate;
342
+ /**
343
+ * 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
344
+ * read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
345
+ * recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
346
+ * driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
347
+ * 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
348
+ */
349
+ surveyProbes;
328
350
  constructor(config) {
329
351
  this.slug = config.slug;
330
352
  this.authType = config.authType;
@@ -342,7 +364,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
342
364
  this.query = config.query;
343
365
  this.checkConnection = config.checkConnection;
344
366
  this.setup = config.setup;
367
+ this.introspect = config.introspect;
345
368
  this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
369
+ this.surveyProbes = config.surveyProbes;
346
370
  }
347
371
  get connectorKey() {
348
372
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -380,25 +404,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
380
404
  if (authType) return `${slug}-${authType}`;
381
405
  const LEGACY_NULL_AUTH_TYPE_MAP = {
382
406
  // user-password
383
- "postgresql": "user-password",
384
- "mysql": "user-password",
385
- "clickhouse": "user-password",
386
- "kintone": "user-password",
407
+ postgresql: "user-password",
408
+ mysql: "user-password",
409
+ clickhouse: "user-password",
410
+ kintone: "user-password",
387
411
  "squadbase-db": "user-password",
388
412
  // service-account
389
- "snowflake": "service-account",
390
- "bigquery": "service-account",
413
+ snowflake: "service-account",
414
+ bigquery: "service-account",
391
415
  "google-analytics": "service-account",
392
416
  "google-calendar": "service-account",
393
417
  "aws-athena": "service-account",
394
- "redshift": "service-account",
418
+ redshift: "service-account",
395
419
  // api-key
396
- "databricks": "api-key",
397
- "dbt": "api-key",
398
- "airtable": "api-key",
399
- "openai": "api-key",
400
- "gemini": "api-key",
401
- "anthropic": "api-key",
420
+ databricks: "api-key",
421
+ dbt: "api-key",
422
+ airtable: "api-key",
423
+ openai: "api-key",
424
+ gemini: "api-key",
425
+ anthropic: "api-key",
402
426
  "wix-store": "api-key"
403
427
  };
404
428
  const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];