@squadbase/vite-server 0.1.3-dev.1 → 0.1.3-dev.10
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 +71031 -6800
- package/dist/connectors/airtable-oauth.js +77 -3
- package/dist/connectors/airtable.js +85 -2
- package/dist/connectors/amplitude.js +85 -2
- package/dist/connectors/anthropic.js +85 -2
- package/dist/connectors/asana.js +86 -3
- package/dist/connectors/attio.js +85 -2
- package/dist/connectors/customerio.js +86 -3
- package/dist/connectors/dbt.js +85 -2
- package/dist/connectors/gemini.js +86 -3
- package/dist/connectors/gmail-oauth.js +78 -4
- package/dist/connectors/gmail.d.ts +5 -0
- package/dist/connectors/gmail.js +875 -0
- package/dist/connectors/google-ads-oauth.js +78 -4
- package/dist/connectors/google-ads.js +85 -2
- package/dist/connectors/google-analytics-oauth.js +90 -8
- package/dist/connectors/google-analytics.js +85 -2
- package/dist/connectors/google-calendar-oauth.d.ts +5 -0
- package/dist/connectors/google-calendar-oauth.js +817 -0
- package/dist/connectors/google-calendar.d.ts +5 -0
- package/dist/connectors/google-calendar.js +991 -0
- package/dist/connectors/google-sheets-oauth.js +144 -33
- package/dist/connectors/google-sheets.js +119 -10
- package/dist/connectors/{microsoft-teams.d.ts → grafana.d.ts} +1 -1
- package/dist/connectors/grafana.js +638 -0
- package/dist/connectors/hubspot-oauth.js +77 -3
- package/dist/connectors/hubspot.js +79 -5
- package/dist/connectors/intercom-oauth.js +78 -4
- package/dist/connectors/intercom.js +86 -3
- package/dist/connectors/jira-api-key.js +84 -9
- package/dist/connectors/kintone-api-token.js +77 -3
- package/dist/connectors/kintone.js +86 -3
- package/dist/connectors/linkedin-ads-oauth.js +78 -4
- package/dist/connectors/linkedin-ads.js +86 -3
- package/dist/connectors/mailchimp-oauth.js +77 -3
- package/dist/connectors/mailchimp.js +86 -3
- package/dist/connectors/{microsoft-teams-oauth.d.ts → notion-oauth.d.ts} +1 -1
- package/dist/connectors/notion-oauth.js +567 -0
- package/dist/connectors/{slack.d.ts → notion.d.ts} +1 -1
- package/dist/connectors/notion.js +663 -0
- package/dist/connectors/openai.js +85 -2
- package/dist/connectors/shopify-oauth.js +77 -3
- package/dist/connectors/shopify.js +85 -2
- package/dist/connectors/stripe-api-key.d.ts +5 -0
- package/dist/connectors/stripe-api-key.js +600 -0
- package/dist/connectors/stripe-oauth.js +77 -3
- package/dist/connectors/wix-store.js +85 -2
- package/dist/connectors/zendesk-oauth.js +78 -4
- package/dist/connectors/zendesk.js +86 -3
- package/dist/index.js +75373 -8431
- package/dist/main.js +75359 -8417
- package/dist/vite-plugin.js +75210 -8305
- package/package.json +46 -2
- package/dist/connectors/microsoft-teams-oauth.js +0 -479
- package/dist/connectors/microsoft-teams.js +0 -381
- package/dist/connectors/slack.js +0 -362
|
@@ -114,7 +114,8 @@ var AUTH_TYPES = {
|
|
|
114
114
|
API_KEY: "api-key",
|
|
115
115
|
JWT: "jwt",
|
|
116
116
|
SERVICE_ACCOUNT: "service-account",
|
|
117
|
-
PAT: "pat"
|
|
117
|
+
PAT: "pat",
|
|
118
|
+
USER_PASSWORD: "user-password"
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
// ../connectors/src/connectors/stripe-oauth/tools/request.ts
|
|
@@ -281,7 +282,7 @@ var tools = { request: requestTool };
|
|
|
281
282
|
var stripeOauthConnector = new ConnectorPlugin({
|
|
282
283
|
slug: "stripe",
|
|
283
284
|
authType: AUTH_TYPES.OAUTH,
|
|
284
|
-
name: "Stripe
|
|
285
|
+
name: "Stripe",
|
|
285
286
|
description: "Connect to Stripe for payment, customer, and subscription data using OAuth.",
|
|
286
287
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2QNK0u2doqp41uL0POS4Ks/7a92367e2388ec77c7f4ada143606f9a/stripe.jpeg",
|
|
287
288
|
parameters,
|
|
@@ -441,6 +442,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
441
442
|
return process.env[envVarName] || void 0;
|
|
442
443
|
}
|
|
443
444
|
|
|
445
|
+
// src/connector-client/proxy-fetch.ts
|
|
446
|
+
import { getContext } from "hono/context-storage";
|
|
447
|
+
import { getCookie } from "hono/cookie";
|
|
448
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
449
|
+
function createSandboxProxyFetch(connectionId) {
|
|
450
|
+
return async (input, init) => {
|
|
451
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
452
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
453
|
+
if (!token || !sandboxId) {
|
|
454
|
+
throw new Error(
|
|
455
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
459
|
+
const originalMethod = init?.method ?? "GET";
|
|
460
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
461
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
462
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
463
|
+
return fetch(proxyUrl, {
|
|
464
|
+
method: "POST",
|
|
465
|
+
headers: {
|
|
466
|
+
"Content-Type": "application/json",
|
|
467
|
+
Authorization: `Bearer ${token}`
|
|
468
|
+
},
|
|
469
|
+
body: JSON.stringify({
|
|
470
|
+
url: originalUrl,
|
|
471
|
+
method: originalMethod,
|
|
472
|
+
body: originalBody
|
|
473
|
+
})
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
478
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
479
|
+
if (!projectId) {
|
|
480
|
+
throw new Error(
|
|
481
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
485
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
486
|
+
return async (input, init) => {
|
|
487
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
488
|
+
const originalMethod = init?.method ?? "GET";
|
|
489
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
490
|
+
const c = getContext();
|
|
491
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
492
|
+
if (!appSession) {
|
|
493
|
+
throw new Error(
|
|
494
|
+
"No authentication method available for connection proxy."
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
return fetch(proxyUrl, {
|
|
498
|
+
method: "POST",
|
|
499
|
+
headers: {
|
|
500
|
+
"Content-Type": "application/json",
|
|
501
|
+
Authorization: `Bearer ${appSession}`
|
|
502
|
+
},
|
|
503
|
+
body: JSON.stringify({
|
|
504
|
+
url: originalUrl,
|
|
505
|
+
method: originalMethod,
|
|
506
|
+
body: originalBody
|
|
507
|
+
})
|
|
508
|
+
});
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function createProxyFetch(connectionId) {
|
|
512
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
513
|
+
return createSandboxProxyFetch(connectionId);
|
|
514
|
+
}
|
|
515
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
516
|
+
}
|
|
517
|
+
|
|
444
518
|
// src/connectors/create-connector-sdk.ts
|
|
445
519
|
function loadConnectionsSync() {
|
|
446
520
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -474,7 +548,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
474
548
|
if (val !== void 0) params[param.slug] = val;
|
|
475
549
|
}
|
|
476
550
|
}
|
|
477
|
-
return createClient2(params);
|
|
551
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
478
552
|
};
|
|
479
553
|
}
|
|
480
554
|
|
|
@@ -299,6 +299,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
+
// ../connectors/src/auth-types.ts
|
|
303
|
+
var AUTH_TYPES = {
|
|
304
|
+
OAUTH: "oauth",
|
|
305
|
+
API_KEY: "api-key",
|
|
306
|
+
JWT: "jwt",
|
|
307
|
+
SERVICE_ACCOUNT: "service-account",
|
|
308
|
+
PAT: "pat",
|
|
309
|
+
USER_PASSWORD: "user-password"
|
|
310
|
+
};
|
|
311
|
+
|
|
302
312
|
// ../connectors/src/connectors/wix-store/setup.ts
|
|
303
313
|
var wixStoreOnboarding = new ConnectorOnboarding({
|
|
304
314
|
dataOverviewInstructions: {
|
|
@@ -385,7 +395,7 @@ Authentication is handled automatically using the API Key and Site ID.`,
|
|
|
385
395
|
var tools = { request: requestTool };
|
|
386
396
|
var wixStoreConnector = new ConnectorPlugin({
|
|
387
397
|
slug: "wix-store",
|
|
388
|
-
authType:
|
|
398
|
+
authType: AUTH_TYPES.API_KEY,
|
|
389
399
|
name: "Wix Store",
|
|
390
400
|
description: "Connect to Wix Store.",
|
|
391
401
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/YyFxclQFzROIYpFam6vRK/e7e75d3feac49a1cc5e433c147216d23/Wix_logo_black.svg",
|
|
@@ -567,6 +577,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
567
577
|
return process.env[envVarName] || void 0;
|
|
568
578
|
}
|
|
569
579
|
|
|
580
|
+
// src/connector-client/proxy-fetch.ts
|
|
581
|
+
import { getContext } from "hono/context-storage";
|
|
582
|
+
import { getCookie } from "hono/cookie";
|
|
583
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
584
|
+
function createSandboxProxyFetch(connectionId) {
|
|
585
|
+
return async (input, init) => {
|
|
586
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
587
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
588
|
+
if (!token || !sandboxId) {
|
|
589
|
+
throw new Error(
|
|
590
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
594
|
+
const originalMethod = init?.method ?? "GET";
|
|
595
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
596
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
597
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
598
|
+
return fetch(proxyUrl, {
|
|
599
|
+
method: "POST",
|
|
600
|
+
headers: {
|
|
601
|
+
"Content-Type": "application/json",
|
|
602
|
+
Authorization: `Bearer ${token}`
|
|
603
|
+
},
|
|
604
|
+
body: JSON.stringify({
|
|
605
|
+
url: originalUrl,
|
|
606
|
+
method: originalMethod,
|
|
607
|
+
body: originalBody
|
|
608
|
+
})
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
613
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
614
|
+
if (!projectId) {
|
|
615
|
+
throw new Error(
|
|
616
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
620
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
621
|
+
return async (input, init) => {
|
|
622
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
623
|
+
const originalMethod = init?.method ?? "GET";
|
|
624
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
625
|
+
const c = getContext();
|
|
626
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
627
|
+
if (!appSession) {
|
|
628
|
+
throw new Error(
|
|
629
|
+
"No authentication method available for connection proxy."
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
return fetch(proxyUrl, {
|
|
633
|
+
method: "POST",
|
|
634
|
+
headers: {
|
|
635
|
+
"Content-Type": "application/json",
|
|
636
|
+
Authorization: `Bearer ${appSession}`
|
|
637
|
+
},
|
|
638
|
+
body: JSON.stringify({
|
|
639
|
+
url: originalUrl,
|
|
640
|
+
method: originalMethod,
|
|
641
|
+
body: originalBody
|
|
642
|
+
})
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function createProxyFetch(connectionId) {
|
|
647
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
648
|
+
return createSandboxProxyFetch(connectionId);
|
|
649
|
+
}
|
|
650
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
651
|
+
}
|
|
652
|
+
|
|
570
653
|
// src/connectors/create-connector-sdk.ts
|
|
571
654
|
function loadConnectionsSync() {
|
|
572
655
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -600,7 +683,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
600
683
|
if (val !== void 0) params[param.slug] = val;
|
|
601
684
|
}
|
|
602
685
|
}
|
|
603
|
-
return createClient2(params);
|
|
686
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
604
687
|
};
|
|
605
688
|
}
|
|
606
689
|
|
|
@@ -112,7 +112,8 @@ var AUTH_TYPES = {
|
|
|
112
112
|
API_KEY: "api-key",
|
|
113
113
|
JWT: "jwt",
|
|
114
114
|
SERVICE_ACCOUNT: "service-account",
|
|
115
|
-
PAT: "pat"
|
|
115
|
+
PAT: "pat",
|
|
116
|
+
USER_PASSWORD: "user-password"
|
|
116
117
|
};
|
|
117
118
|
|
|
118
119
|
// ../connectors/src/connectors/zendesk-oauth/tools/request.ts
|
|
@@ -283,9 +284,9 @@ var tools = { request: requestTool };
|
|
|
283
284
|
var zendeskOauthConnector = new ConnectorPlugin({
|
|
284
285
|
slug: "zendesk",
|
|
285
286
|
authType: AUTH_TYPES.OAUTH,
|
|
286
|
-
name: "Zendesk
|
|
287
|
+
name: "Zendesk",
|
|
287
288
|
description: "Connect to Zendesk Support for tickets, users, organizations, and customer service data using OAuth.",
|
|
288
|
-
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/
|
|
289
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7e9Q7PwV6MJRJMj543m2gl/55385fae903ccfa1599e35be9d3516aa/zendesk-icon.svg",
|
|
289
290
|
parameters,
|
|
290
291
|
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
291
292
|
onboarding: zendeskOauthOnboarding,
|
|
@@ -461,6 +462,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
461
462
|
return process.env[envVarName] || void 0;
|
|
462
463
|
}
|
|
463
464
|
|
|
465
|
+
// src/connector-client/proxy-fetch.ts
|
|
466
|
+
import { getContext } from "hono/context-storage";
|
|
467
|
+
import { getCookie } from "hono/cookie";
|
|
468
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
469
|
+
function createSandboxProxyFetch(connectionId) {
|
|
470
|
+
return async (input, init) => {
|
|
471
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
472
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
473
|
+
if (!token || !sandboxId) {
|
|
474
|
+
throw new Error(
|
|
475
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
479
|
+
const originalMethod = init?.method ?? "GET";
|
|
480
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
481
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
482
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
483
|
+
return fetch(proxyUrl, {
|
|
484
|
+
method: "POST",
|
|
485
|
+
headers: {
|
|
486
|
+
"Content-Type": "application/json",
|
|
487
|
+
Authorization: `Bearer ${token}`
|
|
488
|
+
},
|
|
489
|
+
body: JSON.stringify({
|
|
490
|
+
url: originalUrl,
|
|
491
|
+
method: originalMethod,
|
|
492
|
+
body: originalBody
|
|
493
|
+
})
|
|
494
|
+
});
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
498
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
499
|
+
if (!projectId) {
|
|
500
|
+
throw new Error(
|
|
501
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
505
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
506
|
+
return async (input, init) => {
|
|
507
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
508
|
+
const originalMethod = init?.method ?? "GET";
|
|
509
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
510
|
+
const c = getContext();
|
|
511
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
512
|
+
if (!appSession) {
|
|
513
|
+
throw new Error(
|
|
514
|
+
"No authentication method available for connection proxy."
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
return fetch(proxyUrl, {
|
|
518
|
+
method: "POST",
|
|
519
|
+
headers: {
|
|
520
|
+
"Content-Type": "application/json",
|
|
521
|
+
Authorization: `Bearer ${appSession}`
|
|
522
|
+
},
|
|
523
|
+
body: JSON.stringify({
|
|
524
|
+
url: originalUrl,
|
|
525
|
+
method: originalMethod,
|
|
526
|
+
body: originalBody
|
|
527
|
+
})
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function createProxyFetch(connectionId) {
|
|
532
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
533
|
+
return createSandboxProxyFetch(connectionId);
|
|
534
|
+
}
|
|
535
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
536
|
+
}
|
|
537
|
+
|
|
464
538
|
// src/connectors/create-connector-sdk.ts
|
|
465
539
|
function loadConnectionsSync() {
|
|
466
540
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -494,7 +568,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
494
568
|
if (val !== void 0) params[param.slug] = val;
|
|
495
569
|
}
|
|
496
570
|
}
|
|
497
|
-
return createClient2(params);
|
|
571
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
498
572
|
};
|
|
499
573
|
}
|
|
500
574
|
|
|
@@ -281,6 +281,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
281
281
|
}
|
|
282
282
|
};
|
|
283
283
|
|
|
284
|
+
// ../connectors/src/auth-types.ts
|
|
285
|
+
var AUTH_TYPES = {
|
|
286
|
+
OAUTH: "oauth",
|
|
287
|
+
API_KEY: "api-key",
|
|
288
|
+
JWT: "jwt",
|
|
289
|
+
SERVICE_ACCOUNT: "service-account",
|
|
290
|
+
PAT: "pat",
|
|
291
|
+
USER_PASSWORD: "user-password"
|
|
292
|
+
};
|
|
293
|
+
|
|
284
294
|
// ../connectors/src/connectors/zendesk/setup.ts
|
|
285
295
|
var zendeskOnboarding = new ConnectorOnboarding({
|
|
286
296
|
dataOverviewInstructions: {
|
|
@@ -381,10 +391,10 @@ Zendesk uses cursor-based pagination with page[size] and page[after] parameters.
|
|
|
381
391
|
var tools = { request: requestTool };
|
|
382
392
|
var zendeskConnector = new ConnectorPlugin({
|
|
383
393
|
slug: "zendesk",
|
|
384
|
-
authType:
|
|
394
|
+
authType: AUTH_TYPES.API_KEY,
|
|
385
395
|
name: "Zendesk",
|
|
386
396
|
description: "Connect to Zendesk Support for tickets, users, organizations, and customer service data using an API token.",
|
|
387
|
-
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/
|
|
397
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7e9Q7PwV6MJRJMj543m2gl/55385fae903ccfa1599e35be9d3516aa/zendesk-icon.svg",
|
|
388
398
|
parameters,
|
|
389
399
|
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
390
400
|
onboarding: zendeskOnboarding,
|
|
@@ -587,6 +597,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
587
597
|
return process.env[envVarName] || void 0;
|
|
588
598
|
}
|
|
589
599
|
|
|
600
|
+
// src/connector-client/proxy-fetch.ts
|
|
601
|
+
import { getContext } from "hono/context-storage";
|
|
602
|
+
import { getCookie } from "hono/cookie";
|
|
603
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
604
|
+
function createSandboxProxyFetch(connectionId) {
|
|
605
|
+
return async (input, init) => {
|
|
606
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
607
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
608
|
+
if (!token || !sandboxId) {
|
|
609
|
+
throw new Error(
|
|
610
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
614
|
+
const originalMethod = init?.method ?? "GET";
|
|
615
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
616
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
617
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
618
|
+
return fetch(proxyUrl, {
|
|
619
|
+
method: "POST",
|
|
620
|
+
headers: {
|
|
621
|
+
"Content-Type": "application/json",
|
|
622
|
+
Authorization: `Bearer ${token}`
|
|
623
|
+
},
|
|
624
|
+
body: JSON.stringify({
|
|
625
|
+
url: originalUrl,
|
|
626
|
+
method: originalMethod,
|
|
627
|
+
body: originalBody
|
|
628
|
+
})
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
633
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
634
|
+
if (!projectId) {
|
|
635
|
+
throw new Error(
|
|
636
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
640
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
641
|
+
return async (input, init) => {
|
|
642
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
643
|
+
const originalMethod = init?.method ?? "GET";
|
|
644
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
645
|
+
const c = getContext();
|
|
646
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
647
|
+
if (!appSession) {
|
|
648
|
+
throw new Error(
|
|
649
|
+
"No authentication method available for connection proxy."
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
return fetch(proxyUrl, {
|
|
653
|
+
method: "POST",
|
|
654
|
+
headers: {
|
|
655
|
+
"Content-Type": "application/json",
|
|
656
|
+
Authorization: `Bearer ${appSession}`
|
|
657
|
+
},
|
|
658
|
+
body: JSON.stringify({
|
|
659
|
+
url: originalUrl,
|
|
660
|
+
method: originalMethod,
|
|
661
|
+
body: originalBody
|
|
662
|
+
})
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
function createProxyFetch(connectionId) {
|
|
667
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
668
|
+
return createSandboxProxyFetch(connectionId);
|
|
669
|
+
}
|
|
670
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
671
|
+
}
|
|
672
|
+
|
|
590
673
|
// src/connectors/create-connector-sdk.ts
|
|
591
674
|
function loadConnectionsSync() {
|
|
592
675
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -620,7 +703,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
620
703
|
if (val !== void 0) params[param.slug] = val;
|
|
621
704
|
}
|
|
622
705
|
}
|
|
623
|
-
return createClient2(params);
|
|
706
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
624
707
|
};
|
|
625
708
|
}
|
|
626
709
|
|