@xmobitea/gn-typescript-client 2.6.13 → 2.6.14
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/AGENTS.md +37 -0
- package/README.MD +420 -1
- package/dist/gearn.js.client.js +25056 -1056
- package/dist/gearn.js.client.min.js +1 -1
- package/dist/index.d.ts +30 -0
- package/dist/index.js +24236 -212
- package/dist/runtime/GNNetwork.d.ts +687 -3
- package/dist/runtime/GNNetworkAuthenticateApi.d.ts +327 -0
- package/dist/runtime/GNNetworkCharacterPlayerApi.d.ts +1026 -0
- package/dist/runtime/GNNetworkCloudScriptApi.d.ts +141 -0
- package/dist/runtime/GNNetworkContentApi.d.ts +243 -0
- package/dist/runtime/GNNetworkDashboardApi.d.ts +221 -0
- package/dist/runtime/GNNetworkGamePlayerApi.d.ts +1033 -0
- package/dist/runtime/GNNetworkGroupApi.d.ts +783 -0
- package/dist/runtime/GNNetworkInventoryApi.d.ts +673 -0
- package/dist/runtime/GNNetworkMasterPlayerApi.d.ts +1614 -6
- package/dist/runtime/GNNetworkMultiplayerApi.d.ts +234 -0
- package/dist/runtime/GNNetworkStoreInventoryApi.d.ts +309 -0
- package/dist/runtime/common/Action0.d.ts +30 -0
- package/dist/runtime/common/Action1.d.ts +32 -0
- package/dist/runtime/common/Action2.d.ts +21 -0
- package/dist/runtime/common/Action3.d.ts +16 -0
- package/dist/runtime/common/Action4.d.ts +17 -0
- package/dist/runtime/common/GNData.d.ts +368 -0
- package/dist/runtime/config/GNServerSettings.d.ts +442 -12
- package/dist/runtime/constant/Commands.d.ts +80 -0
- package/dist/runtime/constant/EventCode.d.ts +48 -0
- package/dist/runtime/constant/OperationCode.d.ts +74 -1
- package/dist/runtime/constant/ReturnCode.d.ts +72 -0
- package/dist/runtime/constant/enumType/ExecuteResponseStatus.d.ts +31 -0
- package/dist/runtime/constant/enumType/FriendStatus.d.ts +39 -0
- package/dist/runtime/constant/enumType/GoogleLoginType.d.ts +23 -0
- package/dist/runtime/constant/enumType/GroupStatus.d.ts +32 -0
- package/dist/runtime/constant/enumType/InvalidMemberType.d.ts +75 -0
- package/dist/runtime/constant/enumType/ItemType.d.ts +23 -0
- package/dist/runtime/constant/enumType/MatchStatus.d.ts +30 -0
- package/dist/runtime/constant/enumType/MatchmakingMemberStatus.d.ts +24 -0
- package/dist/runtime/constant/enumType/MatchmakingTicketStatus.d.ts +34 -0
- package/dist/runtime/constant/enumType/OwnerType.d.ts +40 -0
- package/dist/runtime/constant/enumType/PermissionDataItem.d.ts +22 -0
- package/dist/runtime/constant/enumType/PushPlatformType.d.ts +18 -0
- package/dist/runtime/constant/enumType/RequestRole.d.ts +32 -0
- package/dist/runtime/constant/enumType/RequestType.d.ts +70 -0
- package/dist/runtime/constant/enumType/StoreItemType.d.ts +21 -0
- package/dist/runtime/constant/enumType/StoreReceiveType.d.ts +30 -0
- package/dist/runtime/constant/errorCode/ErrorCode.d.ts +190 -8
- package/dist/runtime/constant/parameterCode/ParameterCode.d.ts +35 -5
- package/dist/runtime/entity/DataMember.d.ts +338 -0
- package/dist/runtime/entity/GNMetadata.d.ts +101 -0
- package/dist/runtime/entity/InvalidMember.d.ts +28 -0
- package/dist/runtime/entity/OperationEvent.d.ts +49 -0
- package/dist/runtime/entity/OperationRequest.d.ts +108 -0
- package/dist/runtime/entity/OperationResponse.d.ts +110 -0
- package/dist/runtime/entity/models/AuthenticateModels.d.ts +115 -0
- package/dist/runtime/entity/models/AuthenticateRequestModels.d.ts +131 -0
- package/dist/runtime/entity/models/AuthenticateResponseModels.d.ts +131 -0
- package/dist/runtime/entity/models/CharacterPlayerModels.d.ts +625 -1
- package/dist/runtime/entity/models/CharacterPlayerRequestModels.d.ts +972 -0
- package/dist/runtime/entity/models/CharacterPlayerResponseModels.d.ts +332 -0
- package/dist/runtime/entity/models/CloudScriptModels.d.ts +109 -0
- package/dist/runtime/entity/models/CloudScriptRequestModels.d.ts +107 -0
- package/dist/runtime/entity/models/CloudScriptResponseModels.d.ts +46 -0
- package/dist/runtime/entity/models/ContentModels.d.ts +124 -0
- package/dist/runtime/entity/models/ContentRequestModels.d.ts +152 -0
- package/dist/runtime/entity/models/ContentResponseModels.d.ts +58 -0
- package/dist/runtime/entity/models/DashboardModels.d.ts +371 -8
- package/dist/runtime/entity/models/DashboardRequestModels.d.ts +172 -0
- package/dist/runtime/entity/models/DashboardResponseModels.d.ts +170 -0
- package/dist/runtime/entity/models/GamePlayerModels.d.ts +644 -1
- package/dist/runtime/entity/models/GamePlayerRequestModels.d.ts +959 -0
- package/dist/runtime/entity/models/GamePlayerResponseModels.d.ts +333 -1
- package/dist/runtime/entity/models/GenericModels.d.ts +94 -0
- package/dist/runtime/entity/models/GroupModels.d.ts +484 -2
- package/dist/runtime/entity/models/GroupRequestModels.d.ts +737 -0
- package/dist/runtime/entity/models/GroupResponseModels.d.ts +254 -0
- package/dist/runtime/entity/models/InventoryModels.d.ts +415 -0
- package/dist/runtime/entity/models/InventoryRequestModels.d.ts +629 -0
- package/dist/runtime/entity/models/InventoryResponseModels.d.ts +218 -0
- package/dist/runtime/entity/models/MasterPlayerModels.d.ts +1065 -3
- package/dist/runtime/entity/models/MasterPlayerRequestModels.d.ts +1560 -6
- package/dist/runtime/entity/models/MasterPlayerResponseModels.d.ts +532 -1
- package/dist/runtime/entity/models/MultiplayerModels.d.ts +199 -0
- package/dist/runtime/entity/models/MultiplayerRequestModels.d.ts +196 -0
- package/dist/runtime/entity/models/MultiplayerResponseModels.d.ts +74 -0
- package/dist/runtime/entity/models/StoreInventoryModels.d.ts +262 -0
- package/dist/runtime/entity/models/StoreInventoryRequestModels.d.ts +268 -0
- package/dist/runtime/entity/models/StoreInventoryResponseModels.d.ts +98 -0
- package/dist/runtime/entity/request/CustomOperationRequest.d.ts +99 -0
- package/dist/runtime/entity/response/CustomOperationResponse.d.ts +118 -0
- package/dist/runtime/entity/response/GetAuthInfoResponse.d.ts +53 -0
- package/dist/runtime/entity/response/HealthCheckResponse.d.ts +56 -0
- package/dist/runtime/entity/response/UploadFileResponse.d.ts +19 -0
- package/dist/runtime/helper/CodeHelper.d.ts +122 -0
- package/dist/runtime/helper/ConverterService.d.ts +74 -0
- package/dist/runtime/helper/EnumUtility.d.ts +63 -0
- package/dist/runtime/helper/GNSupport.d.ts +64 -4
- package/dist/runtime/helper/GNUtils.d.ts +54 -0
- package/dist/runtime/helper/MessagePackConverterService.d.ts +48 -0
- package/dist/runtime/helper/OperationHelper.d.ts +51 -0
- package/dist/runtime/helper/StorageService.d.ts +48 -8
- package/dist/runtime/logger/GNDebug.d.ts +117 -0
- package/dist/runtime/networking/AuthenticateStatus.d.ts +64 -0
- package/dist/runtime/networking/IPeer.d.ts +83 -0
- package/dist/runtime/networking/NetworkingPeer.d.ts +256 -1
- package/dist/runtime/networking/OperationPending.d.ts +112 -0
- package/dist/runtime/networking/PeerBase.d.ts +231 -0
- package/dist/runtime/networking/handler/IServerEventHandler.d.ts +84 -0
- package/dist/runtime/networking/handler/OnCharacterPlayerFriendUpdateEventHandler.d.ts +69 -0
- package/dist/runtime/networking/handler/OnCharacterPlayerGroupUpdateEventHandler.d.ts +49 -0
- package/dist/runtime/networking/handler/OnGamePlayerFriendUpdateEventHandler.d.ts +50 -0
- package/dist/runtime/networking/handler/OnGamePlayerGroupUpdateEventHandler.d.ts +41 -0
- package/dist/runtime/networking/handler/OnGroupMemberUpdateEventHandler.d.ts +47 -0
- package/dist/runtime/networking/handler/OnGroupMessageUpdateEventHandler.d.ts +46 -0
- package/dist/runtime/networking/http/HttpPeer.d.ts +173 -0
- package/dist/runtime/networking/http/NetworkingHttpPeerBase.d.ts +87 -0
- package/dist/runtime/networking/http/NetworkingPeerAxiosRequest.d.ts +113 -0
- package/dist/runtime/networking/socket/NetworkingPeerSocketIOClient.d.ts +145 -0
- package/dist/runtime/networking/socket/NetworkingSocketPeerBase.d.ts +198 -0
- package/dist/runtime/networking/socket/SocketPeer.d.ts +155 -0
- package/dist/runtime/typescript/ServiceUpdate.d.ts +46 -0
- package/docs/AI_CHEATSHEET.md +211 -0
- package/docs/COOKBOOK.md +912 -0
- package/docs/RULES.md +307 -0
- package/docs/ai-manifest.json +725 -0
- package/docs/guides/AUTHENTICATE.md +246 -0
- package/docs/guides/CHARACTER_PLAYER.md +439 -0
- package/docs/guides/CLOUDSCRIPT.md +335 -0
- package/docs/guides/COCOS_CREATOR_INTEGRATION.md +150 -0
- package/docs/guides/CONTENT.md +291 -0
- package/docs/guides/DASHBOARD.md +262 -0
- package/docs/guides/GAME_PLAYER.md +473 -0
- package/docs/guides/GROUP.md +412 -0
- package/docs/guides/INVENTORY.md +375 -0
- package/docs/guides/MASTER_PLAYER.md +458 -0
- package/docs/guides/MULTIPLAYER.md +303 -0
- package/docs/guides/STORE_INVENTORY.md +313 -0
- package/docs/llms-full.txt +43 -0
- package/docs/reference/API_AUTHENTICATE.md +75 -0
- package/docs/reference/API_CHARACTER_PLAYER.md +226 -0
- package/docs/reference/API_CLOUDSCRIPT.md +82 -0
- package/docs/reference/API_CONTENT.md +88 -0
- package/docs/reference/API_DASHBOARD.md +82 -0
- package/docs/reference/API_GAME_PLAYER.md +223 -0
- package/docs/reference/API_GROUP.md +187 -0
- package/docs/reference/API_INDEX.md +57 -0
- package/docs/reference/API_INVENTORY.md +169 -0
- package/docs/reference/API_MASTER_PLAYER.md +323 -0
- package/docs/reference/API_MULTIPLAYER.md +97 -0
- package/docs/reference/API_STORE_INVENTORY.md +109 -0
- package/docs/reference/CONFIG.md +107 -0
- package/docs/reference/DTO_INDEX.md +2543 -0
- package/docs/reference/ENUMS.md +433 -0
- package/docs/reference/ERROR_HANDLING.md +159 -0
- package/docs/reference/EVENTS.md +188 -0
- package/docs/reference/PERMISSION_RULES.md +55 -0
- package/docs/reference/dto/AUTHENTICATE.md +619 -0
- package/docs/reference/dto/CHARACTER_PLAYER.md +3686 -0
- package/docs/reference/dto/CLOUDSCRIPT.md +400 -0
- package/docs/reference/dto/CONTENT.md +548 -0
- package/docs/reference/dto/DASHBOARD.md +1980 -0
- package/docs/reference/dto/GAME_PLAYER.md +3631 -0
- package/docs/reference/dto/GENERIC.md +151 -0
- package/docs/reference/dto/GROUP.md +2842 -0
- package/docs/reference/dto/INVENTORY.md +2385 -0
- package/docs/reference/dto/MASTER_PLAYER.md +6024 -0
- package/docs/reference/dto/MULTIPLAYER.md +850 -0
- package/docs/reference/dto/STORE_INVENTORY.md +1262 -0
- package/llms.txt +47 -0
- package/package.json +12 -3
- package/GNServerSettings.debug.json +0 -21
- package/docs/COCOS_CREATOR_INTEGRATION.md +0 -116
- package/examples/cocos-creator/GearNExample.ts.txt +0 -176
- package/srcSwift/Package.swift +0 -32
- package/srcSwift/Sources/GearN/runtime/GNNetwork.swift +0 -530
- package/srcSwift/Sources/GearN/runtime/GNNetworkAuthenticateApi.swift +0 -178
- package/srcSwift/Sources/GearN/runtime/GNNetworkCharacterPlayerApi.swift +0 -1162
- package/srcSwift/Sources/GearN/runtime/GNNetworkCloudScriptApi.swift +0 -154
- package/srcSwift/Sources/GearN/runtime/GNNetworkContentApi.swift +0 -208
- package/srcSwift/Sources/GearN/runtime/GNNetworkDashboardApi.swift +0 -240
- package/srcSwift/Sources/GearN/runtime/GNNetworkGamePlayerApi.swift +0 -1369
- package/srcSwift/Sources/GearN/runtime/GNNetworkGroupApi.swift +0 -1100
- package/srcSwift/Sources/GearN/runtime/GNNetworkInventoryApi.swift +0 -937
- package/srcSwift/Sources/GearN/runtime/GNNetworkMasterPlayerApi.swift +0 -2323
- package/srcSwift/Sources/GearN/runtime/GNNetworkMultiplayerApi.swift +0 -298
- package/srcSwift/Sources/GearN/runtime/GNNetworkStoreInventoryApi.swift +0 -397
- package/srcSwift/Sources/GearN/runtime/common/Action0.swift +0 -3
- package/srcSwift/Sources/GearN/runtime/common/Action1.swift +0 -3
- package/srcSwift/Sources/GearN/runtime/common/Action2.swift +0 -3
- package/srcSwift/Sources/GearN/runtime/common/Action3.swift +0 -3
- package/srcSwift/Sources/GearN/runtime/common/Action4.swift +0 -3
- package/srcSwift/Sources/GearN/runtime/common/GNArray.swift +0 -204
- package/srcSwift/Sources/GearN/runtime/common/GNData.swift +0 -108
- package/srcSwift/Sources/GearN/runtime/common/GNHashtable.swift +0 -200
- package/srcSwift/Sources/GearN/runtime/config/GNServerSettings.swift +0 -95
- package/srcSwift/Sources/GearN/runtime/constant/Commands.swift +0 -28
- package/srcSwift/Sources/GearN/runtime/constant/EventCode.swift +0 -10
- package/srcSwift/Sources/GearN/runtime/constant/OperationCode.swift +0 -252
- package/srcSwift/Sources/GearN/runtime/constant/ReturnCode.swift +0 -19
- package/srcSwift/Sources/GearN/runtime/constant/enumType/ExecuteResponseStatus.swift +0 -9
- package/srcSwift/Sources/GearN/runtime/constant/enumType/FriendStatus.swift +0 -8
- package/srcSwift/Sources/GearN/runtime/constant/enumType/GoogleLoginType.swift +0 -6
- package/srcSwift/Sources/GearN/runtime/constant/enumType/GroupStatus.swift +0 -8
- package/srcSwift/Sources/GearN/runtime/constant/enumType/InvalidMemberType.swift +0 -19
- package/srcSwift/Sources/GearN/runtime/constant/enumType/ItemType.swift +0 -6
- package/srcSwift/Sources/GearN/runtime/constant/enumType/MatchmakingMemberStatus.swift +0 -7
- package/srcSwift/Sources/GearN/runtime/constant/enumType/MatchmakingTicketStatus.swift +0 -9
- package/srcSwift/Sources/GearN/runtime/constant/enumType/OwnerType.swift +0 -10
- package/srcSwift/Sources/GearN/runtime/constant/enumType/PermissionDataItem.swift +0 -6
- package/srcSwift/Sources/GearN/runtime/constant/enumType/PushPlatformType.swift +0 -6
- package/srcSwift/Sources/GearN/runtime/constant/enumType/RequestRole.swift +0 -7
- package/srcSwift/Sources/GearN/runtime/constant/enumType/RequestType.swift +0 -16
- package/srcSwift/Sources/GearN/runtime/constant/enumType/StoreItemType.swift +0 -6
- package/srcSwift/Sources/GearN/runtime/constant/enumType/StoreReceiveType.swift +0 -9
- package/srcSwift/Sources/GearN/runtime/constant/errorCode/ErrorCode.swift +0 -58
- package/srcSwift/Sources/GearN/runtime/constant/parameterCode/ParameterCode.swift +0 -672
- package/srcSwift/Sources/GearN/runtime/entity/DataMember.swift +0 -196
- package/srcSwift/Sources/GearN/runtime/entity/GNMetadata.swift +0 -9
- package/srcSwift/Sources/GearN/runtime/entity/InvalidMember.swift +0 -11
- package/srcSwift/Sources/GearN/runtime/entity/OperationEvent.swift +0 -38
- package/srcSwift/Sources/GearN/runtime/entity/OperationHelper.swift +0 -28
- package/srcSwift/Sources/GearN/runtime/entity/OperationRequest.swift +0 -62
- package/srcSwift/Sources/GearN/runtime/entity/OperationResponse.swift +0 -98
- package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateModels.swift +0 -351
- package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateRequestModels.swift +0 -81
- package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateResponseModels.swift +0 -108
- package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerModels.swift +0 -1045
- package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerRequestModels.swift +0 -821
- package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerResponseModels.swift +0 -588
- package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptModels.swift +0 -187
- package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptRequestModels.swift +0 -84
- package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptResponseModels.swift +0 -59
- package/srcSwift/Sources/GearN/runtime/entity/models/ContentModels.swift +0 -195
- package/srcSwift/Sources/GearN/runtime/entity/models/ContentRequestModels.swift +0 -116
- package/srcSwift/Sources/GearN/runtime/entity/models/ContentResponseModels.swift +0 -81
- package/srcSwift/Sources/GearN/runtime/entity/models/DashboardModels.swift +0 -426
- package/srcSwift/Sources/GearN/runtime/entity/models/DashboardRequestModels.swift +0 -160
- package/srcSwift/Sources/GearN/runtime/entity/models/DashboardResponseModels.swift +0 -82
- package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerModels.swift +0 -1334
- package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerRequestModels.swift +0 -643
- package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerResponseModels.swift +0 -213
- package/srcSwift/Sources/GearN/runtime/entity/models/GenericModels.swift +0 -171
- package/srcSwift/Sources/GearN/runtime/entity/models/GroupModels.swift +0 -850
- package/srcSwift/Sources/GearN/runtime/entity/models/GroupRequestModels.swift +0 -485
- package/srcSwift/Sources/GearN/runtime/entity/models/GroupResponseModels.swift +0 -165
- package/srcSwift/Sources/GearN/runtime/entity/models/InventoryModels.swift +0 -679
- package/srcSwift/Sources/GearN/runtime/entity/models/InventoryRequestModels.swift +0 -413
- package/srcSwift/Sources/GearN/runtime/entity/models/InventoryResponseModels.swift +0 -141
- package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerModels.swift +0 -378
- package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerRequestModels.swift +0 -147
- package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerResponseModels.swift +0 -318
- package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerModels.swift +0 -319
- package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerRequestModels.swift +0 -125
- package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerResponseModels.swift +0 -45
- package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryModels.swift +0 -633
- package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryRequestModels.swift +0 -173
- package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryResponseModels.swift +0 -61
- package/srcSwift/Sources/GearN/runtime/entity/request/CustomOperationRequest.swift +0 -42
- package/srcSwift/Sources/GearN/runtime/entity/response/CustomOperationResponse.swift +0 -49
- package/srcSwift/Sources/GearN/runtime/entity/response/GetAuthInfoResponse.swift +0 -43
- package/srcSwift/Sources/GearN/runtime/entity/response/HealthCheckResponse.swift +0 -86
- package/srcSwift/Sources/GearN/runtime/entity/response/UploadFileResponse.swift +0 -15
- package/srcSwift/Sources/GearN/runtime/helper/CodeHelper.swift +0 -107
- package/srcSwift/Sources/GearN/runtime/helper/ConverterService.swift +0 -98
- package/srcSwift/Sources/GearN/runtime/helper/EnumUtility.swift +0 -34
- package/srcSwift/Sources/GearN/runtime/helper/GNSupport.swift +0 -41
- package/srcSwift/Sources/GearN/runtime/helper/GNUtils.swift +0 -66
- package/srcSwift/Sources/GearN/runtime/helper/MessagePackConverterService.swift +0 -21
- package/srcSwift/Sources/GearN/runtime/helper/StorageService.swift +0 -29
- package/srcSwift/Sources/GearN/runtime/logger/GNDebug.swift +0 -33
- package/srcSwift/Sources/GearN/runtime/networking/AuthenticateStatus.swift +0 -24
- package/srcSwift/Sources/GearN/runtime/networking/IPeer.swift +0 -8
- package/srcSwift/Sources/GearN/runtime/networking/NetworkingPeer.swift +0 -368
- package/srcSwift/Sources/GearN/runtime/networking/OperationPending.swift +0 -81
- package/srcSwift/Sources/GearN/runtime/networking/PeerBase.swift +0 -228
- package/srcSwift/Sources/GearN/runtime/networking/handler/IServerEventHandler.swift +0 -20
- package/srcSwift/Sources/GearN/runtime/networking/http/HttpPeer.swift +0 -226
- package/srcSwift/Sources/GearN/runtime/networking/http/HttpTypes.swift +0 -24
- package/srcSwift/Sources/GearN/runtime/networking/http/NetworkingHttpPeerBase.swift +0 -13
- package/srcSwift/Sources/GearN/runtime/networking/http/NetworkingPeerUrlSession.swift +0 -125
- package/srcSwift/Sources/GearN/runtime/networking/request/NetRequest.swift +0 -19
- package/srcSwift/Sources/GearN/runtime/networking/response/NetResponse.swift +0 -13
- package/srcSwift/Sources/GearN/runtime/networking/socket/NetworkingPeerSocketIOClient.swift +0 -244
- package/srcSwift/Sources/GearN/runtime/networking/socket/NetworkingSocketPeerBase.swift +0 -59
- package/srcSwift/Sources/GearN/runtime/networking/socket/SocketPeer.swift +0 -136
- package/tsconfig-build.cocos.json +0 -31
- package/webpack.config.cocos.mjs +0 -78
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# InventoryApi
|
|
2
|
+
|
|
3
|
+
Tài liệu này dành cho AI code assistant và AI agent nội bộ. Mục tiêu là chọn đúng namespace `client/server/admin`, phân biệt đúng flow đọc item với flow mutation, và không sinh sai request ở các nhóm `infoRequestParam`, leaderboard, owner transfer và statistics log.
|
|
4
|
+
|
|
5
|
+
## 1. Scope
|
|
6
|
+
|
|
7
|
+
- Áp dụng cho:
|
|
8
|
+
- `GNNetwork.inventory`
|
|
9
|
+
- `GNNetwork.inventory.server`
|
|
10
|
+
- `GNNetwork.inventory.admin`
|
|
11
|
+
- Toàn bộ method hiện tại của `InventoryApi` đều gửi qua HTTP.
|
|
12
|
+
- `InventoryApi` có đủ 3 role thật:
|
|
13
|
+
- `GNNetwork.inventory` -> `RequestRole.Client`
|
|
14
|
+
- `GNNetwork.inventory.server` -> `RequestRole.Server`
|
|
15
|
+
- `GNNetwork.inventory.admin` -> `RequestRole.Admin`
|
|
16
|
+
- Nếu không truyền `overrideSecretKey`, SDK sẽ tự lấy secret key theo role tương ứng.
|
|
17
|
+
- Chỉ dùng namespace `.server` khi bạn đã cấu hình `secretKey` với `permission rules` `server` hợp lệ trong `GNServerSettings`, hoặc chủ động truyền `overrideSecretKey`.
|
|
18
|
+
- Chỉ dùng namespace `.admin` khi bạn đã cấu hình `secretKey` với `permission rules` `admin` hợp lệ trong `GNServerSettings`, hoặc chủ động truyền `overrideSecretKey`.
|
|
19
|
+
- Rule chuẩn để chọn `client/server/admin` và hiểu `self/other-self` xem [RULES](../RULES.md#3-route--trust-boundary-của-caller). Không tự suy diễn route chỉ từ target ownership.
|
|
20
|
+
- Payload shape hiện tại giữa `client`, `server`, `admin` là giống nhau; khác biệt chính là trust boundary và secret key mặc định.
|
|
21
|
+
- `InventoryApi` không có flow tạo inventory item mới trong public surface hiện tại. Không được tự suy diễn `createInventoryItem`.
|
|
22
|
+
|
|
23
|
+
## 2. Hard Rules
|
|
24
|
+
|
|
25
|
+
- Luôn ưu tiên `async/await`. Mặc định dùng `*Async()`.
|
|
26
|
+
- Bắt buộc đã `GNNetwork.init(settings)` trước khi gọi.
|
|
27
|
+
- Không dùng socket cho `InventoryApi`.
|
|
28
|
+
- Chọn namespace theo trust boundary, không theo cảm tính:
|
|
29
|
+
- app/player -> `GNNetwork.inventory`
|
|
30
|
+
- trusted backend/service -> `GNNetwork.inventory.server`
|
|
31
|
+
- dashboard/ops/tooling -> `GNNetwork.inventory.admin`
|
|
32
|
+
- `getItemInformationAsync`, `getItemsWithDisplayNameAsync`, `getItemsWithSegmentAsync`, `getItemsWithTagAsync`, `getStatisticsLeaderboardAroundItemAsync`, `getStatisticsLeaderboardAsync` và `getCreateLeaderboardAsync` đều bắt buộc có `infoRequestParam`.
|
|
33
|
+
- `getItemStatisticsAsync` dùng `statisticsKeys`, còn `infoRequestParam` dùng `itemStatisticsKeys`. Không được dùng lẫn hai field này.
|
|
34
|
+
- `getStatisticsLogAsync` phân trang bằng `token`, không dùng `skip`.
|
|
35
|
+
- `setAmountAsync` là set giá trị tuyệt đối. `changeItemStatisticsAsync` là cộng/trừ delta theo từng key.
|
|
36
|
+
- `setOwnerAsync` là chuyển owner của item, không phải clone item.
|
|
37
|
+
- `setRemoveStatusAsync` là đánh dấu remove với `reason?`; trong `InventoryApi` hiện không có public method riêng để undo thao tác này.
|
|
38
|
+
- `removeTagAsync` xóa theo `key`, không theo cặp `key/value`.
|
|
39
|
+
- Dùng enum publish khi package đã có:
|
|
40
|
+
- `itemType` -> `ItemType`
|
|
41
|
+
- `owner.type`, `newOwnerType` -> `OwnerType`
|
|
42
|
+
- `setAvatarAsync` có field `type: number`, nhưng package hiện không publish enum avatar riêng. Không được tự bịa enum nếu backend spec chưa chốt.
|
|
43
|
+
|
|
44
|
+
## 3. Chọn Namespace
|
|
45
|
+
|
|
46
|
+
| Namespace | Role thật | Dùng khi nào |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `GNNetwork.inventory` | `Client` | player app thao tác trên item thuộc session hiện tại |
|
|
49
|
+
| `GNNetwork.inventory.server` | `Server` | trusted backend, game server, worker xử lý item |
|
|
50
|
+
| `GNNetwork.inventory.admin` | `Admin` | GM tool, dashboard, migration, vận hành dữ liệu |
|
|
51
|
+
|
|
52
|
+
Rule nhanh:
|
|
53
|
+
|
|
54
|
+
- Nếu logic chạy trong client app: ưu tiên `GNNetwork.inventory`.
|
|
55
|
+
- Nếu logic chạy trong backend tin cậy: ưu tiên `GNNetwork.inventory.server`.
|
|
56
|
+
- Nếu thao tác quản trị hoặc vận hành dữ liệu: ưu tiên `GNNetwork.inventory.admin`.
|
|
57
|
+
|
|
58
|
+
## 4. Chọn Method
|
|
59
|
+
|
|
60
|
+
### Đọc 1 item
|
|
61
|
+
|
|
62
|
+
| Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú | ErrorCode
|
|
63
|
+
| --- | --- | --- | --- | --- | --- |
|
|
64
|
+
| `getAmountAsync` | Cần đọc số lượng item | `itemId` | `InventoryResponseData` | Giá trị nằm trong `infoResponseParameters.amount` | `Ok`, `ItemNotFound` |
|
|
65
|
+
| `getAvatarAsync` | Cần đọc avatar item | `itemId` | `InventoryResponseData` | `avatar.type` hiện là số thô | `Ok`, `ItemNotFound` |
|
|
66
|
+
| `getCatalogIdAsync` | Cần đọc `catalogId` | `itemId` | `InventoryResponseData` | Kết quả ở `infoResponseParameters.catalogId` | `Ok`, `ItemNotFound` |
|
|
67
|
+
| `getClassIdAsync` | Cần đọc `classId` | `itemId` | `InventoryResponseData` | Kết quả ở `infoResponseParameters.classId` | `Ok`, `ItemNotFound` |
|
|
68
|
+
| `getCustomDataAsync` | Cần đọc custom data | `itemId`, `customDataKeys?` | `InventoryResponseData` | Có thể filter theo key | `Ok`, `ItemNotFound` |
|
|
69
|
+
| `getDisplayNameAsync` | Cần đọc display name | `itemId` | `InventoryResponseData` | Kết quả ở `infoResponseParameters.displayName` | `Ok`, `ItemNotFound` |
|
|
70
|
+
| `getItemDataAsync` | Cần đọc item data | `itemId`, `itemDataKeys?` | `InventoryResponseData` | Có thể filter theo key | `Ok`, `ItemNotFound` |
|
|
71
|
+
| `getItemInformationAsync` | Cần lấy nhiều field trong một lần gọi | `itemId`, `infoRequestParam` | `InventoryResponseData` | Flow đọc tổng hợp quan trọng nhất | `Ok`, `ItemNotFound` |
|
|
72
|
+
| `getItemStatisticsAsync` | Cần đọc statistics theo key | `itemId`, `statisticsKeys?` | `InventoryResponseData` | Không dùng `itemStatisticsKeys` ở đây | `Ok`, `ItemNotFound` |
|
|
73
|
+
| `getItemTypeAsync` | Cần đọc loại item | `itemId` | `InventoryResponseData` | Map `itemType` bằng `ItemType` | `Ok`, `ItemNotFound` |
|
|
74
|
+
| `getOwnerAsync` | Cần đọc owner hiện tại | `itemId` | `InventoryResponseData` | Map `owner.type` bằng `OwnerType` | `Ok`, `ItemNotFound` |
|
|
75
|
+
| `getRemoveStatusAsync` | Cần đọc trạng thái remove | `itemId` | `InventoryResponseData` | Kết quả ở `infoResponseParameters.removeStatus` | `Ok`, `ItemNotFound` |
|
|
76
|
+
| `getSegmentAsync` | Cần đọc danh sách segment | `itemId` | `InventoryResponseData` | Kết quả ở `infoResponseParameters.segments` | `Ok`, `ItemNotFound` |
|
|
77
|
+
| `getTagAsync` | Cần đọc tag theo danh sách key | `itemId`, `tagKeys` | `InventoryResponseData` | Không query theo value | `Ok`, `ItemNotFound` |
|
|
78
|
+
| `getTsCreateAsync` | Cần đọc thời điểm tạo item | `itemId` | `InventoryResponseData` | Kết quả ở `infoResponseParameters.tsCreate` | `Ok`, `ItemNotFound` |
|
|
79
|
+
|
|
80
|
+
### Query danh sách, leaderboard và log
|
|
81
|
+
|
|
82
|
+
| Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú | ErrorCode
|
|
83
|
+
| --- | --- | --- | --- | --- | --- |
|
|
84
|
+
| `getItemsWithDisplayNameAsync` | Tìm item theo tên hiển thị | `keyword`, `infoRequestParam`, `skip?`, `limit?` | `InventoriesWithItemIdResponseData` | `keyword` tối thiểu 2 ký tự | `Ok` |
|
|
85
|
+
| `getItemsWithSegmentAsync` | Tìm item theo segment | `value`, `infoRequestParam`, `skip?`, `limit?` | `InventoriesWithItemIdResponseData` | Query theo exact segment value | `Ok` |
|
|
86
|
+
| `getItemsWithTagAsync` | Tìm item theo tag | `key`, `value`, `infoRequestParam`, `skip?`, `limit?` | `InventoriesWithItemIdResponseData` | Query theo cặp `key/value` | `Ok`, `KeyNotFound` |
|
|
87
|
+
| `getStatisticsLeaderboardAroundItemAsync` | Cần bảng xếp hạng quanh một item cụ thể | `itemId`, `key`, `infoRequestParam`, `skip?`, `limit?`, `loadFromCache?`, `catalogId?` | `GetStatisticsLeaderboardResponseData` | Dùng khi cần vị trí tương đối quanh item đó | `Ok`, `KeyNotFound` |
|
|
88
|
+
| `getStatisticsLeaderboardAsync` | Cần bảng xếp hạng statistics toàn cục theo key | `key`, `infoRequestParam`, `skip?`, `limit?`, `loadFromCache?`, `version?`, `catalogId?` | `GetStatisticsLeaderboardResponseData` | `version` chỉ có ở method này | `Ok`, `KeyNotFound`, `VersionInvalid` |
|
|
89
|
+
| `getCreateLeaderboardAsync` | Cần bảng xếp hạng theo thời điểm tạo item | `infoRequestParam`, `skip?`, `limit?`, `loadFromCache?` | `GetCreateLeaderboardResponseData` | Không cần statistics key | `Ok` |
|
|
90
|
+
| `getStatisticsLogAsync` | Cần audit statistics change log | `keys?`, `itemId?`, `limit?`, `token?` | `GetStatisticsLogResponseData` | Phân trang bằng `token` | `Ok` |
|
|
91
|
+
|
|
92
|
+
### Mutation
|
|
93
|
+
|
|
94
|
+
| Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú | ErrorCode
|
|
95
|
+
| --- | --- | --- | --- | --- | --- |
|
|
96
|
+
| `addSegmentAsync` | Gắn thêm segment cho item | `itemId`, `value` | `EmptyResponseData` | Thêm một segment value | `Ok`, `ItemNotFound` |
|
|
97
|
+
| `removeSegmentAsync` | Gỡ một segment khỏi item | `itemId`, `value` | `EmptyResponseData` | Xóa theo exact value | `Ok`, `ItemNotFound` |
|
|
98
|
+
| `setTagAsync` | Set hoặc upsert một tag | `itemId`, `key`, `value` | `EmptyResponseData` | Thao tác theo một cặp key/value | `Ok`, `KeyNotFound`, `ItemNotFound` |
|
|
99
|
+
| `removeTagAsync` | Xóa tag theo key | `itemId`, `key` | `EmptyResponseData` | Không truyền `value` | `Ok`, `ItemNotFound` |
|
|
100
|
+
| `setAmountAsync` | Set lại amount tuyệt đối | `itemId`, `amount` | `InventoryResponseData` | Không phải delta | `Ok`, `ItemNotFound`, `ItemNotStackable` |
|
|
101
|
+
| `setAvatarAsync` | Set avatar của item | `itemId`, `type`, `value` | `EmptyResponseData` | `type` chưa có enum public | `Ok`, `ItemNotFound` |
|
|
102
|
+
| `setCustomDataAsync` | Set custom data theo nhiều key | `itemId`, `customDatas[]` | `InventoryResponseData` | Mỗi phần tử là `key/value` | `Ok`, `KeyNotFound`, `ItemNotFound` |
|
|
103
|
+
| `setDisplayNameAsync` | Set display name | `itemId`, `displayName` | `EmptyResponseData` | Display name có min length 5 | `Ok`, `ItemNotFound` |
|
|
104
|
+
| `setItemDataAsync` | Set item data theo nhiều key | `itemId`, `itemDatas[]` | `InventoryResponseData` | Mỗi phần tử là `key/value` | `Ok`, `KeyNotFound`, `ItemNotFound` |
|
|
105
|
+
| `changeItemStatisticsAsync` | Cộng/trừ statistics | `itemId`, `itemStatistics[]`, `log?` | `InventoryResponseData` | Dùng cho delta change | `Ok`, `KeyNotFound`, `ItemNotFound` |
|
|
106
|
+
| `setOwnerAsync` | Chuyển owner của item | `itemId`, `newOwnerId`, `newOwnerType` | `EmptyResponseData` | Map `newOwnerType` bằng `OwnerType` | `Ok`, `ItemNotFound`, `OwnerNotFound`, `OwnerTypeNotSupport` |
|
|
107
|
+
| `setRemoveStatusAsync` | Đánh dấu item bị remove | `itemId`, `reason?` | `EmptyResponseData` | Không phải hard delete | `Ok`, `ItemNotFound` |
|
|
108
|
+
|
|
109
|
+
## 5. Enum và Reference
|
|
110
|
+
|
|
111
|
+
- DTO fields: [reference/dto/INVENTORY.md](../reference/dto/INVENTORY.md). Method table: [reference/API_INVENTORY.md](../reference/API_INVENTORY.md).
|
|
112
|
+
- Enums: [ItemType](../reference/ENUMS.md#itemtype), [OwnerType](../reference/ENUMS.md#ownertype).
|
|
113
|
+
- Fallback `dist` chỉ khi reference docs chưa đủ: `dist/runtime/entity/models/Inventory*.d.ts`, `dist/runtime/entity/models/GenericModels.d.ts`.
|
|
114
|
+
- `InfoResponseParameters.itemType` nên map bằng `ItemType`.
|
|
115
|
+
- `InfoResponseParameters.owner.type` và `SetOwnerRequestData.newOwnerType` nên map bằng `OwnerType`.
|
|
116
|
+
- `GenericModels.AvatarItem.type` và `SetAvatarRequestData.type` hiện chưa có enum public trong package. Nếu backend có enum riêng, phải dùng spec backend đó.
|
|
117
|
+
|
|
118
|
+
## 6. InfoRequestParam Rules
|
|
119
|
+
|
|
120
|
+
`InventoryModels.InfoRequestParam` điều khiển payload trả về trong:
|
|
121
|
+
|
|
122
|
+
- `getItemInformationAsync`
|
|
123
|
+
- `getItemsWithDisplayNameAsync`
|
|
124
|
+
- `getItemsWithSegmentAsync`
|
|
125
|
+
- `getItemsWithTagAsync`
|
|
126
|
+
- `getStatisticsLeaderboardAroundItemAsync`
|
|
127
|
+
- `getStatisticsLeaderboardAsync`
|
|
128
|
+
- `getCreateLeaderboardAsync`
|
|
129
|
+
|
|
130
|
+
Rule cứng:
|
|
131
|
+
|
|
132
|
+
- Không truyền `null`.
|
|
133
|
+
- Không bật toàn bộ field một cách mù quáng.
|
|
134
|
+
- Chỉ bật field mà màn hình hoặc flow hiện tại thật sự cần.
|
|
135
|
+
- Nếu cần filter dữ liệu con, dùng các field key-filter tương ứng:
|
|
136
|
+
- `itemDataKeys`
|
|
137
|
+
- `itemStatisticsKeys`
|
|
138
|
+
- `customDataKeys`
|
|
139
|
+
- `tagKeys`
|
|
140
|
+
- Nếu chỉ cần 1 field đơn lẻ như amount hoặc owner, ưu tiên getter chuyên biệt như `getAmountAsync` hoặc `getOwnerAsync` thay vì `getItemInformationAsync`.
|
|
141
|
+
|
|
142
|
+
Các field thường dùng:
|
|
143
|
+
|
|
144
|
+
- `catalogId`
|
|
145
|
+
- `classId`
|
|
146
|
+
- `itemType`
|
|
147
|
+
- `amount`
|
|
148
|
+
- `owner`
|
|
149
|
+
- `removeStatus`
|
|
150
|
+
- `segments`
|
|
151
|
+
- `customDatas`
|
|
152
|
+
- `displayName`
|
|
153
|
+
- `avatar`
|
|
154
|
+
- `tsCreate`
|
|
155
|
+
- `tags`
|
|
156
|
+
- `itemStatistics`
|
|
157
|
+
- `itemDatas`
|
|
158
|
+
|
|
159
|
+
## 7. Decision Rules
|
|
160
|
+
|
|
161
|
+
- Cần đọc đúng 1 field nhỏ của item: ưu tiên getter chuyên biệt.
|
|
162
|
+
- Cần lấy nhiều field trong một lần gọi: dùng `getItemInformationAsync`.
|
|
163
|
+
- Cần search item theo tên: dùng `getItemsWithDisplayNameAsync`.
|
|
164
|
+
- Cần search item theo segment: dùng `getItemsWithSegmentAsync`.
|
|
165
|
+
- Cần search item theo tag: dùng `getItemsWithTagAsync`.
|
|
166
|
+
- Cần leaderboard theo statistics key: dùng `getStatisticsLeaderboardAsync`.
|
|
167
|
+
- Cần leaderboard quanh một item cụ thể: dùng `getStatisticsLeaderboardAroundItemAsync`.
|
|
168
|
+
- Cần leaderboard theo thời điểm tạo: dùng `getCreateLeaderboardAsync`.
|
|
169
|
+
- Cần cộng/trừ stats: dùng `changeItemStatisticsAsync`.
|
|
170
|
+
- Cần set lại amount tuyệt đối: dùng `setAmountAsync`.
|
|
171
|
+
- Cần chuyển item sang owner mới: dùng `setOwnerAsync`.
|
|
172
|
+
- Cần audit biến động statistics: dùng `getStatisticsLogAsync`.
|
|
173
|
+
|
|
174
|
+
## 8. Response Rules
|
|
175
|
+
|
|
176
|
+
Tất cả typed response của `InventoryApi` đều có:
|
|
177
|
+
|
|
178
|
+
- `returnCode`
|
|
179
|
+
- `debugMessage`
|
|
180
|
+
- `invalidMembers`
|
|
181
|
+
- `errorCode`
|
|
182
|
+
- `responseData`
|
|
183
|
+
|
|
184
|
+
Rule kiểm tra response:
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
if (response.hasReturnCodeError()) {
|
|
188
|
+
throw new Error(response.debugMessage);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
192
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Những response chính AI cần nhớ:
|
|
197
|
+
|
|
198
|
+
- Hầu hết getter đơn lẻ trả `InventoryResponseData` và dữ liệu nằm trong `responseData.infoResponseParameters`.
|
|
199
|
+
- Các method list `getItemsWith*Async` trả `responseData.results`, mỗi phần tử có `itemId` và `infoResponseParameters`.
|
|
200
|
+
- `getStatisticsLeaderboardAroundItemAsync` và `getStatisticsLeaderboardAsync` trả `responseData.results` có `itemId`, `position`, `backupValue?`, `infoResponseParameters`.
|
|
201
|
+
- `getCreateLeaderboardAsync` trả `responseData.results` cùng shape leaderboard item.
|
|
202
|
+
- `getStatisticsLogAsync` trả `responseData.results` và có thể có `responseData.token` cho page tiếp.
|
|
203
|
+
- `addSegmentAsync`, `removeSegmentAsync`, `removeTagAsync`, `setAvatarAsync`, `setDisplayNameAsync`, `setOwnerAsync`, `setRemoveStatusAsync`, `setTagAsync` trả `EmptyResponseData`.
|
|
204
|
+
- `setAmountAsync`, `setCustomDataAsync`, `setItemDataAsync`, `changeItemStatisticsAsync` trả `InventoryResponseData`.
|
|
205
|
+
|
|
206
|
+
## 9. Cảnh Báo Implementation Hiện Tại
|
|
207
|
+
|
|
208
|
+
- `SetOwnerRequestData.itemId` hiện được decorate với length `11..11`, trong khi hầu hết request inventory khác dùng `12..12`.
|
|
209
|
+
- Đây là điểm không nhất quán trong model hiện tại.
|
|
210
|
+
- Nếu bạn tự thêm validation ngoài SDK, không được tự hardcode thêm rule khác trước khi verify backend spec thật.
|
|
211
|
+
- `GetItemStatisticsRequestData` dùng `statisticsKeys`, còn `InfoRequestParam` dùng `itemStatisticsKeys`. Đây là hai input khác nhau, đừng trộn lẫn.
|
|
212
|
+
|
|
213
|
+
## 10. Best Practices
|
|
214
|
+
|
|
215
|
+
- Dùng getter chuyên biệt khi chỉ cần một field nhỏ.
|
|
216
|
+
- Với query lớn, giữ `infoRequestParam` tối giản để giảm payload.
|
|
217
|
+
- Với `getStatisticsLogAsync`, nên truyền ít nhất `keys` hoặc `itemId` trong production để tránh query quá rộng.
|
|
218
|
+
- Với leaderboard, dùng `loadFromCache` mặc định nếu chấp nhận dữ liệu cache; chỉ đổi khi bạn thật sự hiểu trade-off.
|
|
219
|
+
- Với `changeItemStatisticsAsync`, luôn truyền `log` nếu flow cần audit.
|
|
220
|
+
- Với `setOwnerAsync`, luôn map `newOwnerType` bằng `OwnerType`, không dùng số thô.
|
|
221
|
+
- Với `setAvatarAsync`, giữ `type` theo đúng backend contract vì package chưa có enum public.
|
|
222
|
+
|
|
223
|
+
## 11. Ví dụ Khuyến Nghị
|
|
224
|
+
|
|
225
|
+
### Đọc item information với `infoRequestParam` tối giản
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
import {
|
|
229
|
+
ErrorCode,
|
|
230
|
+
GNNetwork,
|
|
231
|
+
InventoryModels,
|
|
232
|
+
ItemType,
|
|
233
|
+
OwnerType,
|
|
234
|
+
} from "@xmobitea/gn-typescript-client";
|
|
235
|
+
|
|
236
|
+
const infoRequestParam = new InventoryModels.InfoRequestParam();
|
|
237
|
+
infoRequestParam.itemType = true;
|
|
238
|
+
infoRequestParam.amount = true;
|
|
239
|
+
infoRequestParam.owner = true;
|
|
240
|
+
infoRequestParam.displayName = true;
|
|
241
|
+
|
|
242
|
+
const request = new InventoryModels.GetItemInformationRequestData();
|
|
243
|
+
request.itemId = "ABCDEFGHIJKL";
|
|
244
|
+
request.infoRequestParam = infoRequestParam;
|
|
245
|
+
|
|
246
|
+
const response = await GNNetwork.inventory.getItemInformationAsync(request);
|
|
247
|
+
|
|
248
|
+
if (response.hasReturnCodeError()) {
|
|
249
|
+
throw new Error(response.debugMessage);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
253
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const itemInfo = response.responseData.infoResponseParameters;
|
|
257
|
+
const itemType = itemInfo.itemType as ItemType | undefined;
|
|
258
|
+
const ownerType = itemInfo.owner?.type as OwnerType | undefined;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Cộng statistics có audit log
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
import {
|
|
265
|
+
ErrorCode,
|
|
266
|
+
GNNetwork,
|
|
267
|
+
InventoryModels,
|
|
268
|
+
} from "@xmobitea/gn-typescript-client";
|
|
269
|
+
|
|
270
|
+
const statisticsParam = new InventoryModels.ItemStatisticsParam();
|
|
271
|
+
statisticsParam.key = "killCount";
|
|
272
|
+
statisticsParam.value = 1;
|
|
273
|
+
|
|
274
|
+
const request = new InventoryModels.ChangeItemStatisticsRequestData();
|
|
275
|
+
request.itemId = "ABCDEFGHIJKL";
|
|
276
|
+
request.itemStatistics = [statisticsParam];
|
|
277
|
+
request.log = "award_kill_from_match_end";
|
|
278
|
+
|
|
279
|
+
const response = await GNNetwork.inventory.changeItemStatisticsAsync(request);
|
|
280
|
+
|
|
281
|
+
if (response.hasReturnCodeError()) {
|
|
282
|
+
throw new Error(response.debugMessage);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
286
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Đọc leaderboard quanh một item
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import {
|
|
294
|
+
ErrorCode,
|
|
295
|
+
GNNetwork,
|
|
296
|
+
InventoryModels,
|
|
297
|
+
} from "@xmobitea/gn-typescript-client";
|
|
298
|
+
|
|
299
|
+
const infoRequestParam = new InventoryModels.InfoRequestParam();
|
|
300
|
+
infoRequestParam.displayName = true;
|
|
301
|
+
infoRequestParam.itemStatistics = true;
|
|
302
|
+
infoRequestParam.itemStatisticsKeys = ["killCount"];
|
|
303
|
+
|
|
304
|
+
const request = new InventoryModels.GetStatisticsLeaderboardAroundItemRequestData();
|
|
305
|
+
request.itemId = "ABCDEFGHIJKL";
|
|
306
|
+
request.key = "killCount";
|
|
307
|
+
request.infoRequestParam = infoRequestParam;
|
|
308
|
+
request.skip = 0;
|
|
309
|
+
request.limit = 20;
|
|
310
|
+
request.loadFromCache = true;
|
|
311
|
+
|
|
312
|
+
const response = await GNNetwork.inventory.getStatisticsLeaderboardAroundItemAsync(request);
|
|
313
|
+
|
|
314
|
+
if (response.hasReturnCodeError()) {
|
|
315
|
+
throw new Error(response.debugMessage);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
319
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const results = response.responseData.results;
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Đọc statistics log với cursor
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
import {
|
|
329
|
+
ErrorCode,
|
|
330
|
+
GNNetwork,
|
|
331
|
+
InventoryModels,
|
|
332
|
+
} from "@xmobitea/gn-typescript-client";
|
|
333
|
+
|
|
334
|
+
const request = new InventoryModels.GetStatisticsLogRequestData();
|
|
335
|
+
request.itemId = "ABCDEFGHIJKL";
|
|
336
|
+
request.keys = ["killCount"];
|
|
337
|
+
request.limit = 20;
|
|
338
|
+
|
|
339
|
+
const response = await GNNetwork.inventory.getStatisticsLogAsync(request);
|
|
340
|
+
|
|
341
|
+
if (response.hasReturnCodeError()) {
|
|
342
|
+
throw new Error(response.debugMessage);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
346
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const logs = response.responseData.results;
|
|
350
|
+
const nextToken = response.responseData.token;
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## 12. Anti-Patterns
|
|
354
|
+
|
|
355
|
+
- Không gọi `getItemInformationAsync` chỉ để đọc một field đơn lẻ nếu getter chuyên biệt đã có.
|
|
356
|
+
- Không bỏ `infoRequestParam` ở các method bắt buộc.
|
|
357
|
+
- Không dùng `itemStatisticsKeys` thay cho `statisticsKeys` hoặc ngược lại.
|
|
358
|
+
- Không dùng `setAmountAsync` khi ý đồ là tăng/giảm delta.
|
|
359
|
+
- Không dùng `setOwnerAsync` nếu mục tiêu là duplicate item cho owner mới.
|
|
360
|
+
- Không hardcode số cho `ItemType` hoặc `OwnerType`.
|
|
361
|
+
- Không tự phát minh enum cho `avatar.type` nếu package chưa export.
|
|
362
|
+
- Không phân trang `getStatisticsLogAsync` bằng `skip`.
|
|
363
|
+
- Không bỏ qua kiểm tra `hasReturnCodeError()` và `errorCode`.
|
|
364
|
+
|
|
365
|
+
## 13. AI Checklist
|
|
366
|
+
|
|
367
|
+
- Đã `GNNetwork.init(settings)` chưa.
|
|
368
|
+
- Có chọn đúng namespace `inventory` / `inventory.server` / `inventory.admin` chưa.
|
|
369
|
+
- Có nhớ rằng `InventoryApi` hiện chỉ đi qua HTTP không.
|
|
370
|
+
- Flow hiện tại là getter chuyên biệt, aggregate info, list query, leaderboard hay mutation.
|
|
371
|
+
- Nếu đang gọi method có `infoRequestParam`, đã truyền object này chưa.
|
|
372
|
+
- Nếu đang đọc statistics theo getter chuyên biệt, có dùng đúng `statisticsKeys` chưa.
|
|
373
|
+
- Nếu đang map `itemType` hoặc owner type, có dùng enum publish thay vì số thô không.
|
|
374
|
+
- Nếu đang đọc log, có dùng `token` cho page tiếp chưa.
|
|
375
|
+
- Có kiểm tra `hasReturnCodeError()` trước `errorCode` chưa.
|