@quenty/roblox-api-dump 1.0.1-canary.247.1597949.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/LICENSE.md +21 -0
- package/README.md +21 -0
- package/default.project.json +6 -0
- package/package.json +39 -0
- package/src/Server/RobloxApiClass.lua +267 -0
- package/src/Server/RobloxApiDump.lua +169 -0
- package/src/Server/RobloxApiDumpConstants.lua +11 -0
- package/src/Server/RobloxApiMember.lua +274 -0
- package/src/Server/RobloxApiUtils.lua +21 -0
- package/src/node_modules.project.json +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.1-canary.247.1597949.0 (2022-01-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add RobloxApiDump package. This pulls in the API dump and allows querying of the API surface. ([c5bf337](https://github.com/Quenty/NevermoreEngine/commit/c5bf337d80016f47abac026f7ef0281aeb487e8d))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2021 Quenty
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Roblox-Api-Dump
|
|
2
|
+
<div align="center">
|
|
3
|
+
<a href="http://quenty.github.io/NevermoreEngine/">
|
|
4
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
|
|
5
|
+
</a>
|
|
6
|
+
<a href="https://discord.gg/mhtGUS8">
|
|
7
|
+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/Quenty/NevermoreEngine/actions">
|
|
10
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
|
|
11
|
+
</a>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
Utility functions for grabbing the Roblox API from the web
|
|
15
|
+
|
|
16
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/RobloxApiDump">View docs →</a></div>
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
```
|
|
20
|
+
npm install @quenty/roblox-api-dump --save
|
|
21
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quenty/roblox-api-dump",
|
|
3
|
+
"version": "1.0.1-canary.247.1597949.0",
|
|
4
|
+
"description": "Utility functions for grabbing the Roblox API from the web",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Roblox",
|
|
7
|
+
"Nevermore",
|
|
8
|
+
"Lua",
|
|
9
|
+
"Http",
|
|
10
|
+
"API"
|
|
11
|
+
],
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Quenty/NevermoreEngine/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/Quenty/NevermoreEngine.git",
|
|
18
|
+
"directory": "src/roblox-api-dump/"
|
|
19
|
+
},
|
|
20
|
+
"funding": {
|
|
21
|
+
"type": "patreon",
|
|
22
|
+
"url": "https://www.patreon.com/quenty"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"contributors": [
|
|
26
|
+
"Quenty"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@quenty/baseobject": "3.4.1-canary.247.1597949.0",
|
|
30
|
+
"@quenty/httppromise": "3.5.2-canary.247.1597949.0",
|
|
31
|
+
"@quenty/loader": "3.3.1-canary.247.1597949.0",
|
|
32
|
+
"@quenty/promise": "3.5.2-canary.247.1597949.0",
|
|
33
|
+
"@quenty/table": "2.1.1"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "159794913fb32aedaf48d2a2d7808d50449f4c01"
|
|
39
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
Represents a specific Roblox class.
|
|
3
|
+
@class RobloxApiClass
|
|
4
|
+
]=]
|
|
5
|
+
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local Promise = require("Promise")
|
|
9
|
+
local RobloxApiDumpConstants = require("RobloxApiDumpConstants")
|
|
10
|
+
|
|
11
|
+
local RobloxApiClass = {}
|
|
12
|
+
RobloxApiClass.ClassName = "RobloxApiClass"
|
|
13
|
+
RobloxApiClass.__index = RobloxApiClass
|
|
14
|
+
|
|
15
|
+
--[=[
|
|
16
|
+
Constructs a new RobloxApiClass. See [RobloxApiDump.PromiseClass] to actually construct
|
|
17
|
+
this class.
|
|
18
|
+
@param robloxApiDump RobloxApiDump
|
|
19
|
+
@param data table
|
|
20
|
+
@return RobloxApiClass
|
|
21
|
+
]=]
|
|
22
|
+
function RobloxApiClass.new(robloxApiDump, data)
|
|
23
|
+
local self = setmetatable({}, RobloxApiClass)
|
|
24
|
+
|
|
25
|
+
--[[
|
|
26
|
+
{
|
|
27
|
+
"Members": [
|
|
28
|
+
...
|
|
29
|
+
],
|
|
30
|
+
"MemoryCategory": "Instances",
|
|
31
|
+
"Name": "PackageUIService",
|
|
32
|
+
"Superclass": "Instance",
|
|
33
|
+
"Tags": [
|
|
34
|
+
"NotCreatable",
|
|
35
|
+
"Service",
|
|
36
|
+
"NotReplicated"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
]]
|
|
40
|
+
self._robloxApiDump = assert(robloxApiDump, "No robloxApiDump")
|
|
41
|
+
self._data = assert(data, "No data")
|
|
42
|
+
|
|
43
|
+
return self
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
--[=[
|
|
47
|
+
Retrieves the raw class data
|
|
48
|
+
@return table
|
|
49
|
+
]=]
|
|
50
|
+
function RobloxApiClass:GetRawData()
|
|
51
|
+
return self._data
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
--[=[
|
|
55
|
+
Gets the class name.
|
|
56
|
+
@return string
|
|
57
|
+
]=]
|
|
58
|
+
function RobloxApiClass:GetClassName()
|
|
59
|
+
assert(type(self._data.Name) == "string", "Bad Name")
|
|
60
|
+
return self._data.Name
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
--[=[
|
|
64
|
+
Gets the class category.
|
|
65
|
+
@return string?
|
|
66
|
+
]=]
|
|
67
|
+
function RobloxApiClass:GetMemberCategory()
|
|
68
|
+
return self._data.MemoryCategory -- might be nil, stuff like "Data" or ""
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
--[=[
|
|
72
|
+
Retrieves the super class, or rejects.
|
|
73
|
+
@return Promise<RobloxApiClass>
|
|
74
|
+
]=]
|
|
75
|
+
function RobloxApiClass:PromiseSuperClass()
|
|
76
|
+
local superclass = self:GetSuperClassName()
|
|
77
|
+
if superclass then
|
|
78
|
+
return self._robloxApiDump:PromiseClass(superclass)
|
|
79
|
+
else
|
|
80
|
+
return Promise.rejected("No super class")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
--[=[
|
|
85
|
+
Returns a promise that resolves whether this class is of a specific type.
|
|
86
|
+
@param className string
|
|
87
|
+
@return Promise<boolean>
|
|
88
|
+
]=]
|
|
89
|
+
function RobloxApiClass:PromiseIsA(className)
|
|
90
|
+
if self:GetClassName() == className then
|
|
91
|
+
return Promise.resolved(true)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
return self:PromiseIsDescendantOf(className)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
--[=[
|
|
98
|
+
Returns a promise that resolves whether this class is a descendant of another
|
|
99
|
+
specific class.
|
|
100
|
+
|
|
101
|
+
@param className string
|
|
102
|
+
@return Promise<boolean>
|
|
103
|
+
]=]
|
|
104
|
+
function RobloxApiClass:PromiseIsDescendantOf(className)
|
|
105
|
+
return self:PromiseAllSuperClasses():Then(function(classes)
|
|
106
|
+
for _, class in pairs(classes) do
|
|
107
|
+
if class:GetClassName() == className then
|
|
108
|
+
return true
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
return false
|
|
113
|
+
end)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
--[=[
|
|
117
|
+
Returns a promise that resolves to all super classes.
|
|
118
|
+
@return Promise<{ RobloxApiClass }>
|
|
119
|
+
]=]
|
|
120
|
+
function RobloxApiClass:PromiseAllSuperClasses()
|
|
121
|
+
if self._allSuperClassesPromise then
|
|
122
|
+
return self._allSuperClassesPromise
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
local list = {}
|
|
126
|
+
|
|
127
|
+
local function chain(current)
|
|
128
|
+
return current:PromiseSuperClass()
|
|
129
|
+
:Then(function(superclass)
|
|
130
|
+
if superclass then
|
|
131
|
+
table.insert(list, superclass)
|
|
132
|
+
return chain(superclass)
|
|
133
|
+
else
|
|
134
|
+
return list
|
|
135
|
+
end
|
|
136
|
+
end)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
self._allSuperClassesPromise = chain(self)
|
|
140
|
+
return self._allSuperClassesPromise
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
--[=[
|
|
144
|
+
Returns the super class name
|
|
145
|
+
@return string?
|
|
146
|
+
]=]
|
|
147
|
+
function RobloxApiClass:GetSuperClassName()
|
|
148
|
+
local data = self._data.Superclass
|
|
149
|
+
if data == RobloxApiDumpConstants.ROOT_CLASS_NAME then
|
|
150
|
+
return nil
|
|
151
|
+
else
|
|
152
|
+
return data
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
--[=[
|
|
157
|
+
Returns whether the class has a super class
|
|
158
|
+
@return boolean
|
|
159
|
+
]=]
|
|
160
|
+
function RobloxApiClass:HasSuperClass()
|
|
161
|
+
return self:GetSuperClassName() ~= nil
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
--[=[
|
|
165
|
+
Retrieves all class members (events, properties, callbacks, functions).
|
|
166
|
+
@return Promise<{ RobloxApiMember }>
|
|
167
|
+
]=]
|
|
168
|
+
function RobloxApiClass:PromiseMembers()
|
|
169
|
+
return self._robloxApiDump:PromiseMembers(self:GetClassName())
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
--[=[
|
|
173
|
+
Gets all class properties.
|
|
174
|
+
@return Promise<{ RobloxApiMember }>
|
|
175
|
+
]=]
|
|
176
|
+
function RobloxApiClass:PromiseProperties()
|
|
177
|
+
return self:PromiseMembers()
|
|
178
|
+
:Then(function(members)
|
|
179
|
+
local result = {}
|
|
180
|
+
for _, member in pairs(members) do
|
|
181
|
+
if member:IsProperty() then
|
|
182
|
+
table.insert(result, member)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
return result
|
|
186
|
+
end)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
--[=[
|
|
190
|
+
Gets all class events.
|
|
191
|
+
@return Promise<{ RobloxApiMember }>
|
|
192
|
+
]=]
|
|
193
|
+
function RobloxApiClass:PromiseEvents()
|
|
194
|
+
return self:PromiseMembers()
|
|
195
|
+
:Then(function(members)
|
|
196
|
+
local result = {}
|
|
197
|
+
for _, member in pairs(members) do
|
|
198
|
+
if member:IsEvent() then
|
|
199
|
+
table.insert(result, member)
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
return result
|
|
203
|
+
end)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
--[=[
|
|
207
|
+
Gets all class functions (i.e. methods).
|
|
208
|
+
@return Promise<{ RobloxApiMember }>
|
|
209
|
+
]=]
|
|
210
|
+
function RobloxApiClass:PromiseFunctions()
|
|
211
|
+
return self:PromiseMembers()
|
|
212
|
+
:Then(function(members)
|
|
213
|
+
local result = {}
|
|
214
|
+
for _, member in pairs(members) do
|
|
215
|
+
if member:IsFunction() then
|
|
216
|
+
table.insert(result, member)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
return result
|
|
220
|
+
end)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
--[=[
|
|
224
|
+
Retrieves whether the class is a service
|
|
225
|
+
@return boolean
|
|
226
|
+
]=]
|
|
227
|
+
function RobloxApiClass:IsService()
|
|
228
|
+
return self:HasTag("Service")
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
--[=[
|
|
232
|
+
Retrieves whether the class is not creatable
|
|
233
|
+
@return boolean
|
|
234
|
+
]=]
|
|
235
|
+
function RobloxApiClass:IsNotCreatable()
|
|
236
|
+
return self:HasTag("NotCreatable")
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
--[=[
|
|
240
|
+
Retrieves whether the class is not replicated
|
|
241
|
+
@return boolean
|
|
242
|
+
]=]
|
|
243
|
+
function RobloxApiClass:IsNotReplicated()
|
|
244
|
+
return self:HasTag("NotReplicated")
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
--[=[
|
|
248
|
+
Retrieves whether the class has a tag or not
|
|
249
|
+
@param tagName string
|
|
250
|
+
@return boolean
|
|
251
|
+
]=]
|
|
252
|
+
function RobloxApiClass:HasTag(tagName)
|
|
253
|
+
if self._tagCache then
|
|
254
|
+
return self._tagCache[tagName] == true
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
self._tagCache = {}
|
|
258
|
+
if type(self._data.Tags) == "table" then
|
|
259
|
+
for _, tag in pairs(self._data.Tags) do
|
|
260
|
+
self._tagCache[tag] = true
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
return self._tagCache[tagName] == true
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
return RobloxApiClass
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
Entry point for the Roblox API dump, this class contains api surfaces to
|
|
3
|
+
query the actual API.
|
|
4
|
+
@class RobloxApiDump
|
|
5
|
+
]=]
|
|
6
|
+
|
|
7
|
+
local require = require(script.Parent.loader).load(script)
|
|
8
|
+
|
|
9
|
+
local RobloxApiUtils = require("RobloxApiUtils")
|
|
10
|
+
local Promise = require("Promise")
|
|
11
|
+
local RobloxApiMember = require("RobloxApiMember")
|
|
12
|
+
local RobloxApiClass = require("RobloxApiClass")
|
|
13
|
+
local BaseObject = require("BaseObject")
|
|
14
|
+
local RobloxApiDumpConstants = require("RobloxApiDumpConstants")
|
|
15
|
+
|
|
16
|
+
local RobloxApiDump = setmetatable({}, BaseObject)
|
|
17
|
+
RobloxApiDump.ClassName = "RobloxApiDump"
|
|
18
|
+
RobloxApiDump.__index = RobloxApiDump
|
|
19
|
+
|
|
20
|
+
--[=[
|
|
21
|
+
Constructs a new RobloxApiDump which will cache all results for its lifetime.
|
|
22
|
+
@return RobloxApiDump
|
|
23
|
+
]=]
|
|
24
|
+
function RobloxApiDump.new()
|
|
25
|
+
local self = setmetatable(BaseObject.new(), RobloxApiDump)
|
|
26
|
+
|
|
27
|
+
self._classMemberPromises = {}
|
|
28
|
+
self._ancestorListPromise = {}
|
|
29
|
+
self._classPromises = {}
|
|
30
|
+
|
|
31
|
+
return self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
--[=[
|
|
35
|
+
Promises the Roblox API class for the given class name.
|
|
36
|
+
@param className string
|
|
37
|
+
@return RobloxApiClass
|
|
38
|
+
]=]
|
|
39
|
+
function RobloxApiDump:PromiseClass(className)
|
|
40
|
+
assert(type(className) == "string", "Bad className")
|
|
41
|
+
|
|
42
|
+
if self._classPromises[className] then
|
|
43
|
+
return self._classPromises[className]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
self._classPromises[className] = self:_promiseRawClassData(className)
|
|
47
|
+
:Then(function(classData)
|
|
48
|
+
return RobloxApiClass.new(self, classData)
|
|
49
|
+
end)
|
|
50
|
+
|
|
51
|
+
return self._classPromises[className]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
--[=[
|
|
55
|
+
Promises all Roblox API members.
|
|
56
|
+
@param className string
|
|
57
|
+
@return { RobloxApiMember }
|
|
58
|
+
]=]
|
|
59
|
+
function RobloxApiDump:PromiseMembers(className)
|
|
60
|
+
assert(type(className) == "string", "Bad className")
|
|
61
|
+
|
|
62
|
+
if self._classMemberPromises[className] then
|
|
63
|
+
return self._classMemberPromises[className]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
self._classMemberPromises[className] = self:_promiseClassDataAndAncestorList(className)
|
|
68
|
+
:Then(function(list)
|
|
69
|
+
local members = {}
|
|
70
|
+
for _, entry in pairs(list) do
|
|
71
|
+
if entry.Members then
|
|
72
|
+
for _, member in pairs(entry.Members) do
|
|
73
|
+
table.insert(members, RobloxApiMember.new(member))
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
return members
|
|
79
|
+
end)
|
|
80
|
+
|
|
81
|
+
return self._classMemberPromises[className]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
function RobloxApiDump:_promiseClassDataAndAncestorList(className)
|
|
85
|
+
assert(type(className) == "string", "Bad className")
|
|
86
|
+
|
|
87
|
+
if self._ancestorListPromise[className] then
|
|
88
|
+
return self._ancestorListPromise[className]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
self._ancestorListPromise[className] = self:_promiseClassMap()
|
|
92
|
+
:Then(function(classMap)
|
|
93
|
+
local current = classMap[className]
|
|
94
|
+
if not current then
|
|
95
|
+
return Promise.rejected(("Could not find data for %q"):format(className))
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
local dataList = {}
|
|
99
|
+
while current do
|
|
100
|
+
table.insert(dataList, current)
|
|
101
|
+
|
|
102
|
+
local superclass = current.Superclass
|
|
103
|
+
if superclass and superclass ~= RobloxApiDumpConstants.ROOT_CLASS_NAME then
|
|
104
|
+
current = classMap[superclass]
|
|
105
|
+
if not current then
|
|
106
|
+
return Promise.rejected(("Could not find data for super class %q"):format(superclass))
|
|
107
|
+
end
|
|
108
|
+
else
|
|
109
|
+
current = nil
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
return dataList
|
|
114
|
+
end)
|
|
115
|
+
|
|
116
|
+
return self._ancestorListPromise[className]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
function RobloxApiDump:_promiseRawClassData(className)
|
|
120
|
+
assert(type(className) == "string", "Bad className")
|
|
121
|
+
|
|
122
|
+
return self:_promiseClassMap()
|
|
123
|
+
:Then(function(classMap)
|
|
124
|
+
local data = classMap[className]
|
|
125
|
+
if data then
|
|
126
|
+
return data
|
|
127
|
+
else
|
|
128
|
+
return Promise.rejected(("Could not find data for %q"):format(className))
|
|
129
|
+
end
|
|
130
|
+
end)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
function RobloxApiDump:_promiseClassMap()
|
|
134
|
+
if self._classMapPromise then
|
|
135
|
+
return self._classMapPromise
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
self._classMapPromise = self:_promiseDump():Then(function(dump)
|
|
139
|
+
assert(dump.Version == 1, "Only able to parse version 1 of the dump")
|
|
140
|
+
|
|
141
|
+
local classMap = {}
|
|
142
|
+
for _, entry in pairs(dump.Classes) do
|
|
143
|
+
assert(type(entry) == "table", "Bad entry")
|
|
144
|
+
assert(type(entry.Name) == "string", "Bad entry.Name")
|
|
145
|
+
|
|
146
|
+
if classMap[entry.Name] then
|
|
147
|
+
warn(("[RobloxApiDump] - Duplicate entry for %q"):format(tostring(entry.Name)))
|
|
148
|
+
return
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
classMap[entry.Name] = entry
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
return classMap
|
|
155
|
+
end)
|
|
156
|
+
|
|
157
|
+
return self._classMapPromise
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
function RobloxApiDump:_promiseDump()
|
|
161
|
+
if self._dumpPromise then
|
|
162
|
+
return self._dumpPromise
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
self._dumpPromise = RobloxApiUtils.promiseDump()
|
|
166
|
+
return self._maid:GivePromise(self._dumpPromise)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
return RobloxApiDump
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
Represents a specific member of a class. This could be a property or event, or method, or callback.
|
|
3
|
+
@class RobloxApiMember
|
|
4
|
+
]=]
|
|
5
|
+
|
|
6
|
+
local RobloxApiMember = {}
|
|
7
|
+
RobloxApiMember.ClassName = "RobloxApiMember"
|
|
8
|
+
RobloxApiMember.__index = RobloxApiMember
|
|
9
|
+
|
|
10
|
+
--[=[
|
|
11
|
+
Constructs a new RobloxApiMember wrapping the data given. See [RobloxApiDump.PromiseMembers] to actually
|
|
12
|
+
construct this class.
|
|
13
|
+
@param data table
|
|
14
|
+
@return RobloxApiMember
|
|
15
|
+
]=]
|
|
16
|
+
function RobloxApiMember.new(data)
|
|
17
|
+
local self = setmetatable({}, RobloxApiMember)
|
|
18
|
+
|
|
19
|
+
--[[
|
|
20
|
+
{
|
|
21
|
+
"Category": "Data",
|
|
22
|
+
"MemberType": "Property",
|
|
23
|
+
"Name": "ClassName",
|
|
24
|
+
"Security": {
|
|
25
|
+
"Read": "None",
|
|
26
|
+
"Write": "None"
|
|
27
|
+
},
|
|
28
|
+
"Serialization": {
|
|
29
|
+
"CanLoad": false,
|
|
30
|
+
"CanSave": false
|
|
31
|
+
},
|
|
32
|
+
"Tags": [
|
|
33
|
+
"ReadOnly",
|
|
34
|
+
"NotReplicated"
|
|
35
|
+
],
|
|
36
|
+
"ThreadSafety": "ReadSafe",
|
|
37
|
+
"ValueType": {
|
|
38
|
+
"Category": "Primitive",
|
|
39
|
+
"Name": "string"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
]]
|
|
43
|
+
self._data = assert(data, "No data")
|
|
44
|
+
|
|
45
|
+
return self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
function RobloxApiMember:GetTypeName()
|
|
49
|
+
local valueType = self._data.ValueType
|
|
50
|
+
if valueType then
|
|
51
|
+
return valueType.Name
|
|
52
|
+
else
|
|
53
|
+
return nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
--[=[
|
|
58
|
+
Gets the member name.
|
|
59
|
+
@return string
|
|
60
|
+
]=]
|
|
61
|
+
function RobloxApiMember:GetName()
|
|
62
|
+
assert(type(self._data.Name) == "string", "Bad Name")
|
|
63
|
+
return self._data.Name
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
--[=[
|
|
67
|
+
Gets the member category.
|
|
68
|
+
@return string?
|
|
69
|
+
]=]
|
|
70
|
+
function RobloxApiMember:GetCategory()
|
|
71
|
+
return self._data.Category -- might be nil, stuff like "Data" or ""
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
--[=[
|
|
75
|
+
Retrieves whether the API member is read only.
|
|
76
|
+
@return boolean
|
|
77
|
+
]=]
|
|
78
|
+
function RobloxApiMember:IsReadOnly()
|
|
79
|
+
return self:HasTag("ReadOnly")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
--[=[
|
|
83
|
+
Retrieves the member type.
|
|
84
|
+
@return string
|
|
85
|
+
]=]
|
|
86
|
+
function RobloxApiMember:GetMemberType()
|
|
87
|
+
assert(type(self._data.MemberType) == "string", "Bad MemberType")
|
|
88
|
+
return self._data.MemberType
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
--[=[
|
|
92
|
+
Returns whether the member is an event.
|
|
93
|
+
@return boolean
|
|
94
|
+
]=]
|
|
95
|
+
function RobloxApiMember:IsEvent()
|
|
96
|
+
return self:GetMemberType() == "Event"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
--[=[
|
|
100
|
+
Retrieves the raw member data
|
|
101
|
+
@return table
|
|
102
|
+
]=]
|
|
103
|
+
function RobloxApiMember:GetRawData()
|
|
104
|
+
return self._data
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
--[=[
|
|
108
|
+
Returns whether this member has write NotAccessibleSecurity
|
|
109
|
+
@return boolean
|
|
110
|
+
]=]
|
|
111
|
+
function RobloxApiMember:IsWriteNotAccessibleSecurity()
|
|
112
|
+
return self:GetWriteSecurity() == "NotAccessibleSecurity"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
--[=[
|
|
116
|
+
Returns whether this member has write NotAccessibleSecurity
|
|
117
|
+
@return boolean
|
|
118
|
+
]=]
|
|
119
|
+
function RobloxApiMember:IsReadNotAccessibleSecurity()
|
|
120
|
+
return self:GetReadSecurity() == "NotAccessibleSecurity"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
--[=[
|
|
124
|
+
Returns whether this member has write LocalUserSecurity
|
|
125
|
+
@return boolean
|
|
126
|
+
]=]
|
|
127
|
+
function RobloxApiMember:IsWriteLocalUserSecurity()
|
|
128
|
+
return self:GetWriteSecurity() == "LocalUserSecurity"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
--[=[
|
|
132
|
+
Returns whether this member has read LocalUserSecurity
|
|
133
|
+
@return boolean
|
|
134
|
+
]=]
|
|
135
|
+
function RobloxApiMember:IsReadLocalUserSecurity()
|
|
136
|
+
return self:GetReadSecurity() == "LocalUserSecurity"
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
--[=[
|
|
140
|
+
Returns whether this can serialize save
|
|
141
|
+
@return boolean?
|
|
142
|
+
]=]
|
|
143
|
+
function RobloxApiMember:CanSerializeSave()
|
|
144
|
+
local serialization = self._data.Serialization
|
|
145
|
+
if type(serialization) == "table" then
|
|
146
|
+
return serialization.CanSave
|
|
147
|
+
else
|
|
148
|
+
return nil
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
--[=[
|
|
153
|
+
Returns whether this can serialize save
|
|
154
|
+
@return boolean?
|
|
155
|
+
]=]
|
|
156
|
+
function RobloxApiMember:CanSerializeLoad()
|
|
157
|
+
local serialization = self._data.Serialization
|
|
158
|
+
if type(serialization) == "table" then
|
|
159
|
+
return serialization.CanLoad
|
|
160
|
+
else
|
|
161
|
+
return nil
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
--[=[
|
|
166
|
+
Returns the member's write security as a string
|
|
167
|
+
@return string?
|
|
168
|
+
]=]
|
|
169
|
+
function RobloxApiMember:GetWriteSecurity()
|
|
170
|
+
local security = self._data.Security
|
|
171
|
+
if type(security) == "table" then
|
|
172
|
+
return security.Write
|
|
173
|
+
else
|
|
174
|
+
return nil
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
--[=[
|
|
179
|
+
Returns the member's read security as a string
|
|
180
|
+
@return string?
|
|
181
|
+
]=]
|
|
182
|
+
function RobloxApiMember:GetReadSecurity()
|
|
183
|
+
local security = self._data.Security
|
|
184
|
+
if type(security) == "table" then
|
|
185
|
+
return security.Write
|
|
186
|
+
else
|
|
187
|
+
return nil
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
--[=[
|
|
192
|
+
Returns whether the member is a property.
|
|
193
|
+
@return boolean
|
|
194
|
+
]=]
|
|
195
|
+
function RobloxApiMember:IsProperty()
|
|
196
|
+
return self:GetMemberType() == "Property"
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
--[=[
|
|
200
|
+
Returns whether the member is a function (i.e. method).
|
|
201
|
+
@return boolean
|
|
202
|
+
]=]
|
|
203
|
+
function RobloxApiMember:IsFunction()
|
|
204
|
+
return self:GetMemberType() == "Function"
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
--[=[
|
|
208
|
+
Returns whether the member is a callback.
|
|
209
|
+
@return boolean
|
|
210
|
+
]=]
|
|
211
|
+
function RobloxApiMember:IsCallback()
|
|
212
|
+
return self:GetMemberType() == "Callback"
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
--[=[
|
|
216
|
+
Returns whether a script can modify it.
|
|
217
|
+
@return boolean
|
|
218
|
+
]=]
|
|
219
|
+
function RobloxApiMember:IsNotScriptable()
|
|
220
|
+
return self:HasTag("NotScriptable")
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
--[=[
|
|
224
|
+
Returns whether the member is not replicated.
|
|
225
|
+
@return boolean
|
|
226
|
+
]=]
|
|
227
|
+
function RobloxApiMember:IsNotReplicated()
|
|
228
|
+
return self:HasTag("NotReplicated")
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
--[=[
|
|
232
|
+
Returns whether the member is deprecated..
|
|
233
|
+
]=]
|
|
234
|
+
function RobloxApiMember:IsDeprecated()
|
|
235
|
+
return self:HasTag("Deprecated")
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
--[=[
|
|
239
|
+
Returns whether this api member is hidden.
|
|
240
|
+
@return boolean
|
|
241
|
+
]=]
|
|
242
|
+
function RobloxApiMember:IsHidden()
|
|
243
|
+
return self:HasTag("Hidden")
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
--[=[
|
|
247
|
+
Returns a list of tags. Do not modify this list.
|
|
248
|
+
@return {string}
|
|
249
|
+
]=]
|
|
250
|
+
function RobloxApiMember:GetTags()
|
|
251
|
+
return self._data.Tags
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
--[=[
|
|
255
|
+
Retrieves whether the member has a tag or not.
|
|
256
|
+
@param tagName string
|
|
257
|
+
@return boolean
|
|
258
|
+
]=]
|
|
259
|
+
function RobloxApiMember:HasTag(tagName)
|
|
260
|
+
if self._tagCache then
|
|
261
|
+
return self._tagCache[tagName] == true
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
self._tagCache = {}
|
|
265
|
+
if type(self._data.Tags) == "table" then
|
|
266
|
+
for _, tag in pairs(self._data.Tags) do
|
|
267
|
+
self._tagCache[tag] = true
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
return self._tagCache[tagName] == true
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
return RobloxApiMember
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class RobloxApiUtils
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local HttpPromise = require("HttpPromise")
|
|
8
|
+
|
|
9
|
+
local API_DUMP_URL = "https://raw.githubusercontent.com/CloneTrooper1019/Roblox-Client-Watch/roblox/API-Dump.json"
|
|
10
|
+
|
|
11
|
+
local RobloxApiUtils = {}
|
|
12
|
+
|
|
13
|
+
--[=[
|
|
14
|
+
Retrieves the raw API dump from the web.
|
|
15
|
+
@return Promise<table>
|
|
16
|
+
]=]
|
|
17
|
+
function RobloxApiUtils.promiseDump()
|
|
18
|
+
return HttpPromise.json(API_DUMP_URL)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
return RobloxApiUtils
|