@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
@@ -79,6 +79,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
79
79
  * `runSetupFlow` from `setup-flow.ts`.
80
80
  */
81
81
  setup;
82
+ /**
83
+ * Opt-out of the default "verify before save" behavior on connection
84
+ * creation. The backend invokes `checkConnection` synchronously while
85
+ * creating the connection and aborts (no row inserted) if it fails — this
86
+ * flag disables that for connectors where the check cannot succeed pre-save:
87
+ *
88
+ * - `squadbase-db` populates `connection-url` only after Neon provisioning
89
+ * - OAuth connectors require an OAuth-aware proxyFetch keyed by the
90
+ * connectionId, which doesn't exist until the row is saved
91
+ *
92
+ * Exceptions are the explicit position; new credential-input connectors get
93
+ * the default verify-on-create behavior without opt-in.
94
+ */
95
+ skipConnectionCheckOnCreate;
82
96
  constructor(config) {
83
97
  this.slug = config.slug;
84
98
  this.authType = config.authType;
@@ -96,6 +110,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
96
110
  this.query = config.query;
97
111
  this.checkConnection = config.checkConnection;
98
112
  this.setup = config.setup;
113
+ this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
99
114
  }
100
115
  get connectorKey() {
101
116
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -160,6 +175,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
160
175
  }
161
176
  };
162
177
 
178
+ // ../connectors/src/setup-flow.ts
179
+ async function runSetupFlow(flow, params, ctx, config) {
180
+ const runtime = {
181
+ params,
182
+ language: ctx.language,
183
+ config
184
+ };
185
+ let state = flow.initialState();
186
+ let answerIdx = 0;
187
+ for (const step of flow.steps) {
188
+ const ans = ctx.answers[answerIdx];
189
+ if (ans && ans.questionSlug === step.slug) {
190
+ state = step.applyAnswer(state, ans.answer);
191
+ answerIdx += 1;
192
+ continue;
193
+ }
194
+ if (step.type === "text") {
195
+ return {
196
+ type: "nextQuestion",
197
+ questionSlug: step.slug,
198
+ question: step.question[ctx.language],
199
+ questionType: "text"
200
+ };
201
+ }
202
+ const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
203
+ if (options.length === 0) {
204
+ continue;
205
+ }
206
+ return {
207
+ type: "nextQuestion",
208
+ questionSlug: step.slug,
209
+ question: step.question[ctx.language],
210
+ questionType: step.type,
211
+ options
212
+ };
213
+ }
214
+ const dataInvestigationResult = await flow.finalize(state, runtime);
215
+ return { type: "fulfilled", dataInvestigationResult };
216
+ }
217
+ async function resolveSetupSelection(params) {
218
+ const { selected, allSentinel, fetchAll, limit } = params;
219
+ const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
220
+ return resolved.slice(0, limit);
221
+ }
222
+
163
223
  // ../connectors/src/auth-types.ts
164
224
  var AUTH_TYPES = {
165
225
  OAUTH: "oauth",
@@ -324,11 +384,122 @@ var notionOauthOnboarding = new ConnectorOnboarding({
324
384
  // ../connectors/src/connectors/notion-oauth/parameters.ts
325
385
  var parameters = {};
326
386
 
387
+ // ../connectors/src/connectors/notion-oauth/utils.ts
388
+ var BASE_URL3 = "https://api.notion.com/v1";
389
+ var NOTION_VERSION3 = "2022-06-28";
390
+ function apiFetch(proxyFetch, path2, init) {
391
+ const url = `${BASE_URL3}${path2.startsWith("/") ? "" : "/"}${path2}`;
392
+ const headers = new Headers(init?.headers);
393
+ headers.set("Notion-Version", NOTION_VERSION3);
394
+ if (init?.body && !headers.has("Content-Type")) {
395
+ headers.set("Content-Type", "application/json");
396
+ }
397
+ return proxyFetch(url, { ...init, headers });
398
+ }
399
+
400
+ // ../connectors/src/connectors/notion-oauth/setup-flow.ts
401
+ var ALL_DATABASES = "__ALL_DATABASES__";
402
+ var NOTION_SETUP_MAX_DATABASES = 20;
403
+ function databaseTitle(db) {
404
+ const parts = (db.title ?? []).map((t) => t.plain_text ?? "").filter((s) => s);
405
+ return parts.join("").trim() || "(Untitled)";
406
+ }
407
+ async function searchDatabases(proxyFetch) {
408
+ const results = [];
409
+ let startCursor;
410
+ for (let i = 0; i < 20; i++) {
411
+ const body = {
412
+ filter: { property: "object", value: "database" },
413
+ page_size: 100
414
+ };
415
+ if (startCursor) body.start_cursor = startCursor;
416
+ const res = await apiFetch(proxyFetch, "/search", {
417
+ method: "POST",
418
+ body: JSON.stringify(body)
419
+ });
420
+ if (!res.ok) {
421
+ const text = await res.text().catch(() => res.statusText);
422
+ throw new Error(
423
+ `notion-oauth: search failed (${res.status}): ${text}`
424
+ );
425
+ }
426
+ const data = await res.json();
427
+ for (const r of data.results ?? []) results.push(r);
428
+ if (!data.has_more || !data.next_cursor) break;
429
+ startCursor = data.next_cursor;
430
+ }
431
+ return results;
432
+ }
433
+ async function getDatabase(proxyFetch, databaseId) {
434
+ const res = await apiFetch(proxyFetch, `/databases/${databaseId}`);
435
+ if (!res.ok) {
436
+ const text = await res.text().catch(() => res.statusText);
437
+ throw new Error(
438
+ `notion-oauth: getDatabase ${databaseId} failed (${res.status}): ${text}`
439
+ );
440
+ }
441
+ return await res.json();
442
+ }
443
+ var notionOauthSetupFlow = {
444
+ initialState: () => ({}),
445
+ steps: [
446
+ {
447
+ slug: "databases",
448
+ type: "multiSelect",
449
+ question: {
450
+ ja: "\u5BFE\u8C61\u306E\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
451
+ en: "Select target databases (multi-select allowed)"
452
+ },
453
+ async fetchOptions(_state, rt) {
454
+ const dbs = await searchDatabases(rt.config.proxyFetch);
455
+ const dbOptions = dbs.filter((db) => db.id).map((db) => ({ value: db.id, label: databaseTitle(db) }));
456
+ return [
457
+ {
458
+ value: ALL_DATABASES,
459
+ label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9" : "All databases"
460
+ },
461
+ ...dbOptions
462
+ ];
463
+ },
464
+ applyAnswer: (state, answer) => ({ ...state, databases: answer })
465
+ }
466
+ ],
467
+ async finalize(state, rt) {
468
+ if (!state.databases) {
469
+ throw new Error("Notion setup: incomplete state on finalize");
470
+ }
471
+ const targetIds = await resolveSetupSelection({
472
+ selected: state.databases,
473
+ allSentinel: ALL_DATABASES,
474
+ fetchAll: async () => {
475
+ const dbs = await searchDatabases(rt.config.proxyFetch);
476
+ return dbs.map((db) => db.id).filter((id) => id);
477
+ },
478
+ limit: NOTION_SETUP_MAX_DATABASES
479
+ });
480
+ const sections = ["## Notion", ""];
481
+ for (const dbId of targetIds) {
482
+ const db = await getDatabase(rt.config.proxyFetch, dbId);
483
+ const title = databaseTitle(db);
484
+ sections.push(`### Database: ${title}`, "", `- id: \`${db.id}\``, "");
485
+ sections.push("| Property | Type |");
486
+ sections.push("|----------|------|");
487
+ for (const [name, def] of Object.entries(db.properties ?? {})) {
488
+ const escapedName = name.replace(/\|/g, "\\|");
489
+ sections.push(`| ${escapedName} | ${def?.type ?? "-"} |`);
490
+ }
491
+ sections.push("");
492
+ }
493
+ return sections.join("\n");
494
+ }
495
+ };
496
+
327
497
  // ../connectors/src/connectors/notion-oauth/index.ts
328
498
  var tools = { request: requestTool };
329
499
  var notionOauthConnector = new ConnectorPlugin({
330
500
  slug: "notion",
331
501
  authType: AUTH_TYPES.OAUTH,
502
+ skipConnectionCheckOnCreate: true,
332
503
  name: "Notion",
333
504
  description: "Connect to Notion to query databases, pages, and workspace content using OAuth.",
334
505
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/797V5GDDTA8bsfKUHBCoQO/290ec49b70b68ddb4acd3bf0a6ab8bda/notion-icon.webp",
@@ -447,6 +618,7 @@ const data = await res.json();
447
618
  \`\`\``
448
619
  },
449
620
  tools,
621
+ setup: (params, ctx, config) => runSetupFlow(notionOauthSetupFlow, params, ctx, config),
450
622
  async checkConnection(_params, config) {
451
623
  const { proxyFetch } = config;
452
624
  try {
@@ -497,6 +669,7 @@ function resolveEnvVarOptional(entry, key) {
497
669
  import { getContext } from "hono/context-storage";
498
670
  import { getCookie } from "hono/cookie";
499
671
  var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
672
+ var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
500
673
  function normalizeHeaders(input) {
501
674
  const out = {};
502
675
  if (!input) return out;
@@ -505,6 +678,11 @@ function normalizeHeaders(input) {
505
678
  });
506
679
  return out;
507
680
  }
681
+ function extractInputUrl(input) {
682
+ if (typeof input === "string") return input;
683
+ if (input instanceof URL) return input.href;
684
+ return input.url;
685
+ }
508
686
  function createSandboxProxyFetch(connectionId) {
509
687
  return async (input, init) => {
510
688
  const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
@@ -514,10 +692,17 @@ function createSandboxProxyFetch(connectionId) {
514
692
  "Connection proxy is not configured. Please check your deployment settings."
515
693
  );
516
694
  }
517
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
695
+ const originalUrl = extractInputUrl(input);
696
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
697
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
698
+ const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
699
+ return fetch(sessionUrl, {
700
+ method: "POST",
701
+ headers: { Authorization: `Bearer ${token}` }
702
+ });
703
+ }
518
704
  const originalMethod = init?.method ?? "GET";
519
705
  const originalBody = init?.body ? JSON.parse(init.body) : void 0;
520
- const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
521
706
  const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
522
707
  return fetch(proxyUrl, {
523
708
  method: "POST",
@@ -543,10 +728,9 @@ function createDeployedAppProxyFetch(connectionId) {
543
728
  }
544
729
  const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
545
730
  const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
731
+ const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
546
732
  return async (input, init) => {
547
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
548
- const originalMethod = init?.method ?? "GET";
549
- const originalBody = init?.body ? JSON.parse(init.body) : void 0;
733
+ const originalUrl = extractInputUrl(input);
550
734
  const c = getContext();
551
735
  const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
552
736
  if (!appSession) {
@@ -554,6 +738,14 @@ function createDeployedAppProxyFetch(connectionId) {
554
738
  "No authentication method available for connection proxy."
555
739
  );
556
740
  }
741
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
742
+ return fetch(sessionUrl, {
743
+ method: "POST",
744
+ headers: { Authorization: `Bearer ${appSession}` }
745
+ });
746
+ }
747
+ const originalMethod = init?.method ?? "GET";
748
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
557
749
  return fetch(proxyUrl, {
558
750
  method: "POST",
559
751
  headers: {