@nocobase/sdk 0.20.0-alpha.9 → 0.21.0-alpha.2

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.
@@ -38,15 +38,53 @@ export declare class Auth {
38
38
  set token(value: string);
39
39
  get authenticator(): string;
40
40
  set authenticator(value: string);
41
+ /**
42
+ * @internal
43
+ */
41
44
  getOption(key: string): string;
45
+ /**
46
+ * @internal
47
+ */
42
48
  setOption(key: string, value?: string): void;
49
+ /**
50
+ * @internal
51
+ * use {@link Auth#locale} instead
52
+ */
43
53
  getLocale(): string;
54
+ /**
55
+ * @internal
56
+ * use {@link Auth#locale} instead
57
+ */
44
58
  setLocale(locale: string): void;
59
+ /**
60
+ * @internal
61
+ * use {@link Auth#role} instead
62
+ */
45
63
  getRole(): string;
64
+ /**
65
+ * @internal
66
+ * use {@link Auth#role} instead
67
+ */
46
68
  setRole(role: string): void;
69
+ /**
70
+ * @internal
71
+ * use {@link Auth#token} instead
72
+ */
47
73
  getToken(): string;
74
+ /**
75
+ * @internal
76
+ * use {@link Auth#token} instead
77
+ */
48
78
  setToken(token: string): void;
79
+ /**
80
+ * @internal
81
+ * use {@link Auth#authenticator} instead
82
+ */
49
83
  getAuthenticator(): string;
84
+ /**
85
+ * @internal
86
+ * use {@link Auth#authenticator} instead
87
+ */
50
88
  setAuthenticator(authenticator: string): void;
51
89
  middleware(config: AxiosRequestConfig): AxiosRequestConfig<any>;
52
90
  signIn(values: any, authenticator?: string): Promise<AxiosResponse<any>>;
package/lib/APIClient.js CHANGED
@@ -61,7 +61,7 @@ const _Auth = class _Auth {
61
61
  if (typeof window === "undefined") {
62
62
  return;
63
63
  }
64
- const appName = (0, import_getSubAppName.default)();
64
+ const appName = (0, import_getSubAppName.default)(this.api["app"] ? this.api["app"].getPublicPath() : "/");
65
65
  if (!appName) {
66
66
  return;
67
67
  }
@@ -92,12 +92,18 @@ const _Auth = class _Auth {
92
92
  set authenticator(value) {
93
93
  this.setAuthenticator(value);
94
94
  }
95
+ /**
96
+ * @internal
97
+ */
95
98
  getOption(key) {
96
99
  if (!this.KEYS[key]) {
97
100
  return;
98
101
  }
99
102
  return this.api.storage.getItem(this.KEYS[key]);
100
103
  }
104
+ /**
105
+ * @internal
106
+ */
101
107
  setOption(key, value) {
102
108
  if (!this.KEYS[key]) {
103
109
  return;
@@ -105,27 +111,59 @@ const _Auth = class _Auth {
105
111
  this.options[key] = value;
106
112
  return this.api.storage.setItem(this.KEYS[key], value || "");
107
113
  }
114
+ /**
115
+ * @internal
116
+ * use {@link Auth#locale} instead
117
+ */
108
118
  getLocale() {
109
119
  return this.getOption("locale");
110
120
  }
121
+ /**
122
+ * @internal
123
+ * use {@link Auth#locale} instead
124
+ */
111
125
  setLocale(locale) {
112
126
  this.setOption("locale", locale);
113
127
  }
128
+ /**
129
+ * @internal
130
+ * use {@link Auth#role} instead
131
+ */
114
132
  getRole() {
115
133
  return this.getOption("role");
116
134
  }
135
+ /**
136
+ * @internal
137
+ * use {@link Auth#role} instead
138
+ */
117
139
  setRole(role) {
118
140
  this.setOption("role", role);
119
141
  }
142
+ /**
143
+ * @internal
144
+ * use {@link Auth#token} instead
145
+ */
120
146
  getToken() {
121
147
  return this.getOption("token");
122
148
  }
149
+ /**
150
+ * @internal
151
+ * use {@link Auth#token} instead
152
+ */
123
153
  setToken(token) {
124
154
  this.setOption("token", token);
125
155
  }
156
+ /**
157
+ * @internal
158
+ * use {@link Auth#authenticator} instead
159
+ */
126
160
  getAuthenticator() {
127
161
  return this.getOption("authenticator");
128
162
  }
163
+ /**
164
+ * @internal
165
+ * use {@link Auth#authenticator} instead
166
+ */
129
167
  setAuthenticator(authenticator) {
130
168
  this.setOption("authenticator", authenticator);
131
169
  }
@@ -1,2 +1,2 @@
1
- declare const getSubAppName: () => string;
1
+ declare const getSubAppName: (publicPath?: string) => string;
2
2
  export default getSubAppName;
@@ -21,11 +21,13 @@ __export(getSubAppName_exports, {
21
21
  default: () => getSubAppName_default
22
22
  });
23
23
  module.exports = __toCommonJS(getSubAppName_exports);
24
- const getSubAppName = /* @__PURE__ */ __name(() => {
25
- const match = window.location.pathname.match(/^\/apps\/([^/]*)\/?/);
26
- if (!match) {
27
- return "";
24
+ const getSubAppName = /* @__PURE__ */ __name((publicPath = "/") => {
25
+ const prefix = `${publicPath}apps/`;
26
+ if (!window.location.pathname.startsWith(prefix)) {
27
+ return;
28
28
  }
29
- return match[1];
29
+ const pathname = window.location.pathname.substring(prefix.length);
30
+ const args = pathname.split("/", 1);
31
+ return args[0] || "";
30
32
  }, "getSubAppName");
31
33
  var getSubAppName_default = getSubAppName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/sdk",
3
- "version": "0.20.0-alpha.9",
3
+ "version": "0.21.0-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -11,5 +11,5 @@
11
11
  "devDependencies": {
12
12
  "axios-mock-adapter": "^1.20.0"
13
13
  },
14
- "gitHead": "5473d9039cfdb649a8c8c625edefc9a3ac464be5"
14
+ "gitHead": "90628f2e2da846208fb2d7966ddb4e467d187ffb"
15
15
  }