@quenty/datastore 13.51.1 → 13.52.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 +15 -0
- package/package.json +3 -2
- package/src/Client/Cmdr/DataStoreCmdrServiceClient.lua +48 -0
- package/src/Client/DataStoreServiceClient.lua +35 -0
- package/src/Server/Cmdr/DataStoreCmdrService.lua +454 -0
- package/src/Server/Cmdr/DataStoreCmdrService.spec.lua +370 -0
- package/src/Server/DataStore.lua +21 -0
- package/src/Server/DataStoreLockHelper.lua +8 -86
- package/src/Server/DataStoreService.lua +40 -0
- package/src/Server/Modules/DataStoreLockUtils.lua +139 -0
- package/src/Server/PlayerDataStoreHandle.lua +103 -0
- package/src/Server/PlayerDataStoreManager.Handles.spec.lua +136 -0
- package/src/Server/PlayerDataStoreManager.SessionLockTools.spec.lua +228 -0
- package/src/Server/PlayerDataStoreManager.lua +282 -0
- package/src/Server/PlayerDataStoreManager.spec.lua +86 -0
- package/src/Server/PlayerDataStoreService.lua +112 -0
- package/src/Server/PlayerDataStoreService.spec.lua +65 -0
- package/src/Shared/Cmdr/DataStoreCmdrUtils.lua +57 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[=[
|
|
3
|
+
Shared plumbing for the datastore Cmdr commands. Runs on both realms, so nothing here may reach
|
|
4
|
+
for a store -- those live on the server.
|
|
5
|
+
|
|
6
|
+
@class DataStoreCmdrUtils
|
|
7
|
+
]=]
|
|
8
|
+
|
|
9
|
+
local DataStoreCmdrUtils = {}
|
|
10
|
+
|
|
11
|
+
--[=[
|
|
12
|
+
Splits a slash-delimited sub-store path into its segments, dropping empty ones so a stray or
|
|
13
|
+
trailing slash is forgiving rather than an error. An empty path means the root store.
|
|
14
|
+
|
|
15
|
+
@param text string
|
|
16
|
+
@return { string }
|
|
17
|
+
]=]
|
|
18
|
+
function DataStoreCmdrUtils.parsePath(text: string): { string }
|
|
19
|
+
assert(type(text) == "string", "Bad text")
|
|
20
|
+
|
|
21
|
+
local path = {}
|
|
22
|
+
for segment in string.gmatch(text, "[^/]+") do
|
|
23
|
+
table.insert(path, segment)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
return path
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
--[=[
|
|
30
|
+
Registers the sub-store path type.
|
|
31
|
+
|
|
32
|
+
Cmdr resolves types against the executor, who cannot see another player's stores, so a path is
|
|
33
|
+
accepted as typed rather than completed against anything.
|
|
34
|
+
|
|
35
|
+
@param cmdr Cmdr
|
|
36
|
+
]=]
|
|
37
|
+
function DataStoreCmdrUtils.registerSubStoreType(cmdr: any): ()
|
|
38
|
+
local subStore = {
|
|
39
|
+
Transform = function(text: string)
|
|
40
|
+
if text ~= "" then
|
|
41
|
+
return { text }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
return {}
|
|
45
|
+
end,
|
|
46
|
+
Validate = function(keys: { string })
|
|
47
|
+
return #keys > 0, "Not a sub-store path."
|
|
48
|
+
end,
|
|
49
|
+
Parse = function(keys: { string })
|
|
50
|
+
return DataStoreCmdrUtils.parsePath(keys[1])
|
|
51
|
+
end,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
cmdr.Registry:RegisterType("dataStoreSubStore", subStore)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
return DataStoreCmdrUtils
|