Skip to content

Commit 9dbabce

Browse files
committed
Add typedlua defintions for more modules
1 parent e393790 commit 9dbabce

13 files changed

+161
-0
lines changed

http/bit.tld

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
band: (integer, integer) -> (integer)
2+
bor: (integer, integer) -> (integer)
3+
bxor: (integer, integer) -> (integer)

http/connection_common.tld

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
interface connection
2+
-- implements cqueues polling interface
3+
const pollfd: (self) -> (nil)|(integer) -- TODO: cqueues condition
4+
const events: (self) -> (nil)|(string|integer)
5+
const timeout: (self) -> (nil)|(number)
6+
7+
const checktls: (self) -> (nil)|(any) -- TODO: luaossl SSL object
8+
const localname: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
9+
const peername: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
10+
const onidle: (self, (connection)->()) -> ((connection)->())
11+
const connect: (self) -> (true)|(nil)|(nil, string, number)
12+
const flush: (self, number) -> (true)|(nil, string, number)
13+
const close: (self) -> (true)
14+
15+
-- Not in connection_common.lua
16+
const version: integer
17+
const unget: (self, string) -> (true)
18+
const shutdown: (self) -> (true)
19+
end

http/cookie.tld

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require "http.headers"
2+
3+
bake: (string, string, number?, string?, string?, true?, true?, string?) -> (string)
4+
5+
parse_cookie: (string) -> ({string:string})
6+
parse_cookies: (headers) -> ({{string:string}})
7+
parse_setcookie: (string) -> (string, string, {string:string})
8+
9+
interface cookie_store
10+
psl: any|false -- TODO: use psl type
11+
time: () -> (number)
12+
max_cookie_length: number
13+
max_cookies: number
14+
max_cookies_per_domain: number
15+
16+
const store: (self, string, string, boolean, boolean, string?, string, string, {string:string}) -> (boolean)
17+
const store_from_request: (self, headers, headers, string, string?) -> (boolean)
18+
const get: (self, string, string, string) -> (string)
19+
const remove: (self, string, string?, string?) -> ()
20+
const lookup: (self, string, string, boolean?, boolean?, boolean?, string?, boolean?, integer?) -> ()
21+
const lookup_for_request: (self, headers, string, string?, boolean?, integer?) -> ()
22+
const clean_due: (self) -> (number)
23+
const clean: (self) -> (boolean)
24+
const load_from_file: (self, file) -> (true) | (nil, string, integer)
25+
const save_to_file: (self, file) -> (true) | (nil, string, integer)
26+
end
27+
28+
new_store: () -> (cookie_store)

http/h1_reason_phrases.tld

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
reason_phrases: {string:string}

http/h2_error.tld

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
interface h2_error
2+
const new: (self, {
3+
"name": string?,
4+
"code": integer?,
5+
"description": string?,
6+
"message": string?,
7+
"traceback": string?,
8+
"stream_error": boolean?
9+
}) -> (h2_error)
10+
const new_traceback: (self, string, boolean, integer?) -> (h2_error)
11+
const error: (self, string, boolean, integer?) -> (void)
12+
end
13+
14+
errors: {any:h2_error}
15+
is: (any) -> (boolean)

http/hsts.tld

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
interface hsts_store
2+
time: () -> (number)
3+
max_items: number
4+
5+
clone: (self) -> (hsts_store)
6+
store: (self, string, {string:string}) -> (boolean)
7+
remove: (self, string) -> (boolean)
8+
check: (self, hsts_store) -> (boolean)
9+
const clean_due: (self) -> (number)
10+
const clean: (self) -> (boolean)
11+
end
12+
13+
new_store: () -> (hsts_store)

http/proxies.tld

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface proxies
2+
const update: (self, (string)->(string?))->(self)
3+
const choose: (self, string, string)->(string?)
4+
end
5+
6+
new: proxies

http/request.tld

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require "http.cookie"
2+
require "http.hsts"
3+
require "http.proxies"
4+
require "http.stream_common"
5+
6+
interface request
7+
hsts: hsts_store|false
8+
proxies: proxies|false
9+
cookie_store: cookie_store|false
10+
is_top_level: boolean
11+
site_for_cookies: string?
12+
expect_100_timeout: integer
13+
follow_redirects: boolean
14+
max_redirects: integer
15+
post301: boolean
16+
post302: boolean
17+
headers: headers
18+
const clone: (self) -> (request)
19+
const to_uri: (self, boolean?) -> (string)
20+
const handle_redirect: (self, headers) -> (request)|(nil, string, integer)
21+
const set_body: (self, string|file|()->(string?)) -> ()
22+
const go: (self, number) -> (headers, stream)|(nil, string, integer)
23+
end
24+
25+
new_from_uri: (string, headers?) -> (request)
26+
new_connect: (string, string) -> (request)

http/stream_common.tld

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require "http.connection_common"
2+
3+
interface stream
4+
const checktls: (self) -> (nil)|(any)
5+
const localname: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
6+
const peername: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
7+
const write_continue: (self, number?) -> (true)|(nil, string, number)
8+
const each_chunk: (self) -> ()
9+
const get_body_as_string: (self, number?) -> (string)|(nil, string, number)
10+
const get_body_chars: (self, integer, number?) -> (string)|(nil, string, number)
11+
const get_body_until: (self, string, boolean, boolean, number?) -> (string)|(nil, string, number)
12+
const save_body_to_file: (self, file, number?) -> (true)|(nil, string, number)
13+
const get_body_as_file: (self, number?) -> (file)|(nil, string, number)
14+
const write_body_from_string: (self, string, number?) -> (true)|(nil, string, number)
15+
const write_body_from_file: (self, {"file":file, "count": integer?}|file, number?) -> (true)|(nil, string, number)
16+
-- Not in stream_common.lua
17+
const connection: connection
18+
const write_headers: (self, headers, boolean, number?) -> (true)|(nil, string, number)
19+
const write_chunk: (self, string, boolean, number?) -> (true)|(nil, string, number)
20+
const unget: (self, string) -> (true)
21+
const shutdown: (self) -> (true)
22+
end

http/tls.tld

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
has_alpn: boolean
2+
has_hostname_validation: boolean
3+
modern_cipher_list: string
4+
intermediate_cipher_list: string
5+
old_cipher_list: string
6+
banned_ciphers: {string: true}
7+
-- TODO: luaossl SSL context type
8+
new_client_context: any
9+
new_server_context: any

http/util.tld

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
encodeURI: (string) -> (string)
2+
encodeURIComponent: (string) -> (string)
3+
decodeURI: (string) -> (string)
4+
decodeURIComponent: (string) -> (string)
5+
query_args: (string) -> ((any) -> (string, string), any, any)
6+
dict_to_query: ({string:string}) -> (string)
7+
resolve_relative_path: (orig_path, relative_path) -> (string)
8+
is_safe_method: (method) -> (boolean)
9+
is_ip: (string) -> (boolean)
10+
scheme_to_port: {string:integer}
11+
split_authority: (string, string) -> (string, integer)|(nil, string)
12+
to_authority: (string, integer, string|nil) -> (string)
13+
imf_date: (time) -> (string)
14+
maybe_quote: (string) -> (string)
15+
yieldable_pcall: ((any*) -> (any*), any*) -> (boolean, any*)

http/version.tld

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: string
2+
version: string

http/zlib.tld

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
inflate: () -> ((string, boolean) -> (string))
2+
deflate: () -> ((string, boolean) -> (string))

0 commit comments

Comments
 (0)