@atomm-developer/generator-sdk 1.0.8 → 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());
|
|
@@ -10159,6 +10180,7 @@ class BillingModule {
|
|
|
10159
10180
|
__publicField(this, "credits");
|
|
10160
10181
|
__publicField(this, "emitter", new EventEmitter());
|
|
10161
10182
|
/** 缓存的免费次数信息 */
|
|
10183
|
+
__publicField(this, "_isEnabled", false);
|
|
10162
10184
|
__publicField(this, "_freeRemaining", 0);
|
|
10163
10185
|
__publicField(this, "_freeTotal", 0);
|
|
10164
10186
|
__publicField(this, "_creditsPerUse", 0);
|
|
@@ -10186,6 +10208,7 @@ class BillingModule {
|
|
|
10186
10208
|
}),
|
|
10187
10209
|
this.credits.getBalance()
|
|
10188
10210
|
]);
|
|
10211
|
+
this._isEnabled = freeData.is_enabled;
|
|
10189
10212
|
this._freeRemaining = freeData.remaining_count;
|
|
10190
10213
|
this._freeTotal = freeData.total_count;
|
|
10191
10214
|
this._creditsPerUse = freeData.need_credits;
|
|
@@ -10277,6 +10300,7 @@ class BillingModule {
|
|
|
10277
10300
|
const inFreePeriod = now < this._freePeriodEnd;
|
|
10278
10301
|
const freePeriodRemaining = inFreePeriod ? Math.ceil((this._freePeriodEnd - now) / 1e3) : 0;
|
|
10279
10302
|
return {
|
|
10303
|
+
isEnabled: this._isEnabled,
|
|
10280
10304
|
freeRemaining: this._freeRemaining,
|
|
10281
10305
|
freeTotal: this._freeTotal,
|
|
10282
10306
|
creditsPerUse: this._creditsPerUse,
|
|
@@ -12284,7 +12308,7 @@ class HttpProtocol extends SerdeContext {
|
|
|
12284
12308
|
});
|
|
12285
12309
|
}
|
|
12286
12310
|
async loadEventStreamCapability() {
|
|
12287
|
-
const { EventStreamSerde } = await import("./index-
|
|
12311
|
+
const { EventStreamSerde } = await import("./index-Cf2OSJN2.js");
|
|
12288
12312
|
return new EventStreamSerde({
|
|
12289
12313
|
marshaller: this.getEventStreamMarshaller(),
|
|
12290
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
|
}
|
|
@@ -95,6 +96,7 @@ declare class BillingModule {
|
|
|
95
96
|
private readonly credits;
|
|
96
97
|
private readonly emitter;
|
|
97
98
|
/** 缓存的免费次数信息 */
|
|
99
|
+
private _isEnabled;
|
|
98
100
|
private _freeRemaining;
|
|
99
101
|
private _freeTotal;
|
|
100
102
|
private _creditsPerUse;
|
|
@@ -712,6 +714,8 @@ export declare interface TemplateRuntimeSnapshot {
|
|
|
712
714
|
|
|
713
715
|
/** 使用额度信息(整合免费次数 + 积分余额 + 免费时段) */
|
|
714
716
|
export declare interface UsageInfo {
|
|
717
|
+
/** 当前模块是否启用计费 */
|
|
718
|
+
isEnabled: boolean;
|
|
715
719
|
/** 剩余免费次数 */
|
|
716
720
|
freeRemaining: number;
|
|
717
721
|
/** 免费总次数 */
|
|
@@ -742,6 +746,16 @@ export declare interface UserInfo {
|
|
|
742
746
|
signature: string;
|
|
743
747
|
/** 账号创建时间(Unix 秒) */
|
|
744
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;
|
|
745
759
|
}
|
|
746
760
|
|
|
747
761
|
/**
|
package/dist/index.es.js
CHANGED