@lark-apaas/client-toolkit-lite 1.1.11-alpha.2 → 1.1.11-alpha.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.
package/dist/index.cjs CHANGED
@@ -2814,46 +2814,21 @@ function getAxiosForBackend() {
2814
2814
  __name(getAxiosForBackend, "getAxiosForBackend");
2815
2815
  var axiosForBackend = getAxiosForBackend();
2816
2816
 
2817
- // src/utils/url.ts
2818
- function splitWorkspaceUrl(fullUrl) {
2819
- try {
2820
- const url = new URL(fullUrl);
2821
- const pathParts = url.pathname.split("/");
2822
- const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
2823
- if (workspacesIndex === -1) {
2824
- throw new Error("Invalid workspace URL format");
2825
- }
2826
- const basePathParts = pathParts.slice(0, workspacesIndex);
2827
- const workspace = pathParts[workspacesIndex + 1];
2828
- return {
2829
- baseUrl: `${url.origin}${basePathParts.join("/")}`,
2830
- workspace
2831
- };
2832
- } catch (error) {
2833
- console.error("Error splitting workspace URL:", error);
2834
- }
2835
- return {
2836
- baseUrl: fullUrl,
2837
- // 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
2838
- workspace: "workspace"
2839
- };
2840
- }
2841
- __name(splitWorkspaceUrl, "splitWorkspaceUrl");
2842
-
2843
2817
  // src/integrations/dataloom.ts
2844
2818
  var import_dataloom = require("@lark-apaas/dataloom");
2845
2819
  var import_auth_sdk3 = require("@lark-apaas/auth-sdk");
2846
- var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
2847
- const { baseUrl } = url ? splitWorkspaceUrl(url) : {
2848
- baseUrl: ""
2849
- };
2820
+ var createDataLoomClient = /* @__PURE__ */ __name(() => {
2850
2821
  const appId = getAppId() ?? "";
2851
- return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
2822
+ return (0, import_dataloom.createClient)({
2852
2823
  global: {
2853
2824
  enableDataloomLog: process.env.NODE_ENV !== "production",
2854
2825
  requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
2855
2826
  brandName: "miaoda",
2856
2827
  appId,
2828
+ // 同源网关下不会触发预检;CSRF token 仅用于 POST/PUT/DELETE 防护。
2829
+ headers: {
2830
+ "X-Suda-Csrf-Token": getCsrfToken() ?? ""
2831
+ },
2857
2832
  accountServices: {
2858
2833
  user: import_auth_sdk3.authClient.user,
2859
2834
  session: import_auth_sdk3.authClient.session
@@ -2870,10 +2845,8 @@ function getDataloom() {
2870
2845
  if (pendingPromise3) {
2871
2846
  return pendingPromise3;
2872
2847
  }
2873
- pendingPromise3 = getInitialInfo().then((info) => {
2874
- const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
2875
- const DATALOOM_PAT = info?.app_runtime_extra?.token;
2876
- dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
2848
+ pendingPromise3 = getInitialInfo().then(() => {
2849
+ dataloom = createDataLoomClient();
2877
2850
  return dataloom;
2878
2851
  }).finally(() => {
2879
2852
  pendingPromise3 = null;