@squadbase/vite-server 0.1.12-dev.a9ac647 → 0.1.17-dev.24af54e

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 (77) hide show
  1. package/dist/cli/index.js +12374 -883
  2. package/dist/connectors/airtable-oauth.js +257 -46
  3. package/dist/connectors/airtable.js +294 -51
  4. package/dist/connectors/amplitude.js +297 -47
  5. package/dist/connectors/anthropic.js +135 -47
  6. package/dist/connectors/asana.js +302 -49
  7. package/dist/connectors/attio.js +277 -49
  8. package/dist/connectors/aws-billing.js +262 -46
  9. package/dist/connectors/azure-sql.js +396 -102
  10. package/dist/connectors/backlog-api-key.js +292 -47
  11. package/dist/connectors/clickup.js +313 -49
  12. package/dist/connectors/cosmosdb.js +280 -50
  13. package/dist/connectors/customerio.js +294 -47
  14. package/dist/connectors/dbt.js +315 -47
  15. package/dist/connectors/freshdesk.js +317 -53
  16. package/dist/connectors/freshsales.js +308 -52
  17. package/dist/connectors/freshservice.js +336 -53
  18. package/dist/connectors/gamma.js +302 -52
  19. package/dist/connectors/gemini.js +134 -47
  20. package/dist/connectors/github.js +361 -49
  21. package/dist/connectors/gmail-oauth.js +179 -7
  22. package/dist/connectors/gmail.js +325 -47
  23. package/dist/connectors/google-ads.js +263 -46
  24. package/dist/connectors/google-analytics-oauth.js +285 -46
  25. package/dist/connectors/google-analytics.js +387 -49
  26. package/dist/connectors/google-audit-log.js +413 -47
  27. package/dist/connectors/google-calendar-oauth.js +234 -46
  28. package/dist/connectors/google-calendar.js +334 -47
  29. package/dist/connectors/google-docs.js +195 -6
  30. package/dist/connectors/google-drive.js +237 -5
  31. package/dist/connectors/google-search-console-oauth.js +231 -46
  32. package/dist/connectors/google-sheets.js +247 -47
  33. package/dist/connectors/google-slides.js +180 -6
  34. package/dist/connectors/grafana.js +307 -49
  35. package/dist/connectors/hubspot-oauth.js +183 -5
  36. package/dist/connectors/hubspot.js +281 -49
  37. package/dist/connectors/influxdb.js +391 -51
  38. package/dist/connectors/intercom-oauth.js +185 -5
  39. package/dist/connectors/intercom.js +277 -49
  40. package/dist/connectors/jdbc.js +737 -110
  41. package/dist/connectors/jira-api-key.js +301 -47
  42. package/dist/connectors/kintone-api-token.js +256 -47
  43. package/dist/connectors/kintone.js +303 -47
  44. package/dist/connectors/linear.js +305 -49
  45. package/dist/connectors/linkedin-ads.js +243 -50
  46. package/dist/connectors/mailchimp-oauth.js +243 -46
  47. package/dist/connectors/mailchimp.js +295 -49
  48. package/dist/connectors/meta-ads-oauth.js +248 -48
  49. package/dist/connectors/meta-ads.js +260 -50
  50. package/dist/connectors/mixpanel.js +313 -47
  51. package/dist/connectors/monday.js +335 -49
  52. package/dist/connectors/mongodb.js +294 -57
  53. package/dist/connectors/notion-oauth.js +206 -5
  54. package/dist/connectors/notion.js +298 -51
  55. package/dist/connectors/openai.js +134 -47
  56. package/dist/connectors/oracle.js +414 -103
  57. package/dist/connectors/outlook-oauth.js +179 -5
  58. package/dist/connectors/powerbi-oauth.js +226 -5
  59. package/dist/connectors/salesforce.js +359 -49
  60. package/dist/connectors/semrush.js +289 -49
  61. package/dist/connectors/sentry.js +264 -50
  62. package/dist/connectors/shopify-oauth.js +162 -5
  63. package/dist/connectors/shopify.js +332 -47
  64. package/dist/connectors/sqlserver.js +390 -102
  65. package/dist/connectors/stripe-api-key.js +244 -46
  66. package/dist/connectors/stripe-oauth.js +177 -5
  67. package/dist/connectors/supabase.js +278 -48
  68. package/dist/connectors/tableau.js +389 -184
  69. package/dist/connectors/tiktok-ads.js +254 -48
  70. package/dist/connectors/wix-store.js +295 -49
  71. package/dist/connectors/zendesk-oauth.js +214 -5
  72. package/dist/connectors/zendesk.js +333 -47
  73. package/dist/index.d.ts +149 -1
  74. package/dist/index.js +13677 -1969
  75. package/dist/main.js +13627 -1927
  76. package/dist/vite-plugin.js +12391 -890
  77. package/package.json +1 -1
@@ -15,7 +15,7 @@ function createClient(_params, fetchFn = fetch) {
15
15
  }
16
16
  return await response.json();
17
17
  }
18
- async function listLabels() {
18
+ async function listLabels2() {
19
19
  const response = await request("/me/labels");
20
20
  if (!response.ok) {
21
21
  const body = await response.text();
@@ -98,7 +98,7 @@ function createClient(_params, fetchFn = fetch) {
98
98
  return {
99
99
  request,
100
100
  getProfile,
101
- listLabels,
101
+ listLabels: listLabels2,
102
102
  listMessages,
103
103
  getMessage,
104
104
  listThreads,
@@ -165,6 +165,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
165
165
  tools;
166
166
  query;
167
167
  checkConnection;
168
+ /**
169
+ * SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
170
+ * implement this expose a step-by-step exploration flow (database/schema/
171
+ * table/etc. discovery) that the dashboard backend drives via the
172
+ * `/connections/:connectionId/setup` endpoint. Implement by delegating to
173
+ * `runSetupFlow` from `setup-flow.ts`.
174
+ */
175
+ setup;
176
+ /**
177
+ * Opt-out of the default "verify before save" behavior on connection
178
+ * creation. The backend invokes `checkConnection` synchronously while
179
+ * creating the connection and aborts (no row inserted) if it fails — this
180
+ * flag disables that for connectors where the check cannot succeed pre-save:
181
+ *
182
+ * - `squadbase-db` populates `connection-url` only after Neon provisioning
183
+ * - OAuth connectors require an OAuth-aware proxyFetch keyed by the
184
+ * connectionId, which doesn't exist until the row is saved
185
+ *
186
+ * Exceptions are the explicit position; new credential-input connectors get
187
+ * the default verify-on-create behavior without opt-in.
188
+ */
189
+ skipConnectionCheckOnCreate;
168
190
  constructor(config) {
169
191
  this.slug = config.slug;
170
192
  this.authType = config.authType;
@@ -181,6 +203,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
181
203
  this.tools = config.tools;
182
204
  this.query = config.query;
183
205
  this.checkConnection = config.checkConnection;
206
+ this.setup = config.setup;
207
+ this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
184
208
  }
185
209
  get connectorKey() {
186
210
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -245,6 +269,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
245
269
  }
246
270
  };
247
271
 
272
+ // ../connectors/src/setup-flow.ts
273
+ async function runSetupFlow(flow, params, ctx, config) {
274
+ const runtime = {
275
+ params,
276
+ language: ctx.language,
277
+ config
278
+ };
279
+ let state = flow.initialState();
280
+ let answerIdx = 0;
281
+ for (const step of flow.steps) {
282
+ const ans = ctx.answers[answerIdx];
283
+ if (ans && ans.questionSlug === step.slug) {
284
+ state = step.applyAnswer(state, ans.answer);
285
+ answerIdx += 1;
286
+ continue;
287
+ }
288
+ if (step.type === "text") {
289
+ return {
290
+ type: "nextQuestion",
291
+ questionSlug: step.slug,
292
+ question: step.question[ctx.language],
293
+ questionType: "text"
294
+ };
295
+ }
296
+ const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
297
+ if (options.length === 0) {
298
+ continue;
299
+ }
300
+ return {
301
+ type: "nextQuestion",
302
+ questionSlug: step.slug,
303
+ question: step.question[ctx.language],
304
+ questionType: step.type,
305
+ options
306
+ };
307
+ }
308
+ const dataInvestigationResult = await flow.finalize(state, runtime);
309
+ return { type: "fulfilled", dataInvestigationResult };
310
+ }
311
+ async function resolveSetupSelection(params) {
312
+ const { selected, allSentinel, fetchAll, limit } = params;
313
+ const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
314
+ return resolved.slice(0, limit);
315
+ }
316
+
248
317
  // ../connectors/src/auth-types.ts
249
318
  var AUTH_TYPES = {
250
319
  OAUTH: "oauth",
@@ -425,6 +494,87 @@ var gmailOnboarding = new ConnectorOnboarding({
425
494
  }
426
495
  });
427
496
 
497
+ // ../connectors/src/connectors/gmail-oauth/utils.ts
498
+ async function gmailApiFetch(config, url) {
499
+ const res = await config.proxyFetch(url, { method: "GET" });
500
+ if (!res.ok) {
501
+ const text = await res.text().catch(() => res.statusText);
502
+ throw new Error(`Gmail API ${url} failed: HTTP ${res.status} ${text}`);
503
+ }
504
+ return await res.json();
505
+ }
506
+
507
+ // ../connectors/src/connectors/gmail-oauth/setup-flow.ts
508
+ var ALL_LABELS = "__ALL_LABELS__";
509
+ var GMAIL_SETUP_MAX_LABELS = 20;
510
+ async function listLabels(config) {
511
+ const url = "https://gmail.googleapis.com/gmail/v1/users/me/labels";
512
+ const data = await gmailApiFetch(config, url);
513
+ return data.labels ?? [];
514
+ }
515
+ var gmailOauthSetupFlow = {
516
+ initialState: () => ({}),
517
+ steps: [
518
+ {
519
+ slug: "labels",
520
+ type: "multiSelect",
521
+ question: {
522
+ ja: "\u5BFE\u8C61\u306E\u30E9\u30D9\u30EB\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
523
+ en: "Select target labels (multi-select allowed)"
524
+ },
525
+ async fetchOptions(_state, rt) {
526
+ const labels = await listLabels(rt.config);
527
+ return [
528
+ {
529
+ value: ALL_LABELS,
530
+ label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30E9\u30D9\u30EB" : "All labels"
531
+ },
532
+ ...labels.map((l) => ({ value: l.id, label: l.name }))
533
+ ];
534
+ },
535
+ applyAnswer: (state, answer) => ({ ...state, labels: answer })
536
+ }
537
+ ],
538
+ async finalize(state, rt) {
539
+ if (!state.labels) {
540
+ throw new Error("Gmail setup: incomplete state on finalize");
541
+ }
542
+ const labels = await listLabels(rt.config);
543
+ const labelsById = new Map(labels.map((l) => [l.id, l]));
544
+ const targetIds = await resolveSetupSelection({
545
+ selected: state.labels,
546
+ allSentinel: ALL_LABELS,
547
+ fetchAll: async () => labels.map((l) => l.id),
548
+ limit: GMAIL_SETUP_MAX_LABELS
549
+ });
550
+ const sections = ["## Gmail", ""];
551
+ if (targetIds.length === 0) {
552
+ sections.push(
553
+ rt.language === "ja" ? "\u5BFE\u8C61\u306E\u30E9\u30D9\u30EB\u304C\u9078\u629E\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002" : "No labels selected."
554
+ );
555
+ return sections.join("\n");
556
+ }
557
+ sections.push("| Label | Visibility | Messages | Unread |");
558
+ sections.push("|-------|-----------|----------|--------|");
559
+ for (const id of targetIds) {
560
+ const url = `https://gmail.googleapis.com/gmail/v1/users/me/labels/${encodeURIComponent(
561
+ id
562
+ )}`;
563
+ const detail = await gmailApiFetch(
564
+ rt.config,
565
+ url
566
+ );
567
+ const name = detail.name ?? labelsById.get(id)?.name ?? id;
568
+ const vis = detail.labelListVisibility ?? "-";
569
+ const total = detail.messagesTotal ?? "-";
570
+ const unread = detail.messagesUnread ?? "-";
571
+ sections.push(`| ${name} | ${vis} | ${total} | ${unread} |`);
572
+ }
573
+ sections.push("");
574
+ return sections.join("\n");
575
+ }
576
+ };
577
+
428
578
  // ../connectors/src/connectors/gmail-oauth/parameters.ts
429
579
  var parameters = {};
430
580
 
@@ -433,6 +583,7 @@ var tools = { request: requestTool };
433
583
  var gmailOauthConnector = new ConnectorPlugin({
434
584
  slug: "gmail",
435
585
  authType: AUTH_TYPES.OAUTH,
586
+ skipConnectionCheckOnCreate: true,
436
587
  name: "Gmail",
437
588
  description: "Connect to Gmail for email data access using OAuth. Read-only access to messages, threads, and labels.",
438
589
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4V3rfaSc1ksFIt2eHBNIwJ/7f3be41a154a6d96dcf229ed0e5858c9/Gmail_icon__2020_.svg.png",
@@ -617,6 +768,7 @@ thread.messages.forEach(m => console.log(m.snippet));
617
768
  \`\`\``
618
769
  },
619
770
  tools,
771
+ setup: (params, ctx, config) => runSetupFlow(gmailOauthSetupFlow, params, ctx, config),
620
772
  async checkConnection(_params, config) {
621
773
  const { proxyFetch } = config;
622
774
  const url = "https://gmail.googleapis.com/gmail/v1/users/me/profile";
@@ -665,6 +817,7 @@ function resolveEnvVarOptional(entry, key) {
665
817
  import { getContext } from "hono/context-storage";
666
818
  import { getCookie } from "hono/cookie";
667
819
  var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
820
+ var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
668
821
  function normalizeHeaders(input) {
669
822
  const out = {};
670
823
  if (!input) return out;
@@ -673,6 +826,11 @@ function normalizeHeaders(input) {
673
826
  });
674
827
  return out;
675
828
  }
829
+ function extractInputUrl(input) {
830
+ if (typeof input === "string") return input;
831
+ if (input instanceof URL) return input.href;
832
+ return input.url;
833
+ }
676
834
  function createSandboxProxyFetch(connectionId) {
677
835
  return async (input, init) => {
678
836
  const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
@@ -682,10 +840,17 @@ function createSandboxProxyFetch(connectionId) {
682
840
  "Connection proxy is not configured. Please check your deployment settings."
683
841
  );
684
842
  }
685
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
843
+ const originalUrl = extractInputUrl(input);
844
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
845
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
846
+ const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
847
+ return fetch(sessionUrl, {
848
+ method: "POST",
849
+ headers: { Authorization: `Bearer ${token}` }
850
+ });
851
+ }
686
852
  const originalMethod = init?.method ?? "GET";
687
853
  const originalBody = init?.body ? JSON.parse(init.body) : void 0;
688
- const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
689
854
  const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
690
855
  return fetch(proxyUrl, {
691
856
  method: "POST",
@@ -711,10 +876,9 @@ function createDeployedAppProxyFetch(connectionId) {
711
876
  }
712
877
  const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
713
878
  const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
879
+ const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
714
880
  return async (input, init) => {
715
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
716
- const originalMethod = init?.method ?? "GET";
717
- const originalBody = init?.body ? JSON.parse(init.body) : void 0;
881
+ const originalUrl = extractInputUrl(input);
718
882
  const c = getContext();
719
883
  const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
720
884
  if (!appSession) {
@@ -722,6 +886,14 @@ function createDeployedAppProxyFetch(connectionId) {
722
886
  "No authentication method available for connection proxy."
723
887
  );
724
888
  }
889
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
890
+ return fetch(sessionUrl, {
891
+ method: "POST",
892
+ headers: { Authorization: `Bearer ${appSession}` }
893
+ });
894
+ }
895
+ const originalMethod = init?.method ?? "GET";
896
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
725
897
  return fetch(proxyUrl, {
726
898
  method: "POST",
727
899
  headers: {