@peijundev/screenscoreboard-sdk 0.1.0 → 0.2.0
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/CHANGELOG.md +24 -0
- package/README.md +65 -5
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/resources/auth.d.ts +9 -1
- package/dist/cjs/resources/auth.js +16 -0
- package/dist/cjs/resources/buzz.d.ts +16 -0
- package/dist/cjs/resources/buzz.js +29 -0
- package/dist/cjs/resources/runtime.d.ts +2 -0
- package/dist/cjs/resources/runtime.js +3 -0
- package/dist/cjs/types.d.ts +71 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/resources/auth.d.ts +9 -1
- package/dist/esm/resources/auth.js +16 -0
- package/dist/esm/resources/buzz.d.ts +16 -0
- package/dist/esm/resources/buzz.js +25 -0
- package/dist/esm/resources/runtime.d.ts +2 -0
- package/dist/esm/resources/runtime.js +3 -0
- package/dist/esm/types.d.ts +71 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 变更日志
|
|
2
|
+
|
|
3
|
+
## 0.2.0 — 队员账号与抢答(2026-12-06)
|
|
4
|
+
|
|
5
|
+
### 新增
|
|
6
|
+
|
|
7
|
+
- `client.runtime.buzz`:`start()` / `end()` / `next()` / `press(projectId, buttonId)`。
|
|
8
|
+
- `client.auth.users.setMembersDisabled(disabled)`:批量停用 / 启用全部 `member` 账号。
|
|
9
|
+
- `CreateUserInput` / `UpdateUserInput` 增加 `memberProjectId` / `memberPersonId`,`User` 返回队员绑定字段。
|
|
10
|
+
- 抢答运行态类型:`BuzzRuntime`、`BuzzWinner`、`BuzzHistoryEntry`、`BuzzEndResult`、`BuzzPressResult`;`RuntimeSnapshot.buzz` / `buzzHistory` 由 `unknown` 改为具体类型。
|
|
11
|
+
- `AccessSettings` 与 `auth.getAccess()` / `auth.updateAccess()`(0.1.0 之后累积但此前未发布)。
|
|
12
|
+
- `Health.storageOk`、`RuntimeSnapshot.scoreEvents`、`AuthStatus.openAccess` / `requireLogin`。
|
|
13
|
+
|
|
14
|
+
### 测试
|
|
15
|
+
|
|
16
|
+
- 单元测试覆盖抢答、批量停用与队员绑定字段的请求路径与请求体。
|
|
17
|
+
- 集成测试对真实服务端验证抢答开始 / 下一轮 / 结束、队员账号创建与批量停用。
|
|
18
|
+
|
|
19
|
+
## 0.1.0 — 首个公开版本(2026-11-21)
|
|
20
|
+
|
|
21
|
+
- REST API v1 与 MCP 客户端。
|
|
22
|
+
- 项目、人员、团队、分数、撤销、倒计时、手动突显、设置、运行态、主题、资源库与备份。
|
|
23
|
+
- API 令牌与账号密码会话(自动维护 Cookie / CSRF)。
|
|
24
|
+
- ESM + CommonJS 双格式与 TypeScript 类型。
|
package/README.md
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
ScreenScoreBoard 的 TypeScript / JavaScript SDK,一套代码同时接入 **REST API v1** 与 **MCP**,适合 Node 服务、浏览器管理页、AI Agent、自动化脚本和第三方应用。
|
|
4
4
|
|
|
5
|
-
- 零运行时依赖,Node
|
|
5
|
+
- 零运行时依赖,Node 24+ / 现代浏览器
|
|
6
6
|
- 支持 `Authorization: Bearer` API 令牌与账号密码会话(自动维护 Cookie / CSRF)
|
|
7
|
-
- 完整的 REST
|
|
7
|
+
- 完整的 REST 资源封装:项目、人员、团队、分数、手动突显、设置、运行态、抢答、主题、草稿、资源库、备份
|
|
8
|
+
- 队员账号:绑定项目与人员、按账号配置功能菜单、批量停用 / 启用
|
|
9
|
+
- 抢答:开始 / 结束 / 下一轮,以及队员按钮 `press()`
|
|
8
10
|
- MCP 客户端:`initialize`、`tools/list`、`tools/call`、`resources/list`、`resources/read`
|
|
9
11
|
- 统一错误类型、请求超时、`AbortSignal`、自定义 `fetch`
|
|
10
12
|
- ESM + CommonJS 双格式,自带 TypeScript 类型
|
|
11
13
|
|
|
12
14
|
> 本包是客户端 SDK,不包含计分板服务端。请先部署 ScreenScoreBoard。
|
|
15
|
+
>
|
|
16
|
+
> 0.2.0 新增:`runtime.buzz.*`、`auth.users.setMembersDisabled()`、队员账号绑定字段与抢答运行态类型。变更记录见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
13
17
|
|
|
14
18
|
## 安装
|
|
15
19
|
|
|
@@ -105,6 +109,23 @@ client.setSession({ cookie, csrfToken });
|
|
|
105
109
|
|
|
106
110
|
`auth.users.*`、为其他用户创建/吊销令牌等管理操作需要管理员;`auth.tokens.*` 与 `auth.sessions.*` 默认操作自己的账号。
|
|
107
111
|
|
|
112
|
+
### 访问控制(部署模式)
|
|
113
|
+
|
|
114
|
+
管理员可以在运行时决定是否使用登录系统:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
const access = await client.auth.getAccess();
|
|
118
|
+
console.log(access.requireLogin, access.openAccess, access.activeAdmins);
|
|
119
|
+
|
|
120
|
+
// 完全开放:所有访问者获得管理员权限(建议只在可信局域网/VPN)
|
|
121
|
+
await client.auth.updateAccess(false);
|
|
122
|
+
|
|
123
|
+
// 重新启用登录
|
|
124
|
+
await client.auth.updateAccess(true);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
> 关闭登录系统等同于把管理员权限交给所有访问者。服务端要求至少保留一个启用中的管理员,并会把设置持久化到 `auth.json`。
|
|
128
|
+
|
|
108
129
|
### 4. 浏览器
|
|
109
130
|
|
|
110
131
|
```ts
|
|
@@ -155,6 +176,45 @@ await client.runtime.countdown.resume(projectId);
|
|
|
155
176
|
await client.runtime.countdown.reset(projectId);
|
|
156
177
|
```
|
|
157
178
|
|
|
179
|
+
### 抢答与队员账号
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
// 先开启项目级抢答(默认关闭)
|
|
183
|
+
await client.settings.update(projectId, {
|
|
184
|
+
featureBuzzer: true,
|
|
185
|
+
buzzTimerMode: 'window',
|
|
186
|
+
buzzDurationSec: 10,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const round = await client.runtime.buzz.start(projectId);
|
|
190
|
+
console.log(round.roundId, round.phase);
|
|
191
|
+
|
|
192
|
+
await client.runtime.buzz.next(projectId); // 结束当前轮(写入历史)并立即开始下一轮
|
|
193
|
+
await client.runtime.buzz.end(projectId);
|
|
194
|
+
|
|
195
|
+
// 队员账号必须绑定项目与人员
|
|
196
|
+
const member = await client.auth.users.create({
|
|
197
|
+
username: 'member-01',
|
|
198
|
+
password: '至少 8 位',
|
|
199
|
+
role: 'member',
|
|
200
|
+
memberProjectId: projectId,
|
|
201
|
+
memberPersonId: person.id,
|
|
202
|
+
});
|
|
203
|
+
const memberToken = await client.auth.users.createToken(member.id, 'member-device');
|
|
204
|
+
|
|
205
|
+
// 队员端用人员菜单里的按钮 ID 抢答;只有本轮第一个有效请求返回 won: true
|
|
206
|
+
const memberClient = new ScreenScoreBoardClient({
|
|
207
|
+
baseUrl: BASE,
|
|
208
|
+
token: memberToken.token,
|
|
209
|
+
});
|
|
210
|
+
const press = await memberClient.runtime.buzz.press(projectId, 'button-id');
|
|
211
|
+
console.log(press.won, press.reason, press.winner);
|
|
212
|
+
|
|
213
|
+
// 批量停用 / 启用全部队员账号;停用会吊销其会话与令牌
|
|
214
|
+
const disabled = await client.auth.users.setMembersDisabled(true);
|
|
215
|
+
console.log(disabled.count, disabled.total);
|
|
216
|
+
```
|
|
217
|
+
|
|
158
218
|
### 设置与手动突显
|
|
159
219
|
|
|
160
220
|
```ts
|
|
@@ -304,9 +364,9 @@ await client.request('GET', '/state', { timeoutMs: 5000, signal: abortController
|
|
|
304
364
|
|
|
305
365
|
## 兼容性
|
|
306
366
|
|
|
307
|
-
- Node `>=
|
|
308
|
-
- 浏览器:现代 Chromium / Firefox / Safari
|
|
309
|
-
- 服务端:ScreenScoreBoard 1.6.
|
|
367
|
+
- Node `>=24`(需要全局 `fetch`;更旧环境可通过 `fetch` 选项注入)。
|
|
368
|
+
- 浏览器:现代 Chromium / Firefox / Safari(不受 Node `engines` 限制)。
|
|
369
|
+
- 服务端:ScreenScoreBoard 1.6.1+;手动突显与访问控制需要该版本。
|
|
310
370
|
- 包同时提供 ESM 与 CommonJS,无运行时依赖。
|
|
311
371
|
|
|
312
372
|
## 开发与发布(本仓库维护者)
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './http.js';
|
|
|
5
5
|
export * from './mcp.js';
|
|
6
6
|
export * from './client.js';
|
|
7
7
|
export * from './resources/auth.js';
|
|
8
|
+
export * from './resources/buzz.js';
|
|
8
9
|
export * from './resources/data.js';
|
|
9
10
|
export * from './resources/ops.js';
|
|
10
11
|
export * from './resources/people.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./http.js"), exports);
|
|
|
22
22
|
__exportStar(require("./mcp.js"), exports);
|
|
23
23
|
__exportStar(require("./client.js"), exports);
|
|
24
24
|
__exportStar(require("./resources/auth.js"), exports);
|
|
25
|
+
__exportStar(require("./resources/buzz.js"), exports);
|
|
25
26
|
__exportStar(require("./resources/data.js"), exports);
|
|
26
27
|
__exportStar(require("./resources/ops.js"), exports);
|
|
27
28
|
__exportStar(require("./resources/people.js"), exports);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
|
-
import type { ApiToken, AuthSession, AuthStatus, CreateTokenInput, CreateUserInput, MeResult, UpdateUserInput, User } from '../types.js';
|
|
2
|
+
import type { AccessSettings, ApiToken, AuthSession, AuthStatus, CreateTokenInput, CreateUserInput, MeResult, MemberDisabledResult, UpdateUserInput, User } from '../types.js';
|
|
3
3
|
export declare class AuthUsersApi {
|
|
4
4
|
private readonly http;
|
|
5
5
|
constructor(http: HttpClient);
|
|
6
6
|
list(): Promise<User[]>;
|
|
7
|
+
/** 批量停用 / 启用全部 role=member 的账号;停用会立即吊销其会话与令牌。 */
|
|
8
|
+
setMembersDisabled(disabled: boolean): Promise<MemberDisabledResult>;
|
|
7
9
|
create(input: CreateUserInput): Promise<User>;
|
|
8
10
|
update(userId: string, patch: UpdateUserInput): Promise<User>;
|
|
9
11
|
delete(userId: string): Promise<{
|
|
@@ -54,6 +56,12 @@ export declare class AuthApi {
|
|
|
54
56
|
logout(): Promise<void>;
|
|
55
57
|
setup(username: string, password: string): Promise<User>;
|
|
56
58
|
me(): Promise<MeResult>;
|
|
59
|
+
getAccess(): Promise<AccessSettings>;
|
|
60
|
+
/**
|
|
61
|
+
* 启用/关闭登录系统。`requireLogin: false` 会让所有访问者获得管理员权限。
|
|
62
|
+
* 至少需要一个启用中的管理员。
|
|
63
|
+
*/
|
|
64
|
+
updateAccess(requireLogin: boolean): Promise<AccessSettings>;
|
|
57
65
|
changePassword(currentPassword: string, newPassword: string): Promise<{
|
|
58
66
|
ok: boolean;
|
|
59
67
|
}>;
|
|
@@ -12,6 +12,10 @@ class AuthUsersApi {
|
|
|
12
12
|
.request('GET', '/auth/users')
|
|
13
13
|
.then((result) => result.users);
|
|
14
14
|
}
|
|
15
|
+
/** 批量停用 / 启用全部 role=member 的账号;停用会立即吊销其会话与令牌。 */
|
|
16
|
+
setMembersDisabled(disabled) {
|
|
17
|
+
return this.http.request('POST', '/auth/users/members/disabled', { body: { disabled } });
|
|
18
|
+
}
|
|
15
19
|
create(input) {
|
|
16
20
|
return this.http
|
|
17
21
|
.request('POST', '/auth/users', { body: input })
|
|
@@ -122,6 +126,18 @@ class AuthApi {
|
|
|
122
126
|
me() {
|
|
123
127
|
return this.http.request('GET', '/auth/me');
|
|
124
128
|
}
|
|
129
|
+
getAccess() {
|
|
130
|
+
return this.http.request('GET', '/auth/access');
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 启用/关闭登录系统。`requireLogin: false` 会让所有访问者获得管理员权限。
|
|
134
|
+
* 至少需要一个启用中的管理员。
|
|
135
|
+
*/
|
|
136
|
+
updateAccess(requireLogin) {
|
|
137
|
+
return this.http.request('PATCH', '/auth/access', {
|
|
138
|
+
body: { requireLogin },
|
|
139
|
+
});
|
|
140
|
+
}
|
|
125
141
|
changePassword(currentPassword, newPassword) {
|
|
126
142
|
return this.http.request('POST', '/auth/password', {
|
|
127
143
|
body: { currentPassword, newPassword },
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { BuzzEndResult, BuzzPressResult, BuzzRuntime } from '../types.js';
|
|
3
|
+
/** 抢答:开始 / 结束 / 下一轮,以及队员按钮抢答。 */
|
|
4
|
+
export declare class BuzzApi {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
start(projectId: string): Promise<BuzzRuntime>;
|
|
8
|
+
end(projectId: string): Promise<BuzzEndResult>;
|
|
9
|
+
/** 结束当前轮(写入历史)并立即开始下一轮。 */
|
|
10
|
+
next(projectId: string): Promise<BuzzRuntime>;
|
|
11
|
+
/**
|
|
12
|
+
* 队员按钮抢答。只有本轮第一个有效请求会返回 `won: true`;
|
|
13
|
+
* 需要队员账号令牌,且按钮已在人员功能菜单中配置。
|
|
14
|
+
*/
|
|
15
|
+
press(projectId: string, buttonId: string): Promise<BuzzPressResult>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuzzApi = void 0;
|
|
4
|
+
const path_js_1 = require("../path.js");
|
|
5
|
+
/** 抢答:开始 / 结束 / 下一轮,以及队员按钮抢答。 */
|
|
6
|
+
class BuzzApi {
|
|
7
|
+
http;
|
|
8
|
+
constructor(http) {
|
|
9
|
+
this.http = http;
|
|
10
|
+
}
|
|
11
|
+
start(projectId) {
|
|
12
|
+
return this.http.request('POST', `/projects/${(0, path_js_1.enc)(projectId)}/buzz/start`);
|
|
13
|
+
}
|
|
14
|
+
end(projectId) {
|
|
15
|
+
return this.http.request('POST', `/projects/${(0, path_js_1.enc)(projectId)}/buzz/end`);
|
|
16
|
+
}
|
|
17
|
+
/** 结束当前轮(写入历史)并立即开始下一轮。 */
|
|
18
|
+
next(projectId) {
|
|
19
|
+
return this.http.request('POST', `/projects/${(0, path_js_1.enc)(projectId)}/buzz/next`);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 队员按钮抢答。只有本轮第一个有效请求会返回 `won: true`;
|
|
23
|
+
* 需要队员账号令牌,且按钮已在人员功能菜单中配置。
|
|
24
|
+
*/
|
|
25
|
+
press(projectId, buttonId) {
|
|
26
|
+
return this.http.request('POST', `/projects/${(0, path_js_1.enc)(projectId)}/buzz/press`, { body: { buttonId } });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.BuzzApi = BuzzApi;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
2
|
import type { CountdownRuntime, ProjectRuntime } from '../types.js';
|
|
3
|
+
import { BuzzApi } from './buzz.js';
|
|
3
4
|
export interface UndoResult {
|
|
4
5
|
label: string;
|
|
5
6
|
undoCount: number;
|
|
@@ -22,6 +23,7 @@ export declare class CountdownApi {
|
|
|
22
23
|
export declare class RuntimeApi {
|
|
23
24
|
private readonly http;
|
|
24
25
|
readonly countdown: CountdownApi;
|
|
26
|
+
readonly buzz: BuzzApi;
|
|
25
27
|
constructor(http: HttpClient);
|
|
26
28
|
get(projectId: string): Promise<ProjectRuntime>;
|
|
27
29
|
undo(projectId: string): Promise<UndoResult>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RuntimeApi = exports.CountdownApi = void 0;
|
|
4
4
|
const path_js_1 = require("../path.js");
|
|
5
|
+
const buzz_js_1 = require("./buzz.js");
|
|
5
6
|
class CountdownApi {
|
|
6
7
|
http;
|
|
7
8
|
constructor(http) {
|
|
@@ -24,9 +25,11 @@ exports.CountdownApi = CountdownApi;
|
|
|
24
25
|
class RuntimeApi {
|
|
25
26
|
http;
|
|
26
27
|
countdown;
|
|
28
|
+
buzz;
|
|
27
29
|
constructor(http) {
|
|
28
30
|
this.http = http;
|
|
29
31
|
this.countdown = new CountdownApi(http);
|
|
32
|
+
this.buzz = new buzz_js_1.BuzzApi(http);
|
|
30
33
|
}
|
|
31
34
|
get(projectId) {
|
|
32
35
|
return this.http.request('GET', `/projects/${(0, path_js_1.enc)(projectId)}/runtime`);
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface Health {
|
|
|
14
14
|
version: string;
|
|
15
15
|
uptimeSec: number;
|
|
16
16
|
storage: string;
|
|
17
|
+
/** 存储无冲突/保存正常;旧版服务端可能不返回 */
|
|
18
|
+
storageOk?: boolean;
|
|
17
19
|
wsClients: number;
|
|
18
20
|
projects: number;
|
|
19
21
|
ts: number;
|
|
@@ -129,6 +131,13 @@ export interface ScoreLogEntry {
|
|
|
129
131
|
label: string;
|
|
130
132
|
delta: number;
|
|
131
133
|
}
|
|
134
|
+
export interface ScoreEvent {
|
|
135
|
+
seq: number;
|
|
136
|
+
targetType: 'person' | 'team';
|
|
137
|
+
targetId: string;
|
|
138
|
+
delta: number;
|
|
139
|
+
at: number;
|
|
140
|
+
}
|
|
132
141
|
export interface SpotlightEvent {
|
|
133
142
|
seq: number;
|
|
134
143
|
targetType: 'person' | 'team' | string;
|
|
@@ -136,12 +145,53 @@ export interface SpotlightEvent {
|
|
|
136
145
|
at: number;
|
|
137
146
|
durationMs?: number;
|
|
138
147
|
}
|
|
148
|
+
export interface BuzzWinner {
|
|
149
|
+
userId: string;
|
|
150
|
+
username: string;
|
|
151
|
+
personId: string;
|
|
152
|
+
personName: string;
|
|
153
|
+
teamId: string | null;
|
|
154
|
+
teamName: string;
|
|
155
|
+
targetType: 'person' | 'team';
|
|
156
|
+
targetId: string;
|
|
157
|
+
targetName: string;
|
|
158
|
+
buttonId: string;
|
|
159
|
+
at: number;
|
|
160
|
+
}
|
|
161
|
+
export interface BuzzRuntime {
|
|
162
|
+
roundId: number;
|
|
163
|
+
mode: 'prepare' | 'window';
|
|
164
|
+
phase: 'prepare' | 'open' | 'locked';
|
|
165
|
+
startedAt: number;
|
|
166
|
+
endsAt: number;
|
|
167
|
+
durationMs: number;
|
|
168
|
+
winner: BuzzWinner | null;
|
|
169
|
+
}
|
|
170
|
+
export interface BuzzHistoryEntry {
|
|
171
|
+
roundId: number;
|
|
172
|
+
mode: 'prepare' | 'window';
|
|
173
|
+
startedAt: number;
|
|
174
|
+
endedAt: number;
|
|
175
|
+
winner: BuzzWinner | null;
|
|
176
|
+
}
|
|
177
|
+
export interface BuzzEndResult {
|
|
178
|
+
ended: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface BuzzPressResult {
|
|
181
|
+
won: boolean;
|
|
182
|
+
reason?: string;
|
|
183
|
+
winner?: BuzzWinner;
|
|
184
|
+
warning?: string;
|
|
185
|
+
}
|
|
139
186
|
export interface RuntimeSnapshot {
|
|
140
187
|
undoCounts: Record<string, number>;
|
|
141
188
|
undoLabels?: Record<string, UndoLabel[]>;
|
|
142
189
|
scoreLogs?: Record<string, ScoreLogEntry[]>;
|
|
190
|
+
scoreEvents?: Record<string, ScoreEvent[]>;
|
|
143
191
|
countdowns: Record<string, CountdownRuntime>;
|
|
144
192
|
spotlightEvents?: Record<string, SpotlightEvent[]>;
|
|
193
|
+
buzz?: Record<string, BuzzRuntime>;
|
|
194
|
+
buzzHistory?: Record<string, BuzzHistoryEntry[]>;
|
|
145
195
|
serverNow?: number;
|
|
146
196
|
}
|
|
147
197
|
export interface ProjectRuntime {
|
|
@@ -225,17 +275,28 @@ export interface User {
|
|
|
225
275
|
displayName?: string;
|
|
226
276
|
role: Role;
|
|
227
277
|
disabled?: boolean;
|
|
278
|
+
/** 队员账号绑定的项目;非 member 角色为 null。 */
|
|
279
|
+
memberProjectId?: string | null;
|
|
280
|
+
/** 队员账号绑定的人员;非 member 角色为 null。 */
|
|
281
|
+
memberPersonId?: string | null;
|
|
228
282
|
createdAt?: string;
|
|
229
283
|
updatedAt?: string;
|
|
230
284
|
lastLoginAt?: string | null;
|
|
231
285
|
}
|
|
232
286
|
export interface AuthStatus {
|
|
233
287
|
authEnabled: boolean;
|
|
288
|
+
openAccess?: boolean;
|
|
289
|
+
requireLogin?: boolean;
|
|
234
290
|
setupRequired: boolean;
|
|
235
291
|
setupAllowed: boolean;
|
|
236
292
|
authenticated: boolean;
|
|
237
293
|
user: User | null;
|
|
238
294
|
}
|
|
295
|
+
export interface AccessSettings {
|
|
296
|
+
requireLogin: boolean;
|
|
297
|
+
openAccess: boolean;
|
|
298
|
+
activeAdmins: number;
|
|
299
|
+
}
|
|
239
300
|
export interface AuthSession {
|
|
240
301
|
id: string;
|
|
241
302
|
createdAt: string;
|
|
@@ -363,11 +424,21 @@ export interface CreateUserInput {
|
|
|
363
424
|
password: string;
|
|
364
425
|
role?: Role;
|
|
365
426
|
displayName?: string;
|
|
427
|
+
/** role=member 时必填:绑定的项目与人员。 */
|
|
428
|
+
memberProjectId?: string | null;
|
|
429
|
+
memberPersonId?: string | null;
|
|
366
430
|
}
|
|
367
431
|
export interface UpdateUserInput {
|
|
368
432
|
role?: Role;
|
|
369
433
|
displayName?: string;
|
|
370
434
|
disabled?: boolean;
|
|
435
|
+
memberProjectId?: string | null;
|
|
436
|
+
memberPersonId?: string | null;
|
|
437
|
+
}
|
|
438
|
+
export interface MemberDisabledResult {
|
|
439
|
+
count: number;
|
|
440
|
+
total: number;
|
|
441
|
+
disabled: boolean;
|
|
371
442
|
}
|
|
372
443
|
export interface CreateTokenInput {
|
|
373
444
|
name?: string;
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.2.0";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './http.js';
|
|
|
5
5
|
export * from './mcp.js';
|
|
6
6
|
export * from './client.js';
|
|
7
7
|
export * from './resources/auth.js';
|
|
8
|
+
export * from './resources/buzz.js';
|
|
8
9
|
export * from './resources/data.js';
|
|
9
10
|
export * from './resources/ops.js';
|
|
10
11
|
export * from './resources/people.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from './http.js';
|
|
|
5
5
|
export * from './mcp.js';
|
|
6
6
|
export * from './client.js';
|
|
7
7
|
export * from './resources/auth.js';
|
|
8
|
+
export * from './resources/buzz.js';
|
|
8
9
|
export * from './resources/data.js';
|
|
9
10
|
export * from './resources/ops.js';
|
|
10
11
|
export * from './resources/people.js';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
|
-
import type { ApiToken, AuthSession, AuthStatus, CreateTokenInput, CreateUserInput, MeResult, UpdateUserInput, User } from '../types.js';
|
|
2
|
+
import type { AccessSettings, ApiToken, AuthSession, AuthStatus, CreateTokenInput, CreateUserInput, MeResult, MemberDisabledResult, UpdateUserInput, User } from '../types.js';
|
|
3
3
|
export declare class AuthUsersApi {
|
|
4
4
|
private readonly http;
|
|
5
5
|
constructor(http: HttpClient);
|
|
6
6
|
list(): Promise<User[]>;
|
|
7
|
+
/** 批量停用 / 启用全部 role=member 的账号;停用会立即吊销其会话与令牌。 */
|
|
8
|
+
setMembersDisabled(disabled: boolean): Promise<MemberDisabledResult>;
|
|
7
9
|
create(input: CreateUserInput): Promise<User>;
|
|
8
10
|
update(userId: string, patch: UpdateUserInput): Promise<User>;
|
|
9
11
|
delete(userId: string): Promise<{
|
|
@@ -54,6 +56,12 @@ export declare class AuthApi {
|
|
|
54
56
|
logout(): Promise<void>;
|
|
55
57
|
setup(username: string, password: string): Promise<User>;
|
|
56
58
|
me(): Promise<MeResult>;
|
|
59
|
+
getAccess(): Promise<AccessSettings>;
|
|
60
|
+
/**
|
|
61
|
+
* 启用/关闭登录系统。`requireLogin: false` 会让所有访问者获得管理员权限。
|
|
62
|
+
* 至少需要一个启用中的管理员。
|
|
63
|
+
*/
|
|
64
|
+
updateAccess(requireLogin: boolean): Promise<AccessSettings>;
|
|
57
65
|
changePassword(currentPassword: string, newPassword: string): Promise<{
|
|
58
66
|
ok: boolean;
|
|
59
67
|
}>;
|
|
@@ -9,6 +9,10 @@ export class AuthUsersApi {
|
|
|
9
9
|
.request('GET', '/auth/users')
|
|
10
10
|
.then((result) => result.users);
|
|
11
11
|
}
|
|
12
|
+
/** 批量停用 / 启用全部 role=member 的账号;停用会立即吊销其会话与令牌。 */
|
|
13
|
+
setMembersDisabled(disabled) {
|
|
14
|
+
return this.http.request('POST', '/auth/users/members/disabled', { body: { disabled } });
|
|
15
|
+
}
|
|
12
16
|
create(input) {
|
|
13
17
|
return this.http
|
|
14
18
|
.request('POST', '/auth/users', { body: input })
|
|
@@ -116,6 +120,18 @@ export class AuthApi {
|
|
|
116
120
|
me() {
|
|
117
121
|
return this.http.request('GET', '/auth/me');
|
|
118
122
|
}
|
|
123
|
+
getAccess() {
|
|
124
|
+
return this.http.request('GET', '/auth/access');
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 启用/关闭登录系统。`requireLogin: false` 会让所有访问者获得管理员权限。
|
|
128
|
+
* 至少需要一个启用中的管理员。
|
|
129
|
+
*/
|
|
130
|
+
updateAccess(requireLogin) {
|
|
131
|
+
return this.http.request('PATCH', '/auth/access', {
|
|
132
|
+
body: { requireLogin },
|
|
133
|
+
});
|
|
134
|
+
}
|
|
119
135
|
changePassword(currentPassword, newPassword) {
|
|
120
136
|
return this.http.request('POST', '/auth/password', {
|
|
121
137
|
body: { currentPassword, newPassword },
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { BuzzEndResult, BuzzPressResult, BuzzRuntime } from '../types.js';
|
|
3
|
+
/** 抢答:开始 / 结束 / 下一轮,以及队员按钮抢答。 */
|
|
4
|
+
export declare class BuzzApi {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
start(projectId: string): Promise<BuzzRuntime>;
|
|
8
|
+
end(projectId: string): Promise<BuzzEndResult>;
|
|
9
|
+
/** 结束当前轮(写入历史)并立即开始下一轮。 */
|
|
10
|
+
next(projectId: string): Promise<BuzzRuntime>;
|
|
11
|
+
/**
|
|
12
|
+
* 队员按钮抢答。只有本轮第一个有效请求会返回 `won: true`;
|
|
13
|
+
* 需要队员账号令牌,且按钮已在人员功能菜单中配置。
|
|
14
|
+
*/
|
|
15
|
+
press(projectId: string, buttonId: string): Promise<BuzzPressResult>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { enc } from '../path.js';
|
|
2
|
+
/** 抢答:开始 / 结束 / 下一轮,以及队员按钮抢答。 */
|
|
3
|
+
export class BuzzApi {
|
|
4
|
+
http;
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
start(projectId) {
|
|
9
|
+
return this.http.request('POST', `/projects/${enc(projectId)}/buzz/start`);
|
|
10
|
+
}
|
|
11
|
+
end(projectId) {
|
|
12
|
+
return this.http.request('POST', `/projects/${enc(projectId)}/buzz/end`);
|
|
13
|
+
}
|
|
14
|
+
/** 结束当前轮(写入历史)并立即开始下一轮。 */
|
|
15
|
+
next(projectId) {
|
|
16
|
+
return this.http.request('POST', `/projects/${enc(projectId)}/buzz/next`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 队员按钮抢答。只有本轮第一个有效请求会返回 `won: true`;
|
|
20
|
+
* 需要队员账号令牌,且按钮已在人员功能菜单中配置。
|
|
21
|
+
*/
|
|
22
|
+
press(projectId, buttonId) {
|
|
23
|
+
return this.http.request('POST', `/projects/${enc(projectId)}/buzz/press`, { body: { buttonId } });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
2
|
import type { CountdownRuntime, ProjectRuntime } from '../types.js';
|
|
3
|
+
import { BuzzApi } from './buzz.js';
|
|
3
4
|
export interface UndoResult {
|
|
4
5
|
label: string;
|
|
5
6
|
undoCount: number;
|
|
@@ -22,6 +23,7 @@ export declare class CountdownApi {
|
|
|
22
23
|
export declare class RuntimeApi {
|
|
23
24
|
private readonly http;
|
|
24
25
|
readonly countdown: CountdownApi;
|
|
26
|
+
readonly buzz: BuzzApi;
|
|
25
27
|
constructor(http: HttpClient);
|
|
26
28
|
get(projectId: string): Promise<ProjectRuntime>;
|
|
27
29
|
undo(projectId: string): Promise<UndoResult>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { enc } from '../path.js';
|
|
2
|
+
import { BuzzApi } from './buzz.js';
|
|
2
3
|
export class CountdownApi {
|
|
3
4
|
http;
|
|
4
5
|
constructor(http) {
|
|
@@ -20,9 +21,11 @@ export class CountdownApi {
|
|
|
20
21
|
export class RuntimeApi {
|
|
21
22
|
http;
|
|
22
23
|
countdown;
|
|
24
|
+
buzz;
|
|
23
25
|
constructor(http) {
|
|
24
26
|
this.http = http;
|
|
25
27
|
this.countdown = new CountdownApi(http);
|
|
28
|
+
this.buzz = new BuzzApi(http);
|
|
26
29
|
}
|
|
27
30
|
get(projectId) {
|
|
28
31
|
return this.http.request('GET', `/projects/${enc(projectId)}/runtime`);
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface Health {
|
|
|
14
14
|
version: string;
|
|
15
15
|
uptimeSec: number;
|
|
16
16
|
storage: string;
|
|
17
|
+
/** 存储无冲突/保存正常;旧版服务端可能不返回 */
|
|
18
|
+
storageOk?: boolean;
|
|
17
19
|
wsClients: number;
|
|
18
20
|
projects: number;
|
|
19
21
|
ts: number;
|
|
@@ -129,6 +131,13 @@ export interface ScoreLogEntry {
|
|
|
129
131
|
label: string;
|
|
130
132
|
delta: number;
|
|
131
133
|
}
|
|
134
|
+
export interface ScoreEvent {
|
|
135
|
+
seq: number;
|
|
136
|
+
targetType: 'person' | 'team';
|
|
137
|
+
targetId: string;
|
|
138
|
+
delta: number;
|
|
139
|
+
at: number;
|
|
140
|
+
}
|
|
132
141
|
export interface SpotlightEvent {
|
|
133
142
|
seq: number;
|
|
134
143
|
targetType: 'person' | 'team' | string;
|
|
@@ -136,12 +145,53 @@ export interface SpotlightEvent {
|
|
|
136
145
|
at: number;
|
|
137
146
|
durationMs?: number;
|
|
138
147
|
}
|
|
148
|
+
export interface BuzzWinner {
|
|
149
|
+
userId: string;
|
|
150
|
+
username: string;
|
|
151
|
+
personId: string;
|
|
152
|
+
personName: string;
|
|
153
|
+
teamId: string | null;
|
|
154
|
+
teamName: string;
|
|
155
|
+
targetType: 'person' | 'team';
|
|
156
|
+
targetId: string;
|
|
157
|
+
targetName: string;
|
|
158
|
+
buttonId: string;
|
|
159
|
+
at: number;
|
|
160
|
+
}
|
|
161
|
+
export interface BuzzRuntime {
|
|
162
|
+
roundId: number;
|
|
163
|
+
mode: 'prepare' | 'window';
|
|
164
|
+
phase: 'prepare' | 'open' | 'locked';
|
|
165
|
+
startedAt: number;
|
|
166
|
+
endsAt: number;
|
|
167
|
+
durationMs: number;
|
|
168
|
+
winner: BuzzWinner | null;
|
|
169
|
+
}
|
|
170
|
+
export interface BuzzHistoryEntry {
|
|
171
|
+
roundId: number;
|
|
172
|
+
mode: 'prepare' | 'window';
|
|
173
|
+
startedAt: number;
|
|
174
|
+
endedAt: number;
|
|
175
|
+
winner: BuzzWinner | null;
|
|
176
|
+
}
|
|
177
|
+
export interface BuzzEndResult {
|
|
178
|
+
ended: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface BuzzPressResult {
|
|
181
|
+
won: boolean;
|
|
182
|
+
reason?: string;
|
|
183
|
+
winner?: BuzzWinner;
|
|
184
|
+
warning?: string;
|
|
185
|
+
}
|
|
139
186
|
export interface RuntimeSnapshot {
|
|
140
187
|
undoCounts: Record<string, number>;
|
|
141
188
|
undoLabels?: Record<string, UndoLabel[]>;
|
|
142
189
|
scoreLogs?: Record<string, ScoreLogEntry[]>;
|
|
190
|
+
scoreEvents?: Record<string, ScoreEvent[]>;
|
|
143
191
|
countdowns: Record<string, CountdownRuntime>;
|
|
144
192
|
spotlightEvents?: Record<string, SpotlightEvent[]>;
|
|
193
|
+
buzz?: Record<string, BuzzRuntime>;
|
|
194
|
+
buzzHistory?: Record<string, BuzzHistoryEntry[]>;
|
|
145
195
|
serverNow?: number;
|
|
146
196
|
}
|
|
147
197
|
export interface ProjectRuntime {
|
|
@@ -225,17 +275,28 @@ export interface User {
|
|
|
225
275
|
displayName?: string;
|
|
226
276
|
role: Role;
|
|
227
277
|
disabled?: boolean;
|
|
278
|
+
/** 队员账号绑定的项目;非 member 角色为 null。 */
|
|
279
|
+
memberProjectId?: string | null;
|
|
280
|
+
/** 队员账号绑定的人员;非 member 角色为 null。 */
|
|
281
|
+
memberPersonId?: string | null;
|
|
228
282
|
createdAt?: string;
|
|
229
283
|
updatedAt?: string;
|
|
230
284
|
lastLoginAt?: string | null;
|
|
231
285
|
}
|
|
232
286
|
export interface AuthStatus {
|
|
233
287
|
authEnabled: boolean;
|
|
288
|
+
openAccess?: boolean;
|
|
289
|
+
requireLogin?: boolean;
|
|
234
290
|
setupRequired: boolean;
|
|
235
291
|
setupAllowed: boolean;
|
|
236
292
|
authenticated: boolean;
|
|
237
293
|
user: User | null;
|
|
238
294
|
}
|
|
295
|
+
export interface AccessSettings {
|
|
296
|
+
requireLogin: boolean;
|
|
297
|
+
openAccess: boolean;
|
|
298
|
+
activeAdmins: number;
|
|
299
|
+
}
|
|
239
300
|
export interface AuthSession {
|
|
240
301
|
id: string;
|
|
241
302
|
createdAt: string;
|
|
@@ -363,11 +424,21 @@ export interface CreateUserInput {
|
|
|
363
424
|
password: string;
|
|
364
425
|
role?: Role;
|
|
365
426
|
displayName?: string;
|
|
427
|
+
/** role=member 时必填:绑定的项目与人员。 */
|
|
428
|
+
memberProjectId?: string | null;
|
|
429
|
+
memberPersonId?: string | null;
|
|
366
430
|
}
|
|
367
431
|
export interface UpdateUserInput {
|
|
368
432
|
role?: Role;
|
|
369
433
|
displayName?: string;
|
|
370
434
|
disabled?: boolean;
|
|
435
|
+
memberProjectId?: string | null;
|
|
436
|
+
memberPersonId?: string | null;
|
|
437
|
+
}
|
|
438
|
+
export interface MemberDisabledResult {
|
|
439
|
+
count: number;
|
|
440
|
+
total: number;
|
|
441
|
+
disabled: boolean;
|
|
371
442
|
}
|
|
372
443
|
export interface CreateTokenInput {
|
|
373
444
|
name?: string;
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.2.0";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.
|
|
1
|
+
export const SDK_VERSION = '0.2.0';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peijundev/screenscoreboard-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "ScreenScoreBoard REST API v1 与 MCP 的 TypeScript/JavaScript SDK(Node / 浏览器 / AI
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "ScreenScoreBoard REST API v1 与 MCP 的 TypeScript/JavaScript SDK(Node / 浏览器 / AI 接入,含队员控制台与抢答)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "peijundev"
|
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
28
|
"README.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
29
30
|
"LICENSE"
|
|
30
31
|
],
|
|
31
32
|
"sideEffects": false,
|
|
32
33
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
34
|
+
"node": ">=24"
|
|
34
35
|
},
|
|
35
36
|
"keywords": [
|
|
36
37
|
"screenscoreboard",
|