Software /
code /
prosody
Annotate
doc/storage.tld @ 12579:ca6a43fe0231 0.12
util.jsonschema: Fix validation to not assume presence of "type" field
MattJ reported a curious issue where validation did not work as
expected. Primarily that the "type" field was expected to be mandatory,
and thus leaving it out would result in no checks being performed.
This was likely caused by misreading during initial development.
Spent some time testing against
https://github.com/json-schema-org/JSON-Schema-Test-Suite.git and
discovered a multitude of issues, far too many to bother splitting into
separate commits.
More than half of them fail. Many because of features not implemented,
which have been marked NYI. For example, some require deep comparisons
e.g. when objects or arrays are present in enums fields.
Some because of quirks with how Lua differs from JavaScript, e.g. no
distinct array or object types. Tests involving fractional floating
point numbers. We're definitely not going to follow references to remote
resources. Or deal with UTF-16 sillyness. One test asserted that 1.0 is
an integer, where Lua 5.3+ will disagree.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 08 Jul 2022 14:38:23 +0200 |
parent | 10838:f26f2ec33f1e |
rev | line source |
---|---|
7744
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- Storage Interface API Description |
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 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 interface keyval_store |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 get : ( self, string? ) -> (any) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 set : ( self, string?, any ) -> (boolean) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 end |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 -- 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
|
13 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 interface map_store |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 get : ( self, string?, any ) -> (any) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 set : ( self, string?, any, any ) -> (boolean) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 set_keys : ( self, string?, { any : any }) -> (boolean) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 remove : {} |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 end |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 -- Archive stores |
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 typealias archive_query = { |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 "start" : number?, -- timestamp |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 "end" : number?, -- timestamp |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 "with" : string?, |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 "after" : string?, -- archive id |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 "before" : string?, -- archive id |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 "total" : boolean?, |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 } |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 interface archive_store |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 -- Optional set of capabilities |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 caps : { |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 -- Optional total count of matching items returned as second return value from :find() |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 "total" : boolean?, |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 }? |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 -- Add to the archive |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 append : ( self, string?, string?, any, number?, string? ) -> (string) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 -- Iterate over archive |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 find : ( self, string?, archive_query? ) -> ( () -> ( string, any, number?, string? ), integer? ) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 -- Removal of items. API like find. Optional? |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 delete : ( self, string?, archive_query? ) -> (boolean) | (number) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 -- Array of dates which do have messages (Optional?) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
49 dates : ( self, string? ) -> ({ string }) | (nil, string) |
9903
2c5546cc5c70
mod_storage_internal: Implement a summary API returning message counts per contact
Kim Alvefur <zash@zash.se>
parents:
7744
diff
changeset
|
50 |
2c5546cc5c70
mod_storage_internal: Implement a summary API returning message counts per contact
Kim Alvefur <zash@zash.se>
parents:
7744
diff
changeset
|
51 -- Map of counts per "with" field |
2c5546cc5c70
mod_storage_internal: Implement a summary API returning message counts per contact
Kim Alvefur <zash@zash.se>
parents:
7744
diff
changeset
|
52 summary : ( self, string?, archive_query? ) -> ( { string : integer } ) | (nil, string) |
10838
f26f2ec33f1e
doc/storage: Add archive store map-like API
Kim Alvefur <zash@zash.se>
parents:
9903
diff
changeset
|
53 |
f26f2ec33f1e
doc/storage: Add archive store map-like API
Kim Alvefur <zash@zash.se>
parents:
9903
diff
changeset
|
54 -- Map-store API |
f26f2ec33f1e
doc/storage: Add archive store map-like API
Kim Alvefur <zash@zash.se>
parents:
9903
diff
changeset
|
55 get : ( self, string, string ) -> (stanza, number?, string?) | (nil, string) |
f26f2ec33f1e
doc/storage: Add archive store map-like API
Kim Alvefur <zash@zash.se>
parents:
9903
diff
changeset
|
56 set : ( self, string, string, stanza, number?, string? ) -> (boolean) | (nil, string) |
7744
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
57 end |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
58 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
59 -- This represents moduleapi |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
60 interface module |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
61 -- 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
|
62 -- The second string is one of "keyval" (default), "map" or "archive" |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
63 open_store : (self, string?, string?) -> (keyval_store) | (map_store) | (archive_store) | (nil, string) |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
64 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
65 -- Other module methods omitted |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
66 end |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
67 |
4d9186d990a5
doc: Add a description of the Storage API in TypedLua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
68 module : module |