@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.
- package/dist/cli/index.js +12128 -934
- package/dist/connectors/airtable-oauth.js +248 -46
- package/dist/connectors/airtable.js +285 -51
- package/dist/connectors/amplitude.js +288 -47
- package/dist/connectors/anthropic.js +126 -47
- package/dist/connectors/asana.js +293 -49
- package/dist/connectors/attio.js +268 -49
- package/dist/connectors/aws-billing.js +253 -46
- package/dist/connectors/azure-sql.js +387 -102
- package/dist/connectors/backlog-api-key.js +283 -47
- package/dist/connectors/clickup.js +304 -49
- package/dist/connectors/cosmosdb.js +271 -50
- package/dist/connectors/customerio.js +285 -47
- package/dist/connectors/dbt.js +306 -47
- package/dist/connectors/freshdesk.js +308 -53
- package/dist/connectors/freshsales.js +299 -52
- package/dist/connectors/freshservice.js +327 -53
- package/dist/connectors/gamma.js +293 -52
- package/dist/connectors/gemini.js +125 -47
- package/dist/connectors/github.js +352 -49
- package/dist/connectors/gmail-oauth.js +170 -7
- package/dist/connectors/gmail.js +316 -47
- package/dist/connectors/google-ads.js +254 -46
- package/dist/connectors/google-analytics-oauth.js +276 -46
- package/dist/connectors/google-analytics.js +378 -49
- package/dist/connectors/google-audit-log.js +404 -47
- package/dist/connectors/google-calendar-oauth.js +225 -46
- package/dist/connectors/google-calendar.js +325 -47
- package/dist/connectors/google-docs.js +186 -6
- package/dist/connectors/google-drive.js +228 -5
- package/dist/connectors/google-search-console-oauth.js +222 -46
- package/dist/connectors/google-sheets.js +238 -47
- package/dist/connectors/google-slides.js +171 -6
- package/dist/connectors/grafana.js +298 -49
- package/dist/connectors/hubspot-oauth.js +174 -5
- package/dist/connectors/hubspot.js +272 -49
- package/dist/connectors/influxdb.js +382 -51
- package/dist/connectors/intercom-oauth.js +176 -5
- package/dist/connectors/intercom.js +268 -49
- package/dist/connectors/jdbc.js +728 -110
- package/dist/connectors/jira-api-key.js +292 -47
- package/dist/connectors/kintone-api-token.js +247 -47
- package/dist/connectors/kintone.js +294 -47
- package/dist/connectors/linear.js +296 -49
- package/dist/connectors/linkedin-ads.js +234 -50
- package/dist/connectors/mailchimp-oauth.js +234 -46
- package/dist/connectors/mailchimp.js +286 -49
- package/dist/connectors/meta-ads-oauth.js +239 -48
- package/dist/connectors/meta-ads.js +251 -50
- package/dist/connectors/mixpanel.js +304 -47
- package/dist/connectors/monday.js +326 -49
- package/dist/connectors/mongodb.js +285 -57
- package/dist/connectors/notion-oauth.js +197 -5
- package/dist/connectors/notion.js +289 -51
- package/dist/connectors/openai.js +125 -47
- package/dist/connectors/oracle.js +405 -103
- package/dist/connectors/outlook-oauth.js +170 -5
- package/dist/connectors/powerbi-oauth.js +217 -5
- package/dist/connectors/salesforce.js +350 -49
- package/dist/connectors/semrush.js +280 -49
- package/dist/connectors/sentry.js +255 -50
- package/dist/connectors/shopify-oauth.js +153 -5
- package/dist/connectors/shopify.js +323 -47
- package/dist/connectors/sqlserver.js +381 -102
- package/dist/connectors/stripe-api-key.js +235 -46
- package/dist/connectors/stripe-oauth.js +168 -5
- package/dist/connectors/supabase.js +269 -48
- package/dist/connectors/tableau.js +337 -206
- package/dist/connectors/tiktok-ads.js +245 -48
- package/dist/connectors/wix-store.js +286 -49
- package/dist/connectors/zendesk-oauth.js +205 -5
- package/dist/connectors/zendesk.js +324 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +18297 -6886
- package/dist/main.js +12785 -1382
- package/dist/vite-plugin.js +12140 -936
- 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",
|
|
@@ -209,6 +221,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
209
221
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
210
222
|
*/
|
|
211
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;
|
|
212
238
|
constructor(config) {
|
|
213
239
|
this.slug = config.slug;
|
|
214
240
|
this.authType = config.authType;
|
|
@@ -226,6 +252,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
226
252
|
this.query = config.query;
|
|
227
253
|
this.checkConnection = config.checkConnection;
|
|
228
254
|
this.setup = config.setup;
|
|
255
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
229
256
|
}
|
|
230
257
|
get connectorKey() {
|
|
231
258
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -290,6 +317,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
290
317
|
}
|
|
291
318
|
};
|
|
292
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
|
+
|
|
293
365
|
// ../connectors/src/auth-types.ts
|
|
294
366
|
var AUTH_TYPES = {
|
|
295
367
|
OAUTH: "oauth",
|
|
@@ -312,6 +384,122 @@ var kintoneOnboarding = new ConnectorOnboarding({
|
|
|
312
384
|
}
|
|
313
385
|
});
|
|
314
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
|
+
|
|
315
503
|
// ../connectors/src/connectors/kintone/tools/request.ts
|
|
316
504
|
import { z } from "zod";
|
|
317
505
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -532,7 +720,46 @@ export default async function handler(c: Context) {
|
|
|
532
720
|
- \u5236\u9650: \`limit 100 offset 0\`
|
|
533
721
|
- \u6587\u5B57\u5217: \`like "\u90E8\u5206\u4E00\u81F4"\``
|
|
534
722
|
},
|
|
535
|
-
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
|
+
}
|
|
536
763
|
});
|
|
537
764
|
|
|
538
765
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -561,6 +788,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
561
788
|
import { getContext } from "hono/context-storage";
|
|
562
789
|
import { getCookie } from "hono/cookie";
|
|
563
790
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
791
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
564
792
|
function normalizeHeaders(input) {
|
|
565
793
|
const out = {};
|
|
566
794
|
if (!input) return out;
|
|
@@ -569,6 +797,11 @@ function normalizeHeaders(input) {
|
|
|
569
797
|
});
|
|
570
798
|
return out;
|
|
571
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
|
+
}
|
|
572
805
|
function createSandboxProxyFetch(connectionId) {
|
|
573
806
|
return async (input, init) => {
|
|
574
807
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -578,10 +811,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
578
811
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
579
812
|
);
|
|
580
813
|
}
|
|
581
|
-
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
|
+
}
|
|
582
823
|
const originalMethod = init?.method ?? "GET";
|
|
583
824
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
584
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
585
825
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
586
826
|
return fetch(proxyUrl, {
|
|
587
827
|
method: "POST",
|
|
@@ -607,10 +847,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
607
847
|
}
|
|
608
848
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
609
849
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
850
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
610
851
|
return async (input, init) => {
|
|
611
|
-
const originalUrl =
|
|
612
|
-
const originalMethod = init?.method ?? "GET";
|
|
613
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
852
|
+
const originalUrl = extractInputUrl(input);
|
|
614
853
|
const c = getContext();
|
|
615
854
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
616
855
|
if (!appSession) {
|
|
@@ -618,6 +857,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
618
857
|
"No authentication method available for connection proxy."
|
|
619
858
|
);
|
|
620
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;
|
|
621
868
|
return fetch(proxyUrl, {
|
|
622
869
|
method: "POST",
|
|
623
870
|
headers: {
|