@lark-apaas/client-toolkit-lite 1.1.1-alpha.6 → 1.1.1-alpha.8
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 +30 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -347,11 +347,40 @@ function getCurrentUserProfile() {
|
|
|
347
347
|
}
|
|
348
348
|
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
349
349
|
|
|
350
|
+
// src/utils/url.ts
|
|
351
|
+
function splitWorkspaceUrl(fullUrl) {
|
|
352
|
+
try {
|
|
353
|
+
const url = new URL(fullUrl);
|
|
354
|
+
const pathParts = url.pathname.split("/");
|
|
355
|
+
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
356
|
+
if (workspacesIndex === -1) {
|
|
357
|
+
throw new Error("Invalid workspace URL format");
|
|
358
|
+
}
|
|
359
|
+
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
360
|
+
const workspace = pathParts[workspacesIndex + 1];
|
|
361
|
+
return {
|
|
362
|
+
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
363
|
+
workspace
|
|
364
|
+
};
|
|
365
|
+
} catch (error) {
|
|
366
|
+
console.error("Error splitting workspace URL:", error);
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
baseUrl: fullUrl,
|
|
370
|
+
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
371
|
+
workspace: "workspace"
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
375
|
+
|
|
350
376
|
// src/integrations/dataloom.ts
|
|
351
377
|
var import_dataloom = require("@lark-apaas/dataloom");
|
|
352
378
|
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
379
|
+
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
380
|
+
baseUrl: ""
|
|
381
|
+
};
|
|
353
382
|
const appId = getAppId() ?? "";
|
|
354
|
-
return (0, import_dataloom.createClient)(
|
|
383
|
+
return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
|
|
355
384
|
global: {
|
|
356
385
|
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
357
386
|
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|