Annotate

teal-src/core/storagemanager.d.tl @ 12953:ebe3b2f96cad

mod_tokenauth: Switch to new token format (invalidates existing tokens!) The new format has the following properties: - 5 bytes longer than the previous format - The token now has separate 'id' and 'secret' parts - the token itself is no longer stored in the DB, and the secret part is hashed - The only variable length field (JID) has been moved to the end - The 'secret-token:' prefix (RFC 8959) is now included Compatibility with the old token format was not maintained, and all previously issued tokens are invalid after this commit (they will be removed from the DB if used).
author Matthew Wild <mwild1@gmail.com>
date Tue, 21 Mar 2023 14:33:29 +0000
parent 12802:4a8740e01813
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
1 -- Storage local record API Description
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 --
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 -- This is written as a TypedLua description
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 -- Key-Value stores (the default)
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
7 local stanza = require"util.stanza".stanza_t
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
8
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
9 local record keyval_store
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
10 get : function ( keyval_store, string ) : any , string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
11 set : function ( keyval_store, string, any ) : boolean, string
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 end
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 -- Map stores (key-key-value stores)
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
16 local record map_store
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
17 get : function ( map_store, string, any ) : any, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
18 set : function ( map_store, string, any, any ) : boolean, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
19 set_keys : function ( map_store, string, { any : any }) : boolean, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
20 remove : table
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 end
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 -- Archive stores
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
25 local record archive_query
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
26 start : number -- timestamp
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
27 ["end"]: number -- timestamp
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
28 with : string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
29 after : string -- archive id
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
30 before : string -- archive id
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
31 total : boolean
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
32 end
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
34 local record archive_store
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 -- Optional set of capabilities
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 caps : {
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 -- Optional total count of matching items returned as second return value from :find()
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
38 string : any
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
39 }
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
40
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
41 -- Add to the archive
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
42 append : function ( archive_store, string, string, any, number, string ) : string, string
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
43
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
44 -- Iterate over archive
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
45 type iterator = function () : string, any, number, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
46 find : function ( archive_store, string, archive_query ) : iterator, integer
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
47
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
48 -- Removal of items. API like find. Optional
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
49 delete : function ( archive_store, string, archive_query ) : boolean | number, string
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
50
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
51 -- Array of dates which do have messages (Optional)
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
52 dates : function ( archive_store, string ) : { string }, string
9903
2c5546cc5c70 mod_storage_internal: Implement a summary API returning message counts per contact
Kim Alvefur <zash@zash.se>
parents: 7744
diff changeset
53
2c5546cc5c70 mod_storage_internal: Implement a summary API returning message counts per contact
Kim Alvefur <zash@zash.se>
parents: 7744
diff changeset
54 -- Map of counts per "with" field
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
55 summary : function ( archive_store, string, archive_query ) : { string : integer }, string
10838
f26f2ec33f1e doc/storage: Add archive store map-like API
Kim Alvefur <zash@zash.se>
parents: 9903
diff changeset
56
f26f2ec33f1e doc/storage: Add archive store map-like API
Kim Alvefur <zash@zash.se>
parents: 9903
diff changeset
57 -- Map-store API
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
58 get : function ( archive_store, string, string ) : stanza, number, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
59 get : function ( archive_store, string, string ) : nil, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
60 set : function ( archive_store, string, string, stanza, number, string ) : boolean, string
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
61 end
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
62
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
63 -- This represents moduleapi
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
64 local record coremodule
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
65 -- If the first string is omitted then the name of the module is used
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
66 -- The second string is one of "keyval" (default), "map" or "archive"
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
67 open_store : function (archive_store, string, string) : keyval_store, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
68 open_store : function (archive_store, string, string) : map_store, string
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
69 open_store : function (archive_store, string, string) : archive_store, string
7744
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
70
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
71 -- Other module methods omitted
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
72 end
4d9186d990a5 doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff changeset
73
12607
8943ae10f7e8 core.storagemanager: Convert old Typed Lua description file into Teal
Kim Alvefur <zash@zash.se>
parents: 10838
diff changeset
74 return coremodule