@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
|
@@ -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/kintone/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
baseUrl: new ParameterDefinition({
|
|
48
60
|
slug: "base-url",
|
|
@@ -201,6 +213,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
201
213
|
tools;
|
|
202
214
|
query;
|
|
203
215
|
checkConnection;
|
|
216
|
+
/**
|
|
217
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
218
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
219
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
220
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
221
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
222
|
+
*/
|
|
223
|
+
setup;
|
|
224
|
+
/**
|
|
225
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
226
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
227
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
228
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
229
|
+
*
|
|
230
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
231
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
232
|
+
* connectionId, which doesn't exist until the row is saved
|
|
233
|
+
*
|
|
234
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
235
|
+
* the default verify-on-create behavior without opt-in.
|
|
236
|
+
*/
|
|
237
|
+
skipConnectionCheckOnCreate;
|
|
204
238
|
constructor(config) {
|
|
205
239
|
this.slug = config.slug;
|
|
206
240
|
this.authType = config.authType;
|
|
@@ -217,6 +251,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
217
251
|
this.tools = config.tools;
|
|
218
252
|
this.query = config.query;
|
|
219
253
|
this.checkConnection = config.checkConnection;
|
|
254
|
+
this.setup = config.setup;
|
|
255
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
220
256
|
}
|
|
221
257
|
get connectorKey() {
|
|
222
258
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -281,6 +317,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
281
317
|
}
|
|
282
318
|
};
|
|
283
319
|
|
|
320
|
+
// ../connectors/src/setup-flow.ts
|
|
321
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
322
|
+
const runtime = {
|
|
323
|
+
params,
|
|
324
|
+
language: ctx.language,
|
|
325
|
+
config
|
|
326
|
+
};
|
|
327
|
+
let state = flow.initialState();
|
|
328
|
+
let answerIdx = 0;
|
|
329
|
+
for (const step of flow.steps) {
|
|
330
|
+
const ans = ctx.answers[answerIdx];
|
|
331
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
332
|
+
state = step.applyAnswer(state, ans.answer);
|
|
333
|
+
answerIdx += 1;
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (step.type === "text") {
|
|
337
|
+
return {
|
|
338
|
+
type: "nextQuestion",
|
|
339
|
+
questionSlug: step.slug,
|
|
340
|
+
question: step.question[ctx.language],
|
|
341
|
+
questionType: "text"
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
345
|
+
if (options.length === 0) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
type: "nextQuestion",
|
|
350
|
+
questionSlug: step.slug,
|
|
351
|
+
question: step.question[ctx.language],
|
|
352
|
+
questionType: step.type,
|
|
353
|
+
options
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
357
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
358
|
+
}
|
|
359
|
+
async function resolveSetupSelection(params) {
|
|
360
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
361
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
362
|
+
return resolved.slice(0, limit);
|
|
363
|
+
}
|
|
364
|
+
|
|
284
365
|
// ../connectors/src/auth-types.ts
|
|
285
366
|
var AUTH_TYPES = {
|
|
286
367
|
OAUTH: "oauth",
|
|
@@ -303,6 +384,122 @@ var kintoneOnboarding = new ConnectorOnboarding({
|
|
|
303
384
|
}
|
|
304
385
|
});
|
|
305
386
|
|
|
387
|
+
// ../connectors/src/connectors/kintone/utils.ts
|
|
388
|
+
async function apiFetch(params, path2, init) {
|
|
389
|
+
const baseUrl = params[parameters.baseUrl.slug];
|
|
390
|
+
const username = params[parameters.username.slug];
|
|
391
|
+
const password = params[parameters.password.slug];
|
|
392
|
+
if (!baseUrl || !username || !password) {
|
|
393
|
+
throw new Error(
|
|
394
|
+
"kintone: missing required parameter(s): base-url, username, password"
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
const authToken = Buffer.from(`${username}:${password}`).toString("base64");
|
|
398
|
+
const normalizedPath = path2.replace(/^\/+/, "");
|
|
399
|
+
const url = `${baseUrl.replace(/\/+$/, "")}/k/v1/${normalizedPath}`;
|
|
400
|
+
const headers = new Headers(init?.headers);
|
|
401
|
+
headers.set("X-Cybozu-Authorization", authToken);
|
|
402
|
+
if (init?.body && !headers.has("Content-Type")) {
|
|
403
|
+
headers.set("Content-Type", "application/json");
|
|
404
|
+
}
|
|
405
|
+
return fetch(url, { ...init, headers });
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ../connectors/src/connectors/kintone/setup-flow.ts
|
|
409
|
+
var ALL_APPS = "__ALL_APPS__";
|
|
410
|
+
var KINTONE_SETUP_MAX_APPS = 20;
|
|
411
|
+
async function listApps(params) {
|
|
412
|
+
const results = [];
|
|
413
|
+
let offset = 0;
|
|
414
|
+
for (let i = 0; i < 20; i++) {
|
|
415
|
+
const res = await apiFetch(
|
|
416
|
+
params,
|
|
417
|
+
`apps.json?limit=100&offset=${offset}`
|
|
418
|
+
);
|
|
419
|
+
if (!res.ok) {
|
|
420
|
+
const text = await res.text().catch(() => res.statusText);
|
|
421
|
+
throw new Error(`kintone: listApps failed (${res.status}): ${text}`);
|
|
422
|
+
}
|
|
423
|
+
const data = await res.json();
|
|
424
|
+
const apps = data.apps ?? [];
|
|
425
|
+
for (const a of apps) results.push(a);
|
|
426
|
+
if (apps.length < 100) break;
|
|
427
|
+
offset += apps.length;
|
|
428
|
+
}
|
|
429
|
+
return results;
|
|
430
|
+
}
|
|
431
|
+
async function getFormFields(params, appId) {
|
|
432
|
+
const res = await apiFetch(
|
|
433
|
+
params,
|
|
434
|
+
`app/form/fields.json?app=${encodeURIComponent(appId)}`
|
|
435
|
+
);
|
|
436
|
+
if (!res.ok) {
|
|
437
|
+
const text = await res.text().catch(() => res.statusText);
|
|
438
|
+
throw new Error(
|
|
439
|
+
`kintone: getFormFields ${appId} failed (${res.status}): ${text}`
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
return await res.json();
|
|
443
|
+
}
|
|
444
|
+
var kintoneSetupFlow = {
|
|
445
|
+
initialState: () => ({}),
|
|
446
|
+
steps: [
|
|
447
|
+
{
|
|
448
|
+
slug: "apps",
|
|
449
|
+
type: "multiSelect",
|
|
450
|
+
question: {
|
|
451
|
+
ja: "\u5BFE\u8C61\u306Ekintone\u30A2\u30D7\u30EA\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
452
|
+
en: "Select target kintone apps (multi-select allowed)"
|
|
453
|
+
},
|
|
454
|
+
async fetchOptions(_state, rt) {
|
|
455
|
+
const apps = await listApps(rt.params);
|
|
456
|
+
const appOptions = apps.filter((a) => a.appId && a.name).map((a) => ({ value: String(a.appId), label: a.name }));
|
|
457
|
+
return [
|
|
458
|
+
{
|
|
459
|
+
value: ALL_APPS,
|
|
460
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30A2\u30D7\u30EA" : "All apps"
|
|
461
|
+
},
|
|
462
|
+
...appOptions
|
|
463
|
+
];
|
|
464
|
+
},
|
|
465
|
+
applyAnswer: (state, answer) => ({ ...state, apps: answer })
|
|
466
|
+
}
|
|
467
|
+
],
|
|
468
|
+
async finalize(state, rt) {
|
|
469
|
+
if (!state.apps) {
|
|
470
|
+
throw new Error("kintone setup: incomplete state on finalize");
|
|
471
|
+
}
|
|
472
|
+
const allApps = await listApps(rt.params);
|
|
473
|
+
const appById = new Map(allApps.map((a) => [String(a.appId), a]));
|
|
474
|
+
const targetIds = await resolveSetupSelection({
|
|
475
|
+
selected: state.apps,
|
|
476
|
+
allSentinel: ALL_APPS,
|
|
477
|
+
fetchAll: async () => allApps.map((a) => String(a.appId)).filter((id) => id),
|
|
478
|
+
limit: KINTONE_SETUP_MAX_APPS
|
|
479
|
+
});
|
|
480
|
+
const sections = ["## kintone", ""];
|
|
481
|
+
for (const appId of targetIds) {
|
|
482
|
+
const app = appById.get(appId);
|
|
483
|
+
const heading = app ? `${app.name} (id: ${appId})` : `id: ${appId}`;
|
|
484
|
+
sections.push(`### App: ${heading}`, "");
|
|
485
|
+
if (app?.description) {
|
|
486
|
+
sections.push(app.description, "");
|
|
487
|
+
}
|
|
488
|
+
const fields = await getFormFields(rt.params, appId);
|
|
489
|
+
sections.push("| Field code | Label | Type | Required |");
|
|
490
|
+
sections.push("|------------|-------|------|----------|");
|
|
491
|
+
for (const [code, def] of Object.entries(fields.properties ?? {})) {
|
|
492
|
+
const escapedLabel = (def.label ?? "").replace(/\|/g, "\\|");
|
|
493
|
+
sections.push(
|
|
494
|
+
`| ${code} | ${escapedLabel || "-"} | ${def.type} | ${def.required ? "yes" : "no"} |`
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
sections.push("");
|
|
498
|
+
}
|
|
499
|
+
return sections.join("\n");
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
306
503
|
// ../connectors/src/connectors/kintone/tools/request.ts
|
|
307
504
|
import { z } from "zod";
|
|
308
505
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -523,7 +720,46 @@ export default async function handler(c: Context) {
|
|
|
523
720
|
- \u5236\u9650: \`limit 100 offset 0\`
|
|
524
721
|
- \u6587\u5B57\u5217: \`like "\u90E8\u5206\u4E00\u81F4"\``
|
|
525
722
|
},
|
|
526
|
-
tools
|
|
723
|
+
tools,
|
|
724
|
+
setup: (params, ctx, config) => runSetupFlow(kintoneSetupFlow, params, ctx, config),
|
|
725
|
+
async checkConnection(params, _config) {
|
|
726
|
+
const baseUrl = params[parameters.baseUrl.slug];
|
|
727
|
+
const username = params[parameters.username.slug];
|
|
728
|
+
const password = params[parameters.password.slug];
|
|
729
|
+
if (!baseUrl || !username || !password) {
|
|
730
|
+
return {
|
|
731
|
+
success: false,
|
|
732
|
+
error: `Missing required parameters: ${parameters.baseUrl.slug}, ${parameters.username.slug}, and ${parameters.password.slug}`
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
try {
|
|
736
|
+
const authToken = Buffer.from(`${username}:${password}`).toString(
|
|
737
|
+
"base64"
|
|
738
|
+
);
|
|
739
|
+
const url = `${baseUrl.replace(/\/+$/, "")}/k/v1/apps.json`;
|
|
740
|
+
const res = await fetch(url, {
|
|
741
|
+
method: "GET",
|
|
742
|
+
headers: {
|
|
743
|
+
"X-Cybozu-Authorization": authToken,
|
|
744
|
+
Accept: "application/json"
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
if (!res.ok) {
|
|
748
|
+
const data = await res.json().catch(() => null);
|
|
749
|
+
const message = data?.message ?? `HTTP ${res.status} ${res.statusText}`;
|
|
750
|
+
return {
|
|
751
|
+
success: false,
|
|
752
|
+
error: `kintone API failed: ${message}`
|
|
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
|
+
}
|
|
527
763
|
});
|
|
528
764
|
|
|
529
765
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -552,6 +788,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
552
788
|
import { getContext } from "hono/context-storage";
|
|
553
789
|
import { getCookie } from "hono/cookie";
|
|
554
790
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
791
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
555
792
|
function normalizeHeaders(input) {
|
|
556
793
|
const out = {};
|
|
557
794
|
if (!input) return out;
|
|
@@ -560,6 +797,11 @@ function normalizeHeaders(input) {
|
|
|
560
797
|
});
|
|
561
798
|
return out;
|
|
562
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
|
+
}
|
|
563
805
|
function createSandboxProxyFetch(connectionId) {
|
|
564
806
|
return async (input, init) => {
|
|
565
807
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -569,10 +811,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
569
811
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
570
812
|
);
|
|
571
813
|
}
|
|
572
|
-
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
|
+
}
|
|
573
823
|
const originalMethod = init?.method ?? "GET";
|
|
574
824
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
575
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
576
825
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
577
826
|
return fetch(proxyUrl, {
|
|
578
827
|
method: "POST",
|
|
@@ -598,10 +847,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
598
847
|
}
|
|
599
848
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
600
849
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
850
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
601
851
|
return async (input, init) => {
|
|
602
|
-
const originalUrl =
|
|
603
|
-
const originalMethod = init?.method ?? "GET";
|
|
604
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
852
|
+
const originalUrl = extractInputUrl(input);
|
|
605
853
|
const c = getContext();
|
|
606
854
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
607
855
|
if (!appSession) {
|
|
@@ -609,6 +857,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
609
857
|
"No authentication method available for connection proxy."
|
|
610
858
|
);
|
|
611
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;
|
|
612
868
|
return fetch(proxyUrl, {
|
|
613
869
|
method: "POST",
|
|
614
870
|
headers: {
|