@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/mailchimp/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
apiKey: new ParameterDefinition({
|
|
48
60
|
slug: "api-key",
|
|
@@ -221,6 +233,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
221
233
|
tools;
|
|
222
234
|
query;
|
|
223
235
|
checkConnection;
|
|
236
|
+
/**
|
|
237
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
238
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
239
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
240
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
241
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
242
|
+
*/
|
|
243
|
+
setup;
|
|
244
|
+
/**
|
|
245
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
246
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
247
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
248
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
249
|
+
*
|
|
250
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
251
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
252
|
+
* connectionId, which doesn't exist until the row is saved
|
|
253
|
+
*
|
|
254
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
255
|
+
* the default verify-on-create behavior without opt-in.
|
|
256
|
+
*/
|
|
257
|
+
skipConnectionCheckOnCreate;
|
|
224
258
|
constructor(config) {
|
|
225
259
|
this.slug = config.slug;
|
|
226
260
|
this.authType = config.authType;
|
|
@@ -237,6 +271,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
237
271
|
this.tools = config.tools;
|
|
238
272
|
this.query = config.query;
|
|
239
273
|
this.checkConnection = config.checkConnection;
|
|
274
|
+
this.setup = config.setup;
|
|
275
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
240
276
|
}
|
|
241
277
|
get connectorKey() {
|
|
242
278
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -301,6 +337,76 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
301
337
|
}
|
|
302
338
|
};
|
|
303
339
|
|
|
340
|
+
// ../connectors/src/setup-flow.ts
|
|
341
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
342
|
+
const runtime = {
|
|
343
|
+
params,
|
|
344
|
+
language: ctx.language,
|
|
345
|
+
config
|
|
346
|
+
};
|
|
347
|
+
let state = flow.initialState();
|
|
348
|
+
let answerIdx = 0;
|
|
349
|
+
const pendingParameterUpdates = [];
|
|
350
|
+
for (const step of flow.steps) {
|
|
351
|
+
const ans = ctx.answers[answerIdx];
|
|
352
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
353
|
+
state = step.applyAnswer(state, ans.answer);
|
|
354
|
+
if (step.toParameterUpdates) {
|
|
355
|
+
pendingParameterUpdates.push(...step.toParameterUpdates(state));
|
|
356
|
+
}
|
|
357
|
+
answerIdx += 1;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
361
|
+
if (step.type === "text") {
|
|
362
|
+
if (step.fetchOptions) {
|
|
363
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
364
|
+
if (options2.length === 0) {
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
type: "nextQuestion",
|
|
370
|
+
questionSlug: step.slug,
|
|
371
|
+
question: step.question[ctx.language],
|
|
372
|
+
questionType: "text",
|
|
373
|
+
allowFreeText: resolvedAllowFreeText,
|
|
374
|
+
...pendingParameterUpdates.length > 0 && {
|
|
375
|
+
parameterUpdates: pendingParameterUpdates
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
380
|
+
if (options.length === 0) {
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
type: "nextQuestion",
|
|
385
|
+
questionSlug: step.slug,
|
|
386
|
+
question: step.question[ctx.language],
|
|
387
|
+
questionType: step.type,
|
|
388
|
+
options,
|
|
389
|
+
allowFreeText: resolvedAllowFreeText,
|
|
390
|
+
...pendingParameterUpdates.length > 0 && {
|
|
391
|
+
parameterUpdates: pendingParameterUpdates
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
396
|
+
return {
|
|
397
|
+
type: "fulfilled",
|
|
398
|
+
dataInvestigationResult,
|
|
399
|
+
...pendingParameterUpdates.length > 0 && {
|
|
400
|
+
parameterUpdates: pendingParameterUpdates
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
async function resolveSetupSelection(params) {
|
|
405
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
406
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
407
|
+
return resolved.slice(0, limit);
|
|
408
|
+
}
|
|
409
|
+
|
|
304
410
|
// ../connectors/src/auth-types.ts
|
|
305
411
|
var AUTH_TYPES = {
|
|
306
412
|
OAUTH: "oauth",
|
|
@@ -325,10 +431,115 @@ var mailchimpOnboarding = new ConnectorOnboarding({
|
|
|
325
431
|
}
|
|
326
432
|
});
|
|
327
433
|
|
|
434
|
+
// ../connectors/src/connectors/mailchimp/utils.ts
|
|
435
|
+
function extractDatacenter2(apiKey) {
|
|
436
|
+
const parts = apiKey.split("-");
|
|
437
|
+
const dc = parts[parts.length - 1];
|
|
438
|
+
if (!dc || dc === apiKey) {
|
|
439
|
+
throw new Error(
|
|
440
|
+
"Invalid Mailchimp API key format. Expected format: xxxxxxxxxxxxxxxx-us6"
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
return dc;
|
|
444
|
+
}
|
|
445
|
+
async function apiFetch(params, path2, init) {
|
|
446
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
447
|
+
if (!apiKey) {
|
|
448
|
+
throw new Error("mailchimp: missing required parameter: api-key");
|
|
449
|
+
}
|
|
450
|
+
const dc = extractDatacenter2(apiKey);
|
|
451
|
+
const baseUrl = `https://${dc}.api.mailchimp.com/3.0`;
|
|
452
|
+
const url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
453
|
+
const headers = new Headers(init?.headers);
|
|
454
|
+
headers.set("Authorization", `Basic ${btoa(`anystring:${apiKey}`)}`);
|
|
455
|
+
return fetch(url, { ...init, headers });
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ../connectors/src/connectors/mailchimp/setup-flow.ts
|
|
459
|
+
var ALL_AUDIENCES = "__ALL_AUDIENCES__";
|
|
460
|
+
var MAILCHIMP_SETUP_MAX_AUDIENCES = 10;
|
|
461
|
+
async function defaultListAudiences(params, _fetchFn) {
|
|
462
|
+
const res = await apiFetch(
|
|
463
|
+
params,
|
|
464
|
+
"/lists?count=1000&fields=lists.id,lists.name,lists.stats"
|
|
465
|
+
);
|
|
466
|
+
if (!res.ok) {
|
|
467
|
+
const body = await res.text().catch(() => res.statusText);
|
|
468
|
+
throw new Error(`mailchimp: listAudiences failed (${res.status}): ${body}`);
|
|
469
|
+
}
|
|
470
|
+
const data = await res.json();
|
|
471
|
+
return data.lists ?? [];
|
|
472
|
+
}
|
|
473
|
+
function createMailchimpSetupFlow(listAudiences = defaultListAudiences, labelPrefix = "Mailchimp") {
|
|
474
|
+
return {
|
|
475
|
+
initialState: () => ({}),
|
|
476
|
+
steps: [
|
|
477
|
+
{
|
|
478
|
+
slug: "audiences",
|
|
479
|
+
type: "multiSelect",
|
|
480
|
+
question: {
|
|
481
|
+
ja: "\u5BFE\u8C61\u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
482
|
+
en: "Select target audiences (multi-select allowed)"
|
|
483
|
+
},
|
|
484
|
+
async fetchOptions(_state, rt) {
|
|
485
|
+
const lists = await listAudiences(rt.params, rt.config.proxyFetch);
|
|
486
|
+
const opts = lists.filter((l) => l.id && l.name).map((l) => ({ value: l.id, label: l.name }));
|
|
487
|
+
if (opts.length === 0) return [];
|
|
488
|
+
return [
|
|
489
|
+
{
|
|
490
|
+
value: ALL_AUDIENCES,
|
|
491
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9" : "All audiences"
|
|
492
|
+
},
|
|
493
|
+
...opts
|
|
494
|
+
];
|
|
495
|
+
},
|
|
496
|
+
applyAnswer: (state, answer) => ({ ...state, audiences: answer })
|
|
497
|
+
}
|
|
498
|
+
],
|
|
499
|
+
async finalize(state, rt) {
|
|
500
|
+
if (!state.audiences) {
|
|
501
|
+
throw new Error("Mailchimp setup: incomplete state on finalize");
|
|
502
|
+
}
|
|
503
|
+
const lists = await listAudiences(rt.params, rt.config.proxyFetch);
|
|
504
|
+
const listById = new Map(lists.map((l) => [l.id, l]));
|
|
505
|
+
const targetIds = await resolveSetupSelection({
|
|
506
|
+
selected: state.audiences,
|
|
507
|
+
allSentinel: ALL_AUDIENCES,
|
|
508
|
+
fetchAll: async () => lists.map((l) => l.id).filter((id) => id),
|
|
509
|
+
limit: MAILCHIMP_SETUP_MAX_AUDIENCES
|
|
510
|
+
});
|
|
511
|
+
const sections = [`## ${labelPrefix}`, ""];
|
|
512
|
+
for (const id of targetIds) {
|
|
513
|
+
const list = listById.get(id);
|
|
514
|
+
if (!list) {
|
|
515
|
+
sections.push(`### Audience: ${id}`, "", "_Not found._", "");
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
const stats = list.stats ?? {};
|
|
519
|
+
sections.push(`### Audience: ${list.name}`, "");
|
|
520
|
+
sections.push("| Metric | Value |");
|
|
521
|
+
sections.push("|--------|-------|");
|
|
522
|
+
sections.push(`| Members | ${stats.member_count ?? "-"} |`);
|
|
523
|
+
sections.push(`| Unsubscribed | ${stats.unsubscribe_count ?? "-"} |`);
|
|
524
|
+
sections.push(`| Cleaned | ${stats.cleaned_count ?? "-"} |`);
|
|
525
|
+
sections.push(
|
|
526
|
+
`| Open rate | ${stats.open_rate != null ? stats.open_rate : "-"} |`
|
|
527
|
+
);
|
|
528
|
+
sections.push(
|
|
529
|
+
`| Click rate | ${stats.click_rate != null ? stats.click_rate : "-"} |`
|
|
530
|
+
);
|
|
531
|
+
sections.push("");
|
|
532
|
+
}
|
|
533
|
+
return sections.join("\n");
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
var mailchimpSetupFlow = createMailchimpSetupFlow();
|
|
538
|
+
|
|
328
539
|
// ../connectors/src/connectors/mailchimp/tools/request.ts
|
|
329
540
|
import { z } from "zod";
|
|
330
541
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
331
|
-
function
|
|
542
|
+
function extractDatacenter3(apiKey) {
|
|
332
543
|
const parts = apiKey.split("-");
|
|
333
544
|
const dc = parts[parts.length - 1];
|
|
334
545
|
if (!dc) {
|
|
@@ -384,7 +595,7 @@ The datacenter is automatically extracted from the API key suffix.`,
|
|
|
384
595
|
);
|
|
385
596
|
try {
|
|
386
597
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
387
|
-
const dc =
|
|
598
|
+
const dc = extractDatacenter3(apiKey);
|
|
388
599
|
const baseUrl = `https://${dc}.api.mailchimp.com/3.0`;
|
|
389
600
|
let url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
390
601
|
if (queryParams) {
|
|
@@ -627,7 +838,47 @@ export default async function handler(c: Context) {
|
|
|
627
838
|
- subscriber_hash\u306F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u306E\u5C0F\u6587\u5B57\u306EMD5\u30CF\u30C3\u30B7\u30E5
|
|
628
839
|
- \u30A8\u30E9\u30FC\u306F\`type\`, \`title\`, \`status\`, \`detail\`, \`instance\`\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u8FD4\u5374`
|
|
629
840
|
},
|
|
630
|
-
tools
|
|
841
|
+
tools,
|
|
842
|
+
setup: (params, ctx, config) => runSetupFlow(mailchimpSetupFlow, params, ctx, config),
|
|
843
|
+
async checkConnection(params, _config) {
|
|
844
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
845
|
+
if (!apiKey) {
|
|
846
|
+
return {
|
|
847
|
+
success: false,
|
|
848
|
+
error: "Missing required parameter: api-key"
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
const parts = apiKey.split("-");
|
|
852
|
+
const dc = parts[parts.length - 1];
|
|
853
|
+
if (!dc || dc === apiKey) {
|
|
854
|
+
return {
|
|
855
|
+
success: false,
|
|
856
|
+
error: "Invalid Mailchimp API key format. Expected format: xxxxxxxxxxxxxxxx-us6"
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
try {
|
|
860
|
+
const res = await fetch(`https://${dc}.api.mailchimp.com/3.0/ping`, {
|
|
861
|
+
method: "GET",
|
|
862
|
+
headers: {
|
|
863
|
+
Authorization: `Basic ${btoa(`anystring:${apiKey}`)}`,
|
|
864
|
+
Accept: "application/json"
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
if (!res.ok) {
|
|
868
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
869
|
+
return {
|
|
870
|
+
success: false,
|
|
871
|
+
error: `Mailchimp API failed: HTTP ${res.status} ${errorText}`
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
return { success: true };
|
|
875
|
+
} catch (error) {
|
|
876
|
+
return {
|
|
877
|
+
success: false,
|
|
878
|
+
error: error instanceof Error ? error.message : String(error)
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
}
|
|
631
882
|
});
|
|
632
883
|
|
|
633
884
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -656,6 +907,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
656
907
|
import { getContext } from "hono/context-storage";
|
|
657
908
|
import { getCookie } from "hono/cookie";
|
|
658
909
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
910
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
659
911
|
function normalizeHeaders(input) {
|
|
660
912
|
const out = {};
|
|
661
913
|
if (!input) return out;
|
|
@@ -664,6 +916,11 @@ function normalizeHeaders(input) {
|
|
|
664
916
|
});
|
|
665
917
|
return out;
|
|
666
918
|
}
|
|
919
|
+
function extractInputUrl(input) {
|
|
920
|
+
if (typeof input === "string") return input;
|
|
921
|
+
if (input instanceof URL) return input.href;
|
|
922
|
+
return input.url;
|
|
923
|
+
}
|
|
667
924
|
function createSandboxProxyFetch(connectionId) {
|
|
668
925
|
return async (input, init) => {
|
|
669
926
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -673,10 +930,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
673
930
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
674
931
|
);
|
|
675
932
|
}
|
|
676
|
-
const originalUrl =
|
|
933
|
+
const originalUrl = extractInputUrl(input);
|
|
934
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
935
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
936
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
937
|
+
return fetch(sessionUrl, {
|
|
938
|
+
method: "POST",
|
|
939
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
940
|
+
});
|
|
941
|
+
}
|
|
677
942
|
const originalMethod = init?.method ?? "GET";
|
|
678
943
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
679
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
680
944
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
681
945
|
return fetch(proxyUrl, {
|
|
682
946
|
method: "POST",
|
|
@@ -702,10 +966,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
702
966
|
}
|
|
703
967
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
704
968
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
969
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
705
970
|
return async (input, init) => {
|
|
706
|
-
const originalUrl =
|
|
707
|
-
const originalMethod = init?.method ?? "GET";
|
|
708
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
971
|
+
const originalUrl = extractInputUrl(input);
|
|
709
972
|
const c = getContext();
|
|
710
973
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
711
974
|
if (!appSession) {
|
|
@@ -713,6 +976,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
713
976
|
"No authentication method available for connection proxy."
|
|
714
977
|
);
|
|
715
978
|
}
|
|
979
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
980
|
+
return fetch(sessionUrl, {
|
|
981
|
+
method: "POST",
|
|
982
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
const originalMethod = init?.method ?? "GET";
|
|
986
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
716
987
|
return fetch(proxyUrl, {
|
|
717
988
|
method: "POST",
|
|
718
989
|
headers: {
|