Software /
code /
prosody
Comparison
teal-src/module.d.tl @ 11941:cfd37453e6b6
teal: Describe the module API interface
Helps when writing modules in Teal
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Mar 2021 20:28:25 +0100 |
child | 12502:5862ddf71e3c |
comparison
equal
deleted
inserted
replaced
11940:2d82e4245aa3 | 11941:cfd37453e6b6 |
---|---|
1 local st = require"util.stanza" | |
2 | |
3 global record moduleapi | |
4 get_name : function (moduleapi) : string | |
5 get_host : function (moduleapi) : string | |
6 enum host_type | |
7 "global" | |
8 "local" | |
9 "component" | |
10 end | |
11 get_host_type : function (moduleapi) : host_type | |
12 set_global : function (moduleapi) | |
13 add_feature : function (moduleapi, string) | |
14 add_identity : function (moduleapi, string, string, string) -- TODO enum? | |
15 add_extension : function (moduleapi, st.stanza_t) | |
16 fire_event : function (moduleapi, string, any) : any | |
17 type handler = function (any) : any | |
18 record util_events | |
19 -- TODO import def | |
20 end | |
21 hook_object_event : function (moduleapi, util_events, string, handler, number) | |
22 unhook_object_event : function (moduleapi, util_events, string, handler) | |
23 hook : function (moduleapi, string, handler, number) | |
24 hook_global : function (moduleapi, string, handler, number) | |
25 hook_tag : function (moduleapi, string, string, handler, number) | |
26 unhook : function (moduleapi, string, handler) | |
27 wrap_object_event : function (moduleapi, util_events, string, handler) | |
28 wrap_event : function (moduleapi, string, handler) | |
29 wrap_global : function (moduleapi, string, handler) | |
30 require : function (moduleapi, string) : table | |
31 depends : function (moduleapi, string) : table | |
32 shared : function (moduleapi, string) : table | |
33 type config_getter = function<A> (moduleapi, string, A) : A | |
34 get_option : config_getter<any> | |
35 get_option_scalar : config_getter<nil | boolean | number | string> | |
36 get_option_string : config_getter<string> | |
37 get_option_number : config_getter<number> | |
38 get_option_boolean : config_getter<boolean> | |
39 record util_array | |
40 -- TODO import def | |
41 { any } | |
42 end | |
43 get_option_array : config_getter<util_array> | |
44 record util_set | |
45 -- TODO import def | |
46 _items : { any : boolean } | |
47 end | |
48 get_option_set : function (moduleapi, string, { any }) : util_set | |
49 get_option_inherited_set : function (moduleapi, string, { any }) : util_set | |
50 get_option_path : function (moduleapi, string, string, string) : string | |
51 context : function (moduleapi, string) : moduleapi | |
52 add_item : function (moduleapi, string, any) | |
53 remove_item : function (moduleapi, string, any) | |
54 get_host_items : function (moduleapi, string) : { any } | |
55 handle_items : function (moduleapi, string, handler, handler, boolean) | |
56 provides : function (moduleapi, string, table) | |
57 record util_session | |
58 -- TODO import def | |
59 send : function ( st.stanza_t | string ) | |
60 end | |
61 send : function (moduleapi, st.stanza_t, util_session) | |
62 send_iq : function (moduleapi, st.stanza_t, util_session, number) | |
63 broadcast : function (moduleapi, { string }, st.stanza_t, function) | |
64 type timer_callback = function (number, ... : any) : number | |
65 add_timer : function (moduleapi, number, timer_callback, ... : any) | |
66 get_directory : function (moduleapi) : string | |
67 enum file_mode | |
68 "r" "w" "a" "r+" "w+" "a+" | |
69 end | |
70 load_resource : function (moduleapi, string, file_mode) : FILE | |
71 enum store_type | |
72 "keyval" | |
73 "map" | |
74 "archive" | |
75 end | |
76 open_store : function (moduleapi, string, store_type) | |
77 enum stat_type | |
78 "amount" | |
79 "counter" | |
80 "rate" | |
81 "distribution" | |
82 "sizes" | |
83 "times" | |
84 end | |
85 record stats_conf | |
86 initial : number | |
87 units : string | |
88 type : string | |
89 end | |
90 measure : function (moduleapi, string, stat_type, stats_conf) | |
91 measure_object_event : function (moduleapi, util_events, string, string) | |
92 measure_event : function (moduleapi, string, string) | |
93 measure_global_event : function (moduleapi, string, string) | |
94 enum status_type | |
95 "error" | |
96 "warn" | |
97 "info" | |
98 "core" | |
99 end | |
100 set_status : function (moduleapi, status_type, string, boolean) | |
101 enum log_level | |
102 "debug" | |
103 "info" | |
104 "warn" | |
105 "error" | |
106 end | |
107 log_status : function (moduleapi, log_level, string, ... : any) | |
108 get_status : function (moduleapi) : status_type, string, number | |
109 | |
110 -- added by modulemanager | |
111 name : string | |
112 host : string | |
113 _log : function (log_level, string, ... : any) | |
114 log : function (moduleapi, log_level, string, ... : any) | |
115 reloading : boolean | |
116 saved_state : any | |
117 record module_environment | |
118 module : moduleapi | |
119 end | |
120 environment : module_environment | |
121 path : string | |
122 resource_path : string | |
123 | |
124 -- methods the module can add | |
125 load : function () | |
126 add_host : function (moduleapi) | |
127 save : function () : any | |
128 restore : function (any) | |
129 unload : function () | |
130 end | |
131 | |
132 global module : moduleapi | |
133 | |
134 global record common_event | |
135 stanza : st.stanza_t | |
136 record origin | |
137 send : function (st.stanza_t) | |
138 end | |
139 end | |
140 | |
141 global record prosody | |
142 version : string | |
143 end | |
144 | |
145 return module |