@squadbase/vite-server 0.0.1-build-18 → 0.0.1-build-20
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 +55 -10
- package/dist/index.js +63 -18
- package/dist/main.js +57 -12
- package/dist/vite-plugin.js +55 -10
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -16970,6 +16970,10 @@ var connectors = {
|
|
|
16970
16970
|
}
|
|
16971
16971
|
};
|
|
16972
16972
|
|
|
16973
|
+
// src/connector-client/registry.ts
|
|
16974
|
+
import { getContext } from "hono/context-storage";
|
|
16975
|
+
import { getCookie } from "hono/cookie";
|
|
16976
|
+
|
|
16973
16977
|
// src/connector-client/env.ts
|
|
16974
16978
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16975
16979
|
const envVarName = entry.envVars[key];
|
|
@@ -17057,20 +17061,21 @@ function createConnectorRegistry() {
|
|
|
17057
17061
|
}
|
|
17058
17062
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
17059
17063
|
}
|
|
17060
|
-
|
|
17064
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17065
|
+
function createSandboxProxyFetch(connectionId) {
|
|
17066
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17067
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17068
|
+
if (!token || !sandboxId) {
|
|
17069
|
+
throw new Error(
|
|
17070
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17071
|
+
);
|
|
17072
|
+
}
|
|
17073
|
+
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17074
|
+
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
17061
17075
|
return async (input, init) => {
|
|
17062
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17063
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17064
|
-
if (!token || !sandboxId) {
|
|
17065
|
-
throw new Error(
|
|
17066
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17067
|
-
);
|
|
17068
|
-
}
|
|
17069
17076
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17070
17077
|
const originalMethod = init?.method ?? "GET";
|
|
17071
17078
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17072
|
-
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17073
|
-
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
17074
17079
|
return fetch(proxyUrl, {
|
|
17075
17080
|
method: "POST",
|
|
17076
17081
|
headers: {
|
|
@@ -17085,6 +17090,46 @@ function createProxyFetch(connectionId) {
|
|
|
17085
17090
|
});
|
|
17086
17091
|
};
|
|
17087
17092
|
}
|
|
17093
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
17094
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17095
|
+
if (!projectId) {
|
|
17096
|
+
throw new Error(
|
|
17097
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17098
|
+
);
|
|
17099
|
+
}
|
|
17100
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17101
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
17102
|
+
return async (input, init) => {
|
|
17103
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17104
|
+
const originalMethod = init?.method ?? "GET";
|
|
17105
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17106
|
+
const c = getContext();
|
|
17107
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
17108
|
+
if (!appSession) {
|
|
17109
|
+
throw new Error(
|
|
17110
|
+
"No authentication method available for connection proxy."
|
|
17111
|
+
);
|
|
17112
|
+
}
|
|
17113
|
+
return fetch(proxyUrl, {
|
|
17114
|
+
method: "POST",
|
|
17115
|
+
headers: {
|
|
17116
|
+
"Content-Type": "application/json",
|
|
17117
|
+
Authorization: `Bearer ${appSession}`
|
|
17118
|
+
},
|
|
17119
|
+
body: JSON.stringify({
|
|
17120
|
+
url: originalUrl,
|
|
17121
|
+
method: originalMethod,
|
|
17122
|
+
body: originalBody
|
|
17123
|
+
})
|
|
17124
|
+
});
|
|
17125
|
+
};
|
|
17126
|
+
}
|
|
17127
|
+
function createProxyFetch(connectionId) {
|
|
17128
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
17129
|
+
return createSandboxProxyFetch(connectionId);
|
|
17130
|
+
}
|
|
17131
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
17132
|
+
}
|
|
17088
17133
|
function resolveParams(entry, connectionId, plugin) {
|
|
17089
17134
|
const params = {};
|
|
17090
17135
|
for (const param of Object.values(plugin.parameters)) {
|
package/dist/index.js
CHANGED
|
@@ -16905,6 +16905,10 @@ var connectors = {
|
|
|
16905
16905
|
}
|
|
16906
16906
|
};
|
|
16907
16907
|
|
|
16908
|
+
// src/connector-client/registry.ts
|
|
16909
|
+
import { getContext } from "hono/context-storage";
|
|
16910
|
+
import { getCookie } from "hono/cookie";
|
|
16911
|
+
|
|
16908
16912
|
// src/connector-client/env.ts
|
|
16909
16913
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16910
16914
|
const envVarName = entry.envVars[key];
|
|
@@ -16992,20 +16996,21 @@ function createConnectorRegistry() {
|
|
|
16992
16996
|
}
|
|
16993
16997
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
16994
16998
|
}
|
|
16995
|
-
|
|
16999
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17000
|
+
function createSandboxProxyFetch(connectionId) {
|
|
17001
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17002
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17003
|
+
if (!token || !sandboxId) {
|
|
17004
|
+
throw new Error(
|
|
17005
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17006
|
+
);
|
|
17007
|
+
}
|
|
17008
|
+
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17009
|
+
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
16996
17010
|
return async (input, init) => {
|
|
16997
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
16998
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
16999
|
-
if (!token || !sandboxId) {
|
|
17000
|
-
throw new Error(
|
|
17001
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17002
|
-
);
|
|
17003
|
-
}
|
|
17004
17011
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17005
17012
|
const originalMethod = init?.method ?? "GET";
|
|
17006
17013
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17007
|
-
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17008
|
-
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
17009
17014
|
return fetch(proxyUrl, {
|
|
17010
17015
|
method: "POST",
|
|
17011
17016
|
headers: {
|
|
@@ -17020,6 +17025,46 @@ function createProxyFetch(connectionId) {
|
|
|
17020
17025
|
});
|
|
17021
17026
|
};
|
|
17022
17027
|
}
|
|
17028
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
17029
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17030
|
+
if (!projectId) {
|
|
17031
|
+
throw new Error(
|
|
17032
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17033
|
+
);
|
|
17034
|
+
}
|
|
17035
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17036
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
17037
|
+
return async (input, init) => {
|
|
17038
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17039
|
+
const originalMethod = init?.method ?? "GET";
|
|
17040
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17041
|
+
const c = getContext();
|
|
17042
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
17043
|
+
if (!appSession) {
|
|
17044
|
+
throw new Error(
|
|
17045
|
+
"No authentication method available for connection proxy."
|
|
17046
|
+
);
|
|
17047
|
+
}
|
|
17048
|
+
return fetch(proxyUrl, {
|
|
17049
|
+
method: "POST",
|
|
17050
|
+
headers: {
|
|
17051
|
+
"Content-Type": "application/json",
|
|
17052
|
+
Authorization: `Bearer ${appSession}`
|
|
17053
|
+
},
|
|
17054
|
+
body: JSON.stringify({
|
|
17055
|
+
url: originalUrl,
|
|
17056
|
+
method: originalMethod,
|
|
17057
|
+
body: originalBody
|
|
17058
|
+
})
|
|
17059
|
+
});
|
|
17060
|
+
};
|
|
17061
|
+
}
|
|
17062
|
+
function createProxyFetch(connectionId) {
|
|
17063
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
17064
|
+
return createSandboxProxyFetch(connectionId);
|
|
17065
|
+
}
|
|
17066
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
17067
|
+
}
|
|
17023
17068
|
function resolveParams(entry, connectionId, plugin) {
|
|
17024
17069
|
const params = {};
|
|
17025
17070
|
for (const param of Object.values(plugin.parameters)) {
|
|
@@ -17855,9 +17900,9 @@ app4.get("/runtime-data", (c) => {
|
|
|
17855
17900
|
var pages_default = app4;
|
|
17856
17901
|
|
|
17857
17902
|
// src/connection.ts
|
|
17858
|
-
import { getContext } from "hono/context-storage";
|
|
17859
|
-
import { getCookie } from "hono/cookie";
|
|
17860
|
-
var
|
|
17903
|
+
import { getContext as getContext2 } from "hono/context-storage";
|
|
17904
|
+
import { getCookie as getCookie2 } from "hono/cookie";
|
|
17905
|
+
var APP_SESSION_COOKIE_NAME2 = "__Host-squadbase-session";
|
|
17861
17906
|
var PREVIEW_SESSION_COOKIE_NAME = "squadbase-preview-session";
|
|
17862
17907
|
var APP_BASE_DOMAIN = "squadbase.app";
|
|
17863
17908
|
var PREVIEW_BASE_DOMAIN = "preview.app.squadbase.dev";
|
|
@@ -17873,7 +17918,7 @@ function resolveProxyUrl(connectionId) {
|
|
|
17873
17918
|
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17874
17919
|
if (!projectId) {
|
|
17875
17920
|
throw new Error(
|
|
17876
|
-
"
|
|
17921
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17877
17922
|
);
|
|
17878
17923
|
}
|
|
17879
17924
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? APP_BASE_DOMAIN;
|
|
@@ -17884,20 +17929,20 @@ function resolveAuthHeaders() {
|
|
|
17884
17929
|
if (machineCredential) {
|
|
17885
17930
|
return { Authorization: `Bearer ${machineCredential}` };
|
|
17886
17931
|
}
|
|
17887
|
-
const c =
|
|
17888
|
-
const cookies =
|
|
17932
|
+
const c = getContext2();
|
|
17933
|
+
const cookies = getCookie2(c);
|
|
17889
17934
|
const previewSession = cookies[PREVIEW_SESSION_COOKIE_NAME];
|
|
17890
17935
|
if (previewSession) {
|
|
17891
17936
|
return {
|
|
17892
17937
|
Cookie: `${PREVIEW_SESSION_COOKIE_NAME}=${previewSession}`
|
|
17893
17938
|
};
|
|
17894
17939
|
}
|
|
17895
|
-
const appSession = cookies[
|
|
17940
|
+
const appSession = cookies[APP_SESSION_COOKIE_NAME2];
|
|
17896
17941
|
if (appSession) {
|
|
17897
17942
|
return { Authorization: `Bearer ${appSession}` };
|
|
17898
17943
|
}
|
|
17899
17944
|
throw new Error(
|
|
17900
|
-
"No authentication method available for connection proxy.
|
|
17945
|
+
"No authentication method available for connection proxy."
|
|
17901
17946
|
);
|
|
17902
17947
|
}
|
|
17903
17948
|
function connection(connectionId) {
|
package/dist/main.js
CHANGED
|
@@ -16905,6 +16905,10 @@ var connectors = {
|
|
|
16905
16905
|
}
|
|
16906
16906
|
};
|
|
16907
16907
|
|
|
16908
|
+
// src/connector-client/registry.ts
|
|
16909
|
+
import { getContext } from "hono/context-storage";
|
|
16910
|
+
import { getCookie } from "hono/cookie";
|
|
16911
|
+
|
|
16908
16912
|
// src/connector-client/env.ts
|
|
16909
16913
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16910
16914
|
const envVarName = entry.envVars[key];
|
|
@@ -16992,20 +16996,21 @@ function createConnectorRegistry() {
|
|
|
16992
16996
|
}
|
|
16993
16997
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
16994
16998
|
}
|
|
16995
|
-
|
|
16999
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17000
|
+
function createSandboxProxyFetch(connectionId) {
|
|
17001
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17002
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17003
|
+
if (!token || !sandboxId) {
|
|
17004
|
+
throw new Error(
|
|
17005
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17006
|
+
);
|
|
17007
|
+
}
|
|
17008
|
+
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17009
|
+
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
16996
17010
|
return async (input, init) => {
|
|
16997
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
16998
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
16999
|
-
if (!token || !sandboxId) {
|
|
17000
|
-
throw new Error(
|
|
17001
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17002
|
-
);
|
|
17003
|
-
}
|
|
17004
17011
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17005
17012
|
const originalMethod = init?.method ?? "GET";
|
|
17006
17013
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17007
|
-
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17008
|
-
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
17009
17014
|
return fetch(proxyUrl, {
|
|
17010
17015
|
method: "POST",
|
|
17011
17016
|
headers: {
|
|
@@ -17020,6 +17025,46 @@ function createProxyFetch(connectionId) {
|
|
|
17020
17025
|
});
|
|
17021
17026
|
};
|
|
17022
17027
|
}
|
|
17028
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
17029
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17030
|
+
if (!projectId) {
|
|
17031
|
+
throw new Error(
|
|
17032
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17033
|
+
);
|
|
17034
|
+
}
|
|
17035
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17036
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
17037
|
+
return async (input, init) => {
|
|
17038
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17039
|
+
const originalMethod = init?.method ?? "GET";
|
|
17040
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17041
|
+
const c = getContext();
|
|
17042
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
17043
|
+
if (!appSession) {
|
|
17044
|
+
throw new Error(
|
|
17045
|
+
"No authentication method available for connection proxy."
|
|
17046
|
+
);
|
|
17047
|
+
}
|
|
17048
|
+
return fetch(proxyUrl, {
|
|
17049
|
+
method: "POST",
|
|
17050
|
+
headers: {
|
|
17051
|
+
"Content-Type": "application/json",
|
|
17052
|
+
Authorization: `Bearer ${appSession}`
|
|
17053
|
+
},
|
|
17054
|
+
body: JSON.stringify({
|
|
17055
|
+
url: originalUrl,
|
|
17056
|
+
method: originalMethod,
|
|
17057
|
+
body: originalBody
|
|
17058
|
+
})
|
|
17059
|
+
});
|
|
17060
|
+
};
|
|
17061
|
+
}
|
|
17062
|
+
function createProxyFetch(connectionId) {
|
|
17063
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
17064
|
+
return createSandboxProxyFetch(connectionId);
|
|
17065
|
+
}
|
|
17066
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
17067
|
+
}
|
|
17023
17068
|
function resolveParams(entry, connectionId, plugin) {
|
|
17024
17069
|
const params = {};
|
|
17025
17070
|
for (const param of Object.values(plugin.parameters)) {
|
|
@@ -17593,8 +17638,8 @@ app4.get("/runtime-data", (c) => {
|
|
|
17593
17638
|
var pages_default = app4;
|
|
17594
17639
|
|
|
17595
17640
|
// src/connection.ts
|
|
17596
|
-
import { getContext } from "hono/context-storage";
|
|
17597
|
-
import { getCookie } from "hono/cookie";
|
|
17641
|
+
import { getContext as getContext2 } from "hono/context-storage";
|
|
17642
|
+
import { getCookie as getCookie2 } from "hono/cookie";
|
|
17598
17643
|
|
|
17599
17644
|
// src/index.ts
|
|
17600
17645
|
var apiApp = new Hono5();
|
package/dist/vite-plugin.js
CHANGED
|
@@ -16906,6 +16906,10 @@ var connectors = {
|
|
|
16906
16906
|
}
|
|
16907
16907
|
};
|
|
16908
16908
|
|
|
16909
|
+
// src/connector-client/registry.ts
|
|
16910
|
+
import { getContext } from "hono/context-storage";
|
|
16911
|
+
import { getCookie } from "hono/cookie";
|
|
16912
|
+
|
|
16909
16913
|
// src/connector-client/env.ts
|
|
16910
16914
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16911
16915
|
const envVarName = entry.envVars[key];
|
|
@@ -16993,20 +16997,21 @@ function createConnectorRegistry() {
|
|
|
16993
16997
|
}
|
|
16994
16998
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
16995
16999
|
}
|
|
16996
|
-
|
|
17000
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17001
|
+
function createSandboxProxyFetch(connectionId) {
|
|
17002
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17003
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17004
|
+
if (!token || !sandboxId) {
|
|
17005
|
+
throw new Error(
|
|
17006
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17007
|
+
);
|
|
17008
|
+
}
|
|
17009
|
+
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17010
|
+
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
16997
17011
|
return async (input, init) => {
|
|
16998
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
16999
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17000
|
-
if (!token || !sandboxId) {
|
|
17001
|
-
throw new Error(
|
|
17002
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17003
|
-
);
|
|
17004
|
-
}
|
|
17005
17012
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17006
17013
|
const originalMethod = init?.method ?? "GET";
|
|
17007
17014
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17008
|
-
const envPrefix = process.env.SQUADBASE_ENV === "prod" ? "" : `${process.env.SQUADBASE_ENV ?? "dev1"}-`;
|
|
17009
|
-
const proxyUrl = `https://${sandboxId}.preview.${envPrefix}app.squadbase.dev/_sqcore/connections/${connectionId}/request`;
|
|
17010
17015
|
return fetch(proxyUrl, {
|
|
17011
17016
|
method: "POST",
|
|
17012
17017
|
headers: {
|
|
@@ -17021,6 +17026,46 @@ function createProxyFetch(connectionId) {
|
|
|
17021
17026
|
});
|
|
17022
17027
|
};
|
|
17023
17028
|
}
|
|
17029
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
17030
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17031
|
+
if (!projectId) {
|
|
17032
|
+
throw new Error(
|
|
17033
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17034
|
+
);
|
|
17035
|
+
}
|
|
17036
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17037
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
17038
|
+
return async (input, init) => {
|
|
17039
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17040
|
+
const originalMethod = init?.method ?? "GET";
|
|
17041
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17042
|
+
const c = getContext();
|
|
17043
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
17044
|
+
if (!appSession) {
|
|
17045
|
+
throw new Error(
|
|
17046
|
+
"No authentication method available for connection proxy."
|
|
17047
|
+
);
|
|
17048
|
+
}
|
|
17049
|
+
return fetch(proxyUrl, {
|
|
17050
|
+
method: "POST",
|
|
17051
|
+
headers: {
|
|
17052
|
+
"Content-Type": "application/json",
|
|
17053
|
+
Authorization: `Bearer ${appSession}`
|
|
17054
|
+
},
|
|
17055
|
+
body: JSON.stringify({
|
|
17056
|
+
url: originalUrl,
|
|
17057
|
+
method: originalMethod,
|
|
17058
|
+
body: originalBody
|
|
17059
|
+
})
|
|
17060
|
+
});
|
|
17061
|
+
};
|
|
17062
|
+
}
|
|
17063
|
+
function createProxyFetch(connectionId) {
|
|
17064
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
17065
|
+
return createSandboxProxyFetch(connectionId);
|
|
17066
|
+
}
|
|
17067
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
17068
|
+
}
|
|
17024
17069
|
function resolveParams(entry, connectionId, plugin) {
|
|
17025
17070
|
const params = {};
|
|
17026
17071
|
for (const param of Object.values(plugin.parameters)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/vite-server",
|
|
3
|
-
"version": "0.0.1-build-
|
|
3
|
+
"version": "0.0.1-build-20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@clack/prompts": "^0.9.1",
|
|
57
|
-
"@squadbase/connectors": "^0.0.
|
|
57
|
+
"@squadbase/connectors": "^0.0.4",
|
|
58
58
|
"@types/node": "^22.15.0",
|
|
59
59
|
"@types/pg": "^8.16.0",
|
|
60
60
|
"@types/snowflake-sdk": "^1.6.24",
|