@quenty/userserviceutils 9.14.0 → 9.14.1-canary.522.1d2faf4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/package.json +10 -9
- package/src/Shared/UserInfoAggregator.lua +37 -88
- package/src/Shared/UserInfoService.lua +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [9.14.1-canary.522.1d2faf4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/userserviceutils@9.14.0...@quenty/userserviceutils@9.14.1-canary.522.1d2faf4.0) (2024-12-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Fix username query ([a605933](https://github.com/Quenty/NevermoreEngine/commit/a605933b1375e0f0fc4e55f9d1c8dbf9e5893c4b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [9.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/userserviceutils@9.13.0...@quenty/userserviceutils@9.14.0) (2024-11-13)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/userserviceutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/userserviceutils",
|
|
3
|
-
"version": "9.14.0",
|
|
3
|
+
"version": "9.14.1-canary.522.1d2faf4.0",
|
|
4
4
|
"description": "Utilities involving UserService in Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,16 +25,17 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/
|
|
29
|
-
"@quenty/
|
|
30
|
-
"@quenty/
|
|
31
|
-
"@quenty/
|
|
32
|
-
"@quenty/
|
|
33
|
-
"@quenty/
|
|
34
|
-
"@quenty/
|
|
28
|
+
"@quenty/aggregator": "1.0.1-canary.522.1d2faf4.0",
|
|
29
|
+
"@quenty/baseobject": "10.7.1",
|
|
30
|
+
"@quenty/loader": "10.7.1",
|
|
31
|
+
"@quenty/maid": "3.4.0",
|
|
32
|
+
"@quenty/math": "2.7.0",
|
|
33
|
+
"@quenty/promise": "10.8.0",
|
|
34
|
+
"@quenty/rx": "13.13.1-canary.522.1d2faf4.0",
|
|
35
|
+
"@quenty/servicebag": "11.10.0"
|
|
35
36
|
},
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public"
|
|
38
39
|
},
|
|
39
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "1d2faf48e778ada6f57aecb8000c7c6c76ac33cd"
|
|
40
41
|
}
|
|
@@ -6,12 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
|
+
local Aggregator = require("Aggregator")
|
|
9
10
|
local BaseObject = require("BaseObject")
|
|
10
|
-
local Promise = require("Promise")
|
|
11
|
-
local UserServiceUtils = require("UserServiceUtils")
|
|
12
11
|
local Rx = require("Rx")
|
|
13
|
-
|
|
14
|
-
local MAX_USER_IDS_PER_REQUEST = 200
|
|
12
|
+
local UserServiceUtils = require("UserServiceUtils")
|
|
15
13
|
|
|
16
14
|
local UserInfoAggregator = setmetatable({}, BaseObject)
|
|
17
15
|
UserInfoAggregator.ClassName = "UserInfoAggregator"
|
|
@@ -20,11 +18,9 @@ UserInfoAggregator.__index = UserInfoAggregator
|
|
|
20
18
|
function UserInfoAggregator.new()
|
|
21
19
|
local self = setmetatable(BaseObject.new(), UserInfoAggregator)
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
self._unsentCount = 0
|
|
27
|
-
self._unsentPromises = {}
|
|
21
|
+
self._aggregator = self._maid:Add(Aggregator.new("UserServiceUtils.promiseUserInfosByUserIds", function(userIdList)
|
|
22
|
+
return UserServiceUtils.promiseUserInfosByUserIds(userIdList)
|
|
23
|
+
end))
|
|
28
24
|
|
|
29
25
|
return self
|
|
30
26
|
end
|
|
@@ -39,19 +35,7 @@ end
|
|
|
39
35
|
function UserInfoAggregator:PromiseUserInfo(userId)
|
|
40
36
|
assert(type(userId) == "number", "Bad userId")
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
return self._promises[userId]
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
local promise = Promise.new()
|
|
47
|
-
|
|
48
|
-
self._unsentPromises[userId] = promise
|
|
49
|
-
self._unsentCount = self._unsentCount + 1
|
|
50
|
-
self._promises[userId] = promise
|
|
51
|
-
|
|
52
|
-
self:_queueAggregatedPromises()
|
|
53
|
-
|
|
54
|
-
return promise
|
|
38
|
+
return self._aggregator:Promise(userId)
|
|
55
39
|
end
|
|
56
40
|
|
|
57
41
|
--[=[
|
|
@@ -63,24 +47,24 @@ end
|
|
|
63
47
|
function UserInfoAggregator:PromiseDisplayName(userId)
|
|
64
48
|
assert(type(userId) == "number", "Bad userId")
|
|
65
49
|
|
|
66
|
-
return self:
|
|
50
|
+
return self._aggregator:Promise(userId)
|
|
67
51
|
:Then(function(userInfo)
|
|
68
52
|
return userInfo.DisplayName
|
|
69
53
|
end)
|
|
70
54
|
end
|
|
71
55
|
|
|
72
56
|
--[=[
|
|
73
|
-
Promises the
|
|
57
|
+
Promises the Username for the userId
|
|
74
58
|
|
|
75
59
|
@param userId number
|
|
76
60
|
@return Promise<string>
|
|
77
61
|
]=]
|
|
78
|
-
function UserInfoAggregator:
|
|
62
|
+
function UserInfoAggregator:PromiseUsername(userId)
|
|
79
63
|
assert(type(userId) == "number", "Bad userId")
|
|
80
64
|
|
|
81
|
-
return self:
|
|
65
|
+
return self._aggregator:Promise(userId)
|
|
82
66
|
:Then(function(userInfo)
|
|
83
|
-
return userInfo.
|
|
67
|
+
return userInfo.Username
|
|
84
68
|
end)
|
|
85
69
|
end
|
|
86
70
|
|
|
@@ -93,7 +77,7 @@ end
|
|
|
93
77
|
function UserInfoAggregator:PromiseHasVerifiedBadge(userId)
|
|
94
78
|
assert(type(userId) == "number", "Bad userId")
|
|
95
79
|
|
|
96
|
-
return self:
|
|
80
|
+
return self._aggregator:Promise(userId)
|
|
97
81
|
:Then(function(userInfo)
|
|
98
82
|
return userInfo.HasVerifiedBadge
|
|
99
83
|
end)
|
|
@@ -108,7 +92,7 @@ end
|
|
|
108
92
|
function UserInfoAggregator:ObserveUserInfo(userId)
|
|
109
93
|
assert(type(userId) == "number", "Bad userId")
|
|
110
94
|
|
|
111
|
-
return
|
|
95
|
+
return self._aggregator:Observe(userId)
|
|
112
96
|
end
|
|
113
97
|
|
|
114
98
|
--[=[
|
|
@@ -120,78 +104,43 @@ end
|
|
|
120
104
|
function UserInfoAggregator:ObserveDisplayName(userId)
|
|
121
105
|
assert(type(userId) == "number", "Bad userId")
|
|
122
106
|
|
|
123
|
-
return self:
|
|
107
|
+
return self._aggregator:Observe(userId):Pipe({
|
|
124
108
|
Rx.map(function(userInfo)
|
|
125
109
|
return userInfo.DisplayName
|
|
126
110
|
end)
|
|
127
111
|
})
|
|
128
112
|
end
|
|
129
113
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
local userIds = {}
|
|
134
|
-
local unresolvedMap = {}
|
|
135
|
-
for userId, promise in pairs(promiseMap) do
|
|
136
|
-
table.insert(userIds, userId)
|
|
137
|
-
unresolvedMap[userId] = promise
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
if #userIds == 0 then
|
|
141
|
-
return
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
assert(#userIds <= MAX_USER_IDS_PER_REQUEST, "Too many userIds sent")
|
|
145
|
-
|
|
146
|
-
self._maid:GivePromise(UserServiceUtils.promiseUserInfosByUserIds(userIds))
|
|
147
|
-
:Then(function(result)
|
|
148
|
-
assert(type(result) == "table", "Bad result")
|
|
149
|
-
|
|
150
|
-
for _, data in pairs(result) do
|
|
151
|
-
assert(type(data.Id) == "number", "Bad result[?].Id")
|
|
152
|
-
|
|
153
|
-
if unresolvedMap[data.Id] then
|
|
154
|
-
unresolvedMap[data.Id]:Resolve(data)
|
|
155
|
-
unresolvedMap[data.Id] = nil
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
-- Reject other ones
|
|
160
|
-
for userId, promise in pairs(unresolvedMap) do
|
|
161
|
-
promise:Reject(string.format("Failed to get result for userId %d", userId))
|
|
162
|
-
end
|
|
163
|
-
end, function(...)
|
|
164
|
-
for _, item in pairs(unresolvedMap) do
|
|
165
|
-
item:Reject(...)
|
|
166
|
-
end
|
|
167
|
-
end)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
function UserInfoAggregator:_resetQueue()
|
|
171
|
-
local promiseMap = self._unsentPromises
|
|
114
|
+
--[=[
|
|
115
|
+
Observes the Username for the userId
|
|
172
116
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
117
|
+
@param userId number
|
|
118
|
+
@return Observable<string>
|
|
119
|
+
]=]
|
|
120
|
+
function UserInfoAggregator:ObserveUsername(userId)
|
|
121
|
+
assert(type(userId) == "number", "Bad userId")
|
|
176
122
|
|
|
177
|
-
return
|
|
123
|
+
return self._aggregator:Observe(userId):Pipe({
|
|
124
|
+
Rx.map(function(userInfo)
|
|
125
|
+
return userInfo.Username
|
|
126
|
+
end)
|
|
127
|
+
})
|
|
178
128
|
end
|
|
179
129
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
self:_sendAggregatedPromises(self:_resetQueue())
|
|
183
|
-
return
|
|
184
|
-
end
|
|
130
|
+
--[=[
|
|
131
|
+
Observes the user display name for the userId
|
|
185
132
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
133
|
+
@param userId number
|
|
134
|
+
@return Observable<boolean>
|
|
135
|
+
]=]
|
|
136
|
+
function UserInfoAggregator:ObserveHasVerifiedBadge(userId)
|
|
137
|
+
assert(type(userId) == "number", "Bad userId")
|
|
189
138
|
|
|
190
|
-
self.
|
|
191
|
-
|
|
192
|
-
|
|
139
|
+
return self._aggregator:Observe(userId):Pipe({
|
|
140
|
+
Rx.map(function(userInfo)
|
|
141
|
+
return userInfo.HasVerifiedBadge
|
|
193
142
|
end)
|
|
194
|
-
|
|
143
|
+
})
|
|
195
144
|
end
|
|
196
145
|
|
|
197
146
|
return UserInfoAggregator
|
|
@@ -42,7 +42,7 @@ end
|
|
|
42
42
|
function UserInfoService:ObserveUserInfo(userId)
|
|
43
43
|
assert(type(userId) == "number", "Bad userId")
|
|
44
44
|
|
|
45
|
-
return self._aggregator:
|
|
45
|
+
return self._aggregator:ObserveUserInfo(userId)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
--[=[
|
|
@@ -57,6 +57,18 @@ function UserInfoService:PromiseDisplayName(userId)
|
|
|
57
57
|
return self._aggregator:PromiseDisplayName(userId)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
--[=[
|
|
61
|
+
Promises the Username for the userId
|
|
62
|
+
|
|
63
|
+
@param userId number
|
|
64
|
+
@return Promise<string>
|
|
65
|
+
]=]
|
|
66
|
+
function UserInfoService:PromiseUsername(userId)
|
|
67
|
+
assert(type(userId) == "number", "Bad userId")
|
|
68
|
+
|
|
69
|
+
return self._aggregator:PromiseUsername(userId)
|
|
70
|
+
end
|
|
71
|
+
|
|
60
72
|
--[=[
|
|
61
73
|
Observes the user display name for the userId
|
|
62
74
|
|