@xmobitea/gn-typescript-client 2.6.13-tsc → 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 +71354 -0
- package/dist/gearn.js.client.min.js +2 -0
- package/dist/gearn.js.client.min.js.LICENSE.txt +14 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +58386 -339
- 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 +11 -2
- package/GNServerSettings.debug.json +0 -21
- package/dist/runtime/GNNetwork.js +0 -273
- package/dist/runtime/GNNetworkAuthenticateApi.js +0 -122
- package/dist/runtime/GNNetworkCharacterPlayerApi.js +0 -968
- package/dist/runtime/GNNetworkCloudScriptApi.js +0 -104
- package/dist/runtime/GNNetworkContentApi.js +0 -140
- package/dist/runtime/GNNetworkDashboardApi.js +0 -170
- package/dist/runtime/GNNetworkGamePlayerApi.js +0 -950
- package/dist/runtime/GNNetworkGroupApi.js +0 -734
- package/dist/runtime/GNNetworkInventoryApi.js +0 -626
- package/dist/runtime/GNNetworkMasterPlayerApi.js +0 -1550
- package/dist/runtime/GNNetworkMultiplayerApi.js +0 -194
- package/dist/runtime/GNNetworkStoreInventoryApi.js +0 -266
- package/dist/runtime/common/Action0.js +0 -1
- package/dist/runtime/common/Action1.js +0 -1
- package/dist/runtime/common/Action2.js +0 -1
- package/dist/runtime/common/Action3.js +0 -1
- package/dist/runtime/common/Action4.js +0 -1
- package/dist/runtime/common/GNData.js +0 -209
- package/dist/runtime/config/GNServerSettings.js +0 -156
- package/dist/runtime/constant/Commands.js +0 -20
- package/dist/runtime/constant/EventCode.js +0 -8
- package/dist/runtime/constant/OperationCode.js +0 -221
- package/dist/runtime/constant/ReturnCode.js +0 -14
- package/dist/runtime/constant/enumType/ExecuteResponseStatus.js +0 -8
- package/dist/runtime/constant/enumType/FriendStatus.js +0 -7
- package/dist/runtime/constant/enumType/GoogleLoginType.js +0 -5
- package/dist/runtime/constant/enumType/GroupStatus.js +0 -7
- package/dist/runtime/constant/enumType/InvalidMemberType.js +0 -18
- package/dist/runtime/constant/enumType/ItemType.js +0 -5
- package/dist/runtime/constant/enumType/MatchmakingMemberStatus.js +0 -6
- package/dist/runtime/constant/enumType/MatchmakingTicketStatus.js +0 -8
- package/dist/runtime/constant/enumType/OwnerType.js +0 -9
- package/dist/runtime/constant/enumType/PermissionDataItem.js +0 -5
- package/dist/runtime/constant/enumType/PushPlatformType.js +0 -5
- package/dist/runtime/constant/enumType/RequestRole.js +0 -6
- package/dist/runtime/constant/enumType/RequestType.js +0 -15
- package/dist/runtime/constant/enumType/StoreItemType.js +0 -5
- package/dist/runtime/constant/enumType/StoreReceiveType.js +0 -8
- package/dist/runtime/constant/errorCode/ErrorCode.js +0 -52
- package/dist/runtime/constant/parameterCode/ParameterCode.js +0 -617
- package/dist/runtime/entity/DataMember.js +0 -208
- package/dist/runtime/entity/GNMetadata.js +0 -11
- package/dist/runtime/entity/InvalidMember.js +0 -1
- package/dist/runtime/entity/OperationEvent.js +0 -24
- package/dist/runtime/entity/OperationRequest.js +0 -42
- package/dist/runtime/entity/OperationResponse.js +0 -73
- package/dist/runtime/entity/models/AuthenticateModels.js +0 -426
- package/dist/runtime/entity/models/AuthenticateRequestModels.js +0 -188
- package/dist/runtime/entity/models/AuthenticateResponseModels.js +0 -131
- package/dist/runtime/entity/models/CharacterPlayerModels.js +0 -1433
- package/dist/runtime/entity/models/CharacterPlayerRequestModels.js +0 -1386
- package/dist/runtime/entity/models/CharacterPlayerResponseModels.js +0 -376
- package/dist/runtime/entity/models/CloudScriptModels.js +0 -197
- package/dist/runtime/entity/models/CloudScriptRequestModels.js +0 -138
- package/dist/runtime/entity/models/CloudScriptResponseModels.js +0 -40
- package/dist/runtime/entity/models/ContentModels.js +0 -203
- package/dist/runtime/entity/models/ContentRequestModels.js +0 -190
- package/dist/runtime/entity/models/ContentResponseModels.js +0 -54
- package/dist/runtime/entity/models/DashboardModels.js +0 -3002
- package/dist/runtime/entity/models/DashboardRequestModels.js +0 -268
- package/dist/runtime/entity/models/DashboardResponseModels.js +0 -187
- package/dist/runtime/entity/models/GamePlayerModels.js +0 -1591
- package/dist/runtime/entity/models/GamePlayerRequestModels.js +0 -1360
- package/dist/runtime/entity/models/GamePlayerResponseModels.js +0 -369
- package/dist/runtime/entity/models/GenericModels.js +0 -177
- package/dist/runtime/entity/models/GroupModels.js +0 -1135
- package/dist/runtime/entity/models/GroupRequestModels.js +0 -1048
- package/dist/runtime/entity/models/GroupResponseModels.js +0 -285
- package/dist/runtime/entity/models/InventoryModels.js +0 -915
- package/dist/runtime/entity/models/InventoryRequestModels.js +0 -892
- package/dist/runtime/entity/models/InventoryResponseModels.js +0 -243
- package/dist/runtime/entity/models/MasterPlayerModels.js +0 -2573
- package/dist/runtime/entity/models/MasterPlayerRequestModels.js +0 -2228
- package/dist/runtime/entity/models/MasterPlayerResponseModels.js +0 -607
- package/dist/runtime/entity/models/MultiplayerModels.js +0 -404
- package/dist/runtime/entity/models/MultiplayerRequestModels.js +0 -268
- package/dist/runtime/entity/models/MultiplayerResponseModels.js +0 -75
- package/dist/runtime/entity/models/StoreInventoryModels.js +0 -797
- package/dist/runtime/entity/models/StoreInventoryRequestModels.js +0 -372
- package/dist/runtime/entity/models/StoreInventoryResponseModels.js +0 -103
- package/dist/runtime/entity/request/CustomOperationRequest.js +0 -24
- package/dist/runtime/entity/response/CustomOperationResponse.js +0 -29
- package/dist/runtime/entity/response/GetAuthInfoResponse.js +0 -2
- package/dist/runtime/entity/response/HealthCheckResponse.js +0 -2
- package/dist/runtime/entity/response/UploadFileResponse.js +0 -2
- package/dist/runtime/helper/CodeHelper.js +0 -63
- package/dist/runtime/helper/ConverterService.js +0 -275
- package/dist/runtime/helper/EnumUtility.js +0 -33
- package/dist/runtime/helper/GNSupport.js +0 -47
- package/dist/runtime/helper/GNUtils.js +0 -72
- package/dist/runtime/helper/MessagePackConverterService.js +0 -9
- package/dist/runtime/helper/OperationHelper.js +0 -24
- package/dist/runtime/helper/StorageService.js +0 -62
- package/dist/runtime/logger/GNDebug.js +0 -29
- package/dist/runtime/networking/AuthenticateStatus.js +0 -14
- package/dist/runtime/networking/IPeer.js +0 -1
- package/dist/runtime/networking/NetworkingPeer.js +0 -210
- package/dist/runtime/networking/OperationPending.js +0 -53
- package/dist/runtime/networking/PeerBase.js +0 -161
- package/dist/runtime/networking/handler/IServerEventHandler.js +0 -13
- package/dist/runtime/networking/handler/OnCharacterPlayerFriendUpdateEventHandler.js +0 -39
- package/dist/runtime/networking/handler/OnCharacterPlayerGroupUpdateEventHandler.js +0 -39
- package/dist/runtime/networking/handler/OnGamePlayerFriendUpdateEventHandler.js +0 -39
- package/dist/runtime/networking/handler/OnGamePlayerGroupUpdateEventHandler.js +0 -39
- package/dist/runtime/networking/handler/OnGroupMemberUpdateEventHandler.js +0 -35
- package/dist/runtime/networking/handler/OnGroupMessageUpdateEventHandler.js +0 -43
- package/dist/runtime/networking/http/HttpPeer.js +0 -123
- package/dist/runtime/networking/http/NetworkingHttpPeerBase.js +0 -9
- package/dist/runtime/networking/http/NetworkingPeerAxiosRequest.js +0 -179
- package/dist/runtime/networking/socket/NetworkingPeerSocketIOClient.js +0 -130
- package/dist/runtime/networking/socket/NetworkingSocketPeerBase.js +0 -165
- package/dist/runtime/networking/socket/SocketPeer.js +0 -115
- package/dist/runtime/typescript/ServiceUpdate.js +0 -22
- 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,303 @@
|
|
|
1
|
+
# MultiplayerApi
|
|
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`, gọi đúng sequence matchmaking, và không nhầm `MultiplayerApi` với flow socket realtime.
|
|
4
|
+
|
|
5
|
+
## 1. Scope
|
|
6
|
+
|
|
7
|
+
- Áp dụng cho:
|
|
8
|
+
- `GNNetwork.multiplayer`
|
|
9
|
+
- `GNNetwork.multiplayer.server`
|
|
10
|
+
- `GNNetwork.multiplayer.admin`
|
|
11
|
+
- Toàn bộ method hiện tại của `MultiplayerApi` đều gửi qua HTTP.
|
|
12
|
+
- `MultiplayerApi` có đủ 3 role thật:
|
|
13
|
+
- `GNNetwork.multiplayer` -> `RequestRole.Client`
|
|
14
|
+
- `GNNetwork.multiplayer.server` -> `RequestRole.Server`
|
|
15
|
+
- `GNNetwork.multiplayer.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 semantics permission xem [RULES](../RULES.md#3-route--trust-boundary-của-caller). Với nhóm này, không tự suy diễn route chỉ từ target ownership.
|
|
20
|
+
- `MultiplayerApi` xử lý matchmaking ticket, queue statistics và dữ liệu match. Nó không thay thế socket transport của SDK.
|
|
21
|
+
|
|
22
|
+
## 2. Hard Rules
|
|
23
|
+
|
|
24
|
+
- Luôn ưu tiên `async/await`. Mặc định dùng `*Async()`.
|
|
25
|
+
- Bắt buộc đã `GNNetwork.init(settings)` trước khi gọi.
|
|
26
|
+
- Không dùng socket để tạo, join, cancel hay query matchmaking ticket. Tất cả wrapper hiện tại đều là HTTP.
|
|
27
|
+
- Nếu code chạy trong game client, ưu tiên `GNNetwork.multiplayer`.
|
|
28
|
+
- Nếu code chạy ở trusted backend/worker, ưu tiên `GNNetwork.multiplayer.server`.
|
|
29
|
+
- Nếu code chạy ở dashboard/tool vận hành, ưu tiên `GNNetwork.multiplayer.admin`.
|
|
30
|
+
- Với `server` và `admin`, một số operation thao tác theo user khác bắt buộc có `userId`.
|
|
31
|
+
- `createMatchmakingTicketAsync` không trả match ngay; nó chỉ trả `ticketId`.
|
|
32
|
+
- `joinMatchmakingTicketAsync` và `cancelMatchmakingTicketAsync` trả `EmptyResponseData`; muốn biết state mới phải gọi API query tiếp.
|
|
33
|
+
- Không giả định `GetMatchResponseData` có IP/port server. Model hiện tại của response không expose `ServerDetail`.
|
|
34
|
+
|
|
35
|
+
## 3. Chọn Namespace
|
|
36
|
+
|
|
37
|
+
| Namespace | Role thật | Dùng khi nào |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `GNNetwork.multiplayer` | `Client` | player app tự thao tác ticket của chính user hiện tại |
|
|
40
|
+
| `GNNetwork.multiplayer.server` | `Server` | backend service thao tác ticket/match của user cụ thể |
|
|
41
|
+
| `GNNetwork.multiplayer.admin` | `Admin` | dashboard, GM tool, vận hành |
|
|
42
|
+
|
|
43
|
+
Rule nhanh:
|
|
44
|
+
|
|
45
|
+
- Nếu thao tác gắn với auth token hiện tại của player: dùng `GNNetwork.multiplayer`.
|
|
46
|
+
- Nếu backend/admin cần thao tác ticket của user khác: dùng `server` hoặc `admin`.
|
|
47
|
+
- Với `server/admin`, nếu model có thêm `userId` thì phải truyền.
|
|
48
|
+
|
|
49
|
+
## 4. Chọn Method
|
|
50
|
+
|
|
51
|
+
| Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú | ErrorCode
|
|
52
|
+
| --- | --- | --- | --- | --- | --- |
|
|
53
|
+
| `createMatchmakingTicketAsync` | Tạo ticket mới để bắt đầu matchmaking | `giveUpAfterSeconds`, `queueName`, `attribute?`, `members?` | `CreateMatchmakingTicketResponseData` | Trả `ticketId`; với `server/admin` cần thêm `userId` | `Ok`, `MatchmakingPlayerJoinedOtherTicket`, `MatchmakingQueueNotFound`, `TicketSizeError` |
|
|
54
|
+
| `joinMatchmakingTicketAsync` | Thêm user vào ticket đã tồn tại | `ticketId`, `attribute?` | `EmptyResponseData` | Với `server/admin` cần thêm `userId` | `Ok`, `MatchmakingTicketNotFound`, `MatchmakingTicketAlreadyCompleted`, `MatchmakingPlayerJoinedOtherTicket`, `MatchmakingQueueNotFound` |
|
|
55
|
+
| `cancelMatchmakingTicketAsync` | Hủy 1 ticket cụ thể | `ticketId` | `EmptyResponseData` | Với `server/admin` cần thêm `userId` | `Ok`, `MatchmakingTicketNotFound`, `MatchmakingTicketAlreadyCompleted`, `MatchmakingPlayerNotJoinedTicket` |
|
|
56
|
+
| `cancelAllMatchmakingTicketAsync` | Hủy toàn bộ ticket của 1 queue | `queueName` | `CancelAllMatchmakingTicketResponseData` | Với `server/admin` cần thêm `userId`; response trả `ticketIds` | `Ok`, `MatchmakingQueueNotFound` |
|
|
57
|
+
| `getMatchmakingTicketAsync` | Poll trạng thái ticket cụ thể | `ticketId`, `returnMember?` | `GetMatchmakingTicketResponseData` | Khi `status` đổi sang matched có thể có `matchId` | `Ok`, `MatchmakingTicketNotFound` |
|
|
58
|
+
| `listMatchmakingTicketsForPlayerAsync` | Liệt kê ticket của user trong một queue | `queueName` | `ListMatchmakingTicketsForPlayerResponseData` | Với `server/admin` cần thêm `userId` | `Ok`, `MatchmakingQueueNotFound` |
|
|
59
|
+
| `getMatchAsync` | Lấy chi tiết 1 match theo `matchId` | `matchId`, `returnMember?` | `GetMatchResponseData` | Không giả định có server endpoint | `Ok`, `MatchNotFound` |
|
|
60
|
+
| `getAllMatchAsync` | Liệt kê match hiện có | `returnMember?`, `skip?`, `limit?` | `GetAllMatchResponseData` | Dùng cho admin/ops/listing | `Ok` |
|
|
61
|
+
| `getAllMatchmakingTicketAsync` | Liệt kê ticket hiện có | `status?`, `returnMember?`, `skip?`, `limit?` | `GetAllMatchmakingTicketResponseData` | `status` nên map bằng enum | `Ok` |
|
|
62
|
+
| `getQueueStatisticsAsync` | Lấy thống kê queue trong một time window | `queueName`, `timeInSeconds` | `GetQueueStatisticsResponseData` | `timeInSeconds >= 20` | `Ok`, `MatchmakingQueueNotFound` |
|
|
63
|
+
|
|
64
|
+
## 5. Matchmaking Sequence
|
|
65
|
+
|
|
66
|
+
### Flow chuẩn cho client
|
|
67
|
+
|
|
68
|
+
1. `createMatchmakingTicketAsync(...)`
|
|
69
|
+
2. Lấy `ticketId`
|
|
70
|
+
3. Poll `getMatchmakingTicketAsync(...)`
|
|
71
|
+
4. Khi `status` cho biết đã match và response có `matchId`, gọi `getMatchAsync(...)`
|
|
72
|
+
|
|
73
|
+
### Flow join ticket đã có
|
|
74
|
+
|
|
75
|
+
1. `joinMatchmakingTicketAsync(...)`
|
|
76
|
+
2. Poll `getMatchmakingTicketAsync(...)`
|
|
77
|
+
3. Khi có `matchId`, gọi `getMatchAsync(...)`
|
|
78
|
+
|
|
79
|
+
### Flow hủy
|
|
80
|
+
|
|
81
|
+
1. `cancelMatchmakingTicketAsync(...)` hoặc `cancelAllMatchmakingTicketAsync(...)`
|
|
82
|
+
2. Nếu cần xác nhận state hiện tại, gọi `getMatchmakingTicketAsync(...)` hoặc `listMatchmakingTicketsForPlayerAsync(...)`
|
|
83
|
+
|
|
84
|
+
Rule cứng:
|
|
85
|
+
|
|
86
|
+
- Không chờ `createMatchmakingTicketAsync` trả match data.
|
|
87
|
+
- Không chờ `joinMatchmakingTicketAsync` trả ticket state mới.
|
|
88
|
+
- Không bỏ bước poll nếu flow của bạn cần biết đã match hay chưa.
|
|
89
|
+
|
|
90
|
+
## 6. Request Rules và Reference
|
|
91
|
+
|
|
92
|
+
- DTO fields: [reference/dto/MULTIPLAYER.md](../reference/dto/MULTIPLAYER.md). Method table: [reference/API_MULTIPLAYER.md](../reference/API_MULTIPLAYER.md).
|
|
93
|
+
- Enums: [MatchmakingTicketStatus](../reference/ENUMS.md#matchmakingticketstatus), [MatchmakingMemberStatus](../reference/ENUMS.md#matchmakingmemberstatus).
|
|
94
|
+
- Fallback `dist` chỉ khi reference docs chưa đủ: `dist/runtime/entity/models/Multiplayer*.d.ts`.
|
|
95
|
+
- `CreateMatchmakingTicketRequestData.giveUpAfterSeconds` có min `20`.
|
|
96
|
+
- `GetQueueStatisticsRequestData.timeInSeconds` có min `20`.
|
|
97
|
+
- `queueName` có min `6`, max `32`.
|
|
98
|
+
- `ticketId` có độ dài `10`.
|
|
99
|
+
- `matchId` có độ dài `15`.
|
|
100
|
+
- `GetAllMatchmakingTicketRequestData.status` là numeric field tùy chọn; nên map bằng `MatchmakingTicketStatus`, không đoán số bừa.
|
|
101
|
+
- `returnMember` mặc định là `false`; chỉ bật khi thật sự cần member list.
|
|
102
|
+
- Với `server/admin`, các model sau có thêm `userId`:
|
|
103
|
+
- `createMatchmakingTicket`
|
|
104
|
+
- `joinMatchmakingTicket`
|
|
105
|
+
- `cancelMatchmakingTicket`
|
|
106
|
+
- `cancelAllMatchmakingTicket`
|
|
107
|
+
- `listMatchmakingTicketsForPlayer`
|
|
108
|
+
|
|
109
|
+
## 7. Response Rules
|
|
110
|
+
|
|
111
|
+
Tất cả typed response của `MultiplayerApi` đều có:
|
|
112
|
+
|
|
113
|
+
- `returnCode`
|
|
114
|
+
- `debugMessage`
|
|
115
|
+
- `invalidMembers`
|
|
116
|
+
- `errorCode`
|
|
117
|
+
- `responseData`
|
|
118
|
+
|
|
119
|
+
Rule kiểm tra response:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
if (response.hasReturnCodeError()) {
|
|
123
|
+
throw new Error(response.debugMessage);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
127
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Những response chính AI cần nhớ:
|
|
132
|
+
|
|
133
|
+
- `createMatchmakingTicketAsync` trả `responseData.ticketId`.
|
|
134
|
+
- `cancelAllMatchmakingTicketAsync` trả `responseData.ticketIds`.
|
|
135
|
+
- `getMatchmakingTicketAsync` trả `responseData.matchmakingTicket`.
|
|
136
|
+
- `getMatchAsync` trả `responseData.match`.
|
|
137
|
+
- `getQueueStatisticsAsync` trả `pendingMemberCount`, `pendingTicketCount`, `averageMatchmakingTimeInSeconds`.
|
|
138
|
+
- `getAllMatchAsync` trả `results`.
|
|
139
|
+
- `getAllMatchmakingTicketAsync` trả `results`.
|
|
140
|
+
- `cancelMatchmakingTicketAsync` và `joinMatchmakingTicketAsync` trả `EmptyResponseData`.
|
|
141
|
+
|
|
142
|
+
Ghi chú quan trọng:
|
|
143
|
+
|
|
144
|
+
- `MatchmakingTicketResponseData.status` nên đọc bằng enum `MatchmakingTicketStatus`.
|
|
145
|
+
- `MatchmakingTicketMember.status` nên đọc bằng enum `MatchmakingMemberStatus`.
|
|
146
|
+
- `GetMatchResponseData.match` hiện chỉ có `tsCreate`, `queueName`, `members?`, `timeToMatchInSeconds`; không có server IP/port trong response model hiện tại.
|
|
147
|
+
|
|
148
|
+
## 8. Decision Rules
|
|
149
|
+
|
|
150
|
+
- Muốn bắt đầu tìm trận: dùng `createMatchmakingTicketAsync`.
|
|
151
|
+
- Muốn ghép thêm player vào ticket đang có: dùng `joinMatchmakingTicketAsync`.
|
|
152
|
+
- Muốn xem ticket đã matched chưa: dùng `getMatchmakingTicketAsync`.
|
|
153
|
+
- Đã có `matchId` và muốn lấy match detail: dùng `getMatchAsync`.
|
|
154
|
+
- Muốn xem tất cả ticket của current player trong queue: dùng `listMatchmakingTicketsForPlayerAsync`.
|
|
155
|
+
- Muốn xem snapshot queue hiện tại: dùng `getQueueStatisticsAsync`.
|
|
156
|
+
- Muốn duyệt toàn bộ ticket hoặc match để vận hành: dùng `getAllMatchmakingTicketAsync` hoặc `getAllMatchAsync`.
|
|
157
|
+
- Muốn hủy một ticket: dùng `cancelMatchmakingTicketAsync`.
|
|
158
|
+
- Muốn hủy hàng loạt ticket trong queue: dùng `cancelAllMatchmakingTicketAsync`.
|
|
159
|
+
|
|
160
|
+
## 9. Best Practices
|
|
161
|
+
|
|
162
|
+
- Giữ `returnMember = false` nếu bạn chỉ cần status hoặc id.
|
|
163
|
+
- Chỉ truyền `members` khi bạn thật sự tạo ticket cho nhiều member ngay từ đầu.
|
|
164
|
+
- Với `server/admin`, truyền `userId` rõ ràng thay vì kỳ vọng auth token ngầm chỉ tới user đích.
|
|
165
|
+
- Poll `getMatchmakingTicketAsync` với nhịp hợp lý, không spam quá dày.
|
|
166
|
+
- Khi cần filter ticket theo status, dùng enum `MatchmakingTicketStatus` thay vì hardcode số.
|
|
167
|
+
- Không suy diễn `GetMatchResponseData` là đủ để connect game server. Nếu bạn cần endpoint runtime, phải xác minh từ API/flow khác.
|
|
168
|
+
|
|
169
|
+
## 10. Ví dụ Khuyến Nghị
|
|
170
|
+
|
|
171
|
+
### Client tạo ticket rồi poll tới khi có match
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import {
|
|
175
|
+
ErrorCode,
|
|
176
|
+
GNNetwork,
|
|
177
|
+
MultiplayerModels,
|
|
178
|
+
MatchmakingTicketStatus,
|
|
179
|
+
} from "@xmobitea/gn-typescript-client";
|
|
180
|
+
|
|
181
|
+
const createRequest = new MultiplayerModels.CreateMatchmakingTicketRequestData();
|
|
182
|
+
createRequest.giveUpAfterSeconds = 60;
|
|
183
|
+
createRequest.queueName = "ranked01";
|
|
184
|
+
|
|
185
|
+
const createResponse = await GNNetwork.multiplayer.createMatchmakingTicketAsync(createRequest);
|
|
186
|
+
|
|
187
|
+
if (createResponse.hasReturnCodeError()) {
|
|
188
|
+
throw new Error(createResponse.debugMessage);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (createResponse.errorCode !== ErrorCode.Ok) {
|
|
192
|
+
throw new Error(`Business error: ${createResponse.errorCode}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const ticketId = createResponse.responseData.ticketId;
|
|
196
|
+
|
|
197
|
+
const ticketRequest = new MultiplayerModels.GetMatchmakingTicketRequestData();
|
|
198
|
+
ticketRequest.ticketId = ticketId;
|
|
199
|
+
|
|
200
|
+
const ticketResponse = await GNNetwork.multiplayer.getMatchmakingTicketAsync(ticketRequest);
|
|
201
|
+
|
|
202
|
+
if (ticketResponse.hasReturnCodeError()) {
|
|
203
|
+
throw new Error(ticketResponse.debugMessage);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (ticketResponse.errorCode !== ErrorCode.Ok) {
|
|
207
|
+
throw new Error(`Business error: ${ticketResponse.errorCode}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const ticket = ticketResponse.responseData.matchmakingTicket;
|
|
211
|
+
if (ticket.status === MatchmakingTicketStatus.Matched && ticket.matchId) {
|
|
212
|
+
const matchRequest = new MultiplayerModels.GetMatchRequestData();
|
|
213
|
+
matchRequest.matchId = ticket.matchId;
|
|
214
|
+
|
|
215
|
+
const matchResponse = await GNNetwork.multiplayer.getMatchAsync(matchRequest);
|
|
216
|
+
|
|
217
|
+
if (matchResponse.hasReturnCodeError()) {
|
|
218
|
+
throw new Error(matchResponse.debugMessage);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (matchResponse.errorCode !== ErrorCode.Ok) {
|
|
222
|
+
throw new Error(`Business error: ${matchResponse.errorCode}`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const match = matchResponse.responseData.match;
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Server tạo ticket cho user cụ thể
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import {
|
|
233
|
+
ErrorCode,
|
|
234
|
+
GNNetwork,
|
|
235
|
+
MultiplayerModels,
|
|
236
|
+
} from "@xmobitea/gn-typescript-client";
|
|
237
|
+
|
|
238
|
+
const request = new MultiplayerModels.ServerCreateMatchmakingTicketRequestData();
|
|
239
|
+
request.userId = "1234567890";
|
|
240
|
+
request.giveUpAfterSeconds = 60;
|
|
241
|
+
request.queueName = "ranked01";
|
|
242
|
+
|
|
243
|
+
const response = await GNNetwork.multiplayer.server.createMatchmakingTicketAsync(request);
|
|
244
|
+
|
|
245
|
+
if (response.hasReturnCodeError()) {
|
|
246
|
+
throw new Error(response.debugMessage);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
250
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const ticketId = response.responseData.ticketId;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Admin list ticket theo status
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
import {
|
|
260
|
+
ErrorCode,
|
|
261
|
+
GNNetwork,
|
|
262
|
+
MultiplayerModels,
|
|
263
|
+
MatchmakingTicketStatus,
|
|
264
|
+
} from "@xmobitea/gn-typescript-client";
|
|
265
|
+
|
|
266
|
+
const request = new MultiplayerModels.AdminGetAllMatchmakingTicketRequestData();
|
|
267
|
+
request.status = MatchmakingTicketStatus.WaitingForMatch;
|
|
268
|
+
request.limit = 20;
|
|
269
|
+
request.returnMember = false;
|
|
270
|
+
|
|
271
|
+
const response = await GNNetwork.multiplayer.admin.getAllMatchmakingTicketAsync(request);
|
|
272
|
+
|
|
273
|
+
if (response.hasReturnCodeError()) {
|
|
274
|
+
throw new Error(response.debugMessage);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
278
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const tickets = response.responseData.results;
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## 11. Anti-Patterns
|
|
285
|
+
|
|
286
|
+
- Không dùng socket để tạo hoặc query matchmaking ticket.
|
|
287
|
+
- Không chờ `createMatchmakingTicketAsync` trả match object.
|
|
288
|
+
- Không hardcode numeric status nếu enum đã có.
|
|
289
|
+
- Không giả định `GetMatchResponseData` có IP/port server.
|
|
290
|
+
- Không bỏ qua `userId` ở namespace `server/admin` khi model yêu cầu.
|
|
291
|
+
- Không bật `returnMember` cho mọi request nếu không cần.
|
|
292
|
+
- Không bỏ qua kiểm tra `returnCode` và `errorCode`.
|
|
293
|
+
|
|
294
|
+
## 12. AI Checklist
|
|
295
|
+
|
|
296
|
+
- Đã `GNNetwork.init(settings)` chưa.
|
|
297
|
+
- Có chọn đúng namespace `multiplayer` / `multiplayer.server` / `multiplayer.admin` chưa.
|
|
298
|
+
- Có nhớ rằng `MultiplayerApi` hiện chỉ đi qua HTTP không.
|
|
299
|
+
- Nếu đang tạo ticket, có hiểu rằng response chỉ trả `ticketId` không.
|
|
300
|
+
- Nếu cần biết đã matched chưa, có poll `getMatchmakingTicketAsync` chưa.
|
|
301
|
+
- Nếu đang ở `server/admin`, model hiện tại có yêu cầu `userId` không.
|
|
302
|
+
- Nếu đang lọc status, có dùng enum `MatchmakingTicketStatus` không.
|
|
303
|
+
- Có tránh giả định response match sẽ trả server endpoint không.
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# StoreInventoryApi
|
|
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`, dùng đúng enum cho store flow, và không sinh sai request ở các nhóm mua/quà/receipt/log.
|
|
4
|
+
|
|
5
|
+
## 1. Scope
|
|
6
|
+
|
|
7
|
+
- Áp dụng cho:
|
|
8
|
+
- `GNNetwork.storeInventory`
|
|
9
|
+
- `GNNetwork.storeInventory.server`
|
|
10
|
+
- `GNNetwork.storeInventory.admin`
|
|
11
|
+
- Toàn bộ method hiện tại của `StoreInventoryApi` đều gửi qua HTTP.
|
|
12
|
+
- `StoreInventoryApi` có đủ 3 role thật:
|
|
13
|
+
- `GNNetwork.storeInventory` -> `RequestRole.Client`
|
|
14
|
+
- `GNNetwork.storeInventory.server` -> `RequestRole.Server`
|
|
15
|
+
- `GNNetwork.storeInventory.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 semantics permission xem [RULES](../RULES.md#3-route--trust-boundary-của-caller). Với nhóm này, không tự suy diễn route chỉ từ target ownership.
|
|
20
|
+
- Khác với `MultiplayerApi`, namespace `server/admin` ở đây không thêm field `userId`; payload shape giữa 3 role hiện gần như giống nhau.
|
|
21
|
+
|
|
22
|
+
## 2. Hard Rules
|
|
23
|
+
|
|
24
|
+
- Luôn ưu tiên `async/await`. Mặc định dùng `*Async()`.
|
|
25
|
+
- Bắt buộc đã `GNNetwork.init(settings)` trước khi gọi.
|
|
26
|
+
- Không dùng socket cho `StoreInventoryApi`.
|
|
27
|
+
- Không hardcode số cho `storeItemType`, `storeReceiveTypes` hoặc `type` nếu enum đã có.
|
|
28
|
+
- `getStoreItemInformationAsync`, `getStoreItemsWithTagAsync` và `getCreateLeaderboardAsync` đều bắt buộc có `infoRequestParam`.
|
|
29
|
+
- `getStoreLogAsync` dùng `token` để phân trang tiếp, không dùng `skip`.
|
|
30
|
+
- `createStoreItemAsync` có `storeId` optional; nếu bạn bỏ trống, backend có thể tự sinh `storeId`.
|
|
31
|
+
- `removeStoreUsedAsync` có `ownerIds` optional; nếu chưa có backend spec rõ ràng, không được bỏ trống trường này một cách mù quáng.
|
|
32
|
+
|
|
33
|
+
## 3. Chọn Namespace
|
|
34
|
+
|
|
35
|
+
| Namespace | Role thật | Dùng khi nào |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| `GNNetwork.storeInventory` | `Client` | client/player mua item hoặc đọc store catalog cho chính session hiện tại |
|
|
38
|
+
| `GNNetwork.storeInventory.server` | `Server` | trusted backend, server worker, purchase fulfillment |
|
|
39
|
+
| `GNNetwork.storeInventory.admin` | `Admin` | dashboard, ops, GM tool, quản trị store |
|
|
40
|
+
|
|
41
|
+
Rule nhanh:
|
|
42
|
+
|
|
43
|
+
- Nếu flow mua/validate diễn ra từ player app: ưu tiên `GNNetwork.storeInventory`.
|
|
44
|
+
- Nếu flow này chạy ở backend tin cậy: ưu tiên `GNNetwork.storeInventory.server`.
|
|
45
|
+
- Nếu thao tác vận hành hoặc quản trị catalog/log: ưu tiên `GNNetwork.storeInventory.admin`.
|
|
46
|
+
|
|
47
|
+
## 4. Chọn Method
|
|
48
|
+
|
|
49
|
+
### Catalog và discovery
|
|
50
|
+
|
|
51
|
+
| Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú | ErrorCode
|
|
52
|
+
| --- | --- | --- | --- | --- | --- |
|
|
53
|
+
| `createStoreItemAsync` | Tạo store item mới | `storeId?`, `displayName?` | `CreateStoreItemResponseData` | Nếu bỏ `storeId`, backend có thể sinh id | `Ok`, `StoreItemExists` |
|
|
54
|
+
| `setStoreItemInformationAsync` | Cập nhật catalog, giá, IAP mapping, metadata | `storeId` và field cần đổi | `StoreInventoryResponseData` | `storeItemType` nên map bằng enum | `Ok`, `StoreItemNotFound`, `StoreInvalid` |
|
|
55
|
+
| `setRemoveStatusAsync` | Đánh dấu remove/hide store item | `storeId`, `reason?` | `EmptyResponseData` | Thường dùng để disable item | `Ok`, `StoreItemNotFound` |
|
|
56
|
+
| `getStoreItemInformationAsync` | Đọc chi tiết một store item | `storeId`, `infoRequestParam` | `StoreInventoryResponseData` | Chỉ bật field thật sự cần trong `infoRequestParam` | `Ok`, `StoreItemNotFound` |
|
|
57
|
+
| `getStoreItemsWithTagAsync` | Tìm store item theo tag | `key`, `value`, `infoRequestParam`, `skip?`, `limit?` | `StoreInventoriesWithStoreIdResponseData` | Hữu ích cho listing/filter | `Ok` |
|
|
58
|
+
| `getCreateLeaderboardAsync` | Lấy leaderboard create của store item | `infoRequestParam`, `skip?`, `limit?`, `loadFromCache?` | `GetCreateLeaderboardResponseData` | Response có `position` | `Ok` |
|
|
59
|
+
|
|
60
|
+
### Purchase, gift và receipt
|
|
61
|
+
|
|
62
|
+
| Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú | ErrorCode
|
|
63
|
+
| --- | --- | --- | --- | --- | --- |
|
|
64
|
+
| `buyStoreItemAsync` | Mua store item bằng flow nội bộ | `storeId`, `id`, `type`, `log?` | `BuyStoreInventoryResponseData` | `type` nên map bằng `OwnerType` | `Ok`, `NotEnoughCurrency`, `StoreItemNotFound`, `BuyerNotFound`, `CanNotBuyThisStoreItem`, `StoreItemRemoved`, `StoreItemPurchasedAndNonConsumable` |
|
|
65
|
+
| `presentStoreItemAsync` | Tặng/phát store item | `storeId`, `id`, `type`, `log?` | `PresentStoreInventoryResponseData` | `type` nên map bằng `OwnerType` | `Ok`, `StoreItemNotFound`, `BuyerNotFound`, `StoreItemRemoved`, `StoreItemPurchasedAndNonConsumable` |
|
|
66
|
+
| `validateAppleAppStoreReceiptAsync` | Validate receipt Apple và fulfill purchase | `receipt`, `id`, `type`, `log?` | `BuyStoreInventoryResponseData` | `type` nên map bằng `OwnerType` | `Ok`, `StoreItemNotFound`, `BuyerNotFound`, `ExceptionWhenValidateReceipt`, `StoreInvalid`, `ReceiptInvalid`, `StoreItemRemoved`, `StoreItemPurchasedAndNonConsumable` |
|
|
67
|
+
| `validateFacebookStoreReceiptAsync` | Validate receipt Facebook và fulfill purchase | `receipt`, `id`, `type`, `log?` | `BuyStoreInventoryResponseData` | `type` nên map bằng `OwnerType` | `Ok`, `StoreItemNotFound`, `BuyerNotFound`, `ExceptionWhenValidateReceipt`, `StoreInvalid`, `ReceiptInvalid`, `StoreItemRemoved`, `StoreItemPurchasedAndNonConsumable` |
|
|
68
|
+
| `validateGooglePlayStoreReceiptAsync` | Validate receipt Google Play và fulfill purchase | `receipt`, `id`, `type`, `log?` | `BuyStoreInventoryResponseData` | `type` nên map bằng `OwnerType` | `Ok`, `StoreItemNotFound`, `BuyerNotFound`, `ExceptionWhenValidateReceipt`, `StoreInvalid`, `ReceiptInvalid`, `StoreItemRemoved`, `StoreItemPurchasedAndNonConsumable` |
|
|
69
|
+
|
|
70
|
+
### Audit và used state
|
|
71
|
+
|
|
72
|
+
| Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú |
|
|
73
|
+
| --- | --- | --- | --- | --- |
|
|
74
|
+
| `getStoreLogAsync` | Đọc transaction log của store | `storeId?`, `storeReceiveTypes?`, `id?`, `limit?`, `token?` | `GetStoreLogResponseData` | `token` là cursor cho page tiếp |
|
|
75
|
+
| `getStoreUsedAsync` | Xem owner nào đã dùng store item | `storeId` | `GetStoreUsedResponseData` | Trả list owner id/type |
|
|
76
|
+
| `removeStoreUsedAsync` | Xóa used state của một hoặc nhiều owner | `storeId`, `ownerIds?` | `EmptyResponseData` | Chỉ gọi khi hiểu rõ hậu quả |
|
|
77
|
+
|
|
78
|
+
## 5. Enum và Reference
|
|
79
|
+
|
|
80
|
+
- DTO fields: [reference/dto/STORE_INVENTORY.md](../reference/dto/STORE_INVENTORY.md). Method table: [reference/API_STORE_INVENTORY.md](../reference/API_STORE_INVENTORY.md).
|
|
81
|
+
- Enums: [StoreItemType](../reference/ENUMS.md#storeitemtype), [StoreReceiveType](../reference/ENUMS.md#storereceivetype), [OwnerType](../reference/ENUMS.md#ownertype).
|
|
82
|
+
- Fallback `dist` chỉ khi reference docs chưa đủ: `dist/runtime/entity/models/StoreInventory*.d.ts`.
|
|
83
|
+
- `SetStoreItemInformationRequestData.storeItemType` có range `1..2`, nên map bằng `StoreItemType`.
|
|
84
|
+
- `GetStoreLogRequestData.storeReceiveTypes` nên map bằng `StoreReceiveType`.
|
|
85
|
+
- `BuyStoreItemRequestData.type`, `PresentStoreItemRequestData.type` và các request validate receipt, là OwnerType; theo model/response hiện tại map bằng `OwnerType`.
|
|
86
|
+
|
|
87
|
+
## 6. InfoRequestParam Rules
|
|
88
|
+
|
|
89
|
+
`StoreInventoryModels.InfoRequestParam` điều khiển payload trả về trong:
|
|
90
|
+
|
|
91
|
+
- `getStoreItemInformationAsync`
|
|
92
|
+
- `getStoreItemsWithTagAsync`
|
|
93
|
+
- `getCreateLeaderboardAsync`
|
|
94
|
+
|
|
95
|
+
Rule cứng:
|
|
96
|
+
|
|
97
|
+
- Không truyền `null`.
|
|
98
|
+
- Không bật toàn bộ field một cách mù quáng.
|
|
99
|
+
- Chỉ bật field mà màn hình hoặc flow hiện tại thật sự cần.
|
|
100
|
+
|
|
101
|
+
Các field thường dùng:
|
|
102
|
+
|
|
103
|
+
- `storeItems`
|
|
104
|
+
- `storeItemType`
|
|
105
|
+
- `storeCurrencies`
|
|
106
|
+
- `priceCurrencies`
|
|
107
|
+
- `inAppPurchase`
|
|
108
|
+
- `removeStatus`
|
|
109
|
+
- `displayName`
|
|
110
|
+
- `avatar`
|
|
111
|
+
- `tsCreate`
|
|
112
|
+
- `tags`
|
|
113
|
+
- `storeDatas`
|
|
114
|
+
|
|
115
|
+
## 7. Decision Rules
|
|
116
|
+
|
|
117
|
+
- Cần tạo catalog item mới: dùng `createStoreItemAsync`, rồi nếu cần cấu hình chi tiết thì `setStoreItemInformationAsync`.
|
|
118
|
+
- Cần lấy chi tiết một store item: dùng `getStoreItemInformationAsync`.
|
|
119
|
+
- Cần listing theo tag: dùng `getStoreItemsWithTagAsync`.
|
|
120
|
+
- Cần đánh dấu item bị remove/hide: dùng `setRemoveStatusAsync`.
|
|
121
|
+
- Cần mua item theo flow nội bộ: dùng `buyStoreItemAsync`.
|
|
122
|
+
- Cần tặng item: dùng `presentStoreItemAsync`.
|
|
123
|
+
- Cần xác thực IAP receipt: dùng đúng method theo provider, không dùng chéo provider.
|
|
124
|
+
- Cần audit transaction: dùng `getStoreLogAsync`.
|
|
125
|
+
- Cần xem trạng thái used hoặc reset used: dùng `getStoreUsedAsync` và `removeStoreUsedAsync`.
|
|
126
|
+
|
|
127
|
+
## 8. Response Rules
|
|
128
|
+
|
|
129
|
+
Tất cả typed response của `StoreInventoryApi` đều có:
|
|
130
|
+
|
|
131
|
+
- `returnCode`
|
|
132
|
+
- `debugMessage`
|
|
133
|
+
- `invalidMembers`
|
|
134
|
+
- `errorCode`
|
|
135
|
+
- `responseData`
|
|
136
|
+
|
|
137
|
+
Rule kiểm tra response:
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
if (response.hasReturnCodeError()) {
|
|
141
|
+
throw new Error(response.debugMessage);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
145
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Những response chính AI cần nhớ:
|
|
150
|
+
|
|
151
|
+
- `createStoreItemAsync` trả `responseData.storeId`.
|
|
152
|
+
- `getStoreItemInformationAsync` trả `responseData.infoResponseParameters`.
|
|
153
|
+
- `getStoreItemsWithTagAsync` trả `responseData.results`.
|
|
154
|
+
- `setStoreItemInformationAsync` trả lại `StoreInventoryResponseData`.
|
|
155
|
+
- `buyStoreItemAsync` và các method validate receipt trả `BuyStoreInventoryResponseData`.
|
|
156
|
+
- `presentStoreItemAsync` trả `PresentStoreInventoryResponseData`.
|
|
157
|
+
- `getCreateLeaderboardAsync` trả `results` có `position` và store info.
|
|
158
|
+
- `getStoreLogAsync` trả `results` và có thể có `token` để gọi page tiếp.
|
|
159
|
+
- `getStoreUsedAsync` trả `results`.
|
|
160
|
+
|
|
161
|
+
### Cảnh báo implementation hiện tại
|
|
162
|
+
|
|
163
|
+
- Trong model hiện tại, `BuyStoreInventoryResponseData.storeItems` và `PresentStoreInventoryResponseData.storeItems` đang được decorate bằng `ParameterCode.StoreCurrencies`.
|
|
164
|
+
- Đây có thể là issue mapping của package hiện tại.
|
|
165
|
+
- Nếu bạn phụ thuộc mạnh vào field `storeItems`, hãy verify runtime thực tế thay vì giả định deserialize luôn đúng.
|
|
166
|
+
|
|
167
|
+
## 9. Best Practices
|
|
168
|
+
|
|
169
|
+
- Dùng enum thay vì số thô cho `StoreItemType`, `StoreReceiveType`, `OwnerType`.
|
|
170
|
+
- Với catalog query, giữ `infoRequestParam` tối giản.
|
|
171
|
+
- Với receipt validation, luôn gọi đúng provider method theo source receipt.
|
|
172
|
+
- Với `getStoreLogAsync`, dùng `token` để page tiếp thay vì tự suy diễn offset.
|
|
173
|
+
- Với `removeStoreUsedAsync`, chỉ truyền `ownerIds` đã được xác nhận rõ.
|
|
174
|
+
- Với `createStoreItemAsync`, nếu backend đã có convention sinh `storeId`, đừng tự phát minh format id mới trong client nếu không cần.
|
|
175
|
+
|
|
176
|
+
## 10. Ví dụ Khuyến Nghị
|
|
177
|
+
|
|
178
|
+
### Đọc store item với infoRequestParam tối giản
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import {
|
|
182
|
+
ErrorCode,
|
|
183
|
+
GNNetwork,
|
|
184
|
+
StoreInventoryModels,
|
|
185
|
+
} from "@xmobitea/gn-typescript-client";
|
|
186
|
+
|
|
187
|
+
const infoRequestParam = new StoreInventoryModels.InfoRequestParam();
|
|
188
|
+
infoRequestParam.displayName = true;
|
|
189
|
+
infoRequestParam.priceCurrencies = true;
|
|
190
|
+
infoRequestParam.storeItemType = true;
|
|
191
|
+
|
|
192
|
+
const request = new StoreInventoryModels.GetStoreItemInformationRequestData();
|
|
193
|
+
request.storeId = "store-item-001";
|
|
194
|
+
request.infoRequestParam = infoRequestParam;
|
|
195
|
+
|
|
196
|
+
const response = await GNNetwork.storeInventory.getStoreItemInformationAsync(request);
|
|
197
|
+
|
|
198
|
+
if (response.hasReturnCodeError()) {
|
|
199
|
+
throw new Error(response.debugMessage);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
203
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const storeInfo = response.responseData.infoResponseParameters;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Mua store item
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import {
|
|
213
|
+
ErrorCode,
|
|
214
|
+
GNNetwork,
|
|
215
|
+
OwnerType,
|
|
216
|
+
StoreInventoryModels,
|
|
217
|
+
} from "@xmobitea/gn-typescript-client";
|
|
218
|
+
|
|
219
|
+
const request = new StoreInventoryModels.BuyStoreItemRequestData();
|
|
220
|
+
request.storeId = "store-item-001";
|
|
221
|
+
request.id = "1234567890";
|
|
222
|
+
request.type = OwnerType.MasterPlayer;
|
|
223
|
+
request.log = "buy from shop popup";
|
|
224
|
+
|
|
225
|
+
const response = await GNNetwork.storeInventory.buyStoreItemAsync(request);
|
|
226
|
+
|
|
227
|
+
if (response.hasReturnCodeError()) {
|
|
228
|
+
throw new Error(response.debugMessage);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
232
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const result = response.responseData;
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Validate Google Play receipt
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
import {
|
|
242
|
+
ErrorCode,
|
|
243
|
+
GNNetwork,
|
|
244
|
+
OwnerType,
|
|
245
|
+
StoreInventoryModels,
|
|
246
|
+
} from "@xmobitea/gn-typescript-client";
|
|
247
|
+
|
|
248
|
+
const request = new StoreInventoryModels.ValidateGooglePlayStoreReceiptRequestData();
|
|
249
|
+
request.receipt = googleReceiptPayload;
|
|
250
|
+
request.id = "1234567890";
|
|
251
|
+
request.type = OwnerType.MasterPlayer;
|
|
252
|
+
request.log = "google-play-checkout";
|
|
253
|
+
|
|
254
|
+
const response = await GNNetwork.storeInventory.validateGooglePlayStoreReceiptAsync(request);
|
|
255
|
+
|
|
256
|
+
if (response.hasReturnCodeError()) {
|
|
257
|
+
throw new Error(response.debugMessage);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
261
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Đọc store log với filter và cursor
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
import {
|
|
269
|
+
ErrorCode,
|
|
270
|
+
GNNetwork,
|
|
271
|
+
StoreInventoryModels,
|
|
272
|
+
StoreReceiveType,
|
|
273
|
+
} from "@xmobitea/gn-typescript-client";
|
|
274
|
+
|
|
275
|
+
const request = new StoreInventoryModels.GetStoreLogRequestData();
|
|
276
|
+
request.storeId = "store-item-001";
|
|
277
|
+
request.storeReceiveTypes = [StoreReceiveType.Buy, StoreReceiveType.GooglePlayStore];
|
|
278
|
+
request.limit = 20;
|
|
279
|
+
|
|
280
|
+
const response = await GNNetwork.storeInventory.getStoreLogAsync(request);
|
|
281
|
+
|
|
282
|
+
if (response.hasReturnCodeError()) {
|
|
283
|
+
throw new Error(response.debugMessage);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (response.errorCode !== ErrorCode.Ok) {
|
|
287
|
+
throw new Error(`Business error: ${response.errorCode}`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const logs = response.responseData.results;
|
|
291
|
+
const nextToken = response.responseData.token;
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 11. Anti-Patterns
|
|
295
|
+
|
|
296
|
+
- Không hardcode số cho `storeItemType`, `storeReceiveTypes`, `type`.
|
|
297
|
+
- Không bỏ `infoRequestParam` ở các method bắt buộc.
|
|
298
|
+
- Không dùng receipt của provider này cho method validate của provider khác.
|
|
299
|
+
- Không dùng `getStoreLogAsync` như offset pagination khi API đã có `token`.
|
|
300
|
+
- Không bỏ trống `ownerIds` trong `removeStoreUsedAsync` nếu chưa hiểu backend sẽ xử lý thế nào.
|
|
301
|
+
- Không giả định `storeItems` trong response buy/present luôn deserialize đúng nếu bạn chưa verify runtime.
|
|
302
|
+
- Không bỏ qua kiểm tra `returnCode` và `errorCode`.
|
|
303
|
+
|
|
304
|
+
## 12. AI Checklist
|
|
305
|
+
|
|
306
|
+
- Đã `GNNetwork.init(settings)` chưa.
|
|
307
|
+
- Có chọn đúng namespace `storeInventory` / `storeInventory.server` / `storeInventory.admin` chưa.
|
|
308
|
+
- Có nhớ rằng `StoreInventoryApi` hiện chỉ đi qua HTTP không.
|
|
309
|
+
- Nếu request có numeric enum field, có dùng enum export thay vì số thô không.
|
|
310
|
+
- Nếu đang gọi `getStoreItemInformationAsync`, `getStoreItemsWithTagAsync` hoặc `getCreateLeaderboardAsync`, có truyền `infoRequestParam` chưa.
|
|
311
|
+
- Nếu đang đọc log, có dùng `token` cho page tiếp chưa.
|
|
312
|
+
- Nếu đang validate receipt, method có đúng provider không.
|
|
313
|
+
- Có kiểm tra `hasReturnCodeError()` trước `errorCode` chưa.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
llms-full.txt — optional generated bundle placeholder
|
|
2
|
+
|
|
3
|
+
Status: deprecated-safe stub.
|
|
4
|
+
|
|
5
|
+
This repository no longer treats this file as a primary AI reading source because
|
|
6
|
+
stale concatenated bundles can preserve outdated examples and broken relative
|
|
7
|
+
links. Use the source documents below instead; they are the canonical inputs.
|
|
8
|
+
|
|
9
|
+
Canonical reading order:
|
|
10
|
+
|
|
11
|
+
1. ../AGENTS.md
|
|
12
|
+
2. AI_CHEATSHEET.md
|
|
13
|
+
3. RULES.md
|
|
14
|
+
4. ai-manifest.json
|
|
15
|
+
5. reference/API_INDEX.md
|
|
16
|
+
6. guides/<DOMAIN>.md for the target domain
|
|
17
|
+
7. reference/dto/<DOMAIN>.md or grep reference/DTO_INDEX.md for DTO fields
|
|
18
|
+
8. dist/**/*.d.ts only when docs do not cover the public contract
|
|
19
|
+
|
|
20
|
+
Conflict rule:
|
|
21
|
+
|
|
22
|
+
- Cross-cutting route, permission, auth/socket, override, and error rules:
|
|
23
|
+
RULES.md wins.
|
|
24
|
+
- Method signatures, DTO fields, and enum names:
|
|
25
|
+
reference/API_<GROUP>.md, reference/dto/<DOMAIN>.md, reference/ENUMS.md, then
|
|
26
|
+
dist/**/*.d.ts win.
|
|
27
|
+
- This bundle placeholder never wins over source docs.
|
|
28
|
+
|
|
29
|
+
Important direct links:
|
|
30
|
+
|
|
31
|
+
- AI cheatsheet: AI_CHEATSHEET.md
|
|
32
|
+
- Cross-cutting rules: RULES.md
|
|
33
|
+
- Machine manifest: ai-manifest.json
|
|
34
|
+
- API index: reference/API_INDEX.md
|
|
35
|
+
- DTO index: reference/DTO_INDEX.md
|
|
36
|
+
- Enums: reference/ENUMS.md
|
|
37
|
+
- Config: reference/CONFIG.md
|
|
38
|
+
- Events: reference/EVENTS.md
|
|
39
|
+
- Error handling: reference/ERROR_HANDLING.md
|
|
40
|
+
- Cookbook: COOKBOOK.md
|
|
41
|
+
|
|
42
|
+
If a release needs a true full concatenated bundle again, regenerate it from the
|
|
43
|
+
current source docs and include a generation timestamp plus source commit hash.
|