@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
@@ -1,48 +1,60 @@
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
+
1
6
  // ../connectors/src/parameter-definition.ts
2
- var ParameterDefinition = class {
3
- slug;
4
- name;
5
- description;
6
- envVarBaseKey;
7
- type;
8
- secret;
9
- required;
10
- constructor(config) {
11
- this.slug = config.slug;
12
- this.name = config.name;
13
- this.description = config.description;
14
- this.envVarBaseKey = config.envVarBaseKey;
15
- this.type = config.type;
16
- this.secret = config.secret;
17
- this.required = config.required;
18
- }
19
- /**
20
- * Get the parameter value from a ConnectorConnectionObject.
21
- */
22
- getValue(connection2) {
23
- const param = connection2.parameters.find(
24
- (p) => p.parameterSlug === this.slug
25
- );
26
- if (!param || param.value == null) {
27
- throw new Error(
28
- `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
29
- );
30
- }
31
- return param.value;
32
- }
33
- /**
34
- * Try to get the parameter value. Returns undefined if not found (for optional params).
35
- */
36
- tryGetValue(connection2) {
37
- const param = connection2.parameters.find(
38
- (p) => p.parameterSlug === this.slug
39
- );
40
- if (!param || param.value == null) return void 0;
41
- return param.value;
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
+ constructor(config) {
20
+ this.slug = config.slug;
21
+ this.name = config.name;
22
+ this.description = config.description;
23
+ this.envVarBaseKey = config.envVarBaseKey;
24
+ this.type = config.type;
25
+ this.secret = config.secret;
26
+ this.required = config.required;
27
+ }
28
+ /**
29
+ * Get the parameter value from a ConnectorConnectionObject.
30
+ */
31
+ getValue(connection2) {
32
+ const param = connection2.parameters.find(
33
+ (p) => p.parameterSlug === this.slug
34
+ );
35
+ if (!param || param.value == null) {
36
+ throw new Error(
37
+ `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
38
+ );
39
+ }
40
+ return param.value;
41
+ }
42
+ /**
43
+ * Try to get the parameter value. Returns undefined if not found (for optional params).
44
+ */
45
+ tryGetValue(connection2) {
46
+ const param = connection2.parameters.find(
47
+ (p) => p.parameterSlug === this.slug
48
+ );
49
+ if (!param || param.value == null) return void 0;
50
+ return param.value;
51
+ }
52
+ };
42
53
  }
43
- };
54
+ });
44
55
 
45
56
  // ../connectors/src/connectors/semrush/parameters.ts
57
+ init_parameter_definition();
46
58
  var parameters = {
47
59
  apiKey: new ParameterDefinition({
48
60
  slug: "api-key",
@@ -244,6 +256,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
244
256
  * `runSetupFlow` from `setup-flow.ts`.
245
257
  */
246
258
  setup;
259
+ /**
260
+ * Opt-out of the default "verify before save" behavior on connection
261
+ * creation. The backend invokes `checkConnection` synchronously while
262
+ * creating the connection and aborts (no row inserted) if it fails — this
263
+ * flag disables that for connectors where the check cannot succeed pre-save:
264
+ *
265
+ * - `squadbase-db` populates `connection-url` only after Neon provisioning
266
+ * - OAuth connectors require an OAuth-aware proxyFetch keyed by the
267
+ * connectionId, which doesn't exist until the row is saved
268
+ *
269
+ * Exceptions are the explicit position; new credential-input connectors get
270
+ * the default verify-on-create behavior without opt-in.
271
+ */
272
+ skipConnectionCheckOnCreate;
247
273
  constructor(config) {
248
274
  this.slug = config.slug;
249
275
  this.authType = config.authType;
@@ -261,6 +287,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
261
287
  this.query = config.query;
262
288
  this.checkConnection = config.checkConnection;
263
289
  this.setup = config.setup;
290
+ this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
264
291
  }
265
292
  get connectorKey() {
266
293
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -325,6 +352,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
325
352
  }
326
353
  };
327
354
 
355
+ // ../connectors/src/setup-flow.ts
356
+ async function runSetupFlow(flow, params, ctx, config) {
357
+ const runtime = {
358
+ params,
359
+ language: ctx.language,
360
+ config
361
+ };
362
+ let state = flow.initialState();
363
+ let answerIdx = 0;
364
+ for (const step of flow.steps) {
365
+ const ans = ctx.answers[answerIdx];
366
+ if (ans && ans.questionSlug === step.slug) {
367
+ state = step.applyAnswer(state, ans.answer);
368
+ answerIdx += 1;
369
+ continue;
370
+ }
371
+ if (step.type === "text") {
372
+ return {
373
+ type: "nextQuestion",
374
+ questionSlug: step.slug,
375
+ question: step.question[ctx.language],
376
+ questionType: "text"
377
+ };
378
+ }
379
+ const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
380
+ if (options.length === 0) {
381
+ continue;
382
+ }
383
+ return {
384
+ type: "nextQuestion",
385
+ questionSlug: step.slug,
386
+ question: step.question[ctx.language],
387
+ questionType: step.type,
388
+ options
389
+ };
390
+ }
391
+ const dataInvestigationResult = await flow.finalize(state, runtime);
392
+ return { type: "fulfilled", dataInvestigationResult };
393
+ }
394
+ async function resolveSetupSelection(params) {
395
+ const { selected, allSentinel, fetchAll, limit } = params;
396
+ const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
397
+ return resolved.slice(0, limit);
398
+ }
399
+
328
400
  // ../connectors/src/auth-types.ts
329
401
  var AUTH_TYPES = {
330
402
  OAUTH: "oauth",
@@ -520,6 +592,144 @@ var semrushOnboarding = new ConnectorOnboarding({
520
592
  }
521
593
  });
522
594
 
595
+ // ../connectors/src/connectors/semrush/utils.ts
596
+ var PROJECTS_BASE_URL = "https://api.semrush.com/management/v1";
597
+ function projectsApiFetch(params, path2, init) {
598
+ const apiKey = params[parameters.apiKey.slug];
599
+ if (!apiKey) {
600
+ throw new Error(
601
+ `semrush: missing required parameter: ${parameters.apiKey.slug}`
602
+ );
603
+ }
604
+ const trimmedPath = path2.startsWith("/") ? path2 : `/${path2}`;
605
+ const url = new URL(`${PROJECTS_BASE_URL}${trimmedPath}`);
606
+ if (!url.searchParams.has("key")) {
607
+ url.searchParams.set("key", apiKey);
608
+ }
609
+ const headers = new Headers(init?.headers);
610
+ if (!headers.has("Accept")) headers.set("Accept", "application/json");
611
+ return fetch(url.toString(), { ...init, headers });
612
+ }
613
+
614
+ // ../connectors/src/connectors/semrush/setup-flow.ts
615
+ var ALL_PROJECTS = "__ALL_PROJECTS__";
616
+ var SEMRUSH_SETUP_MAX_PROJECTS = 10;
617
+ function projectId(p) {
618
+ const raw = p.project_id ?? p.id;
619
+ return raw == null ? "" : String(raw);
620
+ }
621
+ function projectName(p) {
622
+ return p.project_name ?? p.name ?? p.domain ?? p.url ?? projectId(p);
623
+ }
624
+ function projectDomain(p) {
625
+ return p.domain ?? p.url ?? "";
626
+ }
627
+ function projectCreatedAt(p) {
628
+ return p.created_at ?? p.date_created ?? "";
629
+ }
630
+ async function fetchProjects(params) {
631
+ let res;
632
+ try {
633
+ res = await projectsApiFetch(params, "/projects/");
634
+ } catch (err) {
635
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
636
+ }
637
+ if (!res.ok) {
638
+ const body2 = await res.text().catch(() => res.statusText);
639
+ return { ok: false, error: `HTTP ${res.status} ${body2 || res.statusText}` };
640
+ }
641
+ let body;
642
+ try {
643
+ body = await res.json();
644
+ } catch (err) {
645
+ return {
646
+ ok: false,
647
+ error: err instanceof Error ? err.message : String(err)
648
+ };
649
+ }
650
+ const projects = Array.isArray(body) ? body : Array.isArray(body?.projects) ? body.projects : Array.isArray(body?.data) ? body.data : [];
651
+ return { ok: true, projects };
652
+ }
653
+ var semrushSetupFlow = {
654
+ initialState: () => ({}),
655
+ steps: [
656
+ {
657
+ slug: "projects",
658
+ type: "multiSelect",
659
+ question: {
660
+ ja: "\u5BFE\u8C61\u306E Semrush \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
661
+ en: "Select target Semrush projects (multi-select allowed)"
662
+ },
663
+ async fetchOptions(_state, rt) {
664
+ const result = await fetchProjects(rt.params);
665
+ if (!result.ok || result.projects.length === 0) {
666
+ return [];
667
+ }
668
+ const options = result.projects.map((p) => {
669
+ const id = projectId(p);
670
+ if (!id) return null;
671
+ return { value: id, label: projectName(p) };
672
+ }).filter((opt) => opt !== null);
673
+ if (options.length === 0) return [];
674
+ return [
675
+ {
676
+ value: ALL_PROJECTS,
677
+ label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8" : "All projects"
678
+ },
679
+ ...options
680
+ ];
681
+ },
682
+ applyAnswer: (state, answer) => ({ ...state, projects: answer })
683
+ }
684
+ ],
685
+ async finalize(state, rt) {
686
+ const sections = ["## Semrush", ""];
687
+ if (!state.projects?.length) {
688
+ sections.push(
689
+ "_No Semrush Projects API access detected; Standard Analytics reports run by domain/keyword and don't require pre-selection._",
690
+ ""
691
+ );
692
+ return sections.join("\n");
693
+ }
694
+ const result = await fetchProjects(rt.params);
695
+ if (!result.ok) {
696
+ throw new Error(
697
+ `semrush: listProjects failed on finalize: ${result.error}`
698
+ );
699
+ }
700
+ const projectByIdMap = /* @__PURE__ */ new Map();
701
+ for (const p of result.projects) {
702
+ const id = projectId(p);
703
+ if (id) projectByIdMap.set(id, p);
704
+ }
705
+ const targetIds = await resolveSetupSelection({
706
+ selected: state.projects,
707
+ allSentinel: ALL_PROJECTS,
708
+ fetchAll: async () => result.projects.map((p) => projectId(p)).filter((id) => id),
709
+ limit: SEMRUSH_SETUP_MAX_PROJECTS
710
+ });
711
+ if (!targetIds.length) {
712
+ sections.push("_No projects selected._", "");
713
+ return sections.join("\n");
714
+ }
715
+ sections.push("| Project | Domain | Created |");
716
+ sections.push("|---------|--------|---------|");
717
+ for (const id of targetIds) {
718
+ const p = projectByIdMap.get(id);
719
+ if (!p) {
720
+ sections.push(`| ${id} | - | - |`);
721
+ continue;
722
+ }
723
+ const name = projectName(p).replace(/\|/g, "\\|");
724
+ const domain = projectDomain(p).replace(/\|/g, "\\|") || "-";
725
+ const created = projectCreatedAt(p) || "-";
726
+ sections.push(`| ${name} | ${domain} | ${created} |`);
727
+ }
728
+ sections.push("");
729
+ return sections.join("\n");
730
+ }
731
+ };
732
+
523
733
  // ../connectors/src/connectors/semrush/index.ts
524
734
  var tools = { request: requestTool };
525
735
  var semrushConnector = new ConnectorPlugin({
@@ -741,6 +951,7 @@ API \u30E6\u30CB\u30C3\u30C8\u6B8B\u91CF\u306E\u78BA\u8A8D\uFF08\u7121\u6599\u30
741
951
  - \u5C65\u6B74\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306E\u65E5\u4ED8\u306F\u5FC5\u305A\u6708\u306E15\u65E5\uFF08\`YYYYMM15\`\uFF09`
742
952
  },
743
953
  tools,
954
+ setup: (params, ctx, config) => runSetupFlow(semrushSetupFlow, params, ctx, config),
744
955
  async checkConnection(params) {
745
956
  try {
746
957
  const apiKey = params["api-key"];
@@ -799,6 +1010,7 @@ function resolveEnvVarOptional(entry, key) {
799
1010
  import { getContext } from "hono/context-storage";
800
1011
  import { getCookie } from "hono/cookie";
801
1012
  var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
1013
+ var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
802
1014
  function normalizeHeaders(input) {
803
1015
  const out = {};
804
1016
  if (!input) return out;
@@ -807,6 +1019,11 @@ function normalizeHeaders(input) {
807
1019
  });
808
1020
  return out;
809
1021
  }
1022
+ function extractInputUrl(input) {
1023
+ if (typeof input === "string") return input;
1024
+ if (input instanceof URL) return input.href;
1025
+ return input.url;
1026
+ }
810
1027
  function createSandboxProxyFetch(connectionId) {
811
1028
  return async (input, init) => {
812
1029
  const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
@@ -816,10 +1033,17 @@ function createSandboxProxyFetch(connectionId) {
816
1033
  "Connection proxy is not configured. Please check your deployment settings."
817
1034
  );
818
1035
  }
819
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
1036
+ const originalUrl = extractInputUrl(input);
1037
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
1038
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
1039
+ const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
1040
+ return fetch(sessionUrl, {
1041
+ method: "POST",
1042
+ headers: { Authorization: `Bearer ${token}` }
1043
+ });
1044
+ }
820
1045
  const originalMethod = init?.method ?? "GET";
821
1046
  const originalBody = init?.body ? JSON.parse(init.body) : void 0;
822
- const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
823
1047
  const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
824
1048
  return fetch(proxyUrl, {
825
1049
  method: "POST",
@@ -837,18 +1061,17 @@ function createSandboxProxyFetch(connectionId) {
837
1061
  };
838
1062
  }
839
1063
  function createDeployedAppProxyFetch(connectionId) {
840
- const projectId = process.env["SQUADBASE_PROJECT_ID"];
841
- if (!projectId) {
1064
+ const projectId2 = process.env["SQUADBASE_PROJECT_ID"];
1065
+ if (!projectId2) {
842
1066
  throw new Error(
843
1067
  "Connection proxy is not configured. Please check your deployment settings."
844
1068
  );
845
1069
  }
846
1070
  const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
847
- const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
1071
+ const proxyUrl = `https://${projectId2}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
1072
+ const sessionUrl = `https://${projectId2}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
848
1073
  return async (input, init) => {
849
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
850
- const originalMethod = init?.method ?? "GET";
851
- const originalBody = init?.body ? JSON.parse(init.body) : void 0;
1074
+ const originalUrl = extractInputUrl(input);
852
1075
  const c = getContext();
853
1076
  const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
854
1077
  if (!appSession) {
@@ -856,6 +1079,14 @@ function createDeployedAppProxyFetch(connectionId) {
856
1079
  "No authentication method available for connection proxy."
857
1080
  );
858
1081
  }
1082
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
1083
+ return fetch(sessionUrl, {
1084
+ method: "POST",
1085
+ headers: { Authorization: `Bearer ${appSession}` }
1086
+ });
1087
+ }
1088
+ const originalMethod = init?.method ?? "GET";
1089
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
859
1090
  return fetch(proxyUrl, {
860
1091
  method: "POST",
861
1092
  headers: {