@squadbase/vite-server 0.1.12-dev.93b8799 → 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 +12128 -934
  2. package/dist/connectors/airtable-oauth.js +248 -46
  3. package/dist/connectors/airtable.js +285 -51
  4. package/dist/connectors/amplitude.js +288 -47
  5. package/dist/connectors/anthropic.js +126 -47
  6. package/dist/connectors/asana.js +293 -49
  7. package/dist/connectors/attio.js +268 -49
  8. package/dist/connectors/aws-billing.js +253 -46
  9. package/dist/connectors/azure-sql.js +387 -102
  10. package/dist/connectors/backlog-api-key.js +283 -47
  11. package/dist/connectors/clickup.js +304 -49
  12. package/dist/connectors/cosmosdb.js +271 -50
  13. package/dist/connectors/customerio.js +285 -47
  14. package/dist/connectors/dbt.js +306 -47
  15. package/dist/connectors/freshdesk.js +308 -53
  16. package/dist/connectors/freshsales.js +299 -52
  17. package/dist/connectors/freshservice.js +327 -53
  18. package/dist/connectors/gamma.js +293 -52
  19. package/dist/connectors/gemini.js +125 -47
  20. package/dist/connectors/github.js +352 -49
  21. package/dist/connectors/gmail-oauth.js +170 -7
  22. package/dist/connectors/gmail.js +316 -47
  23. package/dist/connectors/google-ads.js +254 -46
  24. package/dist/connectors/google-analytics-oauth.js +276 -46
  25. package/dist/connectors/google-analytics.js +378 -49
  26. package/dist/connectors/google-audit-log.js +404 -47
  27. package/dist/connectors/google-calendar-oauth.js +225 -46
  28. package/dist/connectors/google-calendar.js +325 -47
  29. package/dist/connectors/google-docs.js +186 -6
  30. package/dist/connectors/google-drive.js +228 -5
  31. package/dist/connectors/google-search-console-oauth.js +222 -46
  32. package/dist/connectors/google-sheets.js +238 -47
  33. package/dist/connectors/google-slides.js +171 -6
  34. package/dist/connectors/grafana.js +298 -49
  35. package/dist/connectors/hubspot-oauth.js +174 -5
  36. package/dist/connectors/hubspot.js +272 -49
  37. package/dist/connectors/influxdb.js +382 -51
  38. package/dist/connectors/intercom-oauth.js +176 -5
  39. package/dist/connectors/intercom.js +268 -49
  40. package/dist/connectors/jdbc.js +728 -110
  41. package/dist/connectors/jira-api-key.js +292 -47
  42. package/dist/connectors/kintone-api-token.js +247 -47
  43. package/dist/connectors/kintone.js +294 -47
  44. package/dist/connectors/linear.js +296 -49
  45. package/dist/connectors/linkedin-ads.js +234 -50
  46. package/dist/connectors/mailchimp-oauth.js +234 -46
  47. package/dist/connectors/mailchimp.js +286 -49
  48. package/dist/connectors/meta-ads-oauth.js +239 -48
  49. package/dist/connectors/meta-ads.js +251 -50
  50. package/dist/connectors/mixpanel.js +304 -47
  51. package/dist/connectors/monday.js +326 -49
  52. package/dist/connectors/mongodb.js +285 -57
  53. package/dist/connectors/notion-oauth.js +197 -5
  54. package/dist/connectors/notion.js +289 -51
  55. package/dist/connectors/openai.js +125 -47
  56. package/dist/connectors/oracle.js +405 -103
  57. package/dist/connectors/outlook-oauth.js +170 -5
  58. package/dist/connectors/powerbi-oauth.js +217 -5
  59. package/dist/connectors/salesforce.js +350 -49
  60. package/dist/connectors/semrush.js +280 -49
  61. package/dist/connectors/sentry.js +255 -50
  62. package/dist/connectors/shopify-oauth.js +153 -5
  63. package/dist/connectors/shopify.js +323 -47
  64. package/dist/connectors/sqlserver.js +381 -102
  65. package/dist/connectors/stripe-api-key.js +235 -46
  66. package/dist/connectors/stripe-oauth.js +168 -5
  67. package/dist/connectors/supabase.js +269 -48
  68. package/dist/connectors/tableau.js +337 -206
  69. package/dist/connectors/tiktok-ads.js +245 -48
  70. package/dist/connectors/wix-store.js +286 -49
  71. package/dist/connectors/zendesk-oauth.js +205 -5
  72. package/dist/connectors/zendesk.js +324 -47
  73. package/dist/index.d.ts +149 -1
  74. package/dist/index.js +18297 -6886
  75. package/dist/main.js +12785 -1382
  76. package/dist/vite-plugin.js +12140 -936
  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,
@@ -173,6 +173,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
173
173
  * `runSetupFlow` from `setup-flow.ts`.
174
174
  */
175
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;
176
190
  constructor(config) {
177
191
  this.slug = config.slug;
178
192
  this.authType = config.authType;
@@ -190,6 +204,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
190
204
  this.query = config.query;
191
205
  this.checkConnection = config.checkConnection;
192
206
  this.setup = config.setup;
207
+ this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
193
208
  }
194
209
  get connectorKey() {
195
210
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -254,6 +269,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
254
269
  }
255
270
  };
256
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
+
257
317
  // ../connectors/src/auth-types.ts
258
318
  var AUTH_TYPES = {
259
319
  OAUTH: "oauth",
@@ -434,6 +494,87 @@ var gmailOnboarding = new ConnectorOnboarding({
434
494
  }
435
495
  });
436
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
+
437
578
  // ../connectors/src/connectors/gmail-oauth/parameters.ts
438
579
  var parameters = {};
439
580
 
@@ -442,6 +583,7 @@ var tools = { request: requestTool };
442
583
  var gmailOauthConnector = new ConnectorPlugin({
443
584
  slug: "gmail",
444
585
  authType: AUTH_TYPES.OAUTH,
586
+ skipConnectionCheckOnCreate: true,
445
587
  name: "Gmail",
446
588
  description: "Connect to Gmail for email data access using OAuth. Read-only access to messages, threads, and labels.",
447
589
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4V3rfaSc1ksFIt2eHBNIwJ/7f3be41a154a6d96dcf229ed0e5858c9/Gmail_icon__2020_.svg.png",
@@ -626,6 +768,7 @@ thread.messages.forEach(m => console.log(m.snippet));
626
768
  \`\`\``
627
769
  },
628
770
  tools,
771
+ setup: (params, ctx, config) => runSetupFlow(gmailOauthSetupFlow, params, ctx, config),
629
772
  async checkConnection(_params, config) {
630
773
  const { proxyFetch } = config;
631
774
  const url = "https://gmail.googleapis.com/gmail/v1/users/me/profile";
@@ -674,6 +817,7 @@ function resolveEnvVarOptional(entry, key) {
674
817
  import { getContext } from "hono/context-storage";
675
818
  import { getCookie } from "hono/cookie";
676
819
  var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
820
+ var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
677
821
  function normalizeHeaders(input) {
678
822
  const out = {};
679
823
  if (!input) return out;
@@ -682,6 +826,11 @@ function normalizeHeaders(input) {
682
826
  });
683
827
  return out;
684
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
+ }
685
834
  function createSandboxProxyFetch(connectionId) {
686
835
  return async (input, init) => {
687
836
  const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
@@ -691,10 +840,17 @@ function createSandboxProxyFetch(connectionId) {
691
840
  "Connection proxy is not configured. Please check your deployment settings."
692
841
  );
693
842
  }
694
- 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
+ }
695
852
  const originalMethod = init?.method ?? "GET";
696
853
  const originalBody = init?.body ? JSON.parse(init.body) : void 0;
697
- const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
698
854
  const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
699
855
  return fetch(proxyUrl, {
700
856
  method: "POST",
@@ -720,10 +876,9 @@ function createDeployedAppProxyFetch(connectionId) {
720
876
  }
721
877
  const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
722
878
  const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
879
+ const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
723
880
  return async (input, init) => {
724
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
725
- const originalMethod = init?.method ?? "GET";
726
- const originalBody = init?.body ? JSON.parse(init.body) : void 0;
881
+ const originalUrl = extractInputUrl(input);
727
882
  const c = getContext();
728
883
  const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
729
884
  if (!appSession) {
@@ -731,6 +886,14 @@ function createDeployedAppProxyFetch(connectionId) {
731
886
  "No authentication method available for connection proxy."
732
887
  );
733
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;
734
897
  return fetch(proxyUrl, {
735
898
  method: "POST",
736
899
  headers: {