@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.
- package/dist/cli/index.js +12374 -883
- package/dist/connectors/airtable-oauth.js +257 -46
- package/dist/connectors/airtable.js +294 -51
- package/dist/connectors/amplitude.js +297 -47
- package/dist/connectors/anthropic.js +135 -47
- package/dist/connectors/asana.js +302 -49
- package/dist/connectors/attio.js +277 -49
- package/dist/connectors/aws-billing.js +262 -46
- package/dist/connectors/azure-sql.js +396 -102
- package/dist/connectors/backlog-api-key.js +292 -47
- package/dist/connectors/clickup.js +313 -49
- package/dist/connectors/cosmosdb.js +280 -50
- package/dist/connectors/customerio.js +294 -47
- package/dist/connectors/dbt.js +315 -47
- package/dist/connectors/freshdesk.js +317 -53
- package/dist/connectors/freshsales.js +308 -52
- package/dist/connectors/freshservice.js +336 -53
- package/dist/connectors/gamma.js +302 -52
- package/dist/connectors/gemini.js +134 -47
- package/dist/connectors/github.js +361 -49
- package/dist/connectors/gmail-oauth.js +179 -7
- package/dist/connectors/gmail.js +325 -47
- package/dist/connectors/google-ads.js +263 -46
- package/dist/connectors/google-analytics-oauth.js +285 -46
- package/dist/connectors/google-analytics.js +387 -49
- package/dist/connectors/google-audit-log.js +413 -47
- package/dist/connectors/google-calendar-oauth.js +234 -46
- package/dist/connectors/google-calendar.js +334 -47
- package/dist/connectors/google-docs.js +195 -6
- package/dist/connectors/google-drive.js +237 -5
- package/dist/connectors/google-search-console-oauth.js +231 -46
- package/dist/connectors/google-sheets.js +247 -47
- package/dist/connectors/google-slides.js +180 -6
- package/dist/connectors/grafana.js +307 -49
- package/dist/connectors/hubspot-oauth.js +183 -5
- package/dist/connectors/hubspot.js +281 -49
- package/dist/connectors/influxdb.js +391 -51
- package/dist/connectors/intercom-oauth.js +185 -5
- package/dist/connectors/intercom.js +277 -49
- package/dist/connectors/jdbc.js +737 -110
- package/dist/connectors/jira-api-key.js +301 -47
- package/dist/connectors/kintone-api-token.js +256 -47
- package/dist/connectors/kintone.js +303 -47
- package/dist/connectors/linear.js +305 -49
- package/dist/connectors/linkedin-ads.js +243 -50
- package/dist/connectors/mailchimp-oauth.js +243 -46
- package/dist/connectors/mailchimp.js +295 -49
- package/dist/connectors/meta-ads-oauth.js +248 -48
- package/dist/connectors/meta-ads.js +260 -50
- package/dist/connectors/mixpanel.js +313 -47
- package/dist/connectors/monday.js +335 -49
- package/dist/connectors/mongodb.js +294 -57
- package/dist/connectors/notion-oauth.js +206 -5
- package/dist/connectors/notion.js +298 -51
- package/dist/connectors/openai.js +134 -47
- package/dist/connectors/oracle.js +414 -103
- package/dist/connectors/outlook-oauth.js +179 -5
- package/dist/connectors/powerbi-oauth.js +226 -5
- package/dist/connectors/salesforce.js +359 -49
- package/dist/connectors/semrush.js +289 -49
- package/dist/connectors/sentry.js +264 -50
- package/dist/connectors/shopify-oauth.js +162 -5
- package/dist/connectors/shopify.js +332 -47
- package/dist/connectors/sqlserver.js +390 -102
- package/dist/connectors/stripe-api-key.js +244 -46
- package/dist/connectors/stripe-oauth.js +177 -5
- package/dist/connectors/supabase.js +278 -48
- package/dist/connectors/tableau.js +389 -184
- package/dist/connectors/tiktok-ads.js +254 -48
- package/dist/connectors/wix-store.js +295 -49
- package/dist/connectors/zendesk-oauth.js +214 -5
- package/dist/connectors/zendesk.js +333 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +13677 -1969
- package/dist/main.js +13627 -1927
- package/dist/vite-plugin.js +12391 -890
- package/package.json +1 -1
|
@@ -71,6 +71,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
71
71
|
tools;
|
|
72
72
|
query;
|
|
73
73
|
checkConnection;
|
|
74
|
+
/**
|
|
75
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
76
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
77
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
78
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
79
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
80
|
+
*/
|
|
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;
|
|
74
96
|
constructor(config) {
|
|
75
97
|
this.slug = config.slug;
|
|
76
98
|
this.authType = config.authType;
|
|
@@ -87,6 +109,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
87
109
|
this.tools = config.tools;
|
|
88
110
|
this.query = config.query;
|
|
89
111
|
this.checkConnection = config.checkConnection;
|
|
112
|
+
this.setup = config.setup;
|
|
113
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
90
114
|
}
|
|
91
115
|
get connectorKey() {
|
|
92
116
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -151,6 +175,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
151
175
|
}
|
|
152
176
|
};
|
|
153
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
|
+
|
|
154
223
|
// ../connectors/src/auth-types.ts
|
|
155
224
|
var AUTH_TYPES = {
|
|
156
225
|
OAUTH: "oauth",
|
|
@@ -315,11 +384,122 @@ var notionOauthOnboarding = new ConnectorOnboarding({
|
|
|
315
384
|
// ../connectors/src/connectors/notion-oauth/parameters.ts
|
|
316
385
|
var parameters = {};
|
|
317
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
|
+
|
|
318
497
|
// ../connectors/src/connectors/notion-oauth/index.ts
|
|
319
498
|
var tools = { request: requestTool };
|
|
320
499
|
var notionOauthConnector = new ConnectorPlugin({
|
|
321
500
|
slug: "notion",
|
|
322
501
|
authType: AUTH_TYPES.OAUTH,
|
|
502
|
+
skipConnectionCheckOnCreate: true,
|
|
323
503
|
name: "Notion",
|
|
324
504
|
description: "Connect to Notion to query databases, pages, and workspace content using OAuth.",
|
|
325
505
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/797V5GDDTA8bsfKUHBCoQO/290ec49b70b68ddb4acd3bf0a6ab8bda/notion-icon.webp",
|
|
@@ -438,6 +618,7 @@ const data = await res.json();
|
|
|
438
618
|
\`\`\``
|
|
439
619
|
},
|
|
440
620
|
tools,
|
|
621
|
+
setup: (params, ctx, config) => runSetupFlow(notionOauthSetupFlow, params, ctx, config),
|
|
441
622
|
async checkConnection(_params, config) {
|
|
442
623
|
const { proxyFetch } = config;
|
|
443
624
|
try {
|
|
@@ -488,6 +669,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
488
669
|
import { getContext } from "hono/context-storage";
|
|
489
670
|
import { getCookie } from "hono/cookie";
|
|
490
671
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
672
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
491
673
|
function normalizeHeaders(input) {
|
|
492
674
|
const out = {};
|
|
493
675
|
if (!input) return out;
|
|
@@ -496,6 +678,11 @@ function normalizeHeaders(input) {
|
|
|
496
678
|
});
|
|
497
679
|
return out;
|
|
498
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
|
+
}
|
|
499
686
|
function createSandboxProxyFetch(connectionId) {
|
|
500
687
|
return async (input, init) => {
|
|
501
688
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -505,10 +692,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
505
692
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
506
693
|
);
|
|
507
694
|
}
|
|
508
|
-
const originalUrl =
|
|
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
|
+
}
|
|
509
704
|
const originalMethod = init?.method ?? "GET";
|
|
510
705
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
511
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
512
706
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
513
707
|
return fetch(proxyUrl, {
|
|
514
708
|
method: "POST",
|
|
@@ -534,10 +728,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
534
728
|
}
|
|
535
729
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
536
730
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
731
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
537
732
|
return async (input, init) => {
|
|
538
|
-
const originalUrl =
|
|
539
|
-
const originalMethod = init?.method ?? "GET";
|
|
540
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
733
|
+
const originalUrl = extractInputUrl(input);
|
|
541
734
|
const c = getContext();
|
|
542
735
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
543
736
|
if (!appSession) {
|
|
@@ -545,6 +738,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
545
738
|
"No authentication method available for connection proxy."
|
|
546
739
|
);
|
|
547
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;
|
|
548
749
|
return fetch(proxyUrl, {
|
|
549
750
|
method: "POST",
|
|
550
751
|
headers: {
|