@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/hubspot/parameters.ts
57
+ init_parameter_definition();
46
58
  var parameters = {
47
59
  apiKey: new ParameterDefinition({
48
60
  slug: "api-key",
@@ -204,6 +216,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
204
216
  * `runSetupFlow` from `setup-flow.ts`.
205
217
  */
206
218
  setup;
219
+ /**
220
+ * Opt-out of the default "verify before save" behavior on connection
221
+ * creation. The backend invokes `checkConnection` synchronously while
222
+ * creating the connection and aborts (no row inserted) if it fails — this
223
+ * flag disables that for connectors where the check cannot succeed pre-save:
224
+ *
225
+ * - `squadbase-db` populates `connection-url` only after Neon provisioning
226
+ * - OAuth connectors require an OAuth-aware proxyFetch keyed by the
227
+ * connectionId, which doesn't exist until the row is saved
228
+ *
229
+ * Exceptions are the explicit position; new credential-input connectors get
230
+ * the default verify-on-create behavior without opt-in.
231
+ */
232
+ skipConnectionCheckOnCreate;
207
233
  constructor(config) {
208
234
  this.slug = config.slug;
209
235
  this.authType = config.authType;
@@ -221,6 +247,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
221
247
  this.query = config.query;
222
248
  this.checkConnection = config.checkConnection;
223
249
  this.setup = config.setup;
250
+ this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
224
251
  }
225
252
  get connectorKey() {
226
253
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -285,6 +312,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
285
312
  }
286
313
  };
287
314
 
315
+ // ../connectors/src/setup-flow.ts
316
+ async function runSetupFlow(flow, params, ctx, config) {
317
+ const runtime = {
318
+ params,
319
+ language: ctx.language,
320
+ config
321
+ };
322
+ let state = flow.initialState();
323
+ let answerIdx = 0;
324
+ for (const step of flow.steps) {
325
+ const ans = ctx.answers[answerIdx];
326
+ if (ans && ans.questionSlug === step.slug) {
327
+ state = step.applyAnswer(state, ans.answer);
328
+ answerIdx += 1;
329
+ continue;
330
+ }
331
+ if (step.type === "text") {
332
+ return {
333
+ type: "nextQuestion",
334
+ questionSlug: step.slug,
335
+ question: step.question[ctx.language],
336
+ questionType: "text"
337
+ };
338
+ }
339
+ const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
340
+ if (options.length === 0) {
341
+ continue;
342
+ }
343
+ return {
344
+ type: "nextQuestion",
345
+ questionSlug: step.slug,
346
+ question: step.question[ctx.language],
347
+ questionType: step.type,
348
+ options
349
+ };
350
+ }
351
+ const dataInvestigationResult = await flow.finalize(state, runtime);
352
+ return { type: "fulfilled", dataInvestigationResult };
353
+ }
354
+ async function resolveSetupSelection(params) {
355
+ const { selected, allSentinel, fetchAll, limit } = params;
356
+ const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
357
+ return resolved.slice(0, limit);
358
+ }
359
+
288
360
  // ../connectors/src/auth-types.ts
289
361
  var AUTH_TYPES = {
290
362
  OAUTH: "oauth",
@@ -307,9 +379,105 @@ var hubspotOnboarding = new ConnectorOnboarding({
307
379
  }
308
380
  });
309
381
 
382
+ // ../connectors/src/connectors/hubspot/utils.ts
383
+ var BASE_URL2 = "https://api.hubapi.com";
384
+ async function apiFetch(params, path2, init) {
385
+ const apiKey = params[parameters.apiKey.slug];
386
+ if (!apiKey) {
387
+ throw new Error("hubspot: missing required parameter: api-key");
388
+ }
389
+ const url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
390
+ const headers = new Headers(init?.headers);
391
+ headers.set("Authorization", `Bearer ${apiKey}`);
392
+ headers.set("Accept", "application/json");
393
+ return fetch(url, { ...init, headers });
394
+ }
395
+
396
+ // ../connectors/src/connectors/hubspot/setup-flow.ts
397
+ var HUBSPOT_SETUP_MAX_OBJECT_TYPES = 10;
398
+ var HUBSPOT_SETUP_MAX_PROPERTIES = 50;
399
+ var HUBSPOT_OBJECT_TYPES = [
400
+ { value: "contacts", label: "Contacts" },
401
+ { value: "companies", label: "Companies" },
402
+ { value: "deals", label: "Deals" },
403
+ { value: "tickets", label: "Tickets" },
404
+ { value: "products", label: "Products" },
405
+ { value: "notes", label: "Notes" },
406
+ { value: "calls", label: "Calls" },
407
+ { value: "emails", label: "Emails" },
408
+ { value: "meetings", label: "Meetings" },
409
+ { value: "tasks", label: "Tasks" }
410
+ ];
411
+ async function listProperties(params, objectType) {
412
+ const res = await apiFetch(params, `/crm/v3/properties/${objectType}`);
413
+ if (!res.ok) {
414
+ const body = await res.text().catch(() => res.statusText);
415
+ throw new Error(
416
+ `hubspot: listProperties(${objectType}) failed (${res.status}): ${body}`
417
+ );
418
+ }
419
+ const data = await res.json();
420
+ return data.results ?? [];
421
+ }
422
+ var hubspotSetupFlow = {
423
+ initialState: () => ({}),
424
+ steps: [
425
+ {
426
+ slug: "objectTypes",
427
+ type: "multiSelect",
428
+ question: {
429
+ ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3067\u6982\u89B3\u3057\u305F\u3044CRM\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
430
+ en: "Select the CRM object types to include in setup (multi-select allowed)"
431
+ },
432
+ async fetchOptions(_state, _rt) {
433
+ return HUBSPOT_OBJECT_TYPES.map((o) => ({
434
+ value: o.value,
435
+ label: o.label
436
+ }));
437
+ },
438
+ applyAnswer: (state, answer) => ({ ...state, objectTypes: answer })
439
+ }
440
+ ],
441
+ async finalize(state, rt) {
442
+ if (!state.objectTypes) {
443
+ throw new Error("HubSpot setup: incomplete state on finalize");
444
+ }
445
+ const targetObjectTypes = await resolveSetupSelection({
446
+ selected: state.objectTypes,
447
+ // No "all" sentinel — the list is fixed and small, so explicit selection
448
+ // is the only path. resolveSetupSelection still enforces the cap.
449
+ allSentinel: "__ALL__",
450
+ fetchAll: async () => HUBSPOT_OBJECT_TYPES.map((o) => o.value),
451
+ limit: HUBSPOT_SETUP_MAX_OBJECT_TYPES
452
+ });
453
+ const sections = ["## HubSpot", ""];
454
+ for (const objectType of targetObjectTypes) {
455
+ sections.push(`### Object: ${objectType}`, "");
456
+ const props = await listProperties(rt.params, objectType);
457
+ const limited = props.slice(0, HUBSPOT_SETUP_MAX_PROPERTIES);
458
+ sections.push("| Property | Type | Label |");
459
+ sections.push("|----------|------|-------|");
460
+ for (const p of limited) {
461
+ const name = (p.name ?? "").replace(/\|/g, "\\|");
462
+ const type = (p.type ?? "").replace(/\|/g, "\\|");
463
+ const label = (p.label ?? "").replace(/\|/g, "\\|");
464
+ sections.push(`| ${name} | ${type} | ${label || "-"} |`);
465
+ }
466
+ if (props.length > HUBSPOT_SETUP_MAX_PROPERTIES) {
467
+ sections.push(
468
+ "",
469
+ `_Showing first ${HUBSPOT_SETUP_MAX_PROPERTIES} of ${props.length} properties._`
470
+ );
471
+ }
472
+ sections.push("");
473
+ }
474
+ return sections.join("\n");
475
+ }
476
+ };
477
+
310
478
  // ../connectors/src/connectors/hubspot/tools/request.ts
311
479
  import { z } from "zod";
312
- var BASE_URL2 = "https://api.hubapi.com";
480
+ var BASE_URL3 = "https://api.hubapi.com";
313
481
  var REQUEST_TIMEOUT_MS = 6e4;
314
482
  var inputSchema = z.object({
315
483
  toolUseIntent: z.string().optional().describe(
@@ -356,7 +524,7 @@ Use the search endpoint (POST /crm/v3/objects/{objectType}/search) for complex q
356
524
  );
357
525
  try {
358
526
  const apiKey = parameters.apiKey.getValue(connection2);
359
- const url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
527
+ const url = `${BASE_URL3}${path2.startsWith("/") ? "" : "/"}${path2}`;
360
528
  const controller = new AbortController();
361
529
  const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
362
530
  try {
@@ -531,7 +699,42 @@ export default async function handler(c: Context) {
531
699
  - \`limit\` \u2014 \u30DA\u30FC\u30B8\u3042\u305F\u308A\u306E\u6700\u5927\u7D50\u679C\u6570\uFF08\u6700\u5927100\uFF09
532
700
  - \`after\` \u2014 \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u30AA\u30D5\u30BB\u30C3\u30C8`
533
701
  },
534
- tools
702
+ tools,
703
+ setup: (params, ctx, config) => runSetupFlow(hubspotSetupFlow, params, ctx, config),
704
+ async checkConnection(params, _config) {
705
+ const apiKey = params[parameters.apiKey.slug];
706
+ if (!apiKey) {
707
+ return {
708
+ success: false,
709
+ error: `Missing required parameter: ${parameters.apiKey.slug}`
710
+ };
711
+ }
712
+ try {
713
+ const res = await fetch(
714
+ "https://api.hubapi.com/account-info/v3/details",
715
+ {
716
+ method: "GET",
717
+ headers: {
718
+ Authorization: `Bearer ${apiKey}`,
719
+ Accept: "application/json"
720
+ }
721
+ }
722
+ );
723
+ if (!res.ok) {
724
+ const errText = await res.text().catch(() => res.statusText);
725
+ return {
726
+ success: false,
727
+ error: `HubSpot API failed: HTTP ${res.status} ${errText}`
728
+ };
729
+ }
730
+ return { success: true };
731
+ } catch (error) {
732
+ return {
733
+ success: false,
734
+ error: error instanceof Error ? error.message : String(error)
735
+ };
736
+ }
737
+ }
535
738
  });
536
739
 
537
740
  // src/connectors/create-connector-sdk.ts
@@ -560,6 +763,7 @@ function resolveEnvVarOptional(entry, key) {
560
763
  import { getContext } from "hono/context-storage";
561
764
  import { getCookie } from "hono/cookie";
562
765
  var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
766
+ var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
563
767
  function normalizeHeaders(input) {
564
768
  const out = {};
565
769
  if (!input) return out;
@@ -568,6 +772,11 @@ function normalizeHeaders(input) {
568
772
  });
569
773
  return out;
570
774
  }
775
+ function extractInputUrl(input) {
776
+ if (typeof input === "string") return input;
777
+ if (input instanceof URL) return input.href;
778
+ return input.url;
779
+ }
571
780
  function createSandboxProxyFetch(connectionId) {
572
781
  return async (input, init) => {
573
782
  const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
@@ -577,10 +786,17 @@ function createSandboxProxyFetch(connectionId) {
577
786
  "Connection proxy is not configured. Please check your deployment settings."
578
787
  );
579
788
  }
580
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
789
+ const originalUrl = extractInputUrl(input);
790
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
791
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
792
+ const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
793
+ return fetch(sessionUrl, {
794
+ method: "POST",
795
+ headers: { Authorization: `Bearer ${token}` }
796
+ });
797
+ }
581
798
  const originalMethod = init?.method ?? "GET";
582
799
  const originalBody = init?.body ? JSON.parse(init.body) : void 0;
583
- const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
584
800
  const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
585
801
  return fetch(proxyUrl, {
586
802
  method: "POST",
@@ -606,10 +822,9 @@ function createDeployedAppProxyFetch(connectionId) {
606
822
  }
607
823
  const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
608
824
  const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
825
+ const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
609
826
  return async (input, init) => {
610
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
611
- const originalMethod = init?.method ?? "GET";
612
- const originalBody = init?.body ? JSON.parse(init.body) : void 0;
827
+ const originalUrl = extractInputUrl(input);
613
828
  const c = getContext();
614
829
  const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
615
830
  if (!appSession) {
@@ -617,6 +832,14 @@ function createDeployedAppProxyFetch(connectionId) {
617
832
  "No authentication method available for connection proxy."
618
833
  );
619
834
  }
835
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
836
+ return fetch(sessionUrl, {
837
+ method: "POST",
838
+ headers: { Authorization: `Bearer ${appSession}` }
839
+ });
840
+ }
841
+ const originalMethod = init?.method ?? "GET";
842
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
620
843
  return fetch(proxyUrl, {
621
844
  method: "POST",
622
845
  headers: {