@tacoreai/web-sdk 1.24.1-beta.1 → 1.24.1-beta.3
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.
|
@@ -7,7 +7,11 @@ const DEFAULT_FILE_SIZE_LIMIT = 100 * 1024 * 1024;
|
|
|
7
7
|
const DEFAULT_MAX_FILES = 20;
|
|
8
8
|
|
|
9
9
|
const isPreviewMode = () => process.env.TACORE_APPSERVER_PREVIEW_MODE === "true";
|
|
10
|
-
const isLocalDeploymentMode = () =>
|
|
10
|
+
const isLocalDeploymentMode = (env = {}) =>
|
|
11
|
+
env.localDeployment === true ||
|
|
12
|
+
env.localAppServer === true ||
|
|
13
|
+
env.appServerDeploymentMode === "local" ||
|
|
14
|
+
process.env.TACORE_APPSERVER_LOCAL_DEPLOYMENT_MODE === "true";
|
|
11
15
|
|
|
12
16
|
const isValidInternalToken = (incomingValue, expectedValue) => {
|
|
13
17
|
return Boolean(expectedValue) && Boolean(incomingValue) && incomingValue === expectedValue;
|
|
@@ -310,7 +314,7 @@ export const createAppServerRuntime = async (options = {}) => {
|
|
|
310
314
|
|
|
311
315
|
if (!isPlatformProxyRequest && !isSchedulerRequest) {
|
|
312
316
|
if (!requestApiKey) {
|
|
313
|
-
if (isLocalDeploymentMode() && requestAccessToken) {
|
|
317
|
+
if (isLocalDeploymentMode(env) && requestAccessToken) {
|
|
314
318
|
try {
|
|
315
319
|
const isValidAccessToken = await validateLocalDeploymentAccessToken(env, requestAccessToken);
|
|
316
320
|
if (!isValidAccessToken) {
|
|
@@ -121,6 +121,27 @@ const clearPreviewSessionToken = (appId) => {
|
|
|
121
121
|
previewSessionPromiseCache.delete(appId);
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
+
const getBrowserPreviewBridgeBaseUrl = () => {
|
|
125
|
+
if (typeof window === "undefined") {
|
|
126
|
+
return "";
|
|
127
|
+
}
|
|
128
|
+
return String(window.__TACORE_APPSERVER_PREVIEW_BRIDGE_BASE_URL__ || "").trim().replace(/\/$/, "");
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const getBrowserPreviewBridgeInvokeUrl = () => {
|
|
132
|
+
if (typeof window === "undefined") {
|
|
133
|
+
return "";
|
|
134
|
+
}
|
|
135
|
+
return String(window.__TACORE_APPSERVER_PREVIEW_BRIDGE_URL__ || "").trim();
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const appendPreviewInvokeParams = (rawUrl, appId, apiName) => {
|
|
139
|
+
const url = new URL(rawUrl, typeof window !== "undefined" ? window.location.origin : "http://localhost");
|
|
140
|
+
url.searchParams.set("appId", appId);
|
|
141
|
+
url.searchParams.set("apiName", apiName);
|
|
142
|
+
return url.toString();
|
|
143
|
+
};
|
|
144
|
+
|
|
124
145
|
const getPreviewSessionToken = async function(options = {}) {
|
|
125
146
|
const { forceRefresh = false } = options;
|
|
126
147
|
const appServerOwnerAppId = getAppServerOwnerAppId.call(this);
|
|
@@ -139,7 +160,10 @@ const getPreviewSessionToken = async function(options = {}) {
|
|
|
139
160
|
}
|
|
140
161
|
|
|
141
162
|
const requestPromise = (async () => {
|
|
142
|
-
const
|
|
163
|
+
const bridgeBaseUrl = getBrowserPreviewBridgeBaseUrl();
|
|
164
|
+
const endpoint = bridgeBaseUrl
|
|
165
|
+
? `${bridgeBaseUrl}/appserver-preview/session?appId=${encodeURIComponent(appServerOwnerAppId)}`
|
|
166
|
+
: `/appserver-preview/session?appId=${encodeURIComponent(appServerOwnerAppId)}`;
|
|
143
167
|
const response = await fetch(endpoint, {
|
|
144
168
|
method: "GET",
|
|
145
169
|
headers: {
|
|
@@ -404,7 +428,13 @@ const invokeByPlatformProxy = async function(appServerAPIName, payload, options
|
|
|
404
428
|
|
|
405
429
|
const invokeByPreviewProxyOnce = async function(appServerAPIName, payload, options = {}, previewToken) {
|
|
406
430
|
const appServerOwnerAppId = getAppServerOwnerAppId.call(this);
|
|
407
|
-
const
|
|
431
|
+
const bridgeInvokeUrl = getBrowserPreviewBridgeInvokeUrl();
|
|
432
|
+
const bridgeBaseUrl = getBrowserPreviewBridgeBaseUrl();
|
|
433
|
+
const endpoint = bridgeInvokeUrl
|
|
434
|
+
? appendPreviewInvokeParams(bridgeInvokeUrl, appServerOwnerAppId, appServerAPIName)
|
|
435
|
+
: bridgeBaseUrl
|
|
436
|
+
? `${bridgeBaseUrl}/appserver-preview/invokeAppServerAPI?appId=${encodeURIComponent(appServerOwnerAppId)}&apiName=${encodeURIComponent(appServerAPIName)}`
|
|
437
|
+
: `/appserver-preview/invokeAppServerAPI?appId=${encodeURIComponent(appServerOwnerAppId)}&apiName=${encodeURIComponent(appServerAPIName)}`;
|
|
408
438
|
const response = await fetch(
|
|
409
439
|
endpoint,
|
|
410
440
|
buildRemoteRequestInit.call(this, payload, options, {
|
package/package.json
CHANGED