@atomm-developer/generator-sdk 1.0.9 → 1.0.10
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/README.md
CHANGED
|
@@ -45,9 +45,15 @@ console.log(GeneratorSDK.getAppKey());
|
|
|
45
45
|
```javascript
|
|
46
46
|
// Login
|
|
47
47
|
const userInfo = await sdk.auth.login();
|
|
48
|
+
console.log(userInfo.roleList);
|
|
49
|
+
console.log(userInfo.isCommunityAdmin);
|
|
48
50
|
|
|
49
51
|
// Get current status
|
|
50
52
|
const { isLogin, userInfo } = sdk.auth.getStatus();
|
|
53
|
+
if (isLogin) {
|
|
54
|
+
console.log(userInfo.roleList);
|
|
55
|
+
console.log(userInfo.isCommunityAdmin);
|
|
56
|
+
}
|
|
51
57
|
|
|
52
58
|
// Logout
|
|
53
59
|
await sdk.auth.logout();
|
|
@@ -106,7 +112,7 @@ pnpm type-check
|
|
|
106
112
|
pnpm test:workbench
|
|
107
113
|
```
|
|
108
114
|
|
|
109
|
-
`pnpm deploy:cdn` uploads
|
|
115
|
+
`pnpm deploy:cdn` uploads the `generator-sdk` bundle, the `generator-workbench` UMD asset, the `generator-workbench/upgrade-manifest.json`, and the `generator-workbench` runtime dependencies under `atomm-pro/dist-browser` to `static-res.atomm.com`.
|
|
110
116
|
|
|
111
117
|
If you need to publish both packages from the repository root, use:
|
|
112
118
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { t as toUtf8, f as fromUtf8 } from "./index-
|
|
4
|
+
import { t as toUtf8, f as fromUtf8 } from "./index-Dhcrx-sO.js";
|
|
5
5
|
class EventStreamSerde {
|
|
6
6
|
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
|
|
7
7
|
__publicField(this, "marshaller");
|
|
@@ -10089,11 +10089,17 @@ class AuthModule {
|
|
|
10089
10089
|
*/
|
|
10090
10090
|
async _fetchUserInfo(token) {
|
|
10091
10091
|
this.passportClient.token = token;
|
|
10092
|
-
const response = await
|
|
10092
|
+
const [response, roleList] = await Promise.all([
|
|
10093
|
+
this.passportClient.userInfo(),
|
|
10094
|
+
this._fetchUserRoles()
|
|
10095
|
+
]);
|
|
10093
10096
|
const raw = (response == null ? void 0 : response.data) ?? response;
|
|
10094
10097
|
if (!(raw == null ? void 0 : raw.uid)) {
|
|
10095
10098
|
throw new Error("Invalid user info: missing uid");
|
|
10096
10099
|
}
|
|
10100
|
+
const isCommunityAdmin = roleList.some(
|
|
10101
|
+
(item) => item.code === "community_admin"
|
|
10102
|
+
);
|
|
10097
10103
|
return {
|
|
10098
10104
|
uid: raw.uid,
|
|
10099
10105
|
uuid: raw.uuid ?? String(raw.uid),
|
|
@@ -10104,9 +10110,24 @@ class AuthModule {
|
|
|
10104
10110
|
phoneZone: raw.phoneZone ?? "",
|
|
10105
10111
|
gender: raw.gender ?? 0,
|
|
10106
10112
|
signature: raw.signature ?? "",
|
|
10107
|
-
createTime: raw.createTime ?? 0
|
|
10113
|
+
createTime: raw.createTime ?? 0,
|
|
10114
|
+
roleList,
|
|
10115
|
+
isCommunityAdmin
|
|
10108
10116
|
};
|
|
10109
10117
|
}
|
|
10118
|
+
async _fetchUserRoles() {
|
|
10119
|
+
try {
|
|
10120
|
+
const roleList = await this.http.request({
|
|
10121
|
+
method: "GET",
|
|
10122
|
+
url: "/efficacy/v1/roles",
|
|
10123
|
+
params: { d: "xtool" }
|
|
10124
|
+
});
|
|
10125
|
+
return Array.isArray(roleList) ? roleList : [];
|
|
10126
|
+
} catch (error) {
|
|
10127
|
+
console.warn("[generator-sdk] fetch user roles failed", error);
|
|
10128
|
+
return [];
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10110
10131
|
_setLoginStatus(userInfo) {
|
|
10111
10132
|
this._status = { isLogin: true, userInfo };
|
|
10112
10133
|
this.emitter.emit("change", this.getStatus());
|
|
@@ -12287,7 +12308,7 @@ class HttpProtocol extends SerdeContext {
|
|
|
12287
12308
|
});
|
|
12288
12309
|
}
|
|
12289
12310
|
async loadEventStreamCapability() {
|
|
12290
|
-
const { EventStreamSerde } = await import("./index-
|
|
12311
|
+
const { EventStreamSerde } = await import("./index-Cf2OSJN2.js");
|
|
12291
12312
|
return new EventStreamSerde({
|
|
12292
12313
|
marshaller: this.getEventStreamMarshaller(),
|
|
12293
12314
|
serializer: this.serializer,
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ declare class AuthModule {
|
|
|
50
50
|
* 接口响应格式:{ code: 0, data: { uid, userName, headpic, uuid, email, ... } }
|
|
51
51
|
*/
|
|
52
52
|
private _fetchUserInfo;
|
|
53
|
+
private _fetchUserRoles;
|
|
53
54
|
private _setLoginStatus;
|
|
54
55
|
private _clearLoginStatus;
|
|
55
56
|
}
|
|
@@ -745,6 +746,16 @@ export declare interface UserInfo {
|
|
|
745
746
|
signature: string;
|
|
746
747
|
/** 账号创建时间(Unix 秒) */
|
|
747
748
|
createTime: number;
|
|
749
|
+
/** 用户角色列表 */
|
|
750
|
+
roleList: UserRole[];
|
|
751
|
+
/** 是否为社区管理员 */
|
|
752
|
+
isCommunityAdmin: boolean;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/** 用户信息 */
|
|
756
|
+
declare interface UserRole {
|
|
757
|
+
code: string;
|
|
758
|
+
[key: string]: unknown;
|
|
748
759
|
}
|
|
749
760
|
|
|
750
761
|
/**
|
package/dist/index.es.js
CHANGED