connectbase-client 3.13.1 → 3.14.1
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 +96 -0
- package/README.md +13 -1
- package/dist/connect-base.umd.js +4 -4
- package/dist/index.d.mts +182 -10
- package/dist/index.d.ts +182 -10
- package/dist/index.js +277 -78
- package/dist/index.mjs +276 -78
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,102 @@
|
|
|
3
3
|
본 SDK 의 모든 주요 변경사항을 [Keep a Changelog](https://keepachangelog.com/ko/1.1.0/) 형식으로 기록합니다.
|
|
4
4
|
버전은 [Semantic Versioning](https://semver.org/lang/ko/) 을 따릅니다.
|
|
5
5
|
|
|
6
|
+
## [3.14.1] - 2026-05-14
|
|
7
|
+
|
|
8
|
+
### Fixed — `cb.game.*` primitive 호스트 라우팅 회귀 (v3.0.0 이후 잠복)
|
|
9
|
+
|
|
10
|
+
NJB 측 deleteScript / deactivateScript 404 보고 (2026-05-14) 로 발견. v3.0.0 BREAKING 에서
|
|
11
|
+
matchqueue / leaderboard / scripts primitive 메서드 16개가 `this.http.*` (기본 baseUrl
|
|
12
|
+
= core-server, `api.connectbase.world`) 를 거치도록 잘못 wired 되어 game-server
|
|
13
|
+
(`game.connectbase.world`) 로 라우팅되지 않고 404 회귀. NJB 는 v3.9.0 부터 `uploadScript`
|
|
14
|
+
회귀를 raw fetch 로 우회 중이었음 (apps/game/scripts/upload-lua.mjs 참고).
|
|
15
|
+
|
|
16
|
+
수정: `GameAPI` 내부 `gameFetch` private helper 도입. `${this.gameServerUrl}${path}` 기준
|
|
17
|
+
fetch + 표준 `getHeaders()` (X-Public-Key / Bearer) + 서버 응답 `{ error }` → `ApiError.code`
|
|
18
|
+
surface + 204/non-JSON 응답을 `undefined` 로 처리. 영향받은 메서드:
|
|
19
|
+
|
|
20
|
+
- **scripts (8)**: `uploadScript` / `listScripts` / `getScript` / `listScriptVersions` /
|
|
21
|
+
`activateScript` / `rollbackScript` / `deactivateScript` / `deleteScript`
|
|
22
|
+
- **matchqueue (3)**: `enqueueMatch` / `listMatchqueue` / `cancelMatch`
|
|
23
|
+
- **leaderboard (6)**: `submitScore` / `getTopScores` / `getMemberRank` /
|
|
24
|
+
`getRankAround` / `resetLeaderboard` / `removeFromLeaderboard`
|
|
25
|
+
|
|
26
|
+
기존에 raw fetch 로 우회 중이던 통합 코드는 SDK 본 메서드로 회귀해도 무방 (4xx/5xx 시
|
|
27
|
+
`ApiError` 로 throw 되며 status/code 분기는 동일하게 작동).
|
|
28
|
+
|
|
29
|
+
### Added — 회귀 가드 테스트
|
|
30
|
+
|
|
31
|
+
- `test/game-host-routing.test.ts` — 17개 메서드 전체가 `game.*` 호스트로 라우팅되는지
|
|
32
|
+
fetch mock 으로 단언. 동일 회귀 재발 방지.
|
|
33
|
+
|
|
34
|
+
## [3.14.0] - 2026-05-14
|
|
35
|
+
|
|
36
|
+
### Added — `GameError` 클래스 + `createRoom` 응답 메타
|
|
37
|
+
|
|
38
|
+
- 신규 export: `GameError` (extends `Error`) — game-server 의 `error` 메시지를 일관된
|
|
39
|
+
인스턴스로 surface. `.code`, `.phase`, `.feature`, `.originClientId`, `.requested`,
|
|
40
|
+
`.available` 모두 노출. `instanceof GameError` 로 UI 분기 가능.
|
|
41
|
+
- 신규 export: `GameErrorCode` literal union — `'SCRIPT_NOT_FOUND' | 'NO_ACTION_HANDLER'
|
|
42
|
+
| 'FEATURE_DISABLED' | 'SCRIPT_ERROR' | 'SCRIPT_TIMEOUT' | 'RATE_LIMITED' |
|
|
43
|
+
'QUOTA_EXCEEDED' | 'TIMEOUT' | 'UNKNOWN' | (string & {})`.
|
|
44
|
+
- 신규 export: `CreateRoomResult` 타입 — `{ roomId, state, scriptName?, scriptVersion? }`.
|
|
45
|
+
- 신규 메서드: `GameRoom.createRoomDetailed(config)` + `GameRoomTransport.createRoomDetailed(config)`
|
|
46
|
+
— server 가 attach 한 lua script 의 이름/버전을 client 가 즉시 검증할 수 있게 응답에 포함.
|
|
47
|
+
- 신규 getter: `room.scriptName` / `room.scriptVersion` (`GameRoom` + `GameRoomTransport`)
|
|
48
|
+
— 마지막 `createRoom` 응답의 메타. `joinRoom`/`leaveRoom`/`disconnect` 시 reset.
|
|
49
|
+
- 기존 `createRoom(config)` 의 시그니처는 그대로 (호환). 내부적으로 `createRoomDetailed`
|
|
50
|
+
를 호출하고 `.state` 만 반환.
|
|
51
|
+
- `onError` 콜백 시그니처가 `Event | ErrorMessage` → `Event | GameError` 로 변경 (호환:
|
|
52
|
+
`ErrorMessage` 의 모든 필드가 `GameError` 인스턴스에 동일하게 surface 됨).
|
|
53
|
+
|
|
54
|
+
### Changed (BREAKING) — `disableScript` rename + `deleteScript` 신규
|
|
55
|
+
|
|
56
|
+
server 측 `DELETE /v1/game/:appID/scripts/:name` 의 의미가 **Disable → hard-delete** 로
|
|
57
|
+
변경된 것에 대응:
|
|
58
|
+
|
|
59
|
+
- `GameAPI.disableScript(appId, name)` **제거**. 대체: `GameAPI.deactivateScript(appId, name)`
|
|
60
|
+
— `POST /scripts/:name/deactivate` 호출 (코드/버전 보존, 재활성화 가능).
|
|
61
|
+
- `GameAPI.deleteScript(appId, name)` **신규** — `DELETE /scripts/:name` 호출 (메타 + 모든
|
|
62
|
+
버전 영구 제거, 복구 불가).
|
|
63
|
+
|
|
64
|
+
### Fixed — `error` 메시지 분류 메타 손실 회귀
|
|
65
|
+
|
|
66
|
+
이전엔 모든 `reject(new Error(msg.data.message))` 로 server 의 `code`/`phase`/`feature`/
|
|
67
|
+
`origin_client_id`/`requested`/`available` 가 손실되어 SDK 사용자가 UI 분기를 만들 수
|
|
68
|
+
없었다 (platform-issue 019e21dd, NJB 2026-05-13). 이제 `GameError` 인스턴스로 reject
|
|
69
|
+
되어 모든 메타가 보존된다.
|
|
70
|
+
|
|
71
|
+
### Migration
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// Before
|
|
75
|
+
import { ErrorMessage } from 'connectbase-client'
|
|
76
|
+
room.on('error', (err) => {
|
|
77
|
+
if ((err as ErrorMessage).code === 'FEATURE_DISABLED') { /* ... */ }
|
|
78
|
+
})
|
|
79
|
+
await cb.game.disableScript(appId, 'old-script')
|
|
80
|
+
|
|
81
|
+
// After
|
|
82
|
+
import { GameError } from 'connectbase-client'
|
|
83
|
+
room.on('error', (err) => {
|
|
84
|
+
if (err instanceof GameError) {
|
|
85
|
+
if (err.code === 'SCRIPT_NOT_FOUND') console.error('candidates:', err.available)
|
|
86
|
+
if (err.code === 'NO_ACTION_HANDLER') console.error('handler for', err.phase, 'undefined')
|
|
87
|
+
if (err.code === 'FEATURE_DISABLED') console.error('feature off:', err.feature)
|
|
88
|
+
if (err.originClientId) console.warn('error from other player:', err.originClientId)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
await cb.game.deactivateScript(appId, 'old-script') // 비활성화 (코드 보존)
|
|
92
|
+
await cb.game.deleteScript(appId, 'really-old') // 영구 삭제 (신규)
|
|
93
|
+
|
|
94
|
+
// createRoom 응답 검증 패턴 (NJB regression 가드)
|
|
95
|
+
const { state, scriptName, scriptVersion } = await room.createRoomDetailed({ scriptName: 'njb-main' })
|
|
96
|
+
if (scriptName !== 'njb-main') {
|
|
97
|
+
throw new Error(`script attach mismatch: expected njb-main got ${scriptName}`)
|
|
98
|
+
}
|
|
99
|
+
console.log('attached', scriptName, 'v', scriptVersion)
|
|
100
|
+
```
|
|
101
|
+
|
|
6
102
|
## [3.13.1] - 2026-05-13
|
|
7
103
|
|
|
8
104
|
### Documentation — README batch/transaction 예제 타입 회귀 수정
|
package/README.md
CHANGED
|
@@ -65,8 +65,20 @@ gameClient
|
|
|
65
65
|
await gameClient.connect()
|
|
66
66
|
const state = await gameClient.createRoom({
|
|
67
67
|
maxPlayers: 4,
|
|
68
|
-
tickRate: 64
|
|
68
|
+
tickRate: 64,
|
|
69
|
+
scriptName: 'my-script', // Optional: attach a lua script (must be pre-uploaded + active)
|
|
69
70
|
})
|
|
71
|
+
|
|
72
|
+
// 3.14+ — Attached script 의 이름/버전을 검증하고 싶으면 createRoomDetailed 사용
|
|
73
|
+
import { GameError } from 'connectbase-client'
|
|
74
|
+
try {
|
|
75
|
+
const r = await gameClient.createRoomDetailed({ scriptName: 'my-script' })
|
|
76
|
+
console.log('attached', r.scriptName, 'v', r.scriptVersion)
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if (e instanceof GameError && e.code === 'SCRIPT_NOT_FOUND') {
|
|
79
|
+
console.error('script missing — candidates:', e.available)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
70
82
|
```
|
|
71
83
|
|
|
72
84
|
## Features
|