@lark-apaas/client-toolkit 1.2.48-alpha.12 → 1.2.48-alpha.13

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.
@@ -1,4 +1,4 @@
1
- declare const createDataLoomClient: (url?: string, pat?: string) => import("@lark-apaas/dataloom").DataloomClient;
2
- /** 获取dataloom实例 */
1
+ declare const createDataLoomClient: () => import("@lark-apaas/dataloom").DataloomClient;
2
+ /** 获取 dataloom 实例 */
3
3
  export declare function getDataloom(): Promise<ReturnType<typeof createDataLoomClient>>;
4
4
  export {};
@@ -1,19 +1,19 @@
1
- import { splitWorkspaceUrl } from "../utils/url.js";
2
1
  import { createClient } from "@lark-apaas/dataloom";
3
2
  import { authClient } from "@lark-apaas/auth-sdk";
4
3
  import { getAppId } from "../utils/getAppId.js";
5
- import { getAppPublished } from "../utils/getInitialInfo.js";
6
- const createDataLoomClient = (url, pat)=>{
7
- const { baseUrl } = url ? splitWorkspaceUrl(url) : {
8
- baseUrl: ''
9
- };
4
+ import { getCsrfToken } from "../utils/getCsrfToken.js";
5
+ import { getInitialInfo } from "../utils/getInitialInfo.js";
6
+ const createDataLoomClient = ()=>{
10
7
  const appId = getAppId();
11
- return createClient(baseUrl, pat, {
8
+ return createClient({
12
9
  global: {
13
10
  enableDataloomLog: 'production' !== process.env.NODE_ENV,
14
11
  requestRateLimit: 'production' !== process.env.NODE_ENV ? 100 : void 0,
15
12
  brandName: 'miaoda',
16
13
  appId,
14
+ headers: {
15
+ 'X-Suda-Csrf-Token': getCsrfToken() ?? ''
16
+ },
17
17
  accountServices: {
18
18
  user: authClient.user,
19
19
  session: authClient.session
@@ -26,10 +26,8 @@ let pendingPromise = null;
26
26
  function getDataloom() {
27
27
  if (dataloom) return Promise.resolve(dataloom);
28
28
  if (pendingPromise) return pendingPromise;
29
- pendingPromise = getAppPublished().then((info)=>{
30
- const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
31
- const DATALOOM_PAT = info?.app_runtime_extra?.token;
32
- dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
29
+ pendingPromise = getInitialInfo().then(()=>{
30
+ dataloom = createDataLoomClient();
33
31
  return dataloom;
34
32
  }).finally(()=>{
35
33
  pendingPromise = null;
@@ -13,13 +13,6 @@ interface AppRuntimePublished {
13
13
  interface BucketConfig {
14
14
  default_bucket_id?: string;
15
15
  }
16
- /**
17
- * 从API获取已发布的应用信息(仅全栈沙箱模式下使用)
18
- */
19
- export declare function getAppPublished(): Promise<{
20
- app_info?: AppRuntimePublished;
21
- app_runtime_extra?: AppRuntimeExtra;
22
- } | undefined>;
23
16
  declare let initialInfo: {
24
17
  app_info?: AppRuntimePublished;
25
18
  app_runtime_extra?: AppRuntimeExtra;
@@ -59,4 +59,4 @@ function getInitialInfo(refresh = false) {
59
59
  });
60
60
  return pendingPromise;
61
61
  }
62
- export { getAppPublished, getInitialInfo };
62
+ export { getInitialInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.48-alpha.12",
3
+ "version": "1.2.48-alpha.13",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -101,7 +101,7 @@
101
101
  "@lark-apaas/aily-web-sdk": "^0.0.11",
102
102
  "@lark-apaas/auth-sdk": "^0.1.5",
103
103
  "@lark-apaas/client-capability": "^0.1.7",
104
- "@lark-apaas/dataloom": "0.1.3-alpha.9",
104
+ "@lark-apaas/dataloom": "0.1.3-alpha.10",
105
105
  "@lark-apaas/internal-slardar": "^0.0.3",
106
106
  "@lark-apaas/miaoda-inspector": "^1.0.23",
107
107
  "@lark-apaas/observable-web": "^1.0.6",
@@ -1,8 +0,0 @@
1
- export interface UrlParts {
2
- baseUrl: string;
3
- workspace: string;
4
- }
5
- /**
6
- * @internal
7
- */
8
- export declare function splitWorkspaceUrl(fullUrl: string): UrlParts;
package/lib/utils/url.js DELETED
@@ -1,22 +0,0 @@
1
- import { logger } from "../logger/index.js";
2
- function splitWorkspaceUrl(fullUrl) {
3
- try {
4
- const url = new URL(fullUrl);
5
- const pathParts = url.pathname.split('/');
6
- const workspacesIndex = pathParts.findIndex((part)=>'workspaces' === part);
7
- if (-1 === workspacesIndex) throw new Error('Invalid workspace URL format');
8
- const basePathParts = pathParts.slice(0, workspacesIndex);
9
- const workspace = pathParts[workspacesIndex + 1];
10
- return {
11
- baseUrl: `${url.origin}${basePathParts.join('/')}`,
12
- workspace
13
- };
14
- } catch (error) {
15
- logger.error('Error splitting workspace URL:', error);
16
- }
17
- return {
18
- baseUrl: fullUrl,
19
- workspace: 'workspace'
20
- };
21
- }
22
- export { splitWorkspaceUrl };