@squadbase/vite-server 0.1.12-dev.a9ac647 → 0.1.17-dev.3b633bb
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 +14375 -1652
- package/dist/connectors/airtable-oauth.js +282 -46
- package/dist/connectors/airtable.js +319 -51
- package/dist/connectors/amplitude.js +322 -47
- package/dist/connectors/anthropic.js +135 -47
- package/dist/connectors/asana.js +327 -49
- package/dist/connectors/attio.js +302 -49
- package/dist/connectors/aws-billing.js +287 -46
- package/dist/connectors/azure-sql.js +421 -102
- package/dist/connectors/backlog-api-key.js +317 -47
- package/dist/connectors/clickup.js +338 -49
- package/dist/connectors/cosmosdb.js +305 -50
- package/dist/connectors/customerio.js +319 -47
- package/dist/connectors/dbt.js +340 -47
- package/dist/connectors/freshdesk.js +342 -53
- package/dist/connectors/freshsales.js +333 -52
- package/dist/connectors/freshservice.js +361 -53
- package/dist/connectors/gamma.js +327 -52
- package/dist/connectors/gemini.js +134 -47
- package/dist/connectors/github.js +386 -49
- package/dist/connectors/gmail-oauth.js +204 -7
- package/dist/connectors/gmail.js +350 -47
- package/dist/connectors/google-ads.js +288 -46
- package/dist/connectors/google-analytics-oauth.js +310 -46
- package/dist/connectors/google-analytics.js +547 -87
- package/dist/connectors/google-audit-log.js +438 -47
- package/dist/connectors/google-calendar-oauth.js +259 -46
- package/dist/connectors/google-calendar.js +359 -47
- package/dist/connectors/google-docs.js +220 -6
- package/dist/connectors/google-drive.js +262 -5
- package/dist/connectors/google-search-console-oauth.js +256 -46
- package/dist/connectors/google-sheets.js +272 -47
- package/dist/connectors/google-slides.js +205 -6
- package/dist/connectors/grafana.js +332 -49
- package/dist/connectors/hubspot-oauth.js +208 -5
- package/dist/connectors/hubspot.js +306 -49
- package/dist/connectors/influxdb.js +416 -51
- package/dist/connectors/intercom-oauth.js +210 -5
- package/dist/connectors/intercom.js +302 -49
- package/dist/connectors/jdbc.js +762 -110
- package/dist/connectors/jira-api-key.js +326 -47
- package/dist/connectors/kintone-api-token.js +281 -47
- package/dist/connectors/kintone.js +328 -47
- package/dist/connectors/linear.js +330 -49
- package/dist/connectors/linkedin-ads.js +268 -50
- package/dist/connectors/mailchimp-oauth.js +268 -46
- package/dist/connectors/mailchimp.js +320 -49
- package/dist/connectors/meta-ads-oauth.js +273 -48
- package/dist/connectors/meta-ads.js +285 -50
- package/dist/connectors/mixpanel.js +338 -47
- package/dist/connectors/monday.js +360 -49
- package/dist/connectors/mongodb.js +319 -57
- package/dist/connectors/notion-oauth.js +231 -5
- package/dist/connectors/notion.js +323 -51
- package/dist/connectors/openai.js +134 -47
- package/dist/connectors/oracle.js +454 -103
- package/dist/connectors/outlook-oauth.js +204 -5
- package/dist/connectors/powerbi-oauth.js +498 -5
- package/dist/connectors/salesforce.js +384 -49
- package/dist/connectors/semrush.js +609 -49
- package/dist/connectors/sentry.js +289 -50
- package/dist/connectors/shopify-oauth.js +187 -5
- package/dist/connectors/shopify.js +357 -47
- package/dist/connectors/sqlserver.js +415 -102
- package/dist/connectors/stripe-api-key.js +269 -46
- package/dist/connectors/stripe-oauth.js +202 -5
- package/dist/connectors/supabase.js +303 -48
- package/dist/connectors/tableau.js +536 -163
- package/dist/connectors/tiktok-ads.js +279 -48
- package/dist/connectors/wix-store.js +320 -49
- package/dist/connectors/zendesk-oauth.js +239 -5
- package/dist/connectors/zendesk.js +358 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +15057 -2117
- package/dist/main.js +15005 -2073
- package/dist/vite-plugin.js +14752 -2019
- 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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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",
|
|
@@ -196,6 +208,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
196
208
|
tools;
|
|
197
209
|
query;
|
|
198
210
|
checkConnection;
|
|
211
|
+
/**
|
|
212
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
213
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
214
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
215
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
216
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
217
|
+
*/
|
|
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;
|
|
199
233
|
constructor(config) {
|
|
200
234
|
this.slug = config.slug;
|
|
201
235
|
this.authType = config.authType;
|
|
@@ -212,6 +246,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
212
246
|
this.tools = config.tools;
|
|
213
247
|
this.query = config.query;
|
|
214
248
|
this.checkConnection = config.checkConnection;
|
|
249
|
+
this.setup = config.setup;
|
|
250
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
215
251
|
}
|
|
216
252
|
get connectorKey() {
|
|
217
253
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -276,6 +312,76 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
276
312
|
}
|
|
277
313
|
};
|
|
278
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
|
+
const pendingParameterUpdates = [];
|
|
325
|
+
for (const step of flow.steps) {
|
|
326
|
+
const ans = ctx.answers[answerIdx];
|
|
327
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
328
|
+
state = step.applyAnswer(state, ans.answer);
|
|
329
|
+
if (step.toParameterUpdates) {
|
|
330
|
+
pendingParameterUpdates.push(...step.toParameterUpdates(state));
|
|
331
|
+
}
|
|
332
|
+
answerIdx += 1;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
336
|
+
if (step.type === "text") {
|
|
337
|
+
if (step.fetchOptions) {
|
|
338
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
339
|
+
if (options2.length === 0) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
type: "nextQuestion",
|
|
345
|
+
questionSlug: step.slug,
|
|
346
|
+
question: step.question[ctx.language],
|
|
347
|
+
questionType: "text",
|
|
348
|
+
allowFreeText: resolvedAllowFreeText,
|
|
349
|
+
...pendingParameterUpdates.length > 0 && {
|
|
350
|
+
parameterUpdates: pendingParameterUpdates
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
355
|
+
if (options.length === 0) {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
type: "nextQuestion",
|
|
360
|
+
questionSlug: step.slug,
|
|
361
|
+
question: step.question[ctx.language],
|
|
362
|
+
questionType: step.type,
|
|
363
|
+
options,
|
|
364
|
+
allowFreeText: resolvedAllowFreeText,
|
|
365
|
+
...pendingParameterUpdates.length > 0 && {
|
|
366
|
+
parameterUpdates: pendingParameterUpdates
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
371
|
+
return {
|
|
372
|
+
type: "fulfilled",
|
|
373
|
+
dataInvestigationResult,
|
|
374
|
+
...pendingParameterUpdates.length > 0 && {
|
|
375
|
+
parameterUpdates: pendingParameterUpdates
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
async function resolveSetupSelection(params) {
|
|
380
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
381
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
382
|
+
return resolved.slice(0, limit);
|
|
383
|
+
}
|
|
384
|
+
|
|
279
385
|
// ../connectors/src/auth-types.ts
|
|
280
386
|
var AUTH_TYPES = {
|
|
281
387
|
OAUTH: "oauth",
|
|
@@ -298,9 +404,105 @@ var hubspotOnboarding = new ConnectorOnboarding({
|
|
|
298
404
|
}
|
|
299
405
|
});
|
|
300
406
|
|
|
407
|
+
// ../connectors/src/connectors/hubspot/utils.ts
|
|
408
|
+
var BASE_URL2 = "https://api.hubapi.com";
|
|
409
|
+
async function apiFetch(params, path2, init) {
|
|
410
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
411
|
+
if (!apiKey) {
|
|
412
|
+
throw new Error("hubspot: missing required parameter: api-key");
|
|
413
|
+
}
|
|
414
|
+
const url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
415
|
+
const headers = new Headers(init?.headers);
|
|
416
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
417
|
+
headers.set("Accept", "application/json");
|
|
418
|
+
return fetch(url, { ...init, headers });
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// ../connectors/src/connectors/hubspot/setup-flow.ts
|
|
422
|
+
var HUBSPOT_SETUP_MAX_OBJECT_TYPES = 10;
|
|
423
|
+
var HUBSPOT_SETUP_MAX_PROPERTIES = 50;
|
|
424
|
+
var HUBSPOT_OBJECT_TYPES = [
|
|
425
|
+
{ value: "contacts", label: "Contacts" },
|
|
426
|
+
{ value: "companies", label: "Companies" },
|
|
427
|
+
{ value: "deals", label: "Deals" },
|
|
428
|
+
{ value: "tickets", label: "Tickets" },
|
|
429
|
+
{ value: "products", label: "Products" },
|
|
430
|
+
{ value: "notes", label: "Notes" },
|
|
431
|
+
{ value: "calls", label: "Calls" },
|
|
432
|
+
{ value: "emails", label: "Emails" },
|
|
433
|
+
{ value: "meetings", label: "Meetings" },
|
|
434
|
+
{ value: "tasks", label: "Tasks" }
|
|
435
|
+
];
|
|
436
|
+
async function listProperties(params, objectType) {
|
|
437
|
+
const res = await apiFetch(params, `/crm/v3/properties/${objectType}`);
|
|
438
|
+
if (!res.ok) {
|
|
439
|
+
const body = await res.text().catch(() => res.statusText);
|
|
440
|
+
throw new Error(
|
|
441
|
+
`hubspot: listProperties(${objectType}) failed (${res.status}): ${body}`
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
const data = await res.json();
|
|
445
|
+
return data.results ?? [];
|
|
446
|
+
}
|
|
447
|
+
var hubspotSetupFlow = {
|
|
448
|
+
initialState: () => ({}),
|
|
449
|
+
steps: [
|
|
450
|
+
{
|
|
451
|
+
slug: "objectTypes",
|
|
452
|
+
type: "multiSelect",
|
|
453
|
+
question: {
|
|
454
|
+
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",
|
|
455
|
+
en: "Select the CRM object types to include in setup (multi-select allowed)"
|
|
456
|
+
},
|
|
457
|
+
async fetchOptions(_state, _rt) {
|
|
458
|
+
return HUBSPOT_OBJECT_TYPES.map((o) => ({
|
|
459
|
+
value: o.value,
|
|
460
|
+
label: o.label
|
|
461
|
+
}));
|
|
462
|
+
},
|
|
463
|
+
applyAnswer: (state, answer) => ({ ...state, objectTypes: answer })
|
|
464
|
+
}
|
|
465
|
+
],
|
|
466
|
+
async finalize(state, rt) {
|
|
467
|
+
if (!state.objectTypes) {
|
|
468
|
+
throw new Error("HubSpot setup: incomplete state on finalize");
|
|
469
|
+
}
|
|
470
|
+
const targetObjectTypes = await resolveSetupSelection({
|
|
471
|
+
selected: state.objectTypes,
|
|
472
|
+
// No "all" sentinel — the list is fixed and small, so explicit selection
|
|
473
|
+
// is the only path. resolveSetupSelection still enforces the cap.
|
|
474
|
+
allSentinel: "__ALL__",
|
|
475
|
+
fetchAll: async () => HUBSPOT_OBJECT_TYPES.map((o) => o.value),
|
|
476
|
+
limit: HUBSPOT_SETUP_MAX_OBJECT_TYPES
|
|
477
|
+
});
|
|
478
|
+
const sections = ["## HubSpot", ""];
|
|
479
|
+
for (const objectType of targetObjectTypes) {
|
|
480
|
+
sections.push(`### Object: ${objectType}`, "");
|
|
481
|
+
const props = await listProperties(rt.params, objectType);
|
|
482
|
+
const limited = props.slice(0, HUBSPOT_SETUP_MAX_PROPERTIES);
|
|
483
|
+
sections.push("| Property | Type | Label |");
|
|
484
|
+
sections.push("|----------|------|-------|");
|
|
485
|
+
for (const p of limited) {
|
|
486
|
+
const name = (p.name ?? "").replace(/\|/g, "\\|");
|
|
487
|
+
const type = (p.type ?? "").replace(/\|/g, "\\|");
|
|
488
|
+
const label = (p.label ?? "").replace(/\|/g, "\\|");
|
|
489
|
+
sections.push(`| ${name} | ${type} | ${label || "-"} |`);
|
|
490
|
+
}
|
|
491
|
+
if (props.length > HUBSPOT_SETUP_MAX_PROPERTIES) {
|
|
492
|
+
sections.push(
|
|
493
|
+
"",
|
|
494
|
+
`_Showing first ${HUBSPOT_SETUP_MAX_PROPERTIES} of ${props.length} properties._`
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
sections.push("");
|
|
498
|
+
}
|
|
499
|
+
return sections.join("\n");
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
301
503
|
// ../connectors/src/connectors/hubspot/tools/request.ts
|
|
302
504
|
import { z } from "zod";
|
|
303
|
-
var
|
|
505
|
+
var BASE_URL3 = "https://api.hubapi.com";
|
|
304
506
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
305
507
|
var inputSchema = z.object({
|
|
306
508
|
toolUseIntent: z.string().optional().describe(
|
|
@@ -347,7 +549,7 @@ Use the search endpoint (POST /crm/v3/objects/{objectType}/search) for complex q
|
|
|
347
549
|
);
|
|
348
550
|
try {
|
|
349
551
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
350
|
-
const url = `${
|
|
552
|
+
const url = `${BASE_URL3}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
351
553
|
const controller = new AbortController();
|
|
352
554
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
353
555
|
try {
|
|
@@ -522,7 +724,42 @@ export default async function handler(c: Context) {
|
|
|
522
724
|
- \`limit\` \u2014 \u30DA\u30FC\u30B8\u3042\u305F\u308A\u306E\u6700\u5927\u7D50\u679C\u6570\uFF08\u6700\u5927100\uFF09
|
|
523
725
|
- \`after\` \u2014 \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u30AA\u30D5\u30BB\u30C3\u30C8`
|
|
524
726
|
},
|
|
525
|
-
tools
|
|
727
|
+
tools,
|
|
728
|
+
setup: (params, ctx, config) => runSetupFlow(hubspotSetupFlow, params, ctx, config),
|
|
729
|
+
async checkConnection(params, _config) {
|
|
730
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
731
|
+
if (!apiKey) {
|
|
732
|
+
return {
|
|
733
|
+
success: false,
|
|
734
|
+
error: `Missing required parameter: ${parameters.apiKey.slug}`
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
try {
|
|
738
|
+
const res = await fetch(
|
|
739
|
+
"https://api.hubapi.com/account-info/v3/details",
|
|
740
|
+
{
|
|
741
|
+
method: "GET",
|
|
742
|
+
headers: {
|
|
743
|
+
Authorization: `Bearer ${apiKey}`,
|
|
744
|
+
Accept: "application/json"
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
);
|
|
748
|
+
if (!res.ok) {
|
|
749
|
+
const errText = await res.text().catch(() => res.statusText);
|
|
750
|
+
return {
|
|
751
|
+
success: false,
|
|
752
|
+
error: `HubSpot API failed: HTTP ${res.status} ${errText}`
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
return { success: true };
|
|
756
|
+
} catch (error) {
|
|
757
|
+
return {
|
|
758
|
+
success: false,
|
|
759
|
+
error: error instanceof Error ? error.message : String(error)
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
}
|
|
526
763
|
});
|
|
527
764
|
|
|
528
765
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -551,6 +788,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
551
788
|
import { getContext } from "hono/context-storage";
|
|
552
789
|
import { getCookie } from "hono/cookie";
|
|
553
790
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
791
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
554
792
|
function normalizeHeaders(input) {
|
|
555
793
|
const out = {};
|
|
556
794
|
if (!input) return out;
|
|
@@ -559,6 +797,11 @@ function normalizeHeaders(input) {
|
|
|
559
797
|
});
|
|
560
798
|
return out;
|
|
561
799
|
}
|
|
800
|
+
function extractInputUrl(input) {
|
|
801
|
+
if (typeof input === "string") return input;
|
|
802
|
+
if (input instanceof URL) return input.href;
|
|
803
|
+
return input.url;
|
|
804
|
+
}
|
|
562
805
|
function createSandboxProxyFetch(connectionId) {
|
|
563
806
|
return async (input, init) => {
|
|
564
807
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -568,10 +811,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
568
811
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
569
812
|
);
|
|
570
813
|
}
|
|
571
|
-
const originalUrl =
|
|
814
|
+
const originalUrl = extractInputUrl(input);
|
|
815
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
816
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
817
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
818
|
+
return fetch(sessionUrl, {
|
|
819
|
+
method: "POST",
|
|
820
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
821
|
+
});
|
|
822
|
+
}
|
|
572
823
|
const originalMethod = init?.method ?? "GET";
|
|
573
824
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
574
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
575
825
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
576
826
|
return fetch(proxyUrl, {
|
|
577
827
|
method: "POST",
|
|
@@ -597,10 +847,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
597
847
|
}
|
|
598
848
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
599
849
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
850
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
600
851
|
return async (input, init) => {
|
|
601
|
-
const originalUrl =
|
|
602
|
-
const originalMethod = init?.method ?? "GET";
|
|
603
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
852
|
+
const originalUrl = extractInputUrl(input);
|
|
604
853
|
const c = getContext();
|
|
605
854
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
606
855
|
if (!appSession) {
|
|
@@ -608,6 +857,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
608
857
|
"No authentication method available for connection proxy."
|
|
609
858
|
);
|
|
610
859
|
}
|
|
860
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
861
|
+
return fetch(sessionUrl, {
|
|
862
|
+
method: "POST",
|
|
863
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
const originalMethod = init?.method ?? "GET";
|
|
867
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
611
868
|
return fetch(proxyUrl, {
|
|
612
869
|
method: "POST",
|
|
613
870
|
headers: {
|