@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/customerio/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
appApiKey: new ParameterDefinition({
|
|
48
60
|
slug: "app-api-key",
|
|
@@ -234,6 +246,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
234
246
|
tools;
|
|
235
247
|
query;
|
|
236
248
|
checkConnection;
|
|
249
|
+
/**
|
|
250
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
251
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
252
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
253
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
254
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
255
|
+
*/
|
|
256
|
+
setup;
|
|
257
|
+
/**
|
|
258
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
259
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
260
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
261
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
262
|
+
*
|
|
263
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
264
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
265
|
+
* connectionId, which doesn't exist until the row is saved
|
|
266
|
+
*
|
|
267
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
268
|
+
* the default verify-on-create behavior without opt-in.
|
|
269
|
+
*/
|
|
270
|
+
skipConnectionCheckOnCreate;
|
|
237
271
|
constructor(config) {
|
|
238
272
|
this.slug = config.slug;
|
|
239
273
|
this.authType = config.authType;
|
|
@@ -250,6 +284,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
250
284
|
this.tools = config.tools;
|
|
251
285
|
this.query = config.query;
|
|
252
286
|
this.checkConnection = config.checkConnection;
|
|
287
|
+
this.setup = config.setup;
|
|
288
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
253
289
|
}
|
|
254
290
|
get connectorKey() {
|
|
255
291
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -314,6 +350,71 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
314
350
|
}
|
|
315
351
|
};
|
|
316
352
|
|
|
353
|
+
// ../connectors/src/setup-flow.ts
|
|
354
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
355
|
+
const runtime = {
|
|
356
|
+
params,
|
|
357
|
+
language: ctx.language,
|
|
358
|
+
config
|
|
359
|
+
};
|
|
360
|
+
let state = flow.initialState();
|
|
361
|
+
let answerIdx = 0;
|
|
362
|
+
const pendingParameterUpdates = [];
|
|
363
|
+
for (const step of flow.steps) {
|
|
364
|
+
const ans = ctx.answers[answerIdx];
|
|
365
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
366
|
+
state = step.applyAnswer(state, ans.answer);
|
|
367
|
+
if (step.toParameterUpdates) {
|
|
368
|
+
pendingParameterUpdates.push(...step.toParameterUpdates(state));
|
|
369
|
+
}
|
|
370
|
+
answerIdx += 1;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
374
|
+
if (step.type === "text") {
|
|
375
|
+
if (step.fetchOptions) {
|
|
376
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
377
|
+
if (options2.length === 0) {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
type: "nextQuestion",
|
|
383
|
+
questionSlug: step.slug,
|
|
384
|
+
question: step.question[ctx.language],
|
|
385
|
+
questionType: "text",
|
|
386
|
+
allowFreeText: resolvedAllowFreeText,
|
|
387
|
+
...pendingParameterUpdates.length > 0 && {
|
|
388
|
+
parameterUpdates: pendingParameterUpdates
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
393
|
+
if (options.length === 0) {
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
type: "nextQuestion",
|
|
398
|
+
questionSlug: step.slug,
|
|
399
|
+
question: step.question[ctx.language],
|
|
400
|
+
questionType: step.type,
|
|
401
|
+
options,
|
|
402
|
+
allowFreeText: resolvedAllowFreeText,
|
|
403
|
+
...pendingParameterUpdates.length > 0 && {
|
|
404
|
+
parameterUpdates: pendingParameterUpdates
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
409
|
+
return {
|
|
410
|
+
type: "fulfilled",
|
|
411
|
+
dataInvestigationResult,
|
|
412
|
+
...pendingParameterUpdates.length > 0 && {
|
|
413
|
+
parameterUpdates: pendingParameterUpdates
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
317
418
|
// ../connectors/src/auth-types.ts
|
|
318
419
|
var AUTH_TYPES = {
|
|
319
420
|
OAUTH: "oauth",
|
|
@@ -338,6 +439,123 @@ var customerioOnboarding = new ConnectorOnboarding({
|
|
|
338
439
|
}
|
|
339
440
|
});
|
|
340
441
|
|
|
442
|
+
// ../connectors/src/connectors/customerio/utils.ts
|
|
443
|
+
async function apiFetch(params, path2, init) {
|
|
444
|
+
const apiKey = params[parameters.appApiKey.slug];
|
|
445
|
+
if (!apiKey) {
|
|
446
|
+
throw new Error("customerio: missing required parameter: app-api-key");
|
|
447
|
+
}
|
|
448
|
+
const region = params[parameters.region.slug];
|
|
449
|
+
const baseUrl = region === "eu" ? "https://api-eu.customer.io" : "https://api.customer.io";
|
|
450
|
+
const url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
451
|
+
const headers = new Headers(init?.headers);
|
|
452
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
453
|
+
return fetch(url, { ...init, headers });
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// ../connectors/src/connectors/customerio/setup-flow.ts
|
|
457
|
+
var CUSTOMERIO_SETUP_MAX_ENTITIES = 10;
|
|
458
|
+
var ENTITY_LABELS = {
|
|
459
|
+
customers: { en: "Customers", ja: "Customers (\u9867\u5BA2)" },
|
|
460
|
+
events: { en: "Events", ja: "Events (\u30A4\u30D9\u30F3\u30C8)" },
|
|
461
|
+
segments: { en: "Segments", ja: "Segments (\u30BB\u30B0\u30E1\u30F3\u30C8)" },
|
|
462
|
+
campaigns: { en: "Campaigns", ja: "Campaigns (\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3)" },
|
|
463
|
+
newsletters: { en: "Newsletters", ja: "Newsletters (\u30CB\u30E5\u30FC\u30B9\u30EC\u30BF\u30FC)" },
|
|
464
|
+
messages: { en: "Messages", ja: "Messages (\u30E1\u30C3\u30BB\u30FC\u30B8)" }
|
|
465
|
+
};
|
|
466
|
+
var ENTITY_DESCRIPTIONS = {
|
|
467
|
+
customers: {
|
|
468
|
+
en: "People profiles and their attributes.",
|
|
469
|
+
ja: "\u4EBA\u7269\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u3068\u305D\u306E\u5C5E\u6027\u3002"
|
|
470
|
+
},
|
|
471
|
+
events: {
|
|
472
|
+
en: "Behavioral events emitted by your app.",
|
|
473
|
+
ja: "\u30A2\u30D7\u30EA\u304B\u3089\u9001\u4FE1\u3055\u308C\u308B\u884C\u52D5\u30A4\u30D9\u30F3\u30C8\u3002"
|
|
474
|
+
},
|
|
475
|
+
segments: {
|
|
476
|
+
en: "Manual and data-driven segment definitions.",
|
|
477
|
+
ja: "\u624B\u52D5\u30FB\u30C7\u30FC\u30BF\u30C9\u30EA\u30D6\u30F3\u306E\u4E21\u65B9\u306E\u30BB\u30B0\u30E1\u30F3\u30C8\u5B9A\u7FA9\u3002"
|
|
478
|
+
},
|
|
479
|
+
campaigns: {
|
|
480
|
+
en: "Triggered and one-off campaign configurations.",
|
|
481
|
+
ja: "\u30C8\u30EA\u30AC\u30FC\u578B\u304A\u3088\u3073\u5358\u767A\u306E\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u8A2D\u5B9A\u3002"
|
|
482
|
+
},
|
|
483
|
+
newsletters: {
|
|
484
|
+
en: "Broadcast newsletter sends.",
|
|
485
|
+
ja: "\u4E00\u6589\u914D\u4FE1\u306E\u30CB\u30E5\u30FC\u30B9\u30EC\u30BF\u30FC\u3002"
|
|
486
|
+
},
|
|
487
|
+
messages: {
|
|
488
|
+
en: "Individual message delivery records.",
|
|
489
|
+
ja: "\u500B\u5225\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u914D\u4FE1\u30EC\u30B3\u30FC\u30C9\u3002"
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
var ENTITY_VALUES = [
|
|
493
|
+
"customers",
|
|
494
|
+
"events",
|
|
495
|
+
"segments",
|
|
496
|
+
"campaigns",
|
|
497
|
+
"newsletters",
|
|
498
|
+
"messages"
|
|
499
|
+
];
|
|
500
|
+
async function fetchEntityCount(params, entity) {
|
|
501
|
+
const endpoint = {
|
|
502
|
+
customers: "/v1/customers/count",
|
|
503
|
+
segments: "/v1/segments",
|
|
504
|
+
campaigns: "/v1/campaigns",
|
|
505
|
+
newsletters: "/v1/newsletters"
|
|
506
|
+
};
|
|
507
|
+
const path2 = endpoint[entity];
|
|
508
|
+
if (!path2) return "available";
|
|
509
|
+
try {
|
|
510
|
+
const res = await apiFetch(params, path2);
|
|
511
|
+
if (!res.ok) return "available";
|
|
512
|
+
const data = await res.json();
|
|
513
|
+
if (typeof data.count === "number") return String(data.count);
|
|
514
|
+
if (Array.isArray(data.segments)) return String(data.segments.length);
|
|
515
|
+
if (Array.isArray(data.campaigns)) return String(data.campaigns.length);
|
|
516
|
+
if (Array.isArray(data.newsletters)) return String(data.newsletters.length);
|
|
517
|
+
return "available";
|
|
518
|
+
} catch {
|
|
519
|
+
return "available";
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
var customerioSetupFlow = {
|
|
523
|
+
initialState: () => ({}),
|
|
524
|
+
steps: [
|
|
525
|
+
{
|
|
526
|
+
slug: "entities",
|
|
527
|
+
type: "multiSelect",
|
|
528
|
+
question: {
|
|
529
|
+
ja: "\u5BFE\u8C61\u306E\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
530
|
+
en: "Select target entities (multi-select allowed)"
|
|
531
|
+
},
|
|
532
|
+
async fetchOptions(_state, rt) {
|
|
533
|
+
return ENTITY_VALUES.map((value) => ({
|
|
534
|
+
value,
|
|
535
|
+
label: ENTITY_LABELS[value][rt.language]
|
|
536
|
+
}));
|
|
537
|
+
},
|
|
538
|
+
applyAnswer: (state, answer) => ({ ...state, entities: answer })
|
|
539
|
+
}
|
|
540
|
+
],
|
|
541
|
+
async finalize(state, rt) {
|
|
542
|
+
if (!state.entities) {
|
|
543
|
+
throw new Error("Customer.io setup: incomplete state on finalize");
|
|
544
|
+
}
|
|
545
|
+
const selected = state.entities.filter(
|
|
546
|
+
(e) => ENTITY_VALUES.includes(e)
|
|
547
|
+
).slice(0, CUSTOMERIO_SETUP_MAX_ENTITIES);
|
|
548
|
+
const sections = ["## Customer.io", ""];
|
|
549
|
+
for (const entity of selected) {
|
|
550
|
+
const count = await fetchEntityCount(rt.params, entity);
|
|
551
|
+
sections.push(`### ${ENTITY_LABELS[entity].en}`, "");
|
|
552
|
+
sections.push(ENTITY_DESCRIPTIONS[entity][rt.language], "");
|
|
553
|
+
sections.push(`Count: ${count}`, "");
|
|
554
|
+
}
|
|
555
|
+
return sections.join("\n");
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
|
|
341
559
|
// ../connectors/src/connectors/customerio/tools/request.ts
|
|
342
560
|
import { z } from "zod";
|
|
343
561
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -614,7 +832,41 @@ export default async function handler(c: Context) {
|
|
|
614
832
|
- \u5927\u91CF\u30C7\u30FC\u30BF\u53D6\u5F97\u306B\u306Fexports\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u3092\u4F7F\u7528
|
|
615
833
|
- \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u306F\u9867\u5BA2\u4E00\u89A7\u3067\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\`start\`\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4F7F\u7528`
|
|
616
834
|
},
|
|
617
|
-
tools
|
|
835
|
+
tools,
|
|
836
|
+
setup: (params, ctx, config) => runSetupFlow(customerioSetupFlow, params, ctx, config),
|
|
837
|
+
async checkConnection(params, _config) {
|
|
838
|
+
const appApiKey = params[parameters.appApiKey.slug];
|
|
839
|
+
if (!appApiKey) {
|
|
840
|
+
return {
|
|
841
|
+
success: false,
|
|
842
|
+
error: "Missing required parameter: app-api-key"
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
const region = params[parameters.region.slug];
|
|
846
|
+
const baseUrl = region === "eu" ? "https://api-eu.customer.io" : "https://api.customer.io";
|
|
847
|
+
try {
|
|
848
|
+
const res = await fetch(`${baseUrl}/v1/segments`, {
|
|
849
|
+
method: "GET",
|
|
850
|
+
headers: {
|
|
851
|
+
Authorization: `Bearer ${appApiKey}`,
|
|
852
|
+
Accept: "application/json"
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
if (!res.ok) {
|
|
856
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
857
|
+
return {
|
|
858
|
+
success: false,
|
|
859
|
+
error: `Customer.io API failed: HTTP ${res.status} ${errorText}`
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
return { success: true };
|
|
863
|
+
} catch (error) {
|
|
864
|
+
return {
|
|
865
|
+
success: false,
|
|
866
|
+
error: error instanceof Error ? error.message : String(error)
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
}
|
|
618
870
|
});
|
|
619
871
|
|
|
620
872
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -643,6 +895,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
643
895
|
import { getContext } from "hono/context-storage";
|
|
644
896
|
import { getCookie } from "hono/cookie";
|
|
645
897
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
898
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
646
899
|
function normalizeHeaders(input) {
|
|
647
900
|
const out = {};
|
|
648
901
|
if (!input) return out;
|
|
@@ -651,6 +904,11 @@ function normalizeHeaders(input) {
|
|
|
651
904
|
});
|
|
652
905
|
return out;
|
|
653
906
|
}
|
|
907
|
+
function extractInputUrl(input) {
|
|
908
|
+
if (typeof input === "string") return input;
|
|
909
|
+
if (input instanceof URL) return input.href;
|
|
910
|
+
return input.url;
|
|
911
|
+
}
|
|
654
912
|
function createSandboxProxyFetch(connectionId) {
|
|
655
913
|
return async (input, init) => {
|
|
656
914
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -660,10 +918,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
660
918
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
661
919
|
);
|
|
662
920
|
}
|
|
663
|
-
const originalUrl =
|
|
921
|
+
const originalUrl = extractInputUrl(input);
|
|
922
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
923
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
924
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
925
|
+
return fetch(sessionUrl, {
|
|
926
|
+
method: "POST",
|
|
927
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
928
|
+
});
|
|
929
|
+
}
|
|
664
930
|
const originalMethod = init?.method ?? "GET";
|
|
665
931
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
666
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
667
932
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
668
933
|
return fetch(proxyUrl, {
|
|
669
934
|
method: "POST",
|
|
@@ -689,10 +954,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
689
954
|
}
|
|
690
955
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
691
956
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
957
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
692
958
|
return async (input, init) => {
|
|
693
|
-
const originalUrl =
|
|
694
|
-
const originalMethod = init?.method ?? "GET";
|
|
695
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
959
|
+
const originalUrl = extractInputUrl(input);
|
|
696
960
|
const c = getContext();
|
|
697
961
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
698
962
|
if (!appSession) {
|
|
@@ -700,6 +964,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
700
964
|
"No authentication method available for connection proxy."
|
|
701
965
|
);
|
|
702
966
|
}
|
|
967
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
968
|
+
return fetch(sessionUrl, {
|
|
969
|
+
method: "POST",
|
|
970
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
const originalMethod = init?.method ?? "GET";
|
|
974
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
703
975
|
return fetch(proxyUrl, {
|
|
704
976
|
method: "POST",
|
|
705
977
|
headers: {
|